@transferwise/components 0.0.0-experimental-e9426b6 → 0.0.0-experimental-0397551

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 (182) 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 +821 -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 +813 -0
  18. package/build/inputs/SelectInput.mjs.map +1 -0
  19. package/build/main.css +47 -47
  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/main.css +47 -47
  29. package/build/types/inputs/{SelectInput/SelectInput.types.d.ts → SelectInput.d.ts} +7 -4
  30. package/build/types/inputs/SelectInput.d.ts.map +1 -0
  31. package/build/types/inputs/SelectInput.messages.d.ts.map +1 -0
  32. package/package.json +1 -1
  33. package/src/actionButton/ActionButton.story.tsx +3 -0
  34. package/src/checkbox/Checkbox.story.tsx +3 -0
  35. package/src/circularButton/CircularButton.story.tsx +3 -0
  36. package/src/common/bottomSheet/BottomSheet.story.tsx +12 -0
  37. package/src/common/circle/Circle.story.tsx +3 -0
  38. package/src/criticalBanner/CriticalCommsBanner.story.tsx +3 -0
  39. package/src/dateInput/DateInput.test.story.tsx +6 -0
  40. package/src/dateLookup/DateLookup.story.tsx +3 -0
  41. package/src/info/Info.story.tsx +6 -0
  42. package/src/inputs/{SelectInput/SelectInput.docs.mdx → SelectInput.docs.mdx} +1 -0
  43. package/src/inputs/SelectInput.less +219 -0
  44. package/src/inputs/{SelectInput/SelectInput.story.tsx → SelectInput.story.tsx} +7 -7
  45. package/src/inputs/SelectInput.tsx +1190 -0
  46. package/src/main.css +47 -47
  47. package/src/main.less +1 -1
  48. package/src/modal/Modal.story.tsx +15 -0
  49. package/src/snackbar/Snackbar.test.story.tsx +9 -0
  50. package/build/inputs/SelectInput/SelectInput.helpers.js +0 -115
  51. package/build/inputs/SelectInput/SelectInput.helpers.js.map +0 -1
  52. package/build/inputs/SelectInput/SelectInput.helpers.mjs +0 -109
  53. package/build/inputs/SelectInput/SelectInput.helpers.mjs.map +0 -1
  54. package/build/inputs/SelectInput/SelectInput.js +0 -216
  55. package/build/inputs/SelectInput/SelectInput.js.map +0 -1
  56. package/build/inputs/SelectInput/SelectInput.messages.js.map +0 -1
  57. package/build/inputs/SelectInput/SelectInput.messages.mjs.map +0 -1
  58. package/build/inputs/SelectInput/SelectInput.mjs +0 -210
  59. package/build/inputs/SelectInput/SelectInput.mjs.map +0 -1
  60. package/build/inputs/SelectInput/components/SelectInputClearButton/SelectInputClearButton.js +0 -26
  61. package/build/inputs/SelectInput/components/SelectInputClearButton/SelectInputClearButton.js.map +0 -1
  62. package/build/inputs/SelectInput/components/SelectInputClearButton/SelectInputClearButton.mjs +0 -24
  63. package/build/inputs/SelectInput/components/SelectInputClearButton/SelectInputClearButton.mjs.map +0 -1
  64. package/build/inputs/SelectInput/components/SelectInputDefaultTrigger/SelectInputDefaultTrigger.js +0 -54
  65. package/build/inputs/SelectInput/components/SelectInputDefaultTrigger/SelectInputDefaultTrigger.js.map +0 -1
  66. package/build/inputs/SelectInput/components/SelectInputDefaultTrigger/SelectInputDefaultTrigger.mjs +0 -52
  67. package/build/inputs/SelectInput/components/SelectInputDefaultTrigger/SelectInputDefaultTrigger.mjs.map +0 -1
  68. package/build/inputs/SelectInput/components/SelectInputGroupItemView/SelectInputGroupItemView.js +0 -50
  69. package/build/inputs/SelectInput/components/SelectInputGroupItemView/SelectInputGroupItemView.js.map +0 -1
  70. package/build/inputs/SelectInput/components/SelectInputGroupItemView/SelectInputGroupItemView.mjs +0 -48
  71. package/build/inputs/SelectInput/components/SelectInputGroupItemView/SelectInputGroupItemView.mjs.map +0 -1
  72. package/build/inputs/SelectInput/components/SelectInputItemView/SelectInputItemView.js +0 -47
  73. package/build/inputs/SelectInput/components/SelectInputItemView/SelectInputItemView.js.map +0 -1
  74. package/build/inputs/SelectInput/components/SelectInputItemView/SelectInputItemView.mjs +0 -45
  75. package/build/inputs/SelectInput/components/SelectInputItemView/SelectInputItemView.mjs.map +0 -1
  76. package/build/inputs/SelectInput/components/SelectInputOption/SelectInputOption.js +0 -45
  77. package/build/inputs/SelectInput/components/SelectInputOption/SelectInputOption.js.map +0 -1
  78. package/build/inputs/SelectInput/components/SelectInputOption/SelectInputOption.mjs +0 -41
  79. package/build/inputs/SelectInput/components/SelectInputOption/SelectInputOption.mjs.map +0 -1
  80. package/build/inputs/SelectInput/components/SelectInputOptionContent/SelectInputOptionContent.js +0 -41
  81. package/build/inputs/SelectInput/components/SelectInputOptionContent/SelectInputOptionContent.js.map +0 -1
  82. package/build/inputs/SelectInput/components/SelectInputOptionContent/SelectInputOptionContent.mjs +0 -38
  83. package/build/inputs/SelectInput/components/SelectInputOptionContent/SelectInputOptionContent.mjs.map +0 -1
  84. package/build/inputs/SelectInput/components/SelectInputOptions/SelectInputOptions.js +0 -270
  85. package/build/inputs/SelectInput/components/SelectInputOptions/SelectInputOptions.js.map +0 -1
  86. package/build/inputs/SelectInput/components/SelectInputOptions/SelectInputOptions.mjs +0 -268
  87. package/build/inputs/SelectInput/components/SelectInputOptions/SelectInputOptions.mjs.map +0 -1
  88. package/build/inputs/SelectInput/components/SelectInputOptionsContainer/SelectInputOptionsContainer.js +0 -48
  89. package/build/inputs/SelectInput/components/SelectInputOptionsContainer/SelectInputOptionsContainer.js.map +0 -1
  90. package/build/inputs/SelectInput/components/SelectInputOptionsContainer/SelectInputOptionsContainer.mjs +0 -46
  91. package/build/inputs/SelectInput/components/SelectInputOptionsContainer/SelectInputOptionsContainer.mjs.map +0 -1
  92. package/build/inputs/SelectInput/components/SelectInputTriggerButton/SelectInputTriggerButton.js +0 -41
  93. package/build/inputs/SelectInput/components/SelectInputTriggerButton/SelectInputTriggerButton.js.map +0 -1
  94. package/build/inputs/SelectInput/components/SelectInputTriggerButton/SelectInputTriggerButton.mjs +0 -34
  95. package/build/inputs/SelectInput/components/SelectInputTriggerButton/SelectInputTriggerButton.mjs.map +0 -1
  96. package/build/styles/inputs/SelectInput/components/SelectInputDefaultTrigger/SelectInputDefaultTrigger.css +0 -17
  97. package/build/styles/inputs/SelectInput/components/SelectInputItemView/SelectInputItemView.css +0 -16
  98. package/build/styles/inputs/SelectInput/components/SelectInputOption/SelectInputOption.css +0 -33
  99. package/build/styles/inputs/SelectInput/components/SelectInputOptionContent/SelectInputOptionContent.css +0 -37
  100. package/build/types/inputs/SelectInput/SelectInput.d.ts +0 -3
  101. package/build/types/inputs/SelectInput/SelectInput.d.ts.map +0 -1
  102. package/build/types/inputs/SelectInput/SelectInput.helpers.d.ts +0 -28
  103. package/build/types/inputs/SelectInput/SelectInput.helpers.d.ts.map +0 -1
  104. package/build/types/inputs/SelectInput/SelectInput.messages.d.ts.map +0 -1
  105. package/build/types/inputs/SelectInput/SelectInput.types.d.ts.map +0 -1
  106. package/build/types/inputs/SelectInput/components/SelectInputClearButton/SelectInputClearButton.d.ts +0 -5
  107. package/build/types/inputs/SelectInput/components/SelectInputClearButton/SelectInputClearButton.d.ts.map +0 -1
  108. package/build/types/inputs/SelectInput/components/SelectInputClearButton/index.d.ts +0 -2
  109. package/build/types/inputs/SelectInput/components/SelectInputClearButton/index.d.ts.map +0 -1
  110. package/build/types/inputs/SelectInput/components/SelectInputDefaultTrigger/SelectInputDefaultTrigger.d.ts +0 -9
  111. package/build/types/inputs/SelectInput/components/SelectInputDefaultTrigger/SelectInputDefaultTrigger.d.ts.map +0 -1
  112. package/build/types/inputs/SelectInput/components/SelectInputDefaultTrigger/index.d.ts +0 -2
  113. package/build/types/inputs/SelectInput/components/SelectInputDefaultTrigger/index.d.ts.map +0 -1
  114. package/build/types/inputs/SelectInput/components/SelectInputGroupItemView/SelectInputGroupItemView.d.ts +0 -9
  115. package/build/types/inputs/SelectInput/components/SelectInputGroupItemView/SelectInputGroupItemView.d.ts.map +0 -1
  116. package/build/types/inputs/SelectInput/components/SelectInputGroupItemView/index.d.ts +0 -2
  117. package/build/types/inputs/SelectInput/components/SelectInputGroupItemView/index.d.ts.map +0 -1
  118. package/build/types/inputs/SelectInput/components/SelectInputItemView/SelectInputItemView.d.ts +0 -8
  119. package/build/types/inputs/SelectInput/components/SelectInputItemView/SelectInputItemView.d.ts.map +0 -1
  120. package/build/types/inputs/SelectInput/components/SelectInputItemView/index.d.ts +0 -2
  121. package/build/types/inputs/SelectInput/components/SelectInputItemView/index.d.ts.map +0 -1
  122. package/build/types/inputs/SelectInput/components/SelectInputOption/SelectInputOption.d.ts +0 -10
  123. package/build/types/inputs/SelectInput/components/SelectInputOption/SelectInputOption.d.ts.map +0 -1
  124. package/build/types/inputs/SelectInput/components/SelectInputOption/index.d.ts +0 -2
  125. package/build/types/inputs/SelectInput/components/SelectInputOption/index.d.ts.map +0 -1
  126. package/build/types/inputs/SelectInput/components/SelectInputOptionContent/SelectInputOptionContent.d.ts +0 -9
  127. package/build/types/inputs/SelectInput/components/SelectInputOptionContent/SelectInputOptionContent.d.ts.map +0 -1
  128. package/build/types/inputs/SelectInput/components/SelectInputOptionContent/index.d.ts +0 -3
  129. package/build/types/inputs/SelectInput/components/SelectInputOptionContent/index.d.ts.map +0 -1
  130. package/build/types/inputs/SelectInput/components/SelectInputOptions/SelectInputOptions.d.ts +0 -15
  131. package/build/types/inputs/SelectInput/components/SelectInputOptions/SelectInputOptions.d.ts.map +0 -1
  132. package/build/types/inputs/SelectInput/components/SelectInputOptions/index.d.ts +0 -2
  133. package/build/types/inputs/SelectInput/components/SelectInputOptions/index.d.ts.map +0 -1
  134. package/build/types/inputs/SelectInput/components/SelectInputOptionsContainer/SelectInputOptionsContainer.d.ts +0 -6
  135. package/build/types/inputs/SelectInput/components/SelectInputOptionsContainer/SelectInputOptionsContainer.d.ts.map +0 -1
  136. package/build/types/inputs/SelectInput/components/SelectInputOptionsContainer/index.d.ts +0 -2
  137. package/build/types/inputs/SelectInput/components/SelectInputOptionsContainer/index.d.ts.map +0 -1
  138. package/build/types/inputs/SelectInput/components/SelectInputTriggerButton/SelectInputTriggerButton.d.ts +0 -15
  139. package/build/types/inputs/SelectInput/components/SelectInputTriggerButton/SelectInputTriggerButton.d.ts.map +0 -1
  140. package/build/types/inputs/SelectInput/components/SelectInputTriggerButton/index.d.ts +0 -3
  141. package/build/types/inputs/SelectInput/components/SelectInputTriggerButton/index.d.ts.map +0 -1
  142. package/build/types/inputs/SelectInput/index.d.ts +0 -5
  143. package/build/types/inputs/SelectInput/index.d.ts.map +0 -1
  144. package/src/inputs/SelectInput/SelectInput.helpers.ts +0 -152
  145. package/src/inputs/SelectInput/SelectInput.less +0 -42
  146. package/src/inputs/SelectInput/SelectInput.test.tsx +0 -606
  147. package/src/inputs/SelectInput/SelectInput.tsx +0 -247
  148. package/src/inputs/SelectInput/SelectInput.types.ts +0 -114
  149. package/src/inputs/SelectInput/components/SelectInputClearButton/SelectInputClearButton.tsx +0 -25
  150. package/src/inputs/SelectInput/components/SelectInputClearButton/index.ts +0 -1
  151. package/src/inputs/SelectInput/components/SelectInputDefaultTrigger/SelectInputDefaultTrigger.css +0 -17
  152. package/src/inputs/SelectInput/components/SelectInputDefaultTrigger/SelectInputDefaultTrigger.less +0 -15
  153. package/src/inputs/SelectInput/components/SelectInputDefaultTrigger/SelectInputDefaultTrigger.tsx +0 -56
  154. package/src/inputs/SelectInput/components/SelectInputDefaultTrigger/index.ts +0 -1
  155. package/src/inputs/SelectInput/components/SelectInputGroupItemView/SelectInputGroupItemView.tsx +0 -64
  156. package/src/inputs/SelectInput/components/SelectInputGroupItemView/index.ts +0 -1
  157. package/src/inputs/SelectInput/components/SelectInputItemView/SelectInputItemView.css +0 -16
  158. package/src/inputs/SelectInput/components/SelectInputItemView/SelectInputItemView.less +0 -17
  159. package/src/inputs/SelectInput/components/SelectInputItemView/SelectInputItemView.tsx +0 -55
  160. package/src/inputs/SelectInput/components/SelectInputItemView/index.ts +0 -1
  161. package/src/inputs/SelectInput/components/SelectInputOption/SelectInputOption.css +0 -33
  162. package/src/inputs/SelectInput/components/SelectInputOption/SelectInputOption.less +0 -32
  163. package/src/inputs/SelectInput/components/SelectInputOption/SelectInputOption.tsx +0 -51
  164. package/src/inputs/SelectInput/components/SelectInputOption/index.ts +0 -5
  165. package/src/inputs/SelectInput/components/SelectInputOptionContent/SelectInputOptionContent.css +0 -37
  166. package/src/inputs/SelectInput/components/SelectInputOptionContent/SelectInputOptionContent.less +0 -38
  167. package/src/inputs/SelectInput/components/SelectInputOptionContent/SelectInputOptionContent.tsx +0 -67
  168. package/src/inputs/SelectInput/components/SelectInputOptionContent/index.ts +0 -5
  169. package/src/inputs/SelectInput/components/SelectInputOptions/SelectInputOptions.less +0 -75
  170. package/src/inputs/SelectInput/components/SelectInputOptions/SelectInputOptions.tsx +0 -369
  171. package/src/inputs/SelectInput/components/SelectInputOptions/index.ts +0 -1
  172. package/src/inputs/SelectInput/components/SelectInputOptionsContainer/SelectInputOptionsContainer.tsx +0 -56
  173. package/src/inputs/SelectInput/components/SelectInputOptionsContainer/index.ts +0 -1
  174. package/src/inputs/SelectInput/components/SelectInputTriggerButton/SelectInputTriggerButton.tsx +0 -39
  175. package/src/inputs/SelectInput/components/SelectInputTriggerButton/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/{src/inputs/SelectInput → build/styles/inputs}/SelectInput.css +47 -47
  180. package/build/types/inputs/{SelectInput/SelectInput.messages.d.ts → SelectInput.messages.d.ts} +0 -0
  181. package/{build/styles/inputs/SelectInput → src/inputs}/SelectInput.css +47 -47
  182. /package/src/inputs/{SelectInput/SelectInput.messages.ts → SelectInput.messages.ts} +0 -0
