How to use the rax.PropTypes.object function in rax

To help you get started, we’ve selected a few rax examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alibaba / rax / templates / template-taobao / templates / default / mods / Swipe.js View on Github external
import View from 'rax-view';
import PanResponder from 'universal-panresponder';
import isValidSwipe from './isValidSwipe';

const directions = {
  SWIPE_UP: 'SWIPE_UP',
  SWIPE_DOWN: 'SWIPE_DOWN',
  SWIPE_LEFT: 'SWIPE_LEFT',
  SWIPE_RIGHT: 'SWIPE_RIGHT'
};

const propTypes = {
  onSwipeBegin: PropTypes.func,
  onSwipe: PropTypes.func,
  onSwipeEnd: PropTypes.func,
  swipeDecoratorStyle: PropTypes.object
};


export default class SwipeEvent extends Component {
  constructor(props) {
    super(props);
    this.state = {
      swipe: {
        direction: null,
        distance: 0,
        velocity: 0
      }
    };

    // 监听swipe是否发生
    this.swipeDetected = false;
github alibaba / rax / packages / rax-countdown / src / index.js View on Github external
state = {
    timeRemaining: 0
  };

  timeoutId = 0;

  static propTypes = {
    formatFunc: PropTypes.func,
    onTick: PropTypes.func,
    onComplete: PropTypes.func,
    tpl: PropTypes.string, // template (example {h}:{m}:{s})
    timeRemaining: PropTypes.number,
    secondStyle: PropTypes.object,
    timeStyle: PropTypes.object, // style for num
    textStyle: PropTypes.object, // style for text
    timeWrapStyle: PropTypes.object,
    timeBackground: PropTypes.string,
    timeBackgroundStyle: PropTypes.object,
    interval: PropTypes.number
  };

  static defaultProps = {
    tpl: '{d}天{h}时{m}分{s}秒',
    timeRemaining: 0,
    interval: 1000
  };

  componentWillMount() {
    const {timeRemaining} = this.props;
    this.setState({
      timeRemaining: timeRemaining
    });
github alibaba / rax / packages / rax-countdown / src / index.js View on Github external
class Index extends Component {
  state = {
    timeRemaining: 0
  };

  timeoutId = 0;

  static propTypes = {
    formatFunc: PropTypes.func,
    onTick: PropTypes.func,
    onComplete: PropTypes.func,
    tpl: PropTypes.string, // template (example {h}:{m}:{s})
    timeRemaining: PropTypes.number,
    secondStyle: PropTypes.object,
    timeStyle: PropTypes.object, // style for num
    textStyle: PropTypes.object, // style for text
    timeWrapStyle: PropTypes.object,
    timeBackground: PropTypes.string,
    timeBackgroundStyle: PropTypes.object,
    interval: PropTypes.number
  };

  static defaultProps = {
    tpl: '{d}天{h}时{m}分{s}秒',
    timeRemaining: 0,
    interval: 1000
  };

  componentWillMount() {
    const {timeRemaining} = this.props;
    this.setState({
      timeRemaining: timeRemaining
github alibaba / rax / packages / rax-theme-lst / templates / default / pages / index / components / Cheap / offer.js View on Github external
import { PropTypes, Component, createElement } from 'rax';
import { View, Text, Image } from 'rax-components';
import OpenUrl from '../../mods/openUrl';

export default class CheapOffer extends Component {
  static propsTypes = {
    offerData: PropTypes.object,
    index: PropTypes.object
  }

  static defaultProps = {
    offerData: {}
  }

  render() {
    const {offerData} = this.props;
    const hasDiscount = offerData.discountPrice && offerData.discountPrice !== 0 && offerData.discountPrice < offerData.price;

    let discountPrice = hasDiscount ? offerData.discountPrice : offerData.price;
    let discount = 0;
    if (hasDiscount) {
      discount = Math.round(offerData.price * 100 - offerData.discountPrice * 100) / 100;
    }
github alibaba / rax / components / rax-tabheader / src / DropDown.js View on Github external
import TouchableHighlight from 'rax-touchable';
import {isWeex} from 'universal-env';
import MultiRow from 'rax-multirow';
import Animated from './animation';
import style from './style';

const TABEHEADER_SCTOLLTO = 'tabheaderScrollTo';
const TABEHEADER_SELECT = 'tabheaderSelect';
const TABEHEADER_GOTOP = 'tabheaderGoTop';
const DROPDOWN_ROW_HEIGHT = 80;
const WINDOWWIDTH = 750;


class DropDown extends Component {
  static contextTypes = {
    tabheader: PropTypes.object
  };

  constructor(props) {
    super(props);
    let itemNum = this.props.dataSource ? this.props.dataSource.length : 0;
    let cols = this.props.dropDownCols;
    this.dropDownHeight = Math.ceil(itemNum / cols) * DROPDOWN_ROW_HEIGHT;
    this.state = {
      weexGridTop: -1000,
      weexGridLeft: -1000,
      weexGridPosition: 'fixed',
      weexGridHeight: 0,
      selected: props.selected
    };
  }
github alibaba / rax / templates / template-retail / templates / default / pages / index / components / Promotion / rowCell.js View on Github external
<img style="{style.image}">
      
    );
  } else {
    return null;
  }
}

rowCell.propTypes = {
  dataSource: PropTypes.object,
  style: PropTypes.object,
  indexid: PropTypes.object
};

rowCell.defaultProps = {
  dataSource: {}
};

export default rowCell;
github alibaba / rax / components / rax-calendar / src / Day.js View on Github external
import {createElement, Component, PropTypes} from 'rax';
import View from 'rax-view';
import Text from 'rax-text';
import Touchable from 'rax-touchable';

import styles from './styles';

export default class Day extends Component {
  static defaultProps = {
    customStyle: {},
  }

  static propTypes = {
    caption: PropTypes.any,
    customStyle: PropTypes.object,
    filler: PropTypes.bool,
    hasEvent: PropTypes.bool,
    isSelected: PropTypes.bool,
    isToday: PropTypes.bool,
    isWeekend: PropTypes.bool,
    isDisabled: PropTypes.bool,
    onPress: PropTypes.func,
    usingEvents: PropTypes.bool,
  }

  dayCircleStyle = (isWeekend, isSelected, isToday) => {
    const { customStyle } = this.props;
    const dayCircleStyle = [styles.dayCircleFiller, customStyle.dayCircleFiller && customStyle.dayCircleFiller];

    if (isSelected && !isToday) {
      dayCircleStyle.push(styles.selectedDayCircle, customStyle.selectedDayCircle && customStyle.selectedDayCircle);
github alibaba / rax / templates / template-taobao / templates / default / mods / FlowView.js View on Github external
import {createElement, Component, PropTypes} from 'rax';
import View from 'rax-view';
import emitter from './Emitter';

class FlowView extends Component {
  static contextTypes = {
    page: PropTypes.object
  };
  componentWillMount() {
    let page = this.context.page;
    emitter.on('pageDidReachEnd', () => {
      this.props.onEndReached && this.props.onEndReached();
    });
    if (page) {
      page.on('pageEndReached', () => {
        this.props.onEndReached && this.props.onEndReached();
      });
    }
  }
  render() {
    let style = this.props.style || {};
    if (style.height !== undefined) {
      delete style.height;
github alibaba / rax / templates / template-retail / templates / default / pages / index / components / Cheap / offer.js View on Github external
import { PropTypes, Component, createElement } from 'rax';
import { View, Text, Image } from 'rax-components';
import OpenUrl from '../../mods/openUrl';

export default class CheapOffer extends Component {
  static propsTypes = {
    offerData: PropTypes.object,
    index: PropTypes.object
  }

  static defaultProps = {
    offerData: {}
  }

  render() {
    const {offerData} = this.props;
    const hasDiscount = offerData.discountPrice &amp;&amp; offerData.discountPrice !== 0 &amp;&amp; offerData.discountPrice &lt; offerData.price;

    let discountPrice = hasDiscount ? offerData.discountPrice : offerData.price;
    let discount = 0;
    if (hasDiscount) {
      discount = Math.round(offerData.price * 100 - offerData.discountPrice * 100) / 100;
    }
github alibaba / rax / packages / rax-tabheader / src / ItemList.js View on Github external
import {createElement, Component, findDOMNode, PropTypes} from 'rax';
import ScrollView from 'rax-scrollview';
import Item from './Item';
import AnimBuoy from './AnimBuoy';
import {Row, Col} from 'rax-grid';
import {isWeex} from 'universal-env';
import styles from './style';

const SCROLLVIEW_REF = 'scrollview';
const TABEHEADER_SCTOLLTO = 'tabheaderScrollTo';
const TABEHEADER_SELECT = 'tabheaderSelect';

class ItemList extends Component {
  static contextTypes = {
    tabheader: PropTypes.object
  };

  constructor(props) {
    super(props);
    this.state = {
      selected: props.selected
    };
  }

  componentWillMount() {
    let tabheader = this.context.tabheader;
    if (tabheader && tabheader.on) {
      tabheader.on(TABEHEADER_SCTOLLTO, (options) => {
        this.scrollTo(options);
      });
      tabheader.on(TABEHEADER_SELECT, (index) => {