@transferwise/components 0.0.0-experimental-3b64f23 → 0.0.0-experimental-ddcff61

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 (243) hide show
  1. package/build/criticalBanner/CriticalCommsBanner.js +4 -4
  2. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  3. package/build/criticalBanner/CriticalCommsBanner.mjs +4 -4
  4. package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
  5. package/build/dateInput/DateInput.js +12 -5
  6. package/build/dateInput/DateInput.js.map +1 -1
  7. package/build/dateInput/DateInput.mjs +11 -4
  8. package/build/dateInput/DateInput.mjs.map +1 -1
  9. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +16 -8
  10. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +1 -1
  11. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +14 -6
  12. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +1 -1
  13. package/build/index.js +12 -7
  14. package/build/index.js.map +1 -1
  15. package/build/index.mjs +9 -3
  16. package/build/index.mjs.map +1 -1
  17. package/build/inputs/{_BottomSheet.js → SelectInput/BottomSheet/SelectInputBottomSheet.js} +7 -7
  18. package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.js.map +1 -0
  19. package/build/inputs/{_BottomSheet.mjs → SelectInput/BottomSheet/SelectInputBottomSheet.mjs} +7 -7
  20. package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.mjs.map +1 -0
  21. package/build/inputs/{_ButtonInput.js → SelectInput/ButtonInput/SelectInputButtonInput.js} +5 -5
  22. package/build/inputs/SelectInput/ButtonInput/SelectInputButtonInput.js.map +1 -0
  23. package/build/inputs/{_ButtonInput.mjs → SelectInput/ButtonInput/SelectInputButtonInput.mjs} +5 -5
  24. package/build/inputs/SelectInput/ButtonInput/SelectInputButtonInput.mjs.map +1 -0
  25. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.js +26 -0
  26. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.js.map +1 -0
  27. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.mjs +24 -0
  28. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.mjs.map +1 -0
  29. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.js +59 -0
  30. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.js.map +1 -0
  31. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.mjs +56 -0
  32. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.mjs.map +1 -0
  33. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.js +50 -0
  34. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.js.map +1 -0
  35. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.mjs +48 -0
  36. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.mjs.map +1 -0
  37. package/build/inputs/SelectInput/ItemView/SelectInputItemView.js +47 -0
  38. package/build/inputs/SelectInput/ItemView/SelectInputItemView.js.map +1 -0
  39. package/build/inputs/SelectInput/ItemView/SelectInputItemView.mjs +45 -0
  40. package/build/inputs/SelectInput/ItemView/SelectInputItemView.mjs.map +1 -0
  41. package/build/inputs/SelectInput/Option/SelectInputOption.js +42 -0
  42. package/build/inputs/SelectInput/Option/SelectInputOption.js.map +1 -0
  43. package/build/inputs/SelectInput/Option/SelectInputOption.mjs +40 -0
  44. package/build/inputs/SelectInput/Option/SelectInputOption.mjs.map +1 -0
  45. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.js +40 -0
  46. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.js.map +1 -0
  47. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs +38 -0
  48. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs.map +1 -0
  49. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.js +48 -0
  50. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.js.map +1 -0
  51. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.mjs +46 -0
  52. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.mjs.map +1 -0
  53. package/build/inputs/SelectInput/Options/SelectInputOptions.js +300 -0
  54. package/build/inputs/SelectInput/Options/SelectInputOptions.js.map +1 -0
  55. package/build/inputs/SelectInput/Options/SelectInputOptions.mjs +298 -0
  56. package/build/inputs/SelectInput/Options/SelectInputOptions.mjs.map +1 -0
  57. package/build/inputs/{_Popover.js → SelectInput/Popover/SelectInputPopover.js} +7 -7
  58. package/build/inputs/SelectInput/Popover/SelectInputPopover.js.map +1 -0
  59. package/build/inputs/{_Popover.mjs → SelectInput/Popover/SelectInputPopover.mjs} +7 -7
  60. package/build/inputs/SelectInput/Popover/SelectInputPopover.mjs.map +1 -0
  61. package/build/inputs/SelectInput/SelectInput.contexts.js +29 -0
  62. package/build/inputs/SelectInput/SelectInput.contexts.js.map +1 -0
  63. package/build/inputs/SelectInput/SelectInput.contexts.mjs +24 -0
  64. package/build/inputs/SelectInput/SelectInput.contexts.mjs.map +1 -0
  65. package/build/inputs/SelectInput/SelectInput.js +222 -0
  66. package/build/inputs/SelectInput/SelectInput.js.map +1 -0
  67. package/build/inputs/SelectInput/SelectInput.messages.js.map +1 -0
  68. package/build/inputs/SelectInput/SelectInput.messages.mjs.map +1 -0
  69. package/build/inputs/SelectInput/SelectInput.mjs +216 -0
  70. package/build/inputs/SelectInput/SelectInput.mjs.map +1 -0
  71. package/build/inputs/SelectInput/SelectInput.utils.js +164 -0
  72. package/build/inputs/SelectInput/SelectInput.utils.js.map +1 -0
  73. package/build/inputs/SelectInput/SelectInput.utils.mjs +154 -0
  74. package/build/inputs/SelectInput/SelectInput.utils.mjs.map +1 -0
  75. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js +42 -0
  76. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js.map +1 -0
  77. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs +36 -0
  78. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs.map +1 -0
  79. package/build/main.css +90 -90
  80. package/build/moneyInput/MoneyInput.js +9 -2
  81. package/build/moneyInput/MoneyInput.js.map +1 -1
  82. package/build/moneyInput/MoneyInput.mjs +8 -1
  83. package/build/moneyInput/MoneyInput.mjs.map +1 -1
  84. package/build/phoneNumberInput/PhoneNumberInput.js +10 -3
  85. package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
  86. package/build/phoneNumberInput/PhoneNumberInput.mjs +9 -2
  87. package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  88. package/build/styles/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.css +96 -0
  89. package/build/styles/inputs/SelectInput/ButtonInput/SelectInputButtonInput.css +16 -0
  90. package/build/styles/inputs/SelectInput/ClearButton/SelectInputClearButton.css +46 -0
  91. package/build/styles/inputs/SelectInput/ItemView/SelectInputItemView.css +16 -0
  92. package/build/styles/inputs/SelectInput/Option/SelectInputOption.css +33 -0
  93. package/build/styles/inputs/SelectInput/OptionContent/SelectInputOptionContent.css +37 -0
  94. package/build/styles/inputs/SelectInput/Options/SelectInputOptions.css +81 -0
  95. package/build/styles/inputs/SelectInput/Popover/SelectInputPopover.css +46 -0
  96. package/build/styles/main.css +90 -90
  97. package/build/types/index.d.ts +1 -1
  98. package/build/types/index.d.ts.map +1 -1
  99. package/build/types/inputs/{_BottomSheet.d.ts → SelectInput/BottomSheet/SelectInputBottomSheet.d.ts} +3 -3
  100. package/build/types/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.d.ts.map +1 -0
  101. package/build/types/inputs/SelectInput/BottomSheet/index.d.ts +3 -0
  102. package/build/types/inputs/SelectInput/BottomSheet/index.d.ts.map +1 -0
  103. package/build/types/inputs/SelectInput/ButtonInput/SelectInputButtonInput.d.ts +5 -0
  104. package/build/types/inputs/SelectInput/ButtonInput/SelectInputButtonInput.d.ts.map +1 -0
  105. package/build/types/inputs/SelectInput/ButtonInput/index.d.ts +3 -0
  106. package/build/types/inputs/SelectInput/ButtonInput/index.d.ts.map +1 -0
  107. package/build/types/inputs/SelectInput/ClearButton/SelectInputClearButton.d.ts +7 -0
  108. package/build/types/inputs/SelectInput/ClearButton/SelectInputClearButton.d.ts.map +1 -0
  109. package/build/types/inputs/SelectInput/ClearButton/index.d.ts +3 -0
  110. package/build/types/inputs/SelectInput/ClearButton/index.d.ts.map +1 -0
  111. package/build/types/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.d.ts +16 -0
  112. package/build/types/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.d.ts.map +1 -0
  113. package/build/types/inputs/SelectInput/DefaultRenderTrigger/index.d.ts +2 -0
  114. package/build/types/inputs/SelectInput/DefaultRenderTrigger/index.d.ts.map +1 -0
  115. package/build/types/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.d.ts +9 -0
  116. package/build/types/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.d.ts.map +1 -0
  117. package/build/types/inputs/SelectInput/ItemView/GroupItemView/index.d.ts +3 -0
  118. package/build/types/inputs/SelectInput/ItemView/GroupItemView/index.d.ts.map +1 -0
  119. package/build/types/inputs/SelectInput/ItemView/SelectInputItemView.d.ts +11 -0
  120. package/build/types/inputs/SelectInput/ItemView/SelectInputItemView.d.ts.map +1 -0
  121. package/build/types/inputs/SelectInput/ItemView/index.d.ts +4 -0
  122. package/build/types/inputs/SelectInput/ItemView/index.d.ts.map +1 -0
  123. package/build/types/inputs/SelectInput/Option/SelectInputOption.d.ts +11 -0
  124. package/build/types/inputs/SelectInput/Option/SelectInputOption.d.ts.map +1 -0
  125. package/build/types/inputs/SelectInput/Option/index.d.ts +3 -0
  126. package/build/types/inputs/SelectInput/Option/index.d.ts.map +1 -0
  127. package/build/types/inputs/SelectInput/OptionContent/SelectInputOptionContent.d.ts +13 -0
  128. package/build/types/inputs/SelectInput/OptionContent/SelectInputOptionContent.d.ts.map +1 -0
  129. package/build/types/inputs/SelectInput/OptionContent/index.d.ts +3 -0
  130. package/build/types/inputs/SelectInput/OptionContent/index.d.ts.map +1 -0
  131. package/build/types/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.d.ts +9 -0
  132. package/build/types/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.d.ts.map +1 -0
  133. package/build/types/inputs/SelectInput/Options/OptionsContainer/index.d.ts +3 -0
  134. package/build/types/inputs/SelectInput/Options/OptionsContainer/index.d.ts.map +1 -0
  135. package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts +21 -0
  136. package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts.map +1 -0
  137. package/build/types/inputs/SelectInput/Options/index.d.ts +4 -0
  138. package/build/types/inputs/SelectInput/Options/index.d.ts.map +1 -0
  139. package/build/types/inputs/{_Popover.d.ts → SelectInput/Popover/SelectInputPopover.d.ts} +3 -3
  140. package/build/types/inputs/SelectInput/Popover/SelectInputPopover.d.ts.map +1 -0
  141. package/build/types/inputs/SelectInput/Popover/index.d.ts +3 -0
  142. package/build/types/inputs/SelectInput/Popover/index.d.ts.map +1 -0
  143. package/build/types/inputs/SelectInput/SelectInput.contexts.d.ts +33 -0
  144. package/build/types/inputs/SelectInput/SelectInput.contexts.d.ts.map +1 -0
  145. package/build/types/inputs/SelectInput/SelectInput.d.ts +10 -0
  146. package/build/types/inputs/SelectInput/SelectInput.d.ts.map +1 -0
  147. package/build/types/inputs/SelectInput/SelectInput.messages.d.ts.map +1 -0
  148. package/build/types/inputs/{SelectInput.d.ts → SelectInput/SelectInput.types.d.ts} +12 -38
  149. package/build/types/inputs/SelectInput/SelectInput.types.d.ts.map +1 -0
  150. package/build/types/inputs/SelectInput/SelectInput.utils.d.ts +60 -0
  151. package/build/types/inputs/SelectInput/SelectInput.utils.d.ts.map +1 -0
  152. package/build/types/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts +12 -0
  153. package/build/types/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts.map +1 -0
  154. package/build/types/inputs/SelectInput/TriggerButton/index.d.ts +3 -0
  155. package/build/types/inputs/SelectInput/TriggerButton/index.d.ts.map +1 -0
  156. package/build/types/inputs/SelectInput/components.d.ts +10 -0
  157. package/build/types/inputs/SelectInput/components.d.ts.map +1 -0
  158. package/build/types/inputs/SelectInput/index.d.ts +10 -0
  159. package/build/types/inputs/SelectInput/index.d.ts.map +1 -0
  160. package/package.json +3 -3
  161. package/src/criticalBanner/CriticalCommsBanner.test.story.tsx +0 -15
  162. package/src/criticalBanner/CriticalCommsBanner.test.tsx +0 -7
  163. package/src/criticalBanner/CriticalCommsBanner.tsx +1 -1
  164. package/src/index.ts +0 -1
  165. package/src/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.css +96 -0
  166. package/src/inputs/{_BottomSheet.tsx → SelectInput/BottomSheet/SelectInputBottomSheet.tsx} +7 -7
  167. package/src/inputs/SelectInput/BottomSheet/index.ts +2 -0
  168. package/src/inputs/SelectInput/ButtonInput/SelectInputButtonInput.css +16 -0
  169. package/src/inputs/{_ButtonInput.tsx → SelectInput/ButtonInput/SelectInputButtonInput.tsx} +5 -5
  170. package/src/inputs/SelectInput/ButtonInput/index.ts +2 -0
  171. package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.css +46 -0
  172. package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.less +39 -0
  173. package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.tsx +27 -0
  174. package/src/inputs/SelectInput/ClearButton/index.ts +2 -0
  175. package/src/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.tsx +74 -0
  176. package/src/inputs/SelectInput/DefaultRenderTrigger/index.ts +5 -0
  177. package/src/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.tsx +61 -0
  178. package/src/inputs/SelectInput/ItemView/GroupItemView/index.ts +2 -0
  179. package/src/inputs/SelectInput/ItemView/SelectInputItemView.css +16 -0
  180. package/src/inputs/SelectInput/ItemView/SelectInputItemView.less +17 -0
  181. package/src/inputs/SelectInput/ItemView/SelectInputItemView.tsx +48 -0
  182. package/src/inputs/SelectInput/ItemView/index.ts +3 -0
  183. package/src/inputs/SelectInput/Option/SelectInputOption.css +33 -0
  184. package/src/inputs/SelectInput/Option/SelectInputOption.less +32 -0
  185. package/src/inputs/SelectInput/Option/SelectInputOption.tsx +57 -0
  186. package/src/inputs/SelectInput/Option/index.ts +2 -0
  187. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.css +37 -0
  188. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.less +38 -0
  189. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.tsx +72 -0
  190. package/src/inputs/SelectInput/OptionContent/index.ts +2 -0
  191. package/src/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.tsx +59 -0
  192. package/src/inputs/SelectInput/Options/OptionsContainer/index.ts +2 -0
  193. package/src/inputs/SelectInput/Options/SelectInputOptions.css +81 -0
  194. package/src/inputs/SelectInput/Options/SelectInputOptions.less +77 -0
  195. package/src/inputs/SelectInput/Options/SelectInputOptions.tsx +411 -0
  196. package/src/inputs/SelectInput/Options/index.ts +3 -0
  197. package/src/inputs/SelectInput/Popover/SelectInputPopover.css +46 -0
  198. package/src/inputs/{_Popover.tsx → SelectInput/Popover/SelectInputPopover.tsx} +7 -7
  199. package/src/inputs/SelectInput/Popover/index.ts +2 -0
  200. package/src/inputs/SelectInput/SelectInput.contexts.tsx +40 -0
  201. package/src/inputs/SelectInput/SelectInput.less +22 -0
  202. package/src/inputs/{SelectInput.test.tsx → SelectInput/SelectInput.test.tsx} +9 -11
  203. package/src/inputs/SelectInput/SelectInput.tsx +257 -0
  204. package/src/inputs/SelectInput/SelectInput.types.ts +113 -0
  205. package/src/inputs/SelectInput/SelectInput.utils.ts +205 -0
  206. package/src/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx +36 -0
  207. package/src/inputs/SelectInput/TriggerButton/index.ts +5 -0
  208. package/src/inputs/{SelectInput.docs.mdx → SelectInput/_stories/SelectInput.docs.mdx} +0 -1
  209. package/src/inputs/{SelectInput.story.tsx → SelectInput/_stories/SelectInput.story.tsx} +11 -8
  210. package/src/inputs/{SelectInput.test.story.tsx → SelectInput/_stories/SelectInput.test.story.tsx} +6 -10
  211. package/src/inputs/SelectInput/components.ts +10 -0
  212. package/src/inputs/SelectInput/index.ts +12 -0
  213. package/src/main.css +90 -90
  214. package/src/main.less +1 -1
  215. package/build/inputs/SelectInput.js +0 -890
  216. package/build/inputs/SelectInput.js.map +0 -1
  217. package/build/inputs/SelectInput.messages.js.map +0 -1
  218. package/build/inputs/SelectInput.messages.mjs.map +0 -1
  219. package/build/inputs/SelectInput.mjs +0 -881
  220. package/build/inputs/SelectInput.mjs.map +0 -1
  221. package/build/inputs/_BottomSheet.js.map +0 -1
  222. package/build/inputs/_BottomSheet.mjs.map +0 -1
  223. package/build/inputs/_ButtonInput.js.map +0 -1
  224. package/build/inputs/_ButtonInput.mjs.map +0 -1
  225. package/build/inputs/_Popover.js.map +0 -1
  226. package/build/inputs/_Popover.mjs.map +0 -1
  227. package/build/types/inputs/SelectInput.d.ts.map +0 -1
  228. package/build/types/inputs/SelectInput.messages.d.ts.map +0 -1
  229. package/build/types/inputs/_BottomSheet.d.ts.map +0 -1
  230. package/build/types/inputs/_ButtonInput.d.ts +0 -5
  231. package/build/types/inputs/_ButtonInput.d.ts.map +0 -1
  232. package/build/types/inputs/_Popover.d.ts.map +0 -1
  233. package/src/inputs/SelectInput.less +0 -219
  234. package/src/inputs/SelectInput.tsx +0 -1269
  235. package/build/inputs/{SelectInput.messages.js → SelectInput/SelectInput.messages.js} +0 -0
  236. package/build/inputs/{SelectInput.messages.mjs → SelectInput/SelectInput.messages.mjs} +0 -0
  237. package/build/styles/inputs/{SelectInput.css → SelectInput/SelectInput.css} +90 -90
  238. package/build/types/inputs/{SelectInput.messages.d.ts → SelectInput/SelectInput.messages.d.ts} +0 -0
  239. package/src/inputs/{_BottomSheet.less → SelectInput/BottomSheet/SelectInputBottomSheet.less} +0 -0
  240. package/src/inputs/{_ButtonInput.less → SelectInput/ButtonInput/SelectInputButtonInput.less} +0 -0
  241. package/src/inputs/{_Popover.less → SelectInput/Popover/SelectInputPopover.less} +0 -0
  242. package/src/inputs/{SelectInput.css → SelectInput/SelectInput.css} +90 -90
  243. /package/src/inputs/{SelectInput.messages.ts → SelectInput/SelectInput.messages.ts} +0 -0
