From ef03b59ee473364ebbd22ea6f07fcc5712d6e75f Mon Sep 17 00:00:00 2001 From: Eric Giovanola Date: Tue, 8 Mar 2016 20:55:07 -0800 Subject: [PATCH] Update to v0.1.6 --- build/react-bootstrap-typeahead.js | 232 ++++++++++++--------- build/react-bootstrap-typeahead.js.map | 2 +- build/react-bootstrap-typeahead.min.js | 4 +- build/react-bootstrap-typeahead.min.js.map | 2 +- lib/Token.react.js | 17 +- lib/TokenizerInput.react.js | 20 +- lib/Typeahead.react.js | 41 ++++ lib/TypeaheadInput.react.js | 8 +- lib/TypeaheadMenu.react.js | 12 +- package.json | 2 +- 10 files changed, 216 insertions(+), 124 deletions(-) diff --git a/build/react-bootstrap-typeahead.js b/build/react-bootstrap-typeahead.js index d77743e8..eb11cb69 100644 --- a/build/react-bootstrap-typeahead.js +++ b/build/react-bootstrap-typeahead.js @@ -54,23 +54,23 @@ var _react2 = _interopRequireDefault(_react); - var _TokenizerInput = __webpack_require__(11); + var _TokenizerInput = __webpack_require__(10); var _TokenizerInput2 = _interopRequireDefault(_TokenizerInput); - var _TypeaheadInput = __webpack_require__(12); + var _TypeaheadInput = __webpack_require__(11); var _TypeaheadInput2 = _interopRequireDefault(_TypeaheadInput); - var _TypeaheadMenu = __webpack_require__(13); + var _TypeaheadMenu = __webpack_require__(12); var _TypeaheadMenu2 = _interopRequireDefault(_TypeaheadMenu); - var _lodash = __webpack_require__(9); + var _lodash = __webpack_require__(8); var _keyCode = __webpack_require__(2); - var _reactOnclickoutside = __webpack_require__(7); + var _reactOnclickoutside = __webpack_require__(5); var _reactOnclickoutside2 = _interopRequireDefault(_reactOnclickoutside); @@ -80,7 +80,7 @@ var PropTypes = _react2['default'].PropTypes; - __webpack_require__(8); + __webpack_require__(16); /** * Typeahead @@ -91,7 +91,22 @@ mixins: [_reactOnclickoutside2['default']], propTypes: { + /** + * Allows the creation of new selections on the fly. Note that any new items + * will be added to the list of selections, but not the list of original + * options unless handled as such by `Typeahead`'s parent. + */ + allowNew: PropTypes.bool, + /** + * Specify any pre-selected options. Use only if you want the component to + * be uncontrolled. + */ defaultSelected: PropTypes.array, + /** + * Whether to disable the input. Will also disable selections when + * `multiple={true}`. + */ + disabled: PropTypes.bool, /** * Message to display in the menu if there are no valid results. */ @@ -101,21 +116,37 @@ * will use the `label` key. */ labelKey: PropTypes.string, + /** + * Maximum height of the dropdown menu, in px. + */ maxHeight: PropTypes.number, /** * Whether or not multiple selections are allowed. */ multiple: PropTypes.bool, + /** + * Provides the ability to specify a prefix before the user-entered text to + * indicate that the selection will be new. No-op unless `allowNew={true}`. + */ + newSelectionPrefix: PropTypes.string, /** * Full set of options, including pre-selected options. */ options: PropTypes.array.isRequired, + /** + * Placeholder text for the input. + */ placeholder: PropTypes.string, + /** + * The selected option(s) displayed in the input. Use this prop if you want + * to control the component via its parent. + */ selected: PropTypes.array }, getDefaultProps: function getDefaultProps() { return { + allowNew: false, defaultSelected: [], labelKey: 'label', multiple: false, @@ -162,6 +193,15 @@ return !(option[labelKey].toLowerCase().indexOf(text.toLowerCase()) === -1 || multiple && (0, _lodash.find)(selected, option)); }); + if (!filteredOptions.length && this.props.allowNew) { + var newOption = { + id: (0, _lodash.uniqueId)('new-id-'), + customOption: true + }; + newOption[labelKey] = text; + filteredOptions = [newOption]; + } + var menu = undefined; if (this.state.showMenu) { menu = _react2['default'].createElement(_TypeaheadMenu2['default'], { @@ -185,6 +225,7 @@ return _react2['default'].createElement('div', { className: 'bootstrap-typeahead open', style: { position: 'relative' } }, _react2['default'].createElement(InputComponent, { + disabled: this.props.disabled, filteredOptions: filteredOptions, labelKey: labelKey, onAdd: this._handleAddOption, @@ -396,6 +437,18 @@ /***/ }, /* 4 */ +/***/ function(module, exports) { + + module.exports = ReactDOM; + +/***/ }, +/* 5 */ +/***/ function(module, exports) { + + module.exports = onClickOutside; + +/***/ }, +/* 6 */ /***/ function(module, exports) { /* @@ -451,7 +504,7 @@ /***/ }, -/* 5 */ +/* 7 */ /***/ function(module, exports, __webpack_require__) { /* @@ -704,52 +757,14 @@ } -/***/ }, -/* 6 */ -/***/ function(module, exports) { - - module.exports = ReactDOM; - -/***/ }, -/* 7 */ -/***/ function(module, exports) { - - module.exports = onClickOutside; - /***/ }, /* 8 */ -/***/ function(module, exports, __webpack_require__) { - - // style-loader: Adds some css to the DOM by adding a