carbon-addons-iot-react 2.98.2 → 2.100.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/css/carbon-addons-iot-react.css +39 -33
  2. package/css/carbon-addons-iot-react.css.map +1 -1
  3. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBox.js +98 -0
  4. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxField.js +57 -0
  5. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenu.js +43 -0
  6. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenuIcon.js +55 -0
  7. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenuItem.js +58 -0
  8. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxPropTypes.js +12 -0
  9. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxSelection.js +96 -0
  10. package/es/node_modules/carbon-components-react/es/components/ListBox/index.js +21 -0
  11. package/es/node_modules/carbon-components-react/es/prop-types/childrenOfType.js +36 -0
  12. package/es/node_modules/carbon-components-react/es/prop-types/tools/createChainableTypeChecker.js +38 -0
  13. package/es/node_modules/carbon-components-react/es/prop-types/tools/getDisplayName.js +37 -0
  14. package/es/src/components/ComboBox/CarbonComboBox.jsx +882 -0
  15. package/es/src/components/ComboBox/ComboBox.jsx +375 -0
  16. package/es/src/components/ComposedModal/ComposedModal.jsx +5 -1
  17. package/es/src/index.js +2 -1
  18. package/lib/css/carbon-addons-iot-react.css +39 -33
  19. package/lib/css/carbon-addons-iot-react.css.map +1 -1
  20. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBox.js +103 -0
  21. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxField.js +62 -0
  22. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenu.js +48 -0
  23. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenuIcon.js +60 -0
  24. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenuItem.js +63 -0
  25. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxPropTypes.js +17 -0
  26. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxSelection.js +101 -0
  27. package/lib/node_modules/carbon-components-react/es/components/ListBox/index.js +23 -0
  28. package/lib/node_modules/carbon-components-react/es/prop-types/childrenOfType.js +41 -0
  29. package/lib/node_modules/carbon-components-react/es/prop-types/tools/createChainableTypeChecker.js +40 -0
  30. package/lib/node_modules/carbon-components-react/es/prop-types/tools/getDisplayName.js +39 -0
  31. package/lib/scss/components/ComboBox/_combo-box.scss +43 -0
  32. package/lib/scss/components/ComposedModal/_composed-modal.scss +5 -0
  33. package/lib/scss/components/Tag/_tag.scss +11 -0
  34. package/lib/scss/styles.scss +1 -44
  35. package/lib/src/components/ComboBox/CarbonComboBox.jsx +889 -0
  36. package/lib/src/components/ComboBox/ComboBox.jsx +380 -0
  37. package/lib/src/components/ComposedModal/ComposedModal.jsx +5 -1
  38. package/lib/src/index.js +2 -1
  39. package/package.json +7 -5
  40. package/scss/components/ComboBox/_combo-box.scss +43 -0
  41. package/scss/components/ComposedModal/_composed-modal.scss +5 -0
  42. package/scss/components/Tag/_tag.scss +11 -0
  43. package/scss/styles.scss +1 -44
  44. package/umd/carbon-addons-iot-react.js +3327 -237