@@ -0,0 +1,205 @@
1
+ import { SelectInputItem, SelectInputOptionItem } from './SelectInput.types';
2
+
3
+ export const MAX_ITEMS_WITHOUT_VIRTUALIZATION = 50;
4
+
5
+ /**
6
+ * Converts a string to a normalized, searchable format by:
7
+ * - Trimming whitespace
8
+ * - Normalizing whitespace (convert multiple spaces to single space)
9
+ * - Converting to NFD normalization form to handle diacritics
10
+ * - Removing combining diacritical marks
11
+ * - Converting to lowercase
12
+ */
13
+ export function searchableString(value: string) {
14
+ return (
15
+ value
16
+ .trim()
17
+ .replace(/\s+/gu, ' ')
18
+ // NFD converts an Å to A + ̊ (and other special characters)
19
+ .normalize('NFD')
20
+ // and then this replaces the ̊ with nothing (and other special characters)
21
+ .replace(/[\u0300-\u036f]/g, '')
22
+ .toLowerCase()
23
+ );
24
+ }
25
+
26
+ /**
27
+ * Extracts searchable strings from a value.
28
+ * - If the value is a string, returns a normalized version.
29
+ * - If the value is an object, extracts all string values and normalizes them.
30
+ * - Otherwise returns an empty array.
31
+ */
32
+ export function inferSearchableStrings(value: unknown) {
33
+ if (typeof value === 'string') {
34
+ return [searchableString(value)];
35
+ }
36
+
37
+ if (typeof value === 'object' && value != null) {
38
+ return Object.values(value)
39
+ .filter((innerValue) => typeof innerValue === 'string')
40
+ .map((innerValue) => searchableString(innerValue));
41
+ }
42
+
43
+ return [];
44
+ }
45
+
46
+ /**
47
+ * Sets the value of a duplicate option item to undefined, effectively hiding it when rendered.
48
+ */
49
+ export function dedupeSelectInputOptionItem<T>(
50
+ item: SelectInputOptionItem<T>,
51
+ existingValues: Set<T>,
52
+ compareValues?: (a: T, b: T) => boolean,
53
+ ): SelectInputOptionItem<T | undefined> {
54
+ const isDuplicate = compareValues
55
+ ? Array.from(existingValues).some((existingValue) => compareValues(item.value, existingValue))
56
+ : existingValues.has(item.value);
57
+
58
+ if (!isDuplicate) {
59
+ existingValues.add(item.value);
60
+ return item;
61
+ }
62
+ return { ...item, value: undefined };
63
+ }
64
+
65
+ /**
66
+ * Sets the `value` of duplicate option items to `undefined`, hiding them when
67
+ * rendered. Indexes are kept intact within groups to preserve the active item
68
+ * between filter changes when possible.
69
+ */
70
+ export function dedupeSelectInputItems<T>(
71
+ items: readonly SelectInputItem<T>[],
72
+ compareValues?: (a: T, b: T) => boolean,
73
+ ): SelectInputItem<T | undefined>[] {
74
+ const existingValues = new Set<T>();
75
+
76
+ return items.map((item) => {
77
+ switch (item.type) {
78
+ case 'option': {
79
+ return dedupeSelectInputOptionItem(item, existingValues, compareValues);
80
+ }
81
+ case 'group': {
82
+ return {
83
+ ...item,
84
+ options: item.options.map((option) =>
85
+ dedupeSelectInputOptionItem(option, existingValues, compareValues),
86
+ ),
87
+ };
88
+ }
89
+ default:
90
+ }
91
+ return item;
92
+ });
93
+ }
94
+
95
+ /**
96
+ * Checks if a SelectInputOptionItem matches the search needle.
97
+ */
98
+ export function selectInputOptionItemIncludesNeedle<T>(
99
+ item: SelectInputOptionItem<T>,
100
+ needle: string,
101
+ ) {
102
+ return inferSearchableStrings(item.filterMatchers ?? item.value).some((haystack) =>
103
+ haystack.includes(needle),
104
+ );
105
+ }
106
+
107
+ /**
108
+ * Filters SelectInputItems based on the provided predicate function.
109
+ * For group items, it checks if any of their options match the predicate.
110
+ */
111
+ export function filterSelectInputItems<T>(
112
+ items: readonly SelectInputItem<T>[],
113
+ predicate: (item: SelectInputOptionItem<T>) => boolean,
114
+ ) {
115
+ return items.filter((item) => {
116
+ switch (item.type) {
117
+ case 'option': {
118
+ return predicate(item);
119
+ }
120
+ case 'group': {
121
+ return item.options.some((option) => predicate(option));
122
+ }
123
+ default:
124
+ }
125
+ return false;
126
+ });
127
+ }
128
+
129
+ /**
130
+ * Flattens and sorts filtered options using the provided comparator.
131
+ * Extracts all options from groups, filters out undefined values (deduplicated items),
132
+ * sorts them, and returns as a flat list of option items.
133
+ */
134
+ export function sortSelectInputItems<T>(
135
+ items: readonly SelectInputItem<T | undefined>[],
136
+ compareFn: (
137
+ a: SelectInputOptionItem<NonNullable<T>>,
138
+ b: SelectInputOptionItem<NonNullable<T>>,
139
+ searchQuery: string,
140
+ ) => number,
141
+ searchQuery: string,
142
+ ): SelectInputItem<NonNullable<T>>[] {
143
+ const flattenedOption = items.flatMap((item) => {
144
+ if (item.type === 'option') {
145
+ return item.value !== undefined ? [item as SelectInputOptionItem<NonNullable<T>>] : [];
146
+ }
147
+
148
+ if (item.type === 'group') {
149
+ return item.options.filter(
150
+ (option): option is SelectInputOptionItem<NonNullable<T>> => option.value !== undefined,
151
+ );
152
+ }
153
+
154
+ return [];
155
+ });
156
+
157
+ // eslint-disable-next-line functional/immutable-data
158
+ return flattenedOption.sort((a, b) => compareFn(a, b, searchQuery));
159
+ }
160
+
161
+ /**
162
+ * A prebuilt sort function for `sortFilteredOptions` that sorts options by relevance to the search query.
163
+ * Prioritizes: exact matches > starts with > contains > alphabetical.
164
+ *
165
+ * @param getLabel - Function to extract the label string from the option value. Defaults to using `title` property.
166
+ *
167
+ * @example
168
+ * ```tsx
169
+ * <SelectInput
170
+ * filterable
171
+ * sortFilteredOptions={sortByRelevance((value) => value.name)}
172
+ * // ...
173
+ * />
174
+ * ```
175
+ */
176
+ export function sortByRelevance<T>(
177
+ getLabel: (value: T) => string = (value) => (value as { title: string }).title,
178
+ ): (a: SelectInputOptionItem<T>, b: SelectInputOptionItem<T>, searchQuery: string) => number {
179
+ return (a, b, searchQuery) => {
180
+ const normalizedQuery = searchQuery.toLowerCase();
181
+ const labelA = getLabel(a.value).toLowerCase();
182
+ const labelB = getLabel(b.value).toLowerCase();
183
+
184
+ // Prioritize exact matches
185
+ const aExactMatch = labelA === normalizedQuery;
186
+ const bExactMatch = labelB === normalizedQuery;
187
+ if (aExactMatch && !bExactMatch) return -1;
188
+ if (!aExactMatch && bExactMatch) return 1;
189
+
190
+ // Then prioritize options where label starts with the search query
191
+ const aStartsWith = labelA.startsWith(normalizedQuery);
192
+ const bStartsWith = labelB.startsWith(normalizedQuery);
193
+ if (aStartsWith && !bStartsWith) return -1;
194
+ if (!aStartsWith && bStartsWith) return 1;
195
+
196
+ // Then prioritize options where label contains the search query
197
+ const aContains = labelA.includes(normalizedQuery);
198
+ const bContains = labelB.includes(normalizedQuery);
199
+ if (aContains && !bContains) return -1;
200
+ if (!aContains && bContains) return 1;
201
+
202
+ // Finally sort alphabetically
203
+ return labelA.localeCompare(labelB);
204
+ };
205
+ }
@@ -0,0 +1,36 @@
1
+ import { ListboxButton } from '@headlessui/react';
2
+ import mergeProps from 'merge-props';
3
+ import { useContext } from 'react';
4
+ import { PolymorphicWithOverrides } from '../../../common/polymorphicWithOverrides/PolymorphicWithOverrides';
5
+ import { Merge } from '../../../utils';
6
+ import { SelectInputTriggerButtonPropsContext } from '../SelectInput.contexts';
7
+
8
+ export type SelectInputTriggerButtonElementType = 'button' | React.ComponentType;
9
+
10
+ export type SelectInputTriggerButtonProps<
11
+ T extends SelectInputTriggerButtonElementType = 'button',
12
+ > = Merge<React.ComponentPropsWithoutRef<T>, { as?: T }>;
13
+
14
+ /**
15
+ * The trigger button component for SelectInput.
16
+ * Uses Headless UI's ListboxButton with polymorphic support to allow
17
+ * rendering as different element types.
18
+ */
19
+ export function SelectInputTriggerButton<T extends SelectInputTriggerButtonElementType = 'button'>({
20
+ as = 'button' as T,
21
+ ...restProps
22
+ }: SelectInputTriggerButtonProps<T>) {
23
+ const { ref, onClick, onKeyDown, size, ...interactionProps } = useContext(
24
+ SelectInputTriggerButtonPropsContext,
25
+ );
26
+
27
+ return (
28
+ <ListboxButton
29
+ ref={ref}
30
+ as={PolymorphicWithOverrides}
31
+ role="combobox"
32
+ __overrides={{ as, size, ...interactionProps } as Record<string, unknown>}
33
+ {...mergeProps({ onClick, onKeyDown }, restProps)}
34
+ />
35
+ );
36
+ }
@@ -0,0 +1,5 @@
1
+ export { SelectInputTriggerButton } from './SelectInputTriggerButton';
2
+ export type {
3
+ SelectInputTriggerButtonElementType,
4
+ SelectInputTriggerButtonProps,
5
+ } from './SelectInputTriggerButton';
@@ -1,5 +1,4 @@
1
1
  import { Meta } from '@storybook/addon-docs/blocks';
