UNPKG

25 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.clearTypeahead = clearTypeahead;
9exports.clickOrFocusInput = clickOrFocusInput;
10exports["default"] = void 0;
11exports.getInitialState = getInitialState;
12exports.hideMenu = hideMenu;
13exports.toggleMenu = toggleMenu;
14
15var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
16
17var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
18
19var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
20
21var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
22
23var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
24
25var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
26
27var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
28
29var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
30
31var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
32
33var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
34
35var _propTypes = _interopRequireDefault(require("prop-types"));
36
37var _react = _interopRequireDefault(require("react"));
38
39var _TypeaheadManager = _interopRequireDefault(require("./TypeaheadManager"));
40
41var _propTypes2 = require("../propTypes");
42
43var _utils = require("../utils");
44
45var _constants = require("../constants");
46
47var _excluded = ["onChange"];
48
49function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
50
51function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
52
53function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
54
55function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
56
57var propTypes = {
58 /**
59 * Allows the creation of new selections on the fly. Note that any new items
60 * will be added to the list of selections, but not the list of original
61 * options unless handled as such by `Typeahead`'s parent.
62 *
63 * If a function is specified, it will be used to determine whether a custom
64 * option should be included. The return value should be true or false.
65 */
66 allowNew: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].func]),
67
68 /**
69 * Autofocus the input when the component initially mounts.
70 */
71 autoFocus: _propTypes["default"].bool,
72
73 /**
74 * Whether or not filtering should be case-sensitive.
75 */
76 caseSensitive: (0, _propTypes2.checkPropType)(_propTypes["default"].bool, _propTypes2.caseSensitiveType),
77
78 /**
79 * The initial value displayed in the text input.
80 */
81 defaultInputValue: (0, _propTypes2.checkPropType)(_propTypes["default"].string, _propTypes2.defaultInputValueType),
82
83 /**
84 * Whether or not the menu is displayed upon initial render.
85 */
86 defaultOpen: _propTypes["default"].bool,
87
88 /**
89 * Specify any pre-selected options. Use only if you want the component to
90 * be uncontrolled.
91 */
92 defaultSelected: (0, _propTypes2.checkPropType)(_propTypes["default"].arrayOf(_propTypes2.optionType), _propTypes2.defaultSelectedType),
93
94 /**
95 * Either an array of fields in `option` to search, or a custom filtering
96 * callback.
97 */
98 filterBy: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].string.isRequired), _propTypes["default"].func]),
99
100 /**
101 * Highlights the menu item if there is only one result and allows selecting
102 * that item by hitting enter. Does not work with `allowNew`.
103 */
104 highlightOnlyResult: (0, _propTypes2.checkPropType)(_propTypes["default"].bool, _propTypes2.highlightOnlyResultType),
105
106 /**
107 * An html id attribute, required for assistive technologies such as screen
108 * readers.
109 */
110 id: (0, _propTypes2.checkPropType)(_propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string]), _propTypes2.isRequiredForA11y),
111
112 /**
113 * Whether the filter should ignore accents and other diacritical marks.
114 */
115 ignoreDiacritics: (0, _propTypes2.checkPropType)(_propTypes["default"].bool, _propTypes2.ignoreDiacriticsType),
116
117 /**
118 * Specify the option key to use for display or a function returning the
119 * display string. By default, the selector will use the `label` key.
120 */
121 labelKey: (0, _propTypes2.checkPropType)(_propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].func]), _propTypes2.labelKeyType),
122
123 /**
124 * Maximum number of results to display by default. Mostly done for
125 * performance reasons so as not to render too many DOM nodes in the case of
126 * large data sets.
127 */
128 maxResults: _propTypes["default"].number,
129
130 /**
131 * Number of input characters that must be entered before showing results.
132 */
133 minLength: _propTypes["default"].number,
134
135 /**
136 * Whether or not multiple selections are allowed.
137 */
138 multiple: _propTypes["default"].bool,
139
140 /**
141 * Invoked when the input is blurred. Receives an event.
142 */
143 onBlur: _propTypes["default"].func,
144
145 /**
146 * Invoked whenever items are added or removed. Receives an array of the
147 * selected options.
148 */
149 onChange: _propTypes["default"].func,
150
151 /**
152 * Invoked when the input is focused. Receives an event.
153 */
154 onFocus: _propTypes["default"].func,
155
156 /**
157 * Invoked when the input value changes. Receives the string value of the
158 * input.
159 */
160 onInputChange: _propTypes["default"].func,
161
162 /**
163 * Invoked when a key is pressed. Receives an event.
164 */
165 onKeyDown: _propTypes["default"].func,
166
167 /**
168 * Invoked when menu visibility changes.
169 */
170 onMenuToggle: _propTypes["default"].func,
171
172 /**
173 * Invoked when the pagination menu item is clicked. Receives an event.
174 */
175 onPaginate: _propTypes["default"].func,
176
177 /**
178 * Whether or not the menu should be displayed. `undefined` allows the
179 * component to control visibility, while `true` and `false` show and hide
180 * the menu, respectively.
181 */
182 open: _propTypes["default"].bool,
183
184 /**
185 * Full set of options, including pre-selected options. Must either be an
186 * array of objects (recommended) or strings.
187 */
188 options: _propTypes["default"].arrayOf(_propTypes2.optionType).isRequired,
189
190 /**
191 * Give user the ability to display additional results if the number of
192 * results exceeds `maxResults`.
193 */
194 paginate: _propTypes["default"].bool,
195
196 /**
197 * The selected option(s) displayed in the input. Use this prop if you want
198 * to control the component via its parent.
199 */
200 selected: (0, _propTypes2.checkPropType)(_propTypes["default"].arrayOf(_propTypes2.optionType), _propTypes2.selectedType)
201};
202var defaultProps = {
203 allowNew: false,
204 autoFocus: false,
205 caseSensitive: false,
206 defaultInputValue: '',
207 defaultOpen: false,
208 defaultSelected: [],
209 filterBy: [],
210 highlightOnlyResult: false,
211 ignoreDiacritics: true,
212 labelKey: _constants.DEFAULT_LABELKEY,
213 maxResults: 100,
214 minLength: 0,
215 multiple: false,
216 onBlur: _utils.noop,
217 onFocus: _utils.noop,
218 onInputChange: _utils.noop,
219 onKeyDown: _utils.noop,
220 onMenuToggle: _utils.noop,
221 onPaginate: _utils.noop,
222 paginate: true
223};
224
225function getInitialState(props) {
226 var defaultInputValue = props.defaultInputValue,
227 defaultOpen = props.defaultOpen,
228 defaultSelected = props.defaultSelected,
229 maxResults = props.maxResults,
230 multiple = props.multiple;
231 var selected = props.selected ? props.selected.slice() : defaultSelected.slice();
232 var text = defaultInputValue;
233
234 if (!multiple && selected.length) {
235 // Set the text if an initial selection is passed in.
236 text = (0, _utils.getOptionLabel)(selected[0], props.labelKey);
237
238 if (selected.length > 1) {
239 // Limit to 1 selection in single-select mode.
240 selected = selected.slice(0, 1);
241 }
242 }
243
244 return {
245 activeIndex: -1,
246 activeItem: undefined,
247 initialItem: undefined,
248 isFocused: false,
249 selected: selected,
250 showMenu: defaultOpen,
251 shownResults: maxResults,
252 text: text
253 };
254}
255
256function clearTypeahead(state, props) {
257 return _objectSpread(_objectSpread({}, getInitialState(props)), {}, {
258 isFocused: state.isFocused,
259 selected: [],
260 text: ''
261 });
262}
263
264function clickOrFocusInput(state) {
265 return _objectSpread(_objectSpread({}, state), {}, {
266 isFocused: true,
267 showMenu: true
268 });
269}
270
271function hideMenu(state, props) {
272 var _getInitialState = getInitialState(props),
273 activeIndex = _getInitialState.activeIndex,
274 activeItem = _getInitialState.activeItem,
275 initialItem = _getInitialState.initialItem,
276 shownResults = _getInitialState.shownResults;
277
278 return _objectSpread(_objectSpread({}, state), {}, {
279 activeIndex: activeIndex,
280 activeItem: activeItem,
281 initialItem: initialItem,
282 showMenu: false,
283 shownResults: shownResults
284 });
285}
286
287function toggleMenu(state, props) {
288 return state.showMenu ? hideMenu(state, props) : _objectSpread(_objectSpread({}, state), {}, {
289 showMenu: true
290 });
291}
292/**
293 * Manually trigger the input's change event.
294 * https://stackoverflow.com/questions/23892547/what-is-the-best-way-to-trigger-onchange-event-in-react-js/46012210#46012210
295 */
296
297
298function triggerInputChange(input, value) {
299 var inputValue = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value');
300 inputValue && inputValue.set && inputValue.set.call(input, value);
301 var e = new Event('input', {
302 bubbles: true
303 });
304 input.dispatchEvent(e);
305}
306
307var Typeahead = /*#__PURE__*/function (_React$Component) {
308 (0, _inherits2["default"])(Typeahead, _React$Component);
309
310 var _super = _createSuper(Typeahead);
311
312 function Typeahead() {
313 var _this;
314
315 (0, _classCallCheck2["default"])(this, Typeahead);
316
317 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
318 args[_key] = arguments[_key];
319 }
320
321 _this = _super.call.apply(_super, [this].concat(args));
322 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", getInitialState(_this.props));
323 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputNode", null);
324 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isMenuShown", false);
325 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "items", []);
326 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "blur", function () {
327 _this.inputNode && _this.inputNode.blur();
328
329 _this.hideMenu();
330 });
331 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "clear", function () {
332 _this.setState(clearTypeahead);
333 });
334 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "focus", function () {
335 _this.inputNode && _this.inputNode.focus();
336 });
337 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getInput", function () {
338 return _this.inputNode;
339 });
340 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputRef", function (inputNode) {
341 _this.inputNode = inputNode;
342 });
343 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setItem", function (item, position) {
344 _this.items[position] = item;
345 });
346 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "hideMenu", function () {
347 _this.setState(hideMenu);
348 });
349 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "toggleMenu", function () {
350 _this.setState(toggleMenu);
351 });
352 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleActiveIndexChange", function (activeIndex) {
353 _this.setState(function (state) {
354 return {
355 activeIndex: activeIndex,
356 activeItem: activeIndex >= 0 ? state.activeItem : undefined
357 };
358 });
359 });
360 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleActiveItemChange", function (activeItem) {
361 // Don't update the active item if it hasn't changed.
362 if (!(0, _fastDeepEqual["default"])(activeItem, _this.state.activeItem)) {
363 _this.setState({
364 activeItem: activeItem
365 });
366 }
367 });
368 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleBlur", function (e) {
369 e.persist();
370
371 _this.setState({
372 isFocused: false
373 }, function () {
374 return _this.props.onBlur(e);
375 });
376 });
377 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleChange", function (selected) {
378 _this.props.onChange && _this.props.onChange(selected);
379 });
380 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleClear", function () {
381 _this.inputNode && triggerInputChange(_this.inputNode, '');
382
383 _this.setState(clearTypeahead, function () {
384 // Change handler is automatically triggered for single selections but
385 // not multi-selections.
386 if (_this.props.multiple) {
387 _this._handleChange([]);
388 }
389 });
390 });
391 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleClick", function (e) {
392 var _this$props$inputProp;
393
394 e.persist();
395 var onClick = (_this$props$inputProp = _this.props.inputProps) === null || _this$props$inputProp === void 0 ? void 0 : _this$props$inputProp.onClick;
396
397 _this.setState(clickOrFocusInput, function () {
398 return (0, _utils.isFunction)(onClick) && onClick(e);
399 });
400 });
401 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleFocus", function (e) {
402 e.persist();
403
404 _this.setState(clickOrFocusInput, function () {
405 return _this.props.onFocus(e);
406 });
407 });
408 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleInitialItemChange", function (initialItem) {
409 // Don't update the initial item if it hasn't changed.
410 if (!(0, _fastDeepEqual["default"])(initialItem, _this.state.initialItem)) {
411 _this.setState({
412 initialItem: initialItem
413 });
414 }
415 });
416 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleInputChange", function (e) {
417 e.persist();
418 var text = e.currentTarget.value;
419 var _this$props = _this.props,
420 multiple = _this$props.multiple,
421 onInputChange = _this$props.onInputChange; // Clear selections when the input value changes in single-select mode.
422
423 var shouldClearSelections = _this.state.selected.length && !multiple;
424
425 _this.setState(function (state, props) {
426 var _getInitialState2 = getInitialState(props),
427 activeIndex = _getInitialState2.activeIndex,
428 activeItem = _getInitialState2.activeItem,
429 shownResults = _getInitialState2.shownResults;
430
431 return {
432 activeIndex: activeIndex,
433 activeItem: activeItem,
434 selected: shouldClearSelections ? [] : state.selected,
435 showMenu: true,
436 shownResults: shownResults,
437 text: text
438 };
439 }, function () {
440 onInputChange(text, e);
441 shouldClearSelections && _this._handleChange([]);
442 });
443 });
444 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleKeyDown", function (e) {
445 var activeItem = _this.state.activeItem; // Skip most actions when the menu is hidden.
446
447 if (!_this.isMenuShown) {
448 if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
449 _this.setState({
450 showMenu: true
451 });
452 }
453
454 _this.props.onKeyDown(e);
455
456 return;
457 }
458
459 switch (e.key) {
460 case 'ArrowUp':
461 case 'ArrowDown':
462 // Prevent input cursor from going to the beginning when pressing up.
463 e.preventDefault();
464
465 _this._handleActiveIndexChange((0, _utils.getUpdatedActiveIndex)(_this.state.activeIndex, e.key, _this.items));
466
467 break;
468
469 case 'Enter':
470 // Prevent form submission while menu is open.
471 e.preventDefault();
472 activeItem && _this._handleMenuItemSelect(activeItem, e);
473 break;
474
475 case 'Escape':
476 case 'Tab':
477 // ESC simply hides the menu. TAB will blur the input and move focus to
478 // the next item; hide the menu so it doesn't gain focus.
479 _this.hideMenu();
480
481 break;
482
483 default:
484 break;
485 }
486
487 _this.props.onKeyDown(e);
488 });
489 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleMenuItemSelect", function (option, e) {
490 if ((0, _utils.getOptionProperty)(option, 'paginationOption')) {
491 _this._handlePaginate(e);
492 } else {
493 _this._handleSelectionAdd(option);
494 }
495 });
496 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handlePaginate", function (e) {
497 e.persist();
498
499 _this.setState(function (state, props) {
500 return {
501 shownResults: state.shownResults + props.maxResults
502 };
503 }, function () {
504 return _this.props.onPaginate(e, _this.state.shownResults);
505 });
506 });
507 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleSelectionAdd", function (option) {
508 var _this$props2 = _this.props,
509 multiple = _this$props2.multiple,
510 labelKey = _this$props2.labelKey;
511 var selected;
512 var selection = option;
513 var text; // Add a unique id to the custom selection. Avoid doing this in `render` so
514 // the id doesn't increment every time.
515
516 if (!(0, _utils.isString)(selection) && selection.customOption) {
517 selection = _objectSpread(_objectSpread({}, selection), {}, {
518 id: (0, _utils.uniqueId)('new-id-')
519 });
520 }
521
522 if (multiple) {
523 // If multiple selections are allowed, add the new selection to the
524 // existing selections.
525 selected = _this.state.selected.concat(selection);
526 text = '';
527 } else {
528 // If only a single selection is allowed, replace the existing selection
529 // with the new one.
530 selected = [selection];
531 text = (0, _utils.getOptionLabel)(selection, labelKey);
532 }
533
534 _this.setState(function (state, props) {
535 return _objectSpread(_objectSpread({}, hideMenu(state, props)), {}, {
536 initialItem: selection,
537 selected: selected,
538 text: text
539 });
540 }, function () {
541 return _this._handleChange(selected);
542 });
543 });
544 (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleSelectionRemove", function (selection) {
545 var selected = _this.state.selected.filter(function (option) {
546 return !(0, _fastDeepEqual["default"])(option, selection);
547 }); // Make sure the input stays focused after the item is removed.
548
549
550 _this.focus();
551
552 _this.setState(function (state, props) {
553 return _objectSpread(_objectSpread({}, hideMenu(state, props)), {}, {
554 selected: selected
555 });
556 }, function () {
557 return _this._handleChange(selected);
558 });
559 });
560 return _this;
561 }
562
563 (0, _createClass2["default"])(Typeahead, [{
564 key: "componentDidMount",
565 value: function componentDidMount() {
566 this.props.autoFocus && this.focus();
567 }
568 }, {
569 key: "componentDidUpdate",
570 value: function componentDidUpdate(prevProps, prevState) {
571 var _this$props3 = this.props,
572 labelKey = _this$props3.labelKey,
573 multiple = _this$props3.multiple,
574 selected = _this$props3.selected;
575 (0, _utils.validateSelectedPropChange)(selected, prevProps.selected); // Sync selections in state with those in props.
576
577 if (selected && !(0, _fastDeepEqual["default"])(selected, prevState.selected)) {
578 this.setState({
579 selected: selected
580 });
581
582 if (!multiple) {
583 this.setState({
584 text: selected.length ? (0, _utils.getOptionLabel)(selected[0], labelKey) : ''
585 });
586 }
587 }
588 }
589 }, {
590 key: "render",
591 value: function render() {
592 var _this$props4 = this.props,
593 onChange = _this$props4.onChange,
594 props = (0, _objectWithoutProperties2["default"])(_this$props4, _excluded);
595
596 var mergedPropsAndState = _objectSpread(_objectSpread({}, props), this.state);
597
598 var filterBy = mergedPropsAndState.filterBy,
599 labelKey = mergedPropsAndState.labelKey,
600 options = mergedPropsAndState.options,
601 paginate = mergedPropsAndState.paginate,
602 shownResults = mergedPropsAndState.shownResults,
603 text = mergedPropsAndState.text;
604 this.isMenuShown = (0, _utils.isShown)(mergedPropsAndState);
605 this.items = []; // Reset items on re-render.
606
607 var results = [];
608
609 if (this.isMenuShown) {
610 var cb = (0, _utils.isFunction)(filterBy) ? filterBy : _utils.defaultFilterBy;
611 results = options.filter(function (option) {
612 return cb(option, mergedPropsAndState);
613 }); // This must come before results are truncated.
614
615 var shouldPaginate = paginate && results.length > shownResults; // Truncate results if necessary.
616
617 results = (0, _utils.getTruncatedOptions)(results, shownResults); // Add the custom option if necessary.
618
619 if ((0, _utils.addCustomOption)(results, mergedPropsAndState)) {
620 results.push((0, _defineProperty2["default"])({
621 customOption: true
622 }, (0, _utils.getStringLabelKey)(labelKey), text));
623 } // Add the pagination item if necessary.
624
625
626 if (shouldPaginate) {
627 var _results$push2;
628
629 results.push((_results$push2 = {}, (0, _defineProperty2["default"])(_results$push2, (0, _utils.getStringLabelKey)(labelKey), ''), (0, _defineProperty2["default"])(_results$push2, "paginationOption", true), _results$push2));
630 }
631 }
632
633 return /*#__PURE__*/_react["default"].createElement(_TypeaheadManager["default"], (0, _extends2["default"])({}, mergedPropsAndState, {
634 hideMenu: this.hideMenu,
635 inputNode: this.inputNode,
636 inputRef: this.inputRef,
637 isMenuShown: this.isMenuShown,
638 onActiveItemChange: this._handleActiveItemChange,
639 onAdd: this._handleSelectionAdd,
640 onBlur: this._handleBlur,
641 onChange: this._handleInputChange,
642 onClear: this._handleClear,
643 onClick: this._handleClick,
644 onFocus: this._handleFocus,
645 onHide: this.hideMenu,
646 onInitialItemChange: this._handleInitialItemChange,
647 onKeyDown: this._handleKeyDown,
648 onMenuItemClick: this._handleMenuItemSelect,
649 onRemove: this._handleSelectionRemove,
650 results: results,
651 setItem: this.setItem,
652 toggleMenu: this.toggleMenu
653 }));
654 }
655 }]);
656 return Typeahead;
657}(_react["default"].Component);
658
659(0, _defineProperty2["default"])(Typeahead, "propTypes", propTypes);
660(0, _defineProperty2["default"])(Typeahead, "defaultProps", defaultProps);
661var _default = Typeahead;
662exports["default"] = _default;
\No newline at end of file