diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..ef2bf99 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015", "react", "stage-1"] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6c56e6e..f339102 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ TODO *.log node_modules tmp - +lib example/bundle.js +yarn.lock diff --git a/.npmignore b/.npmignore index 57f1936..3831994 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,7 @@ example script webpack.config.js +webpack.dist.config.js +src test .travis.yml diff --git a/README.md b/README.md index d17c631..af53dc0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - +  diff --git a/dist/react-tokeninput.js b/dist/react-tokeninput.js index 716a876..4241f17 100644 --- a/dist/react-tokeninput.js +++ b/dist/react-tokeninput.js @@ -1,13 +1,13 @@ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("react")); + module.exports = factory(require("prop-types"), require("react")); else if(typeof define === 'function' && define.amd) - define(["react"], factory); + define(["prop-types", "react"], factory); else if(typeof exports === 'object') - exports["TokenInput"] = factory(require("react")); + exports["TokenInput"] = factory(require("prop-types"), require("react")); else - root["TokenInput"] = factory(root["React"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_2__) { + root["TokenInput"] = factory(root["prop-types"], root["react"]); +})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -44,7 +44,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.c = installedModules; /******/ /******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; +/******/ __webpack_require__.p = "/"; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(0); @@ -52,23200 +52,838 @@ return /******/ (function(modules) { // webpackBootstrap /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - __webpack_require__(1); - module.exports = __webpack_require__(149); - - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - var React = __webpack_require__(2) - var ReactDOM = __webpack_require__(3) - var TokenInput = __webpack_require__(149) - var ComboboxOption = __webpack_require__(149).Option - - var without = __webpack_require__(156) - var uniq = __webpack_require__(169) - var names = __webpack_require__(194) - - var App = React.createClass({displayName: "App", - getInitialState: function() { - return { - input: '', - loading: false, - selected: [], - options: names - }; - }, - - handleChange: function(value) { - this.setState({ - selected: value - }) - }, - - handleRemove: function(value) { - var selectedOptions = uniq(without(this.state.selected,value)) - this.handleChange(selectedOptions) - }, + 'use strict'; - handleSelect: function(value, combobox) { - if(typeof value === 'string') { - value = {id: value, name: value}; - } + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.Token = exports.Option = exports.Combobox = undefined; - var selected = uniq(this.state.selected.concat([value])) - this.setState({ - selected: selected, - selectedToken: null - }) + var _combobox = __webpack_require__(1); - this.handleChange(selected) - }, + var _combobox2 = _interopRequireDefault(_combobox); - handleInput: function(userInput) { - this.setState({ - input: userInput, - loading: true, - options: [] - }) - setTimeout(function () { - this.filterTags(this.state.input) - this.setState({ - loading: false - }) - }.bind(this), 500) - }, + var _option = __webpack_require__(5); - filterTags: function(userInput) { - if (userInput === '') - return this.setState({options: []}); - var filter = new RegExp('^'+userInput, 'i'); - var filteredNames = names.filter(function(state) { - return filter.test(state.name); // || filter.test(state.id); - }).filter(function(state) { - return this.state.selected - .map(function(value) { return value.name }) - .indexOf(state.name) === -1 - }.bind(this)) - this.setState({ - options: filteredNames - }); - }, + var _option2 = _interopRequireDefault(_option); - renderComboboxOptions: function() { - return this.state.options.map(function(name) { - return ( - React.createElement(ComboboxOption, { - key: name.id, - value: name - }, name.name) - ); - }); - }, + var _token = __webpack_require__(6); - render: function() { - var selectedNames = this.state.selected.map(function(tag) { - return React.createElement("li", {key: tag.id}, tag.name) - }) + var _token2 = _interopRequireDefault(_token); - var options = this.state.options.length ? - this.renderComboboxOptions() : []; + var _main = __webpack_require__(7); - const loadingComponent = ( - React.createElement("img", {src: "spinner.gif"}) - ) + var _main2 = _interopRequireDefault(_main); - return ( - React.createElement("div", null, - React.createElement("h1", null, "React TokenInput Example"), + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - React.createElement(TokenInput, { - isLoading: this.state.loading, - loadingComponent: loadingComponent, - menuContent: options, - onChange: this.handleChange, - onInput: this.handleInput, - onSelect: this.handleSelect, - onRemove: this.handleRemove, - selected: this.state.selected} - ), + exports.Combobox = _combobox2.default; + exports.Option = _option2.default; + exports.Token = _token2.default; - React.createElement("h2", null, "Selected"), - React.createElement("ul", null, - selectedNames - ) - ) - ); - } - }) - ReactDOM.render(React.createElement(App, null), document.getElementById('application')) - - -/***/ }, -/* 2 */ -/***/ function(module, exports) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_2__; + /** + * You can't do an import and then immediately export it :( + * And `export default TokenInput from './main'` doesn't seem to + * work either :( + * So this little variable swapping stuff gets it to work. + */ + var TokenInput = _main2.default; + exports.default = TokenInput; -/***/ }, -/* 3 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { 'use strict'; - module.exports = __webpack_require__(4); - - -/***/ }, -/* 4 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactDOM - */ - - /* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/ - - 'use strict'; + 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; }; }(); - var ReactCurrentOwner = __webpack_require__(6); - var ReactDOMTextComponent = __webpack_require__(7); - var ReactDefaultInjection = __webpack_require__(72); - var ReactInstanceHandles = __webpack_require__(46); - var ReactMount = __webpack_require__(29); - var ReactPerf = __webpack_require__(19); - var ReactReconciler = __webpack_require__(51); - var ReactUpdates = __webpack_require__(55); - var ReactVersion = __webpack_require__(147); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var findDOMNode = __webpack_require__(92); - var renderSubtreeIntoContainer = __webpack_require__(148); - var warning = __webpack_require__(26); + 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; } - ReactDefaultInjection.inject(); + 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 render = ReactPerf.measure('React', 'render', ReactMount.render); + var PropTypes = __webpack_require__(2); + var React = __webpack_require__(3); + var guid = 0; + var k = function k() {}; + var addClass = __webpack_require__(4); + var ComboboxOption = __webpack_require__(5); - var React = { - findDOMNode: findDOMNode, - render: render, - unmountComponentAtNode: ReactMount.unmountComponentAtNode, - version: ReactVersion, + var Combobox = function (_React$Component) { + _inherits(Combobox, _React$Component); - /* eslint-disable camelcase */ - unstable_batchedUpdates: ReactUpdates.batchedUpdates, - unstable_renderSubtreeIntoContainer: renderSubtreeIntoContainer - }; + function Combobox() { + var _ref; - // Inject the runtime into a devtools global hook regardless of browser. - // Allows for debugging when the hook is injected on the page. - /* eslint-enable camelcase */ - if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') { - __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({ - CurrentOwner: ReactCurrentOwner, - InstanceHandles: ReactInstanceHandles, - Mount: ReactMount, - Reconciler: ReactReconciler, - TextComponent: ReactDOMTextComponent - }); - } + var _temp, _this, _ret; - if (process.env.NODE_ENV !== 'production') { - var ExecutionEnvironment = __webpack_require__(10); - if (ExecutionEnvironment.canUseDOM && window.top === window.self) { + _classCallCheck(this, Combobox); - // First check if devtools is not installed - if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { - // If we're in Chrome or Firefox, provide a download link if not installed. - if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { - console.debug('Download the React DevTools for a better development experience: ' + 'https://fb.me/react-devtools'); - } + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - // If we're in IE8, check to see if we are in compatibility mode and provide - // information on preventing compatibility mode - var ieCompatibilityMode = document.documentMode && document.documentMode < 8; + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Combobox.__proto__ || Object.getPrototypeOf(Combobox)).call.apply(_ref, [this].concat(args))), _this), _this.makeMenu = function (children) { + var activedescendant; + var isEmpty = true; - process.env.NODE_ENV !== 'production' ? warning(!ieCompatibilityMode, 'Internet Explorer is running in compatibility mode; please add the ' + 'following tag to your HTML to prevent this from happening: ' + '') : undefined; - - var expectedFeatures = [ - // shims - Array.isArray, Array.prototype.every, Array.prototype.forEach, Array.prototype.indexOf, Array.prototype.map, Date.now, Function.prototype.bind, Object.keys, String.prototype.split, String.prototype.trim, + // Should this instead use React.addons.cloneWithProps or React.cloneElement? + var _children = React.Children.map(children, function (child, index) { + // console.log(child.type, ComboboxOption.type) + if (child.type !== ComboboxOption || !child.props.isFocusable) { + // allow random elements to live in this list + return child; + } + isEmpty = false; + // TODO: cloneWithProps and map instead of altering the children in-place + var props = child.props; + var newProps = {}; + if (this.state.value === child.props.value) { + // need an ID for WAI-ARIA + newProps.id = props.id || 'ic-tokeninput-selected-' + ++guid; + newProps.isSelected = true; + activedescendant = props.id; + } + newProps.onBlur = this.handleOptionBlur; + newProps.onClick = this.selectOption.bind(this, child); + newProps.onFocus = this.handleOptionFocus; + newProps.onKeyDown = this.handleOptionKeyDown.bind(this, child); + newProps.onMouseEnter = this.handleOptionMouseEnter.bind(this, index); - // shams - Object.create, Object.freeze]; + return React.cloneElement(child, newProps); + }.bind(_this)); - for (var i = 0; i < expectedFeatures.length; i++) { - if (!expectedFeatures[i]) { - console.error('One or more ES5 shim/shams expected by React are not available: ' + 'https://fb.me/react-warning-polyfills'); - break; + return { + children: _children, + activedescendant: activedescendant, + isEmpty: isEmpty + }; + }, _this.getClassName = function () { + var className = addClass(_this.props.className, 'ic-tokeninput'); + if (_this.state.isOpen) className = addClass(className, 'ic-tokeninput-is-open'); + return className; + }, _this.clearSelectedState = function (cb) { + _this.setState({ + focusedIndex: null, + inputValue: null, + value: null, + matchedAutocompleteOption: null, + activedescendant: null + }, cb); + }, _this.handleInputChange = function () { + var value = _this.input.value; + _this.clearSelectedState(function () { + this.props.onInput(value); + }.bind(_this)); + }, _this.handleInputFocus = function () { + _this.props.onFocus(); + _this.maybeShowList(); + }, _this.handleInputClick = function () { + _this.maybeShowList(); + }, _this.maybeShowList = function () { + if (_this.props.showListOnFocus) { + _this.showList(); + } + }, _this.handleInputBlur = function () { + var focusedAnOption = _this.state.focusedIndex != null; + if (focusedAnOption) return; + _this.maybeSelectAutocompletedOption(); + _this.hideList(); + }, _this.handleOptionBlur = function () { + // don't want to hide the list if we focused another option + _this.blurTimer = setTimeout(_this.hideList, 0); + }, _this.handleOptionFocus = function () { + // see `handleOptionBlur` + clearTimeout(_this.blurTimer); + }, _this.handleInputKeyUp = function (event) { + if (_this.state.menu.isEmpty || + // autocompleting while backspacing feels super weird, so let's not + event.keyCode === 8 /*backspace*/ || !_this.props.autocomplete.match(/both|inline/)) return; + }, _this.handleButtonClick = function () { + _this.state.isOpen ? _this.hideList() : _this.showList(); + _this.focusInput(); + }, _this.showList = function () { + if (!_this.state.menu.children.length) { + return; } - } + _this.setState({ isOpen: true }); + }, _this.hideList = function () { + _this.setState({ + isOpen: false, + focusedIndex: null + }); + }, _this.hideOnEscape = function (event) { + _this.hideList(); + _this.focusInput(); + event.preventDefault(); + }, _this.focusInput = function () { + _this.input.focus(); + }, _this.selectInput = function () { + _this.input.select(); + }, _this.inputKeydownMap = { + 8: 'removeLastToken', // delete + 13: 'selectOnEnter', // enter + 188: 'selectOnEnter', // comma + 27: 'hideOnEscape', // escape + 38: 'focusPrevious', // up arrow + 40: 'focusNext' // down arrow + }, _this.optionKeydownMap = { + 13: 'selectOption', + 27: 'hideOnEscape', + 38: 'focusPrevious', + 40: 'focusNext' + }, _this.handleKeydown = function (event) { + var handlerName = _this.inputKeydownMap[event.keyCode]; + if (!handlerName) return; + _this.setState({ usingKeyboard: true }); + return _this[handlerName].call(_this, event); + }, _this.handleOptionKeyDown = function (child, event) { + var handlerName = _this.optionKeydownMap[event.keyCode]; + if (!handlerName) { + // if the user starts typing again while focused on an option, move focus + // to the inpute, select so it wipes out any existing value + _this.selectInput(); + return; + } + event.preventDefault(); + _this.setState({ usingKeyboard: true }); + _this[handlerName].call(_this, child); + }, _this.handleOptionMouseEnter = function (index) { + if (_this.state.usingKeyboard) _this.setState({ usingKeyboard: false });else _this.focusOptionAtIndex(index); + }, _this.selectOnEnter = function (event) { + event.preventDefault(); + _this.maybeSelectAutocompletedOption(); + }, _this.maybeSelectAutocompletedOption = function () { + if (!_this.state.matchedAutocompleteOption) { + _this.selectText(); + } else { + _this.selectOption(_this.state.matchedAutocompleteOption, { focus: false }); + } + }, _this.selectOption = function (child, options) { + options = options || {}; + _this.setState({ + // value: child.props.value, + // inputValue: getLabel(child), + matchedAutocompleteOption: null + }, function () { + this.props.onSelect(child.props.value, child); + this.hideList(); + this.clearSelectedState(); // added + if (options.focus !== false) this.selectInput(); + }.bind(_this)); + _this.input.value = ''; // added + }, _this.selectText = function () { + var value = _this.input.value; + if (!value) return; + _this.props.onSelect(value); + _this.clearSelectedState(); + _this.input.value = ''; // added + }, _this.focusNext = function (event) { + if (event.preventDefault) event.preventDefault(); + if (_this.state.menu.isEmpty) return; + var index = _this.nextFocusableIndex(_this.state.focusedIndex); + _this.focusOptionAtIndex(index); + }, _this.removeLastToken = function () { + if (_this.props.onRemoveLast && !_this.input.value) { + _this.props.onRemoveLast(); + } + return true; + }, _this.focusPrevious = function (event) { + if (event.preventDefault) event.preventDefault(); + if (_this.state.menu.isEmpty) return; + var index = _this.previousFocusableIndex(_this.state.focusedIndex); + _this.focusOptionAtIndex(index); + }, _this.focusSelectedOption = function () { + var selectedIndex; + React.Children.forEach(_this.props.children, function (child, index) { + if (child.props.value === this.state.value) selectedIndex = index; + }.bind(_this)); + _this.showList(); + _this.setState({ + focusedIndex: selectedIndex + }, _this.focusOption); + }, _this.findInitialInputValue = function () { + // TODO: might not need this, we should know this in `makeMenu` + var inputValue; + React.Children.forEach(_this.props.children, function (child) { + if (child.props.value === this.props.value) inputValue = getLabel(child); + }.bind(_this)); + return inputValue; + }, _this.clampIndex = function (index) { + if (index < 0) { + return _this.props.children.length - 1; + } else if (index >= _this.props.children.length) { + return 0; + } + return index; + }, _this.scanForFocusableIndex = function (index, increment) { + if (index === null || index === undefined) { + index = increment > 0 ? _this.clampIndex(-1) : 0; + } + var newIndex = index; + while (true) { + newIndex = _this.clampIndex(newIndex + increment); + if (newIndex === index || _this.props.children[newIndex].props.isFocusable) { + return newIndex; + } + } + }, _this.nextFocusableIndex = function (index) { + return _this.scanForFocusableIndex(index, 1); + }, _this.previousFocusableIndex = function (index) { + return _this.scanForFocusableIndex(index, -1); + }, _this.focusOptionAtIndex = function (index) { + if (!_this.state.isOpen && _this.state.value) return _this.focusSelectedOption(); + _this.showList(); + var length = _this.props.children.length; + if (index === -1) index = length - 1;else if (index === length) index = 0; + _this.setState({ + focusedIndex: index + }, _this.focusOption); + }, _this.focusOption = function () { + var index = _this.state.focusedIndex; + _this.list.childNodes[index].focus(); + }, _this.state = { + value: _this.props.value, + // the value displayed in the input + inputValue: _this.findInitialInputValue(), + isOpen: false, + focusedIndex: null, + matchedAutocompleteOption: null, + // this prevents crazy jumpiness since we focus options on mouseenter + usingKeyboard: false, + activedescendant: null, + listId: 'ic-tokeninput-list-' + ++guid, + menu: { + children: [], + activedescendant: null, + isEmpty: true + } + }, _temp), _possibleConstructorReturn(_this, _ret); } - } - - module.exports = React; - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5))) - -/***/ }, -/* 5 */ -/***/ function(module, exports) { - - // shim for using process in browser - - var process = module.exports = {}; - var queue = []; - var draining = false; - var currentQueue; - var queueIndex = -1; - function cleanUpNextTick() { - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; + _createClass(Combobox, [{ + key: 'componentWillMount', + value: function componentWillMount() { + this.setState({ menu: this.makeMenu(this.props.children) }); } - if (queue.length) { - drainQueue(); + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(newProps) { + this.setState({ menu: this.makeMenu(newProps.children) }, function () { + if (newProps.children.length && (this.isOpen || document.activeElement === this.input)) { + if (!this.state.menu.children.length) { + return; + } + this.setState({ + isOpen: true + }, function () { + this.list.scrollTop = 0; + }.bind(this)); + } else { + this.hideList(); + } + }.bind(this)); } - } - function drainQueue() { - if (draining) { - return; - } - var timeout = setTimeout(cleanUpNextTick); - draining = true; + /** + * We don't create the components, the user supplies them, + * so before rendering we attach handlers to facilitate communication from + * the ComboboxOption to the Combobox. + */ - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - clearTimeout(timeout); - } - process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - setTimeout(drainQueue, 0); + /** + * When the user begins typing again we need to clear out any state that has + * to do with an existing or potential selection. + */ + + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var ariaLabel = this.props['aria-label'] || 'Start typing to search. ' + 'Press the down arrow to navigate results. If you don\'t find an ' + 'acceptable option, you can input an alternative. Once you find or ' + 'input the tag you want, press Enter or Comma to add it.'; + + return React.createElement( + 'div', + { className: this.getClassName() }, + this.props.value, + this.state.inputValue, + React.createElement('input', { + ref: function ref(e) { + return _this2.input = e; + }, + autoComplete: 'off', + spellCheck: 'false', + 'aria-label': ariaLabel, + 'aria-expanded': this.state.isOpen + '', + 'aria-haspopup': 'true', + 'aria-activedescendant': this.state.menu.activedescendant, + 'aria-autocomplete': 'list', + 'aria-owns': this.state.listId, + id: this.props.id, + disabled: this.props.isDisabled, + className: 'ic-tokeninput-input', + onFocus: this.handleInputFocus, + onClick: this.handleInputClick, + onChange: this.handleInputChange, + onBlur: this.handleInputBlur, + onKeyDown: this.handleKeydown, + onKeyUp: this.handleInputKeyUp, + placeholder: this.props.placeholder, + role: 'combobox' }), + React.createElement( + 'span', + { + 'aria-hidden': 'true', + className: 'ic-tokeninput-button', + onClick: this.handleButtonClick }, + '\u25BE' + ), + React.createElement( + 'div', + { + id: this.state.listId, + ref: function ref(e) { + return _this2.list = e; + }, + className: 'ic-tokeninput-list', + role: 'listbox' }, + this.state.menu.children + ) + ); } - }; + }]); - // v8 likes predictible objects - function Item(fun, array) { - this.fun = fun; - this.array = array; - } - Item.prototype.run = function () { - this.fun.apply(null, this.array); - }; - process.title = 'browser'; - process.browser = true; - process.env = {}; - process.argv = []; - process.version = ''; // empty string to avoid regexp issues - process.versions = {}; + return Combobox; + }(React.Component); - function noop() {} + Combobox.propTypes = { + onFocus: PropTypes.func, - process.on = noop; - process.addListener = noop; - process.once = noop; - process.off = noop; - process.removeListener = noop; - process.removeAllListeners = noop; - process.emit = noop; + /** + * Called when the combobox receives user input, this is your chance to + * filter the data and rerender the options. + * + * Signature: + * + * ```js + * function(userInput){} + * ``` + */ + onInput: PropTypes.func, - process.binding = function (name) { - throw new Error('process.binding is not supported'); - }; + /** + * Called when the combobox receives a selection. You probably want to reset + * the options to the full list at this point. + * + * Signature: + * + * ```js + * function(selectedValue){} + * ``` + */ + onSelect: PropTypes.func, - process.cwd = function () { return '/' }; - process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); + /** + * Shown when the combobox is empty. + */ + placeholder: PropTypes.string + }; + Combobox.defaultProps = { + autocomplete: 'both', + onFocus: k, + onInput: k, + onSelect: k, + value: null, + showListOnFocus: false }; - process.umask = function() { return 0; }; + + + function getLabel(component) { + return component.props.label || component.props.children; + } + + function matchFragment(userInput, firstChildLabel) { + userInput = userInput.toLowerCase(); + firstChildLabel = firstChildLabel.toLowerCase(); + if (userInput === '' || userInput === firstChildLabel) return false; + if (firstChildLabel.toLowerCase().indexOf(userInput.toLowerCase()) === -1) return false; + return true; + } + + module.exports = Combobox; +/***/ }), +/* 2 */ +/***/ (function(module, exports) { -/***/ }, -/* 6 */ -/***/ function(module, exports) { + module.exports = __WEBPACK_EXTERNAL_MODULE_2__; + +/***/ }), +/* 3 */ +/***/ (function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_3__; + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { - /** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactCurrentOwner - */ - 'use strict'; - /** - * Keeps track of the current owner. - * - * The current owner is the component who should own any components that are - * currently being constructed. - */ - var ReactCurrentOwner = { - - /** - * @internal - * @type {ReactComponent} - */ - current: null - - }; + module.exports = addClass; - module.exports = ReactCurrentOwner; + function addClass(existing, added) { + if (!existing) return added; + if (existing.indexOf(added) > -1) return existing; + return existing + ' ' + added; + } -/***/ }, -/* 7 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(process) {/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactDOMTextComponent - * @typechecks static-only - */ - 'use strict'; - var DOMChildrenOperations = __webpack_require__(8); - var DOMPropertyOperations = __webpack_require__(23); - var ReactComponentBrowserEnvironment = __webpack_require__(27); - var ReactMount = __webpack_require__(29); + 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; }; }(); - var assign = __webpack_require__(40); - var escapeTextContentForBrowser = __webpack_require__(22); - var setTextContent = __webpack_require__(21); - var validateDOMNesting = __webpack_require__(71); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - /** - * Text nodes violate a couple assumptions that React makes about components: - * - * - When mounting text into the DOM, adjacent text nodes are merged. - * - Text nodes cannot be assigned a React root ID. - * - * This component is used to wrap strings in elements so that they can undergo - * the same reconciliation that is applied to elements. - * - * TODO: Investigate representing React components in the DOM with text nodes. - * - * @class ReactDOMTextComponent - * @extends ReactComponent - * @internal - */ - var ReactDOMTextComponent = function (props) { - // This constructor and its argument is currently used by mocks. - }; + 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; } - assign(ReactDOMTextComponent.prototype, { + 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; } - /** - * @param {ReactText} text - * @internal - */ - construct: function (text) { - // TODO: This is really a ReactText (ReactNode), not a ReactElement - this._currentElement = text; - this._stringText = '' + text; + var PropTypes = __webpack_require__(2); + var React = __webpack_require__(3); + var addClass = __webpack_require__(4); - // Properties - this._rootNodeID = null; - this._mountIndex = 0; - }, + var Option = function (_React$Component) { + _inherits(Option, _React$Component); - /** - * Creates the markup for this text node. This node is not intended to have - * any features besides containing text content. - * - * @param {string} rootID DOM ID of the root node. - * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction - * @return {string} Markup for this text node. - * @internal - */ - mountComponent: function (rootID, transaction, context) { - if (process.env.NODE_ENV !== 'production') { - if (context[validateDOMNesting.ancestorInfoContextKey]) { - validateDOMNesting('span', null, context[validateDOMNesting.ancestorInfoContextKey]); + function Option() { + _classCallCheck(this, Option); + + return _possibleConstructorReturn(this, (Option.__proto__ || Object.getPrototypeOf(Option)).apply(this, arguments)); + } + + _createClass(Option, [{ + key: 'render', + value: function render() { + var props = this.props; + if (props.isSelected) { + props.className = addClass(props.className, 'ic-tokeninput-selected'); + props.ariaSelected = true; } + return React.createElement('div', props); } + }]); - this._rootNodeID = rootID; - if (transaction.useCreateElement) { - var ownerDocument = context[ReactMount.ownerDocumentContextKey]; - var el = ownerDocument.createElement('span'); - DOMPropertyOperations.setAttributeForID(el, rootID); - // Populate node cache - ReactMount.getID(el); - setTextContent(el, this._stringText); - return el; - } else { - var escapedText = escapeTextContentForBrowser(this._stringText); + return Option; + }(React.Component); - if (transaction.renderToStaticMarkup) { - // Normally we'd wrap this in a `span` for the reasons stated above, but - // since this is a situation where React won't take over (static pages), - // we can simply return the text as it is. - return escapedText; - } + Option.propTypes = { - return '' + escapedText + ''; - } - }, + /** + * The value that will be sent to the `onSelect` handler of the + * parent Combobox. + */ + value: PropTypes.any.isRequired, /** - * Updates this component by updating the text content. - * - * @param {ReactText} nextText The next text content - * @param {ReactReconcileTransaction} transaction - * @internal - */ - receiveComponent: function (nextText, transaction) { - if (nextText !== this._currentElement) { - this._currentElement = nextText; - var nextStringText = '' + nextText; - if (nextStringText !== this._stringText) { - // TODO: Save this as pending props and use performUpdateIfNecessary - // and/or updateComponent to do the actual update for consistency with - // other component types? - this._stringText = nextStringText; - var node = ReactMount.getNode(this._rootNodeID); - DOMChildrenOperations.updateTextContent(node, nextStringText); - } - } - }, + * What value to put into the input element when this option is + * selected, defaults to its children coerced to a string. + */ + label: PropTypes.string, - unmountComponent: function () { - ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID); - } + /** + * Whether the element should be selectable + */ + isFocusable: PropTypes.bool + }; + Option.defaultProps = { + role: 'option', + tabIndex: '-1', + className: 'ic-tokeninput-option', + isSelected: false, + isFocusable: true + }; - }); - module.exports = ReactDOMTextComponent; - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5))) + module.exports = Option; -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(process) {/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule DOMChildrenOperations - * @typechecks static-only - */ - 'use strict'; - var Danger = __webpack_require__(9); - var ReactMultiChildUpdateTypes = __webpack_require__(17); - var ReactPerf = __webpack_require__(19); - - var setInnerHTML = __webpack_require__(20); - var setTextContent = __webpack_require__(21); - var invariant = __webpack_require__(14); - - /** - * Inserts `childNode` as a child of `parentNode` at the `index`. - * - * @param {DOMElement} parentNode Parent node in which to insert. - * @param {DOMElement} childNode Child node to insert. - * @param {number} index Index at which to insert the child. - * @internal - */ - function insertChildAt(parentNode, childNode, index) { - // By exploiting arrays returning `undefined` for an undefined index, we can - // rely exclusively on `insertBefore(node, null)` instead of also using - // `appendChild(node)`. However, using `undefined` is not allowed by all - // browsers so we must replace it with `null`. - - // fix render order error in safari - // IE8 will throw error when index out of list size. - var beforeChild = index >= parentNode.childNodes.length ? null : parentNode.childNodes.item(index); - - parentNode.insertBefore(childNode, beforeChild); - } - - /** - * Operations for updating with DOM children. - */ - var DOMChildrenOperations = { + 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; }; }(); - dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup, + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - updateTextContent: setTextContent, + 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; } - /** - * Updates a component's children by processing a series of updates. The - * update configurations are each expected to have a `parentNode` property. - * - * @param {array} updates List of update configurations. - * @param {array} markupList List of markup strings. - * @internal - */ - processUpdates: function (updates, markupList) { - var update; - // Mapping from parent IDs to initial child orderings. - var initialChildren = null; - // List of children that will be moved or removed. - var updatedChildren = null; + 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; } - for (var i = 0; i < updates.length; i++) { - update = updates[i]; - if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING || update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) { - var updatedIndex = update.fromIndex; - var updatedChild = update.parentNode.childNodes[updatedIndex]; - var parentID = update.parentID; + var React = __webpack_require__(3); - !updatedChild ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processUpdates(): Unable to find child %s of element. This ' + 'probably means the DOM was unexpectedly mutated (e.g., by the ' + 'browser), usually due to forgetting a when using tables, ' + 'nesting tags like , , or , or using non-SVG elements ' + 'in an parent. Try inspecting the child nodes of the element ' + 'with React ID `%s`.', updatedIndex, parentID) : invariant(false) : undefined; + var Token = function (_React$Component) { + _inherits(Token, _React$Component); - initialChildren = initialChildren || {}; - initialChildren[parentID] = initialChildren[parentID] || []; - initialChildren[parentID][updatedIndex] = updatedChild; + function Token() { + var _ref; - updatedChildren = updatedChildren || []; - updatedChildren.push(updatedChild); - } - } + var _temp, _this, _ret; - var renderedMarkup; - // markupList is either a list of markup or just a list of elements - if (markupList.length && typeof markupList[0] === 'string') { - renderedMarkup = Danger.dangerouslyRenderMarkup(markupList); - } else { - renderedMarkup = markupList; - } + _classCallCheck(this, Token); - // Remove updated children first so that `toIndex` is consistent. - if (updatedChildren) { - for (var j = 0; j < updatedChildren.length; j++) { - updatedChildren[j].parentNode.removeChild(updatedChildren[j]); - } + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - for (var k = 0; k < updates.length; k++) { - update = updates[k]; - switch (update.type) { - case ReactMultiChildUpdateTypes.INSERT_MARKUP: - insertChildAt(update.parentNode, renderedMarkup[update.markupIndex], update.toIndex); - break; - case ReactMultiChildUpdateTypes.MOVE_EXISTING: - insertChildAt(update.parentNode, initialChildren[update.parentID][update.fromIndex], update.toIndex); - break; - case ReactMultiChildUpdateTypes.SET_MARKUP: - setInnerHTML(update.parentNode, update.content); - break; - case ReactMultiChildUpdateTypes.TEXT_CONTENT: - setTextContent(update.parentNode, update.content); - break; - case ReactMultiChildUpdateTypes.REMOVE_NODE: - // Already removed by the for-loop above. - break; - } - } + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Token.__proto__ || Object.getPrototypeOf(Token)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function () { + _this.props.onRemove(_this.props.value); + }, _this.handleKeyDown = function (key) { + var enterKey = 13; + if (key.keyCode === enterKey) _this.props.onRemove(_this.props.value); + }, _this.ariaLabelRemove = function () { + return _this.props.tokenAriaFunc ? _this.props.tokenAriaFunc(_this.props.name) : 'Remove \'' + _this.props.name + '\''; + }, _temp), _possibleConstructorReturn(_this, _ret); } - }; + _createClass(Token, [{ + key: 'render', + value: function render() { + return React.createElement( + 'li', + { className: 'ic-token inline-flex' }, + React.createElement( + 'span', + { className: 'ic-token-label' }, + this.props.name + ), + React.createElement( + 'span', + { + role: 'button', + onClick: this.handleClick, + onFocus: this.props.onFocus, + onKeyDown: this.handleKeyDown, + 'aria-label': this.ariaLabelRemove(), + className: 'ic-token-delete-button', + tabIndex: 0 }, + '\u2715' + ) + ); + } + }]); - ReactPerf.measureMethods(DOMChildrenOperations, 'DOMChildrenOperations', { - updateTextContent: 'updateTextContent' - }); + return Token; + }(React.Component); - module.exports = DOMChildrenOperations; - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5))) + module.exports = Token; -/***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(process) {/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule Danger - * @typechecks static-only - */ - 'use strict'; - var ExecutionEnvironment = __webpack_require__(10); + 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; }; }(); - var createNodesFromMarkup = __webpack_require__(11); - var emptyFunction = __webpack_require__(16); - var getMarkupWrap = __webpack_require__(15); - var invariant = __webpack_require__(14); - - var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/; - var RESULT_INDEX_ATTR = 'data-danger-index'; - - /** - * Extracts the `nodeName` from a string of markup. - * - * NOTE: Extracting the `nodeName` does not require a regular expression match - * because we make assumptions about React-generated markup (i.e. there are no - * spaces surrounding the opening tag and there is at least one attribute). - * - * @param {string} markup String of markup. - * @return {string} Node name of the supplied markup. - * @see http://jsperf.com/extract-nodename - */ - function getNodeName(markup) { - return markup.substring(1, markup.indexOf(' ')); - } - - var Danger = { - - /** - * Renders markup into an array of nodes. The markup is expected to render - * into a list of root nodes. Also, the length of `resultList` and - * `markupList` should be the same. - * - * @param {array} markupList List of markup strings to render. - * @return {array} List of rendered nodes. - * @internal - */ - dangerouslyRenderMarkup: function (markupList) { - !ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' + 'thread. Make sure `window` and `document` are available globally ' + 'before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString for server rendering.') : invariant(false) : undefined; - var nodeName; - var markupByNodeName = {}; - // Group markup by `nodeName` if a wrap is necessary, else by '*'. - for (var i = 0; i < markupList.length; i++) { - !markupList[i] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Missing markup.') : invariant(false) : undefined; - nodeName = getNodeName(markupList[i]); - nodeName = getMarkupWrap(nodeName) ? nodeName : '*'; - markupByNodeName[nodeName] = markupByNodeName[nodeName] || []; - markupByNodeName[nodeName][i] = markupList[i]; - } - var resultList = []; - var resultListAssignmentCount = 0; - for (nodeName in markupByNodeName) { - if (!markupByNodeName.hasOwnProperty(nodeName)) { - continue; - } - var markupListByNodeName = markupByNodeName[nodeName]; + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - // This for-in loop skips the holes of the sparse array. The order of - // iteration should follow the order of assignment, which happens to match - // numerical index order, but we don't rely on that. - var resultIndex; - for (resultIndex in markupListByNodeName) { - if (markupListByNodeName.hasOwnProperty(resultIndex)) { - var markup = markupListByNodeName[resultIndex]; + 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; } - // Push the requested markup with an additional RESULT_INDEX_ATTR - // attribute. If the markup does not start with a < character, it - // will be discarded below (with an appropriate console.error). - markupListByNodeName[resultIndex] = markup.replace(OPEN_TAG_NAME_EXP, - // This index will be parsed back out below. - '$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '); - } - } + 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; } - // Render each group of markup with similar wrapping `nodeName`. - var renderNodes = createNodesFromMarkup(markupListByNodeName.join(''), emptyFunction // Do nothing special with
, or , or using non-SVG elements ' + 'in an parent. Try inspecting the child nodes of the element ' + 'with React ID `%s`.', updatedIndex, parentID) : invariant(false) : undefined; + var Token = function (_React$Component) { + _inherits(Token, _React$Component); - initialChildren = initialChildren || {}; - initialChildren[parentID] = initialChildren[parentID] || []; - initialChildren[parentID][updatedIndex] = updatedChild; + function Token() { + var _ref; - updatedChildren = updatedChildren || []; - updatedChildren.push(updatedChild); - } - } + var _temp, _this, _ret; - var renderedMarkup; - // markupList is either a list of markup or just a list of elements - if (markupList.length && typeof markupList[0] === 'string') { - renderedMarkup = Danger.dangerouslyRenderMarkup(markupList); - } else { - renderedMarkup = markupList; - } + _classCallCheck(this, Token); - // Remove updated children first so that `toIndex` is consistent. - if (updatedChildren) { - for (var j = 0; j < updatedChildren.length; j++) { - updatedChildren[j].parentNode.removeChild(updatedChildren[j]); - } + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - for (var k = 0; k < updates.length; k++) { - update = updates[k]; - switch (update.type) { - case ReactMultiChildUpdateTypes.INSERT_MARKUP: - insertChildAt(update.parentNode, renderedMarkup[update.markupIndex], update.toIndex); - break; - case ReactMultiChildUpdateTypes.MOVE_EXISTING: - insertChildAt(update.parentNode, initialChildren[update.parentID][update.fromIndex], update.toIndex); - break; - case ReactMultiChildUpdateTypes.SET_MARKUP: - setInnerHTML(update.parentNode, update.content); - break; - case ReactMultiChildUpdateTypes.TEXT_CONTENT: - setTextContent(update.parentNode, update.content); - break; - case ReactMultiChildUpdateTypes.REMOVE_NODE: - // Already removed by the for-loop above. - break; - } - } + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Token.__proto__ || Object.getPrototypeOf(Token)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function () { + _this.props.onRemove(_this.props.value); + }, _this.handleKeyDown = function (key) { + var enterKey = 13; + if (key.keyCode === enterKey) _this.props.onRemove(_this.props.value); + }, _this.ariaLabelRemove = function () { + return _this.props.tokenAriaFunc ? _this.props.tokenAriaFunc(_this.props.name) : 'Remove \'' + _this.props.name + '\''; + }, _temp), _possibleConstructorReturn(_this, _ret); } - }; + _createClass(Token, [{ + key: 'render', + value: function render() { + return React.createElement( + 'li', + { className: 'ic-token inline-flex' }, + React.createElement( + 'span', + { className: 'ic-token-label' }, + this.props.name + ), + React.createElement( + 'span', + { + role: 'button', + onClick: this.handleClick, + onFocus: this.props.onFocus, + onKeyDown: this.handleKeyDown, + 'aria-label': this.ariaLabelRemove(), + className: 'ic-token-delete-button', + tabIndex: 0 }, + '\u2715' + ) + ); + } + }]); - ReactPerf.measureMethods(DOMChildrenOperations, 'DOMChildrenOperations', { - updateTextContent: 'updateTextContent' - }); + return Token; + }(React.Component); - module.exports = DOMChildrenOperations; - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5))) + module.exports = Token; -/***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(process) {/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule Danger - * @typechecks static-only - */ - 'use strict'; - var ExecutionEnvironment = __webpack_require__(10); + 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; }; }(); - var createNodesFromMarkup = __webpack_require__(11); - var emptyFunction = __webpack_require__(16); - var getMarkupWrap = __webpack_require__(15); - var invariant = __webpack_require__(14); - - var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/; - var RESULT_INDEX_ATTR = 'data-danger-index'; - - /** - * Extracts the `nodeName` from a string of markup. - * - * NOTE: Extracting the `nodeName` does not require a regular expression match - * because we make assumptions about React-generated markup (i.e. there are no - * spaces surrounding the opening tag and there is at least one attribute). - * - * @param {string} markup String of markup. - * @return {string} Node name of the supplied markup. - * @see http://jsperf.com/extract-nodename - */ - function getNodeName(markup) { - return markup.substring(1, markup.indexOf(' ')); - } - - var Danger = { - - /** - * Renders markup into an array of nodes. The markup is expected to render - * into a list of root nodes. Also, the length of `resultList` and - * `markupList` should be the same. - * - * @param {array} markupList List of markup strings to render. - * @return {array} List of rendered nodes. - * @internal - */ - dangerouslyRenderMarkup: function (markupList) { - !ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' + 'thread. Make sure `window` and `document` are available globally ' + 'before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString for server rendering.') : invariant(false) : undefined; - var nodeName; - var markupByNodeName = {}; - // Group markup by `nodeName` if a wrap is necessary, else by '*'. - for (var i = 0; i < markupList.length; i++) { - !markupList[i] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Missing markup.') : invariant(false) : undefined; - nodeName = getNodeName(markupList[i]); - nodeName = getMarkupWrap(nodeName) ? nodeName : '*'; - markupByNodeName[nodeName] = markupByNodeName[nodeName] || []; - markupByNodeName[nodeName][i] = markupList[i]; - } - var resultList = []; - var resultListAssignmentCount = 0; - for (nodeName in markupByNodeName) { - if (!markupByNodeName.hasOwnProperty(nodeName)) { - continue; - } - var markupListByNodeName = markupByNodeName[nodeName]; + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - // This for-in loop skips the holes of the sparse array. The order of - // iteration should follow the order of assignment, which happens to match - // numerical index order, but we don't rely on that. - var resultIndex; - for (resultIndex in markupListByNodeName) { - if (markupListByNodeName.hasOwnProperty(resultIndex)) { - var markup = markupListByNodeName[resultIndex]; + 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; } - // Push the requested markup with an additional RESULT_INDEX_ATTR - // attribute. If the markup does not start with a < character, it - // will be discarded below (with an appropriate console.error). - markupListByNodeName[resultIndex] = markup.replace(OPEN_TAG_NAME_EXP, - // This index will be parsed back out below. - '$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '); - } - } + 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; } - // Render each group of markup with similar wrapping `nodeName`. - var renderNodes = createNodesFromMarkup(markupListByNodeName.join(''), emptyFunction // Do nothing special with