2
- import { MoneyInput } from '..';
3
2
 
4
3
  <Meta title="Forms/SelectInput/Accessibility" />
5
4
 
@@ -5,19 +5,19 @@ import { Flag } from '@wise/art';
5
5
  import { clsx } from 'clsx';
6
6
  import { useState } from 'react';
7
7
 
8
- import Button from '../button';
9
- import { getMonthNames } from '../common/dateUtils';
10
- import Drawer from '../drawer';
11
- import { Field } from '../field/Field';
12
- import Modal from '../modal';
13
- import { wait } from '../test-utils/wait';
8
+ import Button from '../../../button';
9
+ import { getMonthNames } from '../../../common/dateUtils';
10
+ import Drawer from '../../../drawer';
11
+ import { Field } from '../../../field/Field';
12
+ import Modal from '../../../modal';
13
+ import { wait } from '../../../test-utils/wait';
14
14
  import {
15
15
  SelectInput,
16
16
  type SelectInputItem,
17
17
  SelectInputOptionContent,
18
18
  type SelectInputProps,
19
19
  SelectInputTriggerButton,
20
- } from './SelectInput';
20
+ } from '..';
21
21
 
22
22
  const meta = {
23
23
  title: 'Forms/SelectInput',
@@ -35,7 +35,10 @@ const meta = {
35
35
  },
36
36
  },
