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