@@ -0,0 +1,821 @@
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 filtered = filterSelectInputItems(dedupeSelectInputItems(items, compareValues), item => selectInputOptionItemIncludesNeedle(item, needle));
496
+ if (sortFilteredOptions) {
497
+ return sortSelectInputItems(filtered, sortFilteredOptions, filterQuery);
498
+ }
499
+ return filtered;
500
+ // eslint-disable-next-line react-hooks/exhaustive-deps
501
+ }, [needle, items, compareValues]);
502
+ const resultsEmpty = needle != null && filteredItems.length === 0;
503
+ const virtualized = filteredItems.length > MAX_ITEMS_WITHOUT_VIRTUALIZATION;
504
+ // Items shown once shall be kept mounted until the needle changes, otherwise
505
+ // the scroll position may jump around inadvertently. Pattern adopted from:
506
+ // https://inokawa.github.io/virtua/?path=/story/advanced-keep-offscreen-items--append-only
507
+ const [mountedIndexes, setMountedIndexes] = React.useState([]);
508
+ React.useEffect(() => {
509
+ // Ensure the 'End' key works as intended by keeping the last item mounted
510
+ setMountedIndexes(prevMountedIndexes => {
511
+ const indexes = new Set(prevMountedIndexes);
512
+ indexes.add(filteredItems.length - 1);
513
+ return [...indexes]; // Sorting is redundant by nature here
514
+ });
515
+ }, [needle,
516
+ // Needed as `filteredItems.length` may be equal between two updates
517
+ filteredItems.length]);
518
+ const listboxContainerRef = React.useRef(null);
519
+ React.useEffect(() => {
520
+ if (listboxContainerRef.current != null) {
521
+ listboxContainerRef.current.style.setProperty('--initial-height', `${listboxContainerRef.current.offsetHeight}px`);
522
+ }
523
+ }, []);
524
+ React.useEffect(() => {
525
+ setInitialRender(false);
526
+ }, []);
527
+ const showStatus = resultsEmpty;
528
+ const statusId = React.useId();
529
+ const listboxId = React.useId();
530
+ const getItemNode = index => {
531
+ const item = filteredItems[index];
532
+ return /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView, {
533
+ item: item,
534
+ renderValue: renderValue,
535
+ needle: needle
536
+ }, index);
537
+ };
538
+ const findMatchingItem = autocompleteValue => {
539
+ const flatOptions = items.flatMap(item => item.type === 'group' ? item.options : item.type === 'option' ? [item] : []).filter(item => item.type === 'option' && item.value != null);
540
+ const exactMatch = flatOptions.find(option => String(option.value) === autocompleteValue || option.filterMatchers?.some(matcher => matcher === autocompleteValue));
541
+ if (exactMatch) {
542
+ return exactMatch.value;
543
+ }
544
+ const fuzzyMatch = flatOptions.find(option => option.filterMatchers?.some(matcher => matcher.toLowerCase().includes(autocompleteValue.toLowerCase())));
545
+ return fuzzyMatch ? fuzzyMatch.value : null;
546
+ };
547
+ return /*#__PURE__*/jsxRuntime.jsxs(react.ListboxOptions, {
548
+ modal: true,
549
+ as: SelectInputOptionsContainer,
550
+ static: true,
551
+ className: "np-select-input-options-container",
552
+ onAriaActiveDescendantChange: value => {
553
+ if (controllerRef.current != null) {
554
+ if (!initialRender && value != null) {
555
+ controllerRef.current.setAttribute('aria-activedescendant', value);
556
+ } else {
557
+ controllerRef.current.removeAttribute('aria-activedescendant');
558
+ }
559
+ }
560
+ },
561
+ children: [filterable ? /*#__PURE__*/jsxRuntime.jsx("div", {
562
+ className: "np-select-input-query-container",
563
+ children: /*#__PURE__*/jsxRuntime.jsx(SearchInput.SearchInput, {
564
+ ref: searchInputRef,
565
+ id: id,
566
+ name: name,
567
+ autoComplete: autocomplete,
568
+ role: "combobox",
569
+ shape: "rectangle",
570
+ placeholder: filterPlaceholder,
571
+ "aria-label": filterPlaceholder,
572
+ defaultValue: filterQuery,
573
+ "aria-autocomplete": "list",
574
+ "aria-expanded": true,
575
+ "aria-controls": listboxId,
576
+ "aria-describedby": showStatus ? statusId : undefined,
577
+ onKeyDown: event => {
578
+ // Prevent interfering with the matcher of Headless UI
579
+ // https://mathiasbynens.be/notes/javascript-unicode#regex
580
+ if (/^.$/u.test(event.key)) {
581
+ event.stopPropagation();
582
+ }
583
+ },
584
+ onChange: event => {
585
+ // Free up resources and ensure not to go out of bounds when the
586
+ // resulting item count is less than before
587
+ const inputValue = event.currentTarget.value;
588
+ // Free up resources and ensure not to go out of bounds
589
+ setMountedIndexes([]);
590
+ onFilterChange(inputValue);
591
+ },
592
+ onInput: event => {
593
+ const inputValue = event.currentTarget.value;
594
+ const inputElement = event.currentTarget;
595
+ if (autocomplete && onAutocompleteSelect && inputValue) {
596
+ setTimeout(() => {
597
+ if (inputElement.value === inputValue && inputValue.length > 2) {
598
+ const matchedValue = findMatchingItem(inputValue);
599
+ if (matchedValue !== null) {
600
+ onAutocompleteSelect(matchedValue);
601
+ }
602
+ }
603
+ }, 50);
604
+ }
605
+ }
606
+ })
607
+ }) : null, /*#__PURE__*/jsxRuntime.jsxs("section", {
608
+ ref: listboxContainerRef,
609
+ tabIndex: -1,
610
+ className: clsx.clsx('np-select-input-listbox-container', virtualized && 'np-select-input-listbox-container--virtualized', needle == null &&
611
+ // Groups aren't shown when filtering
612
+ items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
613
+ "data-wds-parent": parentId ?? undefined,
614
+ children: [resultsEmpty ? /*#__PURE__*/jsxRuntime.jsxs("div", {
615
+ id: statusId,
616
+ className: "np-select-input-options-status",
617
+ children: [/*#__PURE__*/jsxRuntime.jsx(icons.CrossCircle, {
618
+ size: 16,
619
+ className: "np-select-input-options-status-icon"
620
+ }), intl.formatMessage(SelectInput_messages.default.noResultsFound)]
621
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
622
+ ref: listboxRef,
623
+ id: listboxId,
624
+ role: "listbox",
625
+ "aria-orientation": "vertical",
626
+ "aria-label": listBoxLabel,
627
+ "aria-labelledby": listBoxLabelledBy,
628
+ tabIndex: 0,
629
+ className: "np-select-input-listbox",
630
+ children: !virtualized ? filteredItems.map((_, index) => getItemNode(index)) : /*#__PURE__*/jsxRuntime.jsx(virtua.Virtualizer, {
631
+ ref: virtualiserHandlerRef,
632
+ data: filteredItems,
633
+ keepMounted: mountedIndexes,
634
+ scrollRef: listboxRef // `VList` doesn't expose this
635
+ ,
636
+ onScroll: async () => {
637
+ if (!virtualiserHandlerRef.current) return;
638
+ const startIndex = virtualiserHandlerRef.current.findItemIndex(virtualiserHandlerRef.current.scrollOffset);
639
+ const endIndex = virtualiserHandlerRef.current.findItemIndex(virtualiserHandlerRef.current.scrollOffset + virtualiserHandlerRef.current.viewportSize);
640
+ setMountedIndexes(prevMountedIndexes => {
641
+ const indexes = new Set(prevMountedIndexes);
642
+ for (let index = startIndex; index <= endIndex; index += 1) {
643
+ indexes.add(index);
644
+ }
645
+ return [...indexes].sort((a, b) => a - b);
646
+ });
647
+ },
648
+ children: (item, index) =>
649
+ /*#__PURE__*/
650
+ // The position of each item can't be inferred by browsers when
651
+ // virtualizing, as some of the items may not be in the DOM
652
+ jsxRuntime.jsx(SelectInputItemsCountContext.Provider, {
653
+ value: filteredItems.length,
654
+ children: /*#__PURE__*/jsxRuntime.jsx(SelectInputItemPositionContext.Provider, {
655
+ value: index + 1,
656
+ children: getItemNode(index)
657
+ })
658
+ })
659
+ }, needle)
660
+ }), renderFooter != null ? /*#__PURE__*/jsxRuntime.jsx("footer", {
661
+ className: "np-select-input-footer",
662
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
663
+ role: "none",
664
+ onKeyDown: event => {
665
+ // Prevent interfering with Headless UI
666
+ if (event.key !== 'Escape') {
667
+ event.stopPropagation();
668
+ }
669
+ },
670
+ children: renderFooter({
671
+ resultsEmpty,
672
+ queryNormalized: needle
673
+ })
674
+ })
675
+ }) : null]
676
+ })]
677
+ });
678
+ }
679
+ function SelectInputItemView({
680
+ item,
681
+ renderValue,
682
+ needle
683
+ }) {
684
+ switch (item.type) {
685
+ case 'option':
686
+ {
687
+ if (item.value != null && (needle == null || selectInputOptionItemIncludesNeedle(item, needle))) {
688
+ return /*#__PURE__*/jsxRuntime.jsx(SelectInputOption, {
689
+ value: item.value,
690
+ disabled: item.disabled,
691
+ children: renderValue(item.value, false)
692
+ });
693
+ }
694
+ break;
695
+ }
696
+ case 'group':
697
+ {
698
+ return /*#__PURE__*/jsxRuntime.jsx(SelectInputGroupItemView, {
699
+ item: item,
700
+ renderValue: renderValue,
701
+ needle: needle
702
+ });
703
+ }
704
+ case 'separator':
705
+ {
706
+ if (needle == null) {
707
+ return /*#__PURE__*/jsxRuntime.jsx("hr", {
708
+ className: "np-select-input-separator-item"
709
+ });
710
+ }
711
+ break;
712
+ }
713
+ }
714
+ return null;
715
+ }
716
+ function SelectInputGroupItemView({
717
+ item,
718
+ renderValue,
719
+ needle
720
+ }) {
721
+ const headerId = React.useId();
722
+ const header = /*#__PURE__*/jsxRuntime.jsx(Header.default, {
723
+ as: "header",
724
+ role: "none",
725
+ id: headerId,
726
+ title: item.label
727
+ // @ts-expect-error when we migrate ActionButton to new Button this should be sorted
728
+ ,
729
+ action: item.action && {
730
+ text: item.action.label,
731
+ onClick: item.action.onClick
732
+ },
733
+ className: "np-select-input-group-item-header p-x-1"
734
+ });
735
+ return (
736
+ /*#__PURE__*/
737
+ // An empty container may be rendered when no options match `needle`
738
+ // However, pre-filtering would result in worse performance overall
739
+ jsxRuntime.jsxs(Section.default, {
740
+ as: "section",
741
+ role: "group",
742
+ "aria-labelledby": headerId,
743
+ className: clsx.clsx('m-y-0', needle === null && 'np-select-input-group-item--without-needle'),
744
+ children: [needle == null ? header : null, item.options.map((option, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
745
+ // eslint-disable-next-line react/no-array-index-key
746
+ , {
747
+ item: option,
748
+ renderValue: renderValue,
749
+ needle: needle
750
+ }, index))]
751
+ })
752
+ );
753
+ }
754
+ const SelectInputItemsCountContext = /*#__PURE__*/React.createContext(undefined);
755
+ const SelectInputItemPositionContext = /*#__PURE__*/React.createContext(undefined);
756
+ function SelectInputOption({
757
+ value,
758
+ disabled,
759
+ children
760
+ }) {
761
+ const itemsCount = React.useContext(SelectInputItemsCountContext);
762
+ const itemPosition = React.useContext(SelectInputItemPositionContext);
763
+ return /*#__PURE__*/jsxRuntime.jsx(react.ListboxOption, {
764
+ as: "div",
765
+ value: value,
766
+ "aria-setsize": itemsCount,
767
+ "aria-posinset": itemPosition,
768
+ disabled: disabled,
769
+ className: ({
770
+ active,
771
+ disabled: uiDisabled
772
+ }) => 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'),
773
+ children: ({
774
+ selected
775
+ }) => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
776
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
777
+ className: "np-select-input-option",
778
+ children: children
779
+ }), /*#__PURE__*/jsxRuntime.jsx(icons.Check, {
780
+ size: 16,
781
+ className: clsx.clsx('np-select-input-option-check', !selected && 'np-select-input-option-check--not-selected')
782
+ })]
783
+ })
784
+ });
785
+ }
786
+ const SelectInputOptionContentWithinTriggerContext = /*#__PURE__*/React.createContext(false);
787
+ function SelectInputOptionContent({
788
+ title,
789
+ note,
790
+ description,
791
+ icon
792
+ }) {
793
+ const withinTrigger = React.useContext(SelectInputOptionContentWithinTriggerContext);
794
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
795
+ className: clsx.clsx('np-select-input-option-content-container', (note || description) && 'np-text-body-large'),
796
+ children: [icon ? /*#__PURE__*/jsxRuntime.jsx("div", {
797
+ className: clsx.clsx('np-select-input-option-content-icon', !withinTrigger && 'np-select-input-option-content-icon--not-within-trigger'),
798
+ children: icon
799
+ }) : null, /*#__PURE__*/jsxRuntime.jsxs("div", {
800
+ className: "np-select-input-option-content-text",
801
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
802
+ className: clsx.clsx('np-select-input-option-content-text-line-1', withinTrigger && 'np-select-input-option-content-text-within-trigger'),
803
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
804
+ className: "d-inline",
805
+ children: title
806
+ }), note ? /*#__PURE__*/jsxRuntime.jsx("span", {
807
+ className: "np-select-input-option-content-text-secondary np-text-body-default",
808
+ children: note
809
+ }) : null]
810
+ }), description ? /*#__PURE__*/jsxRuntime.jsx("div", {
811
+ className: clsx.clsx('np-select-input-option-content-text-secondary np-text-body-default', withinTrigger && 'np-select-input-option-content-text-within-trigger'),
812
+ children: description
813
+ }) : null]
814
+ })]
815
+ });
816
+ }
817
+
818
+ exports.SelectInput = SelectInput;
819
+ exports.SelectInputOptionContent = SelectInputOptionContent;
820
+ exports.SelectInputTriggerButton = SelectInputTriggerButton;
821
+ //# sourceMappingURL=SelectInput.js.map