37
37
  },
38
- parameters: { actions: { argTypesRegex: '' } },
38
+ parameters: {
39
+ docs: { toc: true },
40
+ actions: { argTypesRegex: '' },
41
+ },
39
42
  } satisfies Meta<typeof SelectInput>;
40
43
  export default meta;
41
44
 
@@ -2,16 +2,12 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { fireEvent, fn, type Mock, screen, userEvent, within } from 'storybook/test';
3
3
  import { useState } from 'react';
4
4
 
5
- import { allModes } from '../../.storybook/modes';
6
- import Body from '../body';
7
- import { Field } from '../field/Field';
8
- import { lorem5, lorem500 } from '../test-utils';
9
- import {
10
- SelectInput,
11
- SelectInputOptionContent,
12
- type SelectInputProps,
13
- sortByRelevance,
14
- } from './SelectInput';
5
+ import { allModes } from '../../../../.storybook/modes';
6
+ import Body from '../../../body';
7
+ import { Field } from '../../../field/Field';
8
+ import { lorem5, lorem500 } from '../../../test-utils';
9
+ import { sortByRelevance } from '../SelectInput.utils';
10
+ import { SelectInput, SelectInputOptionContent, type SelectInputProps } from '..';
15
11
 
16
12
  const meta = {
17
13
  title: 'Forms/SelectInput/Tests',
@@ -0,0 +1,10 @@
1
+ // Re-export all components from their new locations
2
+ export * from './ClearButton';
3
+ export * from './Option';
4
+ export * from './OptionContent';
5
+ export * from './TriggerButton';
6
+ export * from './ItemView';
7
+ export * from './Options';
8
+ export * from './BottomSheet';
9
+ export * from './Popover';
10
+ export * from './ButtonInput';
@@ -0,0 +1,12 @@
1
+ // Export from the new structure
2
+ export * from './SelectInput';
3
+ export * from './SelectInput.types';
4
+
5
+ // Export components directly
6
+ export * from './ClearButton';
7
+ export * from './Option';
8
+ export * from './OptionContent';
9
+ export * from './TriggerButton';
10
+ export * from './DefaultRenderTrigger';
11
+ export * from './ItemView';
12
+ export * from './Options';
package/src/main.css CHANGED
@@ -4002,14 +4002,91 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
4002
4002
  color: #5d7079;
4003
4003
  color: var(--color-content-secondary);
4004
4004
  }
