@transferwise/components 0.0.0-experimental-a18466a → 0.0.0-experimental-d6b038b

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 (496) hide show
  1. package/build/accordion/Accordion.js.map +1 -1
  2. package/build/accordion/Accordion.mjs.map +1 -1
  3. package/build/actionButton/ActionButton.js.map +1 -1
  4. package/build/actionButton/ActionButton.mjs.map +1 -1
  5. package/build/actionOption/ActionOption.js.map +1 -1
  6. package/build/actionOption/ActionOption.mjs.map +1 -1
  7. package/build/alert/Alert.js +1 -1
  8. package/build/alert/Alert.js.map +1 -1
  9. package/build/alert/Alert.mjs +1 -1
  10. package/build/alert/Alert.mjs.map +1 -1
  11. package/build/avatar/Avatar.js.map +1 -1
  12. package/build/avatar/Avatar.mjs.map +1 -1
  13. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  14. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  15. package/build/badge/Badge.js.map +1 -1
  16. package/build/badge/Badge.mjs.map +1 -1
  17. package/build/body/Body.js.map +1 -1
  18. package/build/body/Body.mjs.map +1 -1
  19. package/build/button/LegacyButton.js.map +1 -1
  20. package/build/button/LegacyButton.mjs.map +1 -1
  21. package/build/card/Card.js.map +1 -1
  22. package/build/card/Card.mjs.map +1 -1
  23. package/build/checkboxButton/CheckboxButton.js.map +1 -1
  24. package/build/checkboxButton/CheckboxButton.mjs.map +1 -1
  25. package/build/checkboxOption/CheckboxOption.js.map +1 -1
  26. package/build/checkboxOption/CheckboxOption.mjs.map +1 -1
  27. package/build/circularButton/CircularButton.js.map +1 -1
  28. package/build/circularButton/CircularButton.mjs.map +1 -1
  29. package/build/common/propsValues/type.js +1 -1
  30. package/build/common/propsValues/type.js.map +1 -1
  31. package/build/common/propsValues/type.mjs +1 -1
  32. package/build/common/propsValues/type.mjs.map +1 -1
  33. package/build/common/propsValues/typography.js +1 -1
  34. package/build/common/propsValues/typography.js.map +1 -1
  35. package/build/common/propsValues/typography.mjs +1 -1
  36. package/build/common/propsValues/typography.mjs.map +1 -1
  37. package/build/criticalBanner/CriticalCommsBanner.js +68 -3
  38. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  39. package/build/criticalBanner/CriticalCommsBanner.mjs +69 -4
  40. package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
  41. package/build/dateInput/DateInput.js +12 -5
  42. package/build/dateInput/DateInput.js.map +1 -1
  43. package/build/dateInput/DateInput.mjs +11 -4
  44. package/build/dateInput/DateInput.mjs.map +1 -1
  45. package/build/dimmer/Dimmer.js.map +1 -1
  46. package/build/dimmer/Dimmer.mjs.map +1 -1
  47. package/build/drawer/Drawer.js.map +1 -1
  48. package/build/drawer/Drawer.mjs.map +1 -1
  49. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +16 -8
  50. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +1 -1
  51. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +14 -6
  52. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +1 -1
  53. package/build/field/Field.js.map +1 -1
  54. package/build/field/Field.mjs.map +1 -1
  55. package/build/flowNavigation/FlowNavigation.js.map +1 -1
  56. package/build/flowNavigation/FlowNavigation.mjs.map +1 -1
  57. package/build/header/Header.js.map +1 -1
  58. package/build/header/Header.mjs.map +1 -1
  59. package/build/iconButton/IconButton.js.map +1 -1
  60. package/build/iconButton/IconButton.mjs.map +1 -1
  61. package/build/index.js +14 -7
  62. package/build/index.js.map +1 -1
  63. package/build/index.mjs +10 -3
  64. package/build/index.mjs.map +1 -1
  65. package/build/inputs/{_BottomSheet.js → SelectInput/BottomSheet/SelectInputBottomSheet.js} +7 -7
  66. package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.js.map +1 -0
  67. package/build/inputs/{_BottomSheet.mjs → SelectInput/BottomSheet/SelectInputBottomSheet.mjs} +7 -7
  68. package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.mjs.map +1 -0
  69. package/build/inputs/{_ButtonInput.js → SelectInput/ButtonInput/SelectInputButtonInput.js} +5 -5
  70. package/build/inputs/SelectInput/ButtonInput/SelectInputButtonInput.js.map +1 -0
  71. package/build/inputs/{_ButtonInput.mjs → SelectInput/ButtonInput/SelectInputButtonInput.mjs} +5 -5
  72. package/build/inputs/SelectInput/ButtonInput/SelectInputButtonInput.mjs.map +1 -0
  73. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.js +27 -0
  74. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.js.map +1 -0
  75. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.mjs +25 -0
  76. package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.mjs.map +1 -0
  77. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.js +59 -0
  78. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.js.map +1 -0
  79. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.mjs +56 -0
  80. package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.mjs.map +1 -0
  81. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.js +50 -0
  82. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.js.map +1 -0
  83. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.mjs +48 -0
  84. package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.mjs.map +1 -0
  85. package/build/inputs/SelectInput/ItemView/SelectInputItemView.js +47 -0
  86. package/build/inputs/SelectInput/ItemView/SelectInputItemView.js.map +1 -0
  87. package/build/inputs/SelectInput/ItemView/SelectInputItemView.mjs +45 -0
  88. package/build/inputs/SelectInput/ItemView/SelectInputItemView.mjs.map +1 -0
  89. package/build/inputs/SelectInput/Option/SelectInputOption.js +42 -0
  90. package/build/inputs/SelectInput/Option/SelectInputOption.js.map +1 -0
  91. package/build/inputs/SelectInput/Option/SelectInputOption.mjs +40 -0
  92. package/build/inputs/SelectInput/Option/SelectInputOption.mjs.map +1 -0
  93. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.js +40 -0
  94. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.js.map +1 -0
  95. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs +38 -0
  96. package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs.map +1 -0
  97. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.js +48 -0
  98. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.js.map +1 -0
  99. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.mjs +46 -0
  100. package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.mjs.map +1 -0
  101. package/build/inputs/SelectInput/Options/SelectInputOptions.js +300 -0
  102. package/build/inputs/SelectInput/Options/SelectInputOptions.js.map +1 -0
  103. package/build/inputs/SelectInput/Options/SelectInputOptions.mjs +298 -0
  104. package/build/inputs/SelectInput/Options/SelectInputOptions.mjs.map +1 -0
  105. package/build/inputs/{_Popover.js → SelectInput/Popover/SelectInputPopover.js} +7 -7
  106. package/build/inputs/SelectInput/Popover/SelectInputPopover.js.map +1 -0
  107. package/build/inputs/{_Popover.mjs → SelectInput/Popover/SelectInputPopover.mjs} +7 -7
  108. package/build/inputs/SelectInput/Popover/SelectInputPopover.mjs.map +1 -0
  109. package/build/inputs/SelectInput/SelectInput.contexts.js +29 -0
  110. package/build/inputs/SelectInput/SelectInput.contexts.js.map +1 -0
  111. package/build/inputs/SelectInput/SelectInput.contexts.mjs +24 -0
  112. package/build/inputs/SelectInput/SelectInput.contexts.mjs.map +1 -0
  113. package/build/inputs/SelectInput/SelectInput.js +222 -0
  114. package/build/inputs/SelectInput/SelectInput.js.map +1 -0
  115. package/build/inputs/SelectInput/SelectInput.messages.js.map +1 -0
  116. package/build/inputs/SelectInput/SelectInput.messages.mjs.map +1 -0
  117. package/build/inputs/SelectInput/SelectInput.mjs +216 -0
  118. package/build/inputs/SelectInput/SelectInput.mjs.map +1 -0
  119. package/build/inputs/SelectInput/SelectInput.utils.js +164 -0
  120. package/build/inputs/SelectInput/SelectInput.utils.js.map +1 -0
  121. package/build/inputs/SelectInput/SelectInput.utils.mjs +154 -0
  122. package/build/inputs/SelectInput/SelectInput.utils.mjs.map +1 -0
  123. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js +42 -0
  124. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js.map +1 -0
  125. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs +36 -0
  126. package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs.map +1 -0
  127. package/build/legacylistItem/LegacyListItem.js.map +1 -1
  128. package/build/legacylistItem/LegacyListItem.mjs.map +1 -1
  129. package/build/list/List.js.map +1 -1
  130. package/build/list/List.mjs.map +1 -1
  131. package/build/listItem/Button/ListItemButton.js.map +1 -1
  132. package/build/listItem/Button/ListItemButton.mjs.map +1 -1
  133. package/build/listItem/IconButton/ListItemIconButton.js.map +1 -1
  134. package/build/listItem/IconButton/ListItemIconButton.mjs.map +1 -1
  135. package/build/listItem/Image/ListItemImage.js.map +1 -1
  136. package/build/listItem/Image/ListItemImage.mjs.map +1 -1
  137. package/build/listItem/ListItem.js.map +1 -1
  138. package/build/listItem/ListItem.mjs.map +1 -1
  139. package/build/loader/Loader.js.map +1 -1
  140. package/build/loader/Loader.mjs.map +1 -1
  141. package/build/logo/Logo.js.map +1 -1
  142. package/build/logo/Logo.mjs.map +1 -1
  143. package/build/main.css +123 -105
  144. package/build/modal/Modal.js.map +1 -1
  145. package/build/modal/Modal.mjs.map +1 -1
  146. package/build/moneyInput/MoneyInput.js +9 -2
  147. package/build/moneyInput/MoneyInput.js.map +1 -1
  148. package/build/moneyInput/MoneyInput.mjs +8 -1
  149. package/build/moneyInput/MoneyInput.mjs.map +1 -1
  150. package/build/navigationOption/NavigationOption.js.map +1 -1
  151. package/build/navigationOption/NavigationOption.mjs.map +1 -1
  152. package/build/navigationOptionsList/NavigationOptionsList.js.map +1 -1
  153. package/build/navigationOptionsList/NavigationOptionsList.mjs.map +1 -1
  154. package/build/nudge/Nudge.js.map +1 -1
  155. package/build/nudge/Nudge.mjs.map +1 -1
  156. package/build/phoneNumberInput/PhoneNumberInput.js +10 -3
  157. package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
  158. package/build/phoneNumberInput/PhoneNumberInput.mjs +9 -2
  159. package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  160. package/build/popover/Popover.js.map +1 -1
  161. package/build/popover/Popover.mjs.map +1 -1
  162. package/build/processIndicator/ProcessIndicator.js.map +1 -1
  163. package/build/processIndicator/ProcessIndicator.mjs.map +1 -1
  164. package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
  165. package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
  166. package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
  167. package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
  168. package/build/radioOption/RadioOption.js.map +1 -1
  169. package/build/radioOption/RadioOption.mjs.map +1 -1
  170. package/build/select/Select.js.map +1 -1
  171. package/build/select/Select.mjs.map +1 -1
  172. package/build/statusIcon/StatusIcon.js.map +1 -1
  173. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  174. package/build/styles/criticalBanner/CriticalCommsBanner.css +33 -15
  175. package/build/styles/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.css +96 -0
  176. package/build/styles/inputs/SelectInput/ButtonInput/SelectInputButtonInput.css +16 -0
  177. package/build/styles/inputs/SelectInput/ClearButton/SelectInputClearButton.css +46 -0
  178. package/build/styles/inputs/SelectInput/ItemView/SelectInputItemView.css +16 -0
  179. package/build/styles/inputs/SelectInput/Option/SelectInputOption.css +33 -0
  180. package/build/styles/inputs/SelectInput/OptionContent/SelectInputOptionContent.css +37 -0
  181. package/build/styles/inputs/SelectInput/Options/SelectInputOptions.css +81 -0
  182. package/build/styles/inputs/SelectInput/Popover/SelectInputPopover.css +46 -0
  183. package/build/styles/main.css +123 -105
  184. package/build/summary/Summary.js +1 -1
  185. package/build/summary/Summary.js.map +1 -1
  186. package/build/summary/Summary.mjs +1 -1
  187. package/build/summary/Summary.mjs.map +1 -1
  188. package/build/switchOption/SwitchOption.js +1 -1
  189. package/build/switchOption/SwitchOption.js.map +1 -1
  190. package/build/switchOption/SwitchOption.mjs +1 -1
  191. package/build/switchOption/SwitchOption.mjs.map +1 -1
  192. package/build/tabs/Tabs.js.map +1 -1
  193. package/build/tabs/Tabs.mjs.map +1 -1
  194. package/build/typeahead/Typeahead.js.map +1 -1
  195. package/build/typeahead/Typeahead.mjs.map +1 -1
  196. package/build/types/accordion/Accordion.d.ts +2 -8
  197. package/build/types/accordion/Accordion.d.ts.map +1 -1
  198. package/build/types/actionButton/ActionButton.d.ts +4 -6
  199. package/build/types/actionButton/ActionButton.d.ts.map +1 -1
  200. package/build/types/actionOption/ActionOption.d.ts +1 -1
  201. package/build/types/alert/Alert.d.ts +2 -5
  202. package/build/types/alert/Alert.d.ts.map +1 -1
  203. package/build/types/avatar/Avatar.d.ts +0 -4
  204. package/build/types/avatar/Avatar.d.ts.map +1 -1
  205. package/build/types/avatarLayout/AvatarLayout.d.ts +1 -5
  206. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  207. package/build/types/badge/Badge.d.ts +0 -2
  208. package/build/types/badge/Badge.d.ts.map +1 -1
  209. package/build/types/body/Body.d.ts +6 -2
  210. package/build/types/body/Body.d.ts.map +1 -1
  211. package/build/types/button/Button.types.d.ts +1 -4
  212. package/build/types/button/Button.types.d.ts.map +1 -1
  213. package/build/types/button/LegacyButton.d.ts +4 -4
  214. package/build/types/card/Card.d.ts +0 -1
  215. package/build/types/card/Card.d.ts.map +1 -1
  216. package/build/types/checkboxButton/CheckboxButton.d.ts +0 -2
  217. package/build/types/checkboxButton/CheckboxButton.d.ts.map +1 -1
  218. package/build/types/checkboxOption/CheckboxOption.d.ts +1 -1
  219. package/build/types/circularButton/CircularButton.d.ts +1 -1
  220. package/build/types/circularButton/CircularButton.d.ts.map +1 -1
  221. package/build/types/common/propsValues/type.d.ts +1 -1
  222. package/build/types/common/propsValues/typography.d.ts +2 -2
  223. package/build/types/criticalBanner/CriticalCommsBanner.d.ts +4 -1
  224. package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
  225. package/build/types/criticalBanner/index.d.ts +1 -0
  226. package/build/types/criticalBanner/index.d.ts.map +1 -1
  227. package/build/types/dateInput/DateInput.d.ts +0 -5
  228. package/build/types/dateInput/DateInput.d.ts.map +1 -1
  229. package/build/types/dimmer/Dimmer.d.ts +0 -6
  230. package/build/types/dimmer/Dimmer.d.ts.map +1 -1
  231. package/build/types/drawer/Drawer.d.ts +2 -8
  232. package/build/types/drawer/Drawer.d.ts.map +1 -1
  233. package/build/types/field/Field.d.ts +2 -5
  234. package/build/types/field/Field.d.ts.map +1 -1
  235. package/build/types/flowNavigation/FlowNavigation.d.ts +0 -3
  236. package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
  237. package/build/types/header/Header.d.ts +1 -5
  238. package/build/types/header/Header.d.ts.map +1 -1
  239. package/build/types/iconButton/IconButton.d.ts +0 -6
  240. package/build/types/iconButton/IconButton.d.ts.map +1 -1
  241. package/build/types/index.d.ts +1 -0
  242. package/build/types/index.d.ts.map +1 -1
  243. package/build/types/inputs/{_BottomSheet.d.ts → SelectInput/BottomSheet/SelectInputBottomSheet.d.ts} +3 -3
  244. package/build/types/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.d.ts.map +1 -0
  245. package/build/types/inputs/SelectInput/BottomSheet/index.d.ts +3 -0
  246. package/build/types/inputs/SelectInput/BottomSheet/index.d.ts.map +1 -0
  247. package/build/types/inputs/SelectInput/ButtonInput/SelectInputButtonInput.d.ts +5 -0
  248. package/build/types/inputs/SelectInput/ButtonInput/SelectInputButtonInput.d.ts.map +1 -0
  249. package/build/types/inputs/SelectInput/ButtonInput/index.d.ts +3 -0
  250. package/build/types/inputs/SelectInput/ButtonInput/index.d.ts.map +1 -0
  251. package/build/types/inputs/SelectInput/ClearButton/SelectInputClearButton.d.ts +7 -0
  252. package/build/types/inputs/SelectInput/ClearButton/SelectInputClearButton.d.ts.map +1 -0
  253. package/build/types/inputs/SelectInput/ClearButton/index.d.ts +3 -0
  254. package/build/types/inputs/SelectInput/ClearButton/index.d.ts.map +1 -0
  255. package/build/types/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.d.ts +16 -0
  256. package/build/types/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.d.ts.map +1 -0
  257. package/build/types/inputs/SelectInput/DefaultRenderTrigger/index.d.ts +2 -0
  258. package/build/types/inputs/SelectInput/DefaultRenderTrigger/index.d.ts.map +1 -0
  259. package/build/types/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.d.ts +9 -0
  260. package/build/types/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.d.ts.map +1 -0
  261. package/build/types/inputs/SelectInput/ItemView/GroupItemView/index.d.ts +3 -0
  262. package/build/types/inputs/SelectInput/ItemView/GroupItemView/index.d.ts.map +1 -0
  263. package/build/types/inputs/SelectInput/ItemView/SelectInputItemView.d.ts +11 -0
  264. package/build/types/inputs/SelectInput/ItemView/SelectInputItemView.d.ts.map +1 -0
  265. package/build/types/inputs/SelectInput/ItemView/index.d.ts +4 -0
  266. package/build/types/inputs/SelectInput/ItemView/index.d.ts.map +1 -0
  267. package/build/types/inputs/SelectInput/Option/SelectInputOption.d.ts +11 -0
  268. package/build/types/inputs/SelectInput/Option/SelectInputOption.d.ts.map +1 -0
  269. package/build/types/inputs/SelectInput/Option/index.d.ts +3 -0
  270. package/build/types/inputs/SelectInput/Option/index.d.ts.map +1 -0
  271. package/build/types/inputs/SelectInput/OptionContent/SelectInputOptionContent.d.ts +13 -0
  272. package/build/types/inputs/SelectInput/OptionContent/SelectInputOptionContent.d.ts.map +1 -0
  273. package/build/types/inputs/SelectInput/OptionContent/index.d.ts +3 -0
  274. package/build/types/inputs/SelectInput/OptionContent/index.d.ts.map +1 -0
  275. package/build/types/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.d.ts +9 -0
  276. package/build/types/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.d.ts.map +1 -0
  277. package/build/types/inputs/SelectInput/Options/OptionsContainer/index.d.ts +3 -0
  278. package/build/types/inputs/SelectInput/Options/OptionsContainer/index.d.ts.map +1 -0
  279. package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts +21 -0
  280. package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts.map +1 -0
  281. package/build/types/inputs/SelectInput/Options/index.d.ts +4 -0
  282. package/build/types/inputs/SelectInput/Options/index.d.ts.map +1 -0
  283. package/build/types/inputs/{_Popover.d.ts → SelectInput/Popover/SelectInputPopover.d.ts} +3 -3
  284. package/build/types/inputs/SelectInput/Popover/SelectInputPopover.d.ts.map +1 -0
  285. package/build/types/inputs/SelectInput/Popover/index.d.ts +3 -0
  286. package/build/types/inputs/SelectInput/Popover/index.d.ts.map +1 -0
  287. package/build/types/inputs/SelectInput/SelectInput.contexts.d.ts +33 -0
  288. package/build/types/inputs/SelectInput/SelectInput.contexts.d.ts.map +1 -0
  289. package/build/types/inputs/SelectInput/SelectInput.d.ts +10 -0
  290. package/build/types/inputs/SelectInput/SelectInput.d.ts.map +1 -0
  291. package/build/types/inputs/SelectInput/SelectInput.messages.d.ts.map +1 -0
  292. package/build/types/inputs/{SelectInput.d.ts → SelectInput/SelectInput.types.d.ts} +12 -38
  293. package/build/types/inputs/SelectInput/SelectInput.types.d.ts.map +1 -0
  294. package/build/types/inputs/SelectInput/SelectInput.utils.d.ts +61 -0
  295. package/build/types/inputs/SelectInput/SelectInput.utils.d.ts.map +1 -0
  296. package/build/types/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts +12 -0
  297. package/build/types/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts.map +1 -0
  298. package/build/types/inputs/SelectInput/TriggerButton/index.d.ts +3 -0
  299. package/build/types/inputs/SelectInput/TriggerButton/index.d.ts.map +1 -0
  300. package/build/types/inputs/SelectInput/components.d.ts +10 -0
  301. package/build/types/inputs/SelectInput/components.d.ts.map +1 -0
  302. package/build/types/inputs/SelectInput/index.d.ts +12 -0
  303. package/build/types/inputs/SelectInput/index.d.ts.map +1 -0
  304. package/build/types/legacylistItem/LegacyListItem.d.ts +1 -1
  305. package/build/types/list/List.d.ts +0 -1
  306. package/build/types/list/List.d.ts.map +1 -1
  307. package/build/types/listItem/Button/ListItemButton.d.ts +0 -4
  308. package/build/types/listItem/Button/ListItemButton.d.ts.map +1 -1
  309. package/build/types/listItem/IconButton/ListItemIconButton.d.ts +1 -3
  310. package/build/types/listItem/IconButton/ListItemIconButton.d.ts.map +1 -1
  311. package/build/types/listItem/Image/ListItemImage.d.ts +0 -2
  312. package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -1
  313. package/build/types/listItem/ListItem.d.ts +0 -3
  314. package/build/types/listItem/ListItem.d.ts.map +1 -1
  315. package/build/types/loader/Loader.d.ts +1 -5
  316. package/build/types/loader/Loader.d.ts.map +1 -1
  317. package/build/types/logo/Logo.d.ts +1 -4
  318. package/build/types/logo/Logo.d.ts.map +1 -1
  319. package/build/types/modal/Modal.d.ts +0 -6
  320. package/build/types/modal/Modal.d.ts.map +1 -1
  321. package/build/types/navigationOption/NavigationOption.d.ts +1 -1
  322. package/build/types/navigationOptionsList/NavigationOptionsList.d.ts +1 -1
  323. package/build/types/nudge/Nudge.d.ts +1 -1
  324. package/build/types/nudge/Nudge.d.ts.map +1 -1
  325. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +1 -7
  326. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  327. package/build/types/popover/Popover.d.ts +0 -1
  328. package/build/types/popover/Popover.d.ts.map +1 -1
  329. package/build/types/processIndicator/ProcessIndicator.d.ts +0 -2
  330. package/build/types/processIndicator/ProcessIndicator.d.ts.map +1 -1
  331. package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +1 -8
  332. package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
  333. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +0 -1
  334. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
  335. package/build/types/radioOption/RadioOption.d.ts +1 -1
  336. package/build/types/select/Select.d.ts +0 -4
  337. package/build/types/select/Select.d.ts.map +1 -1
  338. package/build/types/statusIcon/StatusIcon.d.ts +1 -3
  339. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  340. package/build/types/summary/Summary.d.ts +4 -7
  341. package/build/types/summary/Summary.d.ts.map +1 -1
  342. package/build/types/switchOption/SwitchOption.d.ts +1 -1
  343. package/build/types/tabs/Tabs.d.ts +0 -2
  344. package/build/types/tabs/Tabs.d.ts.map +1 -1
  345. package/build/types/typeahead/Typeahead.d.ts +1 -14
  346. package/build/types/typeahead/Typeahead.d.ts.map +1 -1
  347. package/build/types/upload/Upload.d.ts +0 -6
  348. package/build/types/upload/Upload.d.ts.map +1 -1
  349. package/build/types/uploadInput/UploadInput.d.ts +1 -10
  350. package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
  351. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts +0 -3
  352. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
  353. package/build/upload/Upload.js.map +1 -1
  354. package/build/upload/Upload.mjs.map +1 -1
  355. package/build/uploadInput/UploadInput.js.map +1 -1
  356. package/build/uploadInput/UploadInput.mjs.map +1 -1
  357. package/build/withDisplayFormat/WithDisplayFormat.js.map +1 -1
  358. package/build/withDisplayFormat/WithDisplayFormat.mjs.map +1 -1
  359. package/package.json +1 -1
  360. package/src/accordion/Accordion.tsx +2 -8
  361. package/src/actionButton/ActionButton.tsx +3 -4
  362. package/src/actionOption/ActionOption.tsx +1 -1
  363. package/src/alert/Alert.tsx +2 -5
  364. package/src/avatar/Avatar.tsx +0 -4
  365. package/src/avatarLayout/AvatarLayout.tsx +1 -5
  366. package/src/badge/Badge.tsx +0 -2
  367. package/src/body/Body.tsx +6 -2
  368. package/src/button/Button.types.ts +1 -4
  369. package/src/button/LegacyButton.tsx +4 -4
  370. package/src/card/Card.tsx +0 -1
  371. package/src/checkboxButton/CheckboxButton.tsx +0 -1
  372. package/src/checkboxOption/CheckboxOption.tsx +1 -1
  373. package/src/circularButton/CircularButton.tsx +2 -1
  374. package/src/common/propsValues/type.ts +1 -1
  375. package/src/common/propsValues/typography.ts +2 -2
  376. package/src/criticalBanner/CriticalCommsBanner.css +33 -15
  377. package/src/criticalBanner/CriticalCommsBanner.less +46 -36
  378. package/src/criticalBanner/CriticalCommsBanner.story.tsx +9 -15
  379. package/src/criticalBanner/CriticalCommsBanner.test.story.tsx +70 -0
  380. package/src/criticalBanner/CriticalCommsBanner.test.tsx +66 -0
  381. package/src/criticalBanner/CriticalCommsBanner.tsx +54 -5
  382. package/src/criticalBanner/index.ts +1 -0
  383. package/src/dateInput/DateInput.tsx +0 -5
  384. package/src/dimmer/Dimmer.tsx +0 -6
  385. package/src/drawer/Drawer.tsx +2 -8
  386. package/src/field/Field.tsx +2 -5
  387. package/src/flowNavigation/FlowNavigation.tsx +0 -3
  388. package/src/header/Header.tsx +1 -5
  389. package/src/iconButton/IconButton.tsx +0 -3
  390. package/src/index.ts +1 -0
  391. package/src/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.css +96 -0
  392. package/src/inputs/{_BottomSheet.tsx → SelectInput/BottomSheet/SelectInputBottomSheet.tsx} +7 -7
  393. package/src/inputs/SelectInput/BottomSheet/index.ts +2 -0
  394. package/src/inputs/SelectInput/ButtonInput/SelectInputButtonInput.css +16 -0
  395. package/src/inputs/{_ButtonInput.tsx → SelectInput/ButtonInput/SelectInputButtonInput.tsx} +5 -5
  396. package/src/inputs/SelectInput/ButtonInput/index.ts +2 -0
  397. package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.css +46 -0
  398. package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.less +40 -0
  399. package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.tsx +29 -0
  400. package/src/inputs/SelectInput/ClearButton/index.ts +2 -0
  401. package/src/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.tsx +74 -0
  402. package/src/inputs/SelectInput/DefaultRenderTrigger/index.ts +5 -0
  403. package/src/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.tsx +61 -0
  404. package/src/inputs/SelectInput/ItemView/GroupItemView/index.ts +2 -0
  405. package/src/inputs/SelectInput/ItemView/SelectInputItemView.css +16 -0
  406. package/src/inputs/SelectInput/ItemView/SelectInputItemView.less +17 -0
  407. package/src/inputs/SelectInput/ItemView/SelectInputItemView.tsx +48 -0
  408. package/src/inputs/SelectInput/ItemView/index.ts +3 -0
  409. package/src/inputs/SelectInput/Option/SelectInputOption.css +33 -0
  410. package/src/inputs/SelectInput/Option/SelectInputOption.less +32 -0
  411. package/src/inputs/SelectInput/Option/SelectInputOption.tsx +57 -0
  412. package/src/inputs/SelectInput/Option/index.ts +2 -0
  413. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.css +37 -0
  414. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.less +38 -0
  415. package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.tsx +72 -0
  416. package/src/inputs/SelectInput/OptionContent/index.ts +2 -0
  417. package/src/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.tsx +59 -0
  418. package/src/inputs/SelectInput/Options/OptionsContainer/index.ts +2 -0
  419. package/src/inputs/SelectInput/Options/SelectInputOptions.css +81 -0
  420. package/src/inputs/SelectInput/Options/SelectInputOptions.less +77 -0
  421. package/src/inputs/SelectInput/Options/SelectInputOptions.tsx +411 -0
  422. package/src/inputs/SelectInput/Options/index.ts +3 -0
  423. package/src/inputs/SelectInput/Popover/SelectInputPopover.css +46 -0
  424. package/src/inputs/{_Popover.tsx → SelectInput/Popover/SelectInputPopover.tsx} +7 -7
  425. package/src/inputs/SelectInput/Popover/index.ts +2 -0
  426. package/src/inputs/SelectInput/SelectInput.contexts.tsx +40 -0
  427. package/src/inputs/SelectInput/SelectInput.less +22 -0
  428. package/src/inputs/{SelectInput.test.tsx → SelectInput/SelectInput.test.tsx} +9 -11
  429. package/src/inputs/SelectInput/SelectInput.tsx +257 -0
  430. package/src/inputs/SelectInput/SelectInput.types.ts +113 -0
  431. package/src/inputs/SelectInput/SelectInput.utils.ts +206 -0
  432. package/src/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx +36 -0
  433. package/src/inputs/SelectInput/TriggerButton/index.ts +5 -0
  434. package/src/inputs/{SelectInput.docs.mdx → SelectInput/_stories/SelectInput.docs.mdx} +0 -1
  435. package/src/inputs/{SelectInput.story.tsx → SelectInput/_stories/SelectInput.story.tsx} +11 -8
  436. package/src/inputs/{SelectInput.test.story.tsx → SelectInput/_stories/SelectInput.test.story.tsx} +5 -10
  437. package/src/inputs/SelectInput/components.ts +10 -0
  438. package/src/inputs/SelectInput/index.ts +14 -0
  439. package/src/legacylistItem/LegacyListItem.tsx +1 -1
  440. package/src/list/List.tsx +0 -1
  441. package/src/listItem/Button/ListItemButton.tsx +0 -2
  442. package/src/listItem/IconButton/ListItemIconButton.tsx +1 -3
  443. package/src/listItem/Image/ListItemImage.tsx +0 -2
  444. package/src/listItem/ListItem.tsx +0 -2
  445. package/src/loader/Loader.tsx +2 -6
  446. package/src/logo/Logo.tsx +1 -4
  447. package/src/main.css +123 -105
  448. package/src/main.less +1 -1
  449. package/src/modal/Modal.tsx +0 -6
  450. package/src/navigationOption/NavigationOption.tsx +1 -1
  451. package/src/navigationOptionsList/NavigationOptionsList.tsx +1 -1
  452. package/src/nudge/Nudge.tsx +1 -1
  453. package/src/phoneNumberInput/PhoneNumberInput.tsx +1 -7
  454. package/src/popover/Popover.tsx +0 -1
  455. package/src/processIndicator/ProcessIndicator.tsx +0 -2
  456. package/src/prompt/ActionPrompt/ActionPrompt.tsx +1 -8
  457. package/src/prompt/InlinePrompt/InlinePrompt.tsx +0 -1
  458. package/src/radioOption/RadioOption.tsx +1 -1
  459. package/src/select/Select.tsx +0 -4
  460. package/src/statusIcon/StatusIcon.tsx +1 -3
  461. package/src/summary/Summary.tsx +4 -7
  462. package/src/switchOption/SwitchOption.tsx +1 -1
  463. package/src/tabs/Tabs.tsx +0 -2
  464. package/src/typeahead/Typeahead.tsx +2 -14
  465. package/src/upload/Upload.tsx +0 -6
  466. package/src/uploadInput/UploadInput.tsx +4 -12
  467. package/src/withDisplayFormat/WithDisplayFormat.tsx +0 -3
  468. package/build/inputs/SelectInput.js +0 -890
  469. package/build/inputs/SelectInput.js.map +0 -1
  470. package/build/inputs/SelectInput.messages.js.map +0 -1
  471. package/build/inputs/SelectInput.messages.mjs.map +0 -1
  472. package/build/inputs/SelectInput.mjs +0 -881
  473. package/build/inputs/SelectInput.mjs.map +0 -1
  474. package/build/inputs/_BottomSheet.js.map +0 -1
  475. package/build/inputs/_BottomSheet.mjs.map +0 -1
  476. package/build/inputs/_ButtonInput.js.map +0 -1
  477. package/build/inputs/_ButtonInput.mjs.map +0 -1
  478. package/build/inputs/_Popover.js.map +0 -1
  479. package/build/inputs/_Popover.mjs.map +0 -1
  480. package/build/types/inputs/SelectInput.d.ts.map +0 -1
  481. package/build/types/inputs/SelectInput.messages.d.ts.map +0 -1
  482. package/build/types/inputs/_BottomSheet.d.ts.map +0 -1
  483. package/build/types/inputs/_ButtonInput.d.ts +0 -5
  484. package/build/types/inputs/_ButtonInput.d.ts.map +0 -1
  485. package/build/types/inputs/_Popover.d.ts.map +0 -1
  486. package/src/inputs/SelectInput.less +0 -219
  487. package/src/inputs/SelectInput.tsx +0 -1269
  488. package/build/inputs/{SelectInput.messages.js → SelectInput/SelectInput.messages.js} +0 -0
  489. package/build/inputs/{SelectInput.messages.mjs → SelectInput/SelectInput.messages.mjs} +0 -0
  490. package/build/styles/inputs/{SelectInput.css → SelectInput/SelectInput.css} +90 -90
  491. package/build/types/inputs/{SelectInput.messages.d.ts → SelectInput/SelectInput.messages.d.ts} +0 -0
  492. package/src/inputs/{_BottomSheet.less → SelectInput/BottomSheet/SelectInputBottomSheet.less} +0 -0
  493. package/src/inputs/{_ButtonInput.less → SelectInput/ButtonInput/SelectInputButtonInput.less} +0 -0
  494. package/src/inputs/{_Popover.less → SelectInput/Popover/SelectInputPopover.less} +0 -0
  495. package/src/inputs/{SelectInput.css → SelectInput/SelectInput.css} +90 -90
  496. /package/src/inputs/{SelectInput.messages.ts → SelectInput/SelectInput.messages.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"WithDisplayFormat.mjs","sources":["../../src/withDisplayFormat/WithDisplayFormat.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { HistoryNavigator } from '../common';\nimport {\n formatWithPattern,\n getCountOfSymbolsInSelection,\n getCursorPositionAfterKeystroke,\n unformatWithPattern,\n getDistanceToPreviousSymbol,\n getDistanceToNextSymbol,\n} from '../common/textFormat';\nimport { InputProps } from '../inputs/Input';\nimport { TextAreaProps } from '../inputs/TextArea';\n\ntype HTMLTextElement = HTMLInputElement | HTMLTextAreaElement;\ntype TextElementProps = InputProps | TextAreaProps;\n\nexport type EventType =\n | 'KeyDown'\n | 'Paste'\n | 'Cut'\n | 'Undo'\n | 'Redo'\n | 'Backspace'\n | 'Delete'\n | 'Initial';\n\ninterface WithDisplayFormatState {\n value: string;\n historyNavigator: HistoryNavigator;\n prevDisplayPattern: string;\n triggerType: EventType;\n triggerEvent: React.KeyboardEvent<HTMLTextElement> | null;\n pastedLength: number;\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface WithDisplayFormatProps<T extends TextElementProps = TextElementProps> extends Pick<\n TextElementProps,\n | 'className'\n | 'disabled'\n | 'id'\n | 'maxLength'\n | 'minLength'\n | 'name'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'inputMode'\n> {\n /** @default '' */\n value?: string;\n /** @default '' */\n displayPattern: string;\n /**\n * autocomplete hides our form help so we need to disable it when help text\n * is present. Chrome ignores autocomplete=off, the only way to disable it is\n * to provide an 'invalid' value, for which 'disabled' serves.\n * @default 'off'\n */\n autoComplete?: TextElementProps['autoComplete'] | 'disabled';\n onChange?: (value: string) => void;\n onBlur?: (value: string) => void;\n onFocus?: (value: string) => void;\n render: (renderProps: T) => React.JSX.Element;\n}\n\nclass WithDisplayFormat<T extends TextElementProps> extends React.Component<\n WithDisplayFormatProps<T>,\n WithDisplayFormatState\n> {\n declare props: WithDisplayFormatProps<T> &\n Required<Pick<WithDisplayFormatProps<T>, keyof typeof WithDisplayFormat.defaultProps>>;\n static defaultProps = {\n autoComplete: 'off',\n displayPattern: '',\n value: '',\n };\n\n constructor(props: WithDisplayFormatProps) {\n super(props);\n const unformattedValue = unformatWithPattern(props.value ?? '', props.displayPattern);\n this.state = {\n value: formatWithPattern(unformattedValue, props.displayPattern),\n historyNavigator: new HistoryNavigator(),\n prevDisplayPattern: props.displayPattern,\n triggerType: 'Initial',\n triggerEvent: null,\n selectionStart: 0,\n selectionEnd: 0,\n pastedLength: 0,\n };\n }\n\n static getDerivedStateFromProps(\n { displayPattern }: WithDisplayFormatProps,\n { prevDisplayPattern = displayPattern, value, historyNavigator }: WithDisplayFormatState,\n ) {\n if (prevDisplayPattern !== displayPattern) {\n const unFormattedValue = unformatWithPattern(value, prevDisplayPattern);\n historyNavigator.reset();\n\n return {\n prevDisplayPattern: displayPattern,\n value: formatWithPattern(unFormattedValue, displayPattern),\n triggerType: null,\n triggerEvent: null,\n pastedLength: 0,\n };\n }\n return null;\n }\n\n getUserAction = (unformattedValue: string): EventType | string => {\n const { triggerEvent, triggerType, value } = this.state;\n const { displayPattern } = this.props;\n\n if (triggerEvent) {\n if (triggerType === 'Paste' || triggerType === 'Cut') {\n return triggerType;\n }\n\n if ((triggerEvent.ctrlKey || triggerEvent.metaKey) && triggerEvent.key === 'z') {\n return triggerEvent.shiftKey ? 'Redo' : 'Undo';\n }\n\n // Detect mouse event redo\n if (triggerEvent.ctrlKey && triggerEvent.key === 'd') {\n return 'Delete';\n }\n\n // Android Fix.\n if (\n typeof triggerEvent.key === 'undefined' &&\n unformattedValue.length <= unformatWithPattern(value, displayPattern).length\n ) {\n return 'Backspace';\n }\n return triggerEvent.key;\n }\n // triggerEvent can be null only in case of \"autofilling\" (via password manager extension or browser build-in one) events\n return 'Paste';\n };\n\n resetEvent = () => {\n this.setState({\n triggerType: 'Initial',\n triggerEvent: null,\n pastedLength: 0,\n });\n };\n\n detectUndoRedo = (event: React.KeyboardEvent<HTMLTextElement>) => {\n if ((event.ctrlKey || event.metaKey) && event.key === 'z') {\n return event.shiftKey ? 'Redo' : 'Undo';\n }\n return null;\n };\n\n handleOnKeyDown: React.KeyboardEventHandler<HTMLTextElement> = (event) => {\n event.persist();\n const { selectionStart, selectionEnd } = event.currentTarget;\n const { historyNavigator } = this.state;\n const { displayPattern } = this.props;\n\n // Unfortunately Undo and Redo don't trigger OnChange event so we need to handle some value logic here.\n let newFormattedValue = '';\n\n if (this.detectUndoRedo(event) === 'Undo') {\n newFormattedValue = formatWithPattern(historyNavigator.undo().toString(), displayPattern);\n this.setState({ value: newFormattedValue, triggerType: 'Undo' });\n } else if (this.detectUndoRedo(event) === 'Redo') {\n newFormattedValue = formatWithPattern(historyNavigator.redo().toString(), displayPattern);\n this.setState({ value: newFormattedValue, triggerType: 'Redo' });\n } else {\n this.setState({\n triggerEvent: event,\n triggerType: 'KeyDown',\n selectionStart: selectionStart ?? 0,\n selectionEnd: selectionEnd ?? 0,\n });\n }\n };\n\n handleOnPaste: React.ClipboardEventHandler<HTMLTextElement> = (event) => {\n const { displayPattern } = this.props;\n const pastedLength = unformatWithPattern(\n event.clipboardData.getData('Text'),\n displayPattern,\n ).length;\n\n this.setState({ triggerType: 'Paste', pastedLength });\n };\n\n handleOnCut: React.ClipboardEventHandler<HTMLTextElement> = () => {\n this.setState({ triggerType: 'Cut' });\n };\n\n isKeyAllowed = (action: EventType | string) => {\n const { displayPattern } = this.props;\n const symbolsInPattern = displayPattern.split('').filter((character) => character !== '*');\n\n return !symbolsInPattern.includes(action);\n };\n\n handleOnChange: React.ChangeEventHandler<HTMLTextElement> = (event) => {\n const { historyNavigator, triggerType } = this.state;\n const { displayPattern, onChange } = this.props;\n const { value } = event.target;\n let unformattedValue = unformatWithPattern(value, displayPattern);\n const action = this.getUserAction(unformattedValue);\n if (!this.isKeyAllowed(action) || triggerType === 'Undo' || triggerType === 'Redo') {\n return;\n }\n\n if (action === 'Backspace' || action === 'Delete') {\n unformattedValue = this.handleDelete(unformattedValue, action);\n }\n\n const newFormattedValue = formatWithPattern(unformattedValue, displayPattern);\n historyNavigator.add(unformattedValue);\n\n this.handleCursorPositioning(action);\n\n this.setState({ value: newFormattedValue }, () => {\n this.resetEvent();\n if (onChange) {\n const broadcastValue = unformatWithPattern(newFormattedValue, displayPattern);\n onChange(broadcastValue);\n }\n });\n };\n\n handleOnBlur: React.FocusEventHandler<HTMLTextElement> = (event) => {\n this.props.onBlur?.(unformatWithPattern(event.target.value, this.props.displayPattern));\n };\n\n handleOnFocus: React.FocusEventHandler<HTMLTextElement> = (event) => {\n const { displayPattern, onFocus } = this.props;\n if (onFocus) {\n onFocus(unformatWithPattern(event.target.value, displayPattern));\n }\n };\n\n handleDelete = (unformattedValue: string, action: EventType) => {\n const { displayPattern } = this.props;\n const { selectionStart, selectionEnd } = this.state;\n const newStack = [...unformattedValue];\n if (selectionStart === selectionEnd) {\n let startPosition =\n selectionStart - getCountOfSymbolsInSelection(0, selectionStart, displayPattern);\n let toDelete = 0;\n\n let count = getDistanceToNextSymbol(selectionStart, displayPattern);\n if (action === 'Backspace') {\n startPosition -= 1;\n count = getDistanceToPreviousSymbol(selectionStart, displayPattern);\n }\n\n if (startPosition >= 0 && count) {\n toDelete = 1;\n }\n\n newStack.splice(startPosition, toDelete);\n }\n\n return newStack.join('');\n };\n\n handleCursorPositioning = (action: string) => {\n const { displayPattern } = this.props;\n const { triggerEvent, selectionStart, selectionEnd, pastedLength } = this.state;\n\n const cursorPosition = getCursorPositionAfterKeystroke(\n action,\n selectionStart,\n selectionEnd,\n displayPattern,\n pastedLength,\n );\n\n setTimeout(() => {\n if (triggerEvent) {\n (triggerEvent.target as HTMLTextElement).setSelectionRange(cursorPosition, cursorPosition);\n }\n this.setState({ selectionStart: cursorPosition, selectionEnd: cursorPosition });\n }, 0);\n };\n\n render() {\n const {\n inputMode,\n className,\n id,\n name,\n placeholder,\n readOnly,\n required,\n minLength,\n maxLength,\n disabled,\n autoComplete,\n } = this.props;\n const { value } = this.state;\n const renderProps: TextElementProps = {\n inputMode,\n className,\n id,\n name,\n placeholder,\n readOnly,\n required,\n minLength,\n maxLength,\n disabled,\n autoComplete,\n value,\n onFocus: this.handleOnFocus,\n onBlur: this.handleOnBlur,\n onPaste: this.handleOnPaste,\n onKeyDown: this.handleOnKeyDown,\n onChange: this.handleOnChange,\n onCut: this.handleOnCut,\n };\n return this.props.render(renderProps as T);\n }\n}\n\nexport default WithDisplayFormat;\n"],"names":["WithDisplayFormat","React","Component","defaultProps","autoComplete","displayPattern","value","constructor","props","unformattedValue","unformatWithPattern","state","formatWithPattern","historyNavigator","HistoryNavigator","prevDisplayPattern","triggerType","triggerEvent","selectionStart","selectionEnd","pastedLength","getDerivedStateFromProps","unFormattedValue","reset","getUserAction","ctrlKey","metaKey","key","shiftKey","length","resetEvent","setState","detectUndoRedo","event","handleOnKeyDown","persist","currentTarget","newFormattedValue","undo","toString","redo","handleOnPaste","clipboardData","getData","handleOnCut","isKeyAllowed","action","symbolsInPattern","split","filter","character","includes","handleOnChange","onChange","target","handleDelete","add","handleCursorPositioning","broadcastValue","handleOnBlur","onBlur","handleOnFocus","onFocus","newStack","startPosition","getCountOfSymbolsInSelection","toDelete","count","getDistanceToNextSymbol","getDistanceToPreviousSymbol","splice","join","cursorPosition","getCursorPositionAfterKeystroke","setTimeout","setSelectionRange","render","inputMode","className","id","name","placeholder","readOnly","required","minLength","maxLength","disabled","renderProps","onPaste","onKeyDown","onCut"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAMA,iBAA8C,SAAQC,KAAK,CAACC,SAGjE,CAAA;AAGC,EAAA,OAAOC,YAAY,GAAG;AACpBC,IAAAA,YAAY,EAAE,KAAK;AACnBC,IAAAA,cAAc,EAAE,EAAE;AAClBC,IAAAA,KAAK,EAAE;GACR;EAEDC,WAAAA,CAAYC,KAA6B,EAAA;IACvC,KAAK,CAACA,KAAK,CAAC;AACZ,IAAA,MAAMC,gBAAgB,GAAGC,mBAAmB,CAACF,KAAK,CAACF,KAAK,IAAI,EAAE,EAAEE,KAAK,CAACH,cAAc,CAAC;IACrF,IAAI,CAACM,KAAK,GAAG;MACXL,KAAK,EAAEM,iBAAiB,CAACH,gBAAgB,EAAED,KAAK,CAACH,cAAc,CAAC;AAChEQ,MAAAA,gBAAgB,EAAE,IAAIC,gBAAgB,EAAE;MACxCC,kBAAkB,EAAEP,KAAK,CAACH,cAAc;AACxCW,MAAAA,WAAW,EAAE,SAAS;AACtBC,MAAAA,YAAY,EAAE,IAAI;AAClBC,MAAAA,cAAc,EAAE,CAAC;AACjBC,MAAAA,YAAY,EAAE,CAAC;AACfC,MAAAA,YAAY,EAAE;KACf;AACH,EAAA;AAEA,EAAA,OAAOC,wBAAwBA,CAC7B;AAAEhB,IAAAA;AAAc,GAA0B,EAC1C;AAAEU,IAAAA,kBAAkB,GAAGV,cAAc;IAAEC,KAAK;AAAEO,IAAAA;AAAgB,GAA0B,EAAA;IAExF,IAAIE,kBAAkB,KAAKV,cAAc,EAAE;AACzC,MAAA,MAAMiB,gBAAgB,GAA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EAAE,IAAI,CAAC9C;KACb;AACD,IAAA,OAAO,IAAI,CAACpC,KAAK,CAACoE,MAAM,CAACW,WAAgB,CAAC;AAC5C,EAAA;;;;;"}
1
+ {"version":3,"file":"WithDisplayFormat.mjs","sources":["../../src/withDisplayFormat/WithDisplayFormat.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { HistoryNavigator } from '../common';\nimport {\n formatWithPattern,\n getCountOfSymbolsInSelection,\n getCursorPositionAfterKeystroke,\n unformatWithPattern,\n getDistanceToPreviousSymbol,\n getDistanceToNextSymbol,\n} from '../common/textFormat';\nimport { InputProps } from '../inputs/Input';\nimport { TextAreaProps } from '../inputs/TextArea';\n\ntype HTMLTextElement = HTMLInputElement | HTMLTextAreaElement;\ntype TextElementProps = InputProps | TextAreaProps;\n\nexport type EventType =\n | 'KeyDown'\n | 'Paste'\n | 'Cut'\n | 'Undo'\n | 'Redo'\n | 'Backspace'\n | 'Delete'\n | 'Initial';\n\ninterface WithDisplayFormatState {\n value: string;\n historyNavigator: HistoryNavigator;\n prevDisplayPattern: string;\n triggerType: EventType;\n triggerEvent: React.KeyboardEvent<HTMLTextElement> | null;\n pastedLength: number;\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface WithDisplayFormatProps<T extends TextElementProps = TextElementProps> extends Pick<\n TextElementProps,\n | 'className'\n | 'disabled'\n | 'id'\n | 'maxLength'\n | 'minLength'\n | 'name'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'inputMode'\n> {\n value?: string;\n displayPattern: string;\n /**\n * autocomplete hides our form help so we need to disable it when help text\n * is present. Chrome ignores autocomplete=off, the only way to disable it is\n * to provide an 'invalid' value, for which 'disabled' serves.\n */\n autoComplete?: TextElementProps['autoComplete'] | 'disabled';\n onChange?: (value: string) => void;\n onBlur?: (value: string) => void;\n onFocus?: (value: string) => void;\n render: (renderProps: T) => React.JSX.Element;\n}\n\nclass WithDisplayFormat<T extends TextElementProps> extends React.Component<\n WithDisplayFormatProps<T>,\n WithDisplayFormatState\n> {\n declare props: WithDisplayFormatProps<T> &\n Required<Pick<WithDisplayFormatProps<T>, keyof typeof WithDisplayFormat.defaultProps>>;\n static defaultProps = {\n autoComplete: 'off',\n displayPattern: '',\n value: '',\n };\n\n constructor(props: WithDisplayFormatProps) {\n super(props);\n const unformattedValue = unformatWithPattern(props.value ?? '', props.displayPattern);\n this.state = {\n value: formatWithPattern(unformattedValue, props.displayPattern),\n historyNavigator: new HistoryNavigator(),\n prevDisplayPattern: props.displayPattern,\n triggerType: 'Initial',\n triggerEvent: null,\n selectionStart: 0,\n selectionEnd: 0,\n pastedLength: 0,\n };\n }\n\n static getDerivedStateFromProps(\n { displayPattern }: WithDisplayFormatProps,\n { prevDisplayPattern = displayPattern, value, historyNavigator }: WithDisplayFormatState,\n ) {\n if (prevDisplayPattern !== displayPattern) {\n const unFormattedValue = unformatWithPattern(value, prevDisplayPattern);\n historyNavigator.reset();\n\n return {\n prevDisplayPattern: displayPattern,\n value: formatWithPattern(unFormattedValue, displayPattern),\n triggerType: null,\n triggerEvent: null,\n pastedLength: 0,\n };\n }\n return null;\n }\n\n getUserAction = (unformattedValue: string): EventType | string => {\n const { triggerEvent, triggerType, value } = this.state;\n const { displayPattern } = this.props;\n\n if (triggerEvent) {\n if (triggerType === 'Paste' || triggerType === 'Cut') {\n return triggerType;\n }\n\n if ((triggerEvent.ctrlKey || triggerEvent.metaKey) && triggerEvent.key === 'z') {\n return triggerEvent.shiftKey ? 'Redo' : 'Undo';\n }\n\n // Detect mouse event redo\n if (triggerEvent.ctrlKey && triggerEvent.key === 'd') {\n return 'Delete';\n }\n\n // Android Fix.\n if (\n typeof triggerEvent.key === 'undefined' &&\n unformattedValue.length <= unformatWithPattern(value, displayPattern).length\n ) {\n return 'Backspace';\n }\n return triggerEvent.key;\n }\n // triggerEvent can be null only in case of \"autofilling\" (via password manager extension or browser build-in one) events\n return 'Paste';\n };\n\n resetEvent = () => {\n this.setState({\n triggerType: 'Initial',\n triggerEvent: null,\n pastedLength: 0,\n });\n };\n\n detectUndoRedo = (event: React.KeyboardEvent<HTMLTextElement>) => {\n if ((event.ctrlKey || event.metaKey) && event.key === 'z') {\n return event.shiftKey ? 'Redo' : 'Undo';\n }\n return null;\n };\n\n handleOnKeyDown: React.KeyboardEventHandler<HTMLTextElement> = (event) => {\n event.persist();\n const { selectionStart, selectionEnd } = event.currentTarget;\n const { historyNavigator } = this.state;\n const { displayPattern } = this.props;\n\n // Unfortunately Undo and Redo don't trigger OnChange event so we need to handle some value logic here.\n let newFormattedValue = '';\n\n if (this.detectUndoRedo(event) === 'Undo') {\n newFormattedValue = formatWithPattern(historyNavigator.undo().toString(), displayPattern);\n this.setState({ value: newFormattedValue, triggerType: 'Undo' });\n } else if (this.detectUndoRedo(event) === 'Redo') {\n newFormattedValue = formatWithPattern(historyNavigator.redo().toString(), displayPattern);\n this.setState({ value: newFormattedValue, triggerType: 'Redo' });\n } else {\n this.setState({\n triggerEvent: event,\n triggerType: 'KeyDown',\n selectionStart: selectionStart ?? 0,\n selectionEnd: selectionEnd ?? 0,\n });\n }\n };\n\n handleOnPaste: React.ClipboardEventHandler<HTMLTextElement> = (event) => {\n const { displayPattern } = this.props;\n const pastedLength = unformatWithPattern(\n event.clipboardData.getData('Text'),\n displayPattern,\n ).length;\n\n this.setState({ triggerType: 'Paste', pastedLength });\n };\n\n handleOnCut: React.ClipboardEventHandler<HTMLTextElement> = () => {\n this.setState({ triggerType: 'Cut' });\n };\n\n isKeyAllowed = (action: EventType | string) => {\n const { displayPattern } = this.props;\n const symbolsInPattern = displayPattern.split('').filter((character) => character !== '*');\n\n return !symbolsInPattern.includes(action);\n };\n\n handleOnChange: React.ChangeEventHandler<HTMLTextElement> = (event) => {\n const { historyNavigator, triggerType } = this.state;\n const { displayPattern, onChange } = this.props;\n const { value } = event.target;\n let unformattedValue = unformatWithPattern(value, displayPattern);\n const action = this.getUserAction(unformattedValue);\n if (!this.isKeyAllowed(action) || triggerType === 'Undo' || triggerType === 'Redo') {\n return;\n }\n\n if (action === 'Backspace' || action === 'Delete') {\n unformattedValue = this.handleDelete(unformattedValue, action);\n }\n\n const newFormattedValue = formatWithPattern(unformattedValue, displayPattern);\n historyNavigator.add(unformattedValue);\n\n this.handleCursorPositioning(action);\n\n this.setState({ value: newFormattedValue }, () => {\n this.resetEvent();\n if (onChange) {\n const broadcastValue = unformatWithPattern(newFormattedValue, displayPattern);\n onChange(broadcastValue);\n }\n });\n };\n\n handleOnBlur: React.FocusEventHandler<HTMLTextElement> = (event) => {\n this.props.onBlur?.(unformatWithPattern(event.target.value, this.props.displayPattern));\n };\n\n handleOnFocus: React.FocusEventHandler<HTMLTextElement> = (event) => {\n const { displayPattern, onFocus } = this.props;\n if (onFocus) {\n onFocus(unformatWithPattern(event.target.value, displayPattern));\n }\n };\n\n handleDelete = (unformattedValue: string, action: EventType) => {\n const { displayPattern } = this.props;\n const { selectionStart, selectionEnd } = this.state;\n const newStack = [...unformattedValue];\n if (selectionStart === selectionEnd) {\n let startPosition =\n selectionStart - getCountOfSymbolsInSelection(0, selectionStart, displayPattern);\n let toDelete = 0;\n\n let count = getDistanceToNextSymbol(selectionStart, displayPattern);\n if (action === 'Backspace') {\n startPosition -= 1;\n count = getDistanceToPreviousSymbol(selectionStart, displayPattern);\n }\n\n if (startPosition >= 0 && count) {\n toDelete = 1;\n }\n\n newStack.splice(startPosition, toDelete);\n }\n\n return newStack.join('');\n };\n\n handleCursorPositioning = (action: string) => {\n const { displayPattern } = this.props;\n const { triggerEvent, selectionStart, selectionEnd, pastedLength } = this.state;\n\n const cursorPosition = getCursorPositionAfterKeystroke(\n action,\n selectionStart,\n selectionEnd,\n displayPattern,\n pastedLength,\n );\n\n setTimeout(() => {\n if (triggerEvent) {\n (triggerEvent.target as HTMLTextElement).setSelectionRange(cursorPosition, cursorPosition);\n }\n this.setState({ selectionStart: cursorPosition, selectionEnd: cursorPosition });\n }, 0);\n };\n\n render() {\n const {\n inputMode,\n className,\n id,\n name,\n placeholder,\n readOnly,\n required,\n minLength,\n maxLength,\n disabled,\n autoComplete,\n } = this.props;\n const { value } = this.state;\n const renderProps: TextElementProps = {\n inputMode,\n className,\n id,\n name,\n placeholder,\n readOnly,\n required,\n minLength,\n maxLength,\n disabled,\n autoComplete,\n value,\n onFocus: this.handleOnFocus,\n onBlur: this.handleOnBlur,\n onPaste: this.handleOnPaste,\n onKeyDown: this.handleOnKeyDown,\n onChange: this.handleOnChange,\n onCut: this.handleOnCut,\n };\n return this.props.render(renderProps as T);\n }\n}\n\nexport default WithDisplayFormat;\n"],"names":["WithDisplayFormat","React","Component","defaultProps","autoComplete","displayPattern","value","constructor","props","unformattedValue","unformatWithPattern","state","formatWithPattern","historyNavigator","HistoryNavigator","prevDisplayPattern","triggerType","triggerEvent","selectionStart","selectionEnd","pastedLength","getDerivedStateFromProps","unFormattedValue","reset","getUserAction","ctrlKey","metaKey","key","shiftKey","length","resetEvent","setState","detectUndoRedo","event","handleOnKeyDown","persist","currentTarget","newFormattedValue","undo","toString","redo","handleOnPaste","clipboardData","getData","handleOnCut","isKeyAllowed","action","symbolsInPattern","split","filter","character","includes","handleOnChange","onChange","target","handleDelete","add","handleCursorPositioning","broadcastValue","handleOnBlur","onBlur","handleOnFocus","onFocus","newStack","startPosition","getCountOfSymbolsInSelection","toDelete","count","getDistanceToNextSymbol","getDistanceToPreviousSymbol","splice","join","cursorPosition","getCursorPositionAfterKeystroke","setTimeout","setSelectionRange","render","inputMode","className","id","name","placeholder","readOnly","required","minLength","maxLength","disabled","renderProps","onPaste","onKeyDown","onCut"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,MAAMA,iBAA8C,SAAQC,KAAK,CAACC,SAGjE,CAAA;AAGC,EAAA,OAAOC,YAAY,GAAG;AACpBC,IAAAA,YAAY,EAAE,KAAK;AACnBC,IAAAA,cAAc,EAAE,EAAE;AAClBC,IAAAA,KAAK,EAAE;GACR;EAEDC,WAAAA,CAAYC,KAA6B,EAAA;IACvC,K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EAAEqD;AAAc,OAAE,CAAC;IACjF,CAAC,EAAE,CAAC,CAAC;EACP,CAAC;AAEDI,EAAAA,MAAMA,GAAA;IACJ,MAAM;MACJC,SAAS;MACTC,SAAS;MACTC,EAAE;MACFC,IAAI;MACJC,WAAW;MACXC,QAAQ;MACRC,QAAQ;MACRC,SAAS;MACTC,SAAS;MACTC,QAAQ;AACRlF,MAAAA;KACD,GAAG,IAAI,CAACI,KAAK;IACd,MAAM;AAAEF,MAAAA;KAAO,GAAG,IAAI,CAACK,KAAK;AAC5B,IAAA,MAAM4E,WAAW,GAAqB;MACpCV,SAAS;MACTC,SAAS;MACTC,EAAE;MACFC,IAAI;MACJC,WAAW;MACXC,QAAQ;MACRC,QAAQ;MACRC,SAAS;MACTC,SAAS;MACTC,QAAQ;MACRlF,YAAY;MACZE,KAAK;MACLwD,OAAO,EAAE,IAAI,CAACD,aAAa;MAC3BD,MAAM,EAAE,IAAI,CAACD,YAAY;MACzB6B,OAAO,EAAE,IAAI,CAAC/C,aAAa;MAC3BgD,SAAS,EAAE,IAAI,CAACvD,eAAe;MAC/BmB,QAAQ,EAAE,IAAI,CAACD,cAAc;MAC7BsC,KAAK,EAAE,IAAI,CAAC9C;KACb;AACD,IAAA,OAAO,IAAI,CAACpC,KAAK,CAACoE,MAAM,CAACW,WAAgB,CAAC;AAC5C,EAAA;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-a18466a",
3
+ "version": "0.0.0-experimental-d6b038b",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -5,19 +5,13 @@ import AccordionItem, { AccordionItemProps } from './AccordionItem';
5
5
  export type AccordionItem = Omit<AccordionItemProps, 'onClick' | 'open' | 'theme'>;
6
6
 
7
7
  export interface AccordionProps {
8
- /**
9
- * The index of the item that should be open by default.
10
- * @default -1
11
- */
8
+ /** The index of the item that should be open by default. */
12
9
  indexOpen?: number;
13
10
  /** An array of items to display in the accordion. */
14
11
  items: readonly AccordionItem[];
15
12
  /** A callback function that is called when an item is clicked. */
16
13
  onClick?: (index: number) => void;
17
- /**
18
- * @deprecated
19
- * @default 'light'
20
- */
14
+ /** @deprecated */
21
15
  theme?: 'light' | 'dark';
22
16
  }
23
17
 
@@ -4,19 +4,18 @@ import { ButtonHTMLAttributes, forwardRef } from 'react';
4
4
  import { Priority, PriorityPrimary, PrioritySecondary, PriorityTertiary } from '../common';
5
5
 
6
6
  /**
7
- * @deprecated Use `<Button />` component instead with `ButtonProps`.
7
+ * @deprecated use `<Button />` component instead with `ButtonProps`
8
8
  */
9
9
  export type ActionButtonProps = {
10
- /** @default Priority.PRIMARY */
11
10
  priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary;
12
11
  /**
13
- * @deprecated Use `children` instead.
12
+ * @deprecated use `children` instead
14
13
  */
15
14
  text?: string;
16
15
  } & ButtonHTMLAttributes<HTMLButtonElement>;
17
16
 
18
17
  /**
19
- * @deprecated Use `<Button v2 size="sm" priority={'primary' / 'secondary-neutral' / 'tertiary'} .. />` component instead.
18
+ * @deprecated use `<Button v2 size="sm" priority={'primary' / 'secondary-neutral' / 'tertiary'} .. />` component instead
20
19
  */
21
20
  const ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(
22
21
  (
@@ -36,7 +36,7 @@ export type ActionOptionProps = {
36
36
  AriaLabelProperty;
37
37
 
38
38
  /**
39
- * @deprecated Use `<ListItem />` instead.
39
+ * @deprecated Please use `<ListItem />` instead.
40
40
  * @deprecatedSince 46.104.0
41
41
  * @see [Source](../listItem/ListItem.tsx)
42
42
  * @see [Storybook](https://storybook.wise.design/?path=/docs/content-listitem--docs)
@@ -78,10 +78,7 @@ export interface AlertProps {
78
78
  message?: string;
79
79
  /** The presence of the onDismiss handler will trigger the visibility of the close button */
80
80
  onDismiss?: React.MouseEventHandler<HTMLButtonElement>;
81
- /**
82
- * The type dictates which icon and colour will be used
83
- * @default 'neutral'
84
- */
81
+ /** The type dictates which icon and colour will be used */
85
82
  type?: AlertType;
86
83
  /** @deprecated Use `InlinePrompt` instead. */
87
84
  arrow?: `${AlertArrowPosition}`;
@@ -107,7 +104,7 @@ function resolveType(type: AlertType): AlertTypeResolved {
107
104
  }
108
105
 
109
106
  /**
110
- * @deprecated Use [`InfoPrompt`](https://storybook.wise.design/?path=/docs/prompts-infoprompt--docs) component instead.
107
+ * @deprecated use [`InfoPrompt`](https://storybook.wise.design/?path=/docs/prompts-infoprompt--docs) component instead
111
108
  */
112
109
  export default function Alert({
113
110
  action,
@@ -23,13 +23,9 @@ export interface AvatarProps {
23
23
  backgroundColorSeed?: string;
24
24
  children?: React.ReactNode;
25
25
  className?: string;
26
- /** @default false */
27
26
  outlined?: boolean;
28
- /** @default 48 */
29
27
  size?: AvatarSize;
30
- /** @default 'light' */
31
28
  theme?: AvatarTheme;
32
- /** @default 'thumbnail' */
33
29
  type?: AvatarType;
34
30
  'aria-label'?: string;
35
31
  }
@@ -8,15 +8,11 @@ type SingleAvatarType = { asset?: AvatarViewProps['children'] } & Omit<
8
8
  >;
9
9
 
10
10
  export type Props = {
11
- /** @default [] */
12
11
  avatars: SingleAvatarType[];
13
- /** @default 'horizontal' */
14
12
  orientation?: 'horizontal' | 'diagonal';
15
- /** @default 48 */
16
- size?: AvatarViewProps['size'];
17
13
  } & Pick<
18
14
  AvatarViewProps,
19
- 'interactive' | 'className' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-hidden'
15
+ 'size' | 'interactive' | 'className' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-hidden'
20
16
  >;
21
17
 
22
18
  export default function AvatarLayout({
@@ -26,10 +26,8 @@ export type BadgeProps = {
26
26
  children: ReactNode;
27
27
  /**
28
28
  * `md` is deprecated, it will fallback to `sm` instead.
29
- * @default 'sm'
30
29
  */
31
30
  size?: DeprecatedSizes | BadgeAssetsProps['size'];
32
- /** @default 'light' */
33
31
  border?: ThemeDark | ThemeLight;
34
32
  'aria-label'?: string;
35
33
  style?: React.CSSProperties;
package/src/body/Body.tsx CHANGED
@@ -13,9 +13,13 @@ const bodyTypes = new Set<BodyTypes>([
13
13
  ]);
14
14
 
15
15
  type Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {
16
- /** @default 'body-default' */
16
+ /**
17
+ * Default value: {@link DEFAULT_TYPE}
18
+ */
17
19
  type?: BodyTypes;
18
- /** @default 'div' */
20
+ /**
21
+ * Default value: `div`
22
+ */
19
23
  as?: 'span' | 'p' | 'div';
20
24
  /**
21
25
  * When true, preserves newline characters in the text
@@ -41,10 +41,7 @@ export interface CommonProps {
41
41
  /** @default false */
42
42
  loading?: boolean;
43
43
 
44
- /**
45
- * Makes the button take up the full width of its container
46
- * @default false
47
- */
44
+ /** Makes the button take up the full width of its container */
48
45
  block?: boolean;
49
46
 
50
47
  /**
@@ -31,7 +31,7 @@ type DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';
31
31
  type DeprecatedSizes = SizeExtraSmall;
32
32
 
33
33
  /**
34
- * @deprecated Use new button instead of these APIs.
34
+ * @deprecated use new button instead APIs
35
35
  * @example
36
36
  * ```
37
37
  * import { Button, ButtonProps } from '@transferwise/components';
@@ -68,7 +68,7 @@ export type CommonProps = {
68
68
  };
69
69
 
70
70
  /**
71
- * @deprecated Use new button instead of APIs.
71
+ * @deprecated use new button instead APIs
72
72
  * @example
73
73
  * ```
74
74
  * import { Button, ButtonProps } from '@transferwise/components';
@@ -87,7 +87,7 @@ type AnchorProps = CommonProps &
87
87
  };
88
88
 
89
89
  /**
90
- * @deprecated Use new button instead of APIs.
90
+ * @deprecated use new button instead APIs
91
91
  * @example
92
92
  * ```
93
93
  * import { Button, ButtonProps } from '@transferwise/components';
@@ -98,7 +98,7 @@ type AnchorProps = CommonProps &
98
98
  export type LegacyButtonProps = ButtonProps | AnchorProps;
99
99
 
100
100
  /**
101
- * @deprecated Use new Button component via `<Button v2 .. />` and new props.
101
+ * @deprecated make sure you use new Button component via `<Button v2 .. />` and new props
102
102
  */
103
103
  const LegacyButton = forwardRef<ButtonReferenceType, LegacyButtonProps>(
104
104
  (
package/src/card/Card.tsx CHANGED
@@ -8,7 +8,6 @@ import Option from '../common/Option';
8
8
 
9
9
  export interface CardProps {
10
10
  'aria-label'?: string;
11
- /** @default 'div' */
12
11
  as?: React.ElementType;
13
12
  isExpanded?: boolean;
14
13
  title: React.ReactNode;
@@ -4,7 +4,6 @@ import { InputHTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef
4
4
  import { useInputAttributes } from '../inputs/contexts';
5
5
 
6
6
  export type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement> & {
7
- /** @default false */
8
7
  indeterminate?: boolean;
9
8
  };
10
9
 
@@ -16,7 +16,7 @@ export type CheckboxOptionProps = Omit<BaseOptionProps, 'onChange'> & {
16
16
  };
17
17
 
18
18
  /**
19
- * @deprecated Use `<ListItem />` instead.
19
+ * @deprecated Please use `<ListItem />` instead.
20
20
  * @deprecatedSince 46.104.0
21
21
  * @see [Source](../listItem/ListItem.tsx)
22
22
  * @see [Storybook](https://storybook.wise.design/?path=/docs/content-listitem--docs)
@@ -1,12 +1,13 @@
1
1
  import { clsx } from 'clsx';
2
2
 
3
3
  import Body from '../body/Body';
4
+ import { typeClassMap, priorityClassMap } from '../button/classMap';
4
5
  import { Breakpoint, ControlType, Priority, Typography } from '../common';
5
6
  import IconButton, { IconButtonProps } from '../iconButton';
6
7
  import { useMedia } from '../common/hooks/useMedia';
7
8
 
8
9
  /**
9
- * @deprecated Use `'default'` instead.
10
+ * @deprecated use `'default'` instead
10
11
  */
11
12
  type DeprecatedTypes = `${ControlType.ACCENT | ControlType.POSITIVE}`;
12
13
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @deprecated Use `ControlType` and `Priority` enums instead.
2
+ * @deprecated use `ControlType` and `Priority` enums instead
3
3
  */
4
4
  export enum Type {
5
5
  PRIMARY = 'primary',
@@ -1,6 +1,6 @@
1
1
  export enum Typography {
2
2
  /**
3
- * @deprecated Use Marketing titles or {@link Typography.DISPLAY_LARGE} instead.
3
+ * @deprecated use Marketing titles or {@link Typography.DISPLAY_LARGE} instead
4
4
  */
5
5
  DISPLAY_EXTRA_LARGE = 'display-extra-large',
6
6
  DISPLAY_LARGE = 'display-large',
@@ -24,7 +24,7 @@ export enum Typography {
24
24
  }
25
25
 
26
26
  /**
27
- * @deprecated Use {@link Typography.DISPLAY_LARGE} instead.
27
+ * @deprecated use {@link Typography.DISPLAY_LARGE} instead
28
28
  */
29
29
  export type DisplayExtraLarge = 'display-extra-large';
30
30
  export type DisplayLarge = 'display-large';
@@ -1,34 +1,52 @@
1
- .np-theme-personal .critical-comms .alert-warning {
2
- color: var(--color-contrast-overlay);
3
- background-color: var(--color-sentiment-negative);
1
+ .critical-comms {
2
+ border-radius: 16px;
3
+ border-radius: var(--radius-medium);
4
+ overflow: hidden;
4
5
  }
5
- .np-theme-personal .critical-comms .alert-warning .np-text-title-body {
6
- color: var(--color-contrast-overlay);
6
+ .critical-comms .alert {
7
+ background-color: var(--color-sentiment-background-surface);
8
+ color: var(--color-sentiment-content-primary);
9
+ margin-bottom: 0;
7
10
  }
8
- .np-theme-personal .critical-comms .status-circle.warning {
11
+ .critical-comms .alert .np-text-title-body {
12
+ color: var(--color-sentiment-content-primary);
13
+ }
14
+ .critical-comms .status-circle.negative {
9
15
  background-color: #ffffff;
10
16
  background-color: var(--color-background-screen);
11
17
  }
12
- .np-theme-personal .critical-comms .status-circle.warning .status-icon {
13
- color: var(--color-contrast-theme);
18
+ .critical-comms .status-circle.negative .status-icon {
19
+ color: #37517e;
20
+ color: var(--color-content-primary);
14
21
  }
15
- .np-theme-personal .critical-comms .alert__message .alert__action {
22
+ .critical-comms .alert__message .alert__action {
16
23
  margin-top: 16px;
17
24
  margin-top: var(--size-16);
18
25
  }
19
- .np-theme-personal .critical-comms .wds-Button {
20
- --Button-background: var(--color-contrast-overlay);
21
- --Button-background-hover: var(--color-sentiment-negative-secondary-hover);
22
- --Button-background-active: var(--color-sentiment-negative-secondary-active);
26
+ .critical-comms .wds-Button {
27
+ --Button-color: var(--color-content-primary);
28
+ --Button-color-hover: var(--color-content-primary);
29
+ --Button-color-active: var(--color-content-primary);
30
+ --Button-background: var(--color-background-screen);
31
+ --Button-background-hover: var(--color-sentiment-interactive-primary-hover);
32
+ --Button-background-active: var(--color-sentiment-interactive-primary-active);
33
+ }
34
+ .critical-comms .alert-warning .wds-Button {
35
+ --Button-background-hover: var(--color-sentiment-interactive-secondary-neutral-hover);
36
+ --Button-background-active: var(--color-sentiment-interactive-secondary-neutral-active);
23
37
  }
24
38
  @media (min-width: 768px) {
25
- .np-theme-personal .critical-comms .alert-warning .alert__message {
39
+ .critical-comms .alert-warning .alert__message,
40
+ .critical-comms .alert-negative .alert__message,
41
+ .critical-comms .alert-neutral .alert__message {
26
42
  flex-direction: row;
27
43
  justify-content: space-between;
28
44
  align-items: center;
29
45
  width: 100%;
30
46
  }
31
- .np-theme-personal .critical-comms .alert-warning .alert__message .alert__action {
47
+ .critical-comms .alert-warning .alert__message .alert__action,
48
+ .critical-comms .alert-negative .alert__message .alert__action,
49
+ .critical-comms .alert-neutral .alert__message .alert__action {
32
50
  margin-top: 0;
33
51
  margin-left: 16px;
34
52
  margin-left: var(--padding-small);
@@ -1,51 +1,61 @@
1
- .np-theme-personal {
2
- .critical-comms {
3
- .alert-warning {
4
- color: var(--color-contrast-overlay);
5
- background-color: var(--color-sentiment-negative);
6
-
7
- .np-text-title-body {
8
- color: var(--color-contrast-overlay);
9
- }
10
- }
1
+ .critical-comms {
2
+ border-radius: var(--radius-medium);
3
+ overflow: hidden;
11
4
 
12
- .status-circle.warning {
13
- background-color: var(--color-background-screen);
5
+ .alert {
6
+ background-color: var(--color-sentiment-background-surface);
7
+ color: var(--color-sentiment-content-primary);
8
+ margin-bottom: 0;
14
9
 
15
- .status-icon {
16
- color: var(--color-contrast-theme);
17
- }
10
+ .np-text-title-body {
11
+ color: var(--color-sentiment-content-primary);
18
12
  }
13
+ }
19
14
 
20
- .alert__message {
21
- .alert__action {
22
- margin-top: var(--size-16);
23
- }
15
+ .status-circle.negative {
16
+ background-color: var(--color-background-screen);
17
+
18
+ .status-icon {
19
+ color: var(--color-content-primary);
24
20
  }
21
+ }
25
22
 
26
- .wds-Button {
27
- --Button-background: var(--color-contrast-overlay);
28
- --Button-background-hover: var(--color-sentiment-negative-secondary-hover);
29
- --Button-background-active: var(--color-sentiment-negative-secondary-active);
23
+ .alert__message {
24
+ .alert__action {
25
+ margin-top: var(--size-16);
30
26
  }
31
27
  }
32
28
 
29
+ .wds-Button {
30
+ --Button-color: var(--color-content-primary);
31
+ --Button-color-hover: var(--color-content-primary);
32
+ --Button-color-active: var(--color-content-primary);
33
+
34
+ --Button-background: var(--color-background-screen);
35
+ --Button-background-hover: var(--color-sentiment-interactive-primary-hover);
36
+ --Button-background-active: var(--color-sentiment-interactive-primary-active);
37
+ }
38
+
39
+ .alert-warning .wds-Button {
40
+ --Button-background-hover: var(--color-sentiment-interactive-secondary-neutral-hover);
41
+ --Button-background-active: var(--color-sentiment-interactive-secondary-neutral-active);
42
+ }
33
43
 
34
44
  @media (--screen-md) {
35
- .critical-comms {
36
- .alert-warning {
37
- .alert__message {
38
- flex-direction: row;
39
- justify-content: space-between;
40
- align-items: center;
41
- width: 100%;
42
-
43
- .alert__action {
44
- margin-top: 0;
45
- margin-left: var(--padding-small);
46
- }
45
+ .alert-warning,
46
+ .alert-negative,
47
+ .alert-neutral {
48
+ .alert__message {
49
+ flex-direction: row;
50
+ justify-content: space-between;
51
+ align-items: center;
52
+ width: 100%;
53
+
54
+ .alert__action {
55
+ margin-top: 0;
56
+ margin-left: var(--padding-small);
47
57
  }
48
58
  }
49
59
  }
50
60
  }
51
- }
61
+ }
@@ -1,7 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
-
3
2
  import CriticalCommsBanner from '.';
4
- import { withVariantConfig } from '../../.storybook/helpers';
5
3
 
6
4
  export default {
7
5
  component: CriticalCommsBanner,
@@ -18,21 +16,17 @@ export const Basic = {
18
16
  },
19
17
  };
20
18
 
21
- export const Variants: Story = {
19
+ export const Sentiments: Story = {
20
+ render: (args) => (
21
+ <>
22
+ <CriticalCommsBanner {...args} sentiment="negative" title="Your account is overdrawn" />
23
+ <CriticalCommsBanner {...args} sentiment="warning" title="Your account needs attention" />
24
+ <CriticalCommsBanner {...args} sentiment="neutral" title="Your transfer is being processed" />
25
+ </>
26
+ ),
22
27
  args: {
23
- title: 'Your account is overdrawn',
24
- subtitle: 'Add money within the next 30 days',
25
- action: { label: 'Take action', href: 'https://wise.com' },
26
- },
27
- ...withVariantConfig(['default', 'dark', 'rtl']),
28
- };
29
-
30
- export const Mobile: Story = {
31
- tags: ['!autodocs'],
32
- args: {
33
- title: 'Your account is overdrawn',
34
28
  subtitle: 'Add money within the next 30 days',
35
29
  action: { label: 'Take action', href: 'https://wise.com' },
30
+ className: 'm-b-1',
36
31
  },
37
- ...withVariantConfig(['default', 'dark', 'rtl', 'mobile']),
38
32
  };
@@ -0,0 +1,70 @@
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+
3
+ import CriticalCommsBanner from '.';
4
+ import { withVariantConfig } from '../../.storybook/helpers';
5
+
6
+ export default {
7
+ component: CriticalCommsBanner,
8
+ title: 'Prompts/CriticalCommsBanner/tests',
9
+ tags: ['!autodocs'],
10
+ } satisfies Meta<typeof CriticalCommsBanner>;
11
+
12
+ type Story = StoryObj<typeof CriticalCommsBanner>;
13
+
14
+ export const Sentiments: Story = {
15
+ render: (args) => (
16
+ <>
17
+ <CriticalCommsBanner {...args} sentiment="negative" />
18
+ <CriticalCommsBanner {...args} sentiment="warning" />
19
+ <CriticalCommsBanner {...args} sentiment="neutral" />
20
+ </>
21
+ ),
22
+ args: {
23
+ subtitle: 'Add money within the next 30 days',
24
+ action: { label: 'Take action', href: 'https://wise.com' },
25
+ className: 'm-b-1',
26
+ },
27
+ ...withVariantConfig([
28
+ 'default',
29
+ 'dark',
30
+ 'bright-green',
31
+ 'forest-green',
32
+ 'business',
33
+ 'business--forest-green',
34
+ 'business--bright-green',
35
+ ]),
36
+ };
37
+
38
+ export const RTL: Story = {
39
+ render: (args) => (
40
+ <>
41
+ <CriticalCommsBanner {...args} sentiment="negative" />
42
+ <CriticalCommsBanner {...args} sentiment="warning" />
43
+ <CriticalCommsBanner {...args} sentiment="neutral" />
44
+ </>
45
+ ),
46
+ args: {
47
+ subtitle: 'Add money within the next 30 days',
48
+ action: { label: 'Take action', href: 'https://wise.com' },
49
+ className: 'm-b-1',
50
+ },
51
+ ...withVariantConfig(['rtl']),
52
+ };
53
+
54
+ export const Mobile: Story = {
55
+ args: {
56
+ subtitle: 'Add money within the next 30 days',
57
+ action: { label: 'Take action', href: 'https://wise.com' },
58
+ className: 'm-b-1',
59
+ },
60
+ ...withVariantConfig(['mobile']),
61
+ };
62
+
63
+ export const Zoom: Story = {
64
+ args: {
65
+ subtitle: 'Add money within the next 30 days',
66
+ action: { label: 'Take action', href: 'https://wise.com' },
67
+ className: 'm-b-1',
68
+ },
69
+ ...withVariantConfig(['400%']),
70
+ };