@transferwise/components 0.0.0-experimental-bcfa03a → 0.0.0-experimental-5cd0315

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 (180) hide show
  1. package/build/dateInput/DateInput.js +3 -6
  2. package/build/dateInput/DateInput.js.map +1 -1
  3. package/build/dateInput/DateInput.mjs +2 -5
  4. package/build/dateInput/DateInput.mjs.map +1 -1
  5. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +3 -5
  6. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +1 -1
  7. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +1 -3
  8. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +1 -1
  9. package/build/index.js +3 -5
  10. package/build/index.js.map +1 -1
  11. package/build/index.mjs +1 -3
  12. package/build/index.mjs.map +1 -1
  13. package/build/inputs/SelectInput.js +840 -0
  14. package/build/inputs/SelectInput.js.map +1 -0
  15. package/build/inputs/SelectInput.messages.js.map +1 -0
  16. package/build/inputs/SelectInput.messages.mjs.map +1 -0
  17. package/build/inputs/SelectInput.mjs +832 -0
  18. package/build/inputs/SelectInput.mjs.map +1 -0
  19. package/build/main.css +70 -65
  20. package/build/moneyInput/MoneyInput.js +2 -5
  21. package/build/moneyInput/MoneyInput.js.map +1 -1
  22. package/build/moneyInput/MoneyInput.mjs +1 -4
  23. package/build/moneyInput/MoneyInput.mjs.map +1 -1
  24. package/build/phoneNumberInput/PhoneNumberInput.js +2 -5
  25. package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
  26. package/build/phoneNumberInput/PhoneNumberInput.mjs +1 -4
  27. package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  28. package/build/styles/inputs/{SelectInput/SelectInput.css → SelectInput.css} +70 -65
  29. package/build/styles/main.css +70 -65
  30. package/build/types/inputs/{SelectInput/SelectInput.types.d.ts → SelectInput.d.ts} +7 -10
  31. package/build/types/inputs/SelectInput.d.ts.map +1 -0
  32. package/build/types/inputs/SelectInput.messages.d.ts.map +1 -0
  33. package/package.json +2 -2
  34. package/src/inputs/{SelectInput/SelectInput.css → SelectInput.css} +70 -65
  35. package/src/inputs/{SelectInput/SelectInput.docs.mdx → SelectInput.docs.mdx} +1 -0
  36. package/src/inputs/SelectInput.less +219 -0
  37. package/src/inputs/{SelectInput/SelectInput.story.tsx → SelectInput.story.tsx} +7 -7
  38. package/src/inputs/SelectInput.tsx +1209 -0
  39. package/src/main.css +70 -65
  40. package/src/main.less +1 -1
  41. package/build/inputs/SelectInput/DefaultTrigger/ClearButton/SelectInputClearButton.js +0 -26
  42. package/build/inputs/SelectInput/DefaultTrigger/ClearButton/SelectInputClearButton.js.map +0 -1
  43. package/build/inputs/SelectInput/DefaultTrigger/ClearButton/SelectInputClearButton.mjs +0 -24
  44. package/build/inputs/SelectInput/DefaultTrigger/ClearButton/SelectInputClearButton.mjs.map +0 -1
  45. package/build/inputs/SelectInput/DefaultTrigger/SelectInputDefaultTrigger.js +0 -54
  46. package/build/inputs/SelectInput/DefaultTrigger/SelectInputDefaultTrigger.js.map +0 -1
  47. package/build/inputs/SelectInput/DefaultTrigger/SelectInputDefaultTrigger.mjs +0 -52
  48. package/build/inputs/SelectInput/DefaultTrigger/SelectInputDefaultTrigger.mjs.map +0 -1
  49. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.js +0 -41
  50. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.js.map +0 -1
  51. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs +0 -38
  52. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs.map +0 -1
  53. package/build/inputs/SelectInput/Options/GroupItemView/SelectInputGroupItemView.js +0 -50
  54. package/build/inputs/SelectInput/Options/GroupItemView/SelectInputGroupItemView.js.map +0 -1
  55. package/build/inputs/SelectInput/Options/GroupItemView/SelectInputGroupItemView.mjs +0 -48
  56. package/build/inputs/SelectInput/Options/GroupItemView/SelectInputGroupItemView.mjs.map +0 -1
  57. package/build/inputs/SelectInput/Options/ItemView/Option/SelectInputOption.js +0 -45
  58. package/build/inputs/SelectInput/Options/ItemView/Option/SelectInputOption.js.map +0 -1
  59. package/build/inputs/SelectInput/Options/ItemView/Option/SelectInputOption.mjs +0 -41
  60. package/build/inputs/SelectInput/Options/ItemView/Option/SelectInputOption.mjs.map +0 -1
  61. package/build/inputs/SelectInput/Options/ItemView/SelectInputItemView.js +0 -50
  62. package/build/inputs/SelectInput/Options/ItemView/SelectInputItemView.js.map +0 -1
  63. package/build/inputs/SelectInput/Options/ItemView/SelectInputItemView.mjs +0 -48
  64. package/build/inputs/SelectInput/Options/ItemView/SelectInputItemView.mjs.map +0 -1
  65. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.js +0 -48
  66. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.js.map +0 -1
  67. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.mjs +0 -46
  68. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.mjs.map +0 -1
  69. package/build/inputs/SelectInput/Options/SelectInputOptions.js +0 -270
  70. package/build/inputs/SelectInput/Options/SelectInputOptions.js.map +0 -1
  71. package/build/inputs/SelectInput/Options/SelectInputOptions.mjs +0 -268
  72. package/build/inputs/SelectInput/Options/SelectInputOptions.mjs.map +0 -1
  73. package/build/inputs/SelectInput/SelectInput.constants.js +0 -6
  74. package/build/inputs/SelectInput/SelectInput.constants.js.map +0 -1
  75. package/build/inputs/SelectInput/SelectInput.constants.mjs +0 -4
  76. package/build/inputs/SelectInput/SelectInput.constants.mjs.map +0 -1
  77. package/build/inputs/SelectInput/SelectInput.helpers.js +0 -115
  78. package/build/inputs/SelectInput/SelectInput.helpers.js.map +0 -1
  79. package/build/inputs/SelectInput/SelectInput.helpers.mjs +0 -109
  80. package/build/inputs/SelectInput/SelectInput.helpers.mjs.map +0 -1
  81. package/build/inputs/SelectInput/SelectInput.js +0 -216
  82. package/build/inputs/SelectInput/SelectInput.js.map +0 -1
  83. package/build/inputs/SelectInput/SelectInput.messages.js.map +0 -1
  84. package/build/inputs/SelectInput/SelectInput.messages.mjs.map +0 -1
  85. package/build/inputs/SelectInput/SelectInput.mjs +0 -210
  86. package/build/inputs/SelectInput/SelectInput.mjs.map +0 -1
  87. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js +0 -41
  88. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js.map +0 -1
  89. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs +0 -34
  90. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs.map +0 -1
  91. package/build/styles/inputs/SelectInput/DefaultTrigger/SelectInputDefaultTrigger.css +0 -17
  92. package/build/styles/inputs/SelectInput/OptionContent/SelectInputOptionContent.css +0 -37
  93. package/build/styles/inputs/SelectInput/Options/ItemView/Option/SelectInputOption.css +0 -33
  94. package/build/styles/inputs/SelectInput/Options/ItemView/SelectInputItemView.css +0 -44
  95. package/build/styles/inputs/SelectInput/Options/SelectInputOptions.css +0 -125
  96. package/build/types/inputs/SelectInput/DefaultTrigger/ClearButton/SelectInputClearButton.d.ts +0 -5
  97. package/build/types/inputs/SelectInput/DefaultTrigger/ClearButton/SelectInputClearButton.d.ts.map +0 -1
  98. package/build/types/inputs/SelectInput/DefaultTrigger/ClearButton/index.d.ts +0 -2
  99. package/build/types/inputs/SelectInput/DefaultTrigger/ClearButton/index.d.ts.map +0 -1
  100. package/build/types/inputs/SelectInput/DefaultTrigger/SelectInputDefaultTrigger.d.ts +0 -9
  101. package/build/types/inputs/SelectInput/DefaultTrigger/SelectInputDefaultTrigger.d.ts.map +0 -1
  102. package/build/types/inputs/SelectInput/DefaultTrigger/index.d.ts +0 -2
  103. package/build/types/inputs/SelectInput/DefaultTrigger/index.d.ts.map +0 -1
  104. package/build/types/inputs/SelectInput/OptionContent/SelectInputOptionContent.d.ts +0 -9
  105. package/build/types/inputs/SelectInput/OptionContent/SelectInputOptionContent.d.ts.map +0 -1
  106. package/build/types/inputs/SelectInput/OptionContent/index.d.ts +0 -3
  107. package/build/types/inputs/SelectInput/OptionContent/index.d.ts.map +0 -1
  108. package/build/types/inputs/SelectInput/Options/GroupItemView/SelectInputGroupItemView.d.ts +0 -3
  109. package/build/types/inputs/SelectInput/Options/GroupItemView/SelectInputGroupItemView.d.ts.map +0 -1
  110. package/build/types/inputs/SelectInput/Options/GroupItemView/index.d.ts +0 -2
  111. package/build/types/inputs/SelectInput/Options/GroupItemView/index.d.ts.map +0 -1
  112. package/build/types/inputs/SelectInput/Options/ItemView/Option/SelectInputOption.d.ts +0 -10
  113. package/build/types/inputs/SelectInput/Options/ItemView/Option/SelectInputOption.d.ts.map +0 -1
  114. package/build/types/inputs/SelectInput/Options/ItemView/Option/index.d.ts +0 -2
  115. package/build/types/inputs/SelectInput/Options/ItemView/Option/index.d.ts.map +0 -1
  116. package/build/types/inputs/SelectInput/Options/ItemView/SelectInputItemView.d.ts +0 -3
  117. package/build/types/inputs/SelectInput/Options/ItemView/SelectInputItemView.d.ts.map +0 -1
  118. package/build/types/inputs/SelectInput/Options/ItemView/index.d.ts +0 -2
  119. package/build/types/inputs/SelectInput/Options/ItemView/index.d.ts.map +0 -1
  120. package/build/types/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.d.ts +0 -6
  121. package/build/types/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.d.ts.map +0 -1
  122. package/build/types/inputs/SelectInput/Options/OptionsContainer/index.d.ts +0 -2
  123. package/build/types/inputs/SelectInput/Options/OptionsContainer/index.d.ts.map +0 -1
  124. package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts +0 -15
  125. package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts.map +0 -1
  126. package/build/types/inputs/SelectInput/Options/index.d.ts +0 -2
  127. package/build/types/inputs/SelectInput/Options/index.d.ts.map +0 -1
  128. package/build/types/inputs/SelectInput/SelectInput.constants.d.ts +0 -2
  129. package/build/types/inputs/SelectInput/SelectInput.constants.d.ts.map +0 -1
  130. package/build/types/inputs/SelectInput/SelectInput.d.ts +0 -3
  131. package/build/types/inputs/SelectInput/SelectInput.d.ts.map +0 -1
  132. package/build/types/inputs/SelectInput/SelectInput.helpers.d.ts +0 -28
  133. package/build/types/inputs/SelectInput/SelectInput.helpers.d.ts.map +0 -1
  134. package/build/types/inputs/SelectInput/SelectInput.messages.d.ts.map +0 -1
  135. package/build/types/inputs/SelectInput/SelectInput.types.d.ts.map +0 -1
  136. package/build/types/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts +0 -15
  137. package/build/types/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts.map +0 -1
  138. package/build/types/inputs/SelectInput/TriggerButton/index.d.ts +0 -3
  139. package/build/types/inputs/SelectInput/TriggerButton/index.d.ts.map +0 -1
  140. package/build/types/inputs/SelectInput/index.d.ts +0 -5
  141. package/build/types/inputs/SelectInput/index.d.ts.map +0 -1
  142. package/src/inputs/SelectInput/DefaultTrigger/ClearButton/SelectInputClearButton.tsx +0 -25
  143. package/src/inputs/SelectInput/DefaultTrigger/ClearButton/index.ts +0 -1
  144. package/src/inputs/SelectInput/DefaultTrigger/SelectInputDefaultTrigger.css +0 -17
  145. package/src/inputs/SelectInput/DefaultTrigger/SelectInputDefaultTrigger.less +0 -15
  146. package/src/inputs/SelectInput/DefaultTrigger/SelectInputDefaultTrigger.tsx +0 -56
  147. package/src/inputs/SelectInput/DefaultTrigger/index.ts +0 -1
  148. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.css +0 -37
  149. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.less +0 -38
  150. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.tsx +0 -67
  151. package/src/inputs/SelectInput/OptionContent/index.ts +0 -5
  152. package/src/inputs/SelectInput/Options/GroupItemView/SelectInputGroupItemView.tsx +0 -53
  153. package/src/inputs/SelectInput/Options/GroupItemView/index.ts +0 -1
  154. package/src/inputs/SelectInput/Options/ItemView/Option/SelectInputOption.css +0 -33
  155. package/src/inputs/SelectInput/Options/ItemView/Option/SelectInputOption.less +0 -32
  156. package/src/inputs/SelectInput/Options/ItemView/Option/SelectInputOption.tsx +0 -51
  157. package/src/inputs/SelectInput/Options/ItemView/Option/index.ts +0 -5
  158. package/src/inputs/SelectInput/Options/ItemView/SelectInputItemView.css +0 -44
  159. package/src/inputs/SelectInput/Options/ItemView/SelectInputItemView.less +0 -14
  160. package/src/inputs/SelectInput/Options/ItemView/SelectInputItemView.tsx +0 -37
  161. package/src/inputs/SelectInput/Options/ItemView/index.ts +0 -1
  162. package/src/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.tsx +0 -55
  163. package/src/inputs/SelectInput/Options/OptionsContainer/index.ts +0 -1
  164. package/src/inputs/SelectInput/Options/SelectInputOptions.css +0 -125
  165. package/src/inputs/SelectInput/Options/SelectInputOptions.less +0 -78
  166. package/src/inputs/SelectInput/Options/SelectInputOptions.tsx +0 -372
  167. package/src/inputs/SelectInput/Options/index.ts +0 -1
  168. package/src/inputs/SelectInput/SelectInput.constants.ts +0 -1
  169. package/src/inputs/SelectInput/SelectInput.helpers.ts +0 -152
  170. package/src/inputs/SelectInput/SelectInput.less +0 -40
  171. package/src/inputs/SelectInput/SelectInput.test.tsx +0 -606
  172. package/src/inputs/SelectInput/SelectInput.tsx +0 -247
  173. package/src/inputs/SelectInput/SelectInput.types.ts +0 -127
  174. package/src/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx +0 -39
  175. package/src/inputs/SelectInput/TriggerButton/index.ts +0 -5
  176. package/src/inputs/SelectInput/index.ts +0 -13
  177. /package/build/inputs/{SelectInput/SelectInput.messages.js → SelectInput.messages.js} +0 -0
  178. /package/build/inputs/{SelectInput/SelectInput.messages.mjs → SelectInput.messages.mjs} +0 -0
  179. /package/build/types/inputs/{SelectInput/SelectInput.messages.d.ts → SelectInput.messages.d.ts} +0 -0
  180. /package/src/inputs/{SelectInput/SelectInput.messages.ts → SelectInput.messages.ts} +0 -0