4005
- .np-select-input-content {
4005
+ .np-select-input-option-container {
4006
+ display: flex;
4007
+ cursor: default;
4008
+ -webkit-user-select: none;
4009
+ -moz-user-select: none;
4010
+ user-select: none;
4011
+ align-items: center;
4012
+ -moz-column-gap: 8px;
4013
+ column-gap: 8px;
4014
+ -moz-column-gap: var(--size-8);
4015
+ column-gap: var(--size-8);
4016
+ border-radius: 10px;
4017
+ border-radius: var(--radius-small);
4018
+ padding: 12px 16px;
4019
+ padding: var(--size-12) var(--size-16);
4020
+ color: var(--color-interactive-primary);
4021
+ }
4022
+ .np-select-input-option-container:focus {
4023
+ outline: none;
4024
+ }
4025
+ .np-select-input-option-container--active {
4026
+ box-shadow: inset 0 0 0 1px #c9cbce;
4027
+ box-shadow: inset 0 0 0 1px var(--color-interactive-secondary);
4028
+ }
4029
+ .np-select-input-option-container--disabled {
4030
+ opacity: 0.45;
4031
+ }
4032
+ .np-select-input-option-check--not-selected {
4033
+ visibility: hidden;
4034
+ }
4035
+ .np-select-input-option {
4036
+ flex: 1;
4037
+ }
4038
+ .np-select-input-option-content-container {
4039
+ display: flex;
4040
+ align-items: center;
4041
+ -moz-column-gap: 8px;
4042
+ column-gap: 8px;
4043
+ -moz-column-gap: var(--size-8);
4044
+ column-gap: var(--size-8);
4045
+ color: #37517e;
4046
+ color: var(--color-content-primary);
4047
+ }
4048
+ .np-select-input-option-content-icon {
4049
+ display: flex;
4050
+ }
4051
+ .np-select-input-option-content-icon--not-within-trigger {
4052
+ align-self: flex-start;
4053
+ }
4054
+ .np-select-input-option-content-text {
4055
+ display: flex;
4056
+ flex: 1;
4057
+ flex-direction: column;
4058
+ overflow: hidden;
4059
+ }
4060
+ .np-select-input-option-content-text-secondary {
4061
+ color: #5d7079;
4062
+ color: var(--color-content-secondary);
4063
+ }
4064
+ .np-select-input-option-content-text-within-trigger {
4006
4065
  overflow: hidden;
4007
4066
  text-overflow: ellipsis;
4008
4067
  white-space: nowrap;
4009
4068
  }
4010
- .np-select-input-placeholder {
4011
- color: #768e9c;
4012
- color: var(--color-content-tertiary);
4069
+ .np-select-input-option-content-text-line-1 > :not([hidden]) ~ :not([hidden]) {
4070
+ margin-right: 8px;
4071
+ margin-right: var(--size-8);
4072
+ margin-left: 8px;
4073
+ margin-left: var(--size-8);
4074
+ }
4075
+ .np-select-input-group-item--without-needle:first-child {
4076
+ margin-top: calc(-1 * 8px);
4077
+ margin-top: calc(-1 * var(--size-8));
4078
+ }
4079
+ .np-select-input-group-item-header {
4080
+ position: sticky;
4081
+ top: 0px;
4082
+ z-index: 10;
4083
+ background-color: #ffffff;
4084
+ background-color: var(--color-background-elevated);
4085
+ }
4086
+ .np-select-input-separator-item {
4087
+ margin: 8px;
4088
+ margin: var(--size-8);
4089
+ border-top-width: 1px;
4013
4090
  }
4014
4091
  .np-select-input-options-container {
4015
4092
  display: flex;
@@ -4088,92 +4165,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
4088
4165
  contain: strict;
4089
4166
  height: 100%;
4090
4167
  }
4091
- .np-select-input-separator-item {
4092
- margin: 8px;
4093
- margin: var(--size-8);
4094
- border-top-width: 1px;
4095
- }
4096
- .np-select-input-group-item--without-needle:first-child {
4097
- margin-top: calc(-1 * 8px);
4098
- margin-top: calc(-1 * var(--size-8));
4099
- }
4100
- .np-select-input-group-item-header {
4101
- position: sticky;
4102
- top: 0px;
4103
- z-index: 10;
4104
- background-color: #ffffff;
4105
- background-color: var(--color-background-elevated);
4106
- }
4107
- .np-select-input-option-container {
4108
- display: flex;
4109
- cursor: default;
4110
- -webkit-user-select: none;
4111
- -moz-user-select: none;
4112
- user-select: none;
4113
- align-items: center;
4114
- -moz-column-gap: 8px;
4115
- column-gap: 8px;
4116
- -moz-column-gap: var(--size-8);
4117
- column-gap: var(--size-8);
4118
- border-radius: 10px;
4119
- border-radius: var(--radius-small);
4120
- padding: 12px 16px;
4121
- padding: var(--size-12) var(--size-16);
4122
- color: var(--color-interactive-primary);
4123
- }
4124
- .np-select-input-option-container:focus {
4125
- outline: none;
4126
- }
4127
- .np-select-input-option-container--active {
4128
- box-shadow: inset 0 0 0 1px #c9cbce;
4129
- box-shadow: inset 0 0 0 1px var(--color-interactive-secondary);
4130
- }
4131
- .np-select-input-option-container--disabled {
4132
- opacity: 0.45;
4133
- }
4134
- .np-select-input-option-check--not-selected {
4135
- visibility: hidden;
4136
- }
4137
- .np-select-input-option {
4138
- flex: 1;
4139
- }
4140
- .np-select-input-option-content-container {
4141
- display: flex;
4142
- align-items: center;
4143
- -moz-column-gap: 8px;
4144
- column-gap: 8px;
4145
- -moz-column-gap: var(--size-8);
4146
- column-gap: var(--size-8);
4147
- color: #37517e;
4148
- color: var(--color-content-primary);
4149
- }
4150
- .np-select-input-option-content-icon {
4151
- display: flex;
4152
- }
4153
- .np-select-input-option-content-icon--not-within-trigger {
4154
- align-self: flex-start;
4155
- }
4156
- .np-select-input-option-content-text {
4157
- display: flex;
4158
- flex: 1;
4159
- flex-direction: column;
4160
- overflow: hidden;
4161
- }
4162
- .np-select-input-option-content-text-secondary {
4163
- color: #5d7079;
4164
- color: var(--color-content-secondary);
4165
- }
4166
- .np-select-input-option-content-text-within-trigger {
4167
- overflow: hidden;
4168
- text-overflow: ellipsis;
4169
- white-space: nowrap;
4170
- }
4171
- .np-select-input-option-content-text-line-1 > :not([hidden]) ~ :not([hidden]) {
4172
- margin-right: 8px;
4173
- margin-right: var(--size-8);
4174
- margin-left: 8px;
4175
- margin-left: var(--size-8);
4176
- }
4177
4168
  .np-select-input-footer {
4178
4169
  padding: 4px 24px 16px;
4179
4170
  padding: var(--size-4) var(--size-24) var(--size-16);
@@ -4224,6 +4215,15 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
4224
4215
  border-inline-start: 1px solid rgba(0,0,0,0.10196);
4225
4216
  border-inline-start: 1px solid var(--color-border-neutral);
4226
4217
  }
4218
+ .np-select-input-content {
4219
+ overflow: hidden;
4220
+ text-overflow: ellipsis;
4221
+ white-space: nowrap;
4222
+ }
4223
+ .np-select-input-placeholder {
4224
+ color: #768e9c;
4225
+ color: var(--color-content-tertiary);
4226
+ }
4227
4227
  .np-text-area {
4228
4228
  min-height: 72px;
4229
4229
  min-height: var(--size-72);
package/src/main.less CHANGED
@@ -44,7 +44,7 @@
44
44
  @import "./listItem/ListItem.less";
45
45
  @import "./field/Field.less";
46
46
  @import "./inputs/InputGroup.less";
47
- @import "./inputs/SelectInput.less";
47
+ @import "./inputs/SelectInput/SelectInput.less";
48
48
  @import "./inputs/TextArea.less";
49
49
  @import "./instructionsList/InstructionsList.less";
50
50
  @import "./link/Link.less";