@@ -0,0 +1,889 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var PropTypes = _interopDefault(require('prop-types'));
6
+ var React = require('react');
7
+ var React__default = _interopDefault(React);
8
+ var classnames = _interopDefault(require('classnames'));
9
+ var iconsReact = require('@carbon/icons-react');
10
+ require('core-js/modules/es.array.filter');
11
+ var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
12
+ var carbonComponents = require('carbon-components');
13
+ var _extends = _interopDefault(require('@babel/runtime/helpers/extends'));
14
+ var _objectWithoutProperties = _interopDefault(require('@babel/runtime/helpers/objectWithoutProperties'));
15
+ require('core-js/modules/es.array.map');
16
+ var _classCallCheck = _interopDefault(require('@babel/runtime/helpers/classCallCheck'));
17
+ var _createClass = _interopDefault(require('@babel/runtime/helpers/createClass'));
18
+ var _possibleConstructorReturn = _interopDefault(require('@babel/runtime/helpers/possibleConstructorReturn'));
19
+ var _getPrototypeOf = _interopDefault(require('@babel/runtime/helpers/getPrototypeOf'));
20
+ var _assertThisInitialized = _interopDefault(require('@babel/runtime/helpers/assertThisInitialized'));
21
+ var _inherits = _interopDefault(require('@babel/runtime/helpers/inherits'));
22
+ require('core-js/modules/es.array.index-of');
23
+ var Downshift = _interopDefault(require('downshift'));
24
+ var __chunk_197 = require('../../../node_modules/carbon-components-react/es/components/ListBox/index.js');
25
+
26
+ var keys = {
27
+ Tab: {
28
+ key: 'Tab',
29
+ which: 9,
30
+ keyCode: 9
31
+ },
32
+ Enter: {
33
+ key: 'Enter',
34
+ which: 13,
35
+ keyCode: 13
36
+ },
37
+ Escape: {
38
+ key: ['Escape', // IE11 Escape
39
+ 'Esc'],
40
+ which: 27,
41
+ keyCode: 27
42
+ },
43
+ Space: {
44
+ key: ' ',
45
+ which: 32,
46
+ keyCode: 32
47
+ },
48
+ PageUp: {
49
+ key: 'PageUp',
50
+ which: 33,
51
+ keyCode: 33
52
+ },
53
+ PageDown: {
54
+ key: 'PageDown',
55
+ which: 34,
56
+ keyCode: 34
57
+ },
58
+ End: {
59
+ key: 'End',
60
+ which: 35,
61
+ keyCode: 35
62
+ },
63
+ Home: {
64
+ key: 'Home',
65
+ which: 36,
66
+ keyCode: 36
67
+ },
68
+ ArrowLeft: {
69
+ key: 'ArrowLeft',
70
+ which: 37,
71
+ keyCode: 37
72
+ },
73
+ ArrowUp: {
74
+ key: 'ArrowUp',
75
+ which: 38,
76
+ keyCode: 38
77
+ },
78
+ ArrowRight: {
79
+ key: 'ArrowRight',
80
+ which: 39,
81
+ keyCode: 39
82
+ },
83
+ ArrowDown: {
84
+ key: 'ArrowDown',
85
+ which: 40,
86
+ keyCode: 40
87
+ }
88
+ };
89
+ var ListBoxPropTypes = {
90
+ ListBoxType: PropTypes.oneOf(['default', 'inline']),
91
+ ListBoxSize: PropTypes.oneOf(['sm', 'xl'])
92
+ };
93
+ var prefix = carbonComponents.settings.prefix;
94
+ /**
95
+ * Check to see if the given key matches the corresponding keyboard event. Also
96
+ * supports passing in the value directly if you can't used the given event.
97
+ *
98
+ * @example
99
+ * import * as keys from '../keys';
100
+ * import { matches } from '../match';
101
+ *
102
+ * function handleOnKeyDown(event) {
103
+ * if (match(event, keys.Enter) {
104
+ * // ...
105
+ * }
106
+ * }
107
+ *
108
+ * @param {Event|number|string} eventOrCode
109
+ * @param {Key} key
110
+ * @returns {boolean}
111
+ */
112
+
113
+ /* istanbul ignore next */
114
+
115
+ function match(eventOrCode) {
116
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
117
+ key = _ref.key,
118
+ which = _ref.which,
119
+ keyCode = _ref.keyCode;
120
+
121
+ if (typeof eventOrCode === 'string') {
122
+ return eventOrCode === key;
123
+ }
124
+
125
+ if (typeof eventOrCode === 'number') {
126
+ return eventOrCode === which || eventOrCode === keyCode;
127
+ }
128
+
129
+ if (eventOrCode.key && Array.isArray(key)) {
130
+ return key.indexOf(eventOrCode.key) !== -1;
131
+ }
132
+
133
+ return eventOrCode.key === key || eventOrCode.which === which || eventOrCode.keyCode === keyCode;
134
+ }
135
+ /**
136
+ * Generic utility to initialize a method that will return a unique instance id
137
+ * for a component.
138
+ */
139
+
140
+ function setupGetInstanceId() {
141
+ var instanceId = 0;
142
+ return function getInstanceId() {
143
+ return ++instanceId; // eslint-disable-line no-plusplus
144
+ };
145
+ }
146
+ var defaultItemToString = function defaultItemToString(item) {
147
+ if (typeof item === 'string') {
148
+ return item;
149
+ }
150
+
151
+ return item && item.label;
152
+ };
153
+
154
+ var defaultShouldFilterItem = function defaultShouldFilterItem() {
155
+ return true;
156
+ };
157
+
158
+ var getInputValue = function getInputValue(props, state) {
159
+ if (props.selectedItem) {
160
+ return props.itemToString(props.selectedItem);
161
+ } // TODO: consistent `initialSelectedItem` behavior with other listbox components in v11
162
+
163
+
164
+ if (props.initialSelectedItem) {
165
+ return props.itemToString(props.initialSelectedItem);
166
+ }
167
+
168
+ return state.inputValue || '';
169
+ }; // Since we always provide a func this will never be hit
170
+
171
+ /* istanbul ignore next */
172
+
173
+
174
+ var defaultFindHighlightedIndex = function defaultFindHighlightedIndex(_ref2, inputValue) {
175
+ var items = _ref2.items,
176
+ itemToString = _ref2.itemToString;
177
+
178
+ if (!inputValue) {
179
+ return -1;
180
+ }
181
+
182
+ var searchValue = inputValue.toLowerCase(); // eslint-disable-next-line no-plusplus
183
+
184
+ for (var i = 0; i < items.length; i++) {
185
+ var item = itemToString(items[i]).toLowerCase();
186
+
187
+ if (item.indexOf(searchValue) !== -1 && searchValue.length > 1) {
188
+ return i;
189
+ }
190
+ }
191
+
192
+ return -1;
193
+ };
194
+
195
+ var getInstanceId = setupGetInstanceId();
196
+ /* eslint react/require-default-props: 0 */
197
+
198
+ var ComboBox = /*#__PURE__*/function (_React$Component) {
199
+ _inherits(ComboBox, _React$Component);
200
+
201
+ _createClass(ComboBox, null, [{
202
+ key: "getDerivedStateFromProps",
203
+ value: function getDerivedStateFromProps(nextProps, state) {
204
+ var prevSelectedItem = state.prevSelectedItem,
205
+ doneInitialSelectedItem = state.doneInitialSelectedItem;
206
+ var selectedItem = nextProps.selectedItem;
207
+
208
+ if (!doneInitialSelectedItem || prevSelectedItem !== selectedItem) {
209
+ return {
210
+ doneInitialSelectedItem: true,
211
+ prevSelectedItem: selectedItem,
212
+ inputValue: getInputValue(nextProps, state)
213
+ };
214
+ }
215
+
216
+ return null;
217
+ }
218
+ }]);
219
+
220
+ function ComboBox(props) {
221
+ var _this;
222
+
223
+ _classCallCheck(this, ComboBox);
224
+
225
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(ComboBox).call(this, props));
226
+
227
+ _defineProperty(_assertThisInitialized(_this), "filterItems", function (items, itemToString, inputValue) {
228
+ return items.filter(function (item) {
229
+ return _this.props.shouldFilterItem({
230
+ item: item,
231
+ itemToString: itemToString,
232
+ inputValue: inputValue
233
+ });
234
+ });
235
+ });
236
+
237
+ _defineProperty(_assertThisInitialized(_this), "handleOnChange", function (selectedItem) {
238
+ if (_this.props.onChange) {
239
+ _this.props.onChange({
240
+ selectedItem: selectedItem
241
+ });
242
+ }
243
+ });
244
+
245
+ _defineProperty(_assertThisInitialized(_this), "handleOnInputValueChange", function (inputValue) {
246
+ var onInputChange = _this.props.onInputChange;
247
+
248
+ _this.setState(function () {
249
+ return {
250
+ // Default to empty string if we have a false-y `inputValue`
251
+ inputValue: inputValue || ''
252
+ };
253
+ }, function () {
254
+ if (onInputChange) {
255
+ onInputChange(inputValue);
256
+ }
257
+ });
258
+ });
259
+
260
+ _defineProperty(_assertThisInitialized(_this), "handleOnStateChange", function (newState, _ref3) {
261
+ var setHighlightedIndex = _ref3.setHighlightedIndex,
262
+ highlightedIndex = _ref3.highlightedIndex;
263
+
264
+ _this.props.onHighligtedIndexChange(highlightedIndex);
265
+
266
+ var findHighlightedIndex = _this.props.findHighlightedIndex || defaultFindHighlightedIndex;
267
+
268
+ if (Object.prototype.hasOwnProperty.call(newState, 'inputValue')) {
269
+ var inputValue = newState.inputValue;
270
+ setHighlightedIndex(findHighlightedIndex(_this.props, inputValue));
271
+ }
272
+ });
273
+
274
+ _defineProperty(_assertThisInitialized(_this), "onToggleClick", function (isOpen) {
275
+ return function (event) {
276
+ if (event.target === _this.textInput.current && isOpen) {
277
+ // eslint-disable-next-line no-param-reassign
278
+ event.preventDownshiftDefault = true;
279
+ event.persist();
280
+ }
281
+ };
282
+ });
283
+
284
+ _this.textInput = /*#__PURE__*/React__default.createRef();
285
+ _this.comboBoxInstanceId = getInstanceId();
286
+ _this.state = {
287
+ inputValue: getInputValue(props, {})
288
+ };
289
+ return _this;
290
+ }
291
+
292
+ _createClass(ComboBox, [{
293
+ key: "render",
294
+ value: function render() {
295
+ var _this2 = this;
296
+
297
+ var _this$props = this.props,
298
+ containerClassName = _this$props.className,
299
+ disabled = _this$props.disabled,
300
+ id = _this$props.id,
301
+ items = _this$props.items,
302
+ itemToString = _this$props.itemToString,
303
+ itemToElement = _this$props.itemToElement,
304
+ titleText = _this$props.titleText,
305
+ helperText = _this$props.helperText,
306
+ placeholder = _this$props.placeholder,
307
+ initialSelectedItem = _this$props.initialSelectedItem,
308
+ selectedItem = _this$props.selectedItem,
309
+ ariaLabel = _this$props.ariaLabel,
310
+ translateWithId = _this$props.translateWithId,
311
+ invalid = _this$props.invalid,
312
+ invalidText = _this$props.invalidText,
313
+ light = _this$props.light,
314
+ type = _this$props.type,
315
+ size = _this$props.size,
316
+ shouldFilterItem = _this$props.shouldFilterItem,
317
+ onChange = _this$props.onChange,
318
+ onInputChange = _this$props.onInputChange,
319
+ downshiftProps = _this$props.downshiftProps,
320
+ direction = _this$props.direction,
321
+ onHighligtedIndexChange = _this$props.onHighligtedIndexChange,
322
+ findHighlightedIndex = _this$props.findHighlightedIndex,
323
+ editOptionText = _this$props.editOptionText,
324
+ rest = _objectWithoutProperties(_this$props, ["className", "disabled", "id", "items", "itemToString", "itemToElement", "titleText", "helperText", "placeholder", "initialSelectedItem", "selectedItem", "ariaLabel", "translateWithId", "invalid", "invalidText", "light", "type", "size", "shouldFilterItem", "onChange", "onInputChange", "downshiftProps", "direction", "onHighligtedIndexChange", "findHighlightedIndex", "editOptionText"]);
325
+
326
+ var inputValue = this.state.inputValue;
327
+ var className = classnames("".concat(prefix, "--combo-box"), containerClassName, _defineProperty({}, "".concat(prefix, "--list-box--up"), direction === 'top'));
328
+ var titleClasses = classnames("".concat(prefix, "--label"), _defineProperty({}, "".concat(prefix, "--label--disabled"), disabled));
329
+ var comboBoxHelperId = !helperText ? undefined : "combobox-helper-text-".concat(this.comboBoxInstanceId);
330
+ var comboBoxLabelId = "combobox-label-".concat(this.comboBoxInstanceId);
331
+ var title = titleText ?
332
+ /*#__PURE__*/
333
+ // eslint-disable-next-line jsx-a11y/label-has-for
334
+ React__default.createElement("label", {
335
+ id: comboBoxLabelId,
336
+ htmlFor: id,
337
+ className: titleClasses
338
+ }, titleText) : null;
339
+ var helperClasses = classnames("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
340
+ var helper = helperText ? /*#__PURE__*/React__default.createElement("div", {
341
+ id: comboBoxHelperId,
342
+ className: helperClasses
343
+ }, helperText) : null;
344
+ var wrapperClasses = classnames("".concat(prefix, "--list-box__wrapper"));
345
+ var comboBoxA11yId = "combobox-a11y-".concat(this.comboBoxInstanceId);
346
+ var inputClasses = classnames("".concat(prefix, "--text-input"), _defineProperty({}, "".concat(prefix, "--text-input--empty"), !inputValue)); // needs to be Capitalized for react to render it correctly
347
+
348
+ var ItemToElement = itemToElement;
349
+ var input = /*#__PURE__*/React__default.createElement(Downshift, _extends({}, downshiftProps, {
350
+ onChange: this.handleOnChange,
351
+ onInputValueChange: this.handleOnInputValueChange,
352
+ onStateChange: this.handleOnStateChange,
353
+ inputValue: inputValue || '',
354
+ itemToString: itemToString,
355
+ initialIsOpen: false,
356
+ defaultSelectedItem: initialSelectedItem,
357
+ selectedItem: selectedItem
358
+ }), function (_ref4) {
359
+ var getButtonProps = _ref4.getButtonProps,
360
+ getInputProps = _ref4.getInputProps,
361
+ getItemProps = _ref4.getItemProps,
362
+ getRootProps = _ref4.getRootProps,
363
+ isOpen = _ref4.isOpen,
364
+ inputValue = _ref4.inputValue,
365
+ selectedItem = _ref4.selectedItem,
366
+ highlightedIndex = _ref4.highlightedIndex,
367
+ clearSelection = _ref4.clearSelection,
368
+ toggleMenu = _ref4.toggleMenu;
369
+ // console.log({ highlightedIndex });
370
+ return /*#__PURE__*/React__default.createElement(__chunk_197.default, _extends({
371
+ className: className,
372
+ disabled: disabled,
373
+ invalid: invalid,
374
+ id: comboBoxA11yId,
375
+ "aria-label": ariaLabel,
376
+ invalidText: invalidText,
377
+ isOpen: isOpen,
378
+ light: light,
379
+ size: size
380
+ }, getRootProps({
381
+ refKey: 'innerRef'
382
+ })), /*#__PURE__*/React__default.createElement(__chunk_197.default.Field, _extends({
383
+ id: id,
384
+ disabled: disabled,
385
+ "aria-labelledby": comboBoxLabelId,
386
+ "aria-describedby": comboBoxHelperId
387
+ }, getButtonProps({
388
+ disabled: disabled,
389
+ onClick: _this2.onToggleClick(isOpen)
390
+ })), /*#__PURE__*/React__default.createElement("input", _extends({
391
+ className: inputClasses,
392
+ "aria-labelledby": comboBoxA11yId,
393
+ tabIndex: "0",
394
+ "aria-disabled": disabled,
395
+ "aria-controls": isOpen ? "".concat(id, "__menu") : null,
396
+ "aria-owns": isOpen ? "".concat(id, "__menu") : null,
397
+ "aria-autocomplete": "list",
398
+ ref: _this2.textInput,
399
+ title: inputValue
400
+ }, rest, getInputProps({
401
+ disabled: disabled,
402
+ id: id,
403
+ placeholder: placeholder,
404
+ onKeyDown: function onKeyDown(event) {
405
+ if (match(event, keys.Space)) {
406
+ event.stopPropagation();
407
+ }
408
+
409
+ if (match(event, keys.Enter)) {
410
+ toggleMenu();
411
+ }
412
+ }
413
+ }))), invalid && /*#__PURE__*/React__default.createElement(iconsReact.WarningFilled16, {
414
+ className: "".concat(prefix, "--list-box__invalid-icon")
415
+ }), inputValue && /*#__PURE__*/React__default.createElement(__chunk_197.default.Selection, {
416
+ clearSelection: clearSelection,
417
+ translateWithId: translateWithId,
418
+ disabled: disabled
419
+ }), /*#__PURE__*/React__default.createElement(__chunk_197.default.MenuIcon, {
420
+ isOpen: isOpen,
421
+ translateWithId: translateWithId
422
+ })), /*#__PURE__*/React__default.createElement(__chunk_197.default.Menu, {
423
+ "aria-label": ariaLabel,
424
+ id: id
425
+ }, _this2.filterItems(items, itemToString, inputValue).map(function (item, index) {
426
+ var itemProps = getItemProps({
427
+ item: item,
428
+ index: index
429
+ });
430
+ return /*#__PURE__*/React__default.createElement(__chunk_197.default.MenuItem, _extends({
431
+ key: itemProps.id,
432
+ "data-text": editOptionText,
433
+ isActive: selectedItem === item,
434
+ isHighlighted: highlightedIndex === index || selectedItem && selectedItem.id === item.id || false,
435
+ title: itemToElement ? item.text : itemToString(item)
436
+ }, itemProps), itemToElement ? /*#__PURE__*/React__default.createElement(ItemToElement, _extends({
437
+ key: itemProps.id
438
+ }, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React__default.createElement(iconsReact.Checkmark16, {
439
+ className: "".concat(prefix, "--list-box__menu-item__selected-icon")
440
+ }));
441
+ })));
442
+ });
443
+ return /*#__PURE__*/React__default.createElement("div", {
444
+ className: wrapperClasses
445
+ }, title, helper, input);
446
+ }
447
+ }]);
448
+
449
+ return ComboBox;
450
+ }(React__default.Component);
451
+
452
+ _defineProperty(ComboBox, "propTypes", {
453
+ /**
454
+ * 'aria-label' of the ListBox component.
455
+ */
456
+ ariaLabel: PropTypes.string,
457
+
458
+ /**
459
+ * An optional className to add to the container node
460
+ */
461
+ className: PropTypes.string,
462
+
463
+ /**
464
+ * Specify if the control should be disabled, or not
465
+ */
466
+ disabled: PropTypes.bool,
467
+
468
+ /**
469
+ * Specify a custom `id` for the input
470
+ */
471
+ id: PropTypes.string.isRequired,
472
+
473
+ /**
474
+ * Allow users to pass in an arbitrary item or a string (in case their items are an array of strings)
475
+ * from their collection that are pre-selected
476
+ */
477
+ initialSelectedItem: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
478
+
479
+ /**
480
+ * We try to stay as generic as possible here to allow individuals to pass
481
+ * in a collection of whatever kind of data structure they prefer
482
+ */
483
+ items: PropTypes.array.isRequired,
484
+ // eslint-disable-line react/forbid-prop-types
485
+
486
+ /**
487
+ * Helper function passed to downshift that allows the library to render a
488
+ * given item to a string label. By default, it extracts the `label` field
489
+ * from a given item to serve as the item label in the list
490
+ */
491
+ itemToString: PropTypes.func,
492
+
493
+ /**
494
+ * Optional function to render items as custom components instead of strings.
495
+ * Defaults to null and is overriden by a getter
496
+ */
497
+ itemToElement: PropTypes.func,
498
+
499
+ /**
500
+ * `onChange` is a utility for this controlled component to communicate to a
501
+ * consuming component when a specific dropdown item is selected.
502
+ * @param {{ selectedItem }}
503
+ */
504
+ onChange: PropTypes.func.isRequired,
505
+
506
+ /**
507
+ * Used to provide a placeholder text node before a user enters any input.
508
+ * This is only present if the control has no items selected
509
+ */
510
+ placeholder: PropTypes.string.isRequired,
511
+
512
+ /**
513
+ * Specify your own filtering logic by passing in a `shouldFilterItem`
514
+ * function that takes in the current input and an item and passes back
515
+ * whether or not the item should be filtered.
516
+ */
517
+ shouldFilterItem: PropTypes.func,
518
+
519
+ /**
520
+ * Specify if the currently selected value is invalid.
521
+ */
522
+ invalid: PropTypes.bool,
523
+
524
+ /**
525
+ * Message which is displayed if the value is invalid.
526
+ */
527
+ invalidText: PropTypes.string,
528
+
529
+ /**
530
+ * For full control of the selection
531
+ */
532
+ selectedItem: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
533
+
534
+ /**
535
+ * Specify a custom translation function that takes in a message identifier
536
+ * and returns the localized string for the message
537
+ */
538
+ translateWithId: PropTypes.func,
539
+
540
+ /**
541
+ * Currently supports either the default type, or an inline variant
542
+ */
543
+ type: ListBoxPropTypes.ListBoxType,
544
+
545
+ /**
546
+ * Specify the size of the ListBox. Currently supports either `sm`, `lg` or `xl` as an option.
547
+ */
548
+ size: ListBoxPropTypes.ListBoxSize,
549
+
550
+ /**
551
+ * Callback function to notify consumer when the text input changes.
552
+ * This provides support to change available items based on the text.
553
+ * @param {string} inputText
554
+ */
555
+ onInputChange: PropTypes.func,
556
+
557
+ /**
558
+ * should use "light theme" (white background)?
559
+ */
560
+ light: PropTypes.bool,
561
+
562
+ /**
563
+ * Additional props passed to Downshift
564
+ */
565
+ downshiftProps: PropTypes.shape(Downshift.propTypes),
566
+
567
+ /**
568
+ * Specify the direction of the combobox dropdown. Can be either top or bottom.
569
+ */
570
+ direction: PropTypes.oneOf(['top', 'bottom']),
571
+
572
+ /**
573
+ * Optional callback to pass the highlighted index to parent
574
+ */
575
+ onHighligtedIndexChange: PropTypes.func,
576
+
577
+ /**
578
+ * Optional func to change behavior of highlighted index
579
+ */
580
+ findHighlightedIndex: PropTypes.func,
581
+
582
+ /**
583
+ * String to pass to input field option
584
+ */
585
+ editOptionText: PropTypes.string
586
+ });
587
+
588
+ _defineProperty(ComboBox, "defaultProps", {
589
+ disabled: false,
590
+ itemToString: defaultItemToString,
591
+ itemToElement: null,
592
+ shouldFilterItem: defaultShouldFilterItem,
593
+ type: 'default',
594
+ ariaLabel: 'Choose an item',
595
+ light: false,
596
+ direction: 'bottom',
597
+ editOptionText: '+ Add'
598
+ });
599
+ ComboBox.__docgenInfo = {
600
+ "description": "",
601
+ "methods": [{
602
+ "name": "filterItems",
603
+ "docblock": null,
604
+ "modifiers": [],
605
+ "params": [{
606
+ "name": "items",
607
+ "type": null
608
+ }, {
609
+ "name": "itemToString",
610
+ "type": null
611
+ }, {
612
+ "name": "inputValue",
613
+ "type": null
614
+ }],
615
+ "returns": null
616
+ }, {
617
+ "name": "handleOnChange",
618
+ "docblock": null,
619
+ "modifiers": [],
620
+ "params": [{
621
+ "name": "selectedItem",
622
+ "type": null
623
+ }],
624
+ "returns": null
625
+ }, {
626
+ "name": "handleOnInputValueChange",
627
+ "docblock": null,
628
+ "modifiers": [],
629
+ "params": [{
630
+ "name": "inputValue",
631
+ "type": null
632
+ }],
633
+ "returns": null
634
+ }, {
635
+ "name": "handleOnStateChange",
636
+ "docblock": null,
637
+ "modifiers": [],
638
+ "params": [{
639
+ "name": "newState",
640
+ "type": null
641
+ }, {
642
+ "name": "{ setHighlightedIndex, highlightedIndex }",
643
+ "type": null
644
+ }],
645
+ "returns": null
646
+ }, {
647
+ "name": "onToggleClick",
648
+ "docblock": null,
649
+ "modifiers": [],
650
+ "params": [{
651
+ "name": "isOpen",
652
+ "type": null
653
+ }],
654
+ "returns": null
655
+ }],
656
+ "displayName": "ComboBox",
657
+ "props": {
658
+ "disabled": {
659
+ "defaultValue": {
660
+ "value": "false",
661
+ "computed": false
662
+ },
663
+ "type": {
664
+ "name": "bool"
665
+ },
666
+ "required": false,
667
+ "description": "Specify if the control should be disabled, or not"
668
+ },
669
+ "itemToString": {
670
+ "defaultValue": {
671
+ "value": "item => {\n if (typeof item === 'string') {\n return item;\n }\n\n return item && item.label;\n}",
672
+ "computed": false
673
+ },
674
+ "type": {
675
+ "name": "func"
676
+ },
677
+ "required": false,
678
+ "description": "Helper function passed to downshift that allows the library to render a\ngiven item to a string label. By default, it extracts the `label` field\nfrom a given item to serve as the item label in the list"
679
+ },
680
+ "itemToElement": {
681
+ "defaultValue": {
682
+ "value": "null",
683
+ "computed": false
684
+ },
685
+ "type": {
686
+ "name": "func"
687
+ },
688
+ "required": false,
689
+ "description": "Optional function to render items as custom components instead of strings.\nDefaults to null and is overriden by a getter"
690
+ },
691
+ "shouldFilterItem": {
692
+ "defaultValue": {
693
+ "value": "() => true",
694
+ "computed": false
695
+ },
696
+ "type": {
697
+ "name": "func"
698
+ },
699
+ "required": false,
700
+ "description": "Specify your own filtering logic by passing in a `shouldFilterItem`\nfunction that takes in the current input and an item and passes back\nwhether or not the item should be filtered."
701
+ },
702
+ "type": {
703
+ "defaultValue": {
704
+ "value": "'default'",
705
+ "computed": false
706
+ },
707
+ "type": {
708
+ "name": "custom",
709
+ "raw": "ListBoxPropTypes.ListBoxType"
710
+ },
711
+ "required": false,
712
+ "description": "Currently supports either the default type, or an inline variant"
713
+ },
714
+ "ariaLabel": {
715
+ "defaultValue": {
716
+ "value": "'Choose an item'",
717
+ "computed": false
718
+ },
719
+ "type": {
720
+ "name": "string"
721
+ },
722
+ "required": false,
723
+ "description": "'aria-label' of the ListBox component."
724
+ },
725
+ "light": {
726
+ "defaultValue": {
727
+ "value": "false",
728
+ "computed": false
729
+ },
730
+ "type": {
731
+ "name": "bool"
732
+ },
733
+ "required": false,
734
+ "description": "should use \"light theme\" (white background)?"
735
+ },
736
+ "direction": {
737
+ "defaultValue": {
738
+ "value": "'bottom'",
739
+ "computed": false
740
+ },
741
+ "type": {
742
+ "name": "enum",
743
+ "value": [{
744
+ "value": "'top'",
745
+ "computed": false
746
+ }, {
747
+ "value": "'bottom'",
748
+ "computed": false
749
+ }]
750
+ },
751
+ "required": false,
752
+ "description": "Specify the direction of the combobox dropdown. Can be either top or bottom."
753
+ },
754
+ "editOptionText": {
755
+ "defaultValue": {
756
+ "value": "'+ Add'",
757
+ "computed": false
758
+ },
759
+ "type": {
760
+ "name": "string"
761
+ },
762
+ "required": false,
763
+ "description": "String to pass to input field option"
764
+ },
765
+ "className": {
766
+ "type": {
767
+ "name": "string"
768
+ },
769
+ "required": false,
770
+ "description": "An optional className to add to the container node"
771
+ },
772
+ "id": {
773
+ "type": {
774
+ "name": "string"
775
+ },
776
+ "required": true,
777
+ "description": "Specify a custom `id` for the input"
778
+ },
779
+ "initialSelectedItem": {
780
+ "type": {
781
+ "name": "union",
782
+ "value": [{
783
+ "name": "object"
784
+ }, {
785
+ "name": "string"
786
+ }]
787
+ },
788
+ "required": false,
789
+ "description": "Allow users to pass in an arbitrary item or a string (in case their items are an array of strings)\nfrom their collection that are pre-selected"
790
+ },
791
+ "items": {
792
+ "type": {
793
+ "name": "array"
794
+ },
795
+ "required": true,
796
+ "description": "We try to stay as generic as possible here to allow individuals to pass\nin a collection of whatever kind of data structure they prefer"
797
+ },
798
+ "onChange": {
799
+ "type": {
800
+ "name": "func"
801
+ },
802
+ "required": true,
803
+ "description": "`onChange` is a utility for this controlled component to communicate to a\nconsuming component when a specific dropdown item is selected.\n@param {{ selectedItem }}"
804
+ },
805
+ "placeholder": {
806
+ "type": {
807
+ "name": "string"
808
+ },
809
+ "required": true,
810
+ "description": "Used to provide a placeholder text node before a user enters any input.\nThis is only present if the control has no items selected"
811
+ },
812
+ "invalid": {
813
+ "type": {
814
+ "name": "bool"
815
+ },
816
+ "required": false,
817
+ "description": "Specify if the currently selected value is invalid."
818
+ },
819
+ "invalidText": {
820
+ "type": {
821
+ "name": "string"
822
+ },
823
+ "required": false,
824
+ "description": "Message which is displayed if the value is invalid."
825
+ },
826
+ "selectedItem": {
827
+ "type": {
828
+ "name": "union",
829
+ "value": [{
830
+ "name": "object"
831
+ }, {
832
+ "name": "string"
833
+ }]
834
+ },
835
+ "required": false,
836
+ "description": "For full control of the selection"
837
+ },
838
+ "translateWithId": {
839
+ "type": {
840
+ "name": "func"
841
+ },
842
+ "required": false,
843
+ "description": "Specify a custom translation function that takes in a message identifier\nand returns the localized string for the message"
844
+ },
845
+ "size": {
846
+ "type": {
847
+ "name": "custom",
848
+ "raw": "ListBoxPropTypes.ListBoxSize"
849
+ },
850
+ "required": false,
851
+ "description": "Specify the size of the ListBox. Currently supports either `sm`, `lg` or `xl` as an option."
852
+ },
853
+ "onInputChange": {
854
+ "type": {
855
+ "name": "func"
856
+ },
857
+ "required": false,
858
+ "description": "Callback function to notify consumer when the text input changes.\nThis provides support to change available items based on the text.\n@param {string} inputText"
859
+ },
860
+ "downshiftProps": {
861
+ "type": {
862
+ "name": "shape",
863
+ "value": "Downshift.propTypes",
864
+ "computed": true
865
+ },
866
+ "required": false,
867
+ "description": "Additional props passed to Downshift"
868
+ },
869
+ "onHighligtedIndexChange": {
870
+ "type": {
871
+ "name": "func"
872
+ },
873
+ "required": false,
874
+ "description": "Optional callback to pass the highlighted index to parent"
875
+ },
876
+ "findHighlightedIndex": {
877
+ "type": {
878
+ "name": "func"
879
+ },
880
+ "required": false,
881
+ "description": "Optional func to change behavior of highlighted index"
882
+ }
883
+ }
884
+ };
885
+
886
+ exports.match = match;
887
+ exports.setupGetInstanceId = setupGetInstanceId;
888
+ exports.defaultItemToString = defaultItemToString;
889
+ exports.default = ComboBox;