@transferwise/components 46.130.1 → 46.130.3

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 (255) hide show
  1. package/build/alert/Alert.js +4 -1
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +4 -1
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/criticalBanner/CriticalCommsBanner.js +6 -4
  6. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  7. package/build/criticalBanner/CriticalCommsBanner.mjs +6 -4
  8. package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
  9. package/build/dateInput/DateInput.js +12 -5
  10. package/build/dateInput/DateInput.js.map +1 -1
  11. package/build/dateInput/DateInput.mjs +11 -4
  12. package/build/dateInput/DateInput.mjs.map +1 -1
  13. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +16 -8
  14. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +1 -1
  15. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +14 -6
  16. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +1 -1
  17. package/build/index.js +12 -7
  18. package/build/index.js.map +1 -1
  19. package/build/index.mjs +9 -3
  20. package/build/index.mjs.map +1 -1
  21. package/build/inputs/{_BottomSheet.js → SelectInput/BottomSheet/SelectInputBottomSheet.js} +7 -7
  22. package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.js.map +1 -0
  23. package/build/inputs/{_BottomSheet.mjs → SelectInput/BottomSheet/SelectInputBottomSheet.mjs} +7 -7
  24. package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.mjs.map +1 -0
  25. package/build/inputs/{_ButtonInput.js → SelectInput/ButtonInput/SelectInputButtonInput.js} +5 -5
  26. package/build/inputs/SelectInput/ButtonInput/SelectInputButtonInput.js.map +1 -0
  27. package/build/inputs/{_ButtonInput.mjs → SelectInput/ButtonInput/SelectInputButtonInput.mjs} +5 -5
  28. package/build/inputs/SelectInput/ButtonInput/SelectInputButtonInput.mjs.map +1 -0
  29. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.js +26 -0
  30. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.js.map +1 -0
  31. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.mjs +24 -0
  32. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.mjs.map +1 -0
  33. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.js +59 -0
  34. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.js.map +1 -0
  35. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.mjs +56 -0
  36. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.mjs.map +1 -0
  37. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.js +50 -0
  38. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.js.map +1 -0
  39. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.mjs +48 -0
  40. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.mjs.map +1 -0
  41. package/build/inputs/SelectInput/ItemView/SelectInputItemView.js +47 -0
  42. package/build/inputs/SelectInput/ItemView/SelectInputItemView.js.map +1 -0
  43. package/build/inputs/SelectInput/ItemView/SelectInputItemView.mjs +45 -0
  44. package/build/inputs/SelectInput/ItemView/SelectInputItemView.mjs.map +1 -0
  45. package/build/inputs/SelectInput/Option/SelectInputOption.js +42 -0
  46. package/build/inputs/SelectInput/Option/SelectInputOption.js.map +1 -0
  47. package/build/inputs/SelectInput/Option/SelectInputOption.mjs +40 -0
  48. package/build/inputs/SelectInput/Option/SelectInputOption.mjs.map +1 -0
  49. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.js +40 -0
  50. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.js.map +1 -0
  51. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs +38 -0
  52. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs.map +1 -0
  53. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.js +48 -0
  54. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.js.map +1 -0
  55. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.mjs +46 -0
  56. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.mjs.map +1 -0
  57. package/build/inputs/SelectInput/Options/SelectInputOptions.js +300 -0
  58. package/build/inputs/SelectInput/Options/SelectInputOptions.js.map +1 -0
  59. package/build/inputs/SelectInput/Options/SelectInputOptions.mjs +298 -0
  60. package/build/inputs/SelectInput/Options/SelectInputOptions.mjs.map +1 -0
  61. package/build/inputs/{_Popover.js → SelectInput/Popover/SelectInputPopover.js} +7 -7
  62. package/build/inputs/SelectInput/Popover/SelectInputPopover.js.map +1 -0
  63. package/build/inputs/{_Popover.mjs → SelectInput/Popover/SelectInputPopover.mjs} +7 -7
  64. package/build/inputs/SelectInput/Popover/SelectInputPopover.mjs.map +1 -0
  65. package/build/inputs/SelectInput/SelectInput.contexts.js +29 -0
  66. package/build/inputs/SelectInput/SelectInput.contexts.js.map +1 -0
  67. package/build/inputs/SelectInput/SelectInput.contexts.mjs +24 -0
  68. package/build/inputs/SelectInput/SelectInput.contexts.mjs.map +1 -0
  69. package/build/inputs/SelectInput/SelectInput.js +222 -0
  70. package/build/inputs/SelectInput/SelectInput.js.map +1 -0
  71. package/build/inputs/SelectInput/SelectInput.messages.js.map +1 -0
  72. package/build/inputs/SelectInput/SelectInput.messages.mjs.map +1 -0
  73. package/build/inputs/SelectInput/SelectInput.mjs +216 -0
  74. package/build/inputs/SelectInput/SelectInput.mjs.map +1 -0
  75. package/build/inputs/SelectInput/SelectInput.utils.js +164 -0
  76. package/build/inputs/SelectInput/SelectInput.utils.js.map +1 -0
  77. package/build/inputs/SelectInput/SelectInput.utils.mjs +154 -0
  78. package/build/inputs/SelectInput/SelectInput.utils.mjs.map +1 -0
  79. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js +42 -0
  80. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js.map +1 -0
  81. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs +36 -0
  82. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs.map +1 -0
  83. package/build/main.css +99 -90
  84. package/build/moneyInput/MoneyInput.js +9 -2
  85. package/build/moneyInput/MoneyInput.js.map +1 -1
  86. package/build/moneyInput/MoneyInput.mjs +8 -1
  87. package/build/moneyInput/MoneyInput.mjs.map +1 -1
  88. package/build/phoneNumberInput/PhoneNumberInput.js +10 -3
  89. package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
  90. package/build/phoneNumberInput/PhoneNumberInput.mjs +9 -2
  91. package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  92. package/build/styles/criticalBanner/CriticalCommsBanner.css +9 -0
  93. package/build/styles/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.css +96 -0
  94. package/build/styles/inputs/SelectInput/ButtonInput/SelectInputButtonInput.css +16 -0
  95. package/build/styles/inputs/SelectInput/ClearButton/SelectInputClearButton.css +46 -0
  96. package/build/styles/inputs/SelectInput/ItemView/SelectInputItemView.css +16 -0
  97. package/build/styles/inputs/SelectInput/Option/SelectInputOption.css +33 -0
  98. package/build/styles/inputs/SelectInput/OptionContent/SelectInputOptionContent.css +37 -0
  99. package/build/styles/inputs/SelectInput/Options/SelectInputOptions.css +81 -0
  100. package/build/styles/inputs/SelectInput/Popover/SelectInputPopover.css +46 -0
  101. package/build/styles/main.css +99 -90
  102. package/build/types/alert/Alert.d.ts +2 -0
  103. package/build/types/alert/Alert.d.ts.map +1 -1
  104. package/build/types/criticalBanner/CriticalCommsBanner.d.ts +1 -0
  105. package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
  106. package/build/types/index.d.ts +1 -1
  107. package/build/types/index.d.ts.map +1 -1
  108. package/build/types/inputs/{_BottomSheet.d.ts → SelectInput/BottomSheet/SelectInputBottomSheet.d.ts} +3 -3
  109. package/build/types/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.d.ts.map +1 -0
  110. package/build/types/inputs/SelectInput/BottomSheet/index.d.ts +3 -0
  111. package/build/types/inputs/SelectInput/BottomSheet/index.d.ts.map +1 -0
  112. package/build/types/inputs/SelectInput/ButtonInput/SelectInputButtonInput.d.ts +5 -0
  113. package/build/types/inputs/SelectInput/ButtonInput/SelectInputButtonInput.d.ts.map +1 -0
  114. package/build/types/inputs/SelectInput/ButtonInput/index.d.ts +3 -0
  115. package/build/types/inputs/SelectInput/ButtonInput/index.d.ts.map +1 -0
  116. package/build/types/inputs/SelectInput/ClearButton/SelectInputClearButton.d.ts +7 -0
  117. package/build/types/inputs/SelectInput/ClearButton/SelectInputClearButton.d.ts.map +1 -0
  118. package/build/types/inputs/SelectInput/ClearButton/index.d.ts +3 -0
  119. package/build/types/inputs/SelectInput/ClearButton/index.d.ts.map +1 -0
  120. package/build/types/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.d.ts +16 -0
  121. package/build/types/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.d.ts.map +1 -0
  122. package/build/types/inputs/SelectInput/DefaultRenderTrigger/index.d.ts +2 -0
  123. package/build/types/inputs/SelectInput/DefaultRenderTrigger/index.d.ts.map +1 -0
  124. package/build/types/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.d.ts +9 -0
  125. package/build/types/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.d.ts.map +1 -0
  126. package/build/types/inputs/SelectInput/ItemView/GroupItemView/index.d.ts +3 -0
  127. package/build/types/inputs/SelectInput/ItemView/GroupItemView/index.d.ts.map +1 -0
  128. package/build/types/inputs/SelectInput/ItemView/SelectInputItemView.d.ts +11 -0
  129. package/build/types/inputs/SelectInput/ItemView/SelectInputItemView.d.ts.map +1 -0
  130. package/build/types/inputs/SelectInput/ItemView/index.d.ts +4 -0
  131. package/build/types/inputs/SelectInput/ItemView/index.d.ts.map +1 -0
  132. package/build/types/inputs/SelectInput/Option/SelectInputOption.d.ts +11 -0
  133. package/build/types/inputs/SelectInput/Option/SelectInputOption.d.ts.map +1 -0
  134. package/build/types/inputs/SelectInput/Option/index.d.ts +3 -0
  135. package/build/types/inputs/SelectInput/Option/index.d.ts.map +1 -0
  136. package/build/types/inputs/SelectInput/OptionContent/SelectInputOptionContent.d.ts +13 -0
  137. package/build/types/inputs/SelectInput/OptionContent/SelectInputOptionContent.d.ts.map +1 -0
  138. package/build/types/inputs/SelectInput/OptionContent/index.d.ts +3 -0
  139. package/build/types/inputs/SelectInput/OptionContent/index.d.ts.map +1 -0
  140. package/build/types/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.d.ts +9 -0
  141. package/build/types/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.d.ts.map +1 -0
  142. package/build/types/inputs/SelectInput/Options/OptionsContainer/index.d.ts +3 -0
  143. package/build/types/inputs/SelectInput/Options/OptionsContainer/index.d.ts.map +1 -0
  144. package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts +21 -0
  145. package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts.map +1 -0
  146. package/build/types/inputs/SelectInput/Options/index.d.ts +4 -0
  147. package/build/types/inputs/SelectInput/Options/index.d.ts.map +1 -0
  148. package/build/types/inputs/{_Popover.d.ts → SelectInput/Popover/SelectInputPopover.d.ts} +3 -3
  149. package/build/types/inputs/SelectInput/Popover/SelectInputPopover.d.ts.map +1 -0
  150. package/build/types/inputs/SelectInput/Popover/index.d.ts +3 -0
  151. package/build/types/inputs/SelectInput/Popover/index.d.ts.map +1 -0
  152. package/build/types/inputs/SelectInput/SelectInput.contexts.d.ts +33 -0
  153. package/build/types/inputs/SelectInput/SelectInput.contexts.d.ts.map +1 -0
  154. package/build/types/inputs/SelectInput/SelectInput.d.ts +10 -0
  155. package/build/types/inputs/SelectInput/SelectInput.d.ts.map +1 -0
  156. package/build/types/inputs/SelectInput/SelectInput.messages.d.ts.map +1 -0
  157. package/build/types/inputs/{SelectInput.d.ts → SelectInput/SelectInput.types.d.ts} +12 -38
  158. package/build/types/inputs/SelectInput/SelectInput.types.d.ts.map +1 -0
  159. package/build/types/inputs/SelectInput/SelectInput.utils.d.ts +60 -0
  160. package/build/types/inputs/SelectInput/SelectInput.utils.d.ts.map +1 -0
  161. package/build/types/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts +12 -0
  162. package/build/types/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts.map +1 -0
  163. package/build/types/inputs/SelectInput/TriggerButton/index.d.ts +3 -0
  164. package/build/types/inputs/SelectInput/TriggerButton/index.d.ts.map +1 -0
  165. package/build/types/inputs/SelectInput/components.d.ts +10 -0
  166. package/build/types/inputs/SelectInput/components.d.ts.map +1 -0
  167. package/build/types/inputs/SelectInput/index.d.ts +10 -0
  168. package/build/types/inputs/SelectInput/index.d.ts.map +1 -0
  169. package/package.json +1 -1
  170. package/src/alert/Alert.tsx +6 -1
  171. package/src/criticalBanner/CriticalCommsBanner.css +9 -0
  172. package/src/criticalBanner/CriticalCommsBanner.less +13 -0
  173. package/src/criticalBanner/CriticalCommsBanner.test.story.tsx +15 -0
  174. package/src/criticalBanner/CriticalCommsBanner.test.tsx +28 -2
  175. package/src/criticalBanner/CriticalCommsBanner.tsx +10 -1
  176. package/src/index.ts +0 -1
  177. package/src/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.css +96 -0
  178. package/src/inputs/{_BottomSheet.tsx → SelectInput/BottomSheet/SelectInputBottomSheet.tsx} +7 -7
  179. package/src/inputs/SelectInput/BottomSheet/index.ts +2 -0
  180. package/src/inputs/SelectInput/ButtonInput/SelectInputButtonInput.css +16 -0
  181. package/src/inputs/{_ButtonInput.tsx → SelectInput/ButtonInput/SelectInputButtonInput.tsx} +5 -5
  182. package/src/inputs/SelectInput/ButtonInput/index.ts +2 -0
  183. package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.css +46 -0
  184. package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.less +39 -0
  185. package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.tsx +27 -0
  186. package/src/inputs/SelectInput/ClearButton/index.ts +2 -0
  187. package/src/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.tsx +74 -0
  188. package/src/inputs/SelectInput/DefaultRenderTrigger/index.ts +5 -0
  189. package/src/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.tsx +61 -0
  190. package/src/inputs/SelectInput/ItemView/GroupItemView/index.ts +2 -0
  191. package/src/inputs/SelectInput/ItemView/SelectInputItemView.css +16 -0
  192. package/src/inputs/SelectInput/ItemView/SelectInputItemView.less +17 -0
  193. package/src/inputs/SelectInput/ItemView/SelectInputItemView.tsx +48 -0
  194. package/src/inputs/SelectInput/ItemView/index.ts +3 -0
  195. package/src/inputs/SelectInput/Option/SelectInputOption.css +33 -0
  196. package/src/inputs/SelectInput/Option/SelectInputOption.less +32 -0
  197. package/src/inputs/SelectInput/Option/SelectInputOption.tsx +57 -0
  198. package/src/inputs/SelectInput/Option/index.ts +2 -0
  199. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.css +37 -0
  200. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.less +38 -0
  201. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.tsx +72 -0
  202. package/src/inputs/SelectInput/OptionContent/index.ts +2 -0
  203. package/src/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.tsx +59 -0
  204. package/src/inputs/SelectInput/Options/OptionsContainer/index.ts +2 -0
  205. package/src/inputs/SelectInput/Options/SelectInputOptions.css +81 -0
  206. package/src/inputs/SelectInput/Options/SelectInputOptions.less +77 -0
  207. package/src/inputs/SelectInput/Options/SelectInputOptions.tsx +411 -0
  208. package/src/inputs/SelectInput/Options/index.ts +3 -0
  209. package/src/inputs/SelectInput/Popover/SelectInputPopover.css +46 -0
  210. package/src/inputs/{_Popover.tsx → SelectInput/Popover/SelectInputPopover.tsx} +7 -7
  211. package/src/inputs/SelectInput/Popover/index.ts +2 -0
  212. package/src/inputs/SelectInput/SelectInput.contexts.tsx +40 -0
  213. package/src/inputs/SelectInput/SelectInput.less +22 -0
  214. package/src/inputs/{SelectInput.test.tsx → SelectInput/SelectInput.test.tsx} +9 -11
  215. package/src/inputs/SelectInput/SelectInput.tsx +257 -0
  216. package/src/inputs/SelectInput/SelectInput.types.ts +113 -0
  217. package/src/inputs/SelectInput/SelectInput.utils.ts +205 -0
  218. package/src/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx +36 -0
  219. package/src/inputs/SelectInput/TriggerButton/index.ts +5 -0
  220. package/src/inputs/{SelectInput.docs.mdx → SelectInput/_stories/SelectInput.docs.mdx} +0 -1
  221. package/src/inputs/{SelectInput.story.tsx → SelectInput/_stories/SelectInput.story.tsx} +11 -8
  222. package/src/inputs/{SelectInput.test.story.tsx → SelectInput/_stories/SelectInput.test.story.tsx} +6 -10
  223. package/src/inputs/SelectInput/components.ts +10 -0
  224. package/src/inputs/SelectInput/index.ts +12 -0
  225. package/src/main.css +99 -90
  226. package/src/main.less +1 -1
  227. package/build/inputs/SelectInput.js +0 -890
  228. package/build/inputs/SelectInput.js.map +0 -1
  229. package/build/inputs/SelectInput.messages.js.map +0 -1
  230. package/build/inputs/SelectInput.messages.mjs.map +0 -1
  231. package/build/inputs/SelectInput.mjs +0 -881
  232. package/build/inputs/SelectInput.mjs.map +0 -1
  233. package/build/inputs/_BottomSheet.js.map +0 -1
  234. package/build/inputs/_BottomSheet.mjs.map +0 -1
  235. package/build/inputs/_ButtonInput.js.map +0 -1
  236. package/build/inputs/_ButtonInput.mjs.map +0 -1
  237. package/build/inputs/_Popover.js.map +0 -1
  238. package/build/inputs/_Popover.mjs.map +0 -1
  239. package/build/types/inputs/SelectInput.d.ts.map +0 -1
  240. package/build/types/inputs/SelectInput.messages.d.ts.map +0 -1
  241. package/build/types/inputs/_BottomSheet.d.ts.map +0 -1
  242. package/build/types/inputs/_ButtonInput.d.ts +0 -5
  243. package/build/types/inputs/_ButtonInput.d.ts.map +0 -1
  244. package/build/types/inputs/_Popover.d.ts.map +0 -1
  245. package/src/inputs/SelectInput.less +0 -219
  246. package/src/inputs/SelectInput.tsx +0 -1269
  247. package/build/inputs/{SelectInput.messages.js → SelectInput/SelectInput.messages.js} +0 -0
  248. package/build/inputs/{SelectInput.messages.mjs → SelectInput/SelectInput.messages.mjs} +0 -0
  249. package/build/styles/inputs/{SelectInput.css → SelectInput/SelectInput.css} +90 -90
  250. package/build/types/inputs/{SelectInput.messages.d.ts → SelectInput/SelectInput.messages.d.ts} +0 -0
  251. package/src/inputs/{_BottomSheet.less → SelectInput/BottomSheet/SelectInputBottomSheet.less} +0 -0
  252. package/src/inputs/{_ButtonInput.less → SelectInput/ButtonInput/SelectInputButtonInput.less} +0 -0
  253. package/src/inputs/{_Popover.less → SelectInput/Popover/SelectInputPopover.less} +0 -0
  254. package/src/inputs/{SelectInput.css → SelectInput/SelectInput.css} +90 -90
  255. /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
