function Button() { _classCallCheck(this, Button); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
Calendar.ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function CalendarView() { _classCallCheck(this, CalendarView); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
Century = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
Combobox.ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
ComboboxInput = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
DateTimePicker.ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
DateTimePickerInput = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
Decade = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
DropdownList.ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function DropdownListInput() { _classCallCheck(this, DropdownListInput); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
Footer = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
Header = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function Input() { _classCallCheck(this, Input); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
List = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
ListGroupable = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
ListOption = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
Month = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
Multiselect.ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function MultiselectInput() { _classCallCheck(this, MultiselectInput); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
MultiselectTagList = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
NumberInput = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
NumberPicker.ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
Popup = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function Select() { _classCallCheck(this, Select); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
SelectList.ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
TimeList = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function Widget() { _classCallCheck(this, Widget); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
Year = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function setAnimate(animatefn) { _configuration2.default.animate = animatefn; }
...
describe('when configuring dependencies', function(){
it('should use the instances provided', function(){
var animate = ()=>{};
expect(config.animate).to.not.equal(animate)
configure.setAnimate(animate)
expect(config.animate).to.equal(animate)
})
})
...
function setDate(spec) { (0, _invariant2.default)(typeof spec.format === 'function', 'date localizer `format(..)` must be a function'); (0, _invariant2.default)(typeof spec.parse === 'function', 'date localizer `parse(..)` must be a function'); (0, _invariant2.default)(typeof spec.firstOfWeek === 'function', 'date localizer `firstOfWeek(..)` must be a function'); checkFormats(REQUIRED_DATE_FORMATS, spec.formats); _dateLocalizer = { formats: spec.formats, propType: spec.propType || localePropType, startOfWeek: spec.firstOfWeek, format: function format(value, str, culture) { return _format(this, spec.format, value, str, culture); }, parse: function parse(value, culture) { var result = spec.parse.call(this, value, culture); (0, _invariant2.default)(result == null || result instanceof Date && !isNaN(result.getTime()), 'date localizer `parse(..)` must return a valid Date, null, or undefined'); return result; } }; }
...
setAnimate: function setAnimate(animatefn) {
_configuration2.default.animate = animatefn;
},
setLocalizers: function setLocalizers(_ref) {
var date = _ref.date,
number = _ref.number;
date && this.setDateLocalizer(date);
number && this.setNumberLocalizer(number);
},
setDateLocalizer: localizers.setDate,
setNumberLocalizer: localizers.setNumber
...
function setLocalizers(_ref) { var date = _ref.date, number = _ref.number; date && this.setDateLocalizer(date); number && this.setNumberLocalizer(number); }
...
date.setMilliseconds(date.getMilliseconds() - 1);
return date;
}
function globalizeLocalizers(globalize) {
var localizers = globalize.locale && !globalize.cultures ? newGlobalize(globalize) : oldGlobalize(globalize);
_configure2.default.setLocalizers(localizers);
return localizers;
}
function newGlobalize(globalize) {
var locale = function locale(culture) {
return culture ? globalize(culture) : globalize;
};
...
function setNumber(_ref) { var _format2 = _ref.format, _parse = _ref.parse, _ref$decimalChar = _ref.decimalChar, decimalChar = _ref$decimalChar === undefined ? function () { return '.'; } : _ref$decimalChar, _ref$precision = _ref.precision, precision = _ref$precision === undefined ? function () { return null; } : _ref$precision, formats = _ref.formats, propType = _ref.propType; (0, _invariant2.default)(typeof _format2 === 'function', 'number localizer `format(..)` must be a function'); (0, _invariant2.default)(typeof _parse === 'function', 'number localizer `parse(..)` must be a function'); checkFormats(REQUIRED_NUMBER_FORMATS, formats); formats.editFormat = formats.editFormat || function (str) { return parseFloat(str); }; _numberLocalizer = { formats: formats, precision: precision, decimalChar: decimalChar, propType: propType || localePropType, format: function format(value, str, culture) { return _format(this, _format2, value, str, culture); }, parse: function parse(value, culture, format) { var result = _parse.call(this, value, culture, format); (0, _invariant2.default)(result == null || typeof result === 'number', 'number localizer `parse(..)` must return a number, null, or undefined'); return result; } }; }
...
_configuration2.default.animate = animatefn;
},
setLocalizers: function setLocalizers(_ref) {
var date = _ref.date,
number = _ref.number;
date && this.setDateLocalizer(date);
number && this.setNumberLocalizer(number);
},
setDateLocalizer: localizers.setDate,
setNumberLocalizer: localizers.setNumber
};
...
utils.ReplaceTransitionGroup = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
utils.SlideTransition = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function componentDidMount() { var autoFocus = this.props.autoFocus; if (autoFocus) this.focus ? this.focus() : (0, _reactDom.findDOMNode)(this).focus(); }
n/a
function Button() { _classCallCheck(this, Button); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
function render() { var _props = this.props, className = _props.className, disabled = _props.disabled, label = _props.label, icon = _props.icon, busy = _props.busy, active = _props.active, children = _props.children, _props$component = _props.component, Tag = _props$component === undefined ? 'button' : _props$component, props = _objectWithoutProperties(_props, ['className', 'disabled', 'label', 'icon', 'busy', 'active', 'children', 'component ']); var type = props.type; if (Tag === 'button') type = type || 'button'; return _react2.default.createElement( Tag, _extends({}, props, { tabIndex: '-1', title: label, type: type, disabled: disabled, 'aria-disabled': disabled, 'aria-label': label, className: (0, _classnames2.default)(className, 'rw-btn', active && !disabled && 'rw-state-active') }), icon && _react2.default.createElement('span', { 'aria-hidden': true, className: (0, _classnames2.default)('rw-i', 'rw-i-' + icon, busy && 'rw-loading') }), children ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
deferControlTo = function (newComponent) { var additions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var nextMethods = arguments[2]; return uncontrollable(newComponent, _extends({}, controlledValues, additions), nextMethods); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { value: null, min: new Date(1900, 0, 1), max: new Date(2099, 11, 31), currentDate: new Date(), initialView: 'month', finalView: 'century', tabIndex: '0', footer: false, ariaActiveDescendantKey: 'calendar', messages: msgs({}) }; }
n/a
function _label() { var _props2 = this.props, culture = _props2.culture, props = _objectWithoutProperties(_props2, ['culture']), view = this.state.view, dt = this.props.currentDate; if (view === 'month') return _localizers.date.format(dt, format(props, 'header'), culture);else if (view === 'year') return _localizers .date.format(dt, format(props, 'year'), culture);else if (view === 'decade') return _localizers.date.format(_dates2.default.startOf (dt, 'decade'), format(props, 'decade'), culture);else if (view === 'century') return _localizers.date.format(_dates2.default.startOf (dt, 'century'), format(props, 'century'), culture); }
...
tabIndex: tabIndex || 0,
onBlur: this.handleBlur,
onFocus: this.handleFocus,
onKeyDown: this.handleKeyDown,
className: (0, _classnames2.default)(className, 'rw-calendar')
}),
_react2.default.createElement(_Header2.default, {
label: this._label(),
labelId: labelID,
messages: messages,
upDisabled: isDisabled || view === finalView,
prevDisabled: isDisabled || !_dates2.default.inRange(this.nextDate(dir.LEFT), min, max, view),
nextDisabled: isDisabled || !_dates2.default.inRange(this.nextDate(dir.RIGHT), min, max, view),
onViewChange: this.navigate.bind(null, dir.UP, null),
onMoveLeft: this.navigate.bind(null, dir.LEFT, null),
...
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper
), e.target)) this.close();
...
function changeCurrentDate(date) { var currentDate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.currentDate; var inRangeDate = this.inRangeValue(date ? new Date(date) : currentDate); if (_dates2.default.eq(inRangeDate, dateOrNull(currentDate), VIEW_UNIT[this.state.view])) return; (0, _widgetHelpers.notify)(this.props.onCurrentDateChange, inRangeDate); }
...
footer: false,
ariaActiveDescendantKey: 'calendar',
messages: msgs({})
};
},
componentWillMount: function componentWillMount() {
this.changeCurrentDate(this.props.value);
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var bottom = VIEW_OPTIONS.indexOf(nextProps.initialView),
top = VIEW_OPTIONS.indexOf(nextProps.finalView),
current = VIEW_OPTIONS.indexOf(this.state.view),
view = this.state.view,
val = this.inRangeValue(nextProps.value);
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function componentDidMount() { var autoFocus = this.props.autoFocus; if (autoFocus) this.focus ? this.focus() : (0, _reactDom.findDOMNode)(this).focus(); }
n/a
function componentWillMount() { this.changeCurrentDate(this.props.value); }
n/a
function componentWillReceiveProps(nextProps) { var bottom = VIEW_OPTIONS.indexOf(nextProps.initialView), top = VIEW_OPTIONS.indexOf(nextProps.finalView), current = VIEW_OPTIONS.indexOf(this.state.view), view = this.state.view, val = this.inRangeValue(nextProps.value); if (current < bottom) this.setState({ view: view = nextProps.initialView });else if (current > top) this.setState({ view: view = nextProps.finalView }); //if the value changes reset views to the new one if (!_dates2.default.eq(val, dateOrNull(this.props.value), VIEW_UNIT[view])) { this.changeCurrentDate(val, nextProps.currentDate); } }
n/a
function componentWillUnmount() { var timers = this._timers || {}; this._unmounted = true; for (var k in timers) { if (has(timers, k)) this.clearTimeout(k); } }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function focus() { if (+this.props.tabIndex > -1) _compat2.default.findDOMNode(this).focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function mergedResult() { var a = one.apply(this, arguments); var b = two.apply(this, arguments); if (a == null) { return b; } else if (b == null) { return a; } var c = {}; mergeIntoWithNoDuplicateKeys(c, a); mergeIntoWithNoDuplicateKeys(c, b); return c; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { return { selectedIndex: 0, view: this.props.initialView || 'month' }; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function inRangeValue(_value) { var value = dateOrNull(_value); if (value === null) return value; return _dates2.default.max(_dates2.default.min(value, this.props.max), this.props.min); }
...
this.changeCurrentDate(this.props.value);
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var bottom = VIEW_OPTIONS.indexOf(nextProps.initialView),
top = VIEW_OPTIONS.indexOf(nextProps.finalView),
current = VIEW_OPTIONS.indexOf(this.state.view),
view = this.state.view,
val = this.inRangeValue(nextProps.value);
if (current < bottom) this.setState({ view: view = nextProps.initialView });else if (current > top) this.setState
({ view: view = nextProps.finalView });
//if the value changes reset views to the new one
if (!_dates2.default.eq(val, dateOrNull(this.props.value), VIEW_UNIT[view])) {
this.changeCurrentDate(val, nextProps.currentDate);
}
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function isValidView(next) { var bottom = VIEW_OPTIONS.indexOf(this.props.initialView), top = VIEW_OPTIONS.indexOf(this.props.finalView), current = VIEW_OPTIONS.indexOf(next); return current >= bottom && current <= top; }
...
if (!date) date = [dir.LEFT, dir.RIGHT].indexOf(direction) !== -1 ? this.nextDate(direction) : this.props.currentDate;
if (direction === dir.DOWN) view = ALT_VIEW[view] || view;
if (direction === dir.UP) view = NEXT_VIEW[view] || view;
if (this.isValidView(view) && _dates2.default.inRange(date, this.props
.min, this.props.max, view)) {
(0, _widgetHelpers.notify)(this.props.onNavigate, [date, slideDir, view]);
this.focus(true);
this.changeCurrentDate(date);
this.setState({
slideDirection: slideDir,
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (this.state.view === this.props.initialView) {
this.changeCurrentDate(date);
(0, _widgetHelpers.notify)(this.props.onChange, date);
this.focus();
return;
}
this.navigate(dir.DOWN, date);
},
changeCurrentDate: function changeCurrentDate(date) {
var currentDate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.currentDate
;
var inRangeDate = this.inRangeValue(date ? new Date(date) : currentDate);
if (_dates2.default.eq(inRangeDate, dateOrNull(currentDate), VIEW_UNIT[this.state.view])) return;
(0, _widgetHelpers.notify)(this.props.onCurrentDateChange, inRangeDate);
...
function nextDate(direction) { var method = direction === dir.LEFT ? 'subtract' : 'add', view = this.state.view, unit = view === views.MONTH ? view : views.YEAR, multi = MULTIPLIER[view] || 1; return _dates2.default[method](this.props.currentDate, 1 * multi, unit); }
...
className: (0, _classnames2.default)(className, 'rw-calendar')
}),
_react2.default.createElement(_Header2.default, {
label: this._label(),
labelId: labelID,
messages: messages,
upDisabled: isDisabled || view === finalView,
prevDisabled: isDisabled || !_dates2.default.inRange(this.nextDate(dir.LEFT),
min, max, view),
nextDisabled: isDisabled || !_dates2.default.inRange(this.nextDate(dir.RIGHT), min, max, view),
onViewChange: this.navigate.bind(null, dir.UP, null),
onMoveLeft: this.navigate.bind(null, dir.LEFT, null),
onMoveRight: this.navigate.bind(null, dir.RIGHT, null)
}),
_react2.default.createElement(
_SlideTransition2.default,
...
function render() { var _this = this; var _props = this.props, className = _props.className, value = _props.value, footerFormat = _props.footerFormat, disabled = _props.disabled, readOnly = _props.readOnly, finalView = _props.finalView, footer = _props.footer, messages = _props.messages, min = _props.min, max = _props.max, culture = _props.culture, duration = _props.duration, tabIndex = _props.tabIndex, currentDate = _props.currentDate; var _state = this.state, view = _state.view, slideDirection = _state.slideDirection, focused = _state.focused; var View = VIEW[view], unit = VIEW_UNIT[view], todaysDate = new Date(), todayNotInRange = !_dates2.default.inRange(todaysDate, min, max, view); unit = unit === 'day' ? 'date' : unit; var viewID = (0, _widgetHelpers.instanceId)(this, '_calendar'), labelID = (0, _widgetHelpers.instanceId)(this, '_calendar_label'), key = view + '_' + _dates2.default[view](currentDate); var elementProps = _3.default.omitOwnProps(this), viewProps = _3.default.pickProps(this.props, View); var isDisabled = disabled || readOnly; messages = msgs(this.props.messages); return _react2.default.createElement( _Widget2.default, _extends({}, elementProps, { role: 'group', focused: focused, disabled: disabled, readOnly: readOnly, tabIndex: tabIndex || 0, onBlur: this.handleBlur, onFocus: this.handleFocus, onKeyDown: this.handleKeyDown, className: (0, _classnames2.default)(className, 'rw-calendar') }), _react2.default.createElement(_Header2.default, { label: this._label(), labelId: labelID, messages: messages, upDisabled: isDisabled || view === finalView, prevDisabled: isDisabled || !_dates2.default.inRange(this.nextDate(dir.LEFT), min, max, view), nextDisabled: isDisabled || !_dates2.default.inRange(this.nextDate(dir.RIGHT), min, max, view), onViewChange: this.navigate.bind(null, dir.UP, null), onMoveLeft: this.navigate.bind(null, dir.LEFT, null), onMoveRight: this.navigate.bind(null, dir.RIGHT, null) }), _react2.default.createElement( _SlideTransition2.default, { ref: 'animation', duration: duration, direction: slideDirection, onAnimate: function onAnimate() { return focused && _this.focus(); } }, _react2.default.createElement(View, _extends({}, viewProps, { key: key, id: viewID, value: value, today: todaysDate, focused: currentDate, onChange: this.change, onKeyDown: this.handleKeyDown, 'aria-labelledby': labelID, ariaActiveDescendantKey: 'calendarView' })) ), footer && _react2.default.createElement(_Footer2.default, { value: todaysDate, format: footerFormat, culture: culture, disabled: disabled || todayNotInRange, readOnly: readOnly, onClick: this.select }) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
el.setSelectionRange(start, end);
} else {
el.focus();
rangeEl = el.createTextRange();
rangeEl.collapse(true);
rangeEl.moveStart('character', start);
rangeEl.moveEnd('character', end - start);
rangeEl.select();
}
} catch (e) {/* not focused or not visible */}
}
module.exports = exports['default'];
/***/ },
/* 66 */
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function shouldComponentUpdate(nextProps, nextState) { return !_.isShallowEqual(this.props, nextProps) || !_.isShallowEqual(this.state, nextState); }
n/a
function _label() { var _props2 = this.props, culture = _props2.culture, props = _objectWithoutProperties(_props2, ['culture']), view = this.state.view, dt = this.props.currentDate; if (view === 'month') return _localizers.date.format(dt, format(props, 'header'), culture);else if (view === 'year') return _localizers .date.format(dt, format(props, 'year'), culture);else if (view === 'decade') return _localizers.date.format(_dates2.default.startOf (dt, 'decade'), format(props, 'decade'), culture);else if (view === 'century') return _localizers.date.format(_dates2.default.startOf (dt, 'century'), format(props, 'century'), culture); }
...
tabIndex: tabIndex || 0,
onBlur: this.handleBlur,
onFocus: this.handleFocus,
onKeyDown: this.handleKeyDown,
className: (0, _classnames2.default)(className, 'rw-calendar')
}),
_react2.default.createElement(_Header2.default, {
label: this._label(),
labelId: labelID,
messages: messages,
upDisabled: isDisabled || view === finalView,
prevDisabled: isDisabled || !_dates2.default.inRange(this.nextDate(dir.LEFT), min, max, view),
nextDisabled: isDisabled || !_dates2.default.inRange(this.nextDate(dir.RIGHT), min, max, view),
onViewChange: this.navigate.bind(null, dir.UP, null),
onMoveLeft: this.navigate.bind(null, dir.LEFT, null),
...
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper
), e.target)) this.close();
...
function changeCurrentDate(date) { var currentDate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.currentDate; var inRangeDate = this.inRangeValue(date ? new Date(date) : currentDate); if (_dates2.default.eq(inRangeDate, dateOrNull(currentDate), VIEW_UNIT[this.state.view])) return; (0, _widgetHelpers.notify)(this.props.onCurrentDateChange, inRangeDate); }
...
footer: false,
ariaActiveDescendantKey: 'calendar',
messages: msgs({})
};
},
componentWillMount: function componentWillMount() {
this.changeCurrentDate(this.props.value);
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var bottom = VIEW_OPTIONS.indexOf(nextProps.initialView),
top = VIEW_OPTIONS.indexOf(nextProps.finalView),
current = VIEW_OPTIONS.indexOf(this.state.view),
view = this.state.view,
val = this.inRangeValue(nextProps.value);
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function focus() { if (+this.props.tabIndex > -1) _compat2.default.findDOMNode(this).focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function inRangeValue(_value) { var value = dateOrNull(_value); if (value === null) return value; return _dates2.default.max(_dates2.default.min(value, this.props.max), this.props.min); }
...
this.changeCurrentDate(this.props.value);
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var bottom = VIEW_OPTIONS.indexOf(nextProps.initialView),
top = VIEW_OPTIONS.indexOf(nextProps.finalView),
current = VIEW_OPTIONS.indexOf(this.state.view),
view = this.state.view,
val = this.inRangeValue(nextProps.value);
if (current < bottom) this.setState({ view: view = nextProps.initialView });else if (current > top) this.setState
({ view: view = nextProps.finalView });
//if the value changes reset views to the new one
if (!_dates2.default.eq(val, dateOrNull(this.props.value), VIEW_UNIT[view])) {
this.changeCurrentDate(val, nextProps.currentDate);
}
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function isValidView(next) { var bottom = VIEW_OPTIONS.indexOf(this.props.initialView), top = VIEW_OPTIONS.indexOf(this.props.finalView), current = VIEW_OPTIONS.indexOf(next); return current >= bottom && current <= top; }
...
if (!date) date = [dir.LEFT, dir.RIGHT].indexOf(direction) !== -1 ? this.nextDate(direction) : this.props.currentDate;
if (direction === dir.DOWN) view = ALT_VIEW[view] || view;
if (direction === dir.UP) view = NEXT_VIEW[view] || view;
if (this.isValidView(view) && _dates2.default.inRange(date, this.props
.min, this.props.max, view)) {
(0, _widgetHelpers.notify)(this.props.onNavigate, [date, slideDir, view]);
this.focus(true);
this.changeCurrentDate(date);
this.setState({
slideDirection: slideDir,
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (this.state.view === this.props.initialView) {
this.changeCurrentDate(date);
(0, _widgetHelpers.notify)(this.props.onChange, date);
this.focus();
return;
}
this.navigate(dir.DOWN, date);
},
changeCurrentDate: function changeCurrentDate(date) {
var currentDate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.currentDate
;
var inRangeDate = this.inRangeValue(date ? new Date(date) : currentDate);
if (_dates2.default.eq(inRangeDate, dateOrNull(currentDate), VIEW_UNIT[this.state.view])) return;
(0, _widgetHelpers.notify)(this.props.onCurrentDateChange, inRangeDate);
...
function nextDate(direction) { var method = direction === dir.LEFT ? 'subtract' : 'add', view = this.state.view, unit = view === views.MONTH ? view : views.YEAR, multi = MULTIPLIER[view] || 1; return _dates2.default[method](this.props.currentDate, 1 * multi, unit); }
...
className: (0, _classnames2.default)(className, 'rw-calendar')
}),
_react2.default.createElement(_Header2.default, {
label: this._label(),
labelId: labelID,
messages: messages,
upDisabled: isDisabled || view === finalView,
prevDisabled: isDisabled || !_dates2.default.inRange(this.nextDate(dir.LEFT),
min, max, view),
nextDisabled: isDisabled || !_dates2.default.inRange(this.nextDate(dir.RIGHT), min, max, view),
onViewChange: this.navigate.bind(null, dir.UP, null),
onMoveLeft: this.navigate.bind(null, dir.LEFT, null),
onMoveRight: this.navigate.bind(null, dir.RIGHT, null)
}),
_react2.default.createElement(
_SlideTransition2.default,
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
el.setSelectionRange(start, end);
} else {
el.focus();
rangeEl = el.createTextRange();
rangeEl.collapse(true);
rangeEl.moveStart('character', start);
rangeEl.moveEnd('character', end - start);
rangeEl.select();
}
} catch (e) {/* not focused or not visible */}
}
module.exports = exports['default'];
/***/ },
/* 66 */
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
currentDate = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
value = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
view = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
function componentWillMount() { var _this2 = this; var props = this.props; this._values = {}; controlledProps.forEach(function (key) { _this2._values[key] = props[utils.defaultKey(key)]; }); }
n/a
function componentWillReceiveProps(nextProps) { var _this3 = this; var props = this.props; if (mixin.componentWillReceiveProps) { mixin.componentWillReceiveProps.call(this, nextProps); } controlledProps.forEach(function (key) { if (utils.getValue(nextProps, key) === undefined && utils.getValue(props, key) !== undefined) { _this3._values[key] = nextProps[utils.defaultKey(key)]; } }); }
n/a
function componentWillUnmount() { this.unmounted = true; }
n/a
focus = function () { var _refs$inner; return (_refs$inner = this.refs.inner)[method].apply(_refs$inner, arguments); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function getControlledInstance() { return this.refs.inner; }
n/a
function render() { var _this4 = this; var newProps = {}, props = omitProps(this.props); utils.each(controlledValues, function (handle, propName) { var linkPropName = utils.getLinkName(propName), prop = _this4.props[propName]; if (linkPropName && !isProp(_this4.props, propName) && isProp(_this4.props, linkPropName)) { prop = _this4.props[linkPropName].value; } newProps[propName] = prop !== undefined ? prop : _this4._values[propName]; newProps[handle] = setAndNotify.bind(_this4, propName); }); newProps = _extends({}, props, newProps, { ref: isCompositeComponent ? 'inner' : null }); return _react2.default.createElement(Component, newProps); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function shouldComponentUpdate() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return !mixin.shouldComponentUpdate || mixin.shouldComponentUpdate.apply(this, args); }
n/a
function CalendarView() { _classCallCheck(this, CalendarView); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
function CalendarViewCell() { var _temp, _this2, _ret; _classCallCheck(this, CalendarViewCell); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this2 = _possibleConstructorReturn(this, _React$Component2.call.apply(_React$Component2, [this].concat (args))), _this2), _this2.handleChange = function () { var _this2$props = _this2.props, onChange = _this2$props.onChange, min = _this2$props.min, max = _this2$props.max, date = _this2$props.date; onChange(clamp(date, min, max)); }, _temp), _possibleConstructorReturn(_this2, _ret); }
n/a
Row = function (props) { return _react2.default.createElement('tr', _extends({ role: 'row' }, props)); }
n/a
function render() { var className = this.props.className; return _react2.default.createElement('table', _extends({}, this.props, { role: 'grid', tabIndex: '-1', className: (0, _classnames2.default)(className, 'rw-nav-view', 'rw-calendar-grid') })); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
Century = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function componentDidUpdate() { var activeId = optionId((0, _widgetHelpers.instanceId)(this), this.props.focused); this.ariaActiveDescendant(activeId); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getChildContext() { var _this = this; return this._context || (this._context = { activeDescendants: { reconcile: function reconcile(key, id) { return _this.ariaActiveDescendant(id, key); } } }); }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function isRtl() { return !!this.context.isRtl; }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function render() { var focused = this.props.focused; return _react2.default.createElement( _CalendarView2.default, _3.default.omitOwnProps(this), _react2.default.createElement( 'tbody', null, _3.default.chunk(getCenturyDecades(focused), 4).map(this.renderRow) ) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function renderRow(row, rowIdx) { var _this = this; var _props = this.props, focused = _props.focused, disabled = _props.disabled, onChange = _props.onChange, value = _props.value, today = _props.today, culture = _props.culture, min = _props.min, max = _props.max; var id = (0, _widgetHelpers.instanceId)(this, '_century'); return _react2.default.createElement( _CalendarView2.default.Row, { key: rowIdx }, row.map(function (date, colIdx) { var label = _localizers.date.format(_dates2.default.startOf(date, 'decade'), format(_this.props), culture); return _react2.default.createElement( _CalendarView2.default.Cell, { key: colIdx, unit: 'decade', id: optionId(id, date), label: label, date: date, now: today, min: min, max: max, onChange: onChange, focused: focused, selected: value, disabled: disabled }, label ); }) ); }
n/a
function shouldComponentUpdate(nextProps, nextState) { return !_.isShallowEqual(this.props, nextProps) || !_.isShallowEqual(this.state, nextState); }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
deferControlTo = function (newComponent) { var additions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var nextMethods = arguments[2]; return uncontrollable(newComponent, _extends({}, controlledValues, additions), nextMethods); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function mergedResult() { var a = one.apply(this, arguments); var b = two.apply(this, arguments); if (a == null) { return b; } else if (b == null) { return a; } var c = {}; mergeIntoWithNoDuplicateKeys(c, a); mergeIntoWithNoDuplicateKeys(c, b); return c; }
n/a
function _data() { return this.state.processedData; }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function _scrollTo(selected, list, focused) { var state = this._scrollState || (this._scrollState = {}), handler = this.props.onMove, lastVisible = state.visible, lastItem = state.focused, shown, changed; state.visible = !(!list.offsetWidth || !list.offsetHeight); state.focused = focused; changed = lastItem !== focused; shown = state.visible && !lastVisible; if (shown || state.visible && changed) { if (handler) handler(selected, list, focused);else { state.scrollCancel && state.scrollCancel(); state.scrollCancel = (0, _scrollTo3.default)(selected, list); } } }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function change(data, typing) { this._typedChange = !!typing; (0, _widgetHelpers.notify)(this.props.onChange, data); }
...
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper
), e.target)) this.close();
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function close() { if (this.props.open) (0, _widgetHelpers.notify)(this.props.onToggle, false); }
...
var DropdownList = _react2.default.createClass((_obj = {
displayName: 'DropdownList',
mixins: [__webpack_require__(52), __webpack_require__(53), __webpack_require__(54), __webpack_require__(55), __webpack_require__
(56), __webpack_require__(61), __webpack_require__(45)(), __webpack_require__(62)({
didHandle: function didHandle(focused) {
if (!focused) this.close();
}
})],
propTypes: propTypes,
getDefaultProps: function getDefaultProps() {
return {
...
function componentDidUpdate() { this.refs.list && (0, _validateListInterface2.default)(this.refs.list); }
n/a
function componentWillReceiveProps(nextProps) { var value = nextProps.value, data = nextProps.data, valueField = nextProps.valueField, textField = nextProps.textField; var rawIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField), valueItem = rawIdx === -1 ? nextProps.value : nextProps.data[rawIdx], isSuggesting = this.refs.input && this.refs.input.isSuggesting(); var items = this.process(nextProps.data, nextProps.value, (rawIdx === -1 || isSuggesting) && (0, _dataHelpers.dataText)(valueItem , textField)); var idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField), focused = this.filterIndexOf(items, (0, _dataHelpers.dataText)(valueItem, textField)); this._searchTerm = ''; this.setState({ processedData: items, selectedItem: items[idx], focusedItem: items[idx === -1 ? focused !== -1 ? focused : 0 // focus the closest match : idx] }); }
n/a
function componentWillUnmount() { var timers = this._timers || {}; this._unmounted = true; for (var k in timers) { if (has(timers, k)) this.clearTimeout(k); } }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function filter(items, searchTerm) { var matches = typeof this.props.filter === 'string' ? getFilter(_filter2.default[this.props.filter], searchTerm, this) : this. props.filter; if (!matches || !searchTerm || !searchTerm.trim() || searchTerm.length < (this.props.minLength || 1)) return items; return items.filter(function (item, idx) { return matches(item, searchTerm, idx); }); }
...
filter = _props.filter,
value = _props.value,
data = _props.data,
searchTerm = _props.searchTerm,
valueField = _props.valueField;
var processed = filter ? this.filter(data, searchTerm) : data,
initialIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField);
return {
filteredData: open && filter ? processed : null,
selectedItem: processed[initialIdx],
focusedItem: processed[initialIdx] || data[0]
};
...
function filterIndexOf(items, searchTerm) { var idx = -1, matches = typeof this.props.filter === 'function' ? this.props.filter : getFilter(_filter2.default[dflt(this.props.filter)], searchTerm, this); if (!searchTerm || !searchTerm.trim() || this.props.filter && searchTerm.length < (this.props.minLength || 1)) return -1; items.every(function (item, i) { if (matches(item, searchTerm, i)) return idx = i, false; return true; }); return idx; }
...
var rawIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField),
valueItem = rawIdx === -1 ? nextProps.value : nextProps.data[rawIdx],
isSuggesting = this.refs.input && this.refs.input.isSuggesting();
var items = this.process(nextProps.data, nextProps.value, (rawIdx === -1 || isSuggesting) && (0, _dataHelpers.dataText
)(valueItem, textField));
var idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField),
focused = this.filterIndexOf(items, (0, _dataHelpers.dataText)(valueItem, textField
));
this._searchTerm = '';
this.setState({
processedData: items,
selectedItem: items[idx],
focusedItem: items[idx === -1 ? focused !== -1 ? focused : 0 // focus the closest match
...
function focus() { this.refs.input && this.refs.input.focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function mergedResult() { var a = one.apply(this, arguments); var b = two.apply(this, arguments); if (a == null) { return b; } else if (b == null) { return a; } var c = {}; mergeIntoWithNoDuplicateKeys(c, a); mergeIntoWithNoDuplicateKeys(c, b); return c; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { var _props = this.props, value = _props.value, data = _props.data, valueField = _props.valueField, items = this.process(data, value), idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField); return { selectedItem: items[idx], focusedItem: items[!~idx ? 0 : idx], processedData: items, open: false }; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function handleInputChange(e) { var _props5 = this.props, data = _props5.data, textField = _props5.textField; var shouldSuggest = !!this.props.suggest, strVal = e.target.value, suggestion; suggestion = this._deleting || !shouldSuggest ? strVal : this.suggest(this._data(), strVal); suggestion = suggestion || strVal; data = _3.default.find(data, function (item) { return (0, _dataHelpers.dataText)(item, textField).toLowerCase() === suggestion.toLowerCase(); }); this.change(!this._deleting && data ? data : strVal, true); this.open(); }
n/a
function handleInputKeyDown(e) { this._deleting = e.key === 'Backspace' || e.key === 'Delete'; this._isTyping = true; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
_this3.close(), _compat2.default.findDOMNode(_this3).focus();
};
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
var change = function change(item, fromList) {
if (item == null) return;
fromList ? _this3.handleSelect(item) : _this3.change(item);
};
if (e.defaultPrevented) return;
if (key === 'End') {
e.preventDefault();
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function open() { if (!this.props.open) (0, _widgetHelpers.notify)(this.props.onToggle, true); }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
function process(data, values, searchTerm) { if (this.props.filter && searchTerm) data = this.filter(data, searchTerm); return data; }
...
propTypes: propTypes,
getInitialState: function getInitialState() {
var _props = this.props,
value = _props.value,
data = _props.data,
valueField = _props.valueField,
items = this.process(data, value),
idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField);
return {
selectedItem: items[idx],
focusedItem: items[!~idx ? 0 : idx],
processedData: items,
...
function render() { var _this = this; var _props4 = this.props, className = _props4.className, duration = _props4.duration, groupBy = _props4.groupBy, messages = _props4.messages, busy = _props4.busy, dropUp = _props4.dropUp, open = _props4.open, List = _props4.listComponent; var focused = this.state.focused; var disabled = (0, _interaction.isDisabled)(this.props), readOnly = (0, _interaction.isReadOnly)(this.props), listID = (0, _widgetHelpers.instanceId)(this, '_listbox'); List = List || groupBy && _ListGroupable2.default || _List2.default; var elementProps = _3.default.omitOwnProps(this, List); var shouldRenderPopup = open || (0, _widgetHelpers.isFirstFocusedRender)(this); messages = msgs(messages); return _react2.default.createElement( _Widget2.default, _extends({}, elementProps, { open: open, dropUp: dropUp, focused: focused, disabled: disabled, readOnly: readOnly, onBlur: this.handleBlur, onFocus: this.handleFocus, onKeyDown: this.handleKeyDown, className: (0, _classnames2.default)(className, 'rw-combobox') }), _react2.default.createElement(_Select2.default, { onClick: this.toggle, disabled: !!(disabled || readOnly), busy: busy, icon: 'caret-down', label: _3.default.result(messages.open, this.props) }), this.renderInput(listID), shouldRenderPopup && _react2.default.createElement( _Popup2.default, { open: open, dropUp: dropUp, duration: duration, onOpening: function onOpening() { return _this.refs.list.forceUpdate(); } }, _react2.default.createElement( 'div', null, this.renderList(List, listID, messages) ) ) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function renderInput(listID) { var _props2 = this.props, suggest = _props2.suggest, filter = _props2.filter, textField = _props2.textField, busy = _props2.busy, name = _props2.name, data = _props2.data, value = _props2.value, valueField = _props2.valueField, autoFocus = _props2.autoFocus, tabIndex = _props2.tabIndex, disabled = _props2.disabled, readOnly = _props2.readOnly, placeholder = _props2.placeholder, open = _props2.open; var valueItem = (0, _dataHelpers.dataItem)(data, value, valueField); // take value from the raw data var completeType = suggest ? filter ? 'both' : 'inline' : filter ? 'list' : ''; return _react2.default.createElement(_ComboboxInput2.default, { ref: 'input', id: (0, _widgetHelpers.instanceId)(this, '_input'), autoFocus: autoFocus, tabIndex: tabIndex, suggest: suggest, name: name, role: 'combobox', disabled: disabled, readOnly: readOnly, 'aria-owns': listID, 'aria-busy': !!busy, 'aria-autocomplete': completeType, 'aria-expanded': open, 'aria-haspopup': true, placeholder: placeholder, value: (0, _dataHelpers.dataText)(valueItem, textField), onChange: this.handleInputChange, onKeyDown: this.handleInputKeyDown }); }
...
_react2.default.createElement(_Select2.default, {
onClick: this.toggle,
disabled: !!(disabled || readOnly),
busy: busy,
icon: 'caret-down',
label: _3.default.result(messages.open, this.props)
}),
this.renderInput(listID),
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpening: function onOpening() {
...
function renderList(List, id, messages) { var _props3 = this.props, open = _props3.open, data = _props3.data; var _state = this.state, selectedItem = _state.selectedItem, focusedItem = _state.focusedItem; var listProps = _3.default.pickProps(this.props, List); var items = this._data(); return _react2.default.createElement(List, _extends({ ref: 'list' }, listProps, { id: id, data: items, selected: selectedItem, focused: focusedItem, 'aria-hidden': !open, 'aria-labelledby': (0, _widgetHelpers.instanceId)(this), 'aria-live': open && 'polite', onSelect: this.handleSelect, onMove: this._scrollTo, messages: { emptyList: data.length ? messages.emptyFilter : messages.emptyList } })); }
...
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function shouldComponentUpdate(nextProps, nextState) { var isSuggesting = this.refs.input && this.refs.input.isSuggesting(), stateChanged = !_3.default.isShallowEqual(nextState, this.state), valueChanged = !_3.default.isShallowEqual(nextProps, this.props); return isSuggesting || stateChanged || valueChanged; }
n/a
function suggest(data, value) { var _props6 = this.props, textField = _props6.textField, suggest = _props6.suggest, minLength = _props6.minLength; var word = (0, _dataHelpers.dataText)(value, textField), suggestion; suggest = defaultSuggest(suggest); if (!(word || '').trim() || word.length < (minLength || 1)) return ''; suggestion = typeof value === 'string' ? _3.default.find(data, getFilter(suggest, word, textField)) : value; if (suggestion && (!this.state || !this.state.deleting)) return (0, _dataHelpers.dataText)(suggestion, textField); return ''; }
...
textField = _props5.textField;
var shouldSuggest = !!this.props.suggest,
strVal = e.target.value,
suggestion;
suggestion = this._deleting || !shouldSuggest ? strVal : this.suggest(this._data
(), strVal);
suggestion = suggestion || strVal;
data = _3.default.find(data, function (item) {
return (0, _dataHelpers.dataText)(item, textField).toLowerCase() === suggestion.toLowerCase();
});
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2
.default)(_compat2.default.findDOMNode(wrapper), e.target)) this.close();
(0, _widgetHelpers.notify)(this.props.onClick, e);
},
handleKeyDown: function handleKeyDown(e) {
var _this3 = this;
var key = e.key,
...
function _data() { return this.state.processedData; }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function _scrollTo(selected, list, focused) { var state = this._scrollState || (this._scrollState = {}), handler = this.props.onMove, lastVisible = state.visible, lastItem = state.focused, shown, changed; state.visible = !(!list.offsetWidth || !list.offsetHeight); state.focused = focused; changed = lastItem !== focused; shown = state.visible && !lastVisible; if (shown || state.visible && changed) { if (handler) handler(selected, list, focused);else { state.scrollCancel && state.scrollCancel(); state.scrollCancel = (0, _scrollTo3.default)(selected, list); } } }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function change(data, typing) { this._typedChange = !!typing; (0, _widgetHelpers.notify)(this.props.onChange, data); }
...
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper
), e.target)) this.close();
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function close() { if (this.props.open) (0, _widgetHelpers.notify)(this.props.onToggle, false); }
...
var DropdownList = _react2.default.createClass((_obj = {
displayName: 'DropdownList',
mixins: [__webpack_require__(52), __webpack_require__(53), __webpack_require__(54), __webpack_require__(55), __webpack_require__
(56), __webpack_require__(61), __webpack_require__(45)(), __webpack_require__(62)({
didHandle: function didHandle(focused) {
if (!focused) this.close();
}
})],
propTypes: propTypes,
getDefaultProps: function getDefaultProps() {
return {
...
function filter(items, searchTerm) { var matches = typeof this.props.filter === 'string' ? getFilter(_filter2.default[this.props.filter], searchTerm, this) : this. props.filter; if (!matches || !searchTerm || !searchTerm.trim() || searchTerm.length < (this.props.minLength || 1)) return items; return items.filter(function (item, idx) { return matches(item, searchTerm, idx); }); }
...
filter = _props.filter,
value = _props.value,
data = _props.data,
searchTerm = _props.searchTerm,
valueField = _props.valueField;
var processed = filter ? this.filter(data, searchTerm) : data,
initialIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField);
return {
filteredData: open && filter ? processed : null,
selectedItem: processed[initialIdx],
focusedItem: processed[initialIdx] || data[0]
};
...
function filterIndexOf(items, searchTerm) { var idx = -1, matches = typeof this.props.filter === 'function' ? this.props.filter : getFilter(_filter2.default[dflt(this.props.filter)], searchTerm, this); if (!searchTerm || !searchTerm.trim() || this.props.filter && searchTerm.length < (this.props.minLength || 1)) return -1; items.every(function (item, i) { if (matches(item, searchTerm, i)) return idx = i, false; return true; }); return idx; }
...
var rawIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField),
valueItem = rawIdx === -1 ? nextProps.value : nextProps.data[rawIdx],
isSuggesting = this.refs.input && this.refs.input.isSuggesting();
var items = this.process(nextProps.data, nextProps.value, (rawIdx === -1 || isSuggesting) && (0, _dataHelpers.dataText
)(valueItem, textField));
var idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField),
focused = this.filterIndexOf(items, (0, _dataHelpers.dataText)(valueItem, textField
));
this._searchTerm = '';
this.setState({
processedData: items,
selectedItem: items[idx],
focusedItem: items[idx === -1 ? focused !== -1 ? focused : 0 // focus the closest match
...
function focus() { this.refs.input && this.refs.input.focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function handleInputChange(e) { var _props5 = this.props, data = _props5.data, textField = _props5.textField; var shouldSuggest = !!this.props.suggest, strVal = e.target.value, suggestion; suggestion = this._deleting || !shouldSuggest ? strVal : this.suggest(this._data(), strVal); suggestion = suggestion || strVal; data = _3.default.find(data, function (item) { return (0, _dataHelpers.dataText)(item, textField).toLowerCase() === suggestion.toLowerCase(); }); this.change(!this._deleting && data ? data : strVal, true); this.open(); }
n/a
function handleInputKeyDown(e) { this._deleting = e.key === 'Backspace' || e.key === 'Delete'; this._isTyping = true; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
_this3.close(), _compat2.default.findDOMNode(_this3).focus();
};
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
var change = function change(item, fromList) {
if (item == null) return;
fromList ? _this3.handleSelect(item) : _this3.change(item);
};
if (e.defaultPrevented) return;
if (key === 'End') {
e.preventDefault();
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function open() { if (!this.props.open) (0, _widgetHelpers.notify)(this.props.onToggle, true); }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
function process(data, values, searchTerm) { if (this.props.filter && searchTerm) data = this.filter(data, searchTerm); return data; }
...
propTypes: propTypes,
getInitialState: function getInitialState() {
var _props = this.props,
value = _props.value,
data = _props.data,
valueField = _props.valueField,
items = this.process(data, value),
idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField);
return {
selectedItem: items[idx],
focusedItem: items[!~idx ? 0 : idx],
processedData: items,
...
function renderInput(listID) { var _props2 = this.props, suggest = _props2.suggest, filter = _props2.filter, textField = _props2.textField, busy = _props2.busy, name = _props2.name, data = _props2.data, value = _props2.value, valueField = _props2.valueField, autoFocus = _props2.autoFocus, tabIndex = _props2.tabIndex, disabled = _props2.disabled, readOnly = _props2.readOnly, placeholder = _props2.placeholder, open = _props2.open; var valueItem = (0, _dataHelpers.dataItem)(data, value, valueField); // take value from the raw data var completeType = suggest ? filter ? 'both' : 'inline' : filter ? 'list' : ''; return _react2.default.createElement(_ComboboxInput2.default, { ref: 'input', id: (0, _widgetHelpers.instanceId)(this, '_input'), autoFocus: autoFocus, tabIndex: tabIndex, suggest: suggest, name: name, role: 'combobox', disabled: disabled, readOnly: readOnly, 'aria-owns': listID, 'aria-busy': !!busy, 'aria-autocomplete': completeType, 'aria-expanded': open, 'aria-haspopup': true, placeholder: placeholder, value: (0, _dataHelpers.dataText)(valueItem, textField), onChange: this.handleInputChange, onKeyDown: this.handleInputKeyDown }); }
...
_react2.default.createElement(_Select2.default, {
onClick: this.toggle,
disabled: !!(disabled || readOnly),
busy: busy,
icon: 'caret-down',
label: _3.default.result(messages.open, this.props)
}),
this.renderInput(listID),
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpening: function onOpening() {
...
function renderList(List, id, messages) { var _props3 = this.props, open = _props3.open, data = _props3.data; var _state = this.state, selectedItem = _state.selectedItem, focusedItem = _state.focusedItem; var listProps = _3.default.pickProps(this.props, List); var items = this._data(); return _react2.default.createElement(List, _extends({ ref: 'list' }, listProps, { id: id, data: items, selected: selectedItem, focused: focusedItem, 'aria-hidden': !open, 'aria-labelledby': (0, _widgetHelpers.instanceId)(this), 'aria-live': open && 'polite', onSelect: this.handleSelect, onMove: this._scrollTo, messages: { emptyList: data.length ? messages.emptyFilter : messages.emptyList } })); }
...
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function suggest(data, value) { var _props6 = this.props, textField = _props6.textField, suggest = _props6.suggest, minLength = _props6.minLength; var word = (0, _dataHelpers.dataText)(value, textField), suggestion; suggest = defaultSuggest(suggest); if (!(word || '').trim() || word.length < (minLength || 1)) return ''; suggestion = typeof value === 'string' ? _3.default.find(data, getFilter(suggest, word, textField)) : value; if (suggestion && (!this.state || !this.state.deleting)) return (0, _dataHelpers.dataText)(suggestion, textField); return ''; }
...
textField = _props5.textField;
var shouldSuggest = !!this.props.suggest,
strVal = e.target.value,
suggestion;
suggestion = this._deleting || !shouldSuggest ? strVal : this.suggest(this._data
(), strVal);
suggestion = suggestion || strVal;
data = _3.default.find(data, function (item) {
return (0, _dataHelpers.dataText)(item, textField).toLowerCase() === suggestion.toLowerCase();
});
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2
.default)(_compat2.default.findDOMNode(wrapper), e.target)) this.close();
(0, _widgetHelpers.notify)(this.props.onClick, e);
},
handleKeyDown: function handleKeyDown(e) {
var _this3 = this;
var key = e.key,
...
open = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
value = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
function componentWillMount() { var _this2 = this; var props = this.props; this._values = {}; controlledProps.forEach(function (key) { _this2._values[key] = props[utils.defaultKey(key)]; }); }
n/a
function componentWillReceiveProps(nextProps) { var _this3 = this; var props = this.props; if (mixin.componentWillReceiveProps) { mixin.componentWillReceiveProps.call(this, nextProps); } controlledProps.forEach(function (key) { if (utils.getValue(nextProps, key) === undefined && utils.getValue(props, key) !== undefined) { _this3._values[key] = nextProps[utils.defaultKey(key)]; } }); }
n/a
function componentWillUnmount() { this.unmounted = true; }
n/a
focus = function () { var _refs$inner; return (_refs$inner = this.refs.inner)[method].apply(_refs$inner, arguments); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function getControlledInstance() { return this.refs.inner; }
n/a
function render() { var _this4 = this; var newProps = {}, props = omitProps(this.props); utils.each(controlledValues, function (handle, propName) { var linkPropName = utils.getLinkName(propName), prop = _this4.props[propName]; if (linkPropName && !isProp(_this4.props, propName) && isProp(_this4.props, linkPropName)) { prop = _this4.props[linkPropName].value; } newProps[propName] = prop !== undefined ? prop : _this4._values[propName]; newProps[handle] = setAndNotify.bind(_this4, propName); }); newProps = _extends({}, props, newProps, { ref: isCompositeComponent ? 'inner' : null }); return _react2.default.createElement(Component, newProps); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function shouldComponentUpdate() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return !mixin.shouldComponentUpdate || mixin.shouldComponentUpdate.apply(this, args); }
n/a
ComboboxInput = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { value: '' }; }
n/a
function accept(removeCaret) { var val = _compat2.default.findDOMNode(this).value || '', end = val.length; this._last = null; removeCaret && (0, _caret2.default)(_compat2.default.findDOMNode(this), end, end); }
...
var ComboBox = _react2.default.createClass((_obj = {
displayName: 'ComboBox',
mixins: [__webpack_require__(52), __webpack_require__(55), __webpack_require__(56), __webpack_require__(61), __webpack_require__
(45)('input'), __webpack_require__(62)({
willHandle: function willHandle(focused) {
// not suggesting anymore
!focused && this.refs.input.accept();
},
didHandle: function didHandle(focused) {
if (!focused) this.close();
}
})],
propTypes: propTypes,
...
function componentDidUpdate() { var input = _compat2.default.findDOMNode(this), val = this.props.value; if (this.isSuggesting()) { var start = val.toLowerCase().indexOf(this._last.toLowerCase()) + this._last.length, end = val.length - start; if (start >= 0) { (0, _caret2.default)(input, start, start + end); } } }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function focus() { _compat2.default.findDOMNode(this).focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function handleChange(e) { var val = e.target.value, pl = !!this.props.placeholder; // IE fires input events when setting/unsetting placeholders. // issue #112 if (pl && !val && val === (this.props.value || '')) return; this._last = val; this.props.onChange(e, val); }
...
handleDateSelect: function handleDateSelect(date) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(date, this.props.value, this.props.currentDate),
dateStr = formatDate(date, format, this.props.culture);
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, [dateTime, dateStr]);
this.handleChange(dateTime, dateStr, true);
this.focus();
},
handleTimeSelect: function handleTimeSelect(datum) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(this.props.value, datum.date, this.props.currentDate),
dateStr = formatDate(datum.date, format, this.props.culture);
...
function isSuggesting() { var val = this.props.value, isSuggestion = this._last != null && val.toLowerCase().indexOf(this._last.toLowerCase()) !== -1; return this.props.suggest && isSuggestion; }
...
ariaActiveDescendantKey: 'combobox'
};
},
componentDidUpdate: function componentDidUpdate() {
this.refs.list && (0, _validateListInterface2.default)(this.refs.list);
},
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
var isSuggesting = this.refs.input && this.refs.input.isSuggesting(),
stateChanged = !_3.default.isShallowEqual(nextState, this.state),
valueChanged = !_3.default.isShallowEqual(nextProps, this.props);
return isSuggesting || stateChanged || valueChanged;
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var value = nextProps.value,
...
function render() { var _props = this.props, onKeyDown = _props.onKeyDown, props = _objectWithoutProperties(_props, ['onKeyDown']); delete props.suggest; return _react2.default.createElement(_Input2.default, _extends({}, props, { onKeyDown: onKeyDown, onChange: this.handleChange })); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function filter(items, searchTerm) { var matches = typeof this.props.filter === 'string' ? getFilter(_filter2.default[this.props.filter], searchTerm, this) : this. props.filter; if (!matches || !searchTerm || !searchTerm.trim() || searchTerm.length < (this.props.minLength || 1)) return items; return items.filter(function (item, idx) { return matches(item, searchTerm, idx); }); }
...
filter = _props.filter,
value = _props.value,
data = _props.data,
searchTerm = _props.searchTerm,
valueField = _props.valueField;
var processed = filter ? this.filter(data, searchTerm) : data,
initialIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField);
return {
filteredData: open && filter ? processed : null,
selectedItem: processed[initialIdx],
focusedItem: processed[initialIdx] || data[0]
};
...
function filterIndexOf(items, searchTerm) { var idx = -1, matches = typeof this.props.filter === 'function' ? this.props.filter : getFilter(_filter2.default[dflt(this.props.filter)], searchTerm, this); if (!searchTerm || !searchTerm.trim() || this.props.filter && searchTerm.length < (this.props.minLength || 1)) return -1; items.every(function (item, i) { if (matches(item, searchTerm, i)) return idx = i, false; return true; }); return idx; }
...
var rawIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField),
valueItem = rawIdx === -1 ? nextProps.value : nextProps.data[rawIdx],
isSuggesting = this.refs.input && this.refs.input.isSuggesting();
var items = this.process(nextProps.data, nextProps.value, (rawIdx === -1 || isSuggesting) && (0, _dataHelpers.dataText
)(valueItem, textField));
var idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField),
focused = this.filterIndexOf(items, (0, _dataHelpers.dataText)(valueItem, textField
));
this._searchTerm = '';
this.setState({
processedData: items,
selectedItem: items[idx],
focusedItem: items[idx === -1 ? focused !== -1 ? focused : 0 // focus the closest match
...
function getDefaultProps() { return { caseSensitive: false, minLength: 1 }; }
n/a
function _dataIndexOf(data, item) { return dataHelpers.dataIndexOf(data, item, this.props.valueField); }
n/a
function _dataItem(data, item) { return dataHelpers.dataItem(data, item, this.props.valueField); }
n/a
function _dataText(item) { return dataHelpers.dataText(item, this.props.textField); }
n/a
function _dataValue(item) { return dataHelpers.dataValue(item, this.props.valueField); }
n/a
function _valueMatcher(a, b) { return dataHelpers.valueMatcher(a, b, this.props.valueField); }
n/a
function componentWillMount() { (0, _warning2.default)(false, '`DataHelpersMixin` is deprecated and will be removed in a later version'); }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
deferControlTo = function (newComponent) { var additions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var nextMethods = arguments[2]; return uncontrollable(newComponent, _extends({}, controlledValues, additions), nextMethods); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { value: null, currentDate: new Date(), min: new Date(1900, 0, 1), max: new Date(2099, 11, 31), calendar: true, time: true, open: false, //calendar override footer: true, messages: { calendarButton: 'Select Date', timeButton: 'Select Time' }, ariaActiveDescendantKey: 'dropdownlist' }; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function _parse(string) { var format = getFormat(this.props, true), editFormat = this.props.editFormat, parse = this.props.parse, formats = []; if (typeof parse === 'function') return parse(string, this.props.culture); if (typeof format === 'string') formats.push(format); if (typeof editFormat === 'string') formats.push(editFormat); if (parse) formats = formats.concat(this.props.parse); (0, _invariant2.default)(formats.length, 'React Widgets: there are no specified `parse` formats provided and the `format` prop is a function. ' + 'the DateTimePicker is unable to parse `%s` into a dateTime, ' + 'please provide either a parse function or Globalize.js compatible string for `format`', string); return formatsParser(formats, this.props.culture, string); }
...
readOnly: this.props.readOnly,
placeholder: this.props.placeholder,
value: value
}));
},
_change: function _change(e) {
var val = e.target.value,
number = this._parse(e.target.value);
var isIntermediate = this.isIntermediateValue(number, val);
if (val == null || val.trim() === '') {
this.current('');
return this.props.onChange(null);
}
...
function _scrollTo(selected, list, focused) { var state = this._scrollState || (this._scrollState = {}), handler = this.props.onMove, lastVisible = state.visible, lastItem = state.focused, shown, changed; state.visible = !(!list.offsetWidth || !list.offsetHeight); state.focused = focused; changed = lastItem !== focused; shown = state.visible && !lastVisible; if (shown || state.visible && changed) { if (handler) handler(selected, list, focused);else { state.scrollCancel && state.scrollCancel(); state.scrollCancel = (0, _scrollTo3.default)(selected, list); } } }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function close() { if (this.props.open) (0, _widgetHelpers.notify)(this.props.onToggle, false); }
...
var DropdownList = _react2.default.createClass((_obj = {
displayName: 'DropdownList',
mixins: [__webpack_require__(52), __webpack_require__(53), __webpack_require__(54), __webpack_require__(55), __webpack_require__
(56), __webpack_require__(61), __webpack_require__(45)(), __webpack_require__(62)({
didHandle: function didHandle(focused) {
if (!focused) this.close();
}
})],
propTypes: propTypes,
getDefaultProps: function getDefaultProps() {
return {
...
function componentWillUnmount() { var timers = this._timers || {}; this._unmounted = true; for (var k in timers) { if (has(timers, k)) this.clearTimeout(k); } }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function focus() { var valueInput = this.refs.valueInput; if (valueInput && (0, _activeElement2.default)() !== _compat2.default.findDOMNode(valueInput)) valueInput.focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function mergedResult() { var a = one.apply(this, arguments); var b = two.apply(this, arguments); if (a == null) { return b; } else if (b == null) { return a; } var c = {}; mergeIntoWithNoDuplicateKeys(c, a); mergeIntoWithNoDuplicateKeys(c, b); return c; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { return { focused: false }; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
handleDateSelect: function handleDateSelect(date) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(date, this.props.value, this.props.currentDate),
dateStr = formatDate(date, format, this.props.culture);
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, [dateTime, dateStr]);
this.handleChange(dateTime, dateStr, true);
this.focus();
},
handleTimeSelect: function handleTimeSelect(datum) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(this.props.value, datum.date, this.props.currentDate),
dateStr = formatDate(datum.date, format, this.props.culture);
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (this.props.open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyPress
span>(e);
},
focus: function focus() {
var valueInput = this.refs.valueInput;
if (valueInput && (0, _activeElement2.default)() !== _compat2.default.findDOMNode(valueInput)) valueInput.focus();
},
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function inRangeValue(value) { if (value == null) return value; return _dates2.default.max(_dates2.default.min(value, this.props.max), this.props.min); }
...
this.changeCurrentDate(this.props.value);
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var bottom = VIEW_OPTIONS.indexOf(nextProps.initialView),
top = VIEW_OPTIONS.indexOf(nextProps.finalView),
current = VIEW_OPTIONS.indexOf(this.state.view),
view = this.state.view,
val = this.inRangeValue(nextProps.value);
if (current < bottom) this.setState({ view: view = nextProps.initialView });else if (current > top) this.setState
({ view: view = nextProps.finalView });
//if the value changes reset views to the new one
if (!_dates2.default.eq(val, dateOrNull(this.props.value), VIEW_UNIT[view])) {
this.changeCurrentDate(val, nextProps.currentDate);
}
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function open(view) { if (this.props.open !== view && this.props[view] === true) (0, _widgetHelpers.notify)(this.props.onToggle, view); }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
function render() { var _props5 = this.props, className = _props5.className, calendar = _props5.calendar, time = _props5.time, open = _props5.open, messages = _props5.messages, disabled = _props5.disabled, readOnly = _props5.readOnly, dropUp = _props5.dropUp; var focused = this.state.focused; var inputID = (0, _widgetHelpers.instanceId)(this, '_input'), timeListID = (0, _widgetHelpers.instanceId)(this, '_time_listbox'), dateListID = (0, _widgetHelpers.instanceId)(this, '_cal'), owns = ''; var elementProps = _3.default.omitOwnProps(this, Calendar, _TimeList2.default); var shouldRenderList = open || (0, _widgetHelpers.isFirstFocusedRender)(this); if (calendar) owns += dateListID; if (time) owns += ' ' + timeListID; return _react2.default.createElement( _Widget2.default, _extends({}, elementProps, { open: !!open, dropUp: dropUp, focused: focused, disabled: disabled, readOnly: readOnly, onBlur: this.handleBlur, onFocus: this.handleFocus, onKeyDown: this.handleKeyDown, onKeyPress: this.handleKeyPress, className: (0, _classnames2.default)(className, 'rw-datetimepicker', calendar && time && 'rw-has-both', !calendar && !time && 'rw-has-neither') }), this.renderInput(inputID, owns.trim()), this.renderButtons(messages), shouldRenderList && this.renderTimeList(timeListID, inputID), shouldRenderList && this.renderCalendar(dateListID, inputID) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function renderButtons(messages) { var _props2 = this.props, calendar = _props2.calendar, time = _props2.time, disabled = _props2.disabled, readOnly = _props2.readOnly; if (!calendar && !time) { return null; } return _react2.default.createElement( 'span', { className: 'rw-select' }, calendar && _react2.default.createElement(_Button2.default, { icon: 'calendar', className: 'rw-btn-calendar', label: messages.calendarButton, disabled: !!(disabled || readOnly), onClick: this._click.bind(null, _constants.datePopups.CALENDAR) }), time && _react2.default.createElement(_Button2.default, { icon: 'clock-o', className: 'rw-btn-time', label: messages.timeButton, disabled: !!(disabled || readOnly), onClick: this._click.bind(null, _constants.datePopups.TIME) }) ); }
...
onBlur: this.handleBlur,
onFocus: this.handleFocus,
onKeyDown: this.handleKeyDown,
onKeyPress: this.handleKeyPress,
className: (0, _classnames2.default)(className, 'rw-datetimepicker', calendar && time &&
x27;rw-has-both', !calendar && !time && 'rw-has-neither')
}),
this.renderInput(inputID, owns.trim()),
this.renderButtons(messages),
shouldRenderList && this.renderTimeList(timeListID, inputID),
shouldRenderList && this.renderCalendar(dateListID, inputID)
);
},
handleChange: function handleChange(date, str, constrain) {
var _props6 = this.props,
onChange = _props6.onChange,
...
function renderCalendar(id, inputID) { var _this = this; var _props3 = this.props, open = _props3.open, value = _props3.value, duration = _props3.duration, dropUp = _props3.dropUp; var calendarProps = _3.default.pickProps(this.props, Calendar); return _react2.default.createElement( _Popup2.default, { dropUp: dropUp, duration: duration, open: open === _constants.datePopups.CALENDAR, className: 'rw-calendar-popup' }, _react2.default.createElement(Calendar, _extends({}, calendarProps, { ref: 'calPopup', id: id, tabIndex: '-1', value: value, autoFocus: false, onChange: this.handleDateSelect // #75: need to aggressively reclaim focus from the calendar otherwise // disabled header/footer buttons will drop focus completely from the widget , onNavigate: function onNavigate() { return _this.focus(); }, currentDate: this.props.currentDate, onCurrentDateChange: this.props.onCurrentDateChange, 'aria-hidden': !open, 'aria-live': 'polite', 'aria-labelledby': inputID, ariaActiveDescendantKey: 'calendar' })) ); }
...
onKeyDown: this.handleKeyDown,
onKeyPress: this.handleKeyPress,
className: (0, _classnames2.default)(className, 'rw-datetimepicker', calendar && time &&
x27;rw-has-both', !calendar && !time && 'rw-has-neither')
}),
this.renderInput(inputID, owns.trim()),
this.renderButtons(messages),
shouldRenderList && this.renderTimeList(timeListID, inputID),
shouldRenderList && this.renderCalendar(dateListID, inputID)
);
},
handleChange: function handleChange(date, str, constrain) {
var _props6 = this.props,
onChange = _props6.onChange,
value = _props6.value;
...
function renderInput(id, owns) { var _props = this.props, open = _props.open, value = _props.value, editFormat = _props.editFormat, culture = _props.culture, busy = _props.busy, placeholder = _props.placeholder, disabled = _props.disabled, readOnly = _props.readOnly, name = _props.name, tabIndex = _props.tabIndex, autoFocus = _props.autoFocus, ariaLabelledby = _props['aria-labelledby'], ariaDescribedby = _props['aria-describedby']; var focused = this.state.focused; return _react2.default.createElement(_DateTimePickerInput2.default, { id: id, ref: 'valueInput', role: 'combobox', name: name, tabIndex: tabIndex, autoFocus: autoFocus, placeholder: placeholder, disabled: disabled, readOnly: readOnly, value: value, format: getFormat(this.props), editFormat: editFormat, editing: focused, culture: culture, parse: this._parse, onChange: this.handleChange, 'aria-haspopup': true, 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, 'aria-expanded': !!open, 'aria-busy': !!busy, 'aria-owns': owns }); }
...
_react2.default.createElement(_Select2.default, {
onClick: this.toggle,
disabled: !!(disabled || readOnly),
busy: busy,
icon: 'caret-down',
label: _3.default.result(messages.open, this.props)
}),
this.renderInput(listID),
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpening: function onOpening() {
...
function renderTimeList(id, inputID) { var _this2 = this; var _props4 = this.props, open = _props4.open, value = _props4.value, duration = _props4.duration, dropUp = _props4.dropUp, calendar = _props4.calendar, timeFormat = _props4.timeFormat, timeComponent = _props4.timeComponent; var timeListProps = _3.default.pickProps(this.props, _TimeList2.default); return _react2.default.createElement( _Popup2.default, { dropUp: dropUp, duration: duration, open: open === _constants.datePopups.TIME, onOpening: function onOpening() { return _this2.refs.timePopup.forceUpdate(); } }, _react2.default.createElement( 'div', null, _react2.default.createElement(_TimeList2.default, _extends({}, timeListProps, { ref: 'timePopup', id: id, format: timeFormat, value: dateOrNull(value), onMove: this._scrollTo, onSelect: this.handleTimeSelect, preserveDate: !!calendar, itemComponent: timeComponent, 'aria-labelledby': inputID, 'aria-live': open && 'polite', 'aria-hidden': !open, ariaActiveDescendantKey: 'timelist' })) ) ); }
...
onFocus: this.handleFocus,
onKeyDown: this.handleKeyDown,
onKeyPress: this.handleKeyPress,
className: (0, _classnames2.default)(className, 'rw-datetimepicker', calendar && time &&
x27;rw-has-both', !calendar && !time && 'rw-has-neither')
}),
this.renderInput(inputID, owns.trim()),
this.renderButtons(messages),
shouldRenderList && this.renderTimeList(timeListID, inputID),
shouldRenderList && this.renderCalendar(dateListID, inputID)
);
},
handleChange: function handleChange(date, str, constrain) {
var _props6 = this.props,
onChange = _props6.onChange,
value = _props6.value;
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function shouldComponentUpdate(nextProps, nextState) { return !_.isShallowEqual(this.props, nextProps) || !_.isShallowEqual(this.state, nextState); }
n/a
function toggle(view) { this.props.open ? this.props.open !== view ? this.open(view) : this.close(view) : this.open(view); }
...
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2
.default)(_compat2.default.findDOMNode(wrapper), e.target)) this.close();
(0, _widgetHelpers.notify)(this.props.onClick, e);
},
handleKeyDown: function handleKeyDown(e) {
var _this3 = this;
var key = e.key,
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function _parse(string) { var format = getFormat(this.props, true), editFormat = this.props.editFormat, parse = this.props.parse, formats = []; if (typeof parse === 'function') return parse(string, this.props.culture); if (typeof format === 'string') formats.push(format); if (typeof editFormat === 'string') formats.push(editFormat); if (parse) formats = formats.concat(this.props.parse); (0, _invariant2.default)(formats.length, 'React Widgets: there are no specified `parse` formats provided and the `format` prop is a function. ' + 'the DateTimePicker is unable to parse `%s` into a dateTime, ' + 'please provide either a parse function or Globalize.js compatible string for `format`', string); return formatsParser(formats, this.props.culture, string); }
...
readOnly: this.props.readOnly,
placeholder: this.props.placeholder,
value: value
}));
},
_change: function _change(e) {
var val = e.target.value,
number = this._parse(e.target.value);
var isIntermediate = this.isIntermediateValue(number, val);
if (val == null || val.trim() === '') {
this.current('');
return this.props.onChange(null);
}
...
function _scrollTo(selected, list, focused) { var state = this._scrollState || (this._scrollState = {}), handler = this.props.onMove, lastVisible = state.visible, lastItem = state.focused, shown, changed; state.visible = !(!list.offsetWidth || !list.offsetHeight); state.focused = focused; changed = lastItem !== focused; shown = state.visible && !lastVisible; if (shown || state.visible && changed) { if (handler) handler(selected, list, focused);else { state.scrollCancel && state.scrollCancel(); state.scrollCancel = (0, _scrollTo3.default)(selected, list); } } }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function close() { if (this.props.open) (0, _widgetHelpers.notify)(this.props.onToggle, false); }
...
var DropdownList = _react2.default.createClass((_obj = {
displayName: 'DropdownList',
mixins: [__webpack_require__(52), __webpack_require__(53), __webpack_require__(54), __webpack_require__(55), __webpack_require__
(56), __webpack_require__(61), __webpack_require__(45)(), __webpack_require__(62)({
didHandle: function didHandle(focused) {
if (!focused) this.close();
}
})],
propTypes: propTypes,
getDefaultProps: function getDefaultProps() {
return {
...
function focus() { var valueInput = this.refs.valueInput; if (valueInput && (0, _activeElement2.default)() !== _compat2.default.findDOMNode(valueInput)) valueInput.focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
handleDateSelect: function handleDateSelect(date) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(date, this.props.value, this.props.currentDate),
dateStr = formatDate(date, format, this.props.culture);
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, [dateTime, dateStr]);
this.handleChange(dateTime, dateStr, true);
this.focus();
},
handleTimeSelect: function handleTimeSelect(datum) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(this.props.value, datum.date, this.props.currentDate),
dateStr = formatDate(datum.date, format, this.props.culture);
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (this.props.open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyPress
span>(e);
},
focus: function focus() {
var valueInput = this.refs.valueInput;
if (valueInput && (0, _activeElement2.default)() !== _compat2.default.findDOMNode(valueInput)) valueInput.focus();
},
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function inRangeValue(value) { if (value == null) return value; return _dates2.default.max(_dates2.default.min(value, this.props.max), this.props.min); }
...
this.changeCurrentDate(this.props.value);
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var bottom = VIEW_OPTIONS.indexOf(nextProps.initialView),
top = VIEW_OPTIONS.indexOf(nextProps.finalView),
current = VIEW_OPTIONS.indexOf(this.state.view),
view = this.state.view,
val = this.inRangeValue(nextProps.value);
if (current < bottom) this.setState({ view: view = nextProps.initialView });else if (current > top) this.setState
({ view: view = nextProps.finalView });
//if the value changes reset views to the new one
if (!_dates2.default.eq(val, dateOrNull(this.props.value), VIEW_UNIT[view])) {
this.changeCurrentDate(val, nextProps.currentDate);
}
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function open(view) { if (this.props.open !== view && this.props[view] === true) (0, _widgetHelpers.notify)(this.props.onToggle, view); }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
function renderButtons(messages) { var _props2 = this.props, calendar = _props2.calendar, time = _props2.time, disabled = _props2.disabled, readOnly = _props2.readOnly; if (!calendar && !time) { return null; } return _react2.default.createElement( 'span', { className: 'rw-select' }, calendar && _react2.default.createElement(_Button2.default, { icon: 'calendar', className: 'rw-btn-calendar', label: messages.calendarButton, disabled: !!(disabled || readOnly), onClick: this._click.bind(null, _constants.datePopups.CALENDAR) }), time && _react2.default.createElement(_Button2.default, { icon: 'clock-o', className: 'rw-btn-time', label: messages.timeButton, disabled: !!(disabled || readOnly), onClick: this._click.bind(null, _constants.datePopups.TIME) }) ); }
...
onBlur: this.handleBlur,
onFocus: this.handleFocus,
onKeyDown: this.handleKeyDown,
onKeyPress: this.handleKeyPress,
className: (0, _classnames2.default)(className, 'rw-datetimepicker', calendar && time &&
x27;rw-has-both', !calendar && !time && 'rw-has-neither')
}),
this.renderInput(inputID, owns.trim()),
this.renderButtons(messages),
shouldRenderList && this.renderTimeList(timeListID, inputID),
shouldRenderList && this.renderCalendar(dateListID, inputID)
);
},
handleChange: function handleChange(date, str, constrain) {
var _props6 = this.props,
onChange = _props6.onChange,
...
function renderCalendar(id, inputID) { var _this = this; var _props3 = this.props, open = _props3.open, value = _props3.value, duration = _props3.duration, dropUp = _props3.dropUp; var calendarProps = _3.default.pickProps(this.props, Calendar); return _react2.default.createElement( _Popup2.default, { dropUp: dropUp, duration: duration, open: open === _constants.datePopups.CALENDAR, className: 'rw-calendar-popup' }, _react2.default.createElement(Calendar, _extends({}, calendarProps, { ref: 'calPopup', id: id, tabIndex: '-1', value: value, autoFocus: false, onChange: this.handleDateSelect // #75: need to aggressively reclaim focus from the calendar otherwise // disabled header/footer buttons will drop focus completely from the widget , onNavigate: function onNavigate() { return _this.focus(); }, currentDate: this.props.currentDate, onCurrentDateChange: this.props.onCurrentDateChange, 'aria-hidden': !open, 'aria-live': 'polite', 'aria-labelledby': inputID, ariaActiveDescendantKey: 'calendar' })) ); }
...
onKeyDown: this.handleKeyDown,
onKeyPress: this.handleKeyPress,
className: (0, _classnames2.default)(className, 'rw-datetimepicker', calendar && time &&
x27;rw-has-both', !calendar && !time && 'rw-has-neither')
}),
this.renderInput(inputID, owns.trim()),
this.renderButtons(messages),
shouldRenderList && this.renderTimeList(timeListID, inputID),
shouldRenderList && this.renderCalendar(dateListID, inputID)
);
},
handleChange: function handleChange(date, str, constrain) {
var _props6 = this.props,
onChange = _props6.onChange,
value = _props6.value;
...
function renderInput(id, owns) { var _props = this.props, open = _props.open, value = _props.value, editFormat = _props.editFormat, culture = _props.culture, busy = _props.busy, placeholder = _props.placeholder, disabled = _props.disabled, readOnly = _props.readOnly, name = _props.name, tabIndex = _props.tabIndex, autoFocus = _props.autoFocus, ariaLabelledby = _props['aria-labelledby'], ariaDescribedby = _props['aria-describedby']; var focused = this.state.focused; return _react2.default.createElement(_DateTimePickerInput2.default, { id: id, ref: 'valueInput', role: 'combobox', name: name, tabIndex: tabIndex, autoFocus: autoFocus, placeholder: placeholder, disabled: disabled, readOnly: readOnly, value: value, format: getFormat(this.props), editFormat: editFormat, editing: focused, culture: culture, parse: this._parse, onChange: this.handleChange, 'aria-haspopup': true, 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, 'aria-expanded': !!open, 'aria-busy': !!busy, 'aria-owns': owns }); }
...
_react2.default.createElement(_Select2.default, {
onClick: this.toggle,
disabled: !!(disabled || readOnly),
busy: busy,
icon: 'caret-down',
label: _3.default.result(messages.open, this.props)
}),
this.renderInput(listID),
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpening: function onOpening() {
...
function renderTimeList(id, inputID) { var _this2 = this; var _props4 = this.props, open = _props4.open, value = _props4.value, duration = _props4.duration, dropUp = _props4.dropUp, calendar = _props4.calendar, timeFormat = _props4.timeFormat, timeComponent = _props4.timeComponent; var timeListProps = _3.default.pickProps(this.props, _TimeList2.default); return _react2.default.createElement( _Popup2.default, { dropUp: dropUp, duration: duration, open: open === _constants.datePopups.TIME, onOpening: function onOpening() { return _this2.refs.timePopup.forceUpdate(); } }, _react2.default.createElement( 'div', null, _react2.default.createElement(_TimeList2.default, _extends({}, timeListProps, { ref: 'timePopup', id: id, format: timeFormat, value: dateOrNull(value), onMove: this._scrollTo, onSelect: this.handleTimeSelect, preserveDate: !!calendar, itemComponent: timeComponent, 'aria-labelledby': inputID, 'aria-live': open && 'polite', 'aria-hidden': !open, ariaActiveDescendantKey: 'timelist' })) ) ); }
...
onFocus: this.handleFocus,
onKeyDown: this.handleKeyDown,
onKeyPress: this.handleKeyPress,
className: (0, _classnames2.default)(className, 'rw-datetimepicker', calendar && time &&
x27;rw-has-both', !calendar && !time && 'rw-has-neither')
}),
this.renderInput(inputID, owns.trim()),
this.renderButtons(messages),
shouldRenderList && this.renderTimeList(timeListID, inputID),
shouldRenderList && this.renderCalendar(dateListID, inputID)
);
},
handleChange: function handleChange(date, str, constrain) {
var _props6 = this.props,
onChange = _props6.onChange,
value = _props6.value;
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function toggle(view) { this.props.open ? this.props.open !== view ? this.open(view) : this.close(view) : this.open(view); }
...
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2
.default)(_compat2.default.findDOMNode(wrapper), e.target)) this.close();
(0, _widgetHelpers.notify)(this.props.onClick, e);
},
handleKeyDown: function handleKeyDown(e) {
var _this3 = this;
var key = e.key,
...
currentDate = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
open = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
value = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
function componentWillMount() { var _this2 = this; var props = this.props; this._values = {}; controlledProps.forEach(function (key) { _this2._values[key] = props[utils.defaultKey(key)]; }); }
n/a
function componentWillReceiveProps(nextProps) { var _this3 = this; var props = this.props; if (mixin.componentWillReceiveProps) { mixin.componentWillReceiveProps.call(this, nextProps); } controlledProps.forEach(function (key) { if (utils.getValue(nextProps, key) === undefined && utils.getValue(props, key) !== undefined) { _this3._values[key] = nextProps[utils.defaultKey(key)]; } }); }
n/a
function componentWillUnmount() { this.unmounted = true; }
n/a
focus = function () { var _refs$inner; return (_refs$inner = this.refs.inner)[method].apply(_refs$inner, arguments); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function getControlledInstance() { return this.refs.inner; }
n/a
function render() { var _this4 = this; var newProps = {}, props = omitProps(this.props); utils.each(controlledValues, function (handle, propName) { var linkPropName = utils.getLinkName(propName), prop = _this4.props[propName]; if (linkPropName && !isProp(_this4.props, propName) && isProp(_this4.props, linkPropName)) { prop = _this4.props[linkPropName].value; } newProps[propName] = prop !== undefined ? prop : _this4._values[propName]; newProps[handle] = setAndNotify.bind(_this4, propName); }); newProps = _extends({}, props, newProps, { ref: isCompositeComponent ? 'inner' : null }); return _react2.default.createElement(Component, newProps); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function shouldComponentUpdate() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return !mixin.shouldComponentUpdate || mixin.shouldComponentUpdate.apply(this, args); }
n/a
DateTimePickerInput = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function componentWillReceiveProps(nextProps) { var value = nextProps.value, editing = nextProps.editing, editFormat = nextProps.editFormat, format = nextProps.format, culture = nextProps.culture; this.setState({ textValue: formatDate(value, editing && editFormat ? editFormat : format, culture) }); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function focus() { _compat2.default.findDOMNode(this).focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { var _props = this.props, value = _props.value, editing = _props.editing, editFormat = _props.editFormat, format = _props.format, culture = _props.culture; return { textValue: formatDate(value, editing && editFormat ? editFormat : format, culture) }; }
n/a
function handleBlur(event) { var _props3 = this.props, format = _props3.format, culture = _props3.culture, parse = _props3.parse, onChange = _props3.onChange, onBlur = _props3.onBlur; onBlur && onBlur(event); if (this._needsFlush) { var date = parse(event.target.value); this._needsFlush = false; onChange(date, formatDate(date, format, culture)); } }
n/a
function handleChange(_ref) { var value = _ref.target.value; this._needsFlush = true; this.setState({ textValue: value }); }
...
handleDateSelect: function handleDateSelect(date) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(date, this.props.value, this.props.currentDate),
dateStr = formatDate(date, format, this.props.culture);
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, [dateTime, dateStr]);
this.handleChange(dateTime, dateStr, true);
this.focus();
},
handleTimeSelect: function handleTimeSelect(datum) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(this.props.value, datum.date, this.props.currentDate),
dateStr = formatDate(datum.date, format, this.props.culture);
...
function render() { var _props2 = this.props, disabled = _props2.disabled, readOnly = _props2.readOnly; var textValue = this.state.textValue; var props = _3.default.omitOwnProps(this); return _react2.default.createElement(_Input2.default, _extends({}, props, { type: 'text', value: textValue, disabled: disabled, readOnly: readOnly, onChange: this.handleChange, onBlur: this.handleBlur })); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
Decade = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function componentDidUpdate() { var activeId = optionId((0, _widgetHelpers.instanceId)(this), this.props.focused); this.ariaActiveDescendant(activeId); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getChildContext() { var _this = this; return this._context || (this._context = { activeDescendants: { reconcile: function reconcile(key, id) { return _this.ariaActiveDescendant(id, key); } } }); }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function isRtl() { return !!this.context.isRtl; }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function render() { var focused = this.props.focused; return _react2.default.createElement( _CalendarView2.default, _3.default.omitOwnProps(this), _react2.default.createElement( 'tbody', null, _3.default.chunk(getDecadeYears(focused), 4).map(this.renderRow) ) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function renderRow(row, rowIdx) { var _props = this.props, focused = _props.focused, disabled = _props.disabled, onChange = _props.onChange, yearFormat = _props.yearFormat, value = _props.value, today = _props.today, culture = _props.culture, min = _props.min, max = _props.max; var id = (0, _widgetHelpers.instanceId)(this); return _react2.default.createElement( _CalendarView2.default.Row, { key: rowIdx }, row.map(function (date, colIdx) { var label = _localizers.date.format(date, _localizers.date.getFormat('year', yearFormat), culture); return _react2.default.createElement( _CalendarView2.default.Cell, { key: colIdx, unit: 'year', id: optionId(id, date), label: label, date: date, now: today, min: min, max: max, onChange: onChange, focused: focused, selected: value, disabled: disabled }, label ); }) ); }
n/a
function shouldComponentUpdate(nextProps, nextState) { return !_.isShallowEqual(this.props, nextProps) || !_.isShallowEqual(this.state, nextState); }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
deferControlTo = function (newComponent) { var additions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var nextMethods = arguments[2]; return uncontrollable(newComponent, _extends({}, controlledValues, additions), nextMethods); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function mergedResult() { var a = one.apply(this, arguments); var b = two.apply(this, arguments); if (a == null) { return b; } else if (b == null) { return a; } var c = {}; mergeIntoWithNoDuplicateKeys(c, a); mergeIntoWithNoDuplicateKeys(c, b); return c; }
n/a
function _data() { return this.state.filteredData || this.props.data.concat(); }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function _scrollTo(selected, list, focused) { var state = this._scrollState || (this._scrollState = {}), handler = this.props.onMove, lastVisible = state.visible, lastItem = state.focused, shown, changed; state.visible = !(!list.offsetWidth || !list.offsetHeight); state.focused = focused; changed = lastItem !== focused; shown = state.visible && !lastVisible; if (shown || state.visible && changed) { if (handler) handler(selected, list, focused);else { state.scrollCancel && state.scrollCancel(); state.scrollCancel = (0, _scrollTo3.default)(selected, list); } } }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function change(data) { if (!(0, _dataHelpers.valueMatcher)(data, this.props.value, this.props.valueField)) { (0, _widgetHelpers.notify)(this.props.onChange, data); (0, _widgetHelpers.notify)(this.props.onSearch, ''); this.close(); } }
...
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper
), e.target)) this.close();
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function close() { (0, _widgetHelpers.notify)(this.props.onToggle, false); }
...
var DropdownList = _react2.default.createClass((_obj = {
displayName: 'DropdownList',
mixins: [__webpack_require__(52), __webpack_require__(53), __webpack_require__(54), __webpack_require__(55), __webpack_require__
(56), __webpack_require__(61), __webpack_require__(45)(), __webpack_require__(62)({
didHandle: function didHandle(focused) {
if (!focused) this.close();
}
})],
propTypes: propTypes,
getDefaultProps: function getDefaultProps() {
return {
...
function componentDidMount() { var autoFocus = this.props.autoFocus; if (autoFocus) this.focus ? this.focus() : (0, _reactDom.findDOMNode)(this).focus(); }
n/a
function componentDidUpdate() { this.refs.list && (0, _validateListInterface2.default)(this.refs.list); }
n/a
function componentWillReceiveProps(props) { var open = props.open, filter = props.filter, value = props.value, data = props.data, searchTerm = props.searchTerm, valueField = props.valueField; var processed = filter ? this.filter(data, searchTerm) : data, idx = (0, _dataHelpers.dataIndexOf)(data, value, valueField); this.setState({ filteredData: open && filter ? processed : null, selectedItem: processed[idx], focusedItem: processed[!~idx ? 0 : idx] }); }
n/a
function componentWillUnmount() { var timers = this._timers || {}; this._unmounted = true; for (var k in timers) { if (has(timers, k)) this.clearTimeout(k); } }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function filter(items, searchTerm) { var matches = typeof this.props.filter === 'string' ? getFilter(_filter2.default[this.props.filter], searchTerm, this) : this. props.filter; if (!matches || !searchTerm || !searchTerm.trim() || searchTerm.length < (this.props.minLength || 1)) return items; return items.filter(function (item, idx) { return matches(item, searchTerm, idx); }); }
...
filter = _props.filter,
value = _props.value,
data = _props.data,
searchTerm = _props.searchTerm,
valueField = _props.valueField;
var processed = filter ? this.filter(data, searchTerm) : data,
initialIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField);
return {
filteredData: open && filter ? processed : null,
selectedItem: processed[initialIdx],
focusedItem: processed[initialIdx] || data[0]
};
...
function filterIndexOf(items, searchTerm) { var idx = -1, matches = typeof this.props.filter === 'function' ? this.props.filter : getFilter(_filter2.default[dflt(this.props.filter)], searchTerm, this); if (!searchTerm || !searchTerm.trim() || this.props.filter && searchTerm.length < (this.props.minLength || 1)) return -1; items.every(function (item, i) { if (matches(item, searchTerm, i)) return idx = i, false; return true; }); return idx; }
...
var rawIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField),
valueItem = rawIdx === -1 ? nextProps.value : nextProps.data[rawIdx],
isSuggesting = this.refs.input && this.refs.input.isSuggesting();
var items = this.process(nextProps.data, nextProps.value, (rawIdx === -1 || isSuggesting) && (0, _dataHelpers.dataText
)(valueItem, textField));
var idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField),
focused = this.filterIndexOf(items, (0, _dataHelpers.dataText)(valueItem, textField
));
this._searchTerm = '';
this.setState({
processedData: items,
selectedItem: items[idx],
focusedItem: items[idx === -1 ? focused !== -1 ? focused : 0 // focus the closest match
...
function focus(target) { var _props4 = this.props, filter = _props4.filter, open = _props4.open; var inst = target || (filter && open ? this.refs.filter : this.refs.input); inst = _compat2.default.findDOMNode(inst); if ((0, _activeElement2.default)() !== inst) inst.focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function mergedResult() { var a = one.apply(this, arguments); var b = two.apply(this, arguments); if (a == null) { return b; } else if (b == null) { return a; } var c = {}; mergeIntoWithNoDuplicateKeys(c, a); mergeIntoWithNoDuplicateKeys(c, b); return c; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { var _props = this.props, open = _props.open, filter = _props.filter, value = _props.value, data = _props.data, searchTerm = _props.searchTerm, valueField = _props.valueField; var processed = filter ? this.filter(data, searchTerm) : data, initialIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField); return { filteredData: open && filter ? processed : null, selectedItem: processed[initialIdx], focusedItem: processed[initialIdx] || data[0] }; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (this.props.open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyPress
span>(e);
},
focus: function focus() {
var valueInput = this.refs.valueInput;
if (valueInput && (0, _activeElement2.default)() !== _compat2.default.findDOMNode(valueInput)) valueInput.focus();
},
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
_this3.close(), _compat2.default.findDOMNode(_this3).focus();
};
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
var change = function change(item, fromList) {
if (item == null) return;
fromList ? _this3.handleSelect(item) : _this3.change(item);
};
if (e.defaultPrevented) return;
if (key === 'End') {
e.preventDefault();
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function open() { (0, _widgetHelpers.notify)(this.props.onToggle, true); }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
function render() { var _this2 = this; var _props3 = this.props, className = _props3.className, tabIndex = _props3.tabIndex, duration = _props3.duration, valueField = _props3.valueField, textField = _props3.textField, groupBy = _props3.groupBy, messages = _props3.messages, data = _props3.data, busy = _props3.busy, dropUp = _props3.dropUp, placeholder = _props3.placeholder, value = _props3.value, open = _props3.open, valueComponent = _props3.valueComponent, List = _props3.listComponent; List = List || groupBy && _ListGroupable2.default || _List2.default; var focused = this.state.focused; var disabled = (0, _interaction.isDisabled)(this.props), readOnly = (0, _interaction.isReadOnly)(this.props), valueItem = (0, _dataHelpers.dataItem)(data, value, valueField) // take value from the raw data , listID = (0, _widgetHelpers.instanceId)(this, '__listbox'); var elementProps = _extends(_3.default.omitOwnProps(this, List), { role: 'combobox', tabIndex: tabIndex || 0, 'aria-owns': listID, 'aria-expanded': !!open, 'aria-haspopup': true, 'aria-busy': !!busy, 'aria-live': !open && 'polite', 'aria-autocomplete': 'list', 'aria-disabled': disabled, 'aria-readonly': readOnly }); var shouldRenderPopup = open || (0, _widgetHelpers.isFirstFocusedRender)(this); messages = msgs(messages); return _react2.default.createElement( _Widget2.default, _extends({}, elementProps, { ref: 'input', className: (0, _classnames2.default)(className, 'rw-dropdownlist'), open: open, dropUp: dropUp, focused: focused, disabled: disabled, readOnly: readOnly, onBlur: this.handleBlur, onFocus: this.handleFocus, onClick: this.handleClick, onKeyDown: this.handleKeyDown, onKeyPress: this.handleKeyPress }), _react2.default.createElement(_Select2.default, { busy: busy, icon: 'caret-down', component: 'span', className: 'rw-dropdownlist-picker', label: result(messages.open, this.props) }), _react2.default.createElement(_DropdownListInput2.default, { value: valueItem, textField: textField, placeholder: placeholder, valueComponent: valueComponent }), shouldRenderPopup && _react2.default.createElement( _Popup2.default, { open: open, dropUp: dropUp, duration: duration, onOpen: function onOpen() { return _this2.focus(); }, onOpening: function onOpening() { return _this2.refs.list.forceUpdate(); } }, this.renderList(List, listID, messages) ) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function renderFilter(messages) { var _this = this; return _react2.default.createElement( 'div', { ref: 'filterWrapper', className: 'rw-filter-input' }, _react2.default.createElement(_Select2.default, { component: 'span', icon: 'search' }), _react2.default.createElement(_Input2.default, { ref: 'filter', value: this.props.searchTerm, placeholder: _3.default.result(messages.filterPlaceholder, this.props), onChange: function onChange(e) { return (0, _widgetHelpers.notify)(_this.props.onSearch, e.target.value); } }) ); }
...
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
id: id,
data: items,
'aria-live': open && 'polite',
'aria-labelledby': (0, _widgetHelpers.instanceId)(this),
'aria-hidden': !this.props.open,
...
function renderList(List, id, messages) { var _props2 = this.props, open = _props2.open, filter = _props2.filter, data = _props2.data; var _state = this.state, selectedItem = _state.selectedItem, focusedItem = _state.focusedItem; var listProps = _3.default.pickProps(this.props, List); var items = this._data(); return _react2.default.createElement( 'div', null, filter && this.renderFilter(messages), _react2.default.createElement(List, _extends({}, listProps, { ref: 'list', id: id, data: items, 'aria-live': open && 'polite', 'aria-labelledby': (0, _widgetHelpers.instanceId)(this), 'aria-hidden': !this.props.open, selected: selectedItem, focused: open ? focusedItem : null, onSelect: this.handleSelect, onMove: this._scrollTo, messages: { emptyList: data.length ? messages.emptyFilter : messages.emptyList } })) ); }
...
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
...
function search(character, cb) { var _this5 = this; var word = ((this._searchTerm || '') + character).toLowerCase(); if (!character) return; this._searchTerm = word; this.setTimeout('search', function () { var list = _this5.refs.list, key = _this5.props.open ? 'focusedItem' : 'selectedItem', item = list.next(_this5.state[key], word); _this5._searchTerm = ''; if (item) cb(item); }, this.props.delay); }
...
handleKeyPress: function handleKeyPress(e) {
var _this4 = this;
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (!(this.props.filter && this.props.open)) this.search(String.fromCharCode
(e.which), function (item) {
_this4.isMounted() && _this4.props.open ? _this4.setState({ focusedItem: item }) : item && _this4.change
(item);
});
},
change: function change(data) {
if (!(0, _dataHelpers.valueMatcher)(data, this.props.value, this.props.valueField)) {
(0, _widgetHelpers.notify)(this.props.onChange, data);
(0, _widgetHelpers.notify)(this.props.onSearch, '');
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function shouldComponentUpdate(nextProps, nextState) { return !_.isShallowEqual(this.props, nextProps) || !_.isShallowEqual(this.state, nextState); }
n/a
function toggle() { this.props.open ? this.close() : this.open(); }
...
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2
.default)(_compat2.default.findDOMNode(wrapper), e.target)) this.close();
(0, _widgetHelpers.notify)(this.props.onClick, e);
},
handleKeyDown: function handleKeyDown(e) {
var _this3 = this;
var key = e.key,
...
function _data() { return this.state.filteredData || this.props.data.concat(); }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function _scrollTo(selected, list, focused) { var state = this._scrollState || (this._scrollState = {}), handler = this.props.onMove, lastVisible = state.visible, lastItem = state.focused, shown, changed; state.visible = !(!list.offsetWidth || !list.offsetHeight); state.focused = focused; changed = lastItem !== focused; shown = state.visible && !lastVisible; if (shown || state.visible && changed) { if (handler) handler(selected, list, focused);else { state.scrollCancel && state.scrollCancel(); state.scrollCancel = (0, _scrollTo3.default)(selected, list); } } }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function change(data) { if (!(0, _dataHelpers.valueMatcher)(data, this.props.value, this.props.valueField)) { (0, _widgetHelpers.notify)(this.props.onChange, data); (0, _widgetHelpers.notify)(this.props.onSearch, ''); this.close(); } }
...
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper
), e.target)) this.close();
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function close() { (0, _widgetHelpers.notify)(this.props.onToggle, false); }
...
var DropdownList = _react2.default.createClass((_obj = {
displayName: 'DropdownList',
mixins: [__webpack_require__(52), __webpack_require__(53), __webpack_require__(54), __webpack_require__(55), __webpack_require__
(56), __webpack_require__(61), __webpack_require__(45)(), __webpack_require__(62)({
didHandle: function didHandle(focused) {
if (!focused) this.close();
}
})],
propTypes: propTypes,
getDefaultProps: function getDefaultProps() {
return {
...
function filter(items, searchTerm) { var matches = typeof this.props.filter === 'string' ? getFilter(_filter2.default[this.props.filter], searchTerm, this) : this. props.filter; if (!matches || !searchTerm || !searchTerm.trim() || searchTerm.length < (this.props.minLength || 1)) return items; return items.filter(function (item, idx) { return matches(item, searchTerm, idx); }); }
...
filter = _props.filter,
value = _props.value,
data = _props.data,
searchTerm = _props.searchTerm,
valueField = _props.valueField;
var processed = filter ? this.filter(data, searchTerm) : data,
initialIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField);
return {
filteredData: open && filter ? processed : null,
selectedItem: processed[initialIdx],
focusedItem: processed[initialIdx] || data[0]
};
...
function filterIndexOf(items, searchTerm) { var idx = -1, matches = typeof this.props.filter === 'function' ? this.props.filter : getFilter(_filter2.default[dflt(this.props.filter)], searchTerm, this); if (!searchTerm || !searchTerm.trim() || this.props.filter && searchTerm.length < (this.props.minLength || 1)) return -1; items.every(function (item, i) { if (matches(item, searchTerm, i)) return idx = i, false; return true; }); return idx; }
...
var rawIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField),
valueItem = rawIdx === -1 ? nextProps.value : nextProps.data[rawIdx],
isSuggesting = this.refs.input && this.refs.input.isSuggesting();
var items = this.process(nextProps.data, nextProps.value, (rawIdx === -1 || isSuggesting) && (0, _dataHelpers.dataText
)(valueItem, textField));
var idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField),
focused = this.filterIndexOf(items, (0, _dataHelpers.dataText)(valueItem, textField
));
this._searchTerm = '';
this.setState({
processedData: items,
selectedItem: items[idx],
focusedItem: items[idx === -1 ? focused !== -1 ? focused : 0 // focus the closest match
...
function focus(target) { var _props4 = this.props, filter = _props4.filter, open = _props4.open; var inst = target || (filter && open ? this.refs.filter : this.refs.input); inst = _compat2.default.findDOMNode(inst); if ((0, _activeElement2.default)() !== inst) inst.focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (this.props.open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyPress
span>(e);
},
focus: function focus() {
var valueInput = this.refs.valueInput;
if (valueInput && (0, _activeElement2.default)() !== _compat2.default.findDOMNode(valueInput)) valueInput.focus();
},
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
_this3.close(), _compat2.default.findDOMNode(_this3).focus();
};
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
var change = function change(item, fromList) {
if (item == null) return;
fromList ? _this3.handleSelect(item) : _this3.change(item);
};
if (e.defaultPrevented) return;
if (key === 'End') {
e.preventDefault();
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function open() { (0, _widgetHelpers.notify)(this.props.onToggle, true); }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
function renderFilter(messages) { var _this = this; return _react2.default.createElement( 'div', { ref: 'filterWrapper', className: 'rw-filter-input' }, _react2.default.createElement(_Select2.default, { component: 'span', icon: 'search' }), _react2.default.createElement(_Input2.default, { ref: 'filter', value: this.props.searchTerm, placeholder: _3.default.result(messages.filterPlaceholder, this.props), onChange: function onChange(e) { return (0, _widgetHelpers.notify)(_this.props.onSearch, e.target.value); } }) ); }
...
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
id: id,
data: items,
'aria-live': open && 'polite',
'aria-labelledby': (0, _widgetHelpers.instanceId)(this),
'aria-hidden': !this.props.open,
...
function renderList(List, id, messages) { var _props2 = this.props, open = _props2.open, filter = _props2.filter, data = _props2.data; var _state = this.state, selectedItem = _state.selectedItem, focusedItem = _state.focusedItem; var listProps = _3.default.pickProps(this.props, List); var items = this._data(); return _react2.default.createElement( 'div', null, filter && this.renderFilter(messages), _react2.default.createElement(List, _extends({}, listProps, { ref: 'list', id: id, data: items, 'aria-live': open && 'polite', 'aria-labelledby': (0, _widgetHelpers.instanceId)(this), 'aria-hidden': !this.props.open, selected: selectedItem, focused: open ? focusedItem : null, onSelect: this.handleSelect, onMove: this._scrollTo, messages: { emptyList: data.length ? messages.emptyFilter : messages.emptyList } })) ); }
...
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
...
function search(character, cb) { var _this5 = this; var word = ((this._searchTerm || '') + character).toLowerCase(); if (!character) return; this._searchTerm = word; this.setTimeout('search', function () { var list = _this5.refs.list, key = _this5.props.open ? 'focusedItem' : 'selectedItem', item = list.next(_this5.state[key], word); _this5._searchTerm = ''; if (item) cb(item); }, this.props.delay); }
...
handleKeyPress: function handleKeyPress(e) {
var _this4 = this;
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (!(this.props.filter && this.props.open)) this.search(String.fromCharCode
(e.which), function (item) {
_this4.isMounted() && _this4.props.open ? _this4.setState({ focusedItem: item }) : item && _this4.change
(item);
});
},
change: function change(data) {
if (!(0, _dataHelpers.valueMatcher)(data, this.props.value, this.props.valueField)) {
(0, _widgetHelpers.notify)(this.props.onChange, data);
(0, _widgetHelpers.notify)(this.props.onSearch, '');
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function toggle() { this.props.open ? this.close() : this.open(); }
...
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2
.default)(_compat2.default.findDOMNode(wrapper), e.target)) this.close();
(0, _widgetHelpers.notify)(this.props.onClick, e);
},
handleKeyDown: function handleKeyDown(e) {
var _this3 = this;
var key = e.key,
...
open = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
searchTerm = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
value = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
function componentWillMount() { var _this2 = this; var props = this.props; this._values = {}; controlledProps.forEach(function (key) { _this2._values[key] = props[utils.defaultKey(key)]; }); }
n/a
function componentWillReceiveProps(nextProps) { var _this3 = this; var props = this.props; if (mixin.componentWillReceiveProps) { mixin.componentWillReceiveProps.call(this, nextProps); } controlledProps.forEach(function (key) { if (utils.getValue(nextProps, key) === undefined && utils.getValue(props, key) !== undefined) { _this3._values[key] = nextProps[utils.defaultKey(key)]; } }); }
n/a
function componentWillUnmount() { this.unmounted = true; }
n/a
focus = function () { var _refs$inner; return (_refs$inner = this.refs.inner)[method].apply(_refs$inner, arguments); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function getControlledInstance() { return this.refs.inner; }
n/a
function render() { var _this4 = this; var newProps = {}, props = omitProps(this.props); utils.each(controlledValues, function (handle, propName) { var linkPropName = utils.getLinkName(propName), prop = _this4.props[propName]; if (linkPropName && !isProp(_this4.props, propName) && isProp(_this4.props, linkPropName)) { prop = _this4.props[linkPropName].value; } newProps[propName] = prop !== undefined ? prop : _this4._values[propName]; newProps[handle] = setAndNotify.bind(_this4, propName); }); newProps = _extends({}, props, newProps, { ref: isCompositeComponent ? 'inner' : null }); return _react2.default.createElement(Component, newProps); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function shouldComponentUpdate() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return !mixin.shouldComponentUpdate || mixin.shouldComponentUpdate.apply(this, args); }
n/a
function DropdownListInput() { _classCallCheck(this, DropdownListInput); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
function render() { var _props = this.props, placeholder = _props.placeholder, value = _props.value, textField = _props.textField, Component = _props.valueComponent; return _react2.default.createElement( 'div', { className: 'rw-input' }, !value && placeholder ? _react2.default.createElement( 'span', { className: 'rw-placeholder' }, placeholder ) : Component ? _react2.default.createElement(Component, { item: value }) : (0, _dataHelpers.dataText)(value, textField) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
Footer = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function render() { var _props = this.props, disabled = _props.disabled, readOnly = _props.readOnly, value = _props.value; return _react2.default.createElement( 'div', { className: 'rw-footer' }, _react2.default.createElement( _Button2.default, { disabled: !!(disabled || readOnly), onClick: this.props.onClick.bind(null, value) }, _localizers.date.format(value, format(this.props), this.props.culture) ) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
Header = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { messages: { moveBack: 'navigate back', moveForward: 'navigate forward' } }; }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function isRtl() { return !!this.context.isRtl; }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function render() { var _props = this.props, messages = _props.messages, label = _props.label, labelId = _props.labelId, onMoveRight = _props.onMoveRight, onMoveLeft = _props.onMoveLeft, onViewChange = _props.onViewChange, prevDisabled = _props.prevDisabled, upDisabled = _props.upDisabled, nextDisabled = _props.nextDisabled; var rtl = this.isRtl(); return _react2.default.createElement( 'div', { className: 'rw-header' }, _react2.default.createElement(_Button2.default, { className: 'rw-btn-left', onClick: onMoveLeft, disabled: prevDisabled, label: messages.moveBack, icon: 'caret-' + (rtl ? 'right' : 'left') }), _react2.default.createElement( _Button2.default, { id: labelId, onClick: onViewChange, className: 'rw-btn-view', disabled: upDisabled, 'aria-live': 'polite', 'aria-atomic': 'true' }, label ), _react2.default.createElement(_Button2.default, { className: 'rw-btn-right', onClick: onMoveRight, disabled: nextDisabled, label: messages.moveForward, icon: 'caret-' + (rtl ? 'left' : 'right') }) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function shouldComponentUpdate(nextProps, nextState) { return !_.isShallowEqual(this.props, nextProps) || !_.isShallowEqual(this.state, nextState); }
n/a
function Input() { _classCallCheck(this, Input); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
function render() { var _props = this.props, className = _props.className, disabled = _props.disabled, readOnly = _props.readOnly, value = _props.value, tabIndex = _props.tabIndex, _props$component = _props.component, Component = _props$component === undefined ? 'input' : _props$component, props = _objectWithoutProperties(_props, ['className', 'disabled', 'readOnly', 'value', 'tabIndex', 'component']); return _react2.default.createElement(Component, _extends({}, props, { type: 'text', tabIndex: tabIndex || 0, autoComplete: 'off', disabled: disabled, readOnly: readOnly, 'aria-disabled': disabled, 'aria-readonly': readOnly, value: value == null ? '' : value, className: (0, _classnames2.default)(className, 'rw-input') })); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
List = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { onSelect: function onSelect() {}, optionComponent: _ListOption2.default, ariaActiveDescendantKey: 'list', data: [], messages: { emptyList: 'There are no items in this list' } }; }
n/a
function _data() { return this.props.data; }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function componentDidMount() { this.move(); }
n/a
function componentDidUpdate() { var _props = this.props, data = _props.data, focused = _props.focused, idx = data.indexOf(focused), activeId = optionId((0, _widgetHelpers.instanceId)(this), idx); this.ariaActiveDescendant(idx !== -1 ? activeId : null); this.move(); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function first() { return this.next(EMPTY_VALUE); }
...
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
var first = chance.first(), last = chance.last()
arr[i] = { id: i + 1, name: `${first} ${last}`, first, surname: last }
}
return arr
}
function suggestList(){
...
function getChildContext() { var _this = this; return this._context || (this._context = { activeDescendants: { reconcile: function reconcile(key, id) { return _this.ariaActiveDescendant(id, key); } } }); }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function last() { var data = this._data(), item = data[data.length - 1]; return isDisabledOrReadonly(item, this.props) ? this.prev(item) : item; }
...
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
var first = chance.first(), last = chance.last()
arr[i] = { id: i + 1, name: `${first} ${last}`, first, surname: last }
}
return arr
}
function suggestList(){
...
function move() { var list = _compat2.default.findDOMNode(this), idx = this._data().indexOf(this.props.focused), selected = list.children[idx]; if (!selected) return; (0, _widgetHelpers.notify)(this.props.onMove, [selected, list, this.props.focused]); }
...
data: [],
messages: {
emptyList: 'There are no items in this list'
}
};
},
componentDidMount: function componentDidMount() {
this.move();
},
componentDidUpdate: function componentDidUpdate() {
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
...
function next(item, word) { var data = this._data(), nextIdx = data.indexOf(item) + 1, len = data.length, matches = matcher(word, item, this.props.textField); while (nextIdx < len && (isDisabledOrReadonly(data[nextIdx], this.props) || !matches(data[nextIdx]))) { nextIdx++; }return nextIdx < len ? data[nextIdx] : item; }
...
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem
) });else change(list.next(selectedItem));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
},
handleKeyPress: function handleKeyPress(e) {
...
function prev(item, word) { var data = this._data(), nextIdx = data.indexOf(item), matches = matcher(word, item, this.props.textField); if (nextIdx < 0 || nextIdx == null) nextIdx = 0; nextIdx--; while (nextIdx > -1 && (isDisabledOrReadonly(data[nextIdx], this.props) || !matches(data[nextIdx]))) { nextIdx--; }return nextIdx >= 0 ? data[nextIdx] : item; }
...
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem));
e.preventDefault();
}
},
handleKeyPress: function handleKeyPress(e) {
var _this4 = this;
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
...
function render() { var _this = this; var _props2 = this.props, className = _props2.className, role = _props2.role, data = _props2.data, textField = _props2.textField, valueField = _props2.valueField, focused = _props2.focused, selected = _props2.selected, messages = _props2.messages, onSelect = _props2.onSelect, ItemComponent = _props2.itemComponent, Option = _props2.optionComponent; var id = (0, _widgetHelpers.instanceId)(this), items = void 0; var elementProps = _3.default.omitOwnProps(this); items = !data.length ? _react2.default.createElement( 'li', { className: 'rw-list-empty' }, _3.default.result(messages.emptyList, this.props) ) : data.map(function (item, idx) { var currentId = optionId(id, idx), isDisabled = (0, _interaction.isDisabledItem)(item, _this.props), isReadOnly = (0, _interaction.isReadOnlyItem)(item, _this.props); return _react2.default.createElement( Option, { key: 'item_' + idx, id: currentId, dataItem: item, disabled: isDisabled, readOnly: isReadOnly, focused: focused === item, selected: selected === item, onClick: isDisabled || isReadOnly ? undefined : onSelect.bind(null, item) }, ItemComponent ? _react2.default.createElement(ItemComponent, { item: item, value: (0, _dataHelpers.dataValue)(item, valueField), text: (0, _dataHelpers.dataText)(item, textField), disabled: isDisabled, readOnly: isReadOnly }) : (0, _dataHelpers.dataText)(item, textField) ); }); return _react2.default.createElement( 'ul', _extends({ id: id, tabIndex: '-1', className: (0, _classnames2.default)(className, 'rw-list'), role: role === undefined ? 'listbox' : role }, elementProps), items ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
ListGroupable = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { onSelect: function onSelect() {}, data: [], optionComponent: _ListOption2.default, ariaActiveDescendantKey: 'groupedList', messages: { emptyList: 'There are no items in this list' } }; }
n/a
function _data() { var groups = this.state.groups; return this.state.sortedKeys.reduce(function (flat, grp) { return flat.concat(groups[grp]); }, []); }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function _group(groupBy, data, keys) { var iter = typeof groupBy === 'function' ? groupBy : function (item) { return item[groupBy]; }; // the keys array ensures that groups are rendered in the order they came in // which means that if you sort the data array it will render sorted, // so long as you also sorted by group keys = keys || []; (0, _warning2.default)(typeof groupBy !== 'string' || !data.length || _3.default.has(data[0], groupBy), '[React Widgets] You seem to be trying to group this list by a ' + ('property `' + groupBy + '` that doesn\'t exist in the dataset items, this may be a typo')); return data.reduce(function (grps, item) { var group = iter(item); _3.default.has(grps, group) ? grps[group].push(item) : (keys.push(group), grps[group] = [item]); return grps; }, {}); }
...
}
};
},
getInitialState: function getInitialState() {
var keys = [];
return {
groups: this._group(this.props.groupBy, this.props.data, keys),
sortedKeys: keys
};
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var keys = [];
...
function _isIndexOf(idx, item) { return this.props.data[idx] === item; }
n/a
function _renderGroupHeader(group) { var GroupComponent = this.props.groupComponent, id = (0, _widgetHelpers.instanceId)(this); return _react2.default.createElement( 'li', { key: 'item_' + group, tabIndex: '-1', role: 'separator', id: id + '_group_' + group, className: 'rw-list-optgroup' }, GroupComponent ? _react2.default.createElement(GroupComponent, { item: group }) : group ); }
...
var id = (0, _widgetHelpers.instanceId)(this);
this._currentActiveID = null;
if (data.length) {
items = sortedKeys.reduce(function (items, key) {
group = groups[key];
items.push(_this._renderGroupHeader(key));
for (var itemIdx = 0; itemIdx < group.length; itemIdx++) {
items.push(_this._renderItem(key, group[itemIdx], ++idx));
}return items;
}, []);
} else items = _react2.default.createElement(
'li',
...
function _renderItem(group, item, idx) { var _props2 = this.props, focused = _props2.focused, selected = _props2.selected, onSelect = _props2.onSelect, textField = _props2.textField, valueField = _props2.valueField, ItemComponent = _props2.itemComponent, Option = _props2.optionComponent; var currentID = optionId((0, _widgetHelpers.instanceId)(this), idx), isDisabled = (0, _interaction.isDisabledItem)(item, this.props), isReadOnly = (0, _interaction.isReadOnlyItem)(item, this.props); if (focused === item) this._currentActiveID = currentID; return _react2.default.createElement( Option, { key: 'item_' + group + '_' + idx, id: currentID, dataItem: item, focused: focused === item, selected: selected === item, disabled: isDisabled, readOnly: isReadOnly, onClick: isDisabled || isReadOnly ? undefined : onSelect.bind(null, item) }, ItemComponent ? _react2.default.createElement(ItemComponent, { item: item, value: (0, _dataHelpers.dataValue)(item, valueField), text: (0, _dataHelpers.dataText)(item, textField), disabled: isDisabled, readOnly: isReadOnly }) : (0, _dataHelpers.dataText)(item, textField) ); }
...
if (data.length) {
items = sortedKeys.reduce(function (items, key) {
group = groups[key];
items.push(_this._renderGroupHeader(key));
for (var itemIdx = 0; itemIdx < group.length; itemIdx++) {
items.push(_this._renderItem(key, group[itemIdx], ++idx));
}return items;
}, []);
} else items = _react2.default.createElement(
'li',
{ className: 'rw-list-empty' },
_3.default.result(messages.emptyList, this.props)
);
...
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function componentDidMount() { this.move(); }
n/a
function componentDidUpdate() { this.ariaActiveDescendant(this._currentActiveID); this.move(); }
n/a
function componentWillReceiveProps(nextProps) { var keys = []; if (nextProps.data !== this.props.data || nextProps.groupBy !== this.props.groupBy) this.setState({ groups: this._group(nextProps.groupBy, nextProps.data, keys), sortedKeys: keys }); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function first() { return this.next(EMPTY_VALUE); }
...
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
var first = chance.first(), last = chance.last()
arr[i] = { id: i + 1, name: `${first} ${last}`, first, surname: last }
}
return arr
}
function suggestList(){
...
function getChildContext() { var _this = this; return this._context || (this._context = { activeDescendants: { reconcile: function reconcile(key, id) { return _this.ariaActiveDescendant(id, key); } } }); }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { var keys = []; return { groups: this._group(this.props.groupBy, this.props.data, keys), sortedKeys: keys }; }
n/a
function getItemDOMNode(item) { var list = _compat2.default.findDOMNode(this), groups = this.state.groups, idx = -1, itemIdx, child; this.state.sortedKeys.some(function (group) { itemIdx = groups[group].indexOf(item); idx++; if (itemIdx !== -1) return !!(child = list.children[idx + itemIdx + 1]); idx += groups[group].length; }); return child; }
...
var groups = this.state.groups;
return this.state.sortedKeys.reduce(function (flat, grp) {
return flat.concat(groups[grp]);
}, []);
},
move: function move() {
var selected = this.getItemDOMNode(this.props.focused);
if (!selected) return;
(0, _widgetHelpers.notify)(this.props.onMove, [selected, _compat2.default.findDOMNode(this), this.props.focused]);
},
getItemDOMNode: function getItemDOMNode(item) {
var list = _compat2.default.findDOMNode(this),
...
function last() { var data = this._data(), item = data[data.length - 1]; return isDisabledOrReadonly(item, this.props) ? this.prev(item) : item; }
...
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
var first = chance.first(), last = chance.last()
arr[i] = { id: i + 1, name: `${first} ${last}`, first, surname: last }
}
return arr
}
function suggestList(){
...
function move() { var selected = this.getItemDOMNode(this.props.focused); if (!selected) return; (0, _widgetHelpers.notify)(this.props.onMove, [selected, _compat2.default.findDOMNode(this), this.props.focused]); }
...
data: [],
messages: {
emptyList: 'There are no items in this list'
}
};
},
componentDidMount: function componentDidMount() {
this.move();
},
componentDidUpdate: function componentDidUpdate() {
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
...
function next(item, word) { var data = this._data(), nextIdx = data.indexOf(item) + 1, len = data.length, matches = matcher(word, item, this.props.textField); while (nextIdx < len && (isDisabledOrReadonly(data[nextIdx], this.props) || !matches(data[nextIdx]))) { nextIdx++; }return nextIdx < len ? data[nextIdx] : item; }
...
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem
) });else change(list.next(selectedItem));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
},
handleKeyPress: function handleKeyPress(e) {
...
function prev(item, word) { var data = this._data(), nextIdx = data.indexOf(item), matches = matcher(word, item, this.props.textField); if (nextIdx < 0 || nextIdx == null) nextIdx = 0; nextIdx--; while (nextIdx > -1 && (isDisabledOrReadonly(data[nextIdx], this.props) || !matches(data[nextIdx]))) { nextIdx--; }return nextIdx >= 0 ? data[nextIdx] : item; }
...
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem));
e.preventDefault();
}
},
handleKeyPress: function handleKeyPress(e) {
var _this4 = this;
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
...
function render() { var _this = this; var _props = this.props, className = _props.className, role = _props.role, data = _props.data, messages = _props.messages; var _state = this.state, sortedKeys = _state.sortedKeys, groups = _state.groups; var elementProps = _3.default.omitOwnProps(this); var items = [], idx = -1, group = void 0; var id = (0, _widgetHelpers.instanceId)(this); this._currentActiveID = null; if (data.length) { items = sortedKeys.reduce(function (items, key) { group = groups[key]; items.push(_this._renderGroupHeader(key)); for (var itemIdx = 0; itemIdx < group.length; itemIdx++) { items.push(_this._renderItem(key, group[itemIdx], ++idx)); }return items; }, []); } else items = _react2.default.createElement( 'li', { className: 'rw-list-empty' }, _3.default.result(messages.emptyList, this.props) ); return _react2.default.createElement( 'ul', _extends({ ref: 'scrollable', id: id, tabIndex: '-1', className: (0, _classnames2.default)(className, 'rw-list', 'rw-list-grouped'), role: role === undefined ? 'listbox' : role }, elementProps), items ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function first() { return this.next(EMPTY_VALUE); }
...
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
var first = chance.first(), last = chance.last()
arr[i] = { id: i + 1, name: `${first} ${last}`, first, surname: last }
}
return arr
}
function suggestList(){
...
function last() { var data = this._data(), item = data[data.length - 1]; return isDisabledOrReadonly(item, this.props) ? this.prev(item) : item; }
...
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
var first = chance.first(), last = chance.last()
arr[i] = { id: i + 1, name: `${first} ${last}`, first, surname: last }
}
return arr
}
function suggestList(){
...
function next(item, word) { var data = this._data(), nextIdx = data.indexOf(item) + 1, len = data.length, matches = matcher(word, item, this.props.textField); while (nextIdx < len && (isDisabledOrReadonly(data[nextIdx], this.props) || !matches(data[nextIdx]))) { nextIdx++; }return nextIdx < len ? data[nextIdx] : item; }
...
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem
) });else change(list.next(selectedItem));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
},
handleKeyPress: function handleKeyPress(e) {
...
function prev(item, word) { var data = this._data(), nextIdx = data.indexOf(item), matches = matcher(word, item, this.props.textField); if (nextIdx < 0 || nextIdx == null) nextIdx = 0; nextIdx--; while (nextIdx > -1 && (isDisabledOrReadonly(data[nextIdx], this.props) || !matches(data[nextIdx]))) { nextIdx--; }return nextIdx >= 0 ? data[nextIdx] : item; }
...
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem));
e.preventDefault();
}
},
handleKeyPress: function handleKeyPress(e) {
var _this4 = this;
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
...
ListOption = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function render() { var _props = this.props, className = _props.className, children = _props.children, focused = _props.focused, selected = _props.selected, disabled = _props.disabled, readOnly = _props.readOnly; var props = _3.default.omitOwnProps(this); var classes = { 'rw-state-focus': focused, 'rw-state-selected': selected, 'rw-state-disabled': disabled, 'rw-state-readonly': readOnly }; return _react2.default.createElement( 'li', _extends({ role: 'option', tabIndex: !(disabled || readOnly) ? '-1' : undefined, 'aria-selected': !!selected, className: (0, _classnames2.default)('rw-list-option', className, classes) }, props), children ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
Month = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function isEqual(dateA, dateB) { return _dates2.default.eq(dateA, dateB, 'day'); }
...
max = _props.max,
date = _props.date;
return !_dates2.default.inRange(date, min, max, unit);
};
CalendarViewCell.prototype.isNow = function isNow() {
return this.isEqual(this.props.now);
};
CalendarViewCell.prototype.isFocused = function isFocused() {
return this.isEqual(this.props.focused);
};
CalendarViewCell.prototype.isSelected = function isSelected() {
...
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function componentDidUpdate() { var activeId = optionId((0, _widgetHelpers.instanceId)(this), this.props.focused); this.ariaActiveDescendant(activeId, null); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getChildContext() { var _this = this; return this._context || (this._context = { activeDescendants: { reconcile: function reconcile(key, id) { return _this.ariaActiveDescendant(id, key); } } }); }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function isRtl() { return !!this.context.isRtl; }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function render() { var _props = this.props, focused = _props.focused, culture = _props.culture, month = _dates2.default.visibleDays(focused, culture), rows = _3.default.chunk(month, 7); return _react2.default.createElement( _CalendarView2.default, _3.default.omitOwnProps(this), _react2.default.createElement( 'thead', null, _react2.default.createElement( 'tr', null, this.renderHeaders(rows[0], dayFormat(this.props), culture) ) ), _react2.default.createElement( 'tbody', null, rows.map(this.renderRow) ) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function renderHeaders(week, format, culture) { return week.map(function (date) { return _react2.default.createElement( 'th', { key: 'header_' + _dates2.default.weekday(date, undefined, _localizers.date.startOfWeek(culture)) }, _localizers.date.format(date, format, culture) ); }); }
...
_3.default.omitOwnProps(this),
_react2.default.createElement(
'thead',
null,
_react2.default.createElement(
'tr',
null,
this.renderHeaders(rows[0], dayFormat(this.props), culture)
)
),
_react2.default.createElement(
'tbody',
null,
rows.map(this.renderRow)
)
...
function renderRow(row, rowIdx) { var _this = this; var _props2 = this.props, focused = _props2.focused, today = _props2.today, disabled = _props2.disabled, onChange = _props2.onChange, value = _props2.value, culture = _props2.culture, min = _props2.min, max = _props2.max, Day = _props2.dayComponent, id = (0, _widgetHelpers.instanceId)(this), labelFormat = _localizers.date.getFormat('footer'); return _react2.default.createElement( _CalendarView2.default.Row, { key: rowIdx }, row.map(function (date, colIdx) { var formattedDate = _localizers.date.format(date, dateFormat(_this.props), culture), label = _localizers.date.format(date, labelFormat, culture); return _react2.default.createElement( _CalendarView2.default.Cell, { key: colIdx, id: optionId(id, date), label: label, date: date, now: today, min: min, max: max, unit: 'day', viewUnit: 'month', onChange: onChange, focused: focused, selected: value, disabled: disabled }, Day ? _react2.default.createElement(Day, { date: date, label: formattedDate }) : formattedDate ); }) ); }
n/a
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
deferControlTo = function (newComponent) { var additions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var nextMethods = arguments[2]; return uncontrollable(newComponent, _extends({}, controlledValues, additions), nextMethods); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function mergedResult() { var a = one.apply(this, arguments); var b = two.apply(this, arguments); if (a == null) { return b; } else if (b == null) { return a; } var c = {}; mergeIntoWithNoDuplicateKeys(c, a); mergeIntoWithNoDuplicateKeys(c, b); return c; }
n/a
function _data() { return this.state.processedData; }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function _scrollTo(selected, list, focused) { var state = this._scrollState || (this._scrollState = {}), handler = this.props.onMove, lastVisible = state.visible, lastItem = state.focused, shown, changed; state.visible = !(!list.offsetWidth || !list.offsetHeight); state.focused = focused; changed = lastItem !== focused; shown = state.visible && !lastVisible; if (shown || state.visible && changed) { if (handler) handler(selected, list, focused);else { state.scrollCancel && state.scrollCancel(); state.scrollCancel = (0, _scrollTo3.default)(selected, list); } } }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper
), e.target)) this.close();
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function close() { (0, _widgetHelpers.notify)(this.props.onToggle, false); }
...
var DropdownList = _react2.default.createClass((_obj = {
displayName: 'DropdownList',
mixins: [__webpack_require__(52), __webpack_require__(53), __webpack_require__(54), __webpack_require__(55), __webpack_require__
(56), __webpack_require__(61), __webpack_require__(45)(), __webpack_require__(62)({
didHandle: function didHandle(focused) {
if (!focused) this.close();
}
})],
propTypes: propTypes,
getDefaultProps: function getDefaultProps() {
return {
...
function componentDidUpdate() { this.ariaActiveDescendant((0, _widgetHelpers.instanceId)(this, '__createlist_option')); this.refs.list && (0, _validateListInterface2.default)(this.refs.list); }
n/a
function componentWillReceiveProps(nextProps) { var data = nextProps.data, value = nextProps.value, valueField = nextProps.valueField, searchTerm = nextProps.searchTerm, values = _3.default.splat(value), current = this.state.focusedItem, items = this.process(data, values, searchTerm); this.setState({ processedData: items, focusedItem: items.indexOf(current) === -1 ? items[0] : current, dataItems: values.map(function (item) { return (0, _dataHelpers.dataItem)(data, item, valueField); }) }); }
n/a
function componentWillUnmount() { var timers = this._timers || {}; this._unmounted = true; for (var k in timers) { if (has(timers, k)) this.clearTimeout(k); } }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function filter(items, searchTerm) { var matches = typeof this.props.filter === 'string' ? getFilter(_filter2.default[this.props.filter], searchTerm, this) : this. props.filter; if (!matches || !searchTerm || !searchTerm.trim() || searchTerm.length < (this.props.minLength || 1)) return items; return items.filter(function (item, idx) { return matches(item, searchTerm, idx); }); }
...
filter = _props.filter,
value = _props.value,
data = _props.data,
searchTerm = _props.searchTerm,
valueField = _props.valueField;
var processed = filter ? this.filter(data, searchTerm) : data,
initialIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField);
return {
filteredData: open && filter ? processed : null,
selectedItem: processed[initialIdx],
focusedItem: processed[initialIdx] || data[0]
};
...
function filterIndexOf(items, searchTerm) { var idx = -1, matches = typeof this.props.filter === 'function' ? this.props.filter : getFilter(_filter2.default[dflt(this.props.filter)], searchTerm, this); if (!searchTerm || !searchTerm.trim() || this.props.filter && searchTerm.length < (this.props.minLength || 1)) return -1; items.every(function (item, i) { if (matches(item, searchTerm, i)) return idx = i, false; return true; }); return idx; }
...
var rawIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField),
valueItem = rawIdx === -1 ? nextProps.value : nextProps.data[rawIdx],
isSuggesting = this.refs.input && this.refs.input.isSuggesting();
var items = this.process(nextProps.data, nextProps.value, (rawIdx === -1 || isSuggesting) && (0, _dataHelpers.dataText
)(valueItem, textField));
var idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField),
focused = this.filterIndexOf(items, (0, _dataHelpers.dataText)(valueItem, textField
));
this._searchTerm = '';
this.setState({
processedData: items,
selectedItem: items[idx],
focusedItem: items[idx === -1 ? focused !== -1 ? focused : 0 // focus the closest match
...
function focus() { this.refs.input && this.refs.input.focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function mergedResult() { var a = one.apply(this, arguments); var b = two.apply(this, arguments); if (a == null) { return b; } else if (b == null) { return a; } var c = {}; mergeIntoWithNoDuplicateKeys(c, a); mergeIntoWithNoDuplicateKeys(c, b); return c; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { var _props = this.props, data = _props.data, value = _props.value, valueField = _props.valueField, searchTerm = _props.searchTerm, dataItems = splat(value).map(function (item) { return (0, _dataHelpers.dataItem)(data, item, valueField); }), processedData = this.process(data, dataItems, searchTerm); return { focusedTag: null, focusedItem: processedData[0], processedData: processedData, dataItems: dataItems }; }
n/a
function getPlaceholder() { return (this.props.value || []).length ? '' : this.props.placeholder || ''; }
...
autoFocus: this.props.autoFocus,
'aria-owns': owns,
'aria-haspopup': true,
value: searchTerm,
maxLength: maxLength,
disabled: disabled === true,
readOnly: readOnly === true,
placeholder: this.getPlaceholder(),
inputSize: this.props.inputSize,
onKeyDown: this.handleSearchKeyDown,
onKeyUp: this.handleSearchKeyUp,
onChange: this.handleInputChange,
onClick: this.handleInputInteraction,
onTouchEnd: this.handleInputInteraction
});
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
},
_react2.default.createElement(
'li',
{
id: optionID,
role: 'option',
onClick: function onClick() {
return _this.handleCreate(searchTerm);
},
className: (0, _classnames2.default)('rw-list-option', 'rw-create-list-option', createIsFocused
x26;& 'rw-state-focus')
},
compatCreate(this.props, messages)
)
);
},
...
function handleDelete(value) { this.focus(); this.change(this.state.dataItems.filter(function (d) { return d !== value; })); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function handleInputChange(e) { (0, _widgetHelpers.notify)(this.props.onSearch, [e.target.value]); this.open(); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function handleSearchKeyDown(e) { if (e.key === 'Backspace' && e.target.value && !this._deletingText) this._deletingText = true; }
n/a
function handleSearchKeyUp(e) { if (e.key === 'Backspace' && this._deletingText) this._deletingText = false; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
_this3.close(), _compat2.default.findDOMNode(_this3).focus();
};
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
var change = function change(item, fromList) {
if (item == null) return;
fromList ? _this3.handleSelect(item) : _this3.change(item);
};
if (e.defaultPrevented) return;
if (key === 'End') {
e.preventDefault();
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function open() { if (!this.props.open) (0, _widgetHelpers.notify)(this.props.onToggle, true); }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
function process(data, values, searchTerm) { var valueField = this.props.valueField; var items = data.filter(function (i) { return !values.some(function (v) { return (0, _dataHelpers.valueMatcher)(i, v, valueField); }); }); this._lengthWithoutValues = items.length; if (searchTerm) items = this.filter(items, searchTerm); return items; }
...
propTypes: propTypes,
getInitialState: function getInitialState() {
var _props = this.props,
value = _props.value,
data = _props.data,
valueField = _props.valueField,
items = this.process(data, value),
idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField);
return {
selectedItem: items[idx],
focusedItem: items[!~idx ? 0 : idx],
processedData: items,
...
function render() { var _this2 = this; var _props5 = this.props, className = _props5.className, groupBy = _props5.groupBy, messages = _props5.messages, busy = _props5.busy, dropUp = _props5.dropUp, open = _props5.open, duration = _props5.duration, disabled = _props5.disabled, readOnly = _props5.readOnly, List = _props5.listComponent; var _state3 = this.state, focused = _state3.focused, dataItems = _state3.dataItems; List = List || groupBy && _ListGroupable2.default || _List2.default; var elementProps = _3.default.omitOwnProps(this, List); var shouldRenderTags = !!dataItems.length, shouldRenderPopup = (0, _widgetHelpers.isFirstFocusedRender)(this) || open, shouldShowCreate = this.shouldShowCreate(); var tagsID = (0, _widgetHelpers.instanceId)(this, '_taglist'), listID = (0, _widgetHelpers.instanceId)(this, '__listbox'), createID = (0, _widgetHelpers.instanceId)(this, '__createlist'), notifyID = (0, _widgetHelpers.instanceId)(this, '__notify'); var inputOwns = listID + ' ' + notifyID + ' ' + (shouldRenderTags ? tagsID : '') + (shouldShowCreate ? createID : ''); messages = msgs(messages); return _react2.default.createElement( _Widget2.default, _extends({}, elementProps, { id: (0, _widgetHelpers.instanceId)(this), open: open, dropUp: dropUp, focused: focused, disabled: disabled === true, readOnly: readOnly === true, onKeyDown: this.handleKeyDown, onBlur: this.handleBlur, onFocus: this.handleFocus, onTouchEnd: this.handleFocus, className: (0, _classnames2.default)(className, 'rw-multiselect') }), this.renderNotificationArea(notifyID, messages), _react2.default.createElement( 'div', { className: 'rw-multiselect-wrapper' }, busy && _react2.default.createElement('span', { className: 'rw-i rw-loading' }), shouldRenderTags && this.renderTags(tagsID, messages), this.renderInput(inputOwns) ), shouldRenderPopup && _react2.default.createElement( _Popup2.default, { dropUp: dropUp, open: open, duration: duration, onOpening: function onOpening() { return _this2.refs.list.forceUpdate(); } }, _react2.default.createElement( 'div', null, this.renderList(List, listID, messages), shouldShowCreate && this.renderCreateItem(createID, messages) ) ) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function renderCreateItem(id, messages) { var _this = this; var searchTerm = this.props.searchTerm; var focusedItem = this.state.focusedItem; var createIsFocused = !this._data().length || focusedItem === null; var optionID = (0, _widgetHelpers.instanceId)(this, '__createlist_option'); return _react2.default.createElement( 'ul', { id: id, role: 'listbox', className: 'rw-list rw-multiselect-create-tag' }, _react2.default.createElement( 'li', { id: optionID, role: 'option', onClick: function onClick() { return _this.handleCreate(searchTerm); }, className: (0, _classnames2.default)('rw-list-option', 'rw-create-list-option', createIsFocused && 'rw-state-focus') }, compatCreate(this.props, messages) ) ); }
...
return _this2.refs.list.forceUpdate();
}
},
_react2.default.createElement(
'div',
null,
this.renderList(List, listID, messages),
shouldShowCreate && this.renderCreateItem(createID, messages)
)
)
);
},
_data: function _data() {
return this.state.processedData;
},
...
function renderInput(owns) { var _props2 = this.props, searchTerm = _props2.searchTerm, maxLength = _props2.maxLength, tabIndex = _props2.tabIndex, busy = _props2.busy, open = _props2.open, disabled = _props2.disabled, readOnly = _props2.readOnly; return _react2.default.createElement(_MultiselectInput2.default, { ref: 'input', tabIndex: tabIndex || 0, role: 'listbox', 'aria-expanded': !!open, 'aria-busy': !!busy, autoFocus: this.props.autoFocus, 'aria-owns': owns, 'aria-haspopup': true, value: searchTerm, maxLength: maxLength, disabled: disabled === true, readOnly: readOnly === true, placeholder: this.getPlaceholder(), inputSize: this.props.inputSize, onKeyDown: this.handleSearchKeyDown, onKeyUp: this.handleSearchKeyUp, onChange: this.handleInputChange, onClick: this.handleInputInteraction, onTouchEnd: this.handleInputInteraction }); }
...
_react2.default.createElement(_Select2.default, {
onClick: this.toggle,
disabled: !!(disabled || readOnly),
busy: busy,
icon: 'caret-down',
label: _3.default.result(messages.open, this.props)
}),
this.renderInput(listID),
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpening: function onOpening() {
...
function renderList(List, id, messages) { var _props3 = this.props, open = _props3.open, disabled = _props3.disabled, readOnly = _props3.readOnly; var focusedItem = this.state.focusedItem; var listProps = _3.default.pickProps(this.props, List); var items = this._data(); return _react2.default.createElement(List, _extends({ ref: 'list', key: 0 }, listProps, { readOnly: readOnly, disabled: disabled, id: id, 'aria-live': 'polite', 'aria-labelledby': (0, _widgetHelpers.instanceId)(this), 'aria-hidden': !open, ariaActiveDescendantKey: 'list', data: items, focused: focusedItem, onSelect: this.handleSelect, onMove: this._scrollTo, messages: { emptyList: this._lengthWithoutValues ? messages.emptyFilter : messages.emptyList } })); }
...
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
...
function renderNotificationArea(id, messages) { var textField = this.props.textField; var _state = this.state, focused = _state.focused, dataItems = _state.dataItems; return _react2.default.createElement( 'span', { id: id, role: 'status', className: 'rw-sr', 'aria-live': 'assertive', 'aria-atomic': 'true', 'aria-relevant': 'additions removals text' }, focused && (dataItems.length ? messages.selectedItems + ': ' + dataItems.map(function (item) { return (0, _dataHelpers.dataText)(item, textField); }).join(', ') : messages.noneSelected) ); }
...
readOnly: readOnly === true,
onKeyDown: this.handleKeyDown,
onBlur: this.handleBlur,
onFocus: this.handleFocus,
onTouchEnd: this.handleFocus,
className: (0, _classnames2.default)(className, 'rw-multiselect')
}),
this.renderNotificationArea(notifyID, messages),
_react2.default.createElement(
'div',
{ className: 'rw-multiselect-wrapper' },
busy && _react2.default.createElement('span', { className: 'rw-i rw-loading' }),
shouldRenderTags && this.renderTags(tagsID, messages),
this.renderInput(inputOwns)
),
...
function renderTags(id, messages) { var _props4 = this.props, disabled = _props4.disabled, readOnly = _props4.readOnly, valueField = _props4.valueField, textField = _props4.textField; var _state2 = this.state, focusedTag = _state2.focusedTag, dataItems = _state2.dataItems; var Component = this.props.tagComponent; return _react2.default.createElement(_MultiselectTagList2.default, { ref: 'tagList', id: id, valueField: valueField, textField: textField, 'aria-label': messages.tagsLabel, value: dataItems, focused: focusedTag, disabled: disabled, readOnly: readOnly, onDelete: this.handleDelete, valueComponent: Component, ariaActiveDescendantKey: 'taglist' }); }
...
className: (0, _classnames2.default)(className, 'rw-multiselect')
}),
this.renderNotificationArea(notifyID, messages),
_react2.default.createElement(
'div',
{ className: 'rw-multiselect-wrapper' },
busy && _react2.default.createElement('span', { className: 'rw-i rw-loading' }),
shouldRenderTags && this.renderTags(tagsID, messages),
this.renderInput(inputOwns)
),
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
dropUp: dropUp,
open: open,
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function shouldShowCreate() { var _props6 = this.props, textField = _props6.textField, searchTerm = _props6.searchTerm, onCreate = _props6.onCreate, caseSensitive = _props6.caseSensitive; if (!onCreate || !searchTerm) return false; var lower = function lower(text) { return caseSensitive ? text : text.toLowerCase(); }; var eq = function eq(v) { return lower((0, _dataHelpers.dataText)(v, textField)) === lower(searchTerm); }; // if there is an exact match on textFields: "john" => { name: "john" }, don't show return !this._data().some(eq) && !this.state.dataItems.some(eq); }
...
List = List || groupBy && _ListGroupable2.default || _List2.default;
var elementProps = _3.default.omitOwnProps(this, List);
var shouldRenderTags = !!dataItems.length,
shouldRenderPopup = (0, _widgetHelpers.isFirstFocusedRender)(this) || open,
shouldShowCreate = this.shouldShowCreate();
var tagsID = (0, _widgetHelpers.instanceId)(this, '_taglist'),
listID = (0, _widgetHelpers.instanceId)(this, '__listbox'),
createID = (0, _widgetHelpers.instanceId)(this, '__createlist'),
notifyID = (0, _widgetHelpers.instanceId)(this, '__notify');
var inputOwns = listID + ' ' + notifyID + ' ' + (shouldRenderTags ? tagsID : '') + (shouldShowCreate
? createID : '');
...
function toggle() { this.props.open ? this.close() : this.open(); }
...
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2
.default)(_compat2.default.findDOMNode(wrapper), e.target)) this.close();
(0, _widgetHelpers.notify)(this.props.onClick, e);
},
handleKeyDown: function handleKeyDown(e) {
var _this3 = this;
var key = e.key,
...
function _data() { return this.state.processedData; }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function _scrollTo(selected, list, focused) { var state = this._scrollState || (this._scrollState = {}), handler = this.props.onMove, lastVisible = state.visible, lastItem = state.focused, shown, changed; state.visible = !(!list.offsetWidth || !list.offsetHeight); state.focused = focused; changed = lastItem !== focused; shown = state.visible && !lastVisible; if (shown || state.visible && changed) { if (handler) handler(selected, list, focused);else { state.scrollCancel && state.scrollCancel(); state.scrollCancel = (0, _scrollTo3.default)(selected, list); } } }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper
), e.target)) this.close();
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function close() { (0, _widgetHelpers.notify)(this.props.onToggle, false); }
...
var DropdownList = _react2.default.createClass((_obj = {
displayName: 'DropdownList',
mixins: [__webpack_require__(52), __webpack_require__(53), __webpack_require__(54), __webpack_require__(55), __webpack_require__
(56), __webpack_require__(61), __webpack_require__(45)(), __webpack_require__(62)({
didHandle: function didHandle(focused) {
if (!focused) this.close();
}
})],
propTypes: propTypes,
getDefaultProps: function getDefaultProps() {
return {
...
function filter(items, searchTerm) { var matches = typeof this.props.filter === 'string' ? getFilter(_filter2.default[this.props.filter], searchTerm, this) : this. props.filter; if (!matches || !searchTerm || !searchTerm.trim() || searchTerm.length < (this.props.minLength || 1)) return items; return items.filter(function (item, idx) { return matches(item, searchTerm, idx); }); }
...
filter = _props.filter,
value = _props.value,
data = _props.data,
searchTerm = _props.searchTerm,
valueField = _props.valueField;
var processed = filter ? this.filter(data, searchTerm) : data,
initialIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField);
return {
filteredData: open && filter ? processed : null,
selectedItem: processed[initialIdx],
focusedItem: processed[initialIdx] || data[0]
};
...
function filterIndexOf(items, searchTerm) { var idx = -1, matches = typeof this.props.filter === 'function' ? this.props.filter : getFilter(_filter2.default[dflt(this.props.filter)], searchTerm, this); if (!searchTerm || !searchTerm.trim() || this.props.filter && searchTerm.length < (this.props.minLength || 1)) return -1; items.every(function (item, i) { if (matches(item, searchTerm, i)) return idx = i, false; return true; }); return idx; }
...
var rawIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField),
valueItem = rawIdx === -1 ? nextProps.value : nextProps.data[rawIdx],
isSuggesting = this.refs.input && this.refs.input.isSuggesting();
var items = this.process(nextProps.data, nextProps.value, (rawIdx === -1 || isSuggesting) && (0, _dataHelpers.dataText
)(valueItem, textField));
var idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField),
focused = this.filterIndexOf(items, (0, _dataHelpers.dataText)(valueItem, textField
));
this._searchTerm = '';
this.setState({
processedData: items,
selectedItem: items[idx],
focusedItem: items[idx === -1 ? focused !== -1 ? focused : 0 // focus the closest match
...
function focus() { this.refs.input && this.refs.input.focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getPlaceholder() { return (this.props.value || []).length ? '' : this.props.placeholder || ''; }
...
autoFocus: this.props.autoFocus,
'aria-owns': owns,
'aria-haspopup': true,
value: searchTerm,
maxLength: maxLength,
disabled: disabled === true,
readOnly: readOnly === true,
placeholder: this.getPlaceholder(),
inputSize: this.props.inputSize,
onKeyDown: this.handleSearchKeyDown,
onKeyUp: this.handleSearchKeyUp,
onChange: this.handleInputChange,
onClick: this.handleInputInteraction,
onTouchEnd: this.handleInputInteraction
});
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
},
_react2.default.createElement(
'li',
{
id: optionID,
role: 'option',
onClick: function onClick() {
return _this.handleCreate(searchTerm);
},
className: (0, _classnames2.default)('rw-list-option', 'rw-create-list-option', createIsFocused
x26;& 'rw-state-focus')
},
compatCreate(this.props, messages)
)
);
},
...
function handleDelete(value) { this.focus(); this.change(this.state.dataItems.filter(function (d) { return d !== value; })); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function handleInputChange(e) { (0, _widgetHelpers.notify)(this.props.onSearch, [e.target.value]); this.open(); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function handleSearchKeyDown(e) { if (e.key === 'Backspace' && e.target.value && !this._deletingText) this._deletingText = true; }
n/a
function handleSearchKeyUp(e) { if (e.key === 'Backspace' && this._deletingText) this._deletingText = false; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
_this3.close(), _compat2.default.findDOMNode(_this3).focus();
};
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
var change = function change(item, fromList) {
if (item == null) return;
fromList ? _this3.handleSelect(item) : _this3.change(item);
};
if (e.defaultPrevented) return;
if (key === 'End') {
e.preventDefault();
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function open() { if (!this.props.open) (0, _widgetHelpers.notify)(this.props.onToggle, true); }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
function process(data, values, searchTerm) { var valueField = this.props.valueField; var items = data.filter(function (i) { return !values.some(function (v) { return (0, _dataHelpers.valueMatcher)(i, v, valueField); }); }); this._lengthWithoutValues = items.length; if (searchTerm) items = this.filter(items, searchTerm); return items; }
...
propTypes: propTypes,
getInitialState: function getInitialState() {
var _props = this.props,
value = _props.value,
data = _props.data,
valueField = _props.valueField,
items = this.process(data, value),
idx = (0, _dataHelpers.dataIndexOf)(items, value, valueField);
return {
selectedItem: items[idx],
focusedItem: items[!~idx ? 0 : idx],
processedData: items,
...
function renderCreateItem(id, messages) { var _this = this; var searchTerm = this.props.searchTerm; var focusedItem = this.state.focusedItem; var createIsFocused = !this._data().length || focusedItem === null; var optionID = (0, _widgetHelpers.instanceId)(this, '__createlist_option'); return _react2.default.createElement( 'ul', { id: id, role: 'listbox', className: 'rw-list rw-multiselect-create-tag' }, _react2.default.createElement( 'li', { id: optionID, role: 'option', onClick: function onClick() { return _this.handleCreate(searchTerm); }, className: (0, _classnames2.default)('rw-list-option', 'rw-create-list-option', createIsFocused && 'rw-state-focus') }, compatCreate(this.props, messages) ) ); }
...
return _this2.refs.list.forceUpdate();
}
},
_react2.default.createElement(
'div',
null,
this.renderList(List, listID, messages),
shouldShowCreate && this.renderCreateItem(createID, messages)
)
)
);
},
_data: function _data() {
return this.state.processedData;
},
...
function renderInput(owns) { var _props2 = this.props, searchTerm = _props2.searchTerm, maxLength = _props2.maxLength, tabIndex = _props2.tabIndex, busy = _props2.busy, open = _props2.open, disabled = _props2.disabled, readOnly = _props2.readOnly; return _react2.default.createElement(_MultiselectInput2.default, { ref: 'input', tabIndex: tabIndex || 0, role: 'listbox', 'aria-expanded': !!open, 'aria-busy': !!busy, autoFocus: this.props.autoFocus, 'aria-owns': owns, 'aria-haspopup': true, value: searchTerm, maxLength: maxLength, disabled: disabled === true, readOnly: readOnly === true, placeholder: this.getPlaceholder(), inputSize: this.props.inputSize, onKeyDown: this.handleSearchKeyDown, onKeyUp: this.handleSearchKeyUp, onChange: this.handleInputChange, onClick: this.handleInputInteraction, onTouchEnd: this.handleInputInteraction }); }
...
_react2.default.createElement(_Select2.default, {
onClick: this.toggle,
disabled: !!(disabled || readOnly),
busy: busy,
icon: 'caret-down',
label: _3.default.result(messages.open, this.props)
}),
this.renderInput(listID),
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpening: function onOpening() {
...
function renderList(List, id, messages) { var _props3 = this.props, open = _props3.open, disabled = _props3.disabled, readOnly = _props3.readOnly; var focusedItem = this.state.focusedItem; var listProps = _3.default.pickProps(this.props, List); var items = this._data(); return _react2.default.createElement(List, _extends({ ref: 'list', key: 0 }, listProps, { readOnly: readOnly, disabled: disabled, id: id, 'aria-live': 'polite', 'aria-labelledby': (0, _widgetHelpers.instanceId)(this), 'aria-hidden': !open, ariaActiveDescendantKey: 'list', data: items, focused: focusedItem, onSelect: this.handleSelect, onMove: this._scrollTo, messages: { emptyList: this._lengthWithoutValues ? messages.emptyFilter : messages.emptyList } })); }
...
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
...
function renderNotificationArea(id, messages) { var textField = this.props.textField; var _state = this.state, focused = _state.focused, dataItems = _state.dataItems; return _react2.default.createElement( 'span', { id: id, role: 'status', className: 'rw-sr', 'aria-live': 'assertive', 'aria-atomic': 'true', 'aria-relevant': 'additions removals text' }, focused && (dataItems.length ? messages.selectedItems + ': ' + dataItems.map(function (item) { return (0, _dataHelpers.dataText)(item, textField); }).join(', ') : messages.noneSelected) ); }
...
readOnly: readOnly === true,
onKeyDown: this.handleKeyDown,
onBlur: this.handleBlur,
onFocus: this.handleFocus,
onTouchEnd: this.handleFocus,
className: (0, _classnames2.default)(className, 'rw-multiselect')
}),
this.renderNotificationArea(notifyID, messages),
_react2.default.createElement(
'div',
{ className: 'rw-multiselect-wrapper' },
busy && _react2.default.createElement('span', { className: 'rw-i rw-loading' }),
shouldRenderTags && this.renderTags(tagsID, messages),
this.renderInput(inputOwns)
),
...
function renderTags(id, messages) { var _props4 = this.props, disabled = _props4.disabled, readOnly = _props4.readOnly, valueField = _props4.valueField, textField = _props4.textField; var _state2 = this.state, focusedTag = _state2.focusedTag, dataItems = _state2.dataItems; var Component = this.props.tagComponent; return _react2.default.createElement(_MultiselectTagList2.default, { ref: 'tagList', id: id, valueField: valueField, textField: textField, 'aria-label': messages.tagsLabel, value: dataItems, focused: focusedTag, disabled: disabled, readOnly: readOnly, onDelete: this.handleDelete, valueComponent: Component, ariaActiveDescendantKey: 'taglist' }); }
...
className: (0, _classnames2.default)(className, 'rw-multiselect')
}),
this.renderNotificationArea(notifyID, messages),
_react2.default.createElement(
'div',
{ className: 'rw-multiselect-wrapper' },
busy && _react2.default.createElement('span', { className: 'rw-i rw-loading' }),
shouldRenderTags && this.renderTags(tagsID, messages),
this.renderInput(inputOwns)
),
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
dropUp: dropUp,
open: open,
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function shouldShowCreate() { var _props6 = this.props, textField = _props6.textField, searchTerm = _props6.searchTerm, onCreate = _props6.onCreate, caseSensitive = _props6.caseSensitive; if (!onCreate || !searchTerm) return false; var lower = function lower(text) { return caseSensitive ? text : text.toLowerCase(); }; var eq = function eq(v) { return lower((0, _dataHelpers.dataText)(v, textField)) === lower(searchTerm); }; // if there is an exact match on textFields: "john" => { name: "john" }, don't show return !this._data().some(eq) && !this.state.dataItems.some(eq); }
...
List = List || groupBy && _ListGroupable2.default || _List2.default;
var elementProps = _3.default.omitOwnProps(this, List);
var shouldRenderTags = !!dataItems.length,
shouldRenderPopup = (0, _widgetHelpers.isFirstFocusedRender)(this) || open,
shouldShowCreate = this.shouldShowCreate();
var tagsID = (0, _widgetHelpers.instanceId)(this, '_taglist'),
listID = (0, _widgetHelpers.instanceId)(this, '__listbox'),
createID = (0, _widgetHelpers.instanceId)(this, '__createlist'),
notifyID = (0, _widgetHelpers.instanceId)(this, '__notify');
var inputOwns = listID + ' ' + notifyID + ' ' + (shouldRenderTags ? tagsID : '') + (shouldShowCreate
? createID : '');
...
function toggle() { this.props.open ? this.close() : this.open(); }
...
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2
.default)(_compat2.default.findDOMNode(wrapper), e.target)) this.close();
(0, _widgetHelpers.notify)(this.props.onClick, e);
},
handleKeyDown: function handleKeyDown(e) {
var _this3 = this;
var key = e.key,
...
open = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
searchTerm = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
value = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
function componentWillMount() { var _this2 = this; var props = this.props; this._values = {}; controlledProps.forEach(function (key) { _this2._values[key] = props[utils.defaultKey(key)]; }); }
n/a
function componentWillReceiveProps(nextProps) { var _this3 = this; var props = this.props; if (mixin.componentWillReceiveProps) { mixin.componentWillReceiveProps.call(this, nextProps); } controlledProps.forEach(function (key) { if (utils.getValue(nextProps, key) === undefined && utils.getValue(props, key) !== undefined) { _this3._values[key] = nextProps[utils.defaultKey(key)]; } }); }
n/a
function componentWillUnmount() { this.unmounted = true; }
n/a
focus = function () { var _refs$inner; return (_refs$inner = this.refs.inner)[method].apply(_refs$inner, arguments); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function getControlledInstance() { return this.refs.inner; }
n/a
function render() { var _this4 = this; var newProps = {}, props = omitProps(this.props); utils.each(controlledValues, function (handle, propName) { var linkPropName = utils.getLinkName(propName), prop = _this4.props[propName]; if (linkPropName && !isProp(_this4.props, propName) && isProp(_this4.props, linkPropName)) { prop = _this4.props[linkPropName].value; } newProps[propName] = prop !== undefined ? prop : _this4._values[propName]; newProps[handle] = setAndNotify.bind(_this4, propName); }); newProps = _extends({}, props, newProps, { ref: isCompositeComponent ? 'inner' : null }); return _react2.default.createElement(Component, newProps); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function shouldComponentUpdate() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return !mixin.shouldComponentUpdate || mixin.shouldComponentUpdate.apply(this, args); }
n/a
function MultiselectInput() { _classCallCheck(this, MultiselectInput); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
function focus() { _compat2.default.findDOMNode(this).focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function render() { var _props = this.props, disabled = _props.disabled, readOnly = _props.readOnly, placeholder = _props.placeholder, onChange = _props.onChange, value = _props.value, props = _objectWithoutProperties(_props, ['disabled', 'readOnly', 'placeholder', 'onChange', 'value']); var size = props.inputSize ? props.inputSize(value || placeholder) : Math.max((value || placeholder).length, 1) + 1; var elementProps = _3.default.omitOwnProps(this); return _react2.default.createElement('input', _extends({}, elementProps, { size: size, className: 'rw-input', autoComplete: 'off', 'aria-disabled': disabled, 'aria-readonly': readOnly, disabled: disabled, readOnly: readOnly, placeholder: placeholder, onChange: onChange, value: value })); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
MultiselectTagList = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { ariaActiveDescendantKey: 'taglist' }; }
n/a
function _delete(val) { this.props.onDelete(val); }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function clear() { this.setState({ focused: null }); }
n/a
function componentDidUpdate() { var focused = this.props.focused, activeId = optionId((0, _widgetHelpers.instanceId)(this), focused); this.ariaActiveDescendant(focused == null || (0, _interaction.isDisabledItem)(focused, this.props) ? null : activeId); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function first() { var idx = 0, value = this.props.value, l = value.length; while (idx < l && (0, _interaction.isDisabledItem)(value[idx], this.props)) { idx++; }return idx !== l ? idx : null; }
...
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
var first = chance.first(), last = chance.last()
arr[i] = { id: i + 1, name: `${first} ${last}`, first, surname: last }
}
return arr
}
function suggestList(){
...
function getChildContext() { var _this = this; return this._context || (this._context = { activeDescendants: { reconcile: function reconcile(key, id) { return _this.ariaActiveDescendant(id, key); } } }); }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function last() { var value = this.props.value, idx = value.length - 1; while (idx > -1 && (0, _interaction.isDisabledItem)(value[idx], this.props)) { idx--; }return idx >= 0 ? idx : null; }
...
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
var first = chance.first(), last = chance.last()
arr[i] = { id: i + 1, name: `${first} ${last}`, first, surname: last }
}
return arr
}
function suggestList(){
...
function next(current) { var nextIdx = current + 1, value = this.props.value, l = value.length; while (nextIdx < l && (0, _interaction.isDisabledItem)(nextIdx, this.props)) { nextIdx++; }if (current === null || nextIdx >= l) return null; return nextIdx; }
...
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem
) });else change(list.next(selectedItem));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
},
handleKeyPress: function handleKeyPress(e) {
...
function prev(current) { var nextIdx = current, value = this.props.value; if (nextIdx === null || nextIdx === 0) nextIdx = value.length; nextIdx--; while (nextIdx > -1 && (0, _interaction.isDisabledItem)(value[nextIdx], this.props)) { nextIdx--; }return nextIdx >= 0 ? nextIdx : null; }
...
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem));
e.preventDefault();
}
},
handleKeyPress: function handleKeyPress(e) {
var _this4 = this;
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
...
function remove(idx) { var val = this.props.value[idx]; if (val && !((0, _interaction.isDisabledItem)(val, this.props) || (0, _interaction.isReadOnlyItem)(val, this.props))) this.props .onDelete(val); }
...
} else if (key === 'Home') {
e.preventDefault();
if (isOpen) this.setState(_extends({ focusedItem: list.first() }, nullTag));else tagList && this.setState({ focusedTag
: tagList.first() });
} else if (isOpen && keyCode === 13) {
// using keyCode to ignore enter for japanese IME
e.preventDefault();
ctrlKey && this.props.onCreate || focusedItem === null ? this.handleCreate(this.props.searchTerm) : this.handleSelect
(this.state.focusedItem);
} else if (key === 'Escape') isOpen ? this.close() : tagList && this.setState(nullTag);else if (noSearch
&& key === 'ArrowLeft') tagList && this.setState({ focusedTag: tagList.prev(focusedTag) });else if
(noSearch && key === 'ArrowRight') tagList && this.setState({ focusedTag: tagList.next(focusedTag
) });else if (noSearch && key === 'Delete') tagList && tagList.
remove(focusedTag);else if (noSearch && key === 'Backspace') tagList && tagList.removeNext();
},
change: function change(data) {
(0, _widgetHelpers.notify)(this.props.onChange, [data]);
(0, _widgetHelpers.notify)(this.props.onSearch, ['']);
},
focus: function focus() {
this.refs.input && this.refs.input.focus();
...
function removeNext() { var val = this.props.value[this.props.value.length - 1]; if (val && !((0, _interaction.isDisabledItem)(val, this.props) || (0, _interaction.isReadOnlyItem)(val, this.props))) this.props .onDelete(val); }
...
} else if (key === 'Home') {
e.preventDefault();
if (isOpen) this.setState(_extends({ focusedItem: list.first() }, nullTag));else tagList && this.setState({ focusedTag
: tagList.first() });
} else if (isOpen && keyCode === 13) {
// using keyCode to ignore enter for japanese IME
e.preventDefault();
ctrlKey && this.props.onCreate || focusedItem === null ? this.handleCreate(this.props.searchTerm) : this.handleSelect
(this.state.focusedItem);
} else if (key === 'Escape') isOpen ? this.close() : tagList && this.setState(nullTag);else if (noSearch
&& key === 'ArrowLeft') tagList && this.setState({ focusedTag: tagList.prev(focusedTag) });else if
(noSearch && key === 'ArrowRight') tagList && this.setState({ focusedTag: tagList.next(focusedTag
) });else if (noSearch && key === 'Delete') tagList && tagList.remove(focusedTag);else if (noSearch
&& key === 'Backspace') tagList && tagList.removeNext();
},
change: function change(data) {
(0, _widgetHelpers.notify)(this.props.onChange, [data]);
(0, _widgetHelpers.notify)(this.props.onSearch, ['']);
},
focus: function focus() {
this.refs.input && this.refs.input.focus();
...
function render() { var _this = this; var _props = this.props, focused = _props.focused, value = _props.value, textField = _props.textField, ValueComponent = _props.valueComponent; var id = (0, _widgetHelpers.instanceId)(this); var props = _3.default.omitOwnProps(this); return _react2.default.createElement( 'ul', _extends({}, props, { role: 'listbox', tabIndex: '-1', className: 'rw-multiselect-taglist' }), value.map(function (item, i) { var isDisabled = (0, _interaction.isDisabledItem)(item, _this.props), isReadonly = (0, _interaction.isReadOnlyItem)(item, _this.props), isFocused = !isDisabled && focused === i, currentID = optionId(id, i); return _react2.default.createElement( 'li', { key: i, id: currentID, tabIndex: '-1', role: 'option', className: (0, _classnames2.default)({ 'rw-state-focus': isFocused, 'rw-state-disabled': isDisabled, 'rw-state-readonly': isReadonly }) }, ValueComponent ? _react2.default.createElement(ValueComponent, { item: item }) : (0, _dataHelpers.dataText)(item, textField ), _react2.default.createElement( 'span', { tabIndex: '-1', onClick: !(isDisabled || isReadonly) ? _this._delete.bind(null, item) : undefined, 'aria-disabled': isDisabled, 'aria-label': 'Unselect', disabled: isDisabled }, _react2.default.createElement( 'span', { className: 'rw-tag-btn', 'aria-hidden': 'true' }, '\xD7' ) ) ); }) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function shouldComponentUpdate(nextProps, nextState) { return !_.isShallowEqual(this.props, nextProps) || !_.isShallowEqual(this.state, nextState); }
n/a
NumberInput = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { value: null, editing: false }; }
n/a
function _change(e) { var val = e.target.value, number = this._parse(e.target.value); var isIntermediate = this.isIntermediateValue(number, val); if (val == null || val.trim() === '') { this.current(''); return this.props.onChange(null); } if (!isIntermediate) { if (number !== this.props.value) { return this.props.onChange(number); } } else { this.current(e.target.value); } }
n/a
function _finish() { var str = this.state.stringValue, number = this._parse(str); // if number is below the min // we need to flush low values and decimal stops, onBlur means i'm done inputing if (this.isIntermediateValue(number, str)) { if (isNaN(number)) { number = null; } this.props.onChange(number); } }
n/a
function _parse(strVal) { var culture = this.props.culture, delimChar = _localizers.number.decimalChar(null, culture), userParse = this.props.parse; if (userParse) return userParse(strVal, culture); strVal = strVal.replace(delimChar, '.'); strVal = parseFloat(strVal); return strVal; }
...
readOnly: this.props.readOnly,
placeholder: this.props.placeholder,
value: value
}));
},
_change: function _change(e) {
var val = e.target.value,
number = this._parse(e.target.value);
var isIntermediate = this.isIntermediateValue(number, val);
if (val == null || val.trim() === '') {
this.current('');
return this.props.onChange(null);
}
...
function componentWillReceiveProps(nextProps) { this.setState(this.getDefaultState(nextProps)); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function current(stringValue) { this.setState({ stringValue: stringValue }); }
...
_change: function _change(e) {
var val = e.target.value,
number = this._parse(e.target.value);
var isIntermediate = this.isIntermediateValue(number, val);
if (val == null || val.trim() === '') {
this.current('');
return this.props.onChange(null);
}
if (!isIntermediate) {
if (number !== this.props.value) {
return this.props.onChange(number);
}
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getDefaultState() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props; var value = props.value, decimal = _localizers.number.decimalChar(null, props.culture), format = getFormat(props); if (value == null || isNaN(props.value)) value = '';else value = props.editing ? ('' + value).replace('.', decimal) : _localizers .number.format(value, format, props.culture); return { stringValue: '' + value }; }
...
if (value == null || isNaN(props.value)) value = '';else value = props.editing ? ('' + value).replace(
x27;.', decimal) : _localizers.number.format(value, format, props.culture);
return {
stringValue: '' + value
};
},
getInitialState: function getInitialState() {
return this.getDefaultState();
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
this.setState(this.getDefaultState(nextProps));
},
render: function render() {
var value = this.state.stringValue;
var props = _3.default.omitOwnProps(this);
...
function getInitialState() { return this.getDefaultState(); }
n/a
function isAtDelimiter(num, str) { var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props; var localeChar = _localizers.number.decimalChar(null, props.culture), lastIndex = str.length - 1, char; if (str.length < 1) return false; char = str[lastIndex]; return !!(char === localeChar && str.indexOf(char) === lastIndex); }
...
strVal = strVal.replace(delimChar, '.');
strVal = parseFloat(strVal);
return strVal;
},
isIntermediateValue: function isIntermediateValue(num, str) {
return !!(num < this.props.min || this.isSign(str) || this.isAtDelimiter(num
, str) || this.isPaddedZeros(str));
},
isSign: function isSign(val) {
return (val || '').trim() === '-';
},
isPaddedZeros: function isPaddedZeros(str) {
var localeChar = _localizers.number.decimalChar(null, this.props.culture);
...
function isIntermediateValue(num, str) { return !!(num < this.props.min || this.isSign(str) || this.isAtDelimiter(num, str) || this.isPaddedZeros(str)); }
...
value: value
}));
},
_change: function _change(e) {
var val = e.target.value,
number = this._parse(e.target.value);
var isIntermediate = this.isIntermediateValue(number, val);
if (val == null || val.trim() === '') {
this.current('');
return this.props.onChange(null);
}
if (!isIntermediate) {
...
function isPaddedZeros(str) { var localeChar = _localizers.number.decimalChar(null, this.props.culture); var _str$split = str.split(localeChar), _ = _str$split[0], decimals = _str$split[1]; return !!(decimals && decimals.match(/0+$/)); }
...
strVal = strVal.replace(delimChar, '.');
strVal = parseFloat(strVal);
return strVal;
},
isIntermediateValue: function isIntermediateValue(num, str) {
return !!(num < this.props.min || this.isSign(str) || this.isAtDelimiter(num, str) || this.isPaddedZeros(str));
},
isSign: function isSign(val) {
return (val || '').trim() === '-';
},
isPaddedZeros: function isPaddedZeros(str) {
var localeChar = _localizers.number.decimalChar(null, this.props.culture);
...
function isSign(val) { return (val || '').trim() === '-'; }
...
strVal = strVal.replace(delimChar, '.');
strVal = parseFloat(strVal);
return strVal;
},
isIntermediateValue: function isIntermediateValue(num, str) {
return !!(num < this.props.min || this.isSign(str) || this.isAtDelimiter(num
, str) || this.isPaddedZeros(str));
},
isSign: function isSign(val) {
return (val || '').trim() === '-';
},
isPaddedZeros: function isPaddedZeros(str) {
var localeChar = _localizers.number.decimalChar(null, this.props.culture);
...
function isValid(num) { if (typeof num !== 'number' || isNaN(num)) return false; return num >= this.props.min; }
...
firstOfWeek: function firstOfWeek(culture) {
return moment.localeData(culture).firstDayOfWeek();
},
parse: function parse(value, format, culture) {
if (!value) return null;
var m = getMoment(culture, value, format);
if (m.isValid()) return m.toDate();
return null;
},
format: function format(value, _format, culture) {
return getMoment(culture, value).format(_format);
}
};
...
function render() { var value = this.state.stringValue; var props = _3.default.omitOwnProps(this); return _react2.default.createElement('input', _extends({}, props, { type: 'text', className: 'rw-input', onChange: this._change, onBlur: this._finish, 'aria-disabled': this.props.disabled, 'aria-readonly': this.props.readOnly, disabled: this.props.disabled, readOnly: this.props.readOnly, placeholder: this.props.placeholder, value: value })); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
deferControlTo = function (newComponent) { var additions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var nextMethods = arguments[2]; return uncontrollable(newComponent, _extends({}, controlledValues, additions), nextMethods); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { value: null, open: false, min: -Infinity, max: Infinity, step: 1, messages: { increment: 'increment value', decrement: 'decrement value' } }; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function change(val) { val = this.constrainValue(val); if (this.props.value !== val) (0, _widgetHelpers.notify)(this.props.onChange, val); }
...
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper
), e.target)) this.close();
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function componentWillUnmount() { var timers = this._timers || {}; this._unmounted = true; for (var k in timers) { if (has(timers, k)) this.clearTimeout(k); } }
n/a
function constrainValue(value) { var max = this.props.max == null ? Infinity : this.props.max, min = this.props.min == null ? -Infinity : this.props.min; if (value == null || value === '') return null; return Math.max(Math.min(value, max), min); }
...
var _$omitOwnProps = _3.default.omitOwnProps(this),
className = _$omitOwnProps.className,
onKeyPress = _$omitOwnProps.onKeyPress,
onKeyUp = _$omitOwnProps.onKeyUp,
props = _objectWithoutProperties(_$omitOwnProps, ['className', 'onKeyPress', 'onKeyUp']);
var val = this.constrainValue(this.props.value);
return _react2.default.createElement(
'div',
_extends({}, props, {
ref: 'element',
onKeyDown: this._keyDown,
onFocus: this.handleFocus,
...
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function decrement() { return this.step(-this.props.step); }
...
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
if (e.defaultPrevented) return;
if (key === 'End' && isFinite(this.props.max)) this.change(this.props.max);else if (key === 'Home
x27; && isFinite(this.props.min)) this.change(this.props.min);else if (key === 'ArrowDown') {
e.preventDefault();
this.decrement();
} else if (key === 'ArrowUp') {
e.preventDefault();
this.increment();
}
},
focus: function focus() {
_compat2.default.findDOMNode(this.refs.input).focus();
...
function focus() { _compat2.default.findDOMNode(this.refs.input).focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function getChildContext() { return { isRtl: !!(this.props.isRtl || this.context && this.context.isRtl) }; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { return { focused: false, active: false }; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
label: this.props.messages.increment,
active: this.state.active === _constants.directions.UP,
disabled: val === this.props.max || this.props.disabled,
onMouseUp: function onMouseUp() {
return _this.handleMouseUp(_constants.directions.UP);
},
onMouseDown: function onMouseDown() {
return _this.handleMouseDown(_constants.directions.UP);
},
onMouseLeave: function onMouseLeave() {
return _this.handleMouseUp(_constants.directions.UP);
}
}),
_react2.default.createElement(_Button2.default, {
icon: 'caret-down',
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
_react2.default.createElement(_Button2.default, {
icon: 'caret-up',
onClick: this.handleFocus,
label: this.props.messages.increment,
active: this.state.active === _constants.directions.UP,
disabled: val === this.props.max || this.props.disabled,
onMouseUp: function onMouseUp() {
return _this.handleMouseUp(_constants.directions.UP);
},
onMouseDown: function onMouseDown() {
return _this.handleMouseDown(_constants.directions.UP);
},
onMouseLeave: function onMouseLeave() {
return _this.handleMouseUp(_constants.directions.UP);
}
...
function increment() { return this.step(this.props.step); }
...
if (e.defaultPrevented) return;
if (key === 'End' && isFinite(this.props.max)) this.change(this.props.max);else if (key === 'Home
x27; && isFinite(this.props.min)) this.change(this.props.min);else if (key === 'ArrowDown') {
e.preventDefault();
this.decrement();
} else if (key === 'ArrowUp') {
e.preventDefault();
this.increment();
}
},
focus: function focus() {
_compat2.default.findDOMNode(this.refs.input).focus();
},
increment: function increment() {
return this.step(this.props.step);
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function render() { var _this = this; var _$omitOwnProps = _3.default.omitOwnProps(this), className = _$omitOwnProps.className, onKeyPress = _$omitOwnProps.onKeyPress, onKeyUp = _$omitOwnProps.onKeyUp, props = _objectWithoutProperties(_$omitOwnProps, ['className', 'onKeyPress', 'onKeyUp']); var val = this.constrainValue(this.props.value); return _react2.default.createElement( 'div', _extends({}, props, { ref: 'element', onKeyDown: this._keyDown, onFocus: this.handleFocus, onBlur: this.handleBlur, tabIndex: '-1', className: (0, _classnames2.default)(className, 'rw-numberpicker', 'rw-widget', { 'rw-state-focus': this.state.focused, 'rw-state-disabled': this.props.disabled, 'rw-state-readonly': this.props.readOnly, 'rw-rtl': this.isRtl() }) }), _react2.default.createElement( 'span', { className: 'rw-select' }, _react2.default.createElement(_Button2.default, { icon: 'caret-up', onClick: this.handleFocus, label: this.props.messages.increment, active: this.state.active === _constants.directions.UP, disabled: val === this.props.max || this.props.disabled, onMouseUp: function onMouseUp() { return _this.handleMouseUp(_constants.directions.UP); }, onMouseDown: function onMouseDown() { return _this.handleMouseDown(_constants.directions.UP); }, onMouseLeave: function onMouseLeave() { return _this.handleMouseUp(_constants.directions.UP); } }), _react2.default.createElement(_Button2.default, { icon: 'caret-down', onClick: this.handleFocus, label: this.props.messages.decrement, active: this.state.active === _constants.directions.DOWN, disabled: val === this.props.min || this.props.disabled, onMouseUp: function onMouseUp() { return _this.handleMouseUp(_constants.directions.DOWN); }, onMouseDown: function onMouseDown() { return _this.handleMouseDown(_constants.directions.DOWN); }, onMouseLeave: function onMouseLeave() { return _this.handleMouseUp(_constants.directions.DOWN); } }) ), _react2.default.createElement(_NumberInput2.default, { ref: 'input', tabIndex: props.tabIndex, placeholder: this.props.placeholder, value: val, autoFocus: this.props.autoFocus, editing: this.state.focused, format: this.props.format, parse: this.props.parse, name: this.props.name, role: 'spinbutton', min: this.props.min, 'aria-valuenow': val, 'aria-valuemin': isFinite(this.props.min) ? this.props.min : null, 'aria-valuemax': isFinite(this.props.max) ? this.props.max : null, 'aria-disabled': this.props.disabled, 'aria-readonly': this.props.readonly, disabled: this.props.disabled, readOnly: this.props.readOnly, onChange: this.change, onKeyPress: onKeyPress, onKeyUp: onKeyUp }) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function shouldComponentUpdate(nextProps, nextState) { return !_.isShallowEqual(this.props, nextProps) || !_.isShallowEqual(this.state, nextState); }
n/a
function step(amount) { var value = (this.props.value || 0) + amount; var decimals = this.props.precision != null ? this.props.precision : _localizers.number.precision(format(this.props)); this.change(decimals != null ? round(value, decimals) : value); return value; }
...
this.increment();
}
},
focus: function focus() {
_compat2.default.findDOMNode(this.refs.input).focus();
},
increment: function increment() {
return this.step(this.props.step);
},
decrement: function decrement() {
return this.step(-this.props.step);
},
step: function step(amount) {
var value = (this.props.value || 0) + amount;
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function change(val) { val = this.constrainValue(val); if (this.props.value !== val) (0, _widgetHelpers.notify)(this.props.onChange, val); }
...
this.renderList(List, listID, messages)
)
);
},
handleSelect: function handleSelect(data) {
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper
), e.target)) this.close();
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function constrainValue(value) { var max = this.props.max == null ? Infinity : this.props.max, min = this.props.min == null ? -Infinity : this.props.min; if (value == null || value === '') return null; return Math.max(Math.min(value, max), min); }
...
var _$omitOwnProps = _3.default.omitOwnProps(this),
className = _$omitOwnProps.className,
onKeyPress = _$omitOwnProps.onKeyPress,
onKeyUp = _$omitOwnProps.onKeyUp,
props = _objectWithoutProperties(_$omitOwnProps, ['className', 'onKeyPress', 'onKeyUp']);
var val = this.constrainValue(this.props.value);
return _react2.default.createElement(
'div',
_extends({}, props, {
ref: 'element',
onKeyDown: this._keyDown,
onFocus: this.handleFocus,
...
function decrement() { return this.step(-this.props.step); }
...
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
if (e.defaultPrevented) return;
if (key === 'End' && isFinite(this.props.max)) this.change(this.props.max);else if (key === 'Home
x27; && isFinite(this.props.min)) this.change(this.props.min);else if (key === 'ArrowDown') {
e.preventDefault();
this.decrement();
} else if (key === 'ArrowUp') {
e.preventDefault();
this.increment();
}
},
focus: function focus() {
_compat2.default.findDOMNode(this.refs.input).focus();
...
function focus() { _compat2.default.findDOMNode(this.refs.input).focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
label: this.props.messages.increment,
active: this.state.active === _constants.directions.UP,
disabled: val === this.props.max || this.props.disabled,
onMouseUp: function onMouseUp() {
return _this.handleMouseUp(_constants.directions.UP);
},
onMouseDown: function onMouseDown() {
return _this.handleMouseDown(_constants.directions.UP);
},
onMouseLeave: function onMouseLeave() {
return _this.handleMouseUp(_constants.directions.UP);
}
}),
_react2.default.createElement(_Button2.default, {
icon: 'caret-down',
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
_react2.default.createElement(_Button2.default, {
icon: 'caret-up',
onClick: this.handleFocus,
label: this.props.messages.increment,
active: this.state.active === _constants.directions.UP,
disabled: val === this.props.max || this.props.disabled,
onMouseUp: function onMouseUp() {
return _this.handleMouseUp(_constants.directions.UP);
},
onMouseDown: function onMouseDown() {
return _this.handleMouseDown(_constants.directions.UP);
},
onMouseLeave: function onMouseLeave() {
return _this.handleMouseUp(_constants.directions.UP);
}
...
function increment() { return this.step(this.props.step); }
...
if (e.defaultPrevented) return;
if (key === 'End' && isFinite(this.props.max)) this.change(this.props.max);else if (key === 'Home
x27; && isFinite(this.props.min)) this.change(this.props.min);else if (key === 'ArrowDown') {
e.preventDefault();
this.decrement();
} else if (key === 'ArrowUp') {
e.preventDefault();
this.increment();
}
},
focus: function focus() {
_compat2.default.findDOMNode(this.refs.input).focus();
},
increment: function increment() {
return this.step(this.props.step);
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function step(amount) { var value = (this.props.value || 0) + amount; var decimals = this.props.precision != null ? this.props.precision : _localizers.number.precision(format(this.props)); this.change(decimals != null ? round(value, decimals) : value); return value; }
...
this.increment();
}
},
focus: function focus() {
_compat2.default.findDOMNode(this.refs.input).focus();
},
increment: function increment() {
return this.step(this.props.step);
},
decrement: function decrement() {
return this.step(-this.props.step);
},
step: function step(amount) {
var value = (this.props.value || 0) + amount;
...
value = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
function componentWillMount() { var _this2 = this; var props = this.props; this._values = {}; controlledProps.forEach(function (key) { _this2._values[key] = props[utils.defaultKey(key)]; }); }
n/a
function componentWillReceiveProps(nextProps) { var _this3 = this; var props = this.props; if (mixin.componentWillReceiveProps) { mixin.componentWillReceiveProps.call(this, nextProps); } controlledProps.forEach(function (key) { if (utils.getValue(nextProps, key) === undefined && utils.getValue(props, key) !== undefined) { _this3._values[key] = nextProps[utils.defaultKey(key)]; } }); }
n/a
function componentWillUnmount() { this.unmounted = true; }
n/a
focus = function () { var _refs$inner; return (_refs$inner = this.refs.inner)[method].apply(_refs$inner, arguments); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function getControlledInstance() { return this.refs.inner; }
n/a
function render() { var _this4 = this; var newProps = {}, props = omitProps(this.props); utils.each(controlledValues, function (handle, propName) { var linkPropName = utils.getLinkName(propName), prop = _this4.props[propName]; if (linkPropName && !isProp(_this4.props, propName) && isProp(_this4.props, linkPropName)) { prop = _this4.props[linkPropName].value; } newProps[propName] = prop !== undefined ? prop : _this4._values[propName]; newProps[handle] = setAndNotify.bind(_this4, propName); }); newProps = _extends({}, props, newProps, { ref: isCompositeComponent ? 'inner' : null }); return _react2.default.createElement(Component, newProps); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function shouldComponentUpdate() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return !mixin.shouldComponentUpdate || mixin.shouldComponentUpdate.apply(this, args); }
n/a
Popup = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { duration: 200, open: false, onClosing: function onClosing() {}, onOpening: function onOpening() {}, onClose: function onClose() {}, onOpen: function onOpen() {} }; }
n/a
function animate(el, props, dur, easing, cb) { this._transition = _configuration2.default.animate(el, props, dur, easing, this.setNextCallback(cb)); }
...
this.props.onOpening();
this.safeSetState({ status: OPENING, height: height }, function () {
var offset = _this2.getOffsetForStatus(OPEN),
duration = _this2.props.duration;
_this2.animate(el, offset, duration, 'ease', function () {
_this2.safeSetState({ status: OPEN }, function () {
_this2.props.onOpen();
});
});
});
},
close: function close() {
...
function cancelNextCallback() { if (this._transition && this._transition.cancel) { this._transition.cancel(); this._transition = null; } if (this.nextCallback) { this.nextCallback.cancel(); this.nextCallback = null; } }
...
componentDidUpdate: function componentDidUpdate(pvProps) {
var closing = pvProps.open && !this.props.open,
opening = !pvProps.open && this.props.open,
open = this.props.open,
status = this.state.status;
if (!!pvProps.dropUp !== !!this.props.dropUp) {
this.cancelNextCallback();
if (status === OPENING) this.open();
if (status === CLOSING) this.close();
return;
}
if (opening) this.open();else if (closing) this.close();else if (open) {
// this.height() returns a floating point number with the desired height
...
function close() { var _this3 = this; this.cancelNextCallback(); var el = _compat2.default.findDOMNode(this).firstChild, height = this.height(); this.props.onClosing(); this.safeSetState({ status: CLOSING, height: height }, function () { var offset = _this3.getOffsetForStatus(CLOSED), duration = _this3.props.duration; _this3.animate(el, offset, duration, 'ease', function () { return _this3.safeSetState({ status: CLOSED }, function () { _this3.props.onClose(); }); }); }); }
...
var DropdownList = _react2.default.createClass((_obj = {
displayName: 'DropdownList',
mixins: [__webpack_require__(52), __webpack_require__(53), __webpack_require__(54), __webpack_require__(55), __webpack_require__
(56), __webpack_require__(61), __webpack_require__(45)(), __webpack_require__(62)({
didHandle: function didHandle(focused) {
if (!focused) this.close();
}
})],
propTypes: propTypes,
getDefaultProps: function getDefaultProps() {
return {
...
function componentDidMount() { var _this = this; var isOpen = this.state.status === OPENING; _compat2.default.batchedUpdates(function () { _this.setState({ initialRender: false }); if (isOpen) { _this.open(); } }); }
n/a
function componentDidUpdate(pvProps) { var closing = pvProps.open && !this.props.open, opening = !pvProps.open && this.props.open, open = this.props.open, status = this.state.status; if (!!pvProps.dropUp !== !!this.props.dropUp) { this.cancelNextCallback(); if (status === OPENING) this.open(); if (status === CLOSING) this.close(); return; } if (opening) this.open();else if (closing) this.close();else if (open) { // this.height() returns a floating point number with the desired height // for this popup. Because of potential rounding errors in floating point // aritmetic we must allow an error margin when comparing to the current // state, otherwise we can end up in an infinite loop where the height // is never exactly equal to our target value. var height = this.height(), diff = Math.abs(height - this.state.height); if (isNaN(diff) || diff > 0.1) this.setState({ height: height }); } }
n/a
function componentWillReceiveProps(nextProps) { this.setState({ contentChanged: childKey(nextProps.children) !== childKey(this.props.children) }); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { return { initialRender: true, status: this.props.open ? OPENING : CLOSED }; }
n/a
function getOffsetForStatus(status) { var _CLOSED$CLOSING$OPENI; if (this.state.initialRender) return {}; var _in = properties('top', this.props.dropUp ? '100%' : '-100%'), out = properties('top', 0); return (_CLOSED$CLOSING$OPENI = {}, _CLOSED$CLOSING$OPENI[CLOSED] = _in, _CLOSED$CLOSING$OPENI[CLOSING] = out, _CLOSED$CLOSING $OPENI[OPENING] = _in, _CLOSED$CLOSING$OPENI[OPEN] = out, _CLOSED$CLOSING$OPENI)[status] || {}; }
...
},
this.renderChildren()
);
},
renderChildren: function renderChildren() {
if (!this.props.children) return _react2.default.createElement('span', { className: 'rw-popup rw-widget'
; });
var offset = this.getOffsetForStatus(this.state.status),
child = _react2.default.Children.only(this.props.children);
return (0, _react.cloneElement)(child, {
style: _extends({}, child.props.style, offset, {
position: this.isTransitioning() ? 'absolute' : undefined
}),
className: (0, _classnames2.default)(child.props.className, 'rw-popup rw-widget')
...
function height() { var container = _compat2.default.findDOMNode(this), content = container.firstChild, margin = parseInt((0, _style2.default)(content, 'margin-top'), 10) + parseInt((0, _style2.default)(content, 'margin-bottom '), 10); var old = container.style.display, height = void 0; container.style.display = 'block'; height = ((0, _height2.default)(content) || 0) + (isNaN(margin) ? 0 : margin); container.style.display = old; return height; }
...
this.cancelNextCallback();
if (status === OPENING) this.open();
if (status === CLOSING) this.close();
return;
}
if (opening) this.open();else if (closing) this.close();else if (open) {
// this.height() returns a floating point number with the desired height
// for this popup. Because of potential rounding errors in floating point
// aritmetic we must allow an error margin when comparing to the current
// state, otherwise we can end up in an infinite loop where the height
// is never exactly equal to our target value.
var height = this.height(),
diff = Math.abs(height - this.state.height);
if (isNaN(diff) || diff > 0.1) this.setState({ height: height });
...
function isTransitioning() { return this.state.status === OPENING || this.state.status === CLOSED; }
...
'div',
{
style: _extends({
display: display,
overflow: overflow,
height: height
}, style),
className: (0, _classnames2.default)(className, 'rw-popup-container', dropUp && 'rw-dropup'
;, this.isTransitioning() && 'rw-popup-animating')
},
this.renderChildren()
);
},
renderChildren: function renderChildren() {
if (!this.props.children) return _react2.default.createElement('span', { className: 'rw-popup rw-widget'
; });
...
function open() { var _this2 = this; this.cancelNextCallback(); var el = _compat2.default.findDOMNode(this).firstChild, height = this.height(); this.props.onOpening(); this.safeSetState({ status: OPENING, height: height }, function () { var offset = _this2.getOffsetForStatus(OPEN), duration = _this2.props.duration; _this2.animate(el, offset, duration, 'ease', function () { _this2.safeSetState({ status: OPEN }, function () { _this2.props.onOpen(); }); }); }); }
...
e.preventDefault();
closeWithFocus();
} else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) {
e.preventDefault();
change(this.state.focusedItem, true);
} else if (key === ' ' && !filtering && !isOpen) {
e.preventDefault();
this.open();
} else if (key === 'ArrowDown') {
if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem
));
e.preventDefault();
} else if (key === 'ArrowUp') {
if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem
));
e.preventDefault();
}
...
function render() { var _props = this.props, className = _props.className, dropUp = _props.dropUp, style = _props.style, _state = this.state, status = _state.status, height = _state.height; var overflow = OVERFLOW[status] || 'visible', display = status === CLOSED ? 'none' : 'block'; return _react2.default.createElement( 'div', { style: _extends({ display: display, overflow: overflow, height: height }, style), className: (0, _classnames2.default)(className, 'rw-popup-container', dropUp && 'rw-dropup', this.isTransitioning() && 'rw -popup-animating') }, this.renderChildren() ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function renderChildren() { if (!this.props.children) return _react2.default.createElement('span', { className: 'rw-popup rw-widget' }); var offset = this.getOffsetForStatus(this.state.status), child = _react2.default.Children.only(this.props.children); return (0, _react.cloneElement)(child, { style: _extends({}, child.props.style, offset, { position: this.isTransitioning() ? 'absolute' : undefined }), className: (0, _classnames2.default)(child.props.className, 'rw-popup rw-widget') }); }
...
style: _extends({
display: display,
overflow: overflow,
height: height
}, style),
className: (0, _classnames2.default)(className, 'rw-popup-container', dropUp && 'rw-dropup'
;, this.isTransitioning() && 'rw-popup-animating')
},
this.renderChildren()
);
},
renderChildren: function renderChildren() {
if (!this.props.children) return _react2.default.createElement('span', { className: 'rw-popup rw-widget'
; });
var offset = this.getOffsetForStatus(this.state.status),
child = _react2.default.Children.only(this.props.children);
...
function safeSetState(nextState, callback) { this.setState(nextState, this.setNextCallback(callback)); }
...
this.cancelNextCallback();
var el = _compat2.default.findDOMNode(this).firstChild,
height = this.height();
this.props.onOpening();
this.safeSetState({ status: OPENING, height: height }, function () {
var offset = _this2.getOffsetForStatus(OPEN),
duration = _this2.props.duration;
_this2.animate(el, offset, duration, 'ease', function () {
_this2.safeSetState({ status: OPEN }, function () {
_this2.props.onOpen();
});
...
function setNextCallback(callback) { var _this4 = this; var active = true; this.nextCallback = function (event) { if (active) { active = false; _this4.nextCallback = null; callback(event); } }; this.nextCallback.cancel = function () { return active = false; }; return this.nextCallback; }
...
container.style.display = old;
return height;
},
isTransitioning: function isTransitioning() {
return this.state.status === OPENING || this.state.status === CLOSED;
},
animate: function animate(el, props, dur, easing, cb) {
this._transition = _configuration2.default.animate(el, props, dur, easing, this.setNextCallback
(cb));
},
cancelNextCallback: function cancelNextCallback() {
if (this._transition && this._transition.cancel) {
this._transition.cancel();
this._transition = null;
}
if (this.nextCallback) {
...
function _scrollTo(selected, list, focused) { var state = this._scrollState || (this._scrollState = {}), handler = this.props.onMove, lastVisible = state.visible, lastItem = state.focused, shown, changed; state.visible = !(!list.offsetWidth || !list.offsetHeight); state.focused = focused; changed = lastItem !== focused; shown = state.visible && !lastVisible; if (shown || state.visible && changed) { if (handler) handler(selected, list, focused);else { state.scrollCancel && state.scrollCancel(); state.scrollCancel = (0, _scrollTo3.default)(selected, list); } } }
n/a
function shouldComponentUpdate(nextProps, nextState) { return !_.isShallowEqual(this.props, nextProps) || !_.isShallowEqual(this.state, nextState); }
n/a
function isRtl() { return !!this.context.isRtl; }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function getChildContext() { return { isRtl: !!(this.props.isRtl || this.context && this.context.isRtl) }; }
n/a
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function Select() { _classCallCheck(this, Select); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
function render() { var _props = this.props, className = _props.className, props = _objectWithoutProperties(_props, ['className']); return _react2.default.createElement(_Button2.default, _extends({}, props, { className: (0, _classnames2.default)(className, 'rw-select') })); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function component() { _classCallCheck(this, component); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
deferControlTo = function (newComponent) { var additions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var nextMethods = arguments[2]; return uncontrollable(newComponent, _extends({}, controlledValues, additions), nextMethods); }
n/a
ControlledComponent = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { delay: 250, value: [], data: [], ariaActiveDescendantKey: 'selectlist', messages: { emptyList: 'There are no items in this list' } }; }
n/a
function _data() { return this.props.data; }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function _scrollTo(selected, list) { var handler = this.props.onMove; if (handler) handler(selected, list);else { this._scrollCancel && this._scrollCancel(); // default behavior is to scroll the whole page not just the widget this._scrollCancel = (0, _scrollTo3.default)(selected); } }
n/a
function _values() { return this.props.multiple ? this.state.dataItems : this.props.value; }
...
valueField = _props2.valueField,
multiple = _props2.multiple,
list = this.refs.list,
focusedItem = this.state.focusedItem;
var change = function change(item) {
if (item) _this.handleChange(item, multiple ? !(0, _interaction.contains)(item, _this.
_values(), valueField) // toggle value
: true);
};
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
if (e.defaultPrevented) return;
...
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function chainedFunction() { one.apply(this, arguments); two.apply(this, arguments); }
n/a
function componentWillReceiveProps(nextProps) { return this.setState(this.getDefaultState(nextProps)); }
n/a
function componentWillUnmount() { var timers = this._timers || {}; this._unmounted = true; for (var k in timers) { if (has(timers, k)) this.clearTimeout(k); } }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function focus() { _compat2.default.findDOMNode(this.refs.list).focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function mergedResult() { var a = one.apply(this, arguments); var b = two.apply(this, arguments); if (a == null) { return b; } else if (b == null) { return a; } var c = {}; mergeIntoWithNoDuplicateKeys(c, a); mergeIntoWithNoDuplicateKeys(c, b); return c; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getDefaultState(props) { var data = props.data, value = props.value, valueField = props.valueField, multiple = props.multiple; return { dataItems: multiple && _3.default.splat(value).map(function (item) { return (0, _dataHelpers.dataItem)(data, item, valueField); }) }; }
...
if (value == null || isNaN(props.value)) value = '';else value = props.editing ? ('' + value).replace(
x27;.', decimal) : _localizers.number.format(value, format, props.culture);
return {
stringValue: '' + value
};
},
getInitialState: function getInitialState() {
return this.getDefaultState();
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
this.setState(this.getDefaultState(nextProps));
},
render: function render() {
var value = this.state.stringValue;
var props = _3.default.omitOwnProps(this);
...
function getInitialState() { var state = this.getDefaultState(this.props); state.ListItem = getListItem(this); return state; }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function handleChange(item, checked) { var multiple = this.props.multiple, values = this.state.dataItems; multiple = !!multiple; this.clearTimeout('focusedItem'); this.setState({ focusedItem: item }); if (!multiple) return (0, _widgetHelpers.notify)(this.props.onChange, checked ? item : null); values = checked ? values.concat(item) : values.filter(function (v) { return v !== item; }); (0, _widgetHelpers.notify)(this.props.onChange, [values || []]); }
...
handleDateSelect: function handleDateSelect(date) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(date, this.props.value, this.props.currentDate),
dateStr = formatDate(date, format, this.props.culture);
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, [dateTime, dateStr]);
this.handleChange(dateTime, dateStr, true);
this.focus();
},
handleTimeSelect: function handleTimeSelect(datum) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(this.props.value, datum.date, this.props.currentDate),
dateStr = formatDate(datum.date, format, this.props.culture);
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (this.props.open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyPress
span>(e);
},
focus: function focus() {
var valueInput = this.refs.valueInput;
if (valueInput && (0, _activeElement2.default)() !== _compat2.default.findDOMNode(valueInput)) valueInput.focus();
},
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function render() { var _props = this.props, className = _props.className, tabIndex = _props.tabIndex, busy = _props.busy, groupBy = _props.groupBy, List = _props.listComponent; List = List || groupBy && _ListGroupable2.default || _List2.default; var elementProps = _3.default.omitOwnProps(this, List); var listProps = _3.default.pickProps(this.props, List); var _state = this.state, ListItem = _state.ListItem, focusedItem = _state.focusedItem, focused = _state.focused; var items = this._data(); focusedItem = focused && !(0, _interaction.isDisabled)(this.props) && !(0, _interaction.isReadOnly)(this.props) && focusedItem ; return _react2.default.createElement( _Widget2.default, _extends({}, elementProps, { onBlur: this.handleBlur, onFocus: this.handleFocus, onKeyDown: this.handleKeyDown, onKeyPress: this.handleKeyPress, disabled: (0, _interaction.isDisabled)(this.props), readOnly: (0, _interaction.isReadOnly)(this.props), role: 'radiogroup', 'aria-busy': !!busy, className: (0, _classnames2.default)(className, 'rw-selectlist', busy && 'rw-loading-mask') }), _react2.default.createElement(List, _extends({}, listProps, { ref: 'list', role: 'radiogroup', tabIndex: tabIndex || '0', id: (0, _widgetHelpers.instanceId)(this, '_listbox'), data: items, focused: focusedItem, optionComponent: ListItem, itemComponent: this.props.itemComponent, onMove: this._scrollTo })) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function search(character) { var _this3 = this; var word = ((this._searchTerm || '') + character).toLowerCase(), list = this.refs.list, multiple = this.props.multiple; if (!character) return; this._searchTerm = word; this.setTimeout('search', function () { var focusedItem = list.next(_this3.state.focusedItem, word); _this3._searchTerm = ''; if (focusedItem) { !multiple ? _this3.handleChange(focusedItem, true) : _this3.setState({ focusedItem: focusedItem }); } }, this.props.delay); }
...
handleKeyPress: function handleKeyPress(e) {
var _this4 = this;
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (!(this.props.filter && this.props.open)) this.search(String.fromCharCode
(e.which), function (item) {
_this4.isMounted() && _this4.props.open ? _this4.setState({ focusedItem: item }) : item && _this4.change
(item);
});
},
change: function change(data) {
if (!(0, _dataHelpers.valueMatcher)(data, this.props.value, this.props.valueField)) {
(0, _widgetHelpers.notify)(this.props.onChange, data);
(0, _widgetHelpers.notify)(this.props.onSearch, '');
...
function selectAll() { var _this2 = this; var _props3 = this.props, disabled = _props3.disabled, readOnly = _props3.readOnly, valueField = _props3.valueField, values = this.state.dataItems, data = this._data(), blacklist; disabled = disabled || readOnly; disabled = Array.isArray(disabled) ? disabled : []; //disabled values that are not selected blacklist = disabled.filter(function (v) { return !(0, _interaction.contains)(v, values, valueField); }); data = data.filter(function (v) { return !(0, _interaction.contains)(v, blacklist, valueField); }); if (data.length === values.length) { data = disabled.filter(function (item) { return (0, _interaction.contains)(item, values, valueField); }); data = data.map(function (item) { return (0, _dataHelpers.dataItem)(_this2._data(), item, valueField); }); } (0, _widgetHelpers.notify)(this.props.onChange, [data]); }
...
e.preventDefault();
focusedItem = list.prev(focusedItem);
this.setState({ focusedItem: focusedItem });
if (!multiple) change(focusedItem);
} else if (multiple && e.keyCode === 65 && e.ctrlKey) {
e.preventDefault();
this.selectAll();
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function _data() { return this.props.data; }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function _scrollTo(selected, list) { var handler = this.props.onMove; if (handler) handler(selected, list);else { this._scrollCancel && this._scrollCancel(); // default behavior is to scroll the whole page not just the widget this._scrollCancel = (0, _scrollTo3.default)(selected); } }
n/a
function _values() { return this.props.multiple ? this.state.dataItems : this.props.value; }
...
valueField = _props2.valueField,
multiple = _props2.multiple,
list = this.refs.list,
focusedItem = this.state.focusedItem;
var change = function change(item) {
if (item) _this.handleChange(item, multiple ? !(0, _interaction.contains)(item, _this.
_values(), valueField) // toggle value
: true);
};
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
if (e.defaultPrevented) return;
...
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function focus() { _compat2.default.findDOMNode(this.refs.list).focus(); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getDefaultState(props) { var data = props.data, value = props.value, valueField = props.valueField, multiple = props.multiple; return { dataItems: multiple && _3.default.splat(value).map(function (item) { return (0, _dataHelpers.dataItem)(data, item, valueField); }) }; }
...
if (value == null || isNaN(props.value)) value = '';else value = props.editing ? ('' + value).replace(
x27;.', decimal) : _localizers.number.format(value, format, props.culture);
return {
stringValue: '' + value
};
},
getInitialState: function getInitialState() {
return this.getDefaultState();
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
this.setState(this.getDefaultState(nextProps));
},
render: function render() {
var value = this.state.stringValue;
var props = _3.default.omitOwnProps(this);
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function handleChange(item, checked) { var multiple = this.props.multiple, values = this.state.dataItems; multiple = !!multiple; this.clearTimeout('focusedItem'); this.setState({ focusedItem: item }); if (!multiple) return (0, _widgetHelpers.notify)(this.props.onChange, checked ? item : null); values = checked ? values.concat(item) : values.filter(function (v) { return v !== item; }); (0, _widgetHelpers.notify)(this.props.onChange, [values || []]); }
...
handleDateSelect: function handleDateSelect(date) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(date, this.props.value, this.props.currentDate),
dateStr = formatDate(date, format, this.props.culture);
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, [dateTime, dateStr]);
this.handleChange(dateTime, dateStr, true);
this.focus();
},
handleTimeSelect: function handleTimeSelect(datum) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(this.props.value, datum.date, this.props.currentDate),
dateStr = formatDate(datum.date, format, this.props.culture);
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
n/a
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function decoratedMethod() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (!(isDisabled(this.props) || !disabledOnly && isReadOnly(this.props))) return method.apply(this, args); }
...
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (this.props.open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyPress
span>(e);
},
focus: function focus() {
var valueInput = this.refs.valueInput;
if (valueInput && (0, _activeElement2.default)() !== _compat2.default.findDOMNode(valueInput)) valueInput.focus();
},
...
function isRtl() { return !!(this.props.isRtl || this.context && this.context.isRtl); }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function search(character) { var _this3 = this; var word = ((this._searchTerm || '') + character).toLowerCase(), list = this.refs.list, multiple = this.props.multiple; if (!character) return; this._searchTerm = word; this.setTimeout('search', function () { var focusedItem = list.next(_this3.state.focusedItem, word); _this3._searchTerm = ''; if (focusedItem) { !multiple ? _this3.handleChange(focusedItem, true) : _this3.setState({ focusedItem: focusedItem }); } }, this.props.delay); }
...
handleKeyPress: function handleKeyPress(e) {
var _this4 = this;
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (!(this.props.filter && this.props.open)) this.search(String.fromCharCode
(e.which), function (item) {
_this4.isMounted() && _this4.props.open ? _this4.setState({ focusedItem: item }) : item && _this4.change
(item);
});
},
change: function change(data) {
if (!(0, _dataHelpers.valueMatcher)(data, this.props.value, this.props.valueField)) {
(0, _widgetHelpers.notify)(this.props.onChange, data);
(0, _widgetHelpers.notify)(this.props.onSearch, '');
...
function selectAll() { var _this2 = this; var _props3 = this.props, disabled = _props3.disabled, readOnly = _props3.readOnly, valueField = _props3.valueField, values = this.state.dataItems, data = this._data(), blacklist; disabled = disabled || readOnly; disabled = Array.isArray(disabled) ? disabled : []; //disabled values that are not selected blacklist = disabled.filter(function (v) { return !(0, _interaction.contains)(v, values, valueField); }); data = data.filter(function (v) { return !(0, _interaction.contains)(v, blacklist, valueField); }); if (data.length === values.length) { data = disabled.filter(function (item) { return (0, _interaction.contains)(item, values, valueField); }); data = data.map(function (item) { return (0, _dataHelpers.dataItem)(_this2._data(), item, valueField); }); } (0, _widgetHelpers.notify)(this.props.onChange, [data]); }
...
e.preventDefault();
focusedItem = list.prev(focusedItem);
this.setState({ focusedItem: focusedItem });
if (!multiple) change(focusedItem);
} else if (multiple && e.keyCode === 65 && e.ctrlKey) {
e.preventDefault();
this.selectAll();
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
value = function (props, propName) { if (props[propName] !== undefined) { if (!props[handler]) { return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`'); } } }
n/a
function componentWillMount() { var _this2 = this; var props = this.props; this._values = {}; controlledProps.forEach(function (key) { _this2._values[key] = props[utils.defaultKey(key)]; }); }
n/a
function componentWillReceiveProps(nextProps) { var _this3 = this; var props = this.props; if (mixin.componentWillReceiveProps) { mixin.componentWillReceiveProps.call(this, nextProps); } controlledProps.forEach(function (key) { if (utils.getValue(nextProps, key) === undefined && utils.getValue(props, key) !== undefined) { _this3._values[key] = nextProps[utils.defaultKey(key)]; } }); }
n/a
function componentWillUnmount() { this.unmounted = true; }
n/a
focus = function () { var _refs$inner; return (_refs$inner = this.refs.inner)[method].apply(_refs$inner, arguments); }
...
shouldRenderPopup && _react2.default.createElement(
_Popup2.default,
{
open: open,
dropUp: dropUp,
duration: duration,
onOpen: function onOpen() {
return _this2.focus();
},
onOpening: function onOpening() {
return _this2.refs.list.forceUpdate();
}
},
this.renderList(List, listID, messages)
)
...
function getControlledInstance() { return this.refs.inner; }
n/a
function render() { var _this4 = this; var newProps = {}, props = omitProps(this.props); utils.each(controlledValues, function (handle, propName) { var linkPropName = utils.getLinkName(propName), prop = _this4.props[propName]; if (linkPropName && !isProp(_this4.props, propName) && isProp(_this4.props, linkPropName)) { prop = _this4.props[linkPropName].value; } newProps[propName] = prop !== undefined ? prop : _this4._values[propName]; newProps[handle] = setAndNotify.bind(_this4, propName); }); newProps = _extends({}, props, newProps, { ref: isCompositeComponent ? 'inner' : null }); return _react2.default.createElement(Component, newProps); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
selectAll = function () { var _refs$inner; return (_refs$inner = this.refs.inner)[method].apply(_refs$inner, arguments); }
...
e.preventDefault();
focusedItem = list.prev(focusedItem);
this.setState({ focusedItem: focusedItem });
if (!multiple) change(focusedItem);
} else if (multiple && e.keyCode === 65 && e.ctrlKey) {
e.preventDefault();
this.selectAll();
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function shouldComponentUpdate() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return !mixin.shouldComponentUpdate || mixin.shouldComponentUpdate.apply(this, args); }
n/a
TimeList = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { step: 30, onSelect: function onSelect() {}, min: new Date(1900, 0, 1), max: new Date(2099, 11, 31), preserveDate: true, delay: 300, ariaActiveDescendantKey: 'timelist' }; }
n/a
function _closestDate(times, date) { var roundTo = 1000 * 60 * this.props.step, inst = null, label; if (!date) return null; date = new Date(Math.floor(date.getTime() / roundTo) * roundTo); label = _localizers.date.format(date, format(this.props), this.props.culture); times.some(function (time) { if (time.label === label) return inst = time; }); return inst; }
...
preserveDate: true,
delay: 300,
ariaActiveDescendantKey: 'timelist'
};
},
getInitialState: function getInitialState() {
var data = this._dates(this.props),
focusedItem = this._closestDate(data, this.props.value || this.props.currentDate
);
return {
focusedItem: focusedItem || data[0],
dates: data
};
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
...
function _data() { return this.state.dates; }
...
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
ref: 'list',
...
function _dateValues(props) { var value = props.value || props.currentDate || _dates3.default.today(), useDate = props.preserveDate, min = props.min, max = props.max, start, end; //compare just the time regradless of whether they fall on the same day if (!useDate) { start = _dates3.default.startOf(_dates3.default.merge(new Date(), min, props.currentDate), 'minutes'); end = _dates3.default.startOf(_dates3.default.merge(new Date(), max, props.currentDate), 'minutes'); if (_dates3.default.lte(end, start) && _dates3.default.gt(max, min, 'day')) end = _dates3.default.tomorrow(); return { min: start, max: end }; } start = _dates3.default.today(); end = _dates3.default.tomorrow(); //date parts are equal return { min: _dates3.default.eq(value, min, 'day') ? _dates3.default.merge(start, min, props.currentDate) : start, max: _dates3.default.eq(value, max, 'day') ? _dates3.default.merge(start, max, props.currentDate) : end }; }
...
},
_data: function _data() {
return this.state.dates;
},
_dates: function _dates(props) {
var times = [],
i = 0,
values = this._dateValues(props),
start = values.min,
startDay = _dates3.default.date(start);
while (_dates3.default.date(start) === startDay && _dates3.default.lte(start, values.max)) {
i++;
times.push({ date: start, label: _localizers.date.format(start, format(props), props.culture) });
start = _dates3.default.add(start, props.step || 30, 'minutes');
...
function _dates(props) { var times = [], i = 0, values = this._dateValues(props), start = values.min, startDay = _dates3.default.date(start); while (_dates3.default.date(start) === startDay && _dates3.default.lte(start, values.max)) { i++; times.push({ date: start, label: _localizers.date.format(start, format(props), props.culture) }); start = _dates3.default.add(start, props.step || 30, 'minutes'); } return times; }
...
max: new Date(2099, 11, 31),
preserveDate: true,
delay: 300,
ariaActiveDescendantKey: 'timelist'
};
},
getInitialState: function getInitialState() {
var data = this._dates(this.props),
focusedItem = this._closestDate(data, this.props.value || this.props.currentDate);
return {
focusedItem: focusedItem || data[0],
dates: data
};
},
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function componentWillReceiveProps(nextProps) { var data = this._dates(nextProps), focusedItem = this._closestDate(data, nextProps.value || this.props.currentDate), valChanged = !_dates3.default.eq(nextProps.value, this.props.value, 'minutes'), minChanged = !_dates3.default.eq(nextProps.min, this.props.min, 'minutes'), maxChanged = !_dates3.default.eq(nextProps.max, this.props.max, 'minutes'), localeChanged = this.props.format !== nextProps.format || this.props.culture !== nextProps.culture; if (valChanged || minChanged || maxChanged || localeChanged) { this.setState({ focusedItem: focusedItem || data[0], dates: data }); } }
n/a
function componentWillUnmount() { var timers = this._timers || {}; this._unmounted = true; for (var k in timers) { if (has(timers, k)) this.clearTimeout(k); } }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { var data = this._dates(this.props), focusedItem = this._closestDate(data, this.props.value || this.props.currentDate); return { focusedItem: focusedItem || data[0], dates: data }; }
n/a
function handleKeyDown(e) { var key = e.key, focusedItem = this.state.focusedItem, list = this.refs.list; if (key === 'End') { e.preventDefault(); this.setState({ focusedItem: list.last() }); } else if (key === 'Home') { e.preventDefault(); this.setState({ focusedItem: list.first() }); } else if (key === 'Enter') this.props.onSelect(focusedItem);else if (key === 'ArrowDown') { e.preventDefault(); this.setState({ focusedItem: list.next(focusedItem) }); } else if (key === 'ArrowUp') { e.preventDefault(); this.setState({ focusedItem: list.prev(focusedItem) }); } }
...
if (e.key === 'Escape' && open) this.close();else if (e.altKey) {
e.preventDefault();
if (e.key === 'ArrowDown') {
if (calendar && time) this.open(open === _constants.datePopups.CALENDAR ? _constants.datePopups.TIME : _constants
.datePopups.CALENDAR);else if (time) this.open(_constants.datePopups.TIME);else if (calendar) this.open(_constants.datePopups.CALENDAR
);
} else if (e.key === 'ArrowUp') this.close();
} else if (open) {
if (open === _constants.datePopups.CALENDAR) this.refs.calPopup.handleKeyDown(
e);
if (open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyDown(e);
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
...
function handleKeyPress(e) { var _this = this; e.preventDefault(); this.search(String.fromCharCode(e.which), function (item) { _this.isMounted() && _this.setState({ focusedItem: item }); }); }
...
}
},
handleKeyPress: function handleKeyPress(e) {
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (this.props.open === _constants.datePopups.TIME) this.refs.timePopup.handleKeyPress
span>(e);
},
focus: function focus() {
var valueInput = this.refs.valueInput;
if (valueInput && (0, _activeElement2.default)() !== _compat2.default.findDOMNode(valueInput)) valueInput.focus();
},
...
function render() { var _props = this.props, value = _props.value, onSelect = _props.onSelect, itemComponent = _props.itemComponent; var times = this.state.dates, date = this._closestDate(times, value); return _react2.default.createElement(_List2.default, _extends({}, _3.default.omitOwnProps(this), { ref: 'list', data: times, textField: 'label', valueField: 'date', selected: date, onSelect: onSelect, focused: this.state.focusedItem, itemComponent: itemComponent })); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function scrollTo() { this.refs.list.move && this.refs.list.move(); }
...
var getWindow = __webpack_require__(37);
module.exports = function scrollTop(node, val) {
var win = getWindow(node);
if (val === undefined) return win ? 'pageYOffset' in win ? win.pageYOffset : win.document.documentElement.scrollTop
: node.scrollTop;
if (win) win.scrollTo('pageXOffset' in win ? win.pageXOffset : win.document
.documentElement.scrollLeft, val);else node.scrollTop = val;
};
/***/ },
/* 60 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
...
function search(character, cb) { var _this2 = this; var word = ((this._searchTerm || '') + character).toLowerCase(); this._searchTerm = word; this.setTimeout('search', function () { var list = _this2.refs.list, item = list.next(_this2.state.focusedItem, word); _this2._searchTerm = ''; if (item) cb(item); }, this.props.delay); }
...
handleKeyPress: function handleKeyPress(e) {
var _this4 = this;
(0, _widgetHelpers.notify)(this.props.onKeyPress, [e]);
if (e.defaultPrevented) return;
if (!(this.props.filter && this.props.open)) this.search(String.fromCharCode
(e.which), function (item) {
_this4.isMounted() && _this4.props.open ? _this4.setState({ focusedItem: item }) : item && _this4.change
(item);
});
},
change: function change(data) {
if (!(0, _dataHelpers.valueMatcher)(data, this.props.value, this.props.valueField)) {
(0, _widgetHelpers.notify)(this.props.onChange, data);
(0, _widgetHelpers.notify)(this.props.onSearch, '');
...
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function clearTimeout(key) { var timers = this._timers || {}; window.clearTimeout(timers[key]); }
...
module.exports = {
componentWillUnmount: function componentWillUnmount() {
var timers = this._timers || {};
this._unmounted = true;
for (var k in timers) {
if (has(timers, k)) this.clearTimeout(k);
}
},
clearTimeout: function clearTimeout(key) {
var timers = this._timers || {};
window.clearTimeout(timers[key]);
},
setTimeout: function setTimeout(key, cb, duration) {
...
function componentWillUnmount() { var timers = this._timers || {}; this._unmounted = true; for (var k in timers) { if (has(timers, k)) this.clearTimeout(k); } }
n/a
function setTimeout(key, cb, duration) { var _this = this; var timers = this._timers || (this._timers = Object.create(null)); if (this._unmounted) return; this.clearTimeout(key); timers[key] = window.setTimeout(function () { if (!_this._unmounted) cb(); }, duration); }
...
var word = ((this._searchTerm || '') + character).toLowerCase();
if (!character) return;
this._searchTerm = word;
this.setTimeout('search', function () {
var list = _this5.refs.list,
key = _this5.props.open ? 'focusedItem' : 'selectedItem',
item = list.next(_this5.state[key], word);
_this5._searchTerm = '';
if (item) cb(item);
}, this.props.delay);
...
function Widget() { _classCallCheck(this, Widget); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); }
n/a
function render() { var _props = this.props, className = _props.className, tabIndex = _props.tabIndex, open = _props.open, dropUp = _props.dropUp, disabled = _props.disabled, readOnly = _props.readOnly, focused = _props.focused, props = _objectWithoutProperties(_props, ['className', 'tabIndex', 'open', 'dropUp', 'disabled', 'readOnly', 'focused']); var isRtl = !!this.context.isRtl; var openClass = 'rw-open' + (dropUp ? '-up' : ''); tabIndex = tabIndex != null ? tabIndex : '-1'; return _react2.default.createElement('div', _extends({}, props, { tabIndex: tabIndex, className: (0, _classnames2.default)(className, 'rw-widget', isRtl && 'rw-rtl', open && openClass, focused && 'rw-state-focus ', disabled && 'rw-state-disabled', readOnly && 'rw-state-readonly') })); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
Year = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function ariaActiveDescendant(id) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.ariaActiveDescendantKey; var activeDescendants = this.context.activeDescendants; var current = this.__ariaActiveDescendantId; if (id === undefined) return current; id = reconcileChildren.call(this, key, id); if (id === undefined) id = current;else { this.__ariaActiveDescendantId = id; flushAriaToNode(id, nodeOrComponent, this); } activeDescendants && activeDescendants.reconcile(key, id); }
...
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
this.ariaActiveDescendant(idx !== -1 ? activeId : null);
this.move();
},
render: function render() {
var _this = this;
var _props2 = this.props,
...
function componentDidUpdate() { var activeId = optionId((0, _widgetHelpers.instanceId)(this), this.props.focused); this.ariaActiveDescendant(activeId); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getChildContext() { var _this = this; return this._context || (this._context = { activeDescendants: { reconcile: function reconcile(key, id) { return _this.ariaActiveDescendant(id, key); } } }); }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function isRtl() { return !!this.context.isRtl; }
...
}
if (direction) {
if (ctrl) {
e.preventDefault();
this.navigate(direction);
} else {
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION
[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt
(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate(currentDate);
...
function render() { var focused = this.props.focused, months = _dates2.default.monthsInYear(_dates2.default.year(focused)); return _react2.default.createElement( _CalendarView2.default, _3.default.omitOwnProps(this), _react2.default.createElement( 'tbody', null, _3.default.chunk(months, 4).map(this.renderRow) ) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function renderRow(row, rowIdx) { var _this = this; var _props = this.props, focused = _props.focused, disabled = _props.disabled, onChange = _props.onChange, value = _props.value, today = _props.today, culture = _props.culture, min = _props.min, max = _props.max; var id = (0, _widgetHelpers.instanceId)(this), labelFormat = _localizers.date.getFormat('header'); return _react2.default.createElement( _CalendarView2.default.Row, { key: rowIdx }, row.map(function (date, colIdx) { var label = _localizers.date.format(date, labelFormat, culture); return _react2.default.createElement( _CalendarView2.default.Cell, { key: colIdx, id: optionId(id, date), label: label, date: date, now: today, min: min, max: max, unit: 'month', onChange: onChange, focused: focused, selected: value, disabled: disabled }, _localizers.date.format(date, format(_this.props), culture) ); }) ); }
n/a
function chunk(array, chunkSize) { var index = 0, length = array ? array.length : 0, result = []; chunkSize = Math.max(+chunkSize || 1, 1); while (index < length) { result.push(array.slice(index, index += chunkSize)); }return result; }
...
this.ariaActiveDescendant(activeId, null);
},
render: function render() {
var _props = this.props,
focused = _props.focused,
culture = _props.culture,
month = _dates2.default.visibleDays(focused, culture),
rows = _3.default.chunk(month, 7);
return _react2.default.createElement(
_CalendarView2.default,
_3.default.omitOwnProps(this),
_react2.default.createElement(
'thead',
null,
...
function each(obj, cb, thisArg) { if (Array.isArray(obj)) return obj.forEach(cb, thisArg); for (var key in obj) { if (has(obj, key)) cb.call(thisArg, obj[key], key, obj); } }
...
if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) !== 'object' && (typeof b
=== 'undefined' ? 'undefined' : _typeof(b)) !== 'object') return a === b;
if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) !== (typeof b === 'undefined' ? '
;undefined' : _typeof(b))) return false;
return shallowEqual(a, b);
},
transform: function transform(obj, cb, seed) {
_.each(obj, cb.bind(null, seed = seed || (Array.isArray(obj) ? [] : {})));
return seed;
},
each: function each(obj, cb, thisArg) {
if (Array.isArray(obj)) return obj.forEach(cb, thisArg);
for (var key in obj) {
if (has(obj, key)) cb.call(thisArg, obj[key], key, obj);
...
function find(arr, cb, thisArg) { var result; if (Array.isArray(arr)) { arr.every(function (val, idx) { if (cb.call(thisArg, val, idx, arr)) return result = val, false; return true; }); return result; } else for (var key in arr) { if (has(arr, key)) if (cb.call(thisArg, arr[key], key, arr)) return arr[key]; } }
...
strVal = e.target.value,
suggestion;
suggestion = this._deleting || !shouldSuggest ? strVal : this.suggest(this._data(), strVal);
suggestion = suggestion || strVal;
data = _3.default.find(data, function (item) {
return (0, _dataHelpers.dataText)(item, textField).toLowerCase() === suggestion.toLowerCase();
});
this.change(!this._deleting && data ? data : strVal, true);
this.open();
},
...
function has(o, k) { return o ? Object.prototype.hasOwnProperty.call(o, k) : false; }
...
};
// the keys array ensures that groups are rendered in the order they came in
// which means that if you sort the data array it will render sorted,
// so long as you also sorted by group
keys = keys || [];
(0, _warning2.default)(typeof groupBy !== 'string' || !data.length || _3.default.has(data[0], groupBy), '[React Widgets] You seem to be trying to group this list by a ' + ('property `
x27; + groupBy + '` that doesn\'t exist in the dataset items, this may be a typo'));
return data.reduce(function (grps, item) {
var group = iter(item);
_3.default.has(grps, group) ? grps[group].push(item) : (keys.push(group), grps[group] = [item]);
return grps;
...
function isShallowEqual(a, b) { if (a === b) return true; if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime(); if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) !== 'object' && (typeof b === 'undefined' ? 'undefined' : _typeof(b)) !== ' object') return a === b; if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) !== (typeof b === 'undefined' ? 'undefined' : _typeof(b))) return false ; return shallowEqual(a, b); }
...
'use strict';
var _ = __webpack_require__(19);
//backport PureRenderEqual
module.exports = {
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
return !_.isShallowEqual(this.props, nextProps) || !_.isShallowEqual(this.state,
nextState);
}
};
/***/ },
/* 55 */
/***/ function(module, exports, __webpack_require__) {
...
function noop() {}
n/a
function omit(obj, keys) { keys = [].concat(keys); return _.transform(obj, function (mapped, val, key) { if (keys.indexOf(key) === -1) mapped[key] = val; }, {}); }
...
others[_key2 - 1] = arguments[_key2];
}
var keys = others.reduce(function (arr, compClass) {
return arr.concat(Object.keys(compClass.propTypes));
}, Object.keys(component.constructor.propTypes));
return _.omit(component.props, keys);
},
find: function find(arr, cb, thisArg) {
var result;
if (Array.isArray(arr)) {
arr.every(function (val, idx) {
if (cb.call(thisArg, val, idx, arr)) return result = val, false;
return true;
...
function omitOwnProps(component) { for (var _len2 = arguments.length, others = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { others[_key2 - 1] = arguments[_key2]; } var keys = others.reduce(function (arr, compClass) { return arr.concat(Object.keys(compClass.propTypes)); }, Object.keys(component.constructor.propTypes)); return _.omit(component.props, keys); }
...
var disabled = (0, _interaction.isDisabled)(this.props),
readOnly = (0, _interaction.isReadOnly)(this.props),
valueItem = (0, _dataHelpers.dataItem)(data, value, valueField) // take value from the raw data
,
listID = (0, _widgetHelpers.instanceId)(this, '__listbox');
var elementProps = _extends(_3.default.omitOwnProps(this, List), {
role: 'combobox',
tabIndex: tabIndex || 0,
'aria-owns': listID,
'aria-expanded': !!open,
'aria-haspopup': true,
'aria-busy': !!busy,
'aria-live': !open && 'polite',
...
function pick(obj, keys) { keys = [].concat(keys); return _.transform(obj, function (mapped, val, key) { if (keys.indexOf(key) !== -1) mapped[key] = val; }, {}); }
...
pick: function pick(obj, keys) {
keys = [].concat(keys);
return _.transform(obj, function (mapped, val, key) {
if (keys.indexOf(key) !== -1) mapped[key] = val;
}, {});
},
pickProps: function pickProps(props, componentClass) {
return _.pick(props, Object.keys(componentClass.propTypes));
},
omit: function omit(obj, keys) {
keys = [].concat(keys);
return _.transform(obj, function (mapped, val, key) {
if (keys.indexOf(key) === -1) mapped[key] = val;
}, {});
},
...
function pickProps(props, componentClass) { return _.pick(props, Object.keys(componentClass.propTypes)); }
...
filter = _props2.filter,
data = _props2.data;
var _state = this.state,
selectedItem = _state.selectedItem,
focusedItem = _state.focusedItem;
var listProps = _3.default.pickProps(this.props, List);
var items = this._data();
return _react2.default.createElement(
'div',
null,
filter && this.renderFilter(messages),
_react2.default.createElement(List, _extends({}, listProps, {
...
function result(value) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } return typeof value === 'function' ? value.apply(undefined, args) : value; }
...
return _react2.default.createElement(
'div',
{ ref: 'filterWrapper', className: 'rw-filter-input' },
_react2.default.createElement(_Select2.default, { component: 'span', icon: 'search' }),
_react2.default.createElement(_Input2.default, {
ref: 'filter',
value: this.props.searchTerm,
placeholder: _3.default.result(messages.filterPlaceholder, this.props),
onChange: function onChange(e) {
return (0, _widgetHelpers.notify)(_this.props.onSearch, e.target.value);
}
})
);
},
renderList: function renderList(List, id, messages) {
...
function splat(obj) { return obj == null ? [] : [].concat(obj); }
...
},
onAnimating: _3.default.noop,
onAnimate: _3.default.noop
};
},
getInitialState: function getInitialState() {
return {
children: _3.default.splat(this.props.children)
};
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var nextChild = getChild(nextProps.children),
stack = this.state.children.slice(),
next = stack[1],
last = stack[0];
...
function transform(obj, cb, seed) { _.each(obj, cb.bind(null, seed = seed || (Array.isArray(obj) ? [] : {}))); return seed; }
...
for (var key in obj) {
if (has(obj, key)) cb.call(thisArg, obj[key], key, obj);
}
},
pick: function pick(obj, keys) {
keys = [].concat(keys);
return _.transform(obj, function (mapped, val, key) {
if (keys.indexOf(key) !== -1) mapped[key] = val;
}, {});
},
pickProps: function pickProps(props, componentClass) {
return _.pick(props, Object.keys(componentClass.propTypes));
},
omit: function omit(obj, keys) {
...
function uniqueId(prefix) { return '' + ((prefix == null ? '' : prefix) + ++idCount); }
...
it('should FIND', function(){
expect(_.find([1, 2, 3, 4, 5], v => v === 2)).to.equal(2)
expect(_.find([1, 2, 3, 4, 5], (v, i) => i === 2)).to.equal(3)
})
it('should UNIQUEID', function(){
expect(_.uniqueId('gello_')).to.equal('gello_' + 1)
expect(_.uniqueId('ello_')).to.equal('ello_' + 2)
})
it('should SHALLOW EQUAL', function(){
expect( _.isShallowEqual(1, 1) ).to.be(true)
expect( _.isShallowEqual(1, '1') ).to.be(false)
expect( _.isShallowEqual(1, 1.4) ).to.be(false)
...
function batchedUpdates(cb) { _reactDom2.default.unstable_batchedUpdates(cb); }
...
});
},
componentDidMount: function componentDidMount() {
var _this = this;
var isOpen = this.state.status === OPENING;
_compat2.default.batchedUpdates(function () {
_this.setState({ initialRender: false });
if (isOpen) {
_this.open();
}
});
},
componentDidUpdate: function componentDidUpdate(pvProps) {
...
function findDOMNode(component) { return _reactDom2.default.findDOMNode(component); }
...
(0, _widgetHelpers.notify)(this.props.onSelect, data);
this.change(data);
this.focus(this);
},
handleClick: function handleClick(e) {
var wrapper = this.refs.filterWrapper;
if (!this.props.filter || !this.props.open) this.toggle();else if (!(0, _contains2.default)(_compat2.default.findDOMNode(wrapper), e.target)) this.close();
(0, _widgetHelpers.notify)(this.props.onClick, e);
},
handleKeyDown: function handleKeyDown(e) {
var _this3 = this;
var key = e.key,
...
function version() { return _version; }
n/a
function animate(node, properties, duration, easing, callback) { var cssProperties = [], fakeEvent = { target: node, currentTarget: node }, cssValues = {}, transforms = '', fired; if (typeof easing === 'function') callback = easing, easing = null; if (!_properties2.default.end) duration = 0; if (duration === undefined) duration = 200; for (var key in properties) { if (has.call(properties, key)) { if (/(top|bottom)/.test(key)) transforms += TRANSLATION_MAP[key] + '(' + properties[key] + ') ';else { cssValues[key] = properties[key]; cssProperties.push((0, _hyphenate2.default)(key)); } } }if (transforms) { cssValues[_properties2.default.transform] = transforms; cssProperties.push(_properties2.default.transform); } if (duration > 0) { cssValues[_properties2.default.property] = cssProperties.join(', '); cssValues[_properties2.default.duration] = duration / 1000 + 's'; cssValues[_properties2.default.delay] = 0 + 's'; cssValues[_properties2.default.timing] = easing || 'linear'; (0, _on2.default)(node, _properties2.default.end, done); setTimeout(function () { if (!fired) done(fakeEvent); }, duration + 500); } node.clientLeft; // trigger page reflow (0, _style2.default)(node, cssValues); if (duration <= 0) setTimeout(done.bind(null, fakeEvent), 0); return { cancel: function cancel() { if (fired) return; fired = true; (0, _off2.default)(node, _properties2.default.end, done); (0, _style2.default)(node, reset); } }; function done(event) { if (event.target !== event.currentTarget) return; fired = true; (0, _off2.default)(event.target, _properties2.default.end, done); (0, _style2.default)(node, reset); callback && callback.call(this); } }
...
this.props.onOpening();
this.safeSetState({ status: OPENING, height: height }, function () {
var offset = _this2.getOffsetForStatus(OPEN),
duration = _this2.props.duration;
_this2.animate(el, offset, duration, 'ease', function () {
_this2.safeSetState({ status: OPEN }, function () {
_this2.props.onOpen();
});
});
});
},
close: function close() {
...
function setAnimate(animatefn) { _configuration2.default.animate = animatefn; }
...
describe('when configuring dependencies', function(){
it('should use the instances provided', function(){
var animate = ()=>{};
expect(config.animate).to.not.equal(animate)
configure.setAnimate(animate)
expect(config.animate).to.equal(animate)
})
})
...
function setDate(spec) { (0, _invariant2.default)(typeof spec.format === 'function', 'date localizer `format(..)` must be a function'); (0, _invariant2.default)(typeof spec.parse === 'function', 'date localizer `parse(..)` must be a function'); (0, _invariant2.default)(typeof spec.firstOfWeek === 'function', 'date localizer `firstOfWeek(..)` must be a function'); checkFormats(REQUIRED_DATE_FORMATS, spec.formats); _dateLocalizer = { formats: spec.formats, propType: spec.propType || localePropType, startOfWeek: spec.firstOfWeek, format: function format(value, str, culture) { return _format(this, spec.format, value, str, culture); }, parse: function parse(value, culture) { var result = spec.parse.call(this, value, culture); (0, _invariant2.default)(result == null || result instanceof Date && !isNaN(result.getTime()), 'date localizer `parse(..)` must return a valid Date, null, or undefined'); return result; } }; }
...
setAnimate: function setAnimate(animatefn) {
_configuration2.default.animate = animatefn;
},
setLocalizers: function setLocalizers(_ref) {
var date = _ref.date,
number = _ref.number;
date && this.setDateLocalizer(date);
number && this.setNumberLocalizer(number);
},
setDateLocalizer: localizers.setDate,
setNumberLocalizer: localizers.setNumber
...
function setLocalizers(_ref) { var date = _ref.date, number = _ref.number; date && this.setDateLocalizer(date); number && this.setNumberLocalizer(number); }
...
date.setMilliseconds(date.getMilliseconds() - 1);
return date;
}
function globalizeLocalizers(globalize) {
var localizers = globalize.locale && !globalize.cultures ? newGlobalize(globalize) : oldGlobalize(globalize);
_configure2.default.setLocalizers(localizers);
return localizers;
}
function newGlobalize(globalize) {
var locale = function locale(culture) {
return culture ? globalize(culture) : globalize;
};
...
function setNumber(_ref) { var _format2 = _ref.format, _parse = _ref.parse, _ref$decimalChar = _ref.decimalChar, decimalChar = _ref$decimalChar === undefined ? function () { return '.'; } : _ref$decimalChar, _ref$precision = _ref.precision, precision = _ref$precision === undefined ? function () { return null; } : _ref$precision, formats = _ref.formats, propType = _ref.propType; (0, _invariant2.default)(typeof _format2 === 'function', 'number localizer `format(..)` must be a function'); (0, _invariant2.default)(typeof _parse === 'function', 'number localizer `parse(..)` must be a function'); checkFormats(REQUIRED_NUMBER_FORMATS, formats); formats.editFormat = formats.editFormat || function (str) { return parseFloat(str); }; _numberLocalizer = { formats: formats, precision: precision, decimalChar: decimalChar, propType: propType || localePropType, format: function format(value, str, culture) { return _format(this, _format2, value, str, culture); }, parse: function parse(value, culture, format) { var result = _parse.call(this, value, culture, format); (0, _invariant2.default)(result == null || typeof result === 'number', 'number localizer `parse(..)` must return a number, null, or undefined'); return result; } }; }
...
_configuration2.default.animate = animatefn;
},
setLocalizers: function setLocalizers(_ref) {
var date = _ref.date,
number = _ref.number;
date && this.setDateLocalizer(date);
number && this.setNumberLocalizer(number);
},
setDateLocalizer: localizers.setDate,
setNumberLocalizer: localizers.setNumber
};
...
function dataIndexOf(data, item, valueField) { var idx = -1, len = data.length, isValueEqual = function isValueEqual(datum) { return valueMatcher(item, datum, valueField); }; while (++idx < len) { var datum = data[idx]; if (datum === item || isValueEqual(datum)) return idx; } return -1; }
...
expect(helpers.dataItem([{}, val, {}], 3, 'value')).to.equal(val)
})
it('should work with indexOf', function(){
var val = { value: 3 }
expect(helpers.dataIndexOf([ 2, 3, 1], 1)).to.equal(2)
expect(helpers.dataIndexOf([{}, val, {}], val)).to.equal(1)
expect(helpers.dataIndexOf([{}, val, {}], { value: 3 })).to.equal(1)
expect(helpers.dataIndexOf([{}, val, {}], 3, 'value')).to.equal(1)
...
function dataItem(data, item, valueField) { var idx = dataIndexOf(data, dataValue(item, valueField), valueField); if (idx !== -1) return data[idx]; return item; }
...
expect(helpers.dataText({ text: { a: 3 } }, textField)).to.eql('[object Object] hi')
})
})
it('should work with dataItem', function(){
var val = { value: 3 }
expect(helpers.dataItem([ 2, 3, 1], 1)).to.equal(1)
expect(helpers.dataItem([{}, val, {}], val)).to.equal(val)
expect(helpers.dataItem([{}, val, {}], { value: 3 })).to.equal(val)
expect(helpers.dataItem([{}, val, {}], 3, 'value')).to.equal(val)
})
...
function dataText(item, textField) { var value = accessor(item, textField); return value == null ? '' : value + ''; }
...
expect(helpers.dataValue({ value: { a: 3 } }, 'value')).to.eql({ a: 3 })
})
describe('Reading Data Text', () => {
it('should always return a string', function(){
expect(helpers.dataText('hi')).to.be.a('string').and.to.equal(
x27;hi')
expect(helpers.dataText({ a: 3 })).to.be.a('string').and.to.equal('[object Object]')
expect(helpers.dataText(null)).to.be.a('string').and.to.equal('')
expect(helpers.dataText(4)).to.be.a('string').and.to.equal('4')
})
it('should use specified field', function(){
expect(helpers.dataText('hi', 'text')).to.equal('hi')
...
function dataValue(item, valueField) { return valueField && item && (0, _.has)(item, valueField) ? item[valueField] : item; }
...
import * as helpers from'../src/util/dataHelpers';
describe('when using DATA HELPERS', function(){
it('should get a Value Out', function(){
expect(helpers.dataValue(1)).to.equal(1)
expect(helpers.dataValue({ a: 3 })).to.eql({ a: 3 })
expect(helpers.dataValue(1, 'value')).to.equal(1)
expect(helpers.dataValue({ value: 1 }, 'value')).to.equal(1)
expect(helpers.dataValue({ value: { a: 3 } }, 'value')).to.eql({ a: 3 })
})
...
function valueMatcher(a, b, valueField) { return (0, _.isShallowEqual)(dataValue(a, valueField), dataValue(b, valueField)); }
...
_dataText: function _dataText(item) {
return dataHelpers.dataText(item, this.props.textField);
},
_dataIndexOf: function _dataIndexOf(data, item) {
return dataHelpers.dataIndexOf(data, item, this.props.valueField);
},
_valueMatcher: function _valueMatcher(a, b) {
return dataHelpers.valueMatcher(a, b, this.props.valueField);
},
_dataItem: function _dataItem(data, item) {
return dataHelpers.dataItem(data, item, this.props.valueField);
}
};
module.exports = exports['default'];
...
add = function (date, num, unit) { date = new Date(date) switch (unit){ case MILI: case SECONDS: case MINUTES: case HOURS: case YEAR: return dates[unit](date, dates[unit](date) + num) case DAY: return dates.date(date, dates.date(date) + num) case WEEK: return dates.date(date, dates.date(date) + (7 * num)) case MONTH: return monthMath(date, num) case DECADE: return dates.year(date, dates.year(date) + (num * 10)) case CENTURY: return dates.year(date, dates.year(date) + (num * 100)) } throw new TypeError('Invalid units: "' + unit + '"') }
...
visibleDays: function visibleDays(date, culture) {
var current = dates.firstVisibleDay(date, culture),
last = dates.lastVisibleDay(date, culture),
days = [];
while (dates.lte(current, last, 'day')) {
days.push(current);
current = dates.add(current, 1, 'day');
}
return days;
},
move: function move(date, min, max, unit, direction) {
var isMonth = unit === 'month',
isUpOrDown = direction === _constants.directions.UP || direction === _constants.directions.DOWN,
...
century = function (date, val) { return val === undefined ? dates.year(dates.startOf(date, CENTURY)) : dates.add(date, val + 100, YEAR); }
n/a
date = function (date, val){ if (val === undefined) return date['get' + method]() date = new Date(date) date['set' + method](val) return date }
...
return _localizers.date.getFormat('weekday', props.dayFormat);
},
dateFormat = function dateFormat(props) {
return _localizers.date.getFormat('dayOfMonth', props.dateFormat);
};
var optionId = function optionId(id, date) {
return id + '__month_' + _dates2.default.month(date) + '-' + _dates2.default.date(date);
};
var propTypes = {
culture: _react2.default.PropTypes.string,
today: _react2.default.PropTypes.instanceOf(Date),
value: _react2.default.PropTypes.instanceOf(Date),
focused: _react2.default.PropTypes.instanceOf(Date),
...
day = function (date, val){ if (val === undefined) return date['get' + method]() date = new Date(date) date['set' + method](val) return date }
...
century: function (date, val) {
return val === undefined
? dates.year(dates.startOf(date, CENTURY))
: dates.add(date, val + 100, YEAR);
},
weekday: function (date, val, firstDay) {
var weekday = (dates.day(date) + 7 - (firstDay || 0) ) % 7;
return val === undefined
? weekday
: dates.add(date, val - weekday, DAY);
},
diff: function (date1, date2, unit, asFloat) {
...
decade = function (date, val) { return val === undefined ? dates.year(dates.startOf(date, DECADE)) : dates.add(date, val + 10, YEAR); }
n/a
diff = function (date1, date2, unit, asFloat) { var dividend, divisor, result; switch (unit) { case MILI: case SECONDS: case MINUTES: case HOURS: case DAY: case WEEK: dividend = date2.getTime() - date1.getTime(); break; case MONTH: case YEAR: case DECADE: case CENTURY: dividend = (dates.year(date2) - dates.year(date1)) * 12 + dates.month(date2) - dates.month(date1); break; default: throw new TypeError('Invalid units: "' + unit + '"'); } switch (unit) { case MILI: divisor = 1; break; case SECONDS: divisor = 1000; break; case MINUTES: divisor = 1000 * 60; break; case HOURS: divisor = 1000 * 60 * 60; break; case DAY: divisor = 1000 * 60 * 60 * 24; break; case WEEK: divisor = 1000 * 60 * 60 * 24 * 7; break; case MONTH: divisor = 1; break; case YEAR: divisor = 12; break; case DECADE: divisor = 120; break; case CENTURY: divisor = 1200; break; default: throw new TypeError('Invalid units: "' + unit + '"'); } result = dividend / divisor; return asFloat ? result : absoluteFloor(result); }
n/a
endOf = function (date, unit, firstOfWeek){ date = new Date(date) date = dates.startOf(date, unit, firstOfWeek) date = dates.add(date, 1, unit) date = dates.subtract(date, 1, MILI) return date }
...
});
},
firstVisibleDay: function firstVisibleDay(date, culture) {
var firstOfMonth = dates.startOf(date, 'month');
return dates.startOf(firstOfMonth, 'week', _localizers.date.startOfWeek(culture));
},
lastVisibleDay: function lastVisibleDay(date, culture) {
var endOfMonth = dates.endOf(date, 'month');
return dates.endOf(endOfMonth, 'week', _localizers.date.startOfWeek(culture));
},
visibleDays: function visibleDays(date, culture) {
var current = dates.firstVisibleDay(date, culture),
last = dates.lastVisibleDay(date, culture),
days = [];
...
eq = function (a, b, unit) { return operator(+dates.startOf(a, unit), +dates.startOf(b, unit)) }
...
current = VIEW_OPTIONS.indexOf(this.state.view),
view = this.state.view,
val = this.inRangeValue(nextProps.value);
if (current < bottom) this.setState({ view: view = nextProps.initialView });else if (current > top) this.setState
({ view: view = nextProps.finalView });
//if the value changes reset views to the new one
if (!_dates2.default.eq(val, dateOrNull(this.props.value), VIEW_UNIT[view])) {
this.changeCurrentDate(val, nextProps.currentDate);
}
},
render: function render() {
var _this = this;
var _props = this.props,
...
function firstVisibleDay(date, culture) { var firstOfMonth = dates.startOf(date, 'month'); return dates.startOf(firstOfMonth, 'week', _localizers.date.startOfWeek(culture)); }
...
},
lastVisibleDay: function lastVisibleDay(date, culture) {
var endOfMonth = dates.endOf(date, 'month');
return dates.endOf(endOfMonth, 'week', _localizers.date.startOfWeek(culture));
},
visibleDays: function visibleDays(date, culture) {
var current = dates.firstVisibleDay(date, culture),
last = dates.lastVisibleDay(date, culture),
days = [];
while (dates.lte(current, last, 'day')) {
days.push(current);
current = dates.add(current, 1, 'day');
}
...
function format(date, _format, culture) { return _localizers.date.format(date, _format, culture); }
...
footer: { date: 'full' },
weekday: 'eeeeee',
dayOfMonth: 'dd',
month: 'MMM',
year: 'yyyy',
decade: function decade(dt, culture, l) {
return l.format(dt, l.formats.year, culture) + ' - ' + l.format(endOfDecade
(dt), l.formats.year, culture);
},
century: function century(dt, culture, l) {
return l.format(dt, l.formats.year, culture) + ' - ' + l.format(endOfCentury(dt), l.formats.year, culture);
}
},
...
gt = function (a, b, unit) { return operator(+dates.startOf(a, unit), +dates.startOf(b, unit)) }
...
var inRangeDate = this.inRangeValue(date ? new Date(date) : currentDate);
if (_dates2.default.eq(inRangeDate, dateOrNull(currentDate), VIEW_UNIT[this.state.view])) return;
(0, _widgetHelpers.notify)(this.props.onCurrentDateChange, inRangeDate);
},
select: function select(date) {
var view = this.props.initialView,
slideDir = view !== this.state.view || _dates2.default.gt(date, this.state.currentDate
) ? 'left' // move down to a the view
: 'right';
(0, _widgetHelpers.notify)(this.props.onChange, date);
if (this.isValidView(view) && _dates2.default.inRange(date, this.props.min, this.props.max, view)) {
this.focus();
...
gte = function (a, b, unit) { return operator(+dates.startOf(a, unit), +dates.startOf(b, unit)) }
...
max: function(){
return new Date(Math.max.apply(Math, arguments))
},
inRange: function(day, min, max, unit){
unit = unit || 'day'
return (!min || dates.gte(day, min, unit))
&& (!max || dates.lte(day, max, unit))
},
milliseconds: createAccessor('Milliseconds'),
seconds: createAccessor('Seconds'),
minutes: createAccessor('Minutes'),
hours: createAccessor('Hours'),
...
hours = function (date, val){ if (val === undefined) return date['get' + method]() date = new Date(date) date['set' + method](val) return date }
...
merge: function merge(date, time, defaultDate) {
if (time == null && date == null) return null;
if (time == null) time = defaultDate || new Date();
if (date == null) date = defaultDate || new Date();
date = dates.startOf(date, 'day');
date = dates.hours(date, dates.hours(time));
date = dates.minutes(date, dates.minutes(time));
date = dates.seconds(date, dates.seconds(time));
return dates.milliseconds(date, dates.milliseconds(time));
},
sameMonth: function sameMonth(dateA, dateB) {
return dates.eq(dateA, dateB, 'month');
},
...
inRange = function (day, min, max, unit){ unit = unit || 'day' return (!min || dates.gte(day, min, unit)) && (!max || dates.lte(day, max, unit)) }
...
slideDirection = _state.slideDirection,
focused = _state.focused;
var View = VIEW[view],
unit = VIEW_UNIT[view],
todaysDate = new Date(),
todayNotInRange = !_dates2.default.inRange(todaysDate, min, max, view);
unit = unit === 'day' ? 'date' : unit;
var viewID = (0, _widgetHelpers.instanceId)(this, '_calendar'),
labelID = (0, _widgetHelpers.instanceId)(this, '_calendar_label'),
key = view + '_' + _dates2.default[view](currentDate);
...
function lastVisibleDay(date, culture) { var endOfMonth = dates.endOf(date, 'month'); return dates.endOf(endOfMonth, 'week', _localizers.date.startOfWeek(culture)); }
...
lastVisibleDay: function lastVisibleDay(date, culture) {
var endOfMonth = dates.endOf(date, 'month');
return dates.endOf(endOfMonth, 'week', _localizers.date.startOfWeek(culture));
},
visibleDays: function visibleDays(date, culture) {
var current = dates.firstVisibleDay(date, culture),
last = dates.lastVisibleDay(date, culture),
days = [];
while (dates.lte(current, last, 'day')) {
days.push(current);
current = dates.add(current, 1, 'day');
}
...
lt = function (a, b, unit) { return operator(+dates.startOf(a, unit), +dates.startOf(b, unit)) }
...
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate
(currentDate);
}
}
}
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
},
_label: function _label() {
...
lte = function (a, b, unit) { return operator(+dates.startOf(a, unit), +dates.startOf(b, unit)) }
...
return dates.endOf(endOfMonth, 'week', _localizers.date.startOfWeek(culture));
},
visibleDays: function visibleDays(date, culture) {
var current = dates.firstVisibleDay(date, culture),
last = dates.lastVisibleDay(date, culture),
days = [];
while (dates.lte(current, last, 'day')) {
days.push(current);
current = dates.add(current, 1, 'day');
}
return days;
},
move: function move(date, min, max, unit, direction) {
...
max = function (){ return new Date(Math.max.apply(Math, arguments)) }
...
},
propType: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object, _react.PropTypes.func]),
firstOfWeek: function firstOfWeek(culture) {
var date = new Date();
//cldr-data doesn't seem to be zero based
var localeDay = Math.max(parseInt(locale(culture).formatDate(date, { raw: '
;e' }), 10) - 1, 0);
return Math.abs(date.getDay() - localeDay);
},
parse: function parse(value, format, culture) {
format = typeof format === 'string' ? { raw: format } : format;
return locale(culture).parseDate(value, format);
},
...
function merge(date, time, defaultDate) { if (time == null && date == null) return null; if (time == null) time = defaultDate || new Date(); if (date == null) date = defaultDate || new Date(); date = dates.startOf(date, 'day'); date = dates.hours(date, dates.hours(time)); date = dates.minutes(date, dates.minutes(time)); date = dates.seconds(date, dates.seconds(time)); return dates.milliseconds(date, dates.milliseconds(time)); }
...
var valueInput = this.refs.valueInput;
if (valueInput && (0, _activeElement2.default)() !== _compat2.default.findDOMNode(valueInput)) valueInput.focus();
},
handleDateSelect: function handleDateSelect(date) {
var format = getFormat(this.props),
dateTime = _dates2.default.merge(date, this.props.value, this.props.currentDate
),
dateStr = formatDate(date, format, this.props.culture);
this.close();
(0, _widgetHelpers.notify)(this.props.onSelect, [dateTime, dateStr]);
this.handleChange(dateTime, dateStr, true);
this.focus();
},
...
milliseconds = function (date, val){ if (val === undefined) return date['get' + method]() date = new Date(date) date['set' + method](val) return date }
...
if (time == null) time = defaultDate || new Date();
if (date == null) date = defaultDate || new Date();
date = dates.startOf(date, 'day');
date = dates.hours(date, dates.hours(time));
date = dates.minutes(date, dates.minutes(time));
date = dates.seconds(date, dates.seconds(time));
return dates.milliseconds(date, dates.milliseconds(time));
},
sameMonth: function sameMonth(dateA, dateB) {
return dates.eq(dateA, dateB, 'month');
},
today: function today() {
return this.startOf(new Date(), 'day');
},
...
min = function (){ return new Date(Math.min.apply(Math, arguments)) }
...
if (view === 'month') return _localizers.date.format(dt, format(props, 'header'), culture);else if (view
=== 'year') return _localizers.date.format(dt, format(props, 'year'), culture);else if (view === 'decade
') return _localizers.date.format(_dates2.default.startOf(dt, 'decade'), format(props, 'decade'), culture
);else if (view === 'century') return _localizers.date.format(_dates2.default.startOf(dt, 'century'), format
(props, 'century'), culture);
},
inRangeValue: function inRangeValue(_value) {
var value = dateOrNull(_value);
if (value === null) return value;
return _dates2.default.max(_dates2.default.min(value, this.props.max), this.props
.min);
},
isValidView: function isValidView(next) {
var bottom = VIEW_OPTIONS.indexOf(this.props.initialView),
top = VIEW_OPTIONS.indexOf(this.props.finalView),
current = VIEW_OPTIONS.indexOf(next);
return current >= bottom && current <= top;
...
minutes = function (date, val){ if (val === undefined) return date['get' + method]() date = new Date(date) date['set' + method](val) return date }
...
if (time == null && date == null) return null;
if (time == null) time = defaultDate || new Date();
if (date == null) date = defaultDate || new Date();
date = dates.startOf(date, 'day');
date = dates.hours(date, dates.hours(time));
date = dates.minutes(date, dates.minutes(time));
date = dates.seconds(date, dates.seconds(time));
return dates.milliseconds(date, dates.milliseconds(time));
},
sameMonth: function sameMonth(dateA, dateB) {
return dates.eq(dateA, dateB, 'month');
},
today: function today() {
...
month = function (date, val){ if (val === undefined) return date['get' + method]() date = new Date(date) date['set' + method](val) return date }
...
return _localizers.date.getFormat('weekday', props.dayFormat);
},
dateFormat = function dateFormat(props) {
return _localizers.date.getFormat('dayOfMonth', props.dateFormat);
};
var optionId = function optionId(id, date) {
return id + '__month_' + _dates2.default.month(date) + '-' + _dates2
.default.date(date);
};
var propTypes = {
culture: _react2.default.PropTypes.string,
today: _react2.default.PropTypes.instanceOf(Date),
value: _react2.default.PropTypes.instanceOf(Date),
focused: _react2.default.PropTypes.instanceOf(Date),
...
function monthsInYear(year) { var months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], date = new Date(year, 0, 1); return months.map(function (i) { return dates.month(date, i); }); }
...
componentDidUpdate: function componentDidUpdate() {
var activeId = optionId((0, _widgetHelpers.instanceId)(this), this.props.focused);
this.ariaActiveDescendant(activeId);
},
render: function render() {
var focused = this.props.focused,
months = _dates2.default.monthsInYear(_dates2.default.year(focused));
return _react2.default.createElement(
_CalendarView2.default,
_3.default.omitOwnProps(this),
_react2.default.createElement(
'tbody',
...
function move(date, min, max, unit, direction) { var isMonth = unit === 'month', isUpOrDown = direction === _constants.directions.UP || direction === _constants.directions.DOWN, rangeUnit = _constants.calendarViewUnits[unit], addUnit = isMonth && isUpOrDown ? 'week' : _constants.calendarViewUnits[unit], amount = isMonth || !isUpOrDown ? 1 : 4, newDate; if (direction === _constants.directions.UP || direction === _constants.directions.LEFT) amount *= -1; newDate = dates.add(date, amount, addUnit); return dates.inRange(newDate, min, max, rangeUnit) ? newDate : date; }
...
data: [],
messages: {
emptyList: 'There are no items in this list'
}
};
},
componentDidMount: function componentDidMount() {
this.move();
},
componentDidUpdate: function componentDidUpdate() {
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
...
neq = function (a, b, unit) { return operator(+dates.startOf(a, unit), +dates.startOf(b, unit)) }
...
})
describe('when using array filter helpers', function(){
it('should match correctly', function(){
expect(filters.eq(1, 1)).to.equal(true)
expect(filters.neq(2, 1)).to.equal(true)
expect(filters.lt(1, 2)).to.equal(true)
expect(filters.lte(1, 1)).to.equal(true)
expect(filters.gt(2, 1)).to.equal(true)
expect(filters.gte(1, 1)).to.equal(true)
expect(filters.contains([1, 2], 1)).to.equal(true)
expect(filters.contains('hello', 'll')).to.equal(true)
...
function parse(date, format, culture) { return _localizers.date.parse(date, format, culture); }
...
var _localizers = __webpack_require__(17);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var dates = _extends({}, _dateArithmetic2.default, {
parse: function parse(date, format, culture) {
return _localizers.date.parse(date, format, culture);
},
format: function format(date, _format, culture) {
return _localizers.date.format(date, _format, culture);
},
monthsInYear: function monthsInYear(year) {
var months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
date = new Date(year, 0, 1);
...
function sameMonth(dateA, dateB) { return dates.eq(dateA, dateB, 'month'); }
n/a
seconds = function (date, val){ if (val === undefined) return date['get' + method]() date = new Date(date) date['set' + method](val) return date }
...
if (time == null) time = defaultDate || new Date();
if (date == null) date = defaultDate || new Date();
date = dates.startOf(date, 'day');
date = dates.hours(date, dates.hours(time));
date = dates.minutes(date, dates.minutes(time));
date = dates.seconds(date, dates.seconds(time));
return dates.milliseconds(date, dates.milliseconds(time));
},
sameMonth: function sameMonth(dateA, dateB) {
return dates.eq(dateA, dateB, 'month');
},
today: function today() {
return this.startOf(new Date(), 'day');
...
startOf = function (date, unit, firstOfWeek) { date = new Date(date) switch (unit) { case 'century': case 'decade': case 'year': date = dates.month(date, 0); case 'month': date = dates.date(date, 1); case 'week': case 'day': date = dates.hours(date, 0); case 'hours': date = dates.minutes(date, 0); case 'minutes': date = dates.seconds(date, 0); case 'seconds': date = dates.milliseconds(date, 0); } if (unit === DECADE) date = dates.subtract(date, dates.year(date) % 10, 'year') if (unit === CENTURY) date = dates.subtract(date, dates.year(date) % 100, 'year') if (unit === WEEK) date = dates.weekday(date, 0, firstOfWeek); return date }
...
_label: function _label() {
var _props2 = this.props,
culture = _props2.culture,
props = _objectWithoutProperties(_props2, ['culture']),
view = this.state.view,
dt = this.props.currentDate;
if (view === 'month') return _localizers.date.format(dt, format(props, 'header'), culture);else if (view
=== 'year') return _localizers.date.format(dt, format(props, 'year'), culture);else if (view === 'decade
') return _localizers.date.format(_dates2.default.startOf(dt, 'decade'),
format(props, 'decade'), culture);else if (view === 'century') return _localizers.date.format(_dates2.default
.startOf(dt, 'century'), format(props, 'century'), culture);
},
inRangeValue: function inRangeValue(_value) {
var value = dateOrNull(_value);
if (value === null) return value;
return _dates2.default.max(_dates2.default.min(value, this.props.max), this.props.min);
...
subtract = function (date, num, unit) { return dates.add(date, -num, unit) }
...
case 'minutes':
date = dates.seconds(date, 0);
case 'seconds':
date = dates.milliseconds(date, 0);
}
if (unit === DECADE)
date = dates.subtract(date, dates.year(date) % 10, 'year')
if (unit === CENTURY)
date = dates.subtract(date, dates.year(date) % 100, 'year')
if (unit === WEEK)
date = dates.weekday(date, 0, firstOfWeek);
...
function today() { return this.startOf(new Date(), 'day'); }
...
i++;
times.push({ date: start, label: _localizers.date.format(start, format(props), props.culture) });
start = _dates3.default.add(start, props.step || 30, 'minutes');
}
return times;
},
_dateValues: function _dateValues(props) {
var value = props.value || props.currentDate || _dates3.default.today(),
useDate = props.preserveDate,
min = props.min,
max = props.max,
start,
end;
//compare just the time regradless of whether they fall on the same day
...
function tomorrow() { return this.add(this.startOf(new Date(), 'day'), 1, 'day'); }
...
end;
//compare just the time regradless of whether they fall on the same day
if (!useDate) {
start = _dates3.default.startOf(_dates3.default.merge(new Date(), min, props.currentDate), 'minutes');
end = _dates3.default.startOf(_dates3.default.merge(new Date(), max, props.currentDate), 'minutes');
if (_dates3.default.lte(end, start) && _dates3.default.gt(max, min, 'day')) end = _dates3.default.tomorrow();
return {
min: start,
max: end
};
}
...
function visibleDays(date, culture) { var current = dates.firstVisibleDay(date, culture), last = dates.lastVisibleDay(date, culture), days = []; while (dates.lte(current, last, 'day')) { days.push(current); current = dates.add(current, 1, 'day'); } return days; }
...
var activeId = optionId((0, _widgetHelpers.instanceId)(this), this.props.focused);
this.ariaActiveDescendant(activeId, null);
},
render: function render() {
var _props = this.props,
focused = _props.focused,
culture = _props.culture,
month = _dates2.default.visibleDays(focused, culture),
rows = _3.default.chunk(month, 7);
return _react2.default.createElement(
_CalendarView2.default,
_3.default.omitOwnProps(this),
_react2.default.createElement(
'thead',
...
weekday = function (date, val, firstDay) { var weekday = (dates.day(date) + 7 - (firstDay || 0) ) % 7; return val === undefined ? weekday : dates.add(date, val - weekday, DAY); }
...
})
);
},
renderHeaders: function renderHeaders(week, format, culture) {
return week.map(function (date) {
return _react2.default.createElement(
'th',
{ key: 'header_' + _dates2.default.weekday(date, undefined, _localizers
.date.startOfWeek(culture)) },
_localizers.date.format(date, format, culture)
);
});
}
});
exports.default = MonthView;
...
year = function (date, val){ if (val === undefined) return date['get' + method]() date = new Date(date) date['set' + method](val) return date }
...
case DAY:
return dates.date(date, dates.date(date) + num)
case WEEK:
return dates.date(date, dates.date(date) + (7 * num))
case MONTH:
return monthMath(date, num)
case DECADE:
return dates.year(date, dates.year(date) + (num * 10))
case CENTURY:
return dates.year(date, dates.year(date) + (num * 100))
}
throw new TypeError('Invalid units: "' + unit + '"')
},
...
function yesterday() { return this.add(this.startOf(new Date(), 'day'), -1, 'day'); }
n/a
function contains(a, b) { return a.indexOf(b) !== -1; }
...
'use strict';
var canUseDOM = __webpack_require__(14);
var contains = (function () {
var root = canUseDOM && document.documentElement;
return root && root.contains ? function (context, node) {
return context.contains(node);
} : root && root.compareDocumentPosition ? function (context, node) {
return context === node || !!(context.compareDocumentPosition(node) & 16);
} : function (context, node) {
if (node) do {
if (node === context) return true;
} while (node = node.parentNode);
...
function endsWith(a, b) { var pos = a.length - b.length, lastIndex = a.indexOf(b, pos); return lastIndex !== -1 && lastIndex === pos; }
...
expect(filters.gt(2, 1)).to.equal(true)
expect(filters.gte(1, 1)).to.equal(true)
expect(filters.contains([1, 2], 1)).to.equal(true)
expect(filters.contains('hello', 'll')).to.equal(true)
expect(filters.startsWith('hello', 'hel')).to.equal(true)
expect(filters.endsWith('hello', 'llo')).to.equal(true)
})
})
describe('when validating Lists', function(){
it('should throw when methods are not implemented', function(){
var List = { prev: ()=>{}, next: ()=>{}, last: ()=>{}, first: 'wrong type' }
...
function eq(a, b) { return a === b; }
...
current = VIEW_OPTIONS.indexOf(this.state.view),
view = this.state.view,
val = this.inRangeValue(nextProps.value);
if (current < bottom) this.setState({ view: view = nextProps.initialView });else if (current > top) this.setState
({ view: view = nextProps.finalView });
//if the value changes reset views to the new one
if (!_dates2.default.eq(val, dateOrNull(this.props.value), VIEW_UNIT[view])) {
this.changeCurrentDate(val, nextProps.currentDate);
}
},
render: function render() {
var _this = this;
var _props = this.props,
...
function gt(a, b) { return a > b; }
...
var inRangeDate = this.inRangeValue(date ? new Date(date) : currentDate);
if (_dates2.default.eq(inRangeDate, dateOrNull(currentDate), VIEW_UNIT[this.state.view])) return;
(0, _widgetHelpers.notify)(this.props.onCurrentDateChange, inRangeDate);
},
select: function select(date) {
var view = this.props.initialView,
slideDir = view !== this.state.view || _dates2.default.gt(date, this.state.currentDate
) ? 'left' // move down to a the view
: 'right';
(0, _widgetHelpers.notify)(this.props.onChange, date);
if (this.isValidView(view) && _dates2.default.inRange(date, this.props.min, this.props.max, view)) {
this.focus();
...
function gte(a, b) { return a >= b; }
...
max: function(){
return new Date(Math.max.apply(Math, arguments))
},
inRange: function(day, min, max, unit){
unit = unit || 'day'
return (!min || dates.gte(day, min, unit))
&& (!max || dates.lte(day, max, unit))
},
milliseconds: createAccessor('Milliseconds'),
seconds: createAccessor('Seconds'),
minutes: createAccessor('Minutes'),
hours: createAccessor('Hours'),
...
function lt(a, b) { return a < b; }
...
if (this.isRtl() && OPPOSITE_DIRECTION[direction]) direction = OPPOSITE_DIRECTION[direction];
currentDate = _dates2.default.move(currentDate, this.props.min, this.props.max, view, direction);
if (!_dates2.default.eq(current, currentDate, unit)) {
e.preventDefault();
if (_dates2.default.gt(currentDate, current, view)) this.navigate(dir.RIGHT, currentDate);else if (_dates2.default.lt(currentDate, current, view)) this.navigate(dir.LEFT, currentDate);else this.changeCurrentDate
(currentDate);
}
}
}
(0, _widgetHelpers.notify)(this.props.onKeyDown, [e]);
},
_label: function _label() {
...
function lte(a, b) { return a <= b; }
...
return dates.endOf(endOfMonth, 'week', _localizers.date.startOfWeek(culture));
},
visibleDays: function visibleDays(date, culture) {
var current = dates.firstVisibleDay(date, culture),
last = dates.lastVisibleDay(date, culture),
days = [];
while (dates.lte(current, last, 'day')) {
days.push(current);
current = dates.add(current, 1, 'day');
}
return days;
},
move: function move(date, min, max, unit, direction) {
...
function neq(a, b) { return a !== b; }
...
})
describe('when using array filter helpers', function(){
it('should match correctly', function(){
expect(filters.eq(1, 1)).to.equal(true)
expect(filters.neq(2, 1)).to.equal(true)
expect(filters.lt(1, 2)).to.equal(true)
expect(filters.lte(1, 1)).to.equal(true)
expect(filters.gt(2, 1)).to.equal(true)
expect(filters.gte(1, 1)).to.equal(true)
expect(filters.contains([1, 2], 1)).to.equal(true)
expect(filters.contains('hello', 'll')).to.equal(true)
...
function startsWith(a, b) { return a.lastIndexOf(b, 0) === 0; }
...
function matcher(word, item, textField) {
if (!word) return function () {
return true;
};
word = word.toLowerCase();
return function (item) {
return _filter2.default.startsWith((0, _dataHelpers.dataText)(item, textField).toLowerCase
(), word);
};
}
module.exports = exports['default'];
/***/ },
/* 45 */
/***/ function(module, exports, __webpack_require__) {
...
function contains(item, values, valueField) { return Array.isArray(values) ? values.some(function (value) { return (0, _dataHelpers.valueMatcher)(item, value, valueField); }) : (0, _dataHelpers.valueMatcher)(item, values, valueField); }
...
'use strict';
var canUseDOM = __webpack_require__(14);
var contains = (function () {
var root = canUseDOM && document.documentElement;
return root && root.contains ? function (context, node) {
return context.contains(node);
} : root && root.compareDocumentPosition ? function (context, node) {
return context === node || !!(context.compareDocumentPosition(node) & 16);
} : function (context, node) {
if (node) do {
if (node === context) return true;
} while (node = node.parentNode);
...
function isDisabled(props) { return props.disabled === true || props.disabled === 'disabled'; }
n/a
function isDisabledItem(item, props) { return isDisabled(props) || contains(item, props.disabled, props.valueField); }
n/a
function isReadOnly(props) { return props.readOnly === true || props.readOnly === 'readOnly'; }
n/a
function isReadOnlyItem(item, props) { return isReadOnly(props) || contains(item, props.readOnly, props.valueField); }
n/a
function move(dir, item, props, list) { var isDisabledOrReadonly = function isDisabledOrReadonly(item) { return isDisabledItem(item, props) || isReadOnlyItem(item, props); }, stop = dir === 'next' ? list.last() : list.first(), next = list[dir](item); while (next !== stop && isDisabledOrReadonly(next)) { next = list[dir](next); }return isDisabledOrReadonly(next) ? item : next; }
...
data: [],
messages: {
emptyList: 'There are no items in this list'
}
};
},
componentDidMount: function componentDidMount() {
this.move();
},
componentDidUpdate: function componentDidUpdate() {
var _props = this.props,
data = _props.data,
focused = _props.focused,
idx = data.indexOf(focused),
activeId = optionId((0, _widgetHelpers.instanceId)(this), idx);
...
function decorate(target, key, desc) { if (desc.initializer) { (function () { var init = desc.initializer; desc.initializer = function () { return wrap(init()); }; })(); } else desc.value = wrap(desc.value); return desc; }
n/a
function decorate(target, key, desc) { if (desc.initializer) { (function () { var init = desc.initializer; desc.initializer = function () { return wrap(init()); }; })(); } else desc.value = wrap(desc.value); return desc; }
n/a
function setDate(spec) { (0, _invariant2.default)(typeof spec.format === 'function', 'date localizer `format(..)` must be a function'); (0, _invariant2.default)(typeof spec.parse === 'function', 'date localizer `parse(..)` must be a function'); (0, _invariant2.default)(typeof spec.firstOfWeek === 'function', 'date localizer `firstOfWeek(..)` must be a function'); checkFormats(REQUIRED_DATE_FORMATS, spec.formats); _dateLocalizer = { formats: spec.formats, propType: spec.propType || localePropType, startOfWeek: spec.firstOfWeek, format: function format(value, str, culture) { return _format(this, spec.format, value, str, culture); }, parse: function parse(value, culture) { var result = spec.parse.call(this, value, culture); (0, _invariant2.default)(result == null || result instanceof Date && !isNaN(result.getTime()), 'date localizer `parse(..)` must return a valid Date, null, or undefined'); return result; } }; }
n/a
function setNumber(_ref) { var _format2 = _ref.format, _parse = _ref.parse, _ref$decimalChar = _ref.decimalChar, decimalChar = _ref$decimalChar === undefined ? function () { return '.'; } : _ref$decimalChar, _ref$precision = _ref.precision, precision = _ref$precision === undefined ? function () { return null; } : _ref$precision, formats = _ref.formats, propType = _ref.propType; (0, _invariant2.default)(typeof _format2 === 'function', 'number localizer `format(..)` must be a function'); (0, _invariant2.default)(typeof _parse === 'function', 'number localizer `parse(..)` must be a function'); checkFormats(REQUIRED_NUMBER_FORMATS, formats); formats.editFormat = formats.editFormat || function (str) { return parseFloat(str); }; _numberLocalizer = { formats: formats, precision: precision, decimalChar: decimalChar, propType: propType || localePropType, format: function format(value, str, culture) { return _format(this, _format2, value, str, culture); }, parse: function parse(value, culture, format) { var result = _parse.call(this, value, culture, format); (0, _invariant2.default)(result == null || typeof result === 'number', 'number localizer `parse(..)` must return a number, null, or undefined'); return result; } }; }
n/a
accessor = function () { [native code] }
n/a
dateFormat = function () { [native code] }
n/a
disabled = function () { [native code] }
n/a
elementType = function () { [native code] }
...
})
describe('when using custom PropTypes', function(){
it('should concat names', function(){
var props = { type: 'span' }
expect(propTypes.elementType(props, 'type', 'component'))
.to.equal(null)
props.type = function(){}
expect(propTypes.elementType(props, 'type', 'component'))
.to.equal(null)
...
filter = function () { [native code] }
...
filter = _props.filter,
value = _props.value,
data = _props.data,
searchTerm = _props.searchTerm,
valueField = _props.valueField;
var processed = filter ? this.filter(data, searchTerm) : data,
initialIdx = (0, _dataHelpers.dataIndexOf)(data, value, valueField);
return {
filteredData: open && filter ? processed : null,
selectedItem: processed[initialIdx],
focusedItem: processed[initialIdx] || data[0]
};
...
message = function () { [native code] }
n/a
numberFormat = function () { [native code] }
n/a
readOnly = function () { [native code] }
n/a
ReplaceTransitionGroup = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
SlideTransition = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
ReplaceTransitionGroup = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { component: 'span', childFactory: function childFactory(a) { return a; }, onAnimating: _3.default.noop, onAnimate: _3.default.noop }; }
n/a
function _handleDoneEntering(enterkey) { var component = this.refs[enterkey]; if (component && component.componentDidEnter) component.componentDidEnter(); delete this.animatingKeys[enterkey]; if (key(this.props.children) !== enterkey) this.performLeave(enterkey); // This was removed before it had fully entered. Remove it. this._tryFinish(); }
...
performEnter: function performEnter(key) {
var component = this.refs[key];
if (!component) return;
this.animatingKeys[key] = true;
if (component.componentWillEnter) component.componentWillEnter(this._handleDoneEntering.bind(this, key));else this._handleDoneEntering(key);
},
_tryFinish: function _tryFinish() {
if (this.isTransitioning()) return;
if (this.isMounted()) (0, _style2.default)(_compat2.default.findDOMNode(this), { overflow: 'visible', height: '
;', width: '' });
...
function _handleDoneLeaving(leavekey) { var component = this.refs[leavekey]; if (component && component.componentDidLeave) component.componentDidLeave(); delete this.animatingKeys[leavekey]; if (key(this.props.children) === leavekey) this.performEnter(leavekey); // This entered again before it fully left. Add it again . else if (this.isMounted()) this.setState({ children: this.state.children.filter(function (c) { return key(c) !== leavekey; }) }); this._tryFinish(); }
...
performLeave: function performLeave(key) {
var component = this.refs[key];
if (!component) return;
this.animatingKeys[key] = true;
if (component.componentWillLeave) component.componentWillLeave(this._handleDoneLeaving.bind(this, key));else this._handleDoneLeaving(key);
},
_handleDoneLeaving: function _handleDoneLeaving(leavekey) {
var component = this.refs[leavekey];
if (component && component.componentDidLeave) component.componentDidLeave();
delete this.animatingKeys[leavekey];
...
function _tryFinish() { if (this.isTransitioning()) return; if (this.isMounted()) (0, _style2.default)(_compat2.default.findDOMNode(this), { overflow: 'visible', height: '', width: '' }); this.props.onAnimate(); }
...
if (component && component.componentDidEnter) component.componentDidEnter();
delete this.animatingKeys[enterkey];
if (key(this.props.children) !== enterkey) this.performLeave(enterkey); // This was removed before it had fully entered. Remove
it.
this._tryFinish();
},
performLeave: function performLeave(key) {
var component = this.refs[key];
if (!component) return;
this.animatingKeys[key] = true;
...
function componentDidUpdate() { var entering = this.entering, leaving = this.leaving, first = this.refs[key(entering) || key(leaving)], node = _compat2.default.findDOMNode(this), el = first && _compat2.default.findDOMNode(first); if (el) (0, _style2.default)(node, { overflow: 'hidden', height: (0, _height2.default)(el) + 'px', width: (0, _width2.default)(el) + 'px' }); this.props.onAnimating(); this.entering = null; this.leaving = null; if (entering) this.performEnter(key(entering)); if (leaving) this.performLeave(key(leaving)); }
n/a
function componentWillMount() { this.animatingKeys = {}; this.leaving = null; this.entering = null; }
n/a
function componentWillReceiveProps(nextProps) { var nextChild = getChild(nextProps.children), stack = this.state.children.slice(), next = stack[1], last = stack[0]; var isLastChild = last && key(last) === key(nextChild), isNextChild = next && key(next) === key(nextChild); //no children if (!last) { stack.push(nextChild); this.entering = nextChild; } else if (last && !next && !isLastChild) { //new child stack.push(nextChild); this.leaving = last; this.entering = nextChild; } else if (last && next && !isLastChild && !isNextChild) { // the child is not the current one, exit the current one, add the new one // - shift the stack down stack.shift(); stack.push(nextChild); this.leaving = next; this.entering = nextChild; } //new child that just needs to be re-rendered else if (isLastChild) stack.splice(0, 1, nextChild);else if (isNextChild) stack.splice(1, 1, nextChild); if (this.state.children[0] !== stack[0] || this.state.children[1] !== stack[1]) this.setState({ children: stack }); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function getInitialState() { return { children: _3.default.splat(this.props.children) }; }
n/a
function isTransitioning() { return !!Object.keys(this.animatingKeys).length; }
...
'div',
{
style: _extends({
display: display,
overflow: overflow,
height: height
}, style),
className: (0, _classnames2.default)(className, 'rw-popup-container', dropUp && 'rw-dropup'
;, this.isTransitioning() && 'rw-popup-animating')
},
this.renderChildren()
);
},
renderChildren: function renderChildren() {
if (!this.props.children) return _react2.default.createElement('span', { className: 'rw-popup rw-widget'
; });
...
function performEnter(key) { var component = this.refs[key]; if (!component) return; this.animatingKeys[key] = true; if (component.componentWillEnter) component.componentWillEnter(this._handleDoneEntering.bind(this, key));else this._handleDoneEntering (key); }
...
});
this.props.onAnimating();
this.entering = null;
this.leaving = null;
if (entering) this.performEnter(key(entering));
if (leaving) this.performLeave(key(leaving));
},
performEnter: function performEnter(key) {
var component = this.refs[key];
if (!component) return;
...
function performLeave(key) { var component = this.refs[key]; if (!component) return; this.animatingKeys[key] = true; if (component.componentWillLeave) component.componentWillLeave(this._handleDoneLeaving.bind(this, key));else this._handleDoneLeaving (key); }
...
this.props.onAnimating();
this.entering = null;
this.leaving = null;
if (entering) this.performEnter(key(entering));
if (leaving) this.performLeave(key(leaving));
},
performEnter: function performEnter(key) {
var component = this.refs[key];
if (!component) return;
this.animatingKeys[key] = true;
...
function render() { var _this = this; var Component = this.props.component; return _react2.default.createElement( Component, _3.default.omitOwnProps(this), this.state.children.map(function (c) { return _this.props.childFactory(c, key(c)); }) ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function _handleDoneEntering(enterkey) { var component = this.refs[enterkey]; if (component && component.componentDidEnter) component.componentDidEnter(); delete this.animatingKeys[enterkey]; if (key(this.props.children) !== enterkey) this.performLeave(enterkey); // This was removed before it had fully entered. Remove it. this._tryFinish(); }
...
performEnter: function performEnter(key) {
var component = this.refs[key];
if (!component) return;
this.animatingKeys[key] = true;
if (component.componentWillEnter) component.componentWillEnter(this._handleDoneEntering.bind(this, key));else this._handleDoneEntering(key);
},
_tryFinish: function _tryFinish() {
if (this.isTransitioning()) return;
if (this.isMounted()) (0, _style2.default)(_compat2.default.findDOMNode(this), { overflow: 'visible', height: '
;', width: '' });
...
function _handleDoneLeaving(leavekey) { var component = this.refs[leavekey]; if (component && component.componentDidLeave) component.componentDidLeave(); delete this.animatingKeys[leavekey]; if (key(this.props.children) === leavekey) this.performEnter(leavekey); // This entered again before it fully left. Add it again . else if (this.isMounted()) this.setState({ children: this.state.children.filter(function (c) { return key(c) !== leavekey; }) }); this._tryFinish(); }
...
performLeave: function performLeave(key) {
var component = this.refs[key];
if (!component) return;
this.animatingKeys[key] = true;
if (component.componentWillLeave) component.componentWillLeave(this._handleDoneLeaving.bind(this, key));else this._handleDoneLeaving(key);
},
_handleDoneLeaving: function _handleDoneLeaving(leavekey) {
var component = this.refs[leavekey];
if (component && component.componentDidLeave) component.componentDidLeave();
delete this.animatingKeys[leavekey];
...
function _tryFinish() { if (this.isTransitioning()) return; if (this.isMounted()) (0, _style2.default)(_compat2.default.findDOMNode(this), { overflow: 'visible', height: '', width: '' }); this.props.onAnimate(); }
...
if (component && component.componentDidEnter) component.componentDidEnter();
delete this.animatingKeys[enterkey];
if (key(this.props.children) !== enterkey) this.performLeave(enterkey); // This was removed before it had fully entered. Remove
it.
this._tryFinish();
},
performLeave: function performLeave(key) {
var component = this.refs[key];
if (!component) return;
this.animatingKeys[key] = true;
...
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function isTransitioning() { return !!Object.keys(this.animatingKeys).length; }
...
'div',
{
style: _extends({
display: display,
overflow: overflow,
height: height
}, style),
className: (0, _classnames2.default)(className, 'rw-popup-container', dropUp && 'rw-dropup'
;, this.isTransitioning() && 'rw-popup-animating')
},
this.renderChildren()
);
},
renderChildren: function renderChildren() {
if (!this.props.children) return _react2.default.createElement('span', { className: 'rw-popup rw-widget'
; });
...
function performEnter(key) { var component = this.refs[key]; if (!component) return; this.animatingKeys[key] = true; if (component.componentWillEnter) component.componentWillEnter(this._handleDoneEntering.bind(this, key));else this._handleDoneEntering (key); }
...
});
this.props.onAnimating();
this.entering = null;
this.leaving = null;
if (entering) this.performEnter(key(entering));
if (leaving) this.performLeave(key(leaving));
},
performEnter: function performEnter(key) {
var component = this.refs[key];
if (!component) return;
...
function performLeave(key) { var component = this.refs[key]; if (!component) return; this.animatingKeys[key] = true; if (component.componentWillLeave) component.componentWillLeave(this._handleDoneLeaving.bind(this, key));else this._handleDoneLeaving (key); }
...
this.props.onAnimating();
this.entering = null;
this.leaving = null;
if (entering) this.performEnter(key(entering));
if (leaving) this.performLeave(key(leaving));
},
performEnter: function performEnter(key) {
var component = this.refs[key];
if (!component) return;
this.animatingKeys[key] = true;
...
SlideTransition = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
function getDefaultProps() { return { direction: 'left', duration: 250 }; }
n/a
function _wrapChild(child, ref) { return _react2.default.createElement( SlideChildGroup, { key: child.key, ref: ref, direction: this.props.direction, duration: this.props.duration }, child ); }
n/a
constructor = function (props, context, updater) { // This constructor is overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if (process.env.NODE_ENV !== 'production') { process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly . Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; } // Wire up auto-binding if (this.__reactAutoBindMap) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if (process.env.NODE_ENV !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '% s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; this.state = initialState; }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function render() { var _props = this.props, style = _props.style, children = _props.children; style = _extends({}, style, { position: 'relative', overflow: 'hidden' }); return _react2.default.createElement( _ReplaceTransitionGroup2.default, _extends({}, _3.default.omitOwnProps(this), { ref: 'container', component: 'div', childFactory: this._wrapChild, style: style }), children ); }
...
})
//this.setState({ dropUp: !this.state.dropUp })
}
})
React.render(<App/>, document.body);
function generateList(limit = 100){
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
...
function _wrapChild(child, ref) { return _react2.default.createElement( SlideChildGroup, { key: child.key, ref: ref, direction: this.props.direction, duration: this.props.duration }, child ); }
n/a
getDOMNode = function () { process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + ' ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; this.constructor[didWarnKey] = true; return findDOMNode(this); }
n/a
function instanceId(component) { var suffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; component.__id || (component.__id = (0, _.uniqueId)('rw_')); return (component.props.id || component.__id) + suffix; }
n/a
function isFirstFocusedRender(component) { return component._firstFocus || component.state.focused && (component._firstFocus = true); }
n/a
function notify(handler, args) { handler && handler.apply(null, [].concat(args)); }
n/a