From 084785ce54066adc1477a7ccbd4188292f77257d Mon Sep 17 00:00:00 2001 From: Esther Kim Date: Wed, 24 Oct 2018 13:32:06 -0400 Subject: [PATCH 1/4] [fixed] #42: add proper ARIA roles to elements, update test snapshot, update README, update example apps --- README.md | 3 ++- examples/async-data/app.js | 3 ++- examples/custom-menu/app.js | 5 +++-- examples/managed-menu-visibility/app.js | 3 ++- examples/static-data/app.js | 3 ++- lib/Autocomplete.js | 10 +++++----- lib/__tests__/__snapshots__/Autocomplete-test.js.snap | 8 ++++---- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e78523da..cb4d0480 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,8 @@ The value to display in the input field Default value: `{}` Props that are applied to the element which wraps the `` and -dropdown menu elements rendered by `Autocomplete`. +dropdown menu elements rendered by `Autocomplete`. This is in addition to +the following properties set by `Autocomplete`: role, aria-expanded. #### `wrapperStyle: Object` (optional) Default value: diff --git a/examples/async-data/app.js b/examples/async-data/app.js index 93a0fc76..f75f4458 100644 --- a/examples/async-data/app.js +++ b/examples/async-data/app.js @@ -43,12 +43,13 @@ class App extends React.Component { }) }} renderMenu={children => ( -
+
{children}
)} renderItem={(item, isHighlighted) => (
{item.name}
diff --git a/examples/custom-menu/app.js b/examples/custom-menu/app.js index 242fc244..9fefd166 100644 --- a/examples/custom-menu/app.js +++ b/examples/custom-menu/app.js @@ -45,14 +45,15 @@ class App extends React.Component { key={item.header} >{item.header}
:
{item.name}
)} renderMenu={(items, value) => ( -
+
{value === '' ? ( -
Type of the name of a United State
+
Type the name of a United State
) : this.state.loading ? (
Loading...
) : items.length === 0 ? ( diff --git a/examples/managed-menu-visibility/app.js b/examples/managed-menu-visibility/app.js index 1f21f895..2c86b78b 100644 --- a/examples/managed-menu-visibility/app.js +++ b/examples/managed-menu-visibility/app.js @@ -43,6 +43,7 @@ class App extends Component { onChange={e => this.setState({ value: e.target.value })} renderItem={(item, isHighlighted) => (
@@ -50,7 +51,7 @@ class App extends Component {
)} renderMenu={children => -
+
{children}
} diff --git a/examples/static-data/app.js b/examples/static-data/app.js index adb5e3ea..d2a6f651 100644 --- a/examples/static-data/app.js +++ b/examples/static-data/app.js @@ -25,12 +25,13 @@ class App extends React.Component { onChange={(event, value) => this.setState({ value })} onSelect={value => this.setState({ value })} renderMenu={children => ( -
+
{children}
)} renderItem={(item, isHighlighted) => (
{item.name}
diff --git a/lib/Autocomplete.js b/lib/Autocomplete.js index 1658c8bb..b06637ce 100644 --- a/lib/Autocomplete.js +++ b/lib/Autocomplete.js @@ -123,7 +123,8 @@ class Autocomplete extends React.Component { inputProps: PropTypes.object, /** * Props that are applied to the element which wraps the `` and - * dropdown menu elements rendered by `Autocomplete`. + * dropdown menu elements rendered by `Autocomplete`. This is in addition to + * the following properties set by `Autocomplete`: role, aria-expanded. */ wrapperProps: PropTypes.object, /** @@ -173,7 +174,7 @@ class Autocomplete extends React.Component { onSelect() {}, isItemSelectable() { return true }, renderMenu(items, value, style) { - return
+ return
}, menuStyle: { borderRadius: '3px', @@ -571,12 +572,11 @@ class Autocomplete extends React.Component { const { inputProps } = this.props const open = this.isOpen() return ( -
+
{this.props.renderInput({ ...inputProps, - role: 'combobox', + role: 'textbox', 'aria-autocomplete': 'list', - 'aria-expanded': open, autoComplete: 'off', ref: this.exposeAPI, onFocus: this.handleInputFocus, diff --git a/lib/__tests__/__snapshots__/Autocomplete-test.js.snap b/lib/__tests__/__snapshots__/Autocomplete-test.js.snap index 0eeecd50..0eabda33 100644 --- a/lib/__tests__/__snapshots__/Autocomplete-test.js.snap +++ b/lib/__tests__/__snapshots__/Autocomplete-test.js.snap @@ -3,7 +3,6 @@ exports[`Autocomplete.props.renderInput should be invoked in \`render\` to create the element 1`] = ` Object { "aria-autocomplete": "list", - "aria-expanded": false, "autoComplete": "off", "foo": "bar", "onBlur": [Function], @@ -12,13 +11,15 @@ Object { "onFocus": [Function], "onKeyDown": [Function], "ref": [Function], - "role": "combobox", + "role": "textbox", "value": "pants", } `; exports[`Autocomplete.props.renderInput should be invoked in \`render\` to create the element 2`] = `
From 4cd97f10450e298cc4d8381c3c21b882f18be026 Mon Sep 17 00:00:00 2001 From: Esther Kim Date: Wed, 24 Oct 2018 14:20:05 -0400 Subject: [PATCH 2/4] [fixed] #42: textbox role is not valid on input element of type text --- lib/Autocomplete.js | 1 - lib/__tests__/__snapshots__/Autocomplete-test.js.snap | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib/Autocomplete.js b/lib/Autocomplete.js index b06637ce..92ae6ed0 100644 --- a/lib/Autocomplete.js +++ b/lib/Autocomplete.js @@ -575,7 +575,6 @@ class Autocomplete extends React.Component {
{this.props.renderInput({ ...inputProps, - role: 'textbox', 'aria-autocomplete': 'list', autoComplete: 'off', ref: this.exposeAPI, diff --git a/lib/__tests__/__snapshots__/Autocomplete-test.js.snap b/lib/__tests__/__snapshots__/Autocomplete-test.js.snap index 0eabda33..56e2b7c4 100644 --- a/lib/__tests__/__snapshots__/Autocomplete-test.js.snap +++ b/lib/__tests__/__snapshots__/Autocomplete-test.js.snap @@ -11,7 +11,6 @@ Object { "onFocus": [Function], "onKeyDown": [Function], "ref": [Function], - "role": "textbox", "value": "pants", } `; @@ -36,7 +35,6 @@ exports[`Autocomplete.props.renderInput should be invoked in \`render\` to creat onClick={[Function]} onFocus={[Function]} onKeyDown={[Function]} - role="textbox" value="pants" />
From c8afcf18a28f1a9105952992cbd1a93f3b99acd0 Mon Sep 17 00:00:00 2001 From: ekim-novus <44381166+ekim-novus@users.noreply.github.com> Date: Fri, 26 Oct 2018 13:40:40 -0400 Subject: [PATCH 3/4] Update gitignore to get build files --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1b8c616b..41c2d120 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -/build/ -/dist/ /examples/__build__ /node_modules/ /coverage/ From d738948eb87b07a1ee404845e12650ecb0add372 Mon Sep 17 00:00:00 2001 From: Esther Kim Date: Fri, 26 Oct 2018 13:50:20 -0400 Subject: [PATCH 4/4] issue42: add build files to pull from when installing from github --- build/lib/Autocomplete.js | 651 +++++++++ build/lib/index.js | 3 + dist/react-autocomplete.js | 2087 ++++++++++++++++++++++++++++ dist/react-autocomplete.js.map | 32 + dist/react-autocomplete.min.js | 2 + dist/react-autocomplete.min.js.map | 1 + 6 files changed, 2776 insertions(+) create mode 100644 build/lib/Autocomplete.js create mode 100644 build/lib/index.js create mode 100644 dist/react-autocomplete.js create mode 100644 dist/react-autocomplete.js.map create mode 100644 dist/react-autocomplete.min.js create mode 100644 dist/react-autocomplete.min.js.map diff --git a/build/lib/Autocomplete.js b/build/lib/Autocomplete.js new file mode 100644 index 00000000..a70d5db4 --- /dev/null +++ b/build/lib/Autocomplete.js @@ -0,0 +1,651 @@ +'use strict'; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var React = require('react'); +var PropTypes = require('prop-types'); + +var _require = require('react-dom'), + findDOMNode = _require.findDOMNode; + +var scrollIntoView = require('dom-scroll-into-view'); + +var IMPERATIVE_API = ['blur', 'checkValidity', 'click', 'focus', 'select', 'setCustomValidity', 'setSelectionRange', 'setRangeText']; + +function getScrollOffset() { + return { + x: window.pageXOffset !== undefined ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft, + y: window.pageYOffset !== undefined ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop + }; +} + +var Autocomplete = function (_React$Component) { + _inherits(Autocomplete, _React$Component); + + function Autocomplete(props) { + _classCallCheck(this, Autocomplete); + + var _this = _possibleConstructorReturn(this, (Autocomplete.__proto__ || Object.getPrototypeOf(Autocomplete)).call(this, props)); + + _this.state = { + isOpen: false, + highlightedIndex: null + }; + _this._debugStates = []; + _this.ensureHighlightedIndex = _this.ensureHighlightedIndex.bind(_this); + _this.exposeAPI = _this.exposeAPI.bind(_this); + _this.handleInputFocus = _this.handleInputFocus.bind(_this); + _this.handleInputBlur = _this.handleInputBlur.bind(_this); + _this.handleChange = _this.handleChange.bind(_this); + _this.handleKeyDown = _this.handleKeyDown.bind(_this); + _this.handleInputClick = _this.handleInputClick.bind(_this); + _this.maybeAutoCompleteText = _this.maybeAutoCompleteText.bind(_this); + return _this; + } + + _createClass(Autocomplete, [{ + key: 'componentWillMount', + value: function componentWillMount() { + // this.refs is frozen, so we need to assign a new object to it + this.refs = {}; + this._ignoreBlur = false; + this._ignoreFocus = false; + this._scrollOffset = null; + this._scrollTimer = null; + } + }, { + key: 'componentWillUnmount', + value: function componentWillUnmount() { + clearTimeout(this._scrollTimer); + this._scrollTimer = null; + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(nextProps) { + if (this.state.highlightedIndex !== null) { + this.setState(this.ensureHighlightedIndex); + } + if (nextProps.autoHighlight && (this.props.value !== nextProps.value || this.state.highlightedIndex === null)) { + this.setState(this.maybeAutoCompleteText); + } + } + }, { + key: 'componentDidMount', + value: function componentDidMount() { + if (this.isOpen()) { + this.setMenuPositions(); + } + } + }, { + key: 'componentDidUpdate', + value: function componentDidUpdate(prevProps, prevState) { + if (this.state.isOpen && !prevState.isOpen || 'open' in this.props && this.props.open && !prevProps.open) this.setMenuPositions(); + + this.maybeScrollItemIntoView(); + if (prevState.isOpen !== this.state.isOpen) { + this.props.onMenuVisibilityChange(this.state.isOpen); + } + } + }, { + key: 'exposeAPI', + value: function exposeAPI(el) { + var _this2 = this; + + this.refs.input = el; + IMPERATIVE_API.forEach(function (ev) { + return _this2[ev] = el && el[ev] && el[ev].bind(el); + }); + } + }, { + key: 'maybeScrollItemIntoView', + value: function maybeScrollItemIntoView() { + if (this.isOpen() && this.state.highlightedIndex !== null) { + var itemNode = this.refs['item-' + this.state.highlightedIndex]; + var menuNode = this.refs.menu; + scrollIntoView(findDOMNode(itemNode), findDOMNode(menuNode), { onlyScrollIfNeeded: true }); + } + } + }, { + key: 'handleKeyDown', + value: function handleKeyDown(event) { + if (Autocomplete.keyDownHandlers[event.key]) Autocomplete.keyDownHandlers[event.key].call(this, event);else if (!this.isOpen()) { + this.setState({ + isOpen: true + }); + } + } + }, { + key: 'handleChange', + value: function handleChange(event) { + this.props.onChange(event, event.target.value); + } + }, { + key: 'getFilteredItems', + value: function getFilteredItems(props) { + var items = props.items; + + if (props.shouldItemRender) { + items = items.filter(function (item) { + return props.shouldItemRender(item, props.value); + }); + } + + if (props.sortItems) { + items.sort(function (a, b) { + return props.sortItems(a, b, props.value); + }); + } + + return items; + } + }, { + key: 'maybeAutoCompleteText', + value: function maybeAutoCompleteText(state, props) { + var highlightedIndex = state.highlightedIndex; + var value = props.value, + getItemValue = props.getItemValue; + + var index = highlightedIndex === null ? 0 : highlightedIndex; + var items = this.getFilteredItems(props); + for (var i = 0; i < items.length; i++) { + if (props.isItemSelectable(items[index])) break; + index = (index + 1) % items.length; + } + var matchedItem = items[index] && props.isItemSelectable(items[index]) ? items[index] : null; + if (value !== '' && matchedItem) { + var itemValue = getItemValue(matchedItem); + var itemValueDoesMatch = itemValue.toLowerCase().indexOf(value.toLowerCase()) === 0; + if (itemValueDoesMatch) { + return { highlightedIndex: index }; + } + } + return { highlightedIndex: null }; + } + }, { + key: 'ensureHighlightedIndex', + value: function ensureHighlightedIndex(state, props) { + if (state.highlightedIndex >= this.getFilteredItems(props).length) { + return { highlightedIndex: null }; + } + } + }, { + key: 'setMenuPositions', + value: function setMenuPositions() { + var node = this.refs.input; + var rect = node.getBoundingClientRect(); + var computedStyle = global.window.getComputedStyle(node); + var marginBottom = parseInt(computedStyle.marginBottom, 10) || 0; + var marginLeft = parseInt(computedStyle.marginLeft, 10) || 0; + var marginRight = parseInt(computedStyle.marginRight, 10) || 0; + this.setState({ + menuTop: rect.bottom + marginBottom, + menuLeft: rect.left + marginLeft, + menuWidth: rect.width + marginLeft + marginRight + }); + } + }, { + key: 'highlightItemFromMouse', + value: function highlightItemFromMouse(index) { + this.setState({ highlightedIndex: index }); + } + }, { + key: 'selectItemFromMouse', + value: function selectItemFromMouse(item) { + var _this3 = this; + + var value = this.props.getItemValue(item); + // The menu will de-render before a mouseLeave event + // happens. Clear the flag to release control over focus + this.setIgnoreBlur(false); + this.setState({ + isOpen: false, + highlightedIndex: null + }, function () { + _this3.props.onSelect(value, item); + }); + } + }, { + key: 'setIgnoreBlur', + value: function setIgnoreBlur(ignore) { + this._ignoreBlur = ignore; + } + }, { + key: 'renderMenu', + value: function renderMenu() { + var _this4 = this; + + var items = this.getFilteredItems(this.props).map(function (item, index) { + var element = _this4.props.renderItem(item, _this4.state.highlightedIndex === index, { cursor: 'default' }); + return React.cloneElement(element, { + onMouseEnter: _this4.props.isItemSelectable(item) ? function () { + return _this4.highlightItemFromMouse(index); + } : null, + onClick: _this4.props.isItemSelectable(item) ? function () { + return _this4.selectItemFromMouse(item); + } : null, + ref: function ref(e) { + return _this4.refs['item-' + index] = e; + } + }); + }); + var style = { + left: this.state.menuLeft, + top: this.state.menuTop, + minWidth: this.state.menuWidth + }; + var menu = this.props.renderMenu(items, this.props.value, style); + return React.cloneElement(menu, { + ref: function ref(e) { + return _this4.refs.menu = e; + }, + // Ignore blur to prevent menu from de-rendering before we can process click + onTouchStart: function onTouchStart() { + return _this4.setIgnoreBlur(true); + }, + onMouseEnter: function onMouseEnter() { + return _this4.setIgnoreBlur(true); + }, + onMouseLeave: function onMouseLeave() { + return _this4.setIgnoreBlur(false); + } + }); + } + }, { + key: 'handleInputBlur', + value: function handleInputBlur(event) { + var _this5 = this; + + if (this._ignoreBlur) { + this._ignoreFocus = true; + this._scrollOffset = getScrollOffset(); + this.refs.input.focus(); + return; + } + var setStateCallback = void 0; + var highlightedIndex = this.state.highlightedIndex; + + if (this.props.selectOnBlur && highlightedIndex !== null) { + var items = this.getFilteredItems(this.props); + var item = items[highlightedIndex]; + var value = this.props.getItemValue(item); + setStateCallback = function setStateCallback() { + return _this5.props.onSelect(value, item); + }; + } + this.setState({ + isOpen: false, + highlightedIndex: null + }, setStateCallback); + var onBlur = this.props.inputProps.onBlur; + + if (onBlur) { + onBlur(event); + } + } + }, { + key: 'handleInputFocus', + value: function handleInputFocus(event) { + var _this6 = this; + + if (this._ignoreFocus) { + this._ignoreFocus = false; + var _scrollOffset = this._scrollOffset, + x = _scrollOffset.x, + y = _scrollOffset.y; + + this._scrollOffset = null; + // Focus will cause the browser to scroll the into view. + // This can cause the mouse coords to change, which in turn + // could cause a new highlight to happen, cancelling the click + // event (when selecting with the mouse) + window.scrollTo(x, y); + // Some browsers wait until all focus event handlers have been + // processed before scrolling the into view, so let's + // scroll again on the next tick to ensure we're back to where + // the user was before focus was lost. We could do the deferred + // scroll only, but that causes a jarring split second jump in + // some browsers that scroll before the focus event handlers + // are triggered. + clearTimeout(this._scrollTimer); + this._scrollTimer = setTimeout(function () { + _this6._scrollTimer = null; + window.scrollTo(x, y); + }, 0); + return; + } + this.setState({ isOpen: true }); + var onFocus = this.props.inputProps.onFocus; + + if (onFocus) { + onFocus(event); + } + } + }, { + key: 'isInputFocused', + value: function isInputFocused() { + var el = this.refs.input; + return el.ownerDocument && el === el.ownerDocument.activeElement; + } + }, { + key: 'handleInputClick', + value: function handleInputClick() { + // Input will not be focused if it's disabled + if (this.isInputFocused() && !this.isOpen()) this.setState({ isOpen: true }); + } + }, { + key: 'composeEventHandlers', + value: function composeEventHandlers(internal, external) { + return external ? function (e) { + internal(e);external(e); + } : internal; + } + }, { + key: 'isOpen', + value: function isOpen() { + return 'open' in this.props ? this.props.open : this.state.isOpen; + } + }, { + key: 'render', + value: function render() { + if (this.props.debug) { + // you don't like it, you love it + this._debugStates.push({ + id: this._debugStates.length, + state: this.state + }); + } + + var inputProps = this.props.inputProps; + + var open = this.isOpen(); + return React.createElement( + 'div', + _extends({ style: _extends({}, this.props.wrapperStyle) }, this.props.wrapperProps, { role: 'combobox', 'aria-expanded': open }), + this.props.renderInput(_extends({}, inputProps, { + 'aria-autocomplete': 'list', + autoComplete: 'off', + ref: this.exposeAPI, + onFocus: this.handleInputFocus, + onBlur: this.handleInputBlur, + onChange: this.handleChange, + onKeyDown: this.composeEventHandlers(this.handleKeyDown, inputProps.onKeyDown), + onClick: this.composeEventHandlers(this.handleInputClick, inputProps.onClick), + value: this.props.value + })), + open && this.renderMenu(), + this.props.debug && React.createElement( + 'pre', + { style: { marginLeft: 300 } }, + JSON.stringify(this._debugStates.slice(Math.max(0, this._debugStates.length - 5), this._debugStates.length), null, 2) + ) + ); + } + }]); + + return Autocomplete; +}(React.Component); + +Autocomplete.propTypes = { + /** + * The items to display in the dropdown menu + */ + items: PropTypes.array.isRequired, + /** + * The value to display in the input field + */ + value: PropTypes.any, + /** + * Arguments: `event: Event, value: String` + * + * Invoked every time the user changes the input's value. + */ + onChange: PropTypes.func, + /** + * Arguments: `value: String, item: Any` + * + * Invoked when the user selects an item from the dropdown menu. + */ + onSelect: PropTypes.func, + /** + * Arguments: `item: Any, value: String` + * + * Invoked for each entry in `items` and its return value is used to + * determine whether or not it should be displayed in the dropdown menu. + * By default all items are always rendered. + */ + shouldItemRender: PropTypes.func, + /** + * Arguments: `item: Any` + * + * Invoked when attempting to select an item. The return value is used to + * determine whether the item should be selectable or not. + * By default all items are selectable. + */ + isItemSelectable: PropTypes.func, + /** + * Arguments: `itemA: Any, itemB: Any, value: String` + * + * The function which is used to sort `items` before display. + */ + sortItems: PropTypes.func, + /** + * Arguments: `item: Any` + * + * Used to read the display value from each entry in `items`. + */ + getItemValue: PropTypes.func.isRequired, + /** + * Arguments: `item: Any, isHighlighted: Boolean, styles: Object` + * + * Invoked for each entry in `items` that also passes `shouldItemRender` to + * generate the render tree for each item in the dropdown menu. `styles` is + * an optional set of styles that can be applied to improve the look/feel + * of the items in the dropdown menu. + */ + renderItem: PropTypes.func.isRequired, + /** + * Arguments: `items: Array, value: String, styles: Object` + * + * Invoked to generate the render tree for the dropdown menu. Ensure the + * returned tree includes every entry in `items` or else the highlight order + * and keyboard navigation logic will break. `styles` will contain + * { top, left, minWidth } which are the coordinates of the top-left corner + * and the width of the dropdown menu. + */ + renderMenu: PropTypes.func, + /** + * Styles that are applied to the dropdown menu in the default `renderMenu` + * implementation. If you override `renderMenu` and you want to use + * `menuStyle` you must manually apply them (`this.props.menuStyle`). + */ + menuStyle: PropTypes.object, + /** + * Arguments: `props: Object` + * + * Invoked to generate the input element. The `props` argument is the result + * of merging `props.inputProps` with a selection of props that are required + * both for functionality and accessibility. At the very least you need to + * apply `props.ref` and all `props.on` event handlers. Failing to do + * this will cause `Autocomplete` to behave unexpectedly. + */ + renderInput: PropTypes.func, + /** + * Props passed to `props.renderInput`. By default these props will be + * applied to the `` element rendered by `Autocomplete`, unless you + * have specified a custom value for `props.renderInput`. Any properties + * supported by `HTMLInputElement` can be specified, apart from the + * following which are set by `Autocomplete`: value, autoComplete, role, + * aria-autocomplete. `inputProps` is commonly used for (but not limited to) + * placeholder, event handlers (onFocus, onBlur, etc.), autoFocus, etc.. + */ + inputProps: PropTypes.object, + /** + * Props that are applied to the element which wraps the `` and + * dropdown menu elements rendered by `Autocomplete`. This is in addition to + * the following properties set by `Autocomplete`: role, aria-expanded. + */ + wrapperProps: PropTypes.object, + /** + * This is a shorthand for `wrapperProps={{ style: }}`. + * Note that `wrapperStyle` is applied before `wrapperProps`, so the latter + * will win if it contains a `style` entry. + */ + wrapperStyle: PropTypes.object, + /** + * Whether or not to automatically highlight the top match in the dropdown + * menu. + */ + autoHighlight: PropTypes.bool, + /** + * Whether or not to automatically select the highlighted item when the + * `` loses focus. + */ + selectOnBlur: PropTypes.bool, + /** + * Arguments: `isOpen: Boolean` + * + * Invoked every time the dropdown menu's visibility changes (i.e. every + * time it is displayed/hidden). + */ + onMenuVisibilityChange: PropTypes.func, + /** + * Used to override the internal logic which displays/hides the dropdown + * menu. This is useful if you want to force a certain state based on your + * UX/business logic. Use it together with `onMenuVisibilityChange` for + * fine-grained control over the dropdown menu dynamics. + */ + open: PropTypes.bool, + debug: PropTypes.bool +}; +Autocomplete.defaultProps = { + value: '', + wrapperProps: {}, + wrapperStyle: { + display: 'inline-block' + }, + inputProps: {}, + renderInput: function renderInput(props) { + return React.createElement('input', props); + }, + onChange: function onChange() {}, + onSelect: function onSelect() {}, + isItemSelectable: function isItemSelectable() { + return true; + }, + renderMenu: function renderMenu(items, value, style) { + return React.createElement('div', { role: 'listbox', style: _extends({}, style, this.menuStyle), children: items }); + }, + + menuStyle: { + borderRadius: '3px', + boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)', + background: 'rgba(255, 255, 255, 0.9)', + padding: '2px 0', + fontSize: '90%', + position: 'fixed', + overflow: 'auto', + maxHeight: '50%' // TODO: don't cheat, let it flow to the bottom + }, + autoHighlight: true, + selectOnBlur: false, + onMenuVisibilityChange: function onMenuVisibilityChange() {} +}; +Autocomplete.keyDownHandlers = { + ArrowDown: function ArrowDown(event) { + event.preventDefault(); + var items = this.getFilteredItems(this.props); + if (!items.length) return; + var highlightedIndex = this.state.highlightedIndex; + + var index = highlightedIndex === null ? -1 : highlightedIndex; + for (var i = 0; i < items.length; i++) { + var p = (index + i + 1) % items.length; + if (this.props.isItemSelectable(items[p])) { + index = p; + break; + } + } + if (index > -1 && index !== highlightedIndex) { + this.setState({ + highlightedIndex: index, + isOpen: true + }); + } + }, + ArrowUp: function ArrowUp(event) { + event.preventDefault(); + var items = this.getFilteredItems(this.props); + if (!items.length) return; + var highlightedIndex = this.state.highlightedIndex; + + var index = highlightedIndex === null ? items.length : highlightedIndex; + for (var i = 0; i < items.length; i++) { + var p = (index - (1 + i) + items.length) % items.length; + if (this.props.isItemSelectable(items[p])) { + index = p; + break; + } + } + if (index !== items.length) { + this.setState({ + highlightedIndex: index, + isOpen: true + }); + } + }, + Enter: function Enter(event) { + var _this7 = this; + + // Key code 229 is used for selecting items from character selectors (Pinyin, Kana, etc) + if (event.keyCode !== 13) return; + // In case the user is currently hovering over the menu + this.setIgnoreBlur(false); + if (!this.isOpen()) { + // menu is closed so there is no selection to accept -> do nothing + return; + } else if (this.state.highlightedIndex == null) { + // input has focus but no menu item is selected + enter is hit -> close the menu, highlight whatever's in input + this.setState({ + isOpen: false + }, function () { + _this7.refs.input.select(); + }); + } else { + // text entered + menu item has been highlighted + enter is hit -> update value to that of selected menu item, close the menu + event.preventDefault(); + var item = this.getFilteredItems(this.props)[this.state.highlightedIndex]; + var value = this.props.getItemValue(item); + this.setState({ + isOpen: false, + highlightedIndex: null + }, function () { + //this.refs.input.focus() // TODO: file issue + _this7.refs.input.setSelectionRange(value.length, value.length); + _this7.props.onSelect(value, item); + }); + } + }, + Escape: function Escape() { + // In case the user is currently hovering over the menu + this.setIgnoreBlur(false); + this.setState({ + highlightedIndex: null, + isOpen: false + }); + }, + Tab: function Tab() { + // In case the user is currently hovering over the menu + this.setIgnoreBlur(false); + } +}; + + +module.exports = Autocomplete; \ No newline at end of file diff --git a/build/lib/index.js b/build/lib/index.js new file mode 100644 index 00000000..d88cd369 --- /dev/null +++ b/build/lib/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./Autocomplete'); \ No newline at end of file diff --git a/dist/react-autocomplete.js b/dist/react-autocomplete.js new file mode 100644 index 00000000..56669ea6 --- /dev/null +++ b/dist/react-autocomplete.js @@ -0,0 +1,2087 @@ +(function (g, factory) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + module.exports = factory(require('react'), require('react-dom')) + } else if (typeof define === 'function' && define.amd) { + define(['react', 'react-dom'], factory) + } else { + g['ReactAutocomplete'] = factory(g['React'], g['ReactDOM']) + } +})(this, function (dep0, dep1) { + return (function (require) { + var define, module, exports // Reset to avoid causing problems for any nested UMDs + return ((function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i= this.getFilteredItems(props).length) { + return { highlightedIndex: null }; + } + } + }, { + key: 'setMenuPositions', + value: function setMenuPositions() { + var node = this.refs.input; + var rect = node.getBoundingClientRect(); + var computedStyle = global.window.getComputedStyle(node); + var marginBottom = parseInt(computedStyle.marginBottom, 10) || 0; + var marginLeft = parseInt(computedStyle.marginLeft, 10) || 0; + var marginRight = parseInt(computedStyle.marginRight, 10) || 0; + this.setState({ + menuTop: rect.bottom + marginBottom, + menuLeft: rect.left + marginLeft, + menuWidth: rect.width + marginLeft + marginRight + }); + } + }, { + key: 'highlightItemFromMouse', + value: function highlightItemFromMouse(index) { + this.setState({ highlightedIndex: index }); + } + }, { + key: 'selectItemFromMouse', + value: function selectItemFromMouse(item) { + var _this3 = this; + + var value = this.props.getItemValue(item); + // The menu will de-render before a mouseLeave event + // happens. Clear the flag to release control over focus + this.setIgnoreBlur(false); + this.setState({ + isOpen: false, + highlightedIndex: null + }, function () { + _this3.props.onSelect(value, item); + }); + } + }, { + key: 'setIgnoreBlur', + value: function setIgnoreBlur(ignore) { + this._ignoreBlur = ignore; + } + }, { + key: 'renderMenu', + value: function renderMenu() { + var _this4 = this; + + var items = this.getFilteredItems(this.props).map(function (item, index) { + var element = _this4.props.renderItem(item, _this4.state.highlightedIndex === index, { cursor: 'default' }); + return React.cloneElement(element, { + onMouseEnter: _this4.props.isItemSelectable(item) ? function () { + return _this4.highlightItemFromMouse(index); + } : null, + onClick: _this4.props.isItemSelectable(item) ? function () { + return _this4.selectItemFromMouse(item); + } : null, + ref: function ref(e) { + return _this4.refs['item-' + index] = e; + } + }); + }); + var style = { + left: this.state.menuLeft, + top: this.state.menuTop, + minWidth: this.state.menuWidth + }; + var menu = this.props.renderMenu(items, this.props.value, style); + return React.cloneElement(menu, { + ref: function ref(e) { + return _this4.refs.menu = e; + }, + // Ignore blur to prevent menu from de-rendering before we can process click + onTouchStart: function onTouchStart() { + return _this4.setIgnoreBlur(true); + }, + onMouseEnter: function onMouseEnter() { + return _this4.setIgnoreBlur(true); + }, + onMouseLeave: function onMouseLeave() { + return _this4.setIgnoreBlur(false); + } + }); + } + }, { + key: 'handleInputBlur', + value: function handleInputBlur(event) { + var _this5 = this; + + if (this._ignoreBlur) { + this._ignoreFocus = true; + this._scrollOffset = getScrollOffset(); + this.refs.input.focus(); + return; + } + var setStateCallback = void 0; + var highlightedIndex = this.state.highlightedIndex; + + if (this.props.selectOnBlur && highlightedIndex !== null) { + var items = this.getFilteredItems(this.props); + var item = items[highlightedIndex]; + var value = this.props.getItemValue(item); + setStateCallback = function setStateCallback() { + return _this5.props.onSelect(value, item); + }; + } + this.setState({ + isOpen: false, + highlightedIndex: null + }, setStateCallback); + var onBlur = this.props.inputProps.onBlur; + + if (onBlur) { + onBlur(event); + } + } + }, { + key: 'handleInputFocus', + value: function handleInputFocus(event) { + var _this6 = this; + + if (this._ignoreFocus) { + this._ignoreFocus = false; + var _scrollOffset = this._scrollOffset, + x = _scrollOffset.x, + y = _scrollOffset.y; + + this._scrollOffset = null; + // Focus will cause the browser to scroll the into view. + // This can cause the mouse coords to change, which in turn + // could cause a new highlight to happen, cancelling the click + // event (when selecting with the mouse) + window.scrollTo(x, y); + // Some browsers wait until all focus event handlers have been + // processed before scrolling the into view, so let's + // scroll again on the next tick to ensure we're back to where + // the user was before focus was lost. We could do the deferred + // scroll only, but that causes a jarring split second jump in + // some browsers that scroll before the focus event handlers + // are triggered. + clearTimeout(this._scrollTimer); + this._scrollTimer = setTimeout(function () { + _this6._scrollTimer = null; + window.scrollTo(x, y); + }, 0); + return; + } + this.setState({ isOpen: true }); + var onFocus = this.props.inputProps.onFocus; + + if (onFocus) { + onFocus(event); + } + } + }, { + key: 'isInputFocused', + value: function isInputFocused() { + var el = this.refs.input; + return el.ownerDocument && el === el.ownerDocument.activeElement; + } + }, { + key: 'handleInputClick', + value: function handleInputClick() { + // Input will not be focused if it's disabled + if (this.isInputFocused() && !this.isOpen()) this.setState({ isOpen: true }); + } + }, { + key: 'composeEventHandlers', + value: function composeEventHandlers(internal, external) { + return external ? function (e) { + internal(e);external(e); + } : internal; + } + }, { + key: 'isOpen', + value: function isOpen() { + return 'open' in this.props ? this.props.open : this.state.isOpen; + } + }, { + key: 'render', + value: function render() { + if (this.props.debug) { + // you don't like it, you love it + this._debugStates.push({ + id: this._debugStates.length, + state: this.state + }); + } + + var inputProps = this.props.inputProps; + + var open = this.isOpen(); + return React.createElement( + 'div', + _extends({ style: _extends({}, this.props.wrapperStyle) }, this.props.wrapperProps, { role: 'combobox', 'aria-expanded': open }), + this.props.renderInput(_extends({}, inputProps, { + 'aria-autocomplete': 'list', + autoComplete: 'off', + ref: this.exposeAPI, + onFocus: this.handleInputFocus, + onBlur: this.handleInputBlur, + onChange: this.handleChange, + onKeyDown: this.composeEventHandlers(this.handleKeyDown, inputProps.onKeyDown), + onClick: this.composeEventHandlers(this.handleInputClick, inputProps.onClick), + value: this.props.value + })), + open && this.renderMenu(), + this.props.debug && React.createElement( + 'pre', + { style: { marginLeft: 300 } }, + JSON.stringify(this._debugStates.slice(Math.max(0, this._debugStates.length - 5), this._debugStates.length), null, 2) + ) + ); + } + }]); + + return Autocomplete; +}(React.Component); + +Autocomplete.propTypes = { + /** + * The items to display in the dropdown menu + */ + items: PropTypes.array.isRequired, + /** + * The value to display in the input field + */ + value: PropTypes.any, + /** + * Arguments: `event: Event, value: String` + * + * Invoked every time the user changes the input's value. + */ + onChange: PropTypes.func, + /** + * Arguments: `value: String, item: Any` + * + * Invoked when the user selects an item from the dropdown menu. + */ + onSelect: PropTypes.func, + /** + * Arguments: `item: Any, value: String` + * + * Invoked for each entry in `items` and its return value is used to + * determine whether or not it should be displayed in the dropdown menu. + * By default all items are always rendered. + */ + shouldItemRender: PropTypes.func, + /** + * Arguments: `item: Any` + * + * Invoked when attempting to select an item. The return value is used to + * determine whether the item should be selectable or not. + * By default all items are selectable. + */ + isItemSelectable: PropTypes.func, + /** + * Arguments: `itemA: Any, itemB: Any, value: String` + * + * The function which is used to sort `items` before display. + */ + sortItems: PropTypes.func, + /** + * Arguments: `item: Any` + * + * Used to read the display value from each entry in `items`. + */ + getItemValue: PropTypes.func.isRequired, + /** + * Arguments: `item: Any, isHighlighted: Boolean, styles: Object` + * + * Invoked for each entry in `items` that also passes `shouldItemRender` to + * generate the render tree for each item in the dropdown menu. `styles` is + * an optional set of styles that can be applied to improve the look/feel + * of the items in the dropdown menu. + */ + renderItem: PropTypes.func.isRequired, + /** + * Arguments: `items: Array, value: String, styles: Object` + * + * Invoked to generate the render tree for the dropdown menu. Ensure the + * returned tree includes every entry in `items` or else the highlight order + * and keyboard navigation logic will break. `styles` will contain + * { top, left, minWidth } which are the coordinates of the top-left corner + * and the width of the dropdown menu. + */ + renderMenu: PropTypes.func, + /** + * Styles that are applied to the dropdown menu in the default `renderMenu` + * implementation. If you override `renderMenu` and you want to use + * `menuStyle` you must manually apply them (`this.props.menuStyle`). + */ + menuStyle: PropTypes.object, + /** + * Arguments: `props: Object` + * + * Invoked to generate the input element. The `props` argument is the result + * of merging `props.inputProps` with a selection of props that are required + * both for functionality and accessibility. At the very least you need to + * apply `props.ref` and all `props.on` event handlers. Failing to do + * this will cause `Autocomplete` to behave unexpectedly. + */ + renderInput: PropTypes.func, + /** + * Props passed to `props.renderInput`. By default these props will be + * applied to the `` element rendered by `Autocomplete`, unless you + * have specified a custom value for `props.renderInput`. Any properties + * supported by `HTMLInputElement` can be specified, apart from the + * following which are set by `Autocomplete`: value, autoComplete, role, + * aria-autocomplete. `inputProps` is commonly used for (but not limited to) + * placeholder, event handlers (onFocus, onBlur, etc.), autoFocus, etc.. + */ + inputProps: PropTypes.object, + /** + * Props that are applied to the element which wraps the `` and + * dropdown menu elements rendered by `Autocomplete`. This is in addition to + * the following properties set by `Autocomplete`: role, aria-expanded. + */ + wrapperProps: PropTypes.object, + /** + * This is a shorthand for `wrapperProps={{ style: }}`. + * Note that `wrapperStyle` is applied before `wrapperProps`, so the latter + * will win if it contains a `style` entry. + */ + wrapperStyle: PropTypes.object, + /** + * Whether or not to automatically highlight the top match in the dropdown + * menu. + */ + autoHighlight: PropTypes.bool, + /** + * Whether or not to automatically select the highlighted item when the + * `` loses focus. + */ + selectOnBlur: PropTypes.bool, + /** + * Arguments: `isOpen: Boolean` + * + * Invoked every time the dropdown menu's visibility changes (i.e. every + * time it is displayed/hidden). + */ + onMenuVisibilityChange: PropTypes.func, + /** + * Used to override the internal logic which displays/hides the dropdown + * menu. This is useful if you want to force a certain state based on your + * UX/business logic. Use it together with `onMenuVisibilityChange` for + * fine-grained control over the dropdown menu dynamics. + */ + open: PropTypes.bool, + debug: PropTypes.bool +}; +Autocomplete.defaultProps = { + value: '', + wrapperProps: {}, + wrapperStyle: { + display: 'inline-block' + }, + inputProps: {}, + renderInput: function renderInput(props) { + return React.createElement('input', props); + }, + onChange: function onChange() {}, + onSelect: function onSelect() {}, + isItemSelectable: function isItemSelectable() { + return true; + }, + renderMenu: function renderMenu(items, value, style) { + return React.createElement('div', { role: 'listbox', style: _extends({}, style, this.menuStyle), children: items }); + }, + + menuStyle: { + borderRadius: '3px', + boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)', + background: 'rgba(255, 255, 255, 0.9)', + padding: '2px 0', + fontSize: '90%', + position: 'fixed', + overflow: 'auto', + maxHeight: '50%' // TODO: don't cheat, let it flow to the bottom + }, + autoHighlight: true, + selectOnBlur: false, + onMenuVisibilityChange: function onMenuVisibilityChange() {} +}; +Autocomplete.keyDownHandlers = { + ArrowDown: function ArrowDown(event) { + event.preventDefault(); + var items = this.getFilteredItems(this.props); + if (!items.length) return; + var highlightedIndex = this.state.highlightedIndex; + + var index = highlightedIndex === null ? -1 : highlightedIndex; + for (var i = 0; i < items.length; i++) { + var p = (index + i + 1) % items.length; + if (this.props.isItemSelectable(items[p])) { + index = p; + break; + } + } + if (index > -1 && index !== highlightedIndex) { + this.setState({ + highlightedIndex: index, + isOpen: true + }); + } + }, + ArrowUp: function ArrowUp(event) { + event.preventDefault(); + var items = this.getFilteredItems(this.props); + if (!items.length) return; + var highlightedIndex = this.state.highlightedIndex; + + var index = highlightedIndex === null ? items.length : highlightedIndex; + for (var i = 0; i < items.length; i++) { + var p = (index - (1 + i) + items.length) % items.length; + if (this.props.isItemSelectable(items[p])) { + index = p; + break; + } + } + if (index !== items.length) { + this.setState({ + highlightedIndex: index, + isOpen: true + }); + } + }, + Enter: function Enter(event) { + var _this7 = this; + + // Key code 229 is used for selecting items from character selectors (Pinyin, Kana, etc) + if (event.keyCode !== 13) return; + // In case the user is currently hovering over the menu + this.setIgnoreBlur(false); + if (!this.isOpen()) { + // menu is closed so there is no selection to accept -> do nothing + return; + } else if (this.state.highlightedIndex == null) { + // input has focus but no menu item is selected + enter is hit -> close the menu, highlight whatever's in input + this.setState({ + isOpen: false + }, function () { + _this7.refs.input.select(); + }); + } else { + // text entered + menu item has been highlighted + enter is hit -> update value to that of selected menu item, close the menu + event.preventDefault(); + var item = this.getFilteredItems(this.props)[this.state.highlightedIndex]; + var value = this.props.getItemValue(item); + this.setState({ + isOpen: false, + highlightedIndex: null + }, function () { + //this.refs.input.focus() // TODO: file issue + _this7.refs.input.setSelectionRange(value.length, value.length); + _this7.props.onSelect(value, item); + }); + } + }, + Escape: function Escape() { + // In case the user is currently hovering over the menu + this.setIgnoreBlur(false); + this.setState({ + highlightedIndex: null, + isOpen: false + }); + }, + Tab: function Tab() { + // In case the user is currently hovering over the menu + this.setIgnoreBlur(false); + } +}; + + +module.exports = Autocomplete; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"dom-scroll-into-view":2,"prop-types":9,"react":"react","react-dom":"react-dom"}],2:[function(require,module,exports){ +module.exports = require('./lib/dom-scroll-into-view'); + +},{"./lib/dom-scroll-into-view":3}],3:[function(require,module,exports){ +var util = require('./util'); + +function scrollIntoView(elem, container, config) { + config = config || {}; + // document 归一化到 window + if (container.nodeType === 9) { + container = util.getWindow(container); + } + + var allowHorizontalScroll = config.allowHorizontalScroll; + var onlyScrollIfNeeded = config.onlyScrollIfNeeded; + var alignWithTop = config.alignWithTop; + var alignWithLeft = config.alignWithLeft; + + allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll; + + var isWin = util.isWindow(container); + var elemOffset = util.offset(elem); + var eh = util.outerHeight(elem); + var ew = util.outerWidth(elem); + var containerOffset, ch, cw, containerScroll, + diffTop, diffBottom, win, + winScroll, ww, wh; + + if (isWin) { + win = container; + wh = util.height(win); + ww = util.width(win); + winScroll = { + left: util.scrollLeft(win), + top: util.scrollTop(win) + }; + // elem 相对 container 可视视窗的距离 + diffTop = { + left: elemOffset.left - winScroll.left, + top: elemOffset.top - winScroll.top + }; + diffBottom = { + left: elemOffset.left + ew - (winScroll.left + ww), + top: elemOffset.top + eh - (winScroll.top + wh) + }; + containerScroll = winScroll; + } else { + containerOffset = util.offset(container); + ch = container.clientHeight; + cw = container.clientWidth; + containerScroll = { + left: container.scrollLeft, + top: container.scrollTop + }; + // elem 相对 container 可视视窗的距离 + // 注意边框, offset 是边框到根节点 + diffTop = { + left: elemOffset.left - (containerOffset.left + + (parseFloat(util.css(container, 'borderLeftWidth')) || 0)), + top: elemOffset.top - (containerOffset.top + + (parseFloat(util.css(container, 'borderTopWidth')) || 0)) + }; + diffBottom = { + left: elemOffset.left + ew - + (containerOffset.left + cw + + (parseFloat(util.css(container, 'borderRightWidth')) || 0)), + top: elemOffset.top + eh - + (containerOffset.top + ch + + (parseFloat(util.css(container, 'borderBottomWidth')) || 0)) + }; + } + + if (diffTop.top < 0 || diffBottom.top > 0) { + // 强制向上 + if (alignWithTop === true) { + util.scrollTop(container, containerScroll.top + diffTop.top); + } else if (alignWithTop === false) { + util.scrollTop(container, containerScroll.top + diffBottom.top); + } else { + // 自动调整 + if (diffTop.top < 0) { + util.scrollTop(container, containerScroll.top + diffTop.top); + } else { + util.scrollTop(container, containerScroll.top + diffBottom.top); + } + } + } else { + if (!onlyScrollIfNeeded) { + alignWithTop = alignWithTop === undefined ? true : !!alignWithTop; + if (alignWithTop) { + util.scrollTop(container, containerScroll.top + diffTop.top); + } else { + util.scrollTop(container, containerScroll.top + diffBottom.top); + } + } + } + + if (allowHorizontalScroll) { + if (diffTop.left < 0 || diffBottom.left > 0) { + // 强制向上 + if (alignWithLeft === true) { + util.scrollLeft(container, containerScroll.left + diffTop.left); + } else if (alignWithLeft === false) { + util.scrollLeft(container, containerScroll.left + diffBottom.left); + } else { + // 自动调整 + if (diffTop.left < 0) { + util.scrollLeft(container, containerScroll.left + diffTop.left); + } else { + util.scrollLeft(container, containerScroll.left + diffBottom.left); + } + } + } else { + if (!onlyScrollIfNeeded) { + alignWithLeft = alignWithLeft === undefined ? true : !!alignWithLeft; + if (alignWithLeft) { + util.scrollLeft(container, containerScroll.left + diffTop.left); + } else { + util.scrollLeft(container, containerScroll.left + diffBottom.left); + } + } + } + } +} + +module.exports = scrollIntoView; + +},{"./util":4}],4:[function(require,module,exports){ +var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source; + +function getClientPosition(elem) { + var box, x, y; + var doc = elem.ownerDocument; + var body = doc.body; + var docElem = doc && doc.documentElement; + // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式 + box = elem.getBoundingClientRect(); + + // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop + // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确 + // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin + + x = box.left; + y = box.top; + + // In IE, most of the time, 2 extra pixels are added to the top and left + // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and + // IE6 standards mode, this border can be overridden by setting the + // document element's border to zero -- thus, we cannot rely on the + // offset always being 2 pixels. + + // In quirks mode, the offset can be determined by querying the body's + // clientLeft/clientTop, but in standards mode, it is found by querying + // the document element's clientLeft/clientTop. Since we already called + // getClientBoundingRect we have already forced a reflow, so it is not + // too expensive just to query them all. + + // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的 + // 窗口边框标准是设 documentElement ,quirks 时设置 body + // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去 + // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置 + // 标准 ie 下 docElem.clientTop 就是 border-top + // ie7 html 即窗口边框改变不了。永远为 2 + // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0 + + x -= docElem.clientLeft || body.clientLeft || 0; + y -= docElem.clientTop || body.clientTop || 0; + + return {left: x, top: y}; +} + +function getScroll(w, top) { + var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; + var method = 'scroll' + (top ? 'Top' : 'Left'); + if (typeof ret !== 'number') { + var d = w.document; + //ie6,7,8 standard mode + ret = d.documentElement[method]; + if (typeof ret !== 'number') { + //quirks mode + ret = d.body[method]; + } + } + return ret; +} + +function getScrollLeft(w) { + return getScroll(w); +} + +function getScrollTop(w) { + return getScroll(w, true); +} + +function getOffset(el) { + var pos = getClientPosition(el); + var doc = el.ownerDocument; + var w = doc.defaultView || doc.parentWindow; + pos.left += getScrollLeft(w); + pos.top += getScrollTop(w); + return pos; +} +function _getComputedStyle(elem, name, computedStyle) { + var val = ''; + var d = elem.ownerDocument; + + // https://github.com/kissyteam/kissy/issues/61 + if ((computedStyle = (computedStyle || d.defaultView.getComputedStyle(elem, null)))) { + val = computedStyle.getPropertyValue(name) || computedStyle[name]; + } + + return val; +} + +var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i'); +var RE_POS = /^(top|right|bottom|left)$/, + CURRENT_STYLE = 'currentStyle', + RUNTIME_STYLE = 'runtimeStyle', + LEFT = 'left', + PX = 'px'; + +function _getComputedStyleIE(elem, name) { + // currentStyle maybe null + // http://msdn.microsoft.com/en-us/library/ms535231.aspx + var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; + + // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值 + // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19 + // 在 ie 下不对,需要直接用 offset 方式 + // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了 + + // From the awesome hack by Dean Edwards + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 + // If we're not dealing with a regular pixel number + // but a number that has a weird ending, we need to convert it to pixels + // exclude left right for relativity + if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) { + // Remember the original values + var style = elem.style, + left = style[LEFT], + rsLeft = elem[RUNTIME_STYLE][LEFT]; + + // prevent flashing of content + elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; + + // Put in the new values to get a computed value out + style[LEFT] = name === 'fontSize' ? '1em' : (ret || 0); + ret = style.pixelLeft + PX; + + // Revert the changed values + style[LEFT] = left; + + elem[RUNTIME_STYLE][LEFT] = rsLeft; + } + return ret === '' ? 'auto' : ret; +} + +var getComputedStyleX; +if (typeof window !== 'undefined') { + getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE; +} + +// 设置 elem 相对 elem.ownerDocument 的坐标 +function setOffset(elem, offset) { + // set position first, in-case top/left are set even on static elem + if (css(elem, 'position') === 'static') { + elem.style.position = 'relative'; + } + + var old = getOffset(elem), + ret = {}, + current, key; + + for (key in offset) { + current = parseFloat(css(elem, key)) || 0; + ret[key] = current + offset[key] - old[key]; + } + css(elem, ret); +} + +function each(arr, fn) { + for (var i = 0; i < arr.length; i++) { + fn(arr[i]); + } +} + +function isBorderBoxFn(elem) { + return getComputedStyleX(elem, 'boxSizing') === 'border-box'; +} + +var BOX_MODELS = ['margin', 'border', 'padding'], + CONTENT_INDEX = -1, + PADDING_INDEX = 2, + BORDER_INDEX = 1, + MARGIN_INDEX = 0; + +function swap(elem, options, callback) { + var old = {}, + style = elem.style, + name; + + // Remember the old values, and insert the new ones + for (name in options) { + old[name] = style[name]; + style[name] = options[name]; + } + + callback.call(elem); + + // Revert the old values + for (name in options) { + style[name] = old[name]; + } +} + +function getPBMWidth(elem, props, which) { + var value = 0, prop, j, i; + for (j = 0; j < props.length; j++) { + prop = props[j]; + if (prop) { + for (i = 0; i < which.length; i++) { + var cssProp; + if (prop === 'border') { + cssProp = prop + which[i] + 'Width'; + } else { + cssProp = prop + which[i]; + } + value += parseFloat(getComputedStyleX(elem, cssProp)) || 0; + } + } + } + return value; +} + +/** + * A crude way of determining if an object is a window + * @member util + */ +function isWindow(obj) { + // must use == for ie8 + /*jshint eqeqeq:false*/ + return obj != null && obj == obj.window; +} + +var domUtils = {}; + +each(['Width', 'Height'], function (name) { + domUtils['doc' + name] = function (refWin) { + var d = refWin.document; + return Math.max( + //firefox chrome documentElement.scrollHeight< body.scrollHeight + //ie standard mode : documentElement.scrollHeight> body.scrollHeight + d.documentElement['scroll' + name], + //quirks : documentElement.scrollHeight 最大等于可视窗口多一点? + d.body['scroll' + name], + domUtils['viewport' + name](d)); + }; + + domUtils['viewport' + name] = function (win) { + // pc browser includes scrollbar in window.innerWidth + var prop = 'client' + name, + doc = win.document, + body = doc.body, + documentElement = doc.documentElement, + documentElementProp = documentElement[prop]; + // 标准模式取 documentElement + // backcompat 取 body + return doc.compatMode === 'CSS1Compat' && documentElementProp || + body && body[prop] || documentElementProp; + }; +}); + +/* + 得到元素的大小信息 + @param elem + @param name + @param {String} [extra] 'padding' : (css width) + padding + 'border' : (css width) + padding + border + 'margin' : (css width) + padding + border + margin + */ +function getWH(elem, name, extra) { + if (isWindow(elem)) { + return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem); + } else if (elem.nodeType === 9) { + return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem); + } + var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'], + borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight; + var computedStyle = getComputedStyleX(elem); + var isBorderBox = isBorderBoxFn(elem, computedStyle); + var cssBoxValue = 0; + if (borderBoxValue == null || borderBoxValue <= 0) { + borderBoxValue = undefined; + // Fall back to computed then un computed css if necessary + cssBoxValue = getComputedStyleX(elem, name); + if (cssBoxValue == null || (Number(cssBoxValue)) < 0) { + cssBoxValue = elem.style[name] || 0; + } + // Normalize '', auto, and prepare for extra + cssBoxValue = parseFloat(cssBoxValue) || 0; + } + if (extra === undefined) { + extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX; + } + var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox; + var val = borderBoxValue || cssBoxValue; + if (extra === CONTENT_INDEX) { + if (borderBoxValueOrIsBorderBox) { + return val - getPBMWidth(elem, ['border', 'padding'], + which, computedStyle); + } else { + return cssBoxValue; + } + } else if (borderBoxValueOrIsBorderBox) { + return val + (extra === BORDER_INDEX ? 0 : + (extra === PADDING_INDEX ? + -getPBMWidth(elem, ['border'], which, computedStyle) : + getPBMWidth(elem, ['margin'], which, computedStyle))); + } else { + return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), + which, computedStyle); + } +} + +var cssShow = {position: 'absolute', visibility: 'hidden', display: 'block'}; + +// fix #119 : https://github.com/kissyteam/kissy/issues/119 +function getWHIgnoreDisplay(elem) { + var val, args = arguments; + // in case elem is window + // elem.offsetWidth === undefined + if (elem.offsetWidth !== 0) { + val = getWH.apply(undefined, args); + } else { + swap(elem, cssShow, function () { + val = getWH.apply(undefined, args); + }); + } + return val; +} + +each(['width', 'height'], function (name) { + var first = name.charAt(0).toUpperCase() + name.slice(1); + domUtils['outer' + first] = function (el, includeMargin) { + return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX); + }; + var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; + + domUtils[name] = function (elem, val) { + if (val !== undefined) { + if (elem) { + var computedStyle = getComputedStyleX(elem); + var isBorderBox = isBorderBoxFn(elem); + if (isBorderBox) { + val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle); + } + return css(elem, name, val); + } + return; + } + return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX); + }; +}); + +function css(el, name, value) { + if (typeof name === 'object') { + for (var i in name) { + css(el, i, name[i]); + } + return; + } + if (typeof value !== 'undefined') { + if (typeof value === 'number') { + value = value + 'px'; + } + el.style[name] = value; + } else { + return getComputedStyleX(el, name); + } +} + +function mix(to, from) { + for (var i in from) { + to[i] = from[i]; + } + return to; +} + +var utils = module.exports = { + getWindow: function (node) { + var doc = node.ownerDocument || node; + return doc.defaultView || doc.parentWindow; + }, + offset: function (el, value) { + if (typeof value !== 'undefined') { + setOffset(el, value); + } else { + return getOffset(el); + } + }, + isWindow: isWindow, + each: each, + css: css, + clone: function (obj) { + var ret = {}; + for (var i in obj) { + ret[i] = obj[i]; + } + var overflow = obj.overflow; + if (overflow) { + for (i in obj) { + ret.overflow[i] = obj.overflow[i]; + } + } + return ret; + }, + mix: mix, + scrollLeft: function (w, v) { + if (isWindow(w)) { + if (v === undefined) { + return getScrollLeft(w); + } else { + window.scrollTo(v, getScrollTop(w)); + } + } else { + if (v === undefined) { + return w.scrollLeft; + } else { + w.scrollLeft = v; + } + } + }, + scrollTop: function (w, v) { + if (isWindow(w)) { + if (v === undefined) { + return getScrollTop(w); + } else { + window.scrollTo(getScrollLeft(w), v); + } + } else { + if (v === undefined) { + return w.scrollTop; + } else { + w.scrollTop = v; + } + } + }, + merge: function () { + var ret = {}; + for (var i = 0; i < arguments.length; i++) { + utils.mix(ret, arguments[i]); + } + return ret; + }, + viewportWidth: 0, + viewportHeight: 0 +}; + +mix(utils, domUtils); + +},{}],5:[function(require,module,exports){ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ + +'use strict'; +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} + +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; + +},{}],6:[function(require,module,exports){ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +var printWarning = function() {}; + +if ("production" !== 'production') { + var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); + var loggedTypeFailures = {}; + + printWarning = function(text) { + var message = 'Warning: ' + text; + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; +} + +/** + * Assert that the values match with the type specs. + * Error messages are memorized and will only be shown once. + * + * @param {object} typeSpecs Map of name to a ReactPropType + * @param {object} values Runtime values that need to be type-checked + * @param {string} location e.g. "prop", "context", "child context" + * @param {string} componentName Name of the component for error messages. + * @param {?Function} getStack Returns the component stack. + * @private + */ +function checkPropTypes(typeSpecs, values, location, componentName, getStack) { + if ("production" !== 'production') { + for (var typeSpecName in typeSpecs) { + if (typeSpecs.hasOwnProperty(typeSpecName)) { + var error; + // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== 'function') { + var err = Error( + (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + ); + err.name = 'Invariant Violation'; + throw err; + } + error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); + } catch (ex) { + error = ex; + } + if (error && !(error instanceof Error)) { + printWarning( + (componentName || 'React class') + ': type specification of ' + + location + ' `' + typeSpecName + '` is invalid; the type checker ' + + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + + 'You may have forgotten to pass an argument to the type checker ' + + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + + 'shape all require an argument).' + ) + + } + if (error instanceof Error && !(error.message in loggedTypeFailures)) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error.message] = true; + + var stack = getStack ? getStack() : ''; + + printWarning( + 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') + ); + } + } + } + } +} + +module.exports = checkPropTypes; + +},{"./lib/ReactPropTypesSecret":10}],7:[function(require,module,exports){ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); + +function emptyFunction() {} + +module.exports = function() { + function shim(props, propName, componentName, location, propFullName, secret) { + if (secret === ReactPropTypesSecret) { + // It is still safe when called from React. + return; + } + var err = new Error( + 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + + 'Use PropTypes.checkPropTypes() to call them. ' + + 'Read more at http://fb.me/use-check-prop-types' + ); + err.name = 'Invariant Violation'; + throw err; + }; + shim.isRequired = shim; + function getShim() { + return shim; + }; + // Important! + // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. + var ReactPropTypes = { + array: shim, + bool: shim, + func: shim, + number: shim, + object: shim, + string: shim, + symbol: shim, + + any: shim, + arrayOf: getShim, + element: shim, + instanceOf: getShim, + node: shim, + objectOf: getShim, + oneOf: getShim, + oneOfType: getShim, + shape: getShim, + exact: getShim + }; + + ReactPropTypes.checkPropTypes = emptyFunction; + ReactPropTypes.PropTypes = ReactPropTypes; + + return ReactPropTypes; +}; + +},{"./lib/ReactPropTypesSecret":10}],8:[function(require,module,exports){ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +var assign = require('object-assign'); + +var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); +var checkPropTypes = require('./checkPropTypes'); + +var printWarning = function() {}; + +if ("production" !== 'production') { + printWarning = function(text) { + var message = 'Warning: ' + text; + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; +} + +function emptyFunctionThatReturnsNull() { + return null; +} + +module.exports = function(isValidElement, throwOnDirectAccess) { + /* global Symbol */ + var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. + + /** + * Returns the iterator method function contained on the iterable object. + * + * Be sure to invoke the function with the iterable as context: + * + * var iteratorFn = getIteratorFn(myIterable); + * if (iteratorFn) { + * var iterator = iteratorFn.call(myIterable); + * ... + * } + * + * @param {?object} maybeIterable + * @return {?function} + */ + function getIteratorFn(maybeIterable) { + var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; + } + } + + /** + * Collection of methods that allow declaration and validation of props that are + * supplied to React components. Example usage: + * + * var Props = require('ReactPropTypes'); + * var MyArticle = React.createClass({ + * propTypes: { + * // An optional string prop named "description". + * description: Props.string, + * + * // A required enum prop named "category". + * category: Props.oneOf(['News','Photos']).isRequired, + * + * // A prop named "dialog" that requires an instance of Dialog. + * dialog: Props.instanceOf(Dialog).isRequired + * }, + * render: function() { ... } + * }); + * + * A more formal specification of how these methods are used: + * + * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) + * decl := ReactPropTypes.{type}(.isRequired)? + * + * Each and every declaration produces a function with the same signature. This + * allows the creation of custom validation functions. For example: + * + * var MyLink = React.createClass({ + * propTypes: { + * // An optional string or URI prop named "href". + * href: function(props, propName, componentName) { + * var propValue = props[propName]; + * if (propValue != null && typeof propValue !== 'string' && + * !(propValue instanceof URI)) { + * return new Error( + * 'Expected a string or an URI for ' + propName + ' in ' + + * componentName + * ); + * } + * } + * }, + * render: function() {...} + * }); + * + * @internal + */ + + var ANONYMOUS = '<>'; + + // Important! + // Keep this list in sync with production version in `./factoryWithThrowingShims.js`. + var ReactPropTypes = { + array: createPrimitiveTypeChecker('array'), + bool: createPrimitiveTypeChecker('boolean'), + func: createPrimitiveTypeChecker('function'), + number: createPrimitiveTypeChecker('number'), + object: createPrimitiveTypeChecker('object'), + string: createPrimitiveTypeChecker('string'), + symbol: createPrimitiveTypeChecker('symbol'), + + any: createAnyTypeChecker(), + arrayOf: createArrayOfTypeChecker, + element: createElementTypeChecker(), + instanceOf: createInstanceTypeChecker, + node: createNodeChecker(), + objectOf: createObjectOfTypeChecker, + oneOf: createEnumTypeChecker, + oneOfType: createUnionTypeChecker, + shape: createShapeTypeChecker, + exact: createStrictShapeTypeChecker, + }; + + /** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ + /*eslint-disable no-self-compare*/ + function is(x, y) { + // SameValue algorithm + if (x === y) { + // Steps 1-5, 7-10 + // Steps 6.b-6.e: +0 != -0 + return x !== 0 || 1 / x === 1 / y; + } else { + // Step 6.a: NaN == NaN + return x !== x && y !== y; + } + } + /*eslint-enable no-self-compare*/ + + /** + * We use an Error-like object for backward compatibility as people may call + * PropTypes directly and inspect their output. However, we don't use real + * Errors anymore. We don't inspect their stack anyway, and creating them + * is prohibitively expensive if they are created too often, such as what + * happens in oneOfType() for any type before the one that matched. + */ + function PropTypeError(message) { + this.message = message; + this.stack = ''; + } + // Make `instanceof Error` still work for returned errors. + PropTypeError.prototype = Error.prototype; + + function createChainableTypeChecker(validate) { + if ("production" !== 'production') { + var manualPropTypeCallCache = {}; + var manualPropTypeWarningCount = 0; + } + function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { + componentName = componentName || ANONYMOUS; + propFullName = propFullName || propName; + + if (secret !== ReactPropTypesSecret) { + if (throwOnDirectAccess) { + // New behavior only for users of `prop-types` package + var err = new Error( + 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + + 'Use `PropTypes.checkPropTypes()` to call them. ' + + 'Read more at http://fb.me/use-check-prop-types' + ); + err.name = 'Invariant Violation'; + throw err; + } else if ("production" !== 'production' && typeof console !== 'undefined') { + // Old behavior for people using React.PropTypes + var cacheKey = componentName + ':' + propName; + if ( + !manualPropTypeCallCache[cacheKey] && + // Avoid spamming the console because they are often not actionable except for lib authors + manualPropTypeWarningCount < 3 + ) { + printWarning( + 'You are manually calling a React.PropTypes validation ' + + 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + + 'and will throw in the standalone `prop-types` package. ' + + 'You may be seeing this warning due to a third-party PropTypes ' + + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.' + ); + manualPropTypeCallCache[cacheKey] = true; + manualPropTypeWarningCount++; + } + } + } + if (props[propName] == null) { + if (isRequired) { + if (props[propName] === null) { + return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); + } + return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); + } + return null; + } else { + return validate(props, propName, componentName, location, propFullName); + } + } + + var chainedCheckType = checkType.bind(null, false); + chainedCheckType.isRequired = checkType.bind(null, true); + + return chainedCheckType; + } + + function createPrimitiveTypeChecker(expectedType) { + function validate(props, propName, componentName, location, propFullName, secret) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== expectedType) { + // `propValue` being instance of, say, date/regexp, pass the 'object' + // check, but we can offer a more precise error message here rather than + // 'of type `object`'. + var preciseType = getPreciseType(propValue); + + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createAnyTypeChecker() { + return createChainableTypeChecker(emptyFunctionThatReturnsNull); + } + + function createArrayOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + if (typeof typeChecker !== 'function') { + return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); + } + var propValue = props[propName]; + if (!Array.isArray(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); + } + for (var i = 0; i < propValue.length; i++) { + var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); + if (error instanceof Error) { + return error; + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createElementTypeChecker() { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + if (!isValidElement(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createInstanceTypeChecker(expectedClass) { + function validate(props, propName, componentName, location, propFullName) { + if (!(props[propName] instanceof expectedClass)) { + var expectedClassName = expectedClass.name || ANONYMOUS; + var actualClassName = getClassName(props[propName]); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createEnumTypeChecker(expectedValues) { + if (!Array.isArray(expectedValues)) { + "production" !== 'production' ? printWarning('Invalid argument supplied to oneOf, expected an instance of array.') : void 0; + return emptyFunctionThatReturnsNull; + } + + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + for (var i = 0; i < expectedValues.length; i++) { + if (is(propValue, expectedValues[i])) { + return null; + } + } + + var valuesString = JSON.stringify(expectedValues); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); + } + return createChainableTypeChecker(validate); + } + + function createObjectOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + if (typeof typeChecker !== 'function') { + return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); + } + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); + } + for (var key in propValue) { + if (propValue.hasOwnProperty(key)) { + var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error instanceof Error) { + return error; + } + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createUnionTypeChecker(arrayOfTypeCheckers) { + if (!Array.isArray(arrayOfTypeCheckers)) { + "production" !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; + return emptyFunctionThatReturnsNull; + } + + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (typeof checker !== 'function') { + printWarning( + 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' + ); + return emptyFunctionThatReturnsNull; + } + } + + function validate(props, propName, componentName, location, propFullName) { + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) { + return null; + } + } + + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); + } + return createChainableTypeChecker(validate); + } + + function createNodeChecker() { + function validate(props, propName, componentName, location, propFullName) { + if (!isNode(props[propName])) { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + } + for (var key in shapeTypes) { + var checker = shapeTypes[key]; + if (!checker) { + continue; + } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error) { + return error; + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createStrictShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + } + // We need to check all keys in case some are required but missing from + // props. + var allKeys = assign({}, props[propName], shapeTypes); + for (var key in allKeys) { + var checker = shapeTypes[key]; + if (!checker) { + return new PropTypeError( + 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') + ); + } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error) { + return error; + } + } + return null; + } + + return createChainableTypeChecker(validate); + } + + function isNode(propValue) { + switch (typeof propValue) { + case 'number': + case 'string': + case 'undefined': + return true; + case 'boolean': + return !propValue; + case 'object': + if (Array.isArray(propValue)) { + return propValue.every(isNode); + } + if (propValue === null || isValidElement(propValue)) { + return true; + } + + var iteratorFn = getIteratorFn(propValue); + if (iteratorFn) { + var iterator = iteratorFn.call(propValue); + var step; + if (iteratorFn !== propValue.entries) { + while (!(step = iterator.next()).done) { + if (!isNode(step.value)) { + return false; + } + } + } else { + // Iterator will provide entry [k,v] tuples rather than values. + while (!(step = iterator.next()).done) { + var entry = step.value; + if (entry) { + if (!isNode(entry[1])) { + return false; + } + } + } + } + } else { + return false; + } + + return true; + default: + return false; + } + } + + function isSymbol(propType, propValue) { + // Native Symbol. + if (propType === 'symbol') { + return true; + } + + // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' + if (propValue['@@toStringTag'] === 'Symbol') { + return true; + } + + // Fallback for non-spec compliant Symbols which are polyfilled. + if (typeof Symbol === 'function' && propValue instanceof Symbol) { + return true; + } + + return false; + } + + // Equivalent of `typeof` but with special handling for array and regexp. + function getPropType(propValue) { + var propType = typeof propValue; + if (Array.isArray(propValue)) { + return 'array'; + } + if (propValue instanceof RegExp) { + // Old webkits (at least until Android 4.0) return 'function' rather than + // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ + // passes PropTypes.object. + return 'object'; + } + if (isSymbol(propType, propValue)) { + return 'symbol'; + } + return propType; + } + + // This handles more types than `getPropType`. Only used for error messages. + // See `createPrimitiveTypeChecker`. + function getPreciseType(propValue) { + if (typeof propValue === 'undefined' || propValue === null) { + return '' + propValue; + } + var propType = getPropType(propValue); + if (propType === 'object') { + if (propValue instanceof Date) { + return 'date'; + } else if (propValue instanceof RegExp) { + return 'regexp'; + } + } + return propType; + } + + // Returns a string that is postfixed to a warning about an invalid type. + // For example, "undefined" or "of type array" + function getPostfixForTypeWarning(value) { + var type = getPreciseType(value); + switch (type) { + case 'array': + case 'object': + return 'an ' + type; + case 'boolean': + case 'date': + case 'regexp': + return 'a ' + type; + default: + return type; + } + } + + // Returns class name of the object, if any. + function getClassName(propValue) { + if (!propValue.constructor || !propValue.constructor.name) { + return ANONYMOUS; + } + return propValue.constructor.name; + } + + ReactPropTypes.checkPropTypes = checkPropTypes; + ReactPropTypes.PropTypes = ReactPropTypes; + + return ReactPropTypes; +}; + +},{"./checkPropTypes":6,"./lib/ReactPropTypesSecret":10,"object-assign":5}],9:[function(require,module,exports){ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +if ("production" !== 'production') { + var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && + Symbol.for && + Symbol.for('react.element')) || + 0xeac7; + + var isValidElement = function(object) { + return typeof object === 'object' && + object !== null && + object.$$typeof === REACT_ELEMENT_TYPE; + }; + + // By explicitly using `prop-types` you are opting into new development behavior. + // http://fb.me/prop-types-in-prod + var throwOnDirectAccess = true; + module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess); +} else { + // By explicitly using `prop-types` you are opting into new production behavior. + // http://fb.me/prop-types-in-prod + module.exports = require('./factoryWithThrowingShims')(); +} + +},{"./factoryWithThrowingShims":7,"./factoryWithTypeCheckers":8}],10:[function(require,module,exports){ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; + +module.exports = ReactPropTypesSecret; + +},{}]},{},[1]) + +)(1) + })(function newRequire (name) { + if (name === 'react') return dep0 +if (name === 'react-dom') return dep1 + if (typeof require !== 'undefined') return require(name) + var err = new Error("Cannot find module '" + name + "'") + err.code = 'MODULE_NOT_FOUND' + throw err + }) +}) +//# sourceMappingURL=react-autocomplete.js.map \ No newline at end of file diff --git a/dist/react-autocomplete.js.map b/dist/react-autocomplete.js.map new file mode 100644 index 00000000..4ff140e6 --- /dev/null +++ b/dist/react-autocomplete.js.map @@ -0,0 +1,32 @@ +{ + "version": 3, + "sources": [ + "../node_modules/browser-pack/_prelude.js", + "../lib/Autocomplete.js", + "../node_modules/dom-scroll-into-view/index.js", + "../node_modules/dom-scroll-into-view/lib/dom-scroll-into-view.js", + "../node_modules/dom-scroll-into-view/lib/util.js", + "../node_modules/object-assign/index.js", + "../node_modules/prop-types/checkPropTypes.js", + "../node_modules/prop-types/factoryWithThrowingShims.js", + "../node_modules/prop-types/factoryWithTypeCheckers.js", + "../node_modules/prop-types/index.js", + "../node_modules/prop-types/lib/ReactPropTypesSecret.js" + ], + "names": [], + "mappings": ";;;;;;;;;;;YAAA;;;;;;;;;;;;;;ACAA,IAAM,QAAQ,QAAQ,OAAR,CAAd;AACA,IAAM,YAAY,QAAQ,YAAR,CAAlB;;eACwB,QAAQ,WAAR,C;IAAhB,W,YAAA,W;;AACR,IAAM,iBAAiB,QAAQ,sBAAR,CAAvB;;AAEA,IAAM,iBAAiB,CACrB,MADqB,EAErB,eAFqB,EAGrB,OAHqB,EAIrB,OAJqB,EAKrB,QALqB,EAMrB,mBANqB,EAOrB,mBAPqB,EAQrB,cARqB,CAAvB;;AAWA,SAAS,eAAT,GAA2B;AACzB,SAAO;AACL,OAAI,OAAO,WAAP,KAAuB,SAAxB,GACC,OAAO,WADR,GAEC,CAAC,SAAS,eAAT,IAA4B,SAAS,IAAT,CAAc,UAA1C,IAAwD,SAAS,IAAlE,EAAwE,UAHvE;AAIL,OAAI,OAAO,WAAP,KAAuB,SAAxB,GACC,OAAO,WADR,GAEC,CAAC,SAAS,eAAT,IAA4B,SAAS,IAAT,CAAc,UAA1C,IAAwD,SAAS,IAAlE,EAAwE;AANvE,GAAP;AAQD;;IAEK,Y;;;AAsKJ,wBAAY,KAAZ,EAAmB;AAAA;;AAAA,4HACX,KADW;;AAEjB,UAAK,KAAL,GAAa;AACX,cAAQ,KADG;AAEX,w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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/aA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3iBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", + "sourcesContent": [ + "(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i, value: String, styles: Object`\n *\n * Invoked to generate the render tree for the dropdown menu. Ensure the\n * returned tree includes every entry in `items` or else the highlight order\n * and keyboard navigation logic will break. `styles` will contain\n * { top, left, minWidth } which are the coordinates of the top-left corner\n * and the width of the dropdown menu.\n */\n renderMenu: PropTypes.func,\n /**\n * Styles that are applied to the dropdown menu in the default `renderMenu`\n * implementation. If you override `renderMenu` and you want to use\n * `menuStyle` you must manually apply them (`this.props.menuStyle`).\n */\n menuStyle: PropTypes.object,\n /**\n * Arguments: `props: Object`\n *\n * Invoked to generate the input element. The `props` argument is the result\n * of merging `props.inputProps` with a selection of props that are required\n * both for functionality and accessibility. At the very least you need to\n * apply `props.ref` and all `props.on` event handlers. Failing to do\n * this will cause `Autocomplete` to behave unexpectedly.\n */\n renderInput: PropTypes.func,\n /**\n * Props passed to `props.renderInput`. By default these props will be\n * applied to the `` element rendered by `Autocomplete`, unless you\n * have specified a custom value for `props.renderInput`. Any properties\n * supported by `HTMLInputElement` can be specified, apart from the\n * following which are set by `Autocomplete`: value, autoComplete, role,\n * aria-autocomplete. `inputProps` is commonly used for (but not limited to)\n * placeholder, event handlers (onFocus, onBlur, etc.), autoFocus, etc..\n */\n inputProps: PropTypes.object,\n /**\n * Props that are applied to the element which wraps the `` and\n * dropdown menu elements rendered by `Autocomplete`. This is in addition to\n * the following properties set by `Autocomplete`: role, aria-expanded.\n */\n wrapperProps: PropTypes.object,\n /**\n * This is a shorthand for `wrapperProps={{ style: }}`.\n * Note that `wrapperStyle` is applied before `wrapperProps`, so the latter\n * will win if it contains a `style` entry.\n */\n wrapperStyle: PropTypes.object,\n /**\n * Whether or not to automatically highlight the top match in the dropdown\n * menu.\n */\n autoHighlight: PropTypes.bool,\n /**\n * Whether or not to automatically select the highlighted item when the\n * `` loses focus.\n */\n selectOnBlur: PropTypes.bool,\n /**\n * Arguments: `isOpen: Boolean`\n *\n * Invoked every time the dropdown menu's visibility changes (i.e. every\n * time it is displayed/hidden).\n */\n onMenuVisibilityChange: PropTypes.func,\n /**\n * Used to override the internal logic which displays/hides the dropdown\n * menu. This is useful if you want to force a certain state based on your\n * UX/business logic. Use it together with `onMenuVisibilityChange` for\n * fine-grained control over the dropdown menu dynamics.\n */\n open: PropTypes.bool,\n debug: PropTypes.bool,\n }\n\n static defaultProps = {\n value: '',\n wrapperProps: {},\n wrapperStyle: {\n display: 'inline-block'\n },\n inputProps: {},\n renderInput(props) {\n return \n },\n onChange() {},\n onSelect() {},\n isItemSelectable() { return true },\n renderMenu(items, value, style) {\n return
\n },\n menuStyle: {\n borderRadius: '3px',\n boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)',\n background: 'rgba(255, 255, 255, 0.9)',\n padding: '2px 0',\n fontSize: '90%',\n position: 'fixed',\n overflow: 'auto',\n maxHeight: '50%', // TODO: don't cheat, let it flow to the bottom\n },\n autoHighlight: true,\n selectOnBlur: false,\n onMenuVisibilityChange() {},\n }\n\n constructor(props) {\n super(props)\n this.state = {\n isOpen: false,\n highlightedIndex: null,\n }\n this._debugStates = []\n this.ensureHighlightedIndex = this.ensureHighlightedIndex.bind(this)\n this.exposeAPI = this.exposeAPI.bind(this)\n this.handleInputFocus = this.handleInputFocus.bind(this)\n this.handleInputBlur = this.handleInputBlur.bind(this)\n this.handleChange = this.handleChange.bind(this)\n this.handleKeyDown = this.handleKeyDown.bind(this)\n this.handleInputClick = this.handleInputClick.bind(this)\n this.maybeAutoCompleteText = this.maybeAutoCompleteText.bind(this)\n }\n\n componentWillMount() {\n // this.refs is frozen, so we need to assign a new object to it\n this.refs = {}\n this._ignoreBlur = false\n this._ignoreFocus = false\n this._scrollOffset = null\n this._scrollTimer = null\n }\n\n componentWillUnmount() {\n clearTimeout(this._scrollTimer)\n this._scrollTimer = null\n }\n\n componentWillReceiveProps(nextProps) {\n if (this.state.highlightedIndex !== null) {\n this.setState(this.ensureHighlightedIndex)\n }\n if (nextProps.autoHighlight && (this.props.value !== nextProps.value || this.state.highlightedIndex === null)) {\n this.setState(this.maybeAutoCompleteText)\n }\n }\n\n componentDidMount() {\n if (this.isOpen()) {\n this.setMenuPositions()\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n if ((this.state.isOpen && !prevState.isOpen) || ('open' in this.props && this.props.open && !prevProps.open))\n this.setMenuPositions()\n\n this.maybeScrollItemIntoView()\n if (prevState.isOpen !== this.state.isOpen) {\n this.props.onMenuVisibilityChange(this.state.isOpen)\n }\n }\n\n exposeAPI(el) {\n this.refs.input = el\n IMPERATIVE_API.forEach(ev => this[ev] = (el && el[ev] && el[ev].bind(el)))\n }\n\n maybeScrollItemIntoView() {\n if (this.isOpen() && this.state.highlightedIndex !== null) {\n const itemNode = this.refs[`item-${this.state.highlightedIndex}`]\n const menuNode = this.refs.menu\n scrollIntoView(\n findDOMNode(itemNode),\n findDOMNode(menuNode),\n { onlyScrollIfNeeded: true }\n )\n }\n }\n\n handleKeyDown(event) {\n if (Autocomplete.keyDownHandlers[event.key])\n Autocomplete.keyDownHandlers[event.key].call(this, event)\n else if (!this.isOpen()) {\n this.setState({\n isOpen: true\n })\n }\n }\n\n handleChange(event) {\n this.props.onChange(event, event.target.value)\n }\n\n static keyDownHandlers = {\n ArrowDown(event) {\n event.preventDefault()\n const items = this.getFilteredItems(this.props)\n if (!items.length) return\n const { highlightedIndex } = this.state\n let index = highlightedIndex === null ? -1 : highlightedIndex\n for (let i = 0; i < items.length ; i++) {\n const p = (index + i + 1) % items.length\n if (this.props.isItemSelectable(items[p])) {\n index = p\n break\n }\n }\n if (index > -1 && index !== highlightedIndex) {\n this.setState({\n highlightedIndex: index,\n isOpen: true,\n })\n }\n },\n\n ArrowUp(event) {\n event.preventDefault()\n const items = this.getFilteredItems(this.props)\n if (!items.length) return\n const { highlightedIndex } = this.state\n let index = highlightedIndex === null ? items.length : highlightedIndex\n for (let i = 0; i < items.length ; i++) {\n const p = (index - (1 + i) + items.length) % items.length\n if (this.props.isItemSelectable(items[p])) {\n index = p\n break\n }\n }\n if (index !== items.length) {\n this.setState({\n highlightedIndex: index,\n isOpen: true,\n })\n }\n },\n\n Enter(event) {\n // Key code 229 is used for selecting items from character selectors (Pinyin, Kana, etc)\n if (event.keyCode !== 13) return\n // In case the user is currently hovering over the menu\n this.setIgnoreBlur(false)\n if (!this.isOpen()) {\n // menu is closed so there is no selection to accept -> do nothing\n return\n }\n else if (this.state.highlightedIndex == null) {\n // input has focus but no menu item is selected + enter is hit -> close the menu, highlight whatever's in input\n this.setState({\n isOpen: false\n }, () => {\n this.refs.input.select()\n })\n }\n else {\n // text entered + menu item has been highlighted + enter is hit -> update value to that of selected menu item, close the menu\n event.preventDefault()\n const item = this.getFilteredItems(this.props)[this.state.highlightedIndex]\n const value = this.props.getItemValue(item)\n this.setState({\n isOpen: false,\n highlightedIndex: null\n }, () => {\n //this.refs.input.focus() // TODO: file issue\n this.refs.input.setSelectionRange(\n value.length,\n value.length\n )\n this.props.onSelect(value, item)\n })\n }\n },\n\n Escape() {\n // In case the user is currently hovering over the menu\n this.setIgnoreBlur(false)\n this.setState({\n highlightedIndex: null,\n isOpen: false\n })\n },\n\n Tab() {\n // In case the user is currently hovering over the menu\n this.setIgnoreBlur(false)\n },\n }\n\n getFilteredItems(props) {\n let items = props.items\n\n if (props.shouldItemRender) {\n items = items.filter((item) => (\n props.shouldItemRender(item, props.value)\n ))\n }\n\n if (props.sortItems) {\n items.sort((a, b) => (\n props.sortItems(a, b, props.value)\n ))\n }\n\n return items\n }\n\n maybeAutoCompleteText(state, props) {\n const { highlightedIndex } = state\n const { value, getItemValue } = props\n let index = highlightedIndex === null ? 0 : highlightedIndex\n let items = this.getFilteredItems(props)\n for (let i = 0; i < items.length ; i++) {\n if (props.isItemSelectable(items[index]))\n break\n index = (index + 1) % items.length\n }\n const matchedItem = items[index] && props.isItemSelectable(items[index]) ? items[index] : null\n if (value !== '' && matchedItem) {\n const itemValue = getItemValue(matchedItem)\n const itemValueDoesMatch = (itemValue.toLowerCase().indexOf(\n value.toLowerCase()\n ) === 0)\n if (itemValueDoesMatch) {\n return { highlightedIndex: index }\n }\n }\n return { highlightedIndex: null }\n }\n\n ensureHighlightedIndex(state, props) {\n if (state.highlightedIndex >= this.getFilteredItems(props).length) {\n return { highlightedIndex: null }\n }\n }\n\n setMenuPositions() {\n const node = this.refs.input\n const rect = node.getBoundingClientRect()\n const computedStyle = global.window.getComputedStyle(node)\n const marginBottom = parseInt(computedStyle.marginBottom, 10) || 0\n const marginLeft = parseInt(computedStyle.marginLeft, 10) || 0\n const marginRight = parseInt(computedStyle.marginRight, 10) || 0\n this.setState({\n menuTop: rect.bottom + marginBottom,\n menuLeft: rect.left + marginLeft,\n menuWidth: rect.width + marginLeft + marginRight\n })\n }\n\n highlightItemFromMouse(index) {\n this.setState({ highlightedIndex: index })\n }\n\n selectItemFromMouse(item) {\n const value = this.props.getItemValue(item)\n // The menu will de-render before a mouseLeave event\n // happens. Clear the flag to release control over focus\n this.setIgnoreBlur(false)\n this.setState({\n isOpen: false,\n highlightedIndex: null\n }, () => {\n this.props.onSelect(value, item)\n })\n }\n\n setIgnoreBlur(ignore) {\n this._ignoreBlur = ignore\n }\n\n renderMenu() {\n const items = this.getFilteredItems(this.props).map((item, index) => {\n const element = this.props.renderItem(\n item,\n this.state.highlightedIndex === index,\n { cursor: 'default' }\n )\n return React.cloneElement(element, {\n onMouseEnter: this.props.isItemSelectable(item) ?\n () => this.highlightItemFromMouse(index) : null,\n onClick: this.props.isItemSelectable(item) ?\n () => this.selectItemFromMouse(item) : null,\n ref: e => this.refs[`item-${index}`] = e,\n })\n })\n const style = {\n left: this.state.menuLeft,\n top: this.state.menuTop,\n minWidth: this.state.menuWidth,\n }\n const menu = this.props.renderMenu(items, this.props.value, style)\n return React.cloneElement(menu, {\n ref: e => this.refs.menu = e,\n // Ignore blur to prevent menu from de-rendering before we can process click\n onTouchStart: () => this.setIgnoreBlur(true),\n onMouseEnter: () => this.setIgnoreBlur(true),\n onMouseLeave: () => this.setIgnoreBlur(false),\n })\n }\n\n handleInputBlur(event) {\n if (this._ignoreBlur) {\n this._ignoreFocus = true\n this._scrollOffset = getScrollOffset()\n this.refs.input.focus()\n return\n }\n let setStateCallback\n const { highlightedIndex } = this.state\n if (this.props.selectOnBlur && highlightedIndex !== null) {\n const items = this.getFilteredItems(this.props)\n const item = items[highlightedIndex]\n const value = this.props.getItemValue(item)\n setStateCallback = () => this.props.onSelect(value, item)\n }\n this.setState({\n isOpen: false,\n highlightedIndex: null\n }, setStateCallback)\n const { onBlur } = this.props.inputProps\n if (onBlur) {\n onBlur(event)\n }\n }\n\n handleInputFocus(event) {\n if (this._ignoreFocus) {\n this._ignoreFocus = false\n const { x, y } = this._scrollOffset\n this._scrollOffset = null\n // Focus will cause the browser to scroll the into view.\n // This can cause the mouse coords to change, which in turn\n // could cause a new highlight to happen, cancelling the click\n // event (when selecting with the mouse)\n window.scrollTo(x, y)\n // Some browsers wait until all focus event handlers have been\n // processed before scrolling the into view, so let's\n // scroll again on the next tick to ensure we're back to where\n // the user was before focus was lost. We could do the deferred\n // scroll only, but that causes a jarring split second jump in\n // some browsers that scroll before the focus event handlers\n // are triggered.\n clearTimeout(this._scrollTimer)\n this._scrollTimer = setTimeout(() => {\n this._scrollTimer = null\n window.scrollTo(x, y)\n }, 0)\n return\n }\n this.setState({ isOpen: true })\n const { onFocus } = this.props.inputProps\n if (onFocus) {\n onFocus(event)\n }\n }\n\n isInputFocused() {\n const el = this.refs.input\n return el.ownerDocument && (el === el.ownerDocument.activeElement)\n }\n\n handleInputClick() {\n // Input will not be focused if it's disabled\n if (this.isInputFocused() && !this.isOpen())\n this.setState({ isOpen: true })\n }\n\n composeEventHandlers(internal, external) {\n return external\n ? e => { internal(e); external(e) }\n : internal\n }\n\n isOpen() {\n return 'open' in this.props ? this.props.open : this.state.isOpen\n }\n\n render() {\n if (this.props.debug) { // you don't like it, you love it\n this._debugStates.push({\n id: this._debugStates.length,\n state: this.state\n })\n }\n\n const { inputProps } = this.props\n const open = this.isOpen()\n return (\n
\n {this.props.renderInput({\n ...inputProps,\n 'aria-autocomplete': 'list',\n autoComplete: 'off',\n ref: this.exposeAPI,\n onFocus: this.handleInputFocus,\n onBlur: this.handleInputBlur,\n onChange: this.handleChange,\n onKeyDown: this.composeEventHandlers(this.handleKeyDown, inputProps.onKeyDown),\n onClick: this.composeEventHandlers(this.handleInputClick, inputProps.onClick),\n value: this.props.value,\n })}\n {open && this.renderMenu()}\n {this.props.debug && (\n
\n            {JSON.stringify(this._debugStates.slice(Math.max(0, this._debugStates.length - 5), this._debugStates.length), null, 2)}\n          
\n )}\n
\n )\n }\n}\n\nmodule.exports = Autocomplete\n\n", + "module.exports = require('./lib/dom-scroll-into-view');\n", + "var util = require('./util');\n\nfunction scrollIntoView(elem, container, config) {\n config = config || {};\n // document 归一化到 window\n if (container.nodeType === 9) {\n container = util.getWindow(container);\n }\n\n var allowHorizontalScroll = config.allowHorizontalScroll;\n var onlyScrollIfNeeded = config.onlyScrollIfNeeded;\n var alignWithTop = config.alignWithTop;\n var alignWithLeft = config.alignWithLeft;\n\n allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll;\n\n var isWin = util.isWindow(container);\n var elemOffset = util.offset(elem);\n var eh = util.outerHeight(elem);\n var ew = util.outerWidth(elem);\n var containerOffset, ch, cw, containerScroll,\n diffTop, diffBottom, win,\n winScroll, ww, wh;\n\n if (isWin) {\n win = container;\n wh = util.height(win);\n ww = util.width(win);\n winScroll = {\n left: util.scrollLeft(win),\n top: util.scrollTop(win)\n };\n // elem 相对 container 可视视窗的距离\n diffTop = {\n left: elemOffset.left - winScroll.left,\n top: elemOffset.top - winScroll.top\n };\n diffBottom = {\n left: elemOffset.left + ew - (winScroll.left + ww),\n top: elemOffset.top + eh - (winScroll.top + wh)\n };\n containerScroll = winScroll;\n } else {\n containerOffset = util.offset(container);\n ch = container.clientHeight;\n cw = container.clientWidth;\n containerScroll = {\n left: container.scrollLeft,\n top: container.scrollTop\n };\n // elem 相对 container 可视视窗的距离\n // 注意边框, offset 是边框到根节点\n diffTop = {\n left: elemOffset.left - (containerOffset.left +\n (parseFloat(util.css(container, 'borderLeftWidth')) || 0)),\n top: elemOffset.top - (containerOffset.top +\n (parseFloat(util.css(container, 'borderTopWidth')) || 0))\n };\n diffBottom = {\n left: elemOffset.left + ew -\n (containerOffset.left + cw +\n (parseFloat(util.css(container, 'borderRightWidth')) || 0)),\n top: elemOffset.top + eh -\n (containerOffset.top + ch +\n (parseFloat(util.css(container, 'borderBottomWidth')) || 0))\n };\n }\n\n if (diffTop.top < 0 || diffBottom.top > 0) {\n // 强制向上\n if (alignWithTop === true) {\n util.scrollTop(container, containerScroll.top + diffTop.top);\n } else if (alignWithTop === false) {\n util.scrollTop(container, containerScroll.top + diffBottom.top);\n } else {\n // 自动调整\n if (diffTop.top < 0) {\n util.scrollTop(container, containerScroll.top + diffTop.top);\n } else {\n util.scrollTop(container, containerScroll.top + diffBottom.top);\n }\n }\n } else {\n if (!onlyScrollIfNeeded) {\n alignWithTop = alignWithTop === undefined ? true : !!alignWithTop;\n if (alignWithTop) {\n util.scrollTop(container, containerScroll.top + diffTop.top);\n } else {\n util.scrollTop(container, containerScroll.top + diffBottom.top);\n }\n }\n }\n\n if (allowHorizontalScroll) {\n if (diffTop.left < 0 || diffBottom.left > 0) {\n // 强制向上\n if (alignWithLeft === true) {\n util.scrollLeft(container, containerScroll.left + diffTop.left);\n } else if (alignWithLeft === false) {\n util.scrollLeft(container, containerScroll.left + diffBottom.left);\n } else {\n // 自动调整\n if (diffTop.left < 0) {\n util.scrollLeft(container, containerScroll.left + diffTop.left);\n } else {\n util.scrollLeft(container, containerScroll.left + diffBottom.left);\n }\n }\n } else {\n if (!onlyScrollIfNeeded) {\n alignWithLeft = alignWithLeft === undefined ? true : !!alignWithLeft;\n if (alignWithLeft) {\n util.scrollLeft(container, containerScroll.left + diffTop.left);\n } else {\n util.scrollLeft(container, containerScroll.left + diffBottom.left);\n }\n }\n }\n }\n}\n\nmodule.exports = scrollIntoView;\n", + "var RE_NUM = /[\\-+]?(?:\\d*\\.|)\\d+(?:[eE][\\-+]?\\d+|)/.source;\n\nfunction getClientPosition(elem) {\n var box, x, y;\n var doc = elem.ownerDocument;\n var body = doc.body;\n var docElem = doc && doc.documentElement;\n // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式\n box = elem.getBoundingClientRect();\n\n // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop\n // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确\n // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin\n\n x = box.left;\n y = box.top;\n\n // In IE, most of the time, 2 extra pixels are added to the top and left\n // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and\n // IE6 standards mode, this border can be overridden by setting the\n // document element's border to zero -- thus, we cannot rely on the\n // offset always being 2 pixels.\n\n // In quirks mode, the offset can be determined by querying the body's\n // clientLeft/clientTop, but in standards mode, it is found by querying\n // the document element's clientLeft/clientTop. Since we already called\n // getClientBoundingRect we have already forced a reflow, so it is not\n // too expensive just to query them all.\n\n // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的\n // 窗口边框标准是设 documentElement ,quirks 时设置 body\n // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去\n // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置\n // 标准 ie 下 docElem.clientTop 就是 border-top\n // ie7 html 即窗口边框改变不了。永远为 2\n // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0\n\n x -= docElem.clientLeft || body.clientLeft || 0;\n y -= docElem.clientTop || body.clientTop || 0;\n\n return {left: x, top: y};\n}\n\nfunction getScroll(w, top) {\n var ret = w['page' + (top ? 'Y' : 'X') + 'Offset'];\n var method = 'scroll' + (top ? 'Top' : 'Left');\n if (typeof ret !== 'number') {\n var d = w.document;\n //ie6,7,8 standard mode\n ret = d.documentElement[method];\n if (typeof ret !== 'number') {\n //quirks mode\n ret = d.body[method];\n }\n }\n return ret;\n}\n\nfunction getScrollLeft(w) {\n return getScroll(w);\n}\n\nfunction getScrollTop(w) {\n return getScroll(w, true);\n}\n\nfunction getOffset(el) {\n var pos = getClientPosition(el);\n var doc = el.ownerDocument;\n var w = doc.defaultView || doc.parentWindow;\n pos.left += getScrollLeft(w);\n pos.top += getScrollTop(w);\n return pos;\n}\nfunction _getComputedStyle(elem, name, computedStyle) {\n var val = '';\n var d = elem.ownerDocument;\n\n // https://github.com/kissyteam/kissy/issues/61\n if ((computedStyle = (computedStyle || d.defaultView.getComputedStyle(elem, null)))) {\n val = computedStyle.getPropertyValue(name) || computedStyle[name];\n }\n\n return val;\n}\n\nvar _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i');\nvar RE_POS = /^(top|right|bottom|left)$/,\n CURRENT_STYLE = 'currentStyle',\n RUNTIME_STYLE = 'runtimeStyle',\n LEFT = 'left',\n PX = 'px';\n\nfunction _getComputedStyleIE(elem, name) {\n // currentStyle maybe null\n // http://msdn.microsoft.com/en-us/library/ms535231.aspx\n var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name];\n\n // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值\n // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19\n // 在 ie 下不对,需要直接用 offset 方式\n // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了\n\n // From the awesome hack by Dean Edwards\n // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291\n // If we're not dealing with a regular pixel number\n // but a number that has a weird ending, we need to convert it to pixels\n // exclude left right for relativity\n if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {\n // Remember the original values\n var style = elem.style,\n left = style[LEFT],\n rsLeft = elem[RUNTIME_STYLE][LEFT];\n\n // prevent flashing of content\n elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT];\n\n // Put in the new values to get a computed value out\n style[LEFT] = name === 'fontSize' ? '1em' : (ret || 0);\n ret = style.pixelLeft + PX;\n\n // Revert the changed values\n style[LEFT] = left;\n\n elem[RUNTIME_STYLE][LEFT] = rsLeft;\n }\n return ret === '' ? 'auto' : ret;\n}\n\nvar getComputedStyleX;\nif (typeof window !== 'undefined') {\n getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;\n}\n\n// 设置 elem 相对 elem.ownerDocument 的坐标\nfunction setOffset(elem, offset) {\n // set position first, in-case top/left are set even on static elem\n if (css(elem, 'position') === 'static') {\n elem.style.position = 'relative';\n }\n\n var old = getOffset(elem),\n ret = {},\n current, key;\n\n for (key in offset) {\n current = parseFloat(css(elem, key)) || 0;\n ret[key] = current + offset[key] - old[key];\n }\n css(elem, ret);\n}\n\nfunction each(arr, fn) {\n for (var i = 0; i < arr.length; i++) {\n fn(arr[i]);\n }\n}\n\nfunction isBorderBoxFn(elem) {\n return getComputedStyleX(elem, 'boxSizing') === 'border-box';\n}\n\nvar BOX_MODELS = ['margin', 'border', 'padding'],\n CONTENT_INDEX = -1,\n PADDING_INDEX = 2,\n BORDER_INDEX = 1,\n MARGIN_INDEX = 0;\n\nfunction swap(elem, options, callback) {\n var old = {},\n style = elem.style,\n name;\n\n // Remember the old values, and insert the new ones\n for (name in options) {\n old[name] = style[name];\n style[name] = options[name];\n }\n\n callback.call(elem);\n\n // Revert the old values\n for (name in options) {\n style[name] = old[name];\n }\n}\n\nfunction getPBMWidth(elem, props, which) {\n var value = 0, prop, j, i;\n for (j = 0; j < props.length; j++) {\n prop = props[j];\n if (prop) {\n for (i = 0; i < which.length; i++) {\n var cssProp;\n if (prop === 'border') {\n cssProp = prop + which[i] + 'Width';\n } else {\n cssProp = prop + which[i];\n }\n value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;\n }\n }\n }\n return value;\n}\n\n/**\n * A crude way of determining if an object is a window\n * @member util\n */\nfunction isWindow(obj) {\n // must use == for ie8\n /*jshint eqeqeq:false*/\n return obj != null && obj == obj.window;\n}\n\nvar domUtils = {};\n\neach(['Width', 'Height'], function (name) {\n domUtils['doc' + name] = function (refWin) {\n var d = refWin.document;\n return Math.max(\n //firefox chrome documentElement.scrollHeight< body.scrollHeight\n //ie standard mode : documentElement.scrollHeight> body.scrollHeight\n d.documentElement['scroll' + name],\n //quirks : documentElement.scrollHeight 最大等于可视窗口多一点?\n d.body['scroll' + name],\n domUtils['viewport' + name](d));\n };\n\n domUtils['viewport' + name] = function (win) {\n // pc browser includes scrollbar in window.innerWidth\n var prop = 'client' + name,\n doc = win.document,\n body = doc.body,\n documentElement = doc.documentElement,\n documentElementProp = documentElement[prop];\n // 标准模式取 documentElement\n // backcompat 取 body\n return doc.compatMode === 'CSS1Compat' && documentElementProp ||\n body && body[prop] || documentElementProp;\n };\n});\n\n/*\n 得到元素的大小信息\n @param elem\n @param name\n @param {String} [extra] 'padding' : (css width) + padding\n 'border' : (css width) + padding + border\n 'margin' : (css width) + padding + border + margin\n */\nfunction getWH(elem, name, extra) {\n if (isWindow(elem)) {\n return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);\n } else if (elem.nodeType === 9) {\n return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);\n }\n var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'],\n borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight;\n var computedStyle = getComputedStyleX(elem);\n var isBorderBox = isBorderBoxFn(elem, computedStyle);\n var cssBoxValue = 0;\n if (borderBoxValue == null || borderBoxValue <= 0) {\n borderBoxValue = undefined;\n // Fall back to computed then un computed css if necessary\n cssBoxValue = getComputedStyleX(elem, name);\n if (cssBoxValue == null || (Number(cssBoxValue)) < 0) {\n cssBoxValue = elem.style[name] || 0;\n }\n // Normalize '', auto, and prepare for extra\n cssBoxValue = parseFloat(cssBoxValue) || 0;\n }\n if (extra === undefined) {\n extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;\n }\n var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;\n var val = borderBoxValue || cssBoxValue;\n if (extra === CONTENT_INDEX) {\n if (borderBoxValueOrIsBorderBox) {\n return val - getPBMWidth(elem, ['border', 'padding'],\n which, computedStyle);\n } else {\n return cssBoxValue;\n }\n } else if (borderBoxValueOrIsBorderBox) {\n return val + (extra === BORDER_INDEX ? 0 :\n (extra === PADDING_INDEX ?\n -getPBMWidth(elem, ['border'], which, computedStyle) :\n getPBMWidth(elem, ['margin'], which, computedStyle)));\n } else {\n return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra),\n which, computedStyle);\n }\n}\n\nvar cssShow = {position: 'absolute', visibility: 'hidden', display: 'block'};\n\n// fix #119 : https://github.com/kissyteam/kissy/issues/119\nfunction getWHIgnoreDisplay(elem) {\n var val, args = arguments;\n // in case elem is window\n // elem.offsetWidth === undefined\n if (elem.offsetWidth !== 0) {\n val = getWH.apply(undefined, args);\n } else {\n swap(elem, cssShow, function () {\n val = getWH.apply(undefined, args);\n });\n }\n return val;\n}\n\neach(['width', 'height'], function (name) {\n var first = name.charAt(0).toUpperCase() + name.slice(1);\n domUtils['outer' + first] = function (el, includeMargin) {\n return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);\n };\n var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];\n\n domUtils[name] = function (elem, val) {\n if (val !== undefined) {\n if (elem) {\n var computedStyle = getComputedStyleX(elem);\n var isBorderBox = isBorderBoxFn(elem);\n if (isBorderBox) {\n val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle);\n }\n return css(elem, name, val);\n }\n return;\n }\n return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);\n };\n});\n\nfunction css(el, name, value) {\n if (typeof name === 'object') {\n for (var i in name) {\n css(el, i, name[i]);\n }\n return;\n }\n if (typeof value !== 'undefined') {\n if (typeof value === 'number') {\n value = value + 'px';\n }\n el.style[name] = value;\n } else {\n return getComputedStyleX(el, name);\n }\n}\n\nfunction mix(to, from) {\n for (var i in from) {\n to[i] = from[i];\n }\n return to;\n}\n\nvar utils = module.exports = {\n getWindow: function (node) {\n var doc = node.ownerDocument || node;\n return doc.defaultView || doc.parentWindow;\n },\n offset: function (el, value) {\n if (typeof value !== 'undefined') {\n setOffset(el, value);\n } else {\n return getOffset(el);\n }\n },\n isWindow: isWindow,\n each: each,\n css: css,\n clone: function (obj) {\n var ret = {};\n for (var i in obj) {\n ret[i] = obj[i];\n }\n var overflow = obj.overflow;\n if (overflow) {\n for (i in obj) {\n ret.overflow[i] = obj.overflow[i];\n }\n }\n return ret;\n },\n mix: mix,\n scrollLeft: function (w, v) {\n if (isWindow(w)) {\n if (v === undefined) {\n return getScrollLeft(w);\n } else {\n window.scrollTo(v, getScrollTop(w));\n }\n } else {\n if (v === undefined) {\n return w.scrollLeft;\n } else {\n w.scrollLeft = v;\n }\n }\n },\n scrollTop: function (w, v) {\n if (isWindow(w)) {\n if (v === undefined) {\n return getScrollTop(w);\n } else {\n window.scrollTo(getScrollLeft(w), v);\n }\n } else {\n if (v === undefined) {\n return w.scrollTop;\n } else {\n w.scrollTop = v;\n }\n }\n },\n merge: function () {\n var ret = {};\n for (var i = 0; i < arguments.length; i++) {\n utils.mix(ret, arguments[i]);\n }\n return ret;\n },\n viewportWidth: 0,\n viewportHeight: 0\n};\n\nmix(utils, domUtils);\n", + "/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n", + "/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar printWarning = function() {};\n\nif (\"production\" !== 'production') {\n var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n var loggedTypeFailures = {};\n\n printWarning = function(text) {\n var message = 'Warning: ' + text;\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // --- Welcome to debugging React ---\n // This error was thrown as a convenience so that you can use this stack\n // to find the callsite that caused this warning to fire.\n throw new Error(message);\n } catch (x) {}\n };\n}\n\n/**\n * Assert that the values match with the type specs.\n * Error messages are memorized and will only be shown once.\n *\n * @param {object} typeSpecs Map of name to a ReactPropType\n * @param {object} values Runtime values that need to be type-checked\n * @param {string} location e.g. \"prop\", \"context\", \"child context\"\n * @param {string} componentName Name of the component for error messages.\n * @param {?Function} getStack Returns the component stack.\n * @private\n */\nfunction checkPropTypes(typeSpecs, values, location, componentName, getStack) {\n if (\"production\" !== 'production') {\n for (var typeSpecName in typeSpecs) {\n if (typeSpecs.hasOwnProperty(typeSpecName)) {\n var error;\n // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n var err = Error(\n (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +\n 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'\n );\n err.name = 'Invariant Violation';\n throw err;\n }\n error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);\n } catch (ex) {\n error = ex;\n }\n if (error && !(error instanceof Error)) {\n printWarning(\n (componentName || 'React class') + ': type specification of ' +\n location + ' `' + typeSpecName + '` is invalid; the type checker ' +\n 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +\n 'You may have forgotten to pass an argument to the type checker ' +\n 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +\n 'shape all require an argument).'\n )\n\n }\n if (error instanceof Error && !(error.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error.message] = true;\n\n var stack = getStack ? getStack() : '';\n\n printWarning(\n 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')\n );\n }\n }\n }\n }\n}\n\nmodule.exports = checkPropTypes;\n", + "/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n\nfunction emptyFunction() {}\n\nmodule.exports = function() {\n function shim(props, propName, componentName, location, propFullName, secret) {\n if (secret === ReactPropTypesSecret) {\n // It is still safe when called from React.\n return;\n }\n var err = new Error(\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use PropTypes.checkPropTypes() to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n err.name = 'Invariant Violation';\n throw err;\n };\n shim.isRequired = shim;\n function getShim() {\n return shim;\n };\n // Important!\n // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.\n var ReactPropTypes = {\n array: shim,\n bool: shim,\n func: shim,\n number: shim,\n object: shim,\n string: shim,\n symbol: shim,\n\n any: shim,\n arrayOf: getShim,\n element: shim,\n instanceOf: getShim,\n node: shim,\n objectOf: getShim,\n oneOf: getShim,\n oneOfType: getShim,\n shape: getShim,\n exact: getShim\n };\n\n ReactPropTypes.checkPropTypes = emptyFunction;\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n", + "/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar assign = require('object-assign');\n\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\nvar checkPropTypes = require('./checkPropTypes');\n\nvar printWarning = function() {};\n\nif (\"production\" !== 'production') {\n printWarning = function(text) {\n var message = 'Warning: ' + text;\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // --- Welcome to debugging React ---\n // This error was thrown as a convenience so that you can use this stack\n // to find the callsite that caused this warning to fire.\n throw new Error(message);\n } catch (x) {}\n };\n}\n\nfunction emptyFunctionThatReturnsNull() {\n return null;\n}\n\nmodule.exports = function(isValidElement, throwOnDirectAccess) {\n /* global Symbol */\n var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;\n var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.\n\n /**\n * Returns the iterator method function contained on the iterable object.\n *\n * Be sure to invoke the function with the iterable as context:\n *\n * var iteratorFn = getIteratorFn(myIterable);\n * if (iteratorFn) {\n * var iterator = iteratorFn.call(myIterable);\n * ...\n * }\n *\n * @param {?object} maybeIterable\n * @return {?function}\n */\n function getIteratorFn(maybeIterable) {\n var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);\n if (typeof iteratorFn === 'function') {\n return iteratorFn;\n }\n }\n\n /**\n * Collection of methods that allow declaration and validation of props that are\n * supplied to React components. Example usage:\n *\n * var Props = require('ReactPropTypes');\n * var MyArticle = React.createClass({\n * propTypes: {\n * // An optional string prop named \"description\".\n * description: Props.string,\n *\n * // A required enum prop named \"category\".\n * category: Props.oneOf(['News','Photos']).isRequired,\n *\n * // A prop named \"dialog\" that requires an instance of Dialog.\n * dialog: Props.instanceOf(Dialog).isRequired\n * },\n * render: function() { ... }\n * });\n *\n * A more formal specification of how these methods are used:\n *\n * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)\n * decl := ReactPropTypes.{type}(.isRequired)?\n *\n * Each and every declaration produces a function with the same signature. This\n * allows the creation of custom validation functions. For example:\n *\n * var MyLink = React.createClass({\n * propTypes: {\n * // An optional string or URI prop named \"href\".\n * href: function(props, propName, componentName) {\n * var propValue = props[propName];\n * if (propValue != null && typeof propValue !== 'string' &&\n * !(propValue instanceof URI)) {\n * return new Error(\n * 'Expected a string or an URI for ' + propName + ' in ' +\n * componentName\n * );\n * }\n * }\n * },\n * render: function() {...}\n * });\n *\n * @internal\n */\n\n var ANONYMOUS = '<>';\n\n // Important!\n // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.\n var ReactPropTypes = {\n array: createPrimitiveTypeChecker('array'),\n bool: createPrimitiveTypeChecker('boolean'),\n func: createPrimitiveTypeChecker('function'),\n number: createPrimitiveTypeChecker('number'),\n object: createPrimitiveTypeChecker('object'),\n string: createPrimitiveTypeChecker('string'),\n symbol: createPrimitiveTypeChecker('symbol'),\n\n any: createAnyTypeChecker(),\n arrayOf: createArrayOfTypeChecker,\n element: createElementTypeChecker(),\n instanceOf: createInstanceTypeChecker,\n node: createNodeChecker(),\n objectOf: createObjectOfTypeChecker,\n oneOf: createEnumTypeChecker,\n oneOfType: createUnionTypeChecker,\n shape: createShapeTypeChecker,\n exact: createStrictShapeTypeChecker,\n };\n\n /**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\n /*eslint-disable no-self-compare*/\n function is(x, y) {\n // SameValue algorithm\n if (x === y) {\n // Steps 1-5, 7-10\n // Steps 6.b-6.e: +0 != -0\n return x !== 0 || 1 / x === 1 / y;\n } else {\n // Step 6.a: NaN == NaN\n return x !== x && y !== y;\n }\n }\n /*eslint-enable no-self-compare*/\n\n /**\n * We use an Error-like object for backward compatibility as people may call\n * PropTypes directly and inspect their output. However, we don't use real\n * Errors anymore. We don't inspect their stack anyway, and creating them\n * is prohibitively expensive if they are created too often, such as what\n * happens in oneOfType() for any type before the one that matched.\n */\n function PropTypeError(message) {\n this.message = message;\n this.stack = '';\n }\n // Make `instanceof Error` still work for returned errors.\n PropTypeError.prototype = Error.prototype;\n\n function createChainableTypeChecker(validate) {\n if (\"production\" !== 'production') {\n var manualPropTypeCallCache = {};\n var manualPropTypeWarningCount = 0;\n }\n function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {\n componentName = componentName || ANONYMOUS;\n propFullName = propFullName || propName;\n\n if (secret !== ReactPropTypesSecret) {\n if (throwOnDirectAccess) {\n // New behavior only for users of `prop-types` package\n var err = new Error(\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use `PropTypes.checkPropTypes()` to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n err.name = 'Invariant Violation';\n throw err;\n } else if (\"production\" !== 'production' && typeof console !== 'undefined') {\n // Old behavior for people using React.PropTypes\n var cacheKey = componentName + ':' + propName;\n if (\n !manualPropTypeCallCache[cacheKey] &&\n // Avoid spamming the console because they are often not actionable except for lib authors\n manualPropTypeWarningCount < 3\n ) {\n printWarning(\n 'You are manually calling a React.PropTypes validation ' +\n 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +\n 'and will throw in the standalone `prop-types` package. ' +\n 'You may be seeing this warning due to a third-party PropTypes ' +\n 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'\n );\n manualPropTypeCallCache[cacheKey] = true;\n manualPropTypeWarningCount++;\n }\n }\n }\n if (props[propName] == null) {\n if (isRequired) {\n if (props[propName] === null) {\n return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));\n }\n return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));\n }\n return null;\n } else {\n return validate(props, propName, componentName, location, propFullName);\n }\n }\n\n var chainedCheckType = checkType.bind(null, false);\n chainedCheckType.isRequired = checkType.bind(null, true);\n\n return chainedCheckType;\n }\n\n function createPrimitiveTypeChecker(expectedType) {\n function validate(props, propName, componentName, location, propFullName, secret) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== expectedType) {\n // `propValue` being instance of, say, date/regexp, pass the 'object'\n // check, but we can offer a more precise error message here rather than\n // 'of type `object`'.\n var preciseType = getPreciseType(propValue);\n\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createAnyTypeChecker() {\n return createChainableTypeChecker(emptyFunctionThatReturnsNull);\n }\n\n function createArrayOfTypeChecker(typeChecker) {\n function validate(props, propName, componentName, location, propFullName) {\n if (typeof typeChecker !== 'function') {\n return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');\n }\n var propValue = props[propName];\n if (!Array.isArray(propValue)) {\n var propType = getPropType(propValue);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));\n }\n for (var i = 0; i < propValue.length; i++) {\n var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);\n if (error instanceof Error) {\n return error;\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createElementTypeChecker() {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n if (!isValidElement(propValue)) {\n var propType = getPropType(propValue);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createInstanceTypeChecker(expectedClass) {\n function validate(props, propName, componentName, location, propFullName) {\n if (!(props[propName] instanceof expectedClass)) {\n var expectedClassName = expectedClass.name || ANONYMOUS;\n var actualClassName = getClassName(props[propName]);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createEnumTypeChecker(expectedValues) {\n if (!Array.isArray(expectedValues)) {\n \"production\" !== 'production' ? printWarning('Invalid argument supplied to oneOf, expected an instance of array.') : void 0;\n return emptyFunctionThatReturnsNull;\n }\n\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n for (var i = 0; i < expectedValues.length; i++) {\n if (is(propValue, expectedValues[i])) {\n return null;\n }\n }\n\n var valuesString = JSON.stringify(expectedValues);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));\n }\n return createChainableTypeChecker(validate);\n }\n\n function createObjectOfTypeChecker(typeChecker) {\n function validate(props, propName, componentName, location, propFullName) {\n if (typeof typeChecker !== 'function') {\n return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');\n }\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));\n }\n for (var key in propValue) {\n if (propValue.hasOwnProperty(key)) {\n var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error instanceof Error) {\n return error;\n }\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createUnionTypeChecker(arrayOfTypeCheckers) {\n if (!Array.isArray(arrayOfTypeCheckers)) {\n \"production\" !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;\n return emptyFunctionThatReturnsNull;\n }\n\n for (var i = 0; i < arrayOfTypeCheckers.length; i++) {\n var checker = arrayOfTypeCheckers[i];\n if (typeof checker !== 'function') {\n printWarning(\n 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +\n 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'\n );\n return emptyFunctionThatReturnsNull;\n }\n }\n\n function validate(props, propName, componentName, location, propFullName) {\n for (var i = 0; i < arrayOfTypeCheckers.length; i++) {\n var checker = arrayOfTypeCheckers[i];\n if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {\n return null;\n }\n }\n\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));\n }\n return createChainableTypeChecker(validate);\n }\n\n function createNodeChecker() {\n function validate(props, propName, componentName, location, propFullName) {\n if (!isNode(props[propName])) {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createShapeTypeChecker(shapeTypes) {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));\n }\n for (var key in shapeTypes) {\n var checker = shapeTypes[key];\n if (!checker) {\n continue;\n }\n var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error) {\n return error;\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createStrictShapeTypeChecker(shapeTypes) {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));\n }\n // We need to check all keys in case some are required but missing from\n // props.\n var allKeys = assign({}, props[propName], shapeTypes);\n for (var key in allKeys) {\n var checker = shapeTypes[key];\n if (!checker) {\n return new PropTypeError(\n 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +\n '\\nBad object: ' + JSON.stringify(props[propName], null, ' ') +\n '\\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')\n );\n }\n var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error) {\n return error;\n }\n }\n return null;\n }\n\n return createChainableTypeChecker(validate);\n }\n\n function isNode(propValue) {\n switch (typeof propValue) {\n case 'number':\n case 'string':\n case 'undefined':\n return true;\n case 'boolean':\n return !propValue;\n case 'object':\n if (Array.isArray(propValue)) {\n return propValue.every(isNode);\n }\n if (propValue === null || isValidElement(propValue)) {\n return true;\n }\n\n var iteratorFn = getIteratorFn(propValue);\n if (iteratorFn) {\n var iterator = iteratorFn.call(propValue);\n var step;\n if (iteratorFn !== propValue.entries) {\n while (!(step = iterator.next()).done) {\n if (!isNode(step.value)) {\n return false;\n }\n }\n } else {\n // Iterator will provide entry [k,v] tuples rather than values.\n while (!(step = iterator.next()).done) {\n var entry = step.value;\n if (entry) {\n if (!isNode(entry[1])) {\n return false;\n }\n }\n }\n }\n } else {\n return false;\n }\n\n return true;\n default:\n return false;\n }\n }\n\n function isSymbol(propType, propValue) {\n // Native Symbol.\n if (propType === 'symbol') {\n return true;\n }\n\n // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'\n if (propValue['@@toStringTag'] === 'Symbol') {\n return true;\n }\n\n // Fallback for non-spec compliant Symbols which are polyfilled.\n if (typeof Symbol === 'function' && propValue instanceof Symbol) {\n return true;\n }\n\n return false;\n }\n\n // Equivalent of `typeof` but with special handling for array and regexp.\n function getPropType(propValue) {\n var propType = typeof propValue;\n if (Array.isArray(propValue)) {\n return 'array';\n }\n if (propValue instanceof RegExp) {\n // Old webkits (at least until Android 4.0) return 'function' rather than\n // 'object' for typeof a RegExp. We'll normalize this here so that /bla/\n // passes PropTypes.object.\n return 'object';\n }\n if (isSymbol(propType, propValue)) {\n return 'symbol';\n }\n return propType;\n }\n\n // This handles more types than `getPropType`. Only used for error messages.\n // See `createPrimitiveTypeChecker`.\n function getPreciseType(propValue) {\n if (typeof propValue === 'undefined' || propValue === null) {\n return '' + propValue;\n }\n var propType = getPropType(propValue);\n if (propType === 'object') {\n if (propValue instanceof Date) {\n return 'date';\n } else if (propValue instanceof RegExp) {\n return 'regexp';\n }\n }\n return propType;\n }\n\n // Returns a string that is postfixed to a warning about an invalid type.\n // For example, \"undefined\" or \"of type array\"\n function getPostfixForTypeWarning(value) {\n var type = getPreciseType(value);\n switch (type) {\n case 'array':\n case 'object':\n return 'an ' + type;\n case 'boolean':\n case 'date':\n case 'regexp':\n return 'a ' + type;\n default:\n return type;\n }\n }\n\n // Returns class name of the object, if any.\n function getClassName(propValue) {\n if (!propValue.constructor || !propValue.constructor.name) {\n return ANONYMOUS;\n }\n return propValue.constructor.name;\n }\n\n ReactPropTypes.checkPropTypes = checkPropTypes;\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n", + "/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (\"production\" !== 'production') {\n var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&\n Symbol.for &&\n Symbol.for('react.element')) ||\n 0xeac7;\n\n var isValidElement = function(object) {\n return typeof object === 'object' &&\n object !== null &&\n object.$$typeof === REACT_ELEMENT_TYPE;\n };\n\n // By explicitly using `prop-types` you are opting into new development behavior.\n // http://fb.me/prop-types-in-prod\n var throwOnDirectAccess = true;\n module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess);\n} else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = require('./factoryWithThrowingShims')();\n}\n", + "/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';\n\nmodule.exports = ReactPropTypesSecret;\n" + ], + "sourceRoot": "" +} \ No newline at end of file diff --git a/dist/react-autocomplete.min.js b/dist/react-autocomplete.min.js new file mode 100644 index 00000000..e4fcce28 --- /dev/null +++ b/dist/react-autocomplete.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):e.ReactAutocomplete=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){return function(){function t(n,r,o){function i(u,s){if(!r[u]){if(!n[u]){var a="function"==typeof e&&e;if(!s&&a)return a(u,!0);if(l)return l(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[u]={exports:{}};n[u][0].call(f.exports,function(e){return i(n[u][1][e]||e)},f,f.exports,t,n,r,o)}return r[u].exports}for(var l="function"==typeof e&&e,u=0;u=this.getFilteredItems(t).length)return{highlightedIndex:null}}},{key:"setMenuPositions",value:function(){var e=this.refs.input,t=e.getBoundingClientRect(),r=n.window.getComputedStyle(e),o=parseInt(r.marginBottom,10)||0,i=parseInt(r.marginLeft,10)||0,l=parseInt(r.marginRight,10)||0;this.setState({menuTop:t.bottom+o,menuLeft:t.left+i,menuWidth:t.width+i+l})}},{key:"highlightItemFromMouse",value:function(e){this.setState({highlightedIndex:e})}},{key:"selectItemFromMouse",value:function(e){var t=this,n=this.props.getItemValue(e);this.setIgnoreBlur(!1),this.setState({isOpen:!1,highlightedIndex:null},function(){t.props.onSelect(n,e)})}},{key:"setIgnoreBlur",value:function(e){this._ignoreBlur=e}},{key:"renderMenu",value:function(){var e=this,t=this.getFilteredItems(this.props).map(function(t,n){var r=e.props.renderItem(t,e.state.highlightedIndex===n,{cursor:"default"});return a.cloneElement(r,{onMouseEnter:e.props.isItemSelectable(t)?function(){return e.highlightItemFromMouse(n)}:null,onClick:e.props.isItemSelectable(t)?function(){return e.selectItemFromMouse(t)}:null,ref:function(t){return e.refs["item-"+n]=t}})}),n={left:this.state.menuLeft,top:this.state.menuTop,minWidth:this.state.menuWidth},r=this.props.renderMenu(t,this.props.value,n);return a.cloneElement(r,{ref:function(t){return e.refs.menu=t},onTouchStart:function(){return e.setIgnoreBlur(!0)},onMouseEnter:function(){return e.setIgnoreBlur(!0)},onMouseLeave:function(){return e.setIgnoreBlur(!1)}})}},{key:"handleInputBlur",value:function(e){var t=this;if(this._ignoreBlur)return this._ignoreFocus=!0,this._scrollOffset=l(),void this.refs.input.focus();var n=void 0,r=this.state.highlightedIndex;if(this.props.selectOnBlur&&null!==r){var o=this.getFilteredItems(this.props),i=o[r],u=this.props.getItemValue(i);n=function(){return t.props.onSelect(u,i)}}this.setState({isOpen:!1,highlightedIndex:null},n);var s=this.props.inputProps.onBlur;s&&s(e)}},{key:"handleInputFocus",value:function(e){var t=this;if(this._ignoreFocus){this._ignoreFocus=!1;var n=this._scrollOffset,r=n.x,o=n.y;return this._scrollOffset=null,window.scrollTo(r,o),clearTimeout(this._scrollTimer),void(this._scrollTimer=setTimeout(function(){t._scrollTimer=null,window.scrollTo(r,o)},0))}this.setState({isOpen:!0});var i=this.props.inputProps.onFocus;i&&i(e)}},{key:"isInputFocused",value:function(){var e=this.refs.input;return e.ownerDocument&&e===e.ownerDocument.activeElement}},{key:"handleInputClick",value:function(){this.isInputFocused()&&!this.isOpen()&&this.setState({isOpen:!0})}},{key:"composeEventHandlers",value:function(e,t){return t?function(n){e(n),t(n)}:e}},{key:"isOpen",value:function(){return"open"in this.props?this.props.open:this.state.isOpen}},{key:"render",value:function(){this.props.debug&&this._debugStates.push({id:this._debugStates.length,state:this.state});var e=this.props.inputProps,t=this.isOpen();return a.createElement("div",u({style:u({},this.props.wrapperStyle)},this.props.wrapperProps,{role:"combobox","aria-expanded":t}),this.props.renderInput(u({},e,{"aria-autocomplete":"list",autoComplete:"off",ref:this.exposeAPI,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur,onChange:this.handleChange,onKeyDown:this.composeEventHandlers(this.handleKeyDown,e.onKeyDown),onClick:this.composeEventHandlers(this.handleInputClick,e.onClick),value:this.props.value})),t&&this.renderMenu(),this.props.debug&&a.createElement("pre",{style:{marginLeft:300}},JSON.stringify(this._debugStates.slice(Math.max(0,this._debugStates.length-5),this._debugStates.length),null,2)))}}]),t}(a.Component);g.propTypes={items:c.array.isRequired,value:c.any,onChange:c.func,onSelect:c.func,shouldItemRender:c.func,isItemSelectable:c.func,sortItems:c.func,getItemValue:c.func.isRequired,renderItem:c.func.isRequired,renderMenu:c.func,menuStyle:c.object,renderInput:c.func,inputProps:c.object,wrapperProps:c.object,wrapperStyle:c.object,autoHighlight:c.bool,selectOnBlur:c.bool,onMenuVisibilityChange:c.func,open:c.bool,debug:c.bool},g.defaultProps={value:"",wrapperProps:{},wrapperStyle:{display:"inline-block"},inputProps:{},renderInput:function(e){return a.createElement("input",e)},onChange:function(){},onSelect:function(){},isItemSelectable:function(){return!0},renderMenu:function(e,t,n){return a.createElement("div",{role:"listbox",style:u({},n,this.menuStyle),children:e})},menuStyle:{borderRadius:"3px",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.9)",padding:"2px 0",fontSize:"90%",position:"fixed",overflow:"auto",maxHeight:"50%"},autoHighlight:!0,selectOnBlur:!1,onMenuVisibilityChange:function(){}},g.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=this.getFilteredItems(this.props);if(t.length){for(var n=this.state.highlightedIndex,r=null===n?-1:n,o=0;o-1&&r!==n&&this.setState({highlightedIndex:r,isOpen:!0})}},ArrowUp:function(e){e.preventDefault();var t=this.getFilteredItems(this.props);if(t.length){for(var n=this.state.highlightedIndex,r=null===n?t.length:n,o=0;o0?!0===l?o.scrollTop(t,f.top+p.top):!1===l?o.scrollTop(t,f.top+d.top):p.top<0?o.scrollTop(t,f.top+p.top):o.scrollTop(t,f.top+d.top):i||(l=void 0===l||!!l,l?o.scrollTop(t,f.top+p.top):o.scrollTop(t,f.top+d.top)),r&&(p.left<0||d.left>0?!0===u?o.scrollLeft(t,f.left+p.left):!1===u?o.scrollLeft(t,f.left+d.left):p.left<0?o.scrollLeft(t,f.left+p.left):o.scrollLeft(t,f.left+d.left):i||(u=void 0===u||!!u,u?o.scrollLeft(t,f.left+p.left):o.scrollLeft(t,f.left+d.left)))}var o=e("./util");t.exports=r},{"./util":4}],4:[function(e,t,n){function r(e){var t,n,r,o=e.ownerDocument,i=o.body,l=o&&o.documentElement;return t=e.getBoundingClientRect(),n=t.left,r=t.top,n-=l.clientLeft||i.clientLeft||0,r-=l.clientTop||i.clientTop||0,{left:n,top:r}}function o(e,t){var n=e["page"+(t?"Y":"X")+"Offset"],r="scroll"+(t?"Top":"Left");if("number"!=typeof n){var o=e.document;n=o.documentElement[r],"number"!=typeof n&&(n=o.body[r])}return n}function i(e){return o(e)}function l(e){return o(e,!0)}function u(e){var t=r(e),n=e.ownerDocument,o=n.defaultView||n.parentWindow;return t.left+=i(o),t.top+=l(o),t}function s(e,t,n){var r="",o=e.ownerDocument;return(n=n||o.defaultView.getComputedStyle(e,null))&&(r=n.getPropertyValue(t)||n[t]),r}function a(e,t){var n=e[S]&&e[S][t];if(x.test(n)&&!O.test(t)){var r=e.style,o=r[k],i=e[T][k];e[T][k]=e[S][k],r[k]="fontSize"===t?"1em":n||0,n=r.pixelLeft+j,r[k]=o,e[T][k]=i}return""===n?"auto":n}function c(e,t){"static"===m(e,"position")&&(e.style.position="relative");var n,r,o=u(e),i={};for(r in t)n=parseFloat(m(e,r))||0,i[r]=n+t[r]-o[r];m(e,i)}function f(e,t){for(var n=0;n, value: String, styles: Object`\n *\n * Invoked to generate the render tree for the dropdown menu. Ensure the\n * returned tree includes every entry in `items` or else the highlight order\n * and keyboard navigation logic will break. `styles` will contain\n * { top, left, minWidth } which are the coordinates of the top-left corner\n * and the width of the dropdown menu.\n */\n renderMenu: PropTypes.func,\n /**\n * Styles that are applied to the dropdown menu in the default `renderMenu`\n * implementation. If you override `renderMenu` and you want to use\n * `menuStyle` you must manually apply them (`this.props.menuStyle`).\n */\n menuStyle: PropTypes.object,\n /**\n * Arguments: `props: Object`\n *\n * Invoked to generate the input element. The `props` argument is the result\n * of merging `props.inputProps` with a selection of props that are required\n * both for functionality and accessibility. At the very least you need to\n * apply `props.ref` and all `props.on` event handlers. Failing to do\n * this will cause `Autocomplete` to behave unexpectedly.\n */\n renderInput: PropTypes.func,\n /**\n * Props passed to `props.renderInput`. By default these props will be\n * applied to the `` element rendered by `Autocomplete`, unless you\n * have specified a custom value for `props.renderInput`. Any properties\n * supported by `HTMLInputElement` can be specified, apart from the\n * following which are set by `Autocomplete`: value, autoComplete, role,\n * aria-autocomplete. `inputProps` is commonly used for (but not limited to)\n * placeholder, event handlers (onFocus, onBlur, etc.), autoFocus, etc..\n */\n inputProps: PropTypes.object,\n /**\n * Props that are applied to the element which wraps the `` and\n * dropdown menu elements rendered by `Autocomplete`. This is in addition to\n * the following properties set by `Autocomplete`: role, aria-expanded.\n */\n wrapperProps: PropTypes.object,\n /**\n * This is a shorthand for `wrapperProps={{ style: }}`.\n * Note that `wrapperStyle` is applied before `wrapperProps`, so the latter\n * will win if it contains a `style` entry.\n */\n wrapperStyle: PropTypes.object,\n /**\n * Whether or not to automatically highlight the top match in the dropdown\n * menu.\n */\n autoHighlight: PropTypes.bool,\n /**\n * Whether or not to automatically select the highlighted item when the\n * `` loses focus.\n */\n selectOnBlur: PropTypes.bool,\n /**\n * Arguments: `isOpen: Boolean`\n *\n * Invoked every time the dropdown menu's visibility changes (i.e. every\n * time it is displayed/hidden).\n */\n onMenuVisibilityChange: PropTypes.func,\n /**\n * Used to override the internal logic which displays/hides the dropdown\n * menu. This is useful if you want to force a certain state based on your\n * UX/business logic. Use it together with `onMenuVisibilityChange` for\n * fine-grained control over the dropdown menu dynamics.\n */\n open: PropTypes.bool,\n debug: PropTypes.bool,\n }\n\n static defaultProps = {\n value: '',\n wrapperProps: {},\n wrapperStyle: {\n display: 'inline-block'\n },\n inputProps: {},\n renderInput(props) {\n return \n },\n onChange() {},\n onSelect() {},\n isItemSelectable() { return true },\n renderMenu(items, value, style) {\n return
\n },\n menuStyle: {\n borderRadius: '3px',\n boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)',\n background: 'rgba(255, 255, 255, 0.9)',\n padding: '2px 0',\n fontSize: '90%',\n position: 'fixed',\n overflow: 'auto',\n maxHeight: '50%', // TODO: don't cheat, let it flow to the bottom\n },\n autoHighlight: true,\n selectOnBlur: false,\n onMenuVisibilityChange() {},\n }\n\n constructor(props) {\n super(props)\n this.state = {\n isOpen: false,\n highlightedIndex: null,\n }\n this._debugStates = []\n this.ensureHighlightedIndex = this.ensureHighlightedIndex.bind(this)\n this.exposeAPI = this.exposeAPI.bind(this)\n this.handleInputFocus = this.handleInputFocus.bind(this)\n this.handleInputBlur = this.handleInputBlur.bind(this)\n this.handleChange = this.handleChange.bind(this)\n this.handleKeyDown = this.handleKeyDown.bind(this)\n this.handleInputClick = this.handleInputClick.bind(this)\n this.maybeAutoCompleteText = this.maybeAutoCompleteText.bind(this)\n }\n\n componentWillMount() {\n // this.refs is frozen, so we need to assign a new object to it\n this.refs = {}\n this._ignoreBlur = false\n this._ignoreFocus = false\n this._scrollOffset = null\n this._scrollTimer = null\n }\n\n componentWillUnmount() {\n clearTimeout(this._scrollTimer)\n this._scrollTimer = null\n }\n\n componentWillReceiveProps(nextProps) {\n if (this.state.highlightedIndex !== null) {\n this.setState(this.ensureHighlightedIndex)\n }\n if (nextProps.autoHighlight && (this.props.value !== nextProps.value || this.state.highlightedIndex === null)) {\n this.setState(this.maybeAutoCompleteText)\n }\n }\n\n componentDidMount() {\n if (this.isOpen()) {\n this.setMenuPositions()\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n if ((this.state.isOpen && !prevState.isOpen) || ('open' in this.props && this.props.open && !prevProps.open))\n this.setMenuPositions()\n\n this.maybeScrollItemIntoView()\n if (prevState.isOpen !== this.state.isOpen) {\n this.props.onMenuVisibilityChange(this.state.isOpen)\n }\n }\n\n exposeAPI(el) {\n this.refs.input = el\n IMPERATIVE_API.forEach(ev => this[ev] = (el && el[ev] && el[ev].bind(el)))\n }\n\n maybeScrollItemIntoView() {\n if (this.isOpen() && this.state.highlightedIndex !== null) {\n const itemNode = this.refs[`item-${this.state.highlightedIndex}`]\n const menuNode = this.refs.menu\n scrollIntoView(\n findDOMNode(itemNode),\n findDOMNode(menuNode),\n { onlyScrollIfNeeded: true }\n )\n }\n }\n\n handleKeyDown(event) {\n if (Autocomplete.keyDownHandlers[event.key])\n Autocomplete.keyDownHandlers[event.key].call(this, event)\n else if (!this.isOpen()) {\n this.setState({\n isOpen: true\n })\n }\n }\n\n handleChange(event) {\n this.props.onChange(event, event.target.value)\n }\n\n static keyDownHandlers = {\n ArrowDown(event) {\n event.preventDefault()\n const items = this.getFilteredItems(this.props)\n if (!items.length) return\n const { highlightedIndex } = this.state\n let index = highlightedIndex === null ? -1 : highlightedIndex\n for (let i = 0; i < items.length ; i++) {\n const p = (index + i + 1) % items.length\n if (this.props.isItemSelectable(items[p])) {\n index = p\n break\n }\n }\n if (index > -1 && index !== highlightedIndex) {\n this.setState({\n highlightedIndex: index,\n isOpen: true,\n })\n }\n },\n\n ArrowUp(event) {\n event.preventDefault()\n const items = this.getFilteredItems(this.props)\n if (!items.length) return\n const { highlightedIndex } = this.state\n let index = highlightedIndex === null ? items.length : highlightedIndex\n for (let i = 0; i < items.length ; i++) {\n const p = (index - (1 + i) + items.length) % items.length\n if (this.props.isItemSelectable(items[p])) {\n index = p\n break\n }\n }\n if (index !== items.length) {\n this.setState({\n highlightedIndex: index,\n isOpen: true,\n })\n }\n },\n\n Enter(event) {\n // Key code 229 is used for selecting items from character selectors (Pinyin, Kana, etc)\n if (event.keyCode !== 13) return\n // In case the user is currently hovering over the menu\n this.setIgnoreBlur(false)\n if (!this.isOpen()) {\n // menu is closed so there is no selection to accept -> do nothing\n return\n }\n else if (this.state.highlightedIndex == null) {\n // input has focus but no menu item is selected + enter is hit -> close the menu, highlight whatever's in input\n this.setState({\n isOpen: false\n }, () => {\n this.refs.input.select()\n })\n }\n else {\n // text entered + menu item has been highlighted + enter is hit -> update value to that of selected menu item, close the menu\n event.preventDefault()\n const item = this.getFilteredItems(this.props)[this.state.highlightedIndex]\n const value = this.props.getItemValue(item)\n this.setState({\n isOpen: false,\n highlightedIndex: null\n }, () => {\n //this.refs.input.focus() // TODO: file issue\n this.refs.input.setSelectionRange(\n value.length,\n value.length\n )\n this.props.onSelect(value, item)\n })\n }\n },\n\n Escape() {\n // In case the user is currently hovering over the menu\n this.setIgnoreBlur(false)\n this.setState({\n highlightedIndex: null,\n isOpen: false\n })\n },\n\n Tab() {\n // In case the user is currently hovering over the menu\n this.setIgnoreBlur(false)\n },\n }\n\n getFilteredItems(props) {\n let items = props.items\n\n if (props.shouldItemRender) {\n items = items.filter((item) => (\n props.shouldItemRender(item, props.value)\n ))\n }\n\n if (props.sortItems) {\n items.sort((a, b) => (\n props.sortItems(a, b, props.value)\n ))\n }\n\n return items\n }\n\n maybeAutoCompleteText(state, props) {\n const { highlightedIndex } = state\n const { value, getItemValue } = props\n let index = highlightedIndex === null ? 0 : highlightedIndex\n let items = this.getFilteredItems(props)\n for (let i = 0; i < items.length ; i++) {\n if (props.isItemSelectable(items[index]))\n break\n index = (index + 1) % items.length\n }\n const matchedItem = items[index] && props.isItemSelectable(items[index]) ? items[index] : null\n if (value !== '' && matchedItem) {\n const itemValue = getItemValue(matchedItem)\n const itemValueDoesMatch = (itemValue.toLowerCase().indexOf(\n value.toLowerCase()\n ) === 0)\n if (itemValueDoesMatch) {\n return { highlightedIndex: index }\n }\n }\n return { highlightedIndex: null }\n }\n\n ensureHighlightedIndex(state, props) {\n if (state.highlightedIndex >= this.getFilteredItems(props).length) {\n return { highlightedIndex: null }\n }\n }\n\n setMenuPositions() {\n const node = this.refs.input\n const rect = node.getBoundingClientRect()\n const computedStyle = global.window.getComputedStyle(node)\n const marginBottom = parseInt(computedStyle.marginBottom, 10) || 0\n const marginLeft = parseInt(computedStyle.marginLeft, 10) || 0\n const marginRight = parseInt(computedStyle.marginRight, 10) || 0\n this.setState({\n menuTop: rect.bottom + marginBottom,\n menuLeft: rect.left + marginLeft,\n menuWidth: rect.width + marginLeft + marginRight\n })\n }\n\n highlightItemFromMouse(index) {\n this.setState({ highlightedIndex: index })\n }\n\n selectItemFromMouse(item) {\n const value = this.props.getItemValue(item)\n // The menu will de-render before a mouseLeave event\n // happens. Clear the flag to release control over focus\n this.setIgnoreBlur(false)\n this.setState({\n isOpen: false,\n highlightedIndex: null\n }, () => {\n this.props.onSelect(value, item)\n })\n }\n\n setIgnoreBlur(ignore) {\n this._ignoreBlur = ignore\n }\n\n renderMenu() {\n const items = this.getFilteredItems(this.props).map((item, index) => {\n const element = this.props.renderItem(\n item,\n this.state.highlightedIndex === index,\n { cursor: 'default' }\n )\n return React.cloneElement(element, {\n onMouseEnter: this.props.isItemSelectable(item) ?\n () => this.highlightItemFromMouse(index) : null,\n onClick: this.props.isItemSelectable(item) ?\n () => this.selectItemFromMouse(item) : null,\n ref: e => this.refs[`item-${index}`] = e,\n })\n })\n const style = {\n left: this.state.menuLeft,\n top: this.state.menuTop,\n minWidth: this.state.menuWidth,\n }\n const menu = this.props.renderMenu(items, this.props.value, style)\n return React.cloneElement(menu, {\n ref: e => this.refs.menu = e,\n // Ignore blur to prevent menu from de-rendering before we can process click\n onTouchStart: () => this.setIgnoreBlur(true),\n onMouseEnter: () => this.setIgnoreBlur(true),\n onMouseLeave: () => this.setIgnoreBlur(false),\n })\n }\n\n handleInputBlur(event) {\n if (this._ignoreBlur) {\n this._ignoreFocus = true\n this._scrollOffset = getScrollOffset()\n this.refs.input.focus()\n return\n }\n let setStateCallback\n const { highlightedIndex } = this.state\n if (this.props.selectOnBlur && highlightedIndex !== null) {\n const items = this.getFilteredItems(this.props)\n const item = items[highlightedIndex]\n const value = this.props.getItemValue(item)\n setStateCallback = () => this.props.onSelect(value, item)\n }\n this.setState({\n isOpen: false,\n highlightedIndex: null\n }, setStateCallback)\n const { onBlur } = this.props.inputProps\n if (onBlur) {\n onBlur(event)\n }\n }\n\n handleInputFocus(event) {\n if (this._ignoreFocus) {\n this._ignoreFocus = false\n const { x, y } = this._scrollOffset\n this._scrollOffset = null\n // Focus will cause the browser to scroll the into view.\n // This can cause the mouse coords to change, which in turn\n // could cause a new highlight to happen, cancelling the click\n // event (when selecting with the mouse)\n window.scrollTo(x, y)\n // Some browsers wait until all focus event handlers have been\n // processed before scrolling the into view, so let's\n // scroll again on the next tick to ensure we're back to where\n // the user was before focus was lost. We could do the deferred\n // scroll only, but that causes a jarring split second jump in\n // some browsers that scroll before the focus event handlers\n // are triggered.\n clearTimeout(this._scrollTimer)\n this._scrollTimer = setTimeout(() => {\n this._scrollTimer = null\n window.scrollTo(x, y)\n }, 0)\n return\n }\n this.setState({ isOpen: true })\n const { onFocus } = this.props.inputProps\n if (onFocus) {\n onFocus(event)\n }\n }\n\n isInputFocused() {\n const el = this.refs.input\n return el.ownerDocument && (el === el.ownerDocument.activeElement)\n }\n\n handleInputClick() {\n // Input will not be focused if it's disabled\n if (this.isInputFocused() && !this.isOpen())\n this.setState({ isOpen: true })\n }\n\n composeEventHandlers(internal, external) {\n return external\n ? e => { internal(e); external(e) }\n : internal\n }\n\n isOpen() {\n return 'open' in this.props ? this.props.open : this.state.isOpen\n }\n\n render() {\n if (this.props.debug) { // you don't like it, you love it\n this._debugStates.push({\n id: this._debugStates.length,\n state: this.state\n })\n }\n\n const { inputProps } = this.props\n const open = this.isOpen()\n return (\n
\n {this.props.renderInput({\n ...inputProps,\n 'aria-autocomplete': 'list',\n autoComplete: 'off',\n ref: this.exposeAPI,\n onFocus: this.handleInputFocus,\n onBlur: this.handleInputBlur,\n onChange: this.handleChange,\n onKeyDown: this.composeEventHandlers(this.handleKeyDown, inputProps.onKeyDown),\n onClick: this.composeEventHandlers(this.handleInputClick, inputProps.onClick),\n value: this.props.value,\n })}\n {open && this.renderMenu()}\n {this.props.debug && (\n
\n            {JSON.stringify(this._debugStates.slice(Math.max(0, this._debugStates.length - 5), this._debugStates.length), null, 2)}\n          
\n )}\n
\n )\n }\n}\n\nmodule.exports = Autocomplete\n\n","module.exports = require('./lib/dom-scroll-into-view');\n","var util = require('./util');\n\nfunction scrollIntoView(elem, container, config) {\n config = config || {};\n // document 归一化到 window\n if (container.nodeType === 9) {\n container = util.getWindow(container);\n }\n\n var allowHorizontalScroll = config.allowHorizontalScroll;\n var onlyScrollIfNeeded = config.onlyScrollIfNeeded;\n var alignWithTop = config.alignWithTop;\n var alignWithLeft = config.alignWithLeft;\n\n allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll;\n\n var isWin = util.isWindow(container);\n var elemOffset = util.offset(elem);\n var eh = util.outerHeight(elem);\n var ew = util.outerWidth(elem);\n var containerOffset, ch, cw, containerScroll,\n diffTop, diffBottom, win,\n winScroll, ww, wh;\n\n if (isWin) {\n win = container;\n wh = util.height(win);\n ww = util.width(win);\n winScroll = {\n left: util.scrollLeft(win),\n top: util.scrollTop(win)\n };\n // elem 相对 container 可视视窗的距离\n diffTop = {\n left: elemOffset.left - winScroll.left,\n top: elemOffset.top - winScroll.top\n };\n diffBottom = {\n left: elemOffset.left + ew - (winScroll.left + ww),\n top: elemOffset.top + eh - (winScroll.top + wh)\n };\n containerScroll = winScroll;\n } else {\n containerOffset = util.offset(container);\n ch = container.clientHeight;\n cw = container.clientWidth;\n containerScroll = {\n left: container.scrollLeft,\n top: container.scrollTop\n };\n // elem 相对 container 可视视窗的距离\n // 注意边框, offset 是边框到根节点\n diffTop = {\n left: elemOffset.left - (containerOffset.left +\n (parseFloat(util.css(container, 'borderLeftWidth')) || 0)),\n top: elemOffset.top - (containerOffset.top +\n (parseFloat(util.css(container, 'borderTopWidth')) || 0))\n };\n diffBottom = {\n left: elemOffset.left + ew -\n (containerOffset.left + cw +\n (parseFloat(util.css(container, 'borderRightWidth')) || 0)),\n top: elemOffset.top + eh -\n (containerOffset.top + ch +\n (parseFloat(util.css(container, 'borderBottomWidth')) || 0))\n };\n }\n\n if (diffTop.top < 0 || diffBottom.top > 0) {\n // 强制向上\n if (alignWithTop === true) {\n util.scrollTop(container, containerScroll.top + diffTop.top);\n } else if (alignWithTop === false) {\n util.scrollTop(container, containerScroll.top + diffBottom.top);\n } else {\n // 自动调整\n if (diffTop.top < 0) {\n util.scrollTop(container, containerScroll.top + diffTop.top);\n } else {\n util.scrollTop(container, containerScroll.top + diffBottom.top);\n }\n }\n } else {\n if (!onlyScrollIfNeeded) {\n alignWithTop = alignWithTop === undefined ? true : !!alignWithTop;\n if (alignWithTop) {\n util.scrollTop(container, containerScroll.top + diffTop.top);\n } else {\n util.scrollTop(container, containerScroll.top + diffBottom.top);\n }\n }\n }\n\n if (allowHorizontalScroll) {\n if (diffTop.left < 0 || diffBottom.left > 0) {\n // 强制向上\n if (alignWithLeft === true) {\n util.scrollLeft(container, containerScroll.left + diffTop.left);\n } else if (alignWithLeft === false) {\n util.scrollLeft(container, containerScroll.left + diffBottom.left);\n } else {\n // 自动调整\n if (diffTop.left < 0) {\n util.scrollLeft(container, containerScroll.left + diffTop.left);\n } else {\n util.scrollLeft(container, containerScroll.left + diffBottom.left);\n }\n }\n } else {\n if (!onlyScrollIfNeeded) {\n alignWithLeft = alignWithLeft === undefined ? true : !!alignWithLeft;\n if (alignWithLeft) {\n util.scrollLeft(container, containerScroll.left + diffTop.left);\n } else {\n util.scrollLeft(container, containerScroll.left + diffBottom.left);\n }\n }\n }\n }\n}\n\nmodule.exports = scrollIntoView;\n","var RE_NUM = /[\\-+]?(?:\\d*\\.|)\\d+(?:[eE][\\-+]?\\d+|)/.source;\n\nfunction getClientPosition(elem) {\n var box, x, y;\n var doc = elem.ownerDocument;\n var body = doc.body;\n var docElem = doc && doc.documentElement;\n // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式\n box = elem.getBoundingClientRect();\n\n // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop\n // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确\n // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin\n\n x = box.left;\n y = box.top;\n\n // In IE, most of the time, 2 extra pixels are added to the top and left\n // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and\n // IE6 standards mode, this border can be overridden by setting the\n // document element's border to zero -- thus, we cannot rely on the\n // offset always being 2 pixels.\n\n // In quirks mode, the offset can be determined by querying the body's\n // clientLeft/clientTop, but in standards mode, it is found by querying\n // the document element's clientLeft/clientTop. Since we already called\n // getClientBoundingRect we have already forced a reflow, so it is not\n // too expensive just to query them all.\n\n // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的\n // 窗口边框标准是设 documentElement ,quirks 时设置 body\n // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去\n // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置\n // 标准 ie 下 docElem.clientTop 就是 border-top\n // ie7 html 即窗口边框改变不了。永远为 2\n // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0\n\n x -= docElem.clientLeft || body.clientLeft || 0;\n y -= docElem.clientTop || body.clientTop || 0;\n\n return {left: x, top: y};\n}\n\nfunction getScroll(w, top) {\n var ret = w['page' + (top ? 'Y' : 'X') + 'Offset'];\n var method = 'scroll' + (top ? 'Top' : 'Left');\n if (typeof ret !== 'number') {\n var d = w.document;\n //ie6,7,8 standard mode\n ret = d.documentElement[method];\n if (typeof ret !== 'number') {\n //quirks mode\n ret = d.body[method];\n }\n }\n return ret;\n}\n\nfunction getScrollLeft(w) {\n return getScroll(w);\n}\n\nfunction getScrollTop(w) {\n return getScroll(w, true);\n}\n\nfunction getOffset(el) {\n var pos = getClientPosition(el);\n var doc = el.ownerDocument;\n var w = doc.defaultView || doc.parentWindow;\n pos.left += getScrollLeft(w);\n pos.top += getScrollTop(w);\n return pos;\n}\nfunction _getComputedStyle(elem, name, computedStyle) {\n var val = '';\n var d = elem.ownerDocument;\n\n // https://github.com/kissyteam/kissy/issues/61\n if ((computedStyle = (computedStyle || d.defaultView.getComputedStyle(elem, null)))) {\n val = computedStyle.getPropertyValue(name) || computedStyle[name];\n }\n\n return val;\n}\n\nvar _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i');\nvar RE_POS = /^(top|right|bottom|left)$/,\n CURRENT_STYLE = 'currentStyle',\n RUNTIME_STYLE = 'runtimeStyle',\n LEFT = 'left',\n PX = 'px';\n\nfunction _getComputedStyleIE(elem, name) {\n // currentStyle maybe null\n // http://msdn.microsoft.com/en-us/library/ms535231.aspx\n var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name];\n\n // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值\n // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19\n // 在 ie 下不对,需要直接用 offset 方式\n // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了\n\n // From the awesome hack by Dean Edwards\n // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291\n // If we're not dealing with a regular pixel number\n // but a number that has a weird ending, we need to convert it to pixels\n // exclude left right for relativity\n if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {\n // Remember the original values\n var style = elem.style,\n left = style[LEFT],\n rsLeft = elem[RUNTIME_STYLE][LEFT];\n\n // prevent flashing of content\n elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT];\n\n // Put in the new values to get a computed value out\n style[LEFT] = name === 'fontSize' ? '1em' : (ret || 0);\n ret = style.pixelLeft + PX;\n\n // Revert the changed values\n style[LEFT] = left;\n\n elem[RUNTIME_STYLE][LEFT] = rsLeft;\n }\n return ret === '' ? 'auto' : ret;\n}\n\nvar getComputedStyleX;\nif (typeof window !== 'undefined') {\n getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;\n}\n\n// 设置 elem 相对 elem.ownerDocument 的坐标\nfunction setOffset(elem, offset) {\n // set position first, in-case top/left are set even on static elem\n if (css(elem, 'position') === 'static') {\n elem.style.position = 'relative';\n }\n\n var old = getOffset(elem),\n ret = {},\n current, key;\n\n for (key in offset) {\n current = parseFloat(css(elem, key)) || 0;\n ret[key] = current + offset[key] - old[key];\n }\n css(elem, ret);\n}\n\nfunction each(arr, fn) {\n for (var i = 0; i < arr.length; i++) {\n fn(arr[i]);\n }\n}\n\nfunction isBorderBoxFn(elem) {\n return getComputedStyleX(elem, 'boxSizing') === 'border-box';\n}\n\nvar BOX_MODELS = ['margin', 'border', 'padding'],\n CONTENT_INDEX = -1,\n PADDING_INDEX = 2,\n BORDER_INDEX = 1,\n MARGIN_INDEX = 0;\n\nfunction swap(elem, options, callback) {\n var old = {},\n style = elem.style,\n name;\n\n // Remember the old values, and insert the new ones\n for (name in options) {\n old[name] = style[name];\n style[name] = options[name];\n }\n\n callback.call(elem);\n\n // Revert the old values\n for (name in options) {\n style[name] = old[name];\n }\n}\n\nfunction getPBMWidth(elem, props, which) {\n var value = 0, prop, j, i;\n for (j = 0; j < props.length; j++) {\n prop = props[j];\n if (prop) {\n for (i = 0; i < which.length; i++) {\n var cssProp;\n if (prop === 'border') {\n cssProp = prop + which[i] + 'Width';\n } else {\n cssProp = prop + which[i];\n }\n value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;\n }\n }\n }\n return value;\n}\n\n/**\n * A crude way of determining if an object is a window\n * @member util\n */\nfunction isWindow(obj) {\n // must use == for ie8\n /*jshint eqeqeq:false*/\n return obj != null && obj == obj.window;\n}\n\nvar domUtils = {};\n\neach(['Width', 'Height'], function (name) {\n domUtils['doc' + name] = function (refWin) {\n var d = refWin.document;\n return Math.max(\n //firefox chrome documentElement.scrollHeight< body.scrollHeight\n //ie standard mode : documentElement.scrollHeight> body.scrollHeight\n d.documentElement['scroll' + name],\n //quirks : documentElement.scrollHeight 最大等于可视窗口多一点?\n d.body['scroll' + name],\n domUtils['viewport' + name](d));\n };\n\n domUtils['viewport' + name] = function (win) {\n // pc browser includes scrollbar in window.innerWidth\n var prop = 'client' + name,\n doc = win.document,\n body = doc.body,\n documentElement = doc.documentElement,\n documentElementProp = documentElement[prop];\n // 标准模式取 documentElement\n // backcompat 取 body\n return doc.compatMode === 'CSS1Compat' && documentElementProp ||\n body && body[prop] || documentElementProp;\n };\n});\n\n/*\n 得到元素的大小信息\n @param elem\n @param name\n @param {String} [extra] 'padding' : (css width) + padding\n 'border' : (css width) + padding + border\n 'margin' : (css width) + padding + border + margin\n */\nfunction getWH(elem, name, extra) {\n if (isWindow(elem)) {\n return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);\n } else if (elem.nodeType === 9) {\n return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);\n }\n var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'],\n borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight;\n var computedStyle = getComputedStyleX(elem);\n var isBorderBox = isBorderBoxFn(elem, computedStyle);\n var cssBoxValue = 0;\n if (borderBoxValue == null || borderBoxValue <= 0) {\n borderBoxValue = undefined;\n // Fall back to computed then un computed css if necessary\n cssBoxValue = getComputedStyleX(elem, name);\n if (cssBoxValue == null || (Number(cssBoxValue)) < 0) {\n cssBoxValue = elem.style[name] || 0;\n }\n // Normalize '', auto, and prepare for extra\n cssBoxValue = parseFloat(cssBoxValue) || 0;\n }\n if (extra === undefined) {\n extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;\n }\n var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;\n var val = borderBoxValue || cssBoxValue;\n if (extra === CONTENT_INDEX) {\n if (borderBoxValueOrIsBorderBox) {\n return val - getPBMWidth(elem, ['border', 'padding'],\n which, computedStyle);\n } else {\n return cssBoxValue;\n }\n } else if (borderBoxValueOrIsBorderBox) {\n return val + (extra === BORDER_INDEX ? 0 :\n (extra === PADDING_INDEX ?\n -getPBMWidth(elem, ['border'], which, computedStyle) :\n getPBMWidth(elem, ['margin'], which, computedStyle)));\n } else {\n return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra),\n which, computedStyle);\n }\n}\n\nvar cssShow = {position: 'absolute', visibility: 'hidden', display: 'block'};\n\n// fix #119 : https://github.com/kissyteam/kissy/issues/119\nfunction getWHIgnoreDisplay(elem) {\n var val, args = arguments;\n // in case elem is window\n // elem.offsetWidth === undefined\n if (elem.offsetWidth !== 0) {\n val = getWH.apply(undefined, args);\n } else {\n swap(elem, cssShow, function () {\n val = getWH.apply(undefined, args);\n });\n }\n return val;\n}\n\neach(['width', 'height'], function (name) {\n var first = name.charAt(0).toUpperCase() + name.slice(1);\n domUtils['outer' + first] = function (el, includeMargin) {\n return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);\n };\n var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];\n\n domUtils[name] = function (elem, val) {\n if (val !== undefined) {\n if (elem) {\n var computedStyle = getComputedStyleX(elem);\n var isBorderBox = isBorderBoxFn(elem);\n if (isBorderBox) {\n val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle);\n }\n return css(elem, name, val);\n }\n return;\n }\n return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);\n };\n});\n\nfunction css(el, name, value) {\n if (typeof name === 'object') {\n for (var i in name) {\n css(el, i, name[i]);\n }\n return;\n }\n if (typeof value !== 'undefined') {\n if (typeof value === 'number') {\n value = value + 'px';\n }\n el.style[name] = value;\n } else {\n return getComputedStyleX(el, name);\n }\n}\n\nfunction mix(to, from) {\n for (var i in from) {\n to[i] = from[i];\n }\n return to;\n}\n\nvar utils = module.exports = {\n getWindow: function (node) {\n var doc = node.ownerDocument || node;\n return doc.defaultView || doc.parentWindow;\n },\n offset: function (el, value) {\n if (typeof value !== 'undefined') {\n setOffset(el, value);\n } else {\n return getOffset(el);\n }\n },\n isWindow: isWindow,\n each: each,\n css: css,\n clone: function (obj) {\n var ret = {};\n for (var i in obj) {\n ret[i] = obj[i];\n }\n var overflow = obj.overflow;\n if (overflow) {\n for (i in obj) {\n ret.overflow[i] = obj.overflow[i];\n }\n }\n return ret;\n },\n mix: mix,\n scrollLeft: function (w, v) {\n if (isWindow(w)) {\n if (v === undefined) {\n return getScrollLeft(w);\n } else {\n window.scrollTo(v, getScrollTop(w));\n }\n } else {\n if (v === undefined) {\n return w.scrollLeft;\n } else {\n w.scrollLeft = v;\n }\n }\n },\n scrollTop: function (w, v) {\n if (isWindow(w)) {\n if (v === undefined) {\n return getScrollTop(w);\n } else {\n window.scrollTo(getScrollLeft(w), v);\n }\n } else {\n if (v === undefined) {\n return w.scrollTop;\n } else {\n w.scrollTop = v;\n }\n }\n },\n merge: function () {\n var ret = {};\n for (var i = 0; i < arguments.length; i++) {\n utils.mix(ret, arguments[i]);\n }\n return ret;\n },\n viewportWidth: 0,\n viewportHeight: 0\n};\n\nmix(utils, domUtils);\n","/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar printWarning = function() {};\n\nif (\"production\" !== 'production') {\n var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n var loggedTypeFailures = {};\n\n printWarning = function(text) {\n var message = 'Warning: ' + text;\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // --- Welcome to debugging React ---\n // This error was thrown as a convenience so that you can use this stack\n // to find the callsite that caused this warning to fire.\n throw new Error(message);\n } catch (x) {}\n };\n}\n\n/**\n * Assert that the values match with the type specs.\n * Error messages are memorized and will only be shown once.\n *\n * @param {object} typeSpecs Map of name to a ReactPropType\n * @param {object} values Runtime values that need to be type-checked\n * @param {string} location e.g. \"prop\", \"context\", \"child context\"\n * @param {string} componentName Name of the component for error messages.\n * @param {?Function} getStack Returns the component stack.\n * @private\n */\nfunction checkPropTypes(typeSpecs, values, location, componentName, getStack) {\n if (\"production\" !== 'production') {\n for (var typeSpecName in typeSpecs) {\n if (typeSpecs.hasOwnProperty(typeSpecName)) {\n var error;\n // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n var err = Error(\n (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +\n 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'\n );\n err.name = 'Invariant Violation';\n throw err;\n }\n error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);\n } catch (ex) {\n error = ex;\n }\n if (error && !(error instanceof Error)) {\n printWarning(\n (componentName || 'React class') + ': type specification of ' +\n location + ' `' + typeSpecName + '` is invalid; the type checker ' +\n 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +\n 'You may have forgotten to pass an argument to the type checker ' +\n 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +\n 'shape all require an argument).'\n )\n\n }\n if (error instanceof Error && !(error.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error.message] = true;\n\n var stack = getStack ? getStack() : '';\n\n printWarning(\n 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')\n );\n }\n }\n }\n }\n}\n\nmodule.exports = checkPropTypes;\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n\nfunction emptyFunction() {}\n\nmodule.exports = function() {\n function shim(props, propName, componentName, location, propFullName, secret) {\n if (secret === ReactPropTypesSecret) {\n // It is still safe when called from React.\n return;\n }\n var err = new Error(\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use PropTypes.checkPropTypes() to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n err.name = 'Invariant Violation';\n throw err;\n };\n shim.isRequired = shim;\n function getShim() {\n return shim;\n };\n // Important!\n // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.\n var ReactPropTypes = {\n array: shim,\n bool: shim,\n func: shim,\n number: shim,\n object: shim,\n string: shim,\n symbol: shim,\n\n any: shim,\n arrayOf: getShim,\n element: shim,\n instanceOf: getShim,\n node: shim,\n objectOf: getShim,\n oneOf: getShim,\n oneOfType: getShim,\n shape: getShim,\n exact: getShim\n };\n\n ReactPropTypes.checkPropTypes = emptyFunction;\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar assign = require('object-assign');\n\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\nvar checkPropTypes = require('./checkPropTypes');\n\nvar printWarning = function() {};\n\nif (\"production\" !== 'production') {\n printWarning = function(text) {\n var message = 'Warning: ' + text;\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // --- Welcome to debugging React ---\n // This error was thrown as a convenience so that you can use this stack\n // to find the callsite that caused this warning to fire.\n throw new Error(message);\n } catch (x) {}\n };\n}\n\nfunction emptyFunctionThatReturnsNull() {\n return null;\n}\n\nmodule.exports = function(isValidElement, throwOnDirectAccess) {\n /* global Symbol */\n var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;\n var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.\n\n /**\n * Returns the iterator method function contained on the iterable object.\n *\n * Be sure to invoke the function with the iterable as context:\n *\n * var iteratorFn = getIteratorFn(myIterable);\n * if (iteratorFn) {\n * var iterator = iteratorFn.call(myIterable);\n * ...\n * }\n *\n * @param {?object} maybeIterable\n * @return {?function}\n */\n function getIteratorFn(maybeIterable) {\n var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);\n if (typeof iteratorFn === 'function') {\n return iteratorFn;\n }\n }\n\n /**\n * Collection of methods that allow declaration and validation of props that are\n * supplied to React components. Example usage:\n *\n * var Props = require('ReactPropTypes');\n * var MyArticle = React.createClass({\n * propTypes: {\n * // An optional string prop named \"description\".\n * description: Props.string,\n *\n * // A required enum prop named \"category\".\n * category: Props.oneOf(['News','Photos']).isRequired,\n *\n * // A prop named \"dialog\" that requires an instance of Dialog.\n * dialog: Props.instanceOf(Dialog).isRequired\n * },\n * render: function() { ... }\n * });\n *\n * A more formal specification of how these methods are used:\n *\n * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)\n * decl := ReactPropTypes.{type}(.isRequired)?\n *\n * Each and every declaration produces a function with the same signature. This\n * allows the creation of custom validation functions. For example:\n *\n * var MyLink = React.createClass({\n * propTypes: {\n * // An optional string or URI prop named \"href\".\n * href: function(props, propName, componentName) {\n * var propValue = props[propName];\n * if (propValue != null && typeof propValue !== 'string' &&\n * !(propValue instanceof URI)) {\n * return new Error(\n * 'Expected a string or an URI for ' + propName + ' in ' +\n * componentName\n * );\n * }\n * }\n * },\n * render: function() {...}\n * });\n *\n * @internal\n */\n\n var ANONYMOUS = '<>';\n\n // Important!\n // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.\n var ReactPropTypes = {\n array: createPrimitiveTypeChecker('array'),\n bool: createPrimitiveTypeChecker('boolean'),\n func: createPrimitiveTypeChecker('function'),\n number: createPrimitiveTypeChecker('number'),\n object: createPrimitiveTypeChecker('object'),\n string: createPrimitiveTypeChecker('string'),\n symbol: createPrimitiveTypeChecker('symbol'),\n\n any: createAnyTypeChecker(),\n arrayOf: createArrayOfTypeChecker,\n element: createElementTypeChecker(),\n instanceOf: createInstanceTypeChecker,\n node: createNodeChecker(),\n objectOf: createObjectOfTypeChecker,\n oneOf: createEnumTypeChecker,\n oneOfType: createUnionTypeChecker,\n shape: createShapeTypeChecker,\n exact: createStrictShapeTypeChecker,\n };\n\n /**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\n /*eslint-disable no-self-compare*/\n function is(x, y) {\n // SameValue algorithm\n if (x === y) {\n // Steps 1-5, 7-10\n // Steps 6.b-6.e: +0 != -0\n return x !== 0 || 1 / x === 1 / y;\n } else {\n // Step 6.a: NaN == NaN\n return x !== x && y !== y;\n }\n }\n /*eslint-enable no-self-compare*/\n\n /**\n * We use an Error-like object for backward compatibility as people may call\n * PropTypes directly and inspect their output. However, we don't use real\n * Errors anymore. We don't inspect their stack anyway, and creating them\n * is prohibitively expensive if they are created too often, such as what\n * happens in oneOfType() for any type before the one that matched.\n */\n function PropTypeError(message) {\n this.message = message;\n this.stack = '';\n }\n // Make `instanceof Error` still work for returned errors.\n PropTypeError.prototype = Error.prototype;\n\n function createChainableTypeChecker(validate) {\n if (\"production\" !== 'production') {\n var manualPropTypeCallCache = {};\n var manualPropTypeWarningCount = 0;\n }\n function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {\n componentName = componentName || ANONYMOUS;\n propFullName = propFullName || propName;\n\n if (secret !== ReactPropTypesSecret) {\n if (throwOnDirectAccess) {\n // New behavior only for users of `prop-types` package\n var err = new Error(\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use `PropTypes.checkPropTypes()` to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n err.name = 'Invariant Violation';\n throw err;\n } else if (\"production\" !== 'production' && typeof console !== 'undefined') {\n // Old behavior for people using React.PropTypes\n var cacheKey = componentName + ':' + propName;\n if (\n !manualPropTypeCallCache[cacheKey] &&\n // Avoid spamming the console because they are often not actionable except for lib authors\n manualPropTypeWarningCount < 3\n ) {\n printWarning(\n 'You are manually calling a React.PropTypes validation ' +\n 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +\n 'and will throw in the standalone `prop-types` package. ' +\n 'You may be seeing this warning due to a third-party PropTypes ' +\n 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'\n );\n manualPropTypeCallCache[cacheKey] = true;\n manualPropTypeWarningCount++;\n }\n }\n }\n if (props[propName] == null) {\n if (isRequired) {\n if (props[propName] === null) {\n return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));\n }\n return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));\n }\n return null;\n } else {\n return validate(props, propName, componentName, location, propFullName);\n }\n }\n\n var chainedCheckType = checkType.bind(null, false);\n chainedCheckType.isRequired = checkType.bind(null, true);\n\n return chainedCheckType;\n }\n\n function createPrimitiveTypeChecker(expectedType) {\n function validate(props, propName, componentName, location, propFullName, secret) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== expectedType) {\n // `propValue` being instance of, say, date/regexp, pass the 'object'\n // check, but we can offer a more precise error message here rather than\n // 'of type `object`'.\n var preciseType = getPreciseType(propValue);\n\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createAnyTypeChecker() {\n return createChainableTypeChecker(emptyFunctionThatReturnsNull);\n }\n\n function createArrayOfTypeChecker(typeChecker) {\n function validate(props, propName, componentName, location, propFullName) {\n if (typeof typeChecker !== 'function') {\n return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');\n }\n var propValue = props[propName];\n if (!Array.isArray(propValue)) {\n var propType = getPropType(propValue);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));\n }\n for (var i = 0; i < propValue.length; i++) {\n var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);\n if (error instanceof Error) {\n return error;\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createElementTypeChecker() {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n if (!isValidElement(propValue)) {\n var propType = getPropType(propValue);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createInstanceTypeChecker(expectedClass) {\n function validate(props, propName, componentName, location, propFullName) {\n if (!(props[propName] instanceof expectedClass)) {\n var expectedClassName = expectedClass.name || ANONYMOUS;\n var actualClassName = getClassName(props[propName]);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createEnumTypeChecker(expectedValues) {\n if (!Array.isArray(expectedValues)) {\n \"production\" !== 'production' ? printWarning('Invalid argument supplied to oneOf, expected an instance of array.') : void 0;\n return emptyFunctionThatReturnsNull;\n }\n\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n for (var i = 0; i < expectedValues.length; i++) {\n if (is(propValue, expectedValues[i])) {\n return null;\n }\n }\n\n var valuesString = JSON.stringify(expectedValues);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));\n }\n return createChainableTypeChecker(validate);\n }\n\n function createObjectOfTypeChecker(typeChecker) {\n function validate(props, propName, componentName, location, propFullName) {\n if (typeof typeChecker !== 'function') {\n return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');\n }\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));\n }\n for (var key in propValue) {\n if (propValue.hasOwnProperty(key)) {\n var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error instanceof Error) {\n return error;\n }\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createUnionTypeChecker(arrayOfTypeCheckers) {\n if (!Array.isArray(arrayOfTypeCheckers)) {\n \"production\" !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;\n return emptyFunctionThatReturnsNull;\n }\n\n for (var i = 0; i < arrayOfTypeCheckers.length; i++) {\n var checker = arrayOfTypeCheckers[i];\n if (typeof checker !== 'function') {\n printWarning(\n 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +\n 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'\n );\n return emptyFunctionThatReturnsNull;\n }\n }\n\n function validate(props, propName, componentName, location, propFullName) {\n for (var i = 0; i < arrayOfTypeCheckers.length; i++) {\n var checker = arrayOfTypeCheckers[i];\n if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {\n return null;\n }\n }\n\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));\n }\n return createChainableTypeChecker(validate);\n }\n\n function createNodeChecker() {\n function validate(props, propName, componentName, location, propFullName) {\n if (!isNode(props[propName])) {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createShapeTypeChecker(shapeTypes) {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));\n }\n for (var key in shapeTypes) {\n var checker = shapeTypes[key];\n if (!checker) {\n continue;\n }\n var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error) {\n return error;\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createStrictShapeTypeChecker(shapeTypes) {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));\n }\n // We need to check all keys in case some are required but missing from\n // props.\n var allKeys = assign({}, props[propName], shapeTypes);\n for (var key in allKeys) {\n var checker = shapeTypes[key];\n if (!checker) {\n return new PropTypeError(\n 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +\n '\\nBad object: ' + JSON.stringify(props[propName], null, ' ') +\n '\\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')\n );\n }\n var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error) {\n return error;\n }\n }\n return null;\n }\n\n return createChainableTypeChecker(validate);\n }\n\n function isNode(propValue) {\n switch (typeof propValue) {\n case 'number':\n case 'string':\n case 'undefined':\n return true;\n case 'boolean':\n return !propValue;\n case 'object':\n if (Array.isArray(propValue)) {\n return propValue.every(isNode);\n }\n if (propValue === null || isValidElement(propValue)) {\n return true;\n }\n\n var iteratorFn = getIteratorFn(propValue);\n if (iteratorFn) {\n var iterator = iteratorFn.call(propValue);\n var step;\n if (iteratorFn !== propValue.entries) {\n while (!(step = iterator.next()).done) {\n if (!isNode(step.value)) {\n return false;\n }\n }\n } else {\n // Iterator will provide entry [k,v] tuples rather than values.\n while (!(step = iterator.next()).done) {\n var entry = step.value;\n if (entry) {\n if (!isNode(entry[1])) {\n return false;\n }\n }\n }\n }\n } else {\n return false;\n }\n\n return true;\n default:\n return false;\n }\n }\n\n function isSymbol(propType, propValue) {\n // Native Symbol.\n if (propType === 'symbol') {\n return true;\n }\n\n // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'\n if (propValue['@@toStringTag'] === 'Symbol') {\n return true;\n }\n\n // Fallback for non-spec compliant Symbols which are polyfilled.\n if (typeof Symbol === 'function' && propValue instanceof Symbol) {\n return true;\n }\n\n return false;\n }\n\n // Equivalent of `typeof` but with special handling for array and regexp.\n function getPropType(propValue) {\n var propType = typeof propValue;\n if (Array.isArray(propValue)) {\n return 'array';\n }\n if (propValue instanceof RegExp) {\n // Old webkits (at least until Android 4.0) return 'function' rather than\n // 'object' for typeof a RegExp. We'll normalize this here so that /bla/\n // passes PropTypes.object.\n return 'object';\n }\n if (isSymbol(propType, propValue)) {\n return 'symbol';\n }\n return propType;\n }\n\n // This handles more types than `getPropType`. Only used for error messages.\n // See `createPrimitiveTypeChecker`.\n function getPreciseType(propValue) {\n if (typeof propValue === 'undefined' || propValue === null) {\n return '' + propValue;\n }\n var propType = getPropType(propValue);\n if (propType === 'object') {\n if (propValue instanceof Date) {\n return 'date';\n } else if (propValue instanceof RegExp) {\n return 'regexp';\n }\n }\n return propType;\n }\n\n // Returns a string that is postfixed to a warning about an invalid type.\n // For example, \"undefined\" or \"of type array\"\n function getPostfixForTypeWarning(value) {\n var type = getPreciseType(value);\n switch (type) {\n case 'array':\n case 'object':\n return 'an ' + type;\n case 'boolean':\n case 'date':\n case 'regexp':\n return 'a ' + type;\n default:\n return type;\n }\n }\n\n // Returns class name of the object, if any.\n function getClassName(propValue) {\n if (!propValue.constructor || !propValue.constructor.name) {\n return ANONYMOUS;\n }\n return propValue.constructor.name;\n }\n\n ReactPropTypes.checkPropTypes = checkPropTypes;\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (\"production\" !== 'production') {\n var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&\n Symbol.for &&\n Symbol.for('react.element')) ||\n 0xeac7;\n\n var isValidElement = function(object) {\n return typeof object === 'object' &&\n object !== null &&\n object.$$typeof === REACT_ELEMENT_TYPE;\n };\n\n // By explicitly using `prop-types` you are opting into new development behavior.\n // http://fb.me/prop-types-in-prod\n var throwOnDirectAccess = true;\n module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess);\n} else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = require('./factoryWithThrowingShims')();\n}\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';\n\nmodule.exports = ReactPropTypesSecret;\n"]} \ No newline at end of file