@@ -518,6 +518,15 @@
518
518
  --Button-background-hover: var(--color-sentiment-interactive-primary-hover);
519
519
  --Button-background-active: var(--color-sentiment-interactive-primary-active);
520
520
  }
521
+ .critical-comms .wds-Button[class] {
522
+ color: var(--Button-color);
523
+ }
524
+ .critical-comms .wds-Button[class]:hover {
525
+ color: var(--Button-color-hover);
526
+ }
527
+ .critical-comms .wds-Button[class]:active {
528
+ color: var(--Button-color-active);
529
+ }
521
530
  .critical-comms .alert-warning .wds-Button {
522
531
  --Button-background-hover: var(--color-sentiment-interactive-secondary-neutral-hover);
523
532
  --Button-background-active: var(--color-sentiment-interactive-secondary-neutral-active);
@@ -4002,14 +4011,91 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
4002
4011
  color: #5d7079;
4003
4012
  color: var(--color-content-secondary);
4004
4013
  }
4005
- .np-select-input-content {
4014
+ .np-select-input-option-container {
4015
+ display: flex;
4016
+ cursor: default;
4017
+ -webkit-user-select: none;
4018
+ -moz-user-select: none;
4019
+ user-select: none;
4020
+ align-items: center;
4021
+ -moz-column-gap: 8px;
4022
+ column-gap: 8px;
4023
+ -moz-column-gap: var(--size-8);
4024
+ column-gap: var(--size-8);
4025
+ border-radius: 10px;
4026
+ border-radius: var(--radius-small);
4027
+ padding: 12px 16px;
4028
+ padding: var(--size-12) var(--size-16);
4029
+ color: var(--color-interactive-primary);
4030
+ }
4031
+ .np-select-input-option-container:focus {
4032
+ outline: none;
4033
+ }
4034
+ .np-select-input-option-container--active {
4035
+ box-shadow: inset 0 0 0 1px #c9cbce;
4036
+ box-shadow: inset 0 0 0 1px var(--color-interactive-secondary);
4037
+ }
4038
+ .np-select-input-option-container--disabled {
4039
+ opacity: 0.45;
4040
+ }
4041
+ .np-select-input-option-check--not-selected {
4042
+ visibility: hidden;
4043
+ }
4044
+ .np-select-input-option {
4045
+ flex: 1;
4046
+ }
4047
+ .np-select-input-option-content-container {
4048
+ display: flex;
4049
+ align-items: center;
4050
+ -moz-column-gap: 8px;
4051
+ column-gap: 8px;
4052
+ -moz-column-gap: var(--size-8);
4053
+ column-gap: var(--size-8);
4054
+ color: #37517e;
4055
+ color: var(--color-content-primary);
4056
+ }
4057
+ .np-select-input-option-content-icon {
4058
+ display: flex;
4059
+ }
4060
+ .np-select-input-option-content-icon--not-within-trigger {
4061
+ align-self: flex-start;
4062
+ }
4063
+ .np-select-input-option-content-text {
4064
+ display: flex;
4065
+ flex: 1;
4066
+ flex-direction: column;
4067
+ overflow: hidden;
4068
+ }
4069
+ .np-select-input-option-content-text-secondary {
4070
+ color: #5d7079;
4071
+ color: var(--color-content-secondary);
4072
+ }
4073
+ .np-select-input-option-content-text-within-trigger {
4006
4074
  overflow: hidden;
4007
4075
  text-overflow: ellipsis;
4008
4076
  white-space: nowrap;
4009
4077
  }
4010
- .np-select-input-placeholder {
4011
- color: #768e9c;
4012
- color: var(--color-content-tertiary);
4078
+ .np-select-input-option-content-text-line-1 > :not([hidden]) ~ :not([hidden]) {
4079
+ margin-right: 8px;
4080
+ margin-right: var(--size-8);
4081
+ margin-left: 8px;
4082
+ margin-left: var(--size-8);
4083
+ }
4084
+ .np-select-input-group-item--without-needle:first-child {
4085
+ margin-top: calc(-1 * 8px);
4086
+ margin-top: calc(-1 * var(--size-8));
4087
+ }
4088
+ .np-select-input-group-item-header {
4089
+ position: sticky;
4090
+ top: 0px;
4091
+ z-index: 10;
4092
+ background-color: #ffffff;
4093
+ background-color: var(--color-background-elevated);
4094
+ }
4095
+ .np-select-input-separator-item {
4096
+ margin: 8px;
4097
+ margin: var(--size-8);
4098
+ border-top-width: 1px;
4013
4099
  }
4014
4100
  .np-select-input-options-container {
4015
4101
  display: flex;
@@ -4088,92 +4174,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
4088
4174
  contain: strict;
4089
4175
  height: 100%;
4090
4176
  }
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
4177
  .np-select-input-footer {
4178
4178
  padding: 4px 24px 16px;
4179
4179
  padding: var(--size-4) var(--size-24) var(--size-16);
@@ -4224,6 +4224,15 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
4224
4224
  border-inline-start: 1px solid rgba(0,0,0,0.10196);
4225
4225
  border-inline-start: 1px solid var(--color-border-neutral);
4226
4226
  }
4227
+ .np-select-input-content {
4228
+ overflow: hidden;
4229
+ text-overflow: ellipsis;
4230
+ white-space: nowrap;
4231
+ }
4232
+ .np-select-input-placeholder {
4233
+ color: #768e9c;
4234
+ color: var(--color-content-tertiary);
4235
+ }
4227
4236
  .np-text-area {
4228
4237
  min-height: 72px;
4229
4238
  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";