@dhis2-ui/select 10.9.1 → 10.10.0-alpha.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 (148) hide show
  1. package/build/cjs/index.js +18 -4
  2. package/build/cjs/locales/en/translations.json +7 -5
  3. package/build/cjs/simple-single-select/__stories__/DefaultPosition.js +38 -0
  4. package/build/cjs/simple-single-select/__stories__/Dense.js +22 -0
  5. package/build/cjs/simple-single-select/__stories__/Empty.js +20 -0
  6. package/build/cjs/simple-single-select/__stories__/EmptyWithEmptyNode.js +28 -0
  7. package/build/cjs/simple-single-select/__stories__/EmptyWithEmptyText.js +21 -0
  8. package/build/cjs/simple-single-select/__stories__/FlippedPosition.js +37 -0
  9. package/build/cjs/simple-single-select/__stories__/InfiniteLoading.js +61 -0
  10. package/build/cjs/simple-single-select/__stories__/Loading.js +20 -0
  11. package/build/cjs/simple-single-select/__stories__/ShiftedIntoView.js +28 -0
  12. package/build/cjs/simple-single-select/__stories__/WithClearButton.js +25 -0
  13. package/build/cjs/simple-single-select/__stories__/WithCustomLowMaxHeight.js +22 -0
  14. package/build/cjs/simple-single-select/__stories__/WithCustomOptions.js +48 -0
  15. package/build/cjs/simple-single-select/__stories__/WithDisabledOption.js +28 -0
  16. package/build/cjs/simple-single-select/__stories__/WithFilterField.js +36 -0
  17. package/build/cjs/simple-single-select/__stories__/WithInitialFocus.js +38 -0
  18. package/build/cjs/simple-single-select/__stories__/WithManyOptions.js +24 -0
  19. package/build/cjs/simple-single-select/__stories__/WithNoMatchText.js +30 -0
  20. package/build/cjs/simple-single-select/__stories__/WithOnBlur.js +23 -0
  21. package/build/cjs/simple-single-select/__stories__/WithOnFocus.js +23 -0
  22. package/build/cjs/simple-single-select/__stories__/WithOptionsAndDisabled.js +22 -0
  23. package/build/cjs/simple-single-select/__stories__/WithOptionsAndLoading.js +34 -0
  24. package/build/cjs/simple-single-select/__stories__/WithOptionsAndLoadingText.js +35 -0
  25. package/build/cjs/simple-single-select/__stories__/WithPlaceholder.js +23 -0
  26. package/build/cjs/simple-single-select/__stories__/WithPlaceholderAndSelection.js +25 -0
  27. package/build/cjs/simple-single-select/__stories__/WithPrefix.js +22 -0
  28. package/build/cjs/simple-single-select/__stories__/WithPrefixAndSelection.js +25 -0
  29. package/build/cjs/simple-single-select/__stories__/WithRTL.js +34 -0
  30. package/build/cjs/simple-single-select/__stories__/WithSelection.js +24 -0
  31. package/build/cjs/simple-single-select/__stories__/WithSelectionAndDisabled.js +25 -0
  32. package/build/cjs/simple-single-select/__stories__/WithoutOptionsAndLoading.js +21 -0
  33. package/build/cjs/simple-single-select/__stories__/WithoutSelection.js +22 -0
  34. package/build/cjs/simple-single-select/__stories__/options.js +77 -0
  35. package/build/cjs/simple-single-select/features/keyboard-interactions.test.e2e.js +441 -0
  36. package/build/cjs/simple-single-select/features/menu-positioning.test.e2e.js +152 -0
  37. package/build/cjs/simple-single-select/index.js +19 -0
  38. package/build/cjs/simple-single-select/is-option-hidden.js +22 -0
  39. package/build/cjs/simple-single-select/menu/empty.js +26 -0
  40. package/build/cjs/simple-single-select/menu/filter.js +60 -0
  41. package/build/cjs/simple-single-select/menu/index.js +12 -0
  42. package/build/cjs/simple-single-select/menu/loading.js +30 -0
  43. package/build/cjs/simple-single-select/menu/menu.js +158 -0
  44. package/build/cjs/simple-single-select/menu/no-match.js +28 -0
  45. package/build/cjs/simple-single-select/menu/option.js +120 -0
  46. package/build/cjs/simple-single-select/menu/options-list.js +97 -0
  47. package/build/cjs/simple-single-select/selected-value/clear-button.js +74 -0
  48. package/build/cjs/simple-single-select/selected-value/container.js +100 -0
  49. package/build/cjs/simple-single-select/selected-value/index.js +12 -0
  50. package/build/cjs/simple-single-select/selected-value/placeholder.js +30 -0
  51. package/build/cjs/simple-single-select/selected-value/prefix.js +30 -0
  52. package/build/cjs/simple-single-select/selected-value/selected-value.js +119 -0
  53. package/build/cjs/simple-single-select/shared-prop-types.js +14 -0
  54. package/build/cjs/simple-single-select/simple-single-select.e2e.stories.js +156 -0
  55. package/build/cjs/simple-single-select/simple-single-select.js +319 -0
  56. package/build/cjs/simple-single-select/simple-single-select.prod.stories.js +228 -0
  57. package/build/cjs/simple-single-select/simple-single-select.test.js +1106 -0
  58. package/build/cjs/simple-single-select/use-handle-key-press/index.js +19 -0
  59. package/build/cjs/simple-single-select/use-handle-key-press/use-focus-option.js +24 -0
  60. package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +177 -0
  61. package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +106 -0
  62. package/build/cjs/simple-single-select/use-handle-key-press/use-handle-typing.js +81 -0
  63. package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-first-option-on-previous-page.js +50 -0
  64. package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-first-visible-option.js +30 -0
  65. package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-last-option-on-next-page.js +50 -0
  66. package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-last-visible-option.js +42 -0
  67. package/build/cjs/simple-single-select/use-handle-key-press/use-page-down.js +45 -0
  68. package/build/cjs/simple-single-select/use-handle-key-press/use-page-up.js +44 -0
  69. package/build/cjs/simple-single-select/use-handle-key-press/utils.js +46 -0
  70. package/build/cjs/simple-single-select-field/index.js +12 -0
  71. package/build/cjs/simple-single-select-field/simple-single-select-field.js +138 -0
  72. package/build/cjs/simple-single-select-field/simple-single-select-field.prod.stories.js +188 -0
  73. package/build/cjs/simple-single-select-field/simple-single-select-field.test.js +133 -0
  74. package/build/es/index.js +2 -0
  75. package/build/es/locales/en/translations.json +7 -5
  76. package/build/es/simple-single-select/__stories__/DefaultPosition.js +29 -0
  77. package/build/es/simple-single-select/__stories__/Dense.js +13 -0
  78. package/build/es/simple-single-select/__stories__/Empty.js +11 -0
  79. package/build/es/simple-single-select/__stories__/EmptyWithEmptyNode.js +19 -0
  80. package/build/es/simple-single-select/__stories__/EmptyWithEmptyText.js +12 -0
  81. package/build/es/simple-single-select/__stories__/FlippedPosition.js +28 -0
  82. package/build/es/simple-single-select/__stories__/InfiniteLoading.js +53 -0
  83. package/build/es/simple-single-select/__stories__/Loading.js +12 -0
  84. package/build/es/simple-single-select/__stories__/ShiftedIntoView.js +18 -0
  85. package/build/es/simple-single-select/__stories__/WithClearButton.js +16 -0
  86. package/build/es/simple-single-select/__stories__/WithCustomLowMaxHeight.js +13 -0
  87. package/build/es/simple-single-select/__stories__/WithCustomOptions.js +38 -0
  88. package/build/es/simple-single-select/__stories__/WithDisabledOption.js +19 -0
  89. package/build/es/simple-single-select/__stories__/WithFilterField.js +27 -0
  90. package/build/es/simple-single-select/__stories__/WithInitialFocus.js +29 -0
  91. package/build/es/simple-single-select/__stories__/WithManyOptions.js +15 -0
  92. package/build/es/simple-single-select/__stories__/WithNoMatchText.js +21 -0
  93. package/build/es/simple-single-select/__stories__/WithOnBlur.js +14 -0
  94. package/build/es/simple-single-select/__stories__/WithOnFocus.js +14 -0
  95. package/build/es/simple-single-select/__stories__/WithOptionsAndDisabled.js +13 -0
  96. package/build/es/simple-single-select/__stories__/WithOptionsAndLoading.js +25 -0
  97. package/build/es/simple-single-select/__stories__/WithOptionsAndLoadingText.js +26 -0
  98. package/build/es/simple-single-select/__stories__/WithPlaceholder.js +14 -0
  99. package/build/es/simple-single-select/__stories__/WithPlaceholderAndSelection.js +16 -0
  100. package/build/es/simple-single-select/__stories__/WithPrefix.js +13 -0
  101. package/build/es/simple-single-select/__stories__/WithPrefixAndSelection.js +16 -0
  102. package/build/es/simple-single-select/__stories__/WithRTL.js +25 -0
  103. package/build/es/simple-single-select/__stories__/WithSelection.js +15 -0
  104. package/build/es/simple-single-select/__stories__/WithSelectionAndDisabled.js +16 -0
  105. package/build/es/simple-single-select/__stories__/WithoutOptionsAndLoading.js +12 -0
  106. package/build/es/simple-single-select/__stories__/WithoutSelection.js +13 -0
  107. package/build/es/simple-single-select/__stories__/options.js +71 -0
  108. package/build/es/simple-single-select/features/keyboard-interactions.test.e2e.js +439 -0
  109. package/build/es/simple-single-select/features/menu-positioning.test.e2e.js +150 -0
  110. package/build/es/simple-single-select/index.js +2 -0
  111. package/build/es/simple-single-select/is-option-hidden.js +16 -0
  112. package/build/es/simple-single-select/menu/empty.js +19 -0
  113. package/build/es/simple-single-select/menu/filter.js +53 -0
  114. package/build/es/simple-single-select/menu/index.js +1 -0
  115. package/build/es/simple-single-select/menu/loading.js +23 -0
  116. package/build/es/simple-single-select/menu/menu.js +149 -0
  117. package/build/es/simple-single-select/menu/no-match.js +21 -0
  118. package/build/es/simple-single-select/menu/option.js +111 -0
  119. package/build/es/simple-single-select/menu/options-list.js +88 -0
  120. package/build/es/simple-single-select/selected-value/clear-button.js +68 -0
  121. package/build/es/simple-single-select/selected-value/container.js +91 -0
  122. package/build/es/simple-single-select/selected-value/index.js +1 -0
  123. package/build/es/simple-single-select/selected-value/placeholder.js +23 -0
  124. package/build/es/simple-single-select/selected-value/prefix.js +23 -0
  125. package/build/es/simple-single-select/selected-value/selected-value.js +112 -0
  126. package/build/es/simple-single-select/shared-prop-types.js +7 -0
  127. package/build/es/simple-single-select/simple-single-select.e2e.stories.js +142 -0
  128. package/build/es/simple-single-select/simple-single-select.js +310 -0
  129. package/build/es/simple-single-select/simple-single-select.prod.stories.js +36 -0
  130. package/build/es/simple-single-select/simple-single-select.test.js +1103 -0
  131. package/build/es/simple-single-select/use-handle-key-press/index.js +2 -0
  132. package/build/es/simple-single-select/use-handle-key-press/use-focus-option.js +18 -0
  133. package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +171 -0
  134. package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +100 -0
  135. package/build/es/simple-single-select/use-handle-key-press/use-handle-typing.js +75 -0
  136. package/build/es/simple-single-select/use-handle-key-press/use-highlight-first-option-on-previous-page.js +44 -0
  137. package/build/es/simple-single-select/use-handle-key-press/use-highlight-first-visible-option.js +24 -0
  138. package/build/es/simple-single-select/use-handle-key-press/use-highlight-last-option-on-next-page.js +44 -0
  139. package/build/es/simple-single-select/use-handle-key-press/use-highlight-last-visible-option.js +36 -0
  140. package/build/es/simple-single-select/use-handle-key-press/use-page-down.js +39 -0
  141. package/build/es/simple-single-select/use-handle-key-press/use-page-up.js +38 -0
  142. package/build/es/simple-single-select/use-handle-key-press/utils.js +36 -0
  143. package/build/es/simple-single-select-field/index.js +1 -0
  144. package/build/es/simple-single-select-field/simple-single-select-field.js +131 -0
  145. package/build/es/simple-single-select-field/simple-single-select-field.prod.stories.js +172 -0
  146. package/build/es/simple-single-select-field/simple-single-select-field.test.js +130 -0
  147. package/package.json +15 -15
  148. package/types/index.d.ts +184 -1
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SimpleSingleSelect = SimpleSingleSelect;
7
+ var _propTypes = require("@dhis2/prop-types");
8
+ var _uiConstants = require("@dhis2/ui-constants");
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _propTypes2 = _interopRequireDefault(require("prop-types"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _index = _interopRequireDefault(require("../locales/index.js"));
13
+ var _index2 = require("./menu/index.js");
14
+ var _index3 = require("./selected-value/index.js");
15
+ var _sharedPropTypes = require("./shared-prop-types.js");
16
+ var _index4 = require("./use-handle-key-press/index.js");
17
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
+ function useFocussedOptionIndex(_ref) {
21
+ let {
22
+ filterable,
23
+ filterValue,
24
+ options
25
+ } = _ref;
26
+ const [defaultFocussedOptionIndex, setDefaultFocussedOptionIndex] = (0, _react.useState)(0);
27
+ const [searchFocussedOptionIndex, setSearchFocussedOptionIndex] = (0, _react.useState)(0);
28
+
29
+ // We want to reset the focussed option index when searching when the
30
+ // options change BUT we don't want to reset options when adding more
31
+ // options by using the "infinite scrolling" strategy
32
+ const initialized = (0, _react.useRef)(false);
33
+ const prevFirstOption = (0, _react.useRef)();
34
+ (0, _react.useEffect)(() => {
35
+ var _options$2;
36
+ // Ignore first call to prevent unnecessary re-render
37
+ if (!initialized.current) {
38
+ var _options$;
39
+ initialized.current = true;
40
+ prevFirstOption.current = (_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.value;
41
+ } else if (filterable && prevFirstOption.current !== ((_options$2 = options[0]) === null || _options$2 === void 0 ? void 0 : _options$2.value)) {
42
+ var _options$3;
43
+ prevFirstOption.current = (_options$3 = options[0]) === null || _options$3 === void 0 ? void 0 : _options$3.value;
44
+ setSearchFocussedOptionIndex(0);
45
+ }
46
+ }, [options, filterable, initialized, prevFirstOption]);
47
+ const focussedOptionIndex = (0, _react.useMemo)(() => {
48
+ return filterValue ? searchFocussedOptionIndex : defaultFocussedOptionIndex;
49
+ }, [defaultFocussedOptionIndex, searchFocussedOptionIndex, filterValue]);
50
+ const setFocussedOptionIndex = (0, _react.useMemo)(() => {
51
+ return filterValue ? setSearchFocussedOptionIndex : setDefaultFocussedOptionIndex;
52
+ }, [filterValue]);
53
+ return [focussedOptionIndex, setFocussedOptionIndex];
54
+ }
55
+ function SimpleSingleSelect(_ref2) {
56
+ let {
57
+ name,
58
+ options,
59
+ onChange,
60
+ autoFocus = false,
61
+ className = '',
62
+ clearText: _clearText = '',
63
+ clearable = false,
64
+ optionComponent = undefined,
65
+ dataTest = 'dhis2-simplesingleselect',
66
+ dense = false,
67
+ disabled = false,
68
+ empty: _empty = false,
69
+ error = false,
70
+ filterHelpText = '',
71
+ filterLabel = '',
72
+ filterPlaceholder: _filterPlaceholder = '',
73
+ filterValue = '',
74
+ filterable = false,
75
+ inputMaxHeight = '',
76
+ labelledBy = '',
77
+ loading = false,
78
+ menuLoadingText: _menuLoadingText = '',
79
+ menuMaxHeight = '288px',
80
+ noMatchText: _noMatchText = '',
81
+ optionUpdateStrategy = 'polite',
82
+ placeholder = '',
83
+ prefix = '',
84
+ selected = {
85
+ label: '',
86
+ value: ''
87
+ },
88
+ tabIndex = '0',
89
+ valid = false,
90
+ warning = false,
91
+ onBlur = () => undefined,
92
+ onClear = () => undefined,
93
+ onEndReached = () => undefined,
94
+ onFilterChange = () => undefined,
95
+ onFocus = () => undefined
96
+ } = _ref2;
97
+ // We can't translate with default props as the translation function would
98
+ // be called before we get any translations from the consuming app/lib
99
+ const clearText = _clearText || _index.default.t('Clear');
100
+ const empty = _empty || _index.default.t('No data found');
101
+ const filterPlaceholder = _filterPlaceholder || _index.default.t('Type to filter options');
102
+ const menuLoadingText = _menuLoadingText || _index.default.t('Loading options');
103
+ const noMatchText = _noMatchText || _index.default.t('No options found');
104
+ const comboBoxId = `${name}-combo`;
105
+ const comboBoxRef = (0, _react.useRef)();
106
+ const listBoxRef = (0, _react.useRef)();
107
+ const [focussedOptionIndex, setFocussedOptionIndex] = useFocussedOptionIndex({
108
+ filterable,
109
+ filterValue,
110
+ options
111
+ });
112
+ const [selectRef, setSelectRef] = (0, _react.useState)();
113
+ const [expanded, setExpanded] = (0, _react.useState)(false);
114
+ const closeMenu = (0, _react.useCallback)(() => setExpanded(false), []);
115
+ const selectedValue = (selected === null || selected === void 0 ? void 0 : selected.value) || '';
116
+ const selectedLabel = (selected === null || selected === void 0 ? void 0 : selected.label) || '';
117
+ const openMenu = (0, _react.useCallback)(() => {
118
+ const selectedOptionIndex = options.findIndex(option => option.value === selectedValue);
119
+ if (selectedOptionIndex !== focussedOptionIndex) {
120
+ setFocussedOptionIndex(selectedOptionIndex);
121
+ }
122
+ setExpanded(true);
123
+ }, [options, selectedValue, focussedOptionIndex, setFocussedOptionIndex]);
124
+ const toggleMenu = (0, _react.useCallback)(() => {
125
+ if (expanded) {
126
+ closeMenu();
127
+ } else {
128
+ openMenu();
129
+ }
130
+ }, [expanded, openMenu, closeMenu]);
131
+ const selectFocussedOption = (0, _react.useCallback)(() => {
132
+ const option = options[focussedOptionIndex];
133
+ if (option) {
134
+ onChange(option);
135
+ }
136
+ }, [focussedOptionIndex, options, onChange]);
137
+ const focusComboBox = (0, _react.useCallback)(() => {
138
+ var _comboBoxRef$current;
139
+ return (_comboBoxRef$current = comboBoxRef.current) === null || _comboBoxRef$current === void 0 ? void 0 : _comboBoxRef$current.focus();
140
+ }, [comboBoxRef]);
141
+ const handleKeyDown = (0, _index4.useHandleKeyPressOnCombobox)({
142
+ value: selectedValue,
143
+ disabled,
144
+ onChange,
145
+ expanded,
146
+ loading,
147
+ options,
148
+ openMenu,
149
+ closeMenu,
150
+ listBoxRef,
151
+ focussedOptionIndex,
152
+ setFocussedOptionIndex,
153
+ selectFocussedOption
154
+ });
155
+ const handleKeyDownOnFilterInput = (0, _index4.useHandleKeyPressOnFilterInput)({
156
+ value: selectedValue,
157
+ options,
158
+ loading,
159
+ closeMenu,
160
+ listBoxRef,
161
+ focusComboBox,
162
+ focussedOptionIndex,
163
+ setFocussedOptionIndex,
164
+ selectFocussedOption
165
+ });
166
+ return /*#__PURE__*/_react.default.createElement("div", {
167
+ className: (0, _classnames.default)('simple-single-select', className),
168
+ "data-test": dataTest,
169
+ ref: div => {
170
+ if (
171
+ // when setting the state (with `setSelectRef), this
172
+ // component will rerender and this function will be run
173
+ // again twice. The first call will provide a null-value
174
+ !div ||
175
+ // Making sure we're not setting state
176
+ // if we already have the correct element
177
+ div === selectRef) {
178
+ return;
179
+ }
180
+ setSelectRef(div);
181
+ }
182
+ }, /*#__PURE__*/_react.default.createElement(_index3.SelectedValue, {
183
+ autoFocus: autoFocus,
184
+ clearText: clearText,
185
+ clearable: clearable,
186
+ comboBoxRef: comboBoxRef,
187
+ comboBoxId: comboBoxId,
188
+ dataTest: dataTest,
189
+ dense: dense,
190
+ disabled: disabled,
191
+ error: error,
192
+ expanded: expanded,
193
+ hasSelection: !!selectedValue,
194
+ inputMaxHeight: inputMaxHeight,
195
+ labelledBy: labelledBy,
196
+ name: name,
197
+ placeholder: placeholder,
198
+ prefix: prefix,
199
+ tabIndex: tabIndex.toString(),
200
+ warning: warning,
201
+ valid: valid,
202
+ selectedLabel: selectedLabel,
203
+ onBlur: onBlur,
204
+ onClear: onClear,
205
+ onClick: toggleMenu,
206
+ onFocus: onFocus,
207
+ onKeyDown: handleKeyDown
208
+ }), /*#__PURE__*/_react.default.createElement(_index2.Menu, {
209
+ comboBoxId: comboBoxId,
210
+ optionComponent: optionComponent,
211
+ disabled: disabled,
212
+ empty: empty,
213
+ filterHelpText: filterHelpText,
214
+ filterLabel: filterLabel,
215
+ filterable: filterable,
216
+ filterValue: filterValue,
217
+ filterPlaceholder: filterPlaceholder,
218
+ focussedOptionIndex: focussedOptionIndex,
219
+ onFilterInputKeyDown: handleKeyDownOnFilterInput,
220
+ hidden: !expanded,
221
+ name: name,
222
+ labelledBy: labelledBy,
223
+ listBoxRef: listBoxRef,
224
+ loading: loading,
225
+ loadingText: menuLoadingText,
226
+ maxHeight: menuMaxHeight,
227
+ noMatchText: noMatchText,
228
+ optionUpdateStrategy: optionUpdateStrategy,
229
+ options: options,
230
+ selectRef: selectRef,
231
+ selectedValue: selectedValue,
232
+ tabIndex: tabIndex.toString(),
233
+ onBlur: onBlur,
234
+ onChange: nextValue => {
235
+ onChange(nextValue);
236
+ closeMenu();
237
+ },
238
+ onClose: closeMenu,
239
+ onEndReached: onEndReached,
240
+ onFilterChange: onFilterChange
241
+ }));
242
+ }
243
+ SimpleSingleSelect.propTypes = {
244
+ /** necessary for IDs that are required for accessibility **/
245
+ name: _propTypes2.default.string.isRequired,
246
+ /** An array of options **/
247
+ options: _propTypes2.default.arrayOf(_sharedPropTypes.optionProp).isRequired,
248
+ /** A callback that will be called with the new value or an empty string **/
249
+ onChange: _propTypes2.default.func.isRequired,
250
+ /** Will focus the select initially **/
251
+ autoFocus: _propTypes2.default.bool,
252
+ /** Additional class names that will be applied to the root element **/
253
+ className: _propTypes2.default.string,
254
+ /** This will allow us to put an aria-label on the clear button **/
255
+ clearText: (0, _propTypes.requiredIf)(props => props.clearable, _propTypes2.default.string),
256
+ /** Whether a clear button should be displayed or not **/
257
+ clearable: _propTypes2.default.bool,
258
+ /** A value for a `data-test` attribute on the root element **/
259
+ dataTest: _propTypes2.default.string,
260
+ /** Renders a select with lower height **/
261
+ dense: _propTypes2.default.bool,
262
+ /** Disables all interactions with the select (except focussing) **/
263
+ disabled: _propTypes2.default.bool,
264
+ /** Text or component to display when there are no options **/
265
+ empty: _propTypes2.default.node,
266
+ /** Applies 'error' appearance for validation feedback. Mutually exclusive with `warning` and `valid` props **/
267
+ error: _uiConstants.sharedPropTypes.statusPropType,
268
+ /** Help text that will be displayed below the input **/
269
+ filterHelpText: _propTypes2.default.string,
270
+ /** Value will be used as aria-label attribute on the filter input **/
271
+ filterLabel: _propTypes2.default.string,
272
+ /** Placeholder for the filter input **/
273
+ filterPlaceholder: _propTypes2.default.string,
274
+ /** Value of the filter input **/
275
+ filterValue: _propTypes2.default.string,
276
+ /** Whether the select should display a filter input **/
277
+ filterable: _propTypes2.default.bool,
278
+ /** Max height of the container displaying the selected value **/
279
+ inputMaxHeight: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]),
280
+ /** Should contain the id of the element that labels the select, if applicable **/
281
+ labelledBy: _propTypes2.default.string,
282
+ /** Will show a loading indicator at the end of the options-list **/
283
+ loading: _propTypes2.default.bool,
284
+ /** Text that will be displayed next to the loading indicator **/
285
+ menuLoadingText: _propTypes2.default.string,
286
+ /** Allows to modify the max height of the menu **/
287
+ menuMaxHeight: _propTypes2.default.string,
288
+ /** String that will be displayed when the select is being filtered but the options array is empty **/
289
+ noMatchText: (0, _propTypes.requiredIf)(props => props.filterable, _propTypes2.default.string),
290
+ /** Allows to override what's rendered inside the `button[role="option"]`.
291
+ * Can be overriden on an individual option basis **/
292
+ optionComponent: _propTypes2.default.elementType,
293
+ /** For a11y: How aggressively the user should be updated about changes in options **/
294
+ optionUpdateStrategy: _propTypes2.default.oneOf(['off', 'polite', 'assertive']),
295
+ /** String to show when there's no selected option **/
296
+ placeholder: _propTypes2.default.string,
297
+ /** String that will be displayed before the label of the selected option **/
298
+ prefix: _propTypes2.default.string,
299
+ selected: _propTypes2.default.shape({
300
+ label: _propTypes2.default.string.isRequired,
301
+ value: _propTypes2.default.string.isRequired
302
+ }),
303
+ /** Standard HTML tab-index attribute that will be put on the combobox's root element **/
304
+ tabIndex: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]),
305
+ /** Applies 'valid' appearance for validation feedback. Mutually exclusive with `warning` and `valid` props **/
306
+ valid: _uiConstants.sharedPropTypes.statusPropType,
307
+ /** Applies 'warning' appearance for validation feedback. Mutually exclusive with `warning` and `valid` props **/
308
+ warning: _uiConstants.sharedPropTypes.statusPropType,
309
+ /** Will be called when the combobox is loses focus **/
310
+ onBlur: _propTypes2.default.func,
311
+ /** Will be called when the combobox is loses focus **/
312
+ onClear: _propTypes2.default.func,
313
+ /** Will be called when the last option is scrolled into the visible area **/
314
+ onEndReached: _propTypes2.default.func,
315
+ /** Will be called when the filter value changes **/
316
+ onFilterChange: _propTypes2.default.func,
317
+ /** Will be called when the combobox is being focused **/
318
+ onFocus: _propTypes2.default.func
319
+ };
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "DefaultPosition", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _DefaultPosition.DefaultPosition;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "Dense", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Dense.Dense;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "Empty", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _Empty.Empty;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "EmptyWithEmptyNode", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _EmptyWithEmptyNode.EmptyWithEmptyNode;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "EmptyWithEmptyText", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _EmptyWithEmptyText.EmptyWithEmptyText;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "FlippedPosition", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _FlippedPosition.FlippedPosition;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "InfiniteLoading", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _InfiniteLoading.InfiniteLoading;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "Loading", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _Loading.Loading;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "ShiftedIntoView", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _ShiftedIntoView.ShiftedIntoView;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "WithClearButton", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _WithClearButton.WithClearButton;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "WithCustomLowMaxHeight", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _WithCustomLowMaxHeight.WithCustomLowMaxHeight;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "WithCustomOptions", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _WithCustomOptions.WithCustomOptions;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "WithDisabledOption", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _WithDisabledOption.WithDisabledOption;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "WithFilterField", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _WithFilterField.WithFilterField;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, "WithInitialFocus", {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _WithInitialFocus.WithInitialFocus;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "WithManyOptions", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _WithManyOptions.WithManyOptions;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, "WithNoMatchText", {
103
+ enumerable: true,
104
+ get: function () {
105
+ return _WithNoMatchText.WithNoMatchText;
106
+ }
107
+ });
108
+ Object.defineProperty(exports, "WithOnBlur", {
109
+ enumerable: true,
110
+ get: function () {
111
+ return _WithOnBlur.WithOnBlur;
112
+ }
113
+ });
114
+ Object.defineProperty(exports, "WithOnFocus", {
115
+ enumerable: true,
116
+ get: function () {
117
+ return _WithOnFocus.WithOnFocus;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, "WithOptionsAndDisabled", {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _WithOptionsAndDisabled.WithOptionsAndDisabled;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, "WithOptionsAndLoading", {
127
+ enumerable: true,
128
+ get: function () {
129
+ return _WithOptionsAndLoading.WithOptionsAndLoading;
130
+ }
131
+ });
132
+ Object.defineProperty(exports, "WithOptionsAndLoadingText", {
133
+ enumerable: true,
134
+ get: function () {
135
+ return _WithOptionsAndLoadingText.WithOptionsAndLoadingText;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "WithPlaceholder", {
139
+ enumerable: true,
140
+ get: function () {
141
+ return _WithPlaceholder.WithPlaceholder;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "WithPlaceholderAndSelection", {
145
+ enumerable: true,
146
+ get: function () {
147
+ return _WithPlaceholderAndSelection.WithPlaceholderAndSelection;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "WithPrefix", {
151
+ enumerable: true,
152
+ get: function () {
153
+ return _WithPrefix.WithPrefix;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "WithPrefixAndSelection", {
157
+ enumerable: true,
158
+ get: function () {
159
+ return _WithPrefixAndSelection.WithPrefixAndSelection;
160
+ }
161
+ });
162
+ Object.defineProperty(exports, "WithRTL", {
163
+ enumerable: true,
164
+ get: function () {
165
+ return _WithRTL.WithRTL;
166
+ }
167
+ });
168
+ Object.defineProperty(exports, "WithSelection", {
169
+ enumerable: true,
170
+ get: function () {
171
+ return _WithSelection.WithSelection;
172
+ }
173
+ });
174
+ Object.defineProperty(exports, "WithSelectionAndDisabled", {
175
+ enumerable: true,
176
+ get: function () {
177
+ return _WithSelectionAndDisabled.WithSelectionAndDisabled;
178
+ }
179
+ });
180
+ Object.defineProperty(exports, "WithoutOptionsAndLoading", {
181
+ enumerable: true,
182
+ get: function () {
183
+ return _WithoutOptionsAndLoading.WithoutOptionsAndLoading;
184
+ }
185
+ });
186
+ Object.defineProperty(exports, "WithoutSelection", {
187
+ enumerable: true,
188
+ get: function () {
189
+ return _WithoutSelection.WithoutSelection;
190
+ }
191
+ });
192
+ exports.default = void 0;
193
+ var _simpleSingleSelect = require("./simple-single-select.js");
194
+ var _WithoutSelection = require("./__stories__/WithoutSelection.js");
195
+ var _WithSelection = require("./__stories__/WithSelection.js");
196
+ var _WithOnFocus = require("./__stories__/WithOnFocus.js");
197
+ var _WithOnBlur = require("./__stories__/WithOnBlur.js");
198
+ var _WithCustomOptions = require("./__stories__/WithCustomOptions.js");
199
+ var _WithInitialFocus = require("./__stories__/WithInitialFocus.js");
200
+ var _Dense = require("./__stories__/Dense.js");
201
+ var _Empty = require("./__stories__/Empty.js");
202
+ var _Loading = require("./__stories__/Loading.js");
203
+ var _InfiniteLoading = require("./__stories__/InfiniteLoading.js");
204
+ var _EmptyWithEmptyText = require("./__stories__/EmptyWithEmptyText.js");
205
+ var _EmptyWithEmptyNode = require("./__stories__/EmptyWithEmptyNode.js");
206
+ var _WithOptionsAndLoading = require("./__stories__/WithOptionsAndLoading.js");
207
+ var _WithOptionsAndLoadingText = require("./__stories__/WithOptionsAndLoadingText.js");
208
+ var _WithoutOptionsAndLoading = require("./__stories__/WithoutOptionsAndLoading.js");
209
+ var _WithManyOptions = require("./__stories__/WithManyOptions.js");
210
+ var _WithCustomLowMaxHeight = require("./__stories__/WithCustomLowMaxHeight.js");
211
+ var _WithOptionsAndDisabled = require("./__stories__/WithOptionsAndDisabled.js");
212
+ var _WithSelectionAndDisabled = require("./__stories__/WithSelectionAndDisabled.js");
213
+ var _WithPrefix = require("./__stories__/WithPrefix.js");
214
+ var _WithPrefixAndSelection = require("./__stories__/WithPrefixAndSelection.js");
215
+ var _WithRTL = require("./__stories__/WithRTL.js");
216
+ var _WithPlaceholder = require("./__stories__/WithPlaceholder.js");
217
+ var _WithPlaceholderAndSelection = require("./__stories__/WithPlaceholderAndSelection.js");
218
+ var _WithDisabledOption = require("./__stories__/WithDisabledOption.js");
219
+ var _WithClearButton = require("./__stories__/WithClearButton.js");
220
+ var _WithFilterField = require("./__stories__/WithFilterField.js");
221
+ var _WithNoMatchText = require("./__stories__/WithNoMatchText.js");
222
+ var _DefaultPosition = require("./__stories__/DefaultPosition.js");
223
+ var _FlippedPosition = require("./__stories__/FlippedPosition.js");
224
+ var _ShiftedIntoView = require("./__stories__/ShiftedIntoView.js");
225
+ var _default = exports.default = {
226
+ title: 'Simple Single Select',
227
+ component: _simpleSingleSelect.SimpleSingleSelect
228
+ };