@@ -0,0 +1,840 @@
1
+ 'use strict';
2
+
3
+ var react = require('@headlessui/react');
4
+ var icons = require('@transferwise/icons');
5
+ var clsx = require('clsx');
6
+ var mergeProps = require('merge-props');
7
+ var React = require('react');
8
+ var reactIntl = require('react-intl');
9
+ var virtua = require('virtua');
10
+ var useEffectEvent = require('../common/hooks/useEffectEvent.js');
11
+ var useScreenSize = require('../common/hooks/useScreenSize.js');
12
+ var PolymorphicWithOverrides = require('../common/polymorphicWithOverrides/PolymorphicWithOverrides.js');
13
+ var breakpoint = require('../common/propsValues/breakpoint.js');
14
+ var DateTrigger_messages = require('../dateLookup/dateTrigger/DateTrigger.messages.js');
15
+ var _BottomSheet = require('./_BottomSheet.js');
16
+ var _ButtonInput = require('./_ButtonInput.js');
17
+ var _Popover = require('./_Popover.js');
18
+ var contexts = require('./contexts.js');
19
+ var InputGroup = require('./InputGroup.js');
20
+ var SearchInput = require('./SearchInput.js');
21
+ var SelectInput_messages = require('./SelectInput.messages.js');
22
+ var Header = require('../header/Header.js');
23
+ var Section = require('../section/Section.js');
24
+ var jsxRuntime = require('react/jsx-runtime');
25
+
26
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
27
+
28
+ var mergeProps__default = /*#__PURE__*/_interopDefault(mergeProps);
29
+
30
+ const MAX_ITEMS_WITHOUT_VIRTUALIZATION = 50;
31
+ function searchableString(value) {
32
+ return value.trim().replace(/\s+/gu, ' ')
33
+ // NFD converts an Å to A + ̊ (and other special characters)
34
+ .normalize('NFD')
35
+ // and then this replaces the ̊ with nothing (and other special characters)
36
+ .replace(/[\u0300-\u036f]/g, '').toLowerCase();
37
+ }
38
+ function inferSearchableStrings(value) {
39
+ if (typeof value === 'string') {
40
+ return [searchableString(value)];
41
+ }
42
+ if (typeof value === 'object' && value != null) {
43
+ return Object.values(value).filter(innerValue => typeof innerValue === 'string').map(innerValue => searchableString(innerValue));
44
+ }
45
+ return [];
46
+ }
47
+ function dedupeSelectInputOptionItem(item, existingValues, compareValues) {
48
+ const isDuplicate = compareValues ? Array.from(existingValues).some(existingValue => compareValues(item.value, existingValue)) : existingValues.has(item.value);
49
+ if (!isDuplicate) {
50
+ existingValues.add(item.value);
51
+ return item;
52
+ }
53
+ return {
54
+ ...item,
55
+ value: undefined
56
+ };
57
+ }
58
+ /**
59
+ * Sets the `value` of duplicate option items to `undefined`, hiding them when
60
+ * rendered. Indexes are kept intact within groups to preserve the active item
61
+ * between filter changes when possible.
62
+ */
63
+ function dedupeSelectInputItems(items, compareValues) {
64
+ const existingValues = new Set();
65
+ return items.map(item => {
66
+ switch (item.type) {
67
+ case 'option':
68
+ {
69
+ return dedupeSelectInputOptionItem(item, existingValues, compareValues);
70
+ }
71
+ case 'group':
72
+ {
73
+ return {
74
+ ...item,
75
+ options: item.options.map(option => dedupeSelectInputOptionItem(option, existingValues, compareValues))
76
+ };
77
+ }
78
+ }
79
+ return item;
80
+ });
81
+ }
82
+ function selectInputOptionItemIncludesNeedle(item, needle) {
83
+ return inferSearchableStrings(item.filterMatchers ?? item.value).some(haystack => haystack.includes(needle));
84
+ }
85
+ function filterSelectInputItems(items, predicate) {
86
+ return items.filter(item => {
87
+ switch (item.type) {
88
+ case 'option':
89
+ {
90
+ return predicate(item);
91
+ }
92
+ case 'group':
93
+ {
94
+ return item.options.some(option => predicate(option));
95
+ }
96
+ }
97
+ return false;
98
+ });
99
+ }
100
+ /**
101
+ * Flattens and sorts filtered options using the provided comparator.
102
+ * Extracts all options from groups, filters out undefined values (deduplicated items),
103
+ * sorts them, and returns as a flat list of option items.
104
+ */
105
+ function sortSelectInputItems(items, compareFn, searchQuery) {
106
+ const flattenedOption = items.flatMap(item => {
107
+ if (item.type === 'option') {
108
+ return item.value !== undefined ? [item] : [];
109
+ }
110
+ if (item.type === 'group') {
111
+ return item.options.filter(option => option.value !== undefined);
112
+ }
113
+ return [];
114
+ });
115
+ // eslint-disable-next-line functional/immutable-data
116
+ return flattenedOption.sort((a, b) => compareFn(a, b, searchQuery));
117
+ }
118
+ const defaultRenderTrigger = ({
119
+ content,
120
+ placeholderShown,
121
+ clear,
122
+ disabled,
123
+ size,
124
+ className
125
+ }) => /*#__PURE__*/jsxRuntime.jsx(InputGroup.InputGroup, {
126
+ addonEnd: {
127
+ content: /*#__PURE__*/jsxRuntime.jsxs("span", {
128
+ className: clsx.clsx('np-select-input-addon-container', disabled && 'disabled'),
129
+ children: [clear != null && !placeholderShown ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
130
+ children: [/*#__PURE__*/jsxRuntime.jsx(SelectInputClearButton, {
131
+ onClick: event => {
132
+ event.preventDefault();
133
+ clear();
134
+ }
135
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
136
+ className: "np-select-input-addon-separator"
137
+ })]
138
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("span", {
139
+ className: "np-select-input-addon",
140
+ children: /*#__PURE__*/jsxRuntime.jsx(icons.ChevronDown, {
141
+ size: 16
142
+ })
143
+ })]
144
+ }),
145
+ initialContentWidth: 24 + 4,
146
+ padding: 'sm'
147
+ },
148
+ disabled: disabled,
149
+ className: className,
150
+ children: /*#__PURE__*/jsxRuntime.jsx(SelectInputTriggerButton, {
151
+ as: _ButtonInput.ButtonInput,
152
+ size: size,
153
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
154
+ className: clsx.clsx('np-select-input-content', placeholderShown && 'np-select-input-placeholder'),
155
+ children: content
156
+ })
157
+ })
158
+ });
159
+ function SelectInputClearButton({
160
+ className,
161
+ onClick
162
+ }) {
163
+ const intl = reactIntl.useIntl();
164
+ return /*#__PURE__*/jsxRuntime.jsx("button", {
165
+ type: "button",
166
+ "aria-label": intl.formatMessage(DateTrigger_messages.default.ariaLabel),
167
+ className: clsx.clsx(className, 'np-select-input-addon np-select-input-addon--interactive'),
168
+ onClick: onClick,
169
+ children: /*#__PURE__*/jsxRuntime.jsx(icons.Cross, {
170
+ size: 16
171
+ })
172
+ });
173
+ }
174
+ const noop = () => {};
175
+ function SelectInput({
176
+ id: idProp,
177
+ parentId,
178
+ name,
179
+ multiple,
180
+ placeholder,
181
+ autocomplete,
182
+ items,
183
+ defaultValue,
184
+ value: controlledValue,
185
+ compareValues,
186
+ renderValue = String,
187
+ renderFooter,
188
+ renderTrigger = defaultRenderTrigger,
189
+ filterable,
190
+ filterPlaceholder,
191
+ sortFilteredOptions,
192
+ disabled,
193
+ size = 'md',
194
+ className,
195
+ UNSAFE_triggerButtonProps,
196
+ triggerRef: externalTriggerRef,
197
+ onFilterChange = noop,
198
+ onChange,
199
+ onOpen,
200
+ onClose,
201
+ onClear
202
+ }) {
203
+ const inputAttributes = contexts.useInputAttributes({
204
+ nonLabelable: true
205
+ });
206
+ const id = idProp ?? inputAttributes.id;
207
+ const [open, setOpen] = React.useState(false);
208
+ const initialized = React.useRef(false);
209
+ const handleClose = useEffectEvent.useEffectEvent(onClose ?? (() => {}));
210
+ const handleOpen = useEffectEvent.useEffectEvent(onOpen ?? (() => {}));
211
+ React.useEffect(() => {
212
+ if (initialized.current) {
213
+ if (open) {
214
+ handleOpen?.();
215
+ } else {
216
+ handleClose?.();
217
+ }
218
+ } else {
219
+ initialized.current = true;
220
+ }
221
+ }, [handleClose, handleOpen, open]);
222
+ const [filterQuery, _setFilterQuery] = React.useState('');
223
+ const deferredFilterQuery = React.useDeferredValue(filterQuery);
224
+ const setFilterQuery = useEffectEvent.useEffectEvent(query => {
225
+ _setFilterQuery(query);
226
+ if (query !== filterQuery) {
227
+ onFilterChange({
228
+ query,
229
+ queryNormalized: query ? searchableString(query) : null
230
+ });
231
+ }
232
+ });
233
+ const internalTriggerRef = React.useRef(null);
234
+ const screenSm = useScreenSize.useScreenSize(breakpoint.Breakpoint.SMALL);
235
+ const OptionsOverlay = screenSm ? _Popover.Popover : _BottomSheet.BottomSheet;
236
+ const searchInputRef = React.useRef(null);
237
+ const listboxRef = React.useRef(null);
238
+ const controllerRef = filterable ? searchInputRef : listboxRef;
239
+ /**
240
+ * Attempts to resolve the `listbox` label
241
+ * @see https://storybook.wise.design/?path=/docs/forms-selectinput-accessibility--docs#labelling
242
+ */
243
+ const getListBoxLabelProps = () => {
244
+ if (UNSAFE_triggerButtonProps?.['aria-label']) {
245
+ return {
246
+ listBoxLabel: UNSAFE_triggerButtonProps['aria-label']
247
+ };
248
+ }
249
+ if (UNSAFE_triggerButtonProps?.['aria-labelledby']) {
250
+ return {
251
+ listBoxLabelledBy: UNSAFE_triggerButtonProps['aria-labelledby']
252
+ };
253
+ }
254
+ if (inputAttributes['aria-labelledby']) {
255
+ return {
256
+ listBoxLabelledBy: inputAttributes['aria-labelledby']
257
+ };
258
+ }
259
+ return {};
260
+ };
261
+ return /*#__PURE__*/jsxRuntime.jsx(react.Listbox, {
262
+ name: name,
263
+ multiple: multiple,
264
+ defaultValue: defaultValue,
265
+ value: controlledValue,
266
+ by: compareValues,
267
+ disabled: disabled,
268
+ onChange: value => {
269
+ if (!multiple) {
270
+ setOpen(false);
271
+ }
272
+ onChange?.(value);
273
+ },
274
+ children: ({
275
+ disabled: uiDisabled,
276
+ value
277
+ }) => {
278
+ const placeholderShown = multiple && Array.isArray(value) ? value.length === 0 : value == null;
279
+ return /*#__PURE__*/jsxRuntime.jsx(OptionsOverlay, {
280
+ placement: "bottom-start",
281
+ open: open,
282
+ renderTrigger: ({
283
+ ref,
284
+ getInteractionProps
285
+ }) => /*#__PURE__*/jsxRuntime.jsx(SelectInputTriggerButtonPropsContext.Provider, {
286
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
287
+ value: {
288
+ ref: node => {
289
+ ref(node);
290
+ if (externalTriggerRef) {
291
+ // eslint-disable-next-line no-param-reassign
292
+ externalTriggerRef.current = node;
293
+ } else {
294
+ internalTriggerRef.current = node;
295
+ }
296
+ },
297
+ ...inputAttributes,
298
+ ...UNSAFE_triggerButtonProps,
299
+ id,
300
+ ...mergeProps__default.default({
301
+ onClick: () => {
302
+ setOpen(prev => !prev);
303
+ },
304
+ onKeyDown: event => {
305
+ if (event.key === ' ' || event.key === 'Enter' || event.key === 'ArrowDown' || event.key === 'ArrowUp') {
306
+ setOpen(prev => !prev);
307
+ }
308
+ }
309
+ }, getInteractionProps())
310
+ },
311
+ children: renderTrigger({
312
+ content: !placeholderShown ? /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
313
+ value: true,
314
+ children: multiple && Array.isArray(value) ? value.map(option => renderValue(option, true)).filter(node => node != null).join(', ') : renderValue(value, true)
315
+ }) : placeholder,
316
+ placeholderShown,
317
+ clear: onClear != null ? () => {
318
+ onClear();
319
+ (externalTriggerRef?.current ?? internalTriggerRef.current)?.focus({
320
+ preventScroll: true
321
+ });
322
+ } : undefined,
323
+ disabled: uiDisabled,
324
+ size,
325
+ className
326
+ })
327
+ }),
328
+ initialFocusRef: controllerRef,
329
+ size: filterable ? 'lg' : 'md',
330
+ padding: "none",
331
+ onClose: () => {
332
+ setOpen(false);
333
+ },
334
+ onCloseEnd: () => {
335
+ setFilterQuery('');
336
+ },
337
+ children: /*#__PURE__*/jsxRuntime.jsx(SelectInputOptions, {
338
+ id: id ? `${id}Search` : undefined,
339
+ parentId: parentId,
340
+ items: items,
341
+ compareValues: compareValues,
342
+ renderValue: renderValue,
343
+ renderFooter: renderFooter,
344
+ filterable: filterable,
345
+ filterPlaceholder: filterPlaceholder,
346
+ sortFilteredOptions: sortFilteredOptions,
347
+ searchInputRef: searchInputRef,
348
+ listboxRef: listboxRef,
349
+ filterQuery: deferredFilterQuery,
350
+ autocomplete: autocomplete,
351
+ name: name,
352
+ onFilterChange: setFilterQuery,
353
+ onAutocompleteSelect: matchedValue => {
354
+ onChange?.(matchedValue);
355
+ if (!multiple) {
356
+ setOpen(false);
357
+ }
358
+ },
359
+ ...getListBoxLabelProps()
360
+ })
361
+ });
362
+ }
363
+ });
364
+ }
365
+ const SelectInputTriggerButtonPropsContext = /*#__PURE__*/React.createContext({});
366
+ function SelectInputTriggerButton({
367
+ as = 'button',
368
+ ...restProps
369
+ }) {
370
+ const {
371
+ ref,
372
+ onClick,
373
+ onKeyDown,
374
+ ...interactionProps
375
+ } = React.useContext(SelectInputTriggerButtonPropsContext);
376
+ return /*#__PURE__*/jsxRuntime.jsx(react.ListboxButton, {
377
+ ref: ref,
378
+ as: PolymorphicWithOverrides.PolymorphicWithOverrides,
379
+ role: "combobox",
380
+ __overrides: {
381
+ as,
382
+ ...interactionProps
383
+ },
384
+ ...mergeProps__default.default({
385
+ onClick,
386
+ onKeyDown
387
+ }, restProps)
388
+ });
389
+ }
390
+ const SelectInputOptionsContainer = /*#__PURE__*/React.forwardRef(function SelectInputOptionsContainer({
391
+ 'aria-orientation': ariaOrientation,
392
+ 'aria-activedescendant': ariaActiveDescendant,
393
+ role,
394
+ tabIndex,
395
+ onAriaActiveDescendantChange,
396
+ onKeyDown,
397
+ ...restProps
398
+ }, ref) {
399
+ const handleAriaActiveDescendantChange = useEffectEvent.useEffectEvent(onAriaActiveDescendantChange);
400
+ React.useEffect(() => {
401
+ handleAriaActiveDescendantChange(ariaActiveDescendant);
402
+ }, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
403
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
404
+ ref: ref,
405
+ role: "none",
406
+ onKeyDown: event => {
407
+ // Prevent confirmation close without an active item
408
+ if (event.key === 'Enter' && ariaActiveDescendant == null) {
409
+ return;
410
+ }
411
+ // Required to make ListBox focusable
412
+ if (event.key === 'Tab') {
413
+ return;
414
+ }
415
+ // Prevent absorbing Escape early
416
+ if (event.key === 'Escape') {
417
+ onKeyDown?.({
418
+ ...event,
419
+ preventDefault: () => {},
420
+ stopPropagation: () => {}
421
+ });
422
+ return;
423
+ }
424
+ onKeyDown?.(event);
425
+ },
426
+ ...restProps
427
+ });
428
+ });
429
+ function SelectInputOptions({
430
+ id,
431
+ parentId,
432
+ items,
433
+ compareValues: compareValuesProp,
434
+ renderValue = String,
435
+ renderFooter,
436
+ filterable = false,
437
+ filterPlaceholder,
438
+ sortFilteredOptions,
439
+ searchInputRef,
440
+ listboxRef,
441
+ filterQuery,
442
+ onFilterChange,
443
+ listBoxLabel,
444
+ listBoxLabelledBy,
445
+ autocomplete,
446
+ name,
447
+ onAutocompleteSelect
448
+ }) {
449
+ const intl = reactIntl.useIntl();
450
+ const virtualiserHandlerRef = React.useRef(null);
451
+ const controllerRef = filterable ? searchInputRef : listboxRef;
452
+ const [initialRender, setInitialRender] = React.useState(true);
453
+ const needle = React.useMemo(() => {
454
+ if (filterable) {
455
+ return filterQuery ? searchableString(filterQuery) : null;
456
+ }
457
+ return undefined;
458
+ }, [filterQuery, filterable]);
459
+ React.useEffect(() => {
460
+ if (needle) {
461
+ // Ensure having an active option while filtering.
462
+ // Without `requestAnimationFrame` upon which React depends for scheduling
463
+ // updates, the active status would only show for a split second and then
464
+ // disappear inadvertently.
465
+ requestAnimationFrame(() => {
466
+ if (controllerRef.current != null && !controllerRef.current.hasAttribute('aria-activedescendant')) {
467
+ // Activate first option via synthetic key press
468
+ controllerRef.current.dispatchEvent(new KeyboardEvent('keydown', {
469
+ key: 'Home',
470
+ bubbles: true
471
+ }));
472
+ }
473
+ });
474
+ }
475
+ }, [controllerRef, needle]);
476
+ const compareValues = React.useMemo(() => {
477
+ if (!compareValuesProp) {
478
+ return undefined;
479
+ }
480
+ if (typeof compareValuesProp === 'function') {
481
+ return (a, b) => compareValuesProp(a, b);
482
+ }
483
+ const key = compareValuesProp;
484
+ return (a, b) => {
485
+ if (typeof a === 'object' && a != null && typeof b === 'object' && b != null) {
486
+ return a[key] === b[key];
487
+ }
488
+ return a === b;
489
+ };
490
+ }, [compareValuesProp]);
491
+ const filteredItems = React.useMemo(() => {
492
+ if (needle == null) {
493
+ return items;
494
+ }
495
+ const dedupedItems = dedupeSelectInputItems(items, compareValues);
496
+ if (sortFilteredOptions) {
497
+ // When sorting, filter out non-matching items completely to avoid ghost items
498
+ const filtered = dedupedItems.map(item => {
499
+ if (item.type === 'option') {
500
+ return selectInputOptionItemIncludesNeedle(item, needle) ? item : {
501
+ ...item,
502
+ value: undefined
503
+ };
504
+ }
505
+ if (item.type === 'group') {
506
+ return {
507
+ ...item,
508
+ options: item.options.map(option => selectInputOptionItemIncludesNeedle(option, needle) ? option : {
509
+ ...option,
510
+ value: undefined
511
+ })
512
+ };
513
+ }
514
+ return item;
515
+ });
516
+ return sortSelectInputItems(filtered, sortFilteredOptions, filterQuery);
517
+ }
518
+ return filterSelectInputItems(dedupedItems, item => selectInputOptionItemIncludesNeedle(item, needle));
519
+ // eslint-disable-next-line react-hooks/exhaustive-deps
520
+ }, [needle, items, compareValues]);
521
+ const resultsEmpty = needle != null && filteredItems.length === 0;
522
+ const virtualized = filteredItems.length > MAX_ITEMS_WITHOUT_VIRTUALIZATION;
523
+ // Items shown once shall be kept mounted until the needle changes, otherwise
524
+ // the scroll position may jump around inadvertently. Pattern adopted from:
525
+ // https://inokawa.github.io/virtua/?path=/story/advanced-keep-offscreen-items--append-only
526
+ const [mountedIndexes, setMountedIndexes] = React.useState([]);
527
+ React.useEffect(() => {
528
+ // Ensure the 'End' key works as intended by keeping the last item mounted
529
+ setMountedIndexes(prevMountedIndexes => {
530
+ const indexes = new Set(prevMountedIndexes);
531
+ indexes.add(filteredItems.length - 1);
532
+ return [...indexes]; // Sorting is redundant by nature here
533
+ });
534
+ }, [needle,
535
+ // Needed as `filteredItems.length` may be equal between two updates
536
+ filteredItems.length]);
537
+ const listboxContainerRef = React.useRef(null);
538
+ React.useEffect(() => {
539
+ if (listboxContainerRef.current != null) {
540
+ listboxContainerRef.current.style.setProperty('--initial-height', `${listboxContainerRef.current.offsetHeight}px`);
541
+ }
542
+ }, []);
543
+ React.useEffect(() => {
544
+ setInitialRender(false);
545
+ }, []);
546
+ const showStatus = resultsEmpty;
547
+ const statusId = React.useId();
548
+ const listboxId = React.useId();
549
+ const getItemNode = index => {
550
+ const item = filteredItems[index];
551
+ return /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView, {
552
+ item: item,
553
+ renderValue: renderValue,
554
+ needle: needle
555
+ }, index);
556
+ };
557
+ const findMatchingItem = autocompleteValue => {
558
+ const flatOptions = items.flatMap(item => item.type === 'group' ? item.options : item.type === 'option' ? [item] : []).filter(item => item.type === 'option' && item.value != null);
559
+ const exactMatch = flatOptions.find(option => String(option.value) === autocompleteValue || option.filterMatchers?.some(matcher => matcher === autocompleteValue));
560
+ if (exactMatch) {
561
+ return exactMatch.value;
562
+ }
563
+ const fuzzyMatch = flatOptions.find(option => option.filterMatchers?.some(matcher => matcher.toLowerCase().includes(autocompleteValue.toLowerCase())));
564
+ return fuzzyMatch ? fuzzyMatch.value : null;
565
+ };
566
+ return /*#__PURE__*/jsxRuntime.jsxs(react.ListboxOptions, {
567
+ modal: true,
568
+ as: SelectInputOptionsContainer,
569
+ static: true,
570
+ className: "np-select-input-options-container",
571
+ onAriaActiveDescendantChange: value => {
572
+ if (controllerRef.current != null) {
573
+ if (!initialRender && value != null) {
574
+ controllerRef.current.setAttribute('aria-activedescendant', value);
575
+ } else {
576
+ controllerRef.current.removeAttribute('aria-activedescendant');
577
+ }
578
+ }
579
+ },
580
+ children: [filterable ? /*#__PURE__*/jsxRuntime.jsx("div", {
581
+ className: "np-select-input-query-container",
582
+ children: /*#__PURE__*/jsxRuntime.jsx(SearchInput.SearchInput, {
583
+ ref: searchInputRef,
584
+ id: id,
585
+ name: name,
586
+ autoComplete: autocomplete,
587
+ role: "combobox",
588
+ shape: "rectangle",
589
+ placeholder: filterPlaceholder,
590
+ "aria-label": filterPlaceholder,
591
+ defaultValue: filterQuery,
592
+ "aria-autocomplete": "list",
593
+ "aria-expanded": true,
594
+ "aria-controls": listboxId,
595
+ "aria-describedby": showStatus ? statusId : undefined,
596
+ onKeyDown: event => {
597
+ // Prevent interfering with the matcher of Headless UI
598
+ // https://mathiasbynens.be/notes/javascript-unicode#regex
599
+ if (/^.$/u.test(event.key)) {
600
+ event.stopPropagation();
601
+ }
602
+ },
603
+ onChange: event => {
604
+ // Free up resources and ensure not to go out of bounds when the
605
+ // resulting item count is less than before
606
+ const inputValue = event.currentTarget.value;
607
+ // Free up resources and ensure not to go out of bounds
608
+ setMountedIndexes([]);
609
+ onFilterChange(inputValue);
610
+ },
611
+ onInput: event => {
612
+ const inputValue = event.currentTarget.value;
613
+ const inputElement = event.currentTarget;
614
+ if (autocomplete && onAutocompleteSelect && inputValue) {
615
+ setTimeout(() => {
616
+ if (inputElement.value === inputValue && inputValue.length > 2) {
617
+ const matchedValue = findMatchingItem(inputValue);
618
+ if (matchedValue !== null) {
619
+ onAutocompleteSelect(matchedValue);
620
+ }
621
+ }
622
+ }, 50);
623
+ }
624
+ }
625
+ })
626
+ }) : null, /*#__PURE__*/jsxRuntime.jsxs("section", {
627
+ ref: listboxContainerRef,
628
+ tabIndex: -1,
629
+ className: clsx.clsx('np-select-input-listbox-container', virtualized && 'np-select-input-listbox-container--virtualized', needle == null &&
630
+ // Groups aren't shown when filtering
631
+ items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
632
+ "data-wds-parent": parentId ?? undefined,
633
+ children: [resultsEmpty ? /*#__PURE__*/jsxRuntime.jsxs("div", {
634
+ id: statusId,
635
+ className: "np-select-input-options-status",
636
+ children: [/*#__PURE__*/jsxRuntime.jsx(icons.CrossCircle, {
637
+ size: 16,
638
+ className: "np-select-input-options-status-icon"
639
+ }), intl.formatMessage(SelectInput_messages.default.noResultsFound)]
640
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
641
+ ref: listboxRef,
642
+ id: listboxId,
643
+ role: "listbox",
644
+ "aria-orientation": "vertical",
645
+ "aria-label": listBoxLabel,
646
+ "aria-labelledby": listBoxLabelledBy,
647
+ tabIndex: 0,
648
+ className: "np-select-input-listbox",
649
+ children: !virtualized ? filteredItems.map((_, index) => getItemNode(index)) : /*#__PURE__*/jsxRuntime.jsx(virtua.Virtualizer, {
650
+ ref: virtualiserHandlerRef,
651
+ data: filteredItems,
652
+ keepMounted: mountedIndexes,
653
+ scrollRef: listboxRef // `VList` doesn't expose this
654
+ ,
655
+ onScroll: async () => {
656
+ if (!virtualiserHandlerRef.current) return;
657
+ const startIndex = virtualiserHandlerRef.current.findItemIndex(virtualiserHandlerRef.current.scrollOffset);
658
+ const endIndex = virtualiserHandlerRef.current.findItemIndex(virtualiserHandlerRef.current.scrollOffset + virtualiserHandlerRef.current.viewportSize);
659
+ setMountedIndexes(prevMountedIndexes => {
660
+ const indexes = new Set(prevMountedIndexes);
661
+ for (let index = startIndex; index <= endIndex; index += 1) {
662
+ indexes.add(index);
663
+ }
664
+ return [...indexes].sort((a, b) => a - b);
665
+ });
666
+ },
667
+ children: (item, index) =>
668
+ /*#__PURE__*/
669
+ // The position of each item can't be inferred by browsers when
670
+ // virtualizing, as some of the items may not be in the DOM
671
+ jsxRuntime.jsx(SelectInputItemsCountContext.Provider, {
672
+ value: filteredItems.length,
673
+ children: /*#__PURE__*/jsxRuntime.jsx(SelectInputItemPositionContext.Provider, {
674
+ value: index + 1,
675
+ children: getItemNode(index)
676
+ })
677
+ })
678
+ })
679
+ }), renderFooter != null ? /*#__PURE__*/jsxRuntime.jsx("footer", {
680
+ className: "np-select-input-footer",
681
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
682
+ role: "none",
683
+ onKeyDown: event => {
684
+ // Prevent interfering with Headless UI
685
+ if (event.key !== 'Escape') {
686
+ event.stopPropagation();
687
+ }
688
+ },
689
+ children: renderFooter({
690
+ resultsEmpty,
691
+ queryNormalized: needle
692
+ })
693
+ })
694
+ }) : null]
695
+ })]
696
+ });
697
+ }
698
+ function SelectInputItemView({
699
+ item,
700
+ renderValue,
701
+ needle
702
+ }) {
703
+ switch (item.type) {
704
+ case 'option':
705
+ {
706
+ if (item.value != null && (needle == null || selectInputOptionItemIncludesNeedle(item, needle))) {
707
+ return /*#__PURE__*/jsxRuntime.jsx(SelectInputOption, {
708
+ value: item.value,
709
+ disabled: item.disabled,
710
+ children: renderValue(item.value, false)
711
+ });
712
+ }
713
+ break;
714
+ }
715
+ case 'group':
716
+ {
717
+ return /*#__PURE__*/jsxRuntime.jsx(SelectInputGroupItemView, {
718
+ item: item,
719
+ renderValue: renderValue,
720
+ needle: needle
721
+ });
722
+ }
723
+ case 'separator':
724
+ {
725
+ if (needle == null) {
726
+ return /*#__PURE__*/jsxRuntime.jsx("hr", {
727
+ className: "np-select-input-separator-item"
728
+ });
729
+ }
730
+ break;
731
+ }
732
+ }
733
+ return null;
734
+ }
735
+ function SelectInputGroupItemView({
736
+ item,
737
+ renderValue,
738
+ needle
739
+ }) {
740
+ const headerId = React.useId();
741
+ const header = /*#__PURE__*/jsxRuntime.jsx(Header.default, {
742
+ as: "header",
743
+ role: "none",
744
+ id: headerId,
745
+ title: item.label
746
+ // @ts-expect-error when we migrate ActionButton to new Button this should be sorted
747
+ ,
748
+ action: item.action && {
749
+ text: item.action.label,
750
+ onClick: item.action.onClick
751
+ },
752
+ className: "np-select-input-group-item-header p-x-1"
753
+ });
754
+ return (
755
+ /*#__PURE__*/
756
+ // An empty container may be rendered when no options match `needle`
757
+ // However, pre-filtering would result in worse performance overall
758
+ jsxRuntime.jsxs(Section.default, {
759
+ as: "section",
760
+ role: "group",
761
+ "aria-labelledby": headerId,
762
+ className: clsx.clsx('m-y-0', needle === null && 'np-select-input-group-item--without-needle'),
763
+ children: [needle == null ? header : null, item.options.map((option, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
764
+ // eslint-disable-next-line react/no-array-index-key
765
+ , {
766
+ item: option,
767
+ renderValue: renderValue,
768
+ needle: needle
769
+ }, index))]
770
+ })
771
+ );
772
+ }
773
+ const SelectInputItemsCountContext = /*#__PURE__*/React.createContext(undefined);
774
+ const SelectInputItemPositionContext = /*#__PURE__*/React.createContext(undefined);
775
+ function SelectInputOption({
776
+ value,
777
+ disabled,
778
+ children
779
+ }) {
780
+ const itemsCount = React.useContext(SelectInputItemsCountContext);
781
+ const itemPosition = React.useContext(SelectInputItemPositionContext);
782
+ return /*#__PURE__*/jsxRuntime.jsx(react.ListboxOption, {
783
+ as: "div",
784
+ value: value,
785
+ "aria-setsize": itemsCount,
786
+ "aria-posinset": itemPosition,
787
+ disabled: disabled,
788
+ className: ({
789
+ active,
790
+ disabled: uiDisabled
791
+ }) => clsx.clsx('np-select-input-option-container np-text-body-large', active && 'np-select-input-option-container--active', uiDisabled && 'np-select-input-option-container--disabled'),
792
+ children: ({
793
+ selected
794
+ }) => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
795
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
796
+ className: "np-select-input-option",
797
+ children: children
798
+ }), /*#__PURE__*/jsxRuntime.jsx(icons.Check, {
799
+ size: 16,
800
+ className: clsx.clsx('np-select-input-option-check', !selected && 'np-select-input-option-check--not-selected')
801
+ })]
802
+ })
803
+ });
804
+ }
805
+ const SelectInputOptionContentWithinTriggerContext = /*#__PURE__*/React.createContext(false);
806
+ function SelectInputOptionContent({
807
+ title,
808
+ note,
809
+ description,
810
+ icon
811
+ }) {
812
+ const withinTrigger = React.useContext(SelectInputOptionContentWithinTriggerContext);
813
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
814
+ className: clsx.clsx('np-select-input-option-content-container', (note || description) && 'np-text-body-large'),
815
+ children: [icon ? /*#__PURE__*/jsxRuntime.jsx("div", {
816
+ className: clsx.clsx('np-select-input-option-content-icon', !withinTrigger && 'np-select-input-option-content-icon--not-within-trigger'),
817
+ children: icon
818
+ }) : null, /*#__PURE__*/jsxRuntime.jsxs("div", {
819
+ className: "np-select-input-option-content-text",
820
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
821
+ className: clsx.clsx('np-select-input-option-content-text-line-1', withinTrigger && 'np-select-input-option-content-text-within-trigger'),
822
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
823
+ className: "d-inline",
824
+ children: title
825
+ }), note ? /*#__PURE__*/jsxRuntime.jsx("span", {
826
+ className: "np-select-input-option-content-text-secondary np-text-body-default",
827
+ children: note
828
+ }) : null]
829
+ }), description ? /*#__PURE__*/jsxRuntime.jsx("div", {
830
+ className: clsx.clsx('np-select-input-option-content-text-secondary np-text-body-default', withinTrigger && 'np-select-input-option-content-text-within-trigger'),
831
+ children: description
832
+ }) : null]
833
+ })]
834
+ });
835
+ }
836
+
837
+ exports.SelectInput = SelectInput;
838
+ exports.SelectInputOptionContent = SelectInputOptionContent;
839
+ exports.SelectInputTriggerButton = SelectInputTriggerButton;
840
+ //# sourceMappingURL=SelectInput.js.map