@transferwise/components 46.124.1 → 46.125.0

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 (304) hide show
  1. package/build/field/Field.js +10 -0
  2. package/build/field/Field.js.map +1 -1
  3. package/build/field/Field.mjs +10 -0
  4. package/build/field/Field.mjs.map +1 -1
  5. package/build/index.js +2 -0
  6. package/build/index.js.map +1 -1
  7. package/build/index.mjs +1 -0
  8. package/build/index.mjs.map +1 -1
  9. package/build/listItem/Prompt/ListItemPrompt.js +10 -0
  10. package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
  11. package/build/listItem/Prompt/ListItemPrompt.mjs +10 -0
  12. package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
  13. package/build/main.css +32 -2
  14. package/build/prompt/ActionPrompt/ActionPrompt.js +123 -0
  15. package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -0
  16. package/build/prompt/ActionPrompt/ActionPrompt.mjs +118 -0
  17. package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -0
  18. package/build/prompt/PrimitivePrompt/PrimitivePrompt.js +13 -11
  19. package/build/prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
  20. package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs +14 -12
  21. package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
  22. package/build/styles/main.css +32 -2
  23. package/build/styles/prompt/ActionPrompt/ActionPrompt.css +21 -0
  24. package/build/styles/prompt/PrimitivePrompt/PrimitivePrompt.css +11 -2
  25. package/build/tabs/Tabs.js +14 -171
  26. package/build/tabs/Tabs.js.map +1 -1
  27. package/build/tabs/Tabs.mjs +16 -173
  28. package/build/tabs/Tabs.mjs.map +1 -1
  29. package/build/tabs/utils.js +0 -18
  30. package/build/tabs/utils.js.map +1 -1
  31. package/build/tabs/utils.mjs +1 -17
  32. package/build/tabs/utils.mjs.map +1 -1
  33. package/build/typeahead/Typeahead.js +10 -0
  34. package/build/typeahead/Typeahead.js.map +1 -1
  35. package/build/typeahead/Typeahead.mjs +10 -0
  36. package/build/typeahead/Typeahead.mjs.map +1 -1
  37. package/build/types/index.d.ts +2 -2
  38. package/build/types/index.d.ts.map +1 -1
  39. package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +26 -0
  40. package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -0
  41. package/build/types/prompt/ActionPrompt/index.d.ts +3 -0
  42. package/build/types/prompt/ActionPrompt/index.d.ts.map +1 -0
  43. package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
  44. package/build/types/prompt/index.d.ts +2 -0
  45. package/build/types/prompt/index.d.ts.map +1 -1
  46. package/build/types/tabs/Tabs.d.ts +2 -24
  47. package/build/types/tabs/Tabs.d.ts.map +1 -1
  48. package/build/types/tabs/utils.d.ts +0 -2
  49. package/build/types/tabs/utils.d.ts.map +1 -1
  50. package/package.json +1 -2
  51. package/src/actionButton/ActionButton.story.tsx +2 -9
  52. package/src/avatar/Avatar.story.tsx +2 -8
  53. package/src/button/_stories/{Button.tests.story.tsx → Button.test.story.tsx} +5 -10
  54. package/src/checkbox/Checkbox.story.tsx +3 -16
  55. package/src/circularButton/CircularButton.story.tsx +2 -7
  56. package/src/common/bottomSheet/BottomSheet.story.tsx +6 -32
  57. package/src/common/circle/Circle.story.tsx +3 -14
  58. package/src/criticalBanner/CriticalCommsBanner.story.tsx +3 -16
  59. package/src/dateInput/{DateInput.tests.story.tsx → DateInput.test.story.tsx} +3 -13
  60. package/src/dateLookup/DateLookup.story.tsx +9 -7
  61. package/src/header/{Header.tests.story.tsx → Header.test.story.tsx} +5 -10
  62. package/src/index.ts +2 -2
  63. package/src/info/Info.story.tsx +4 -20
  64. package/src/listItem/_stories/variants/ListItem.brightGreen.test.story.tsx +2 -7
  65. package/src/listItem/_stories/variants/ListItem.dark.test.story.tsx +2 -7
  66. package/src/listItem/_stories/variants/ListItem.forestGreen.test.story.tsx +2 -7
  67. package/src/listItem/_stories/variants/ListItem.rtl.test.story.tsx +2 -7
  68. package/src/main.css +32 -2
  69. package/src/main.less +1 -0
  70. package/src/modal/Modal.story.tsx +6 -31
  71. package/src/prompt/ActionPrompt/ActionPrompt.css +21 -0
  72. package/src/prompt/ActionPrompt/ActionPrompt.less +23 -0
  73. package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +184 -0
  74. package/src/prompt/ActionPrompt/ActionPrompt.test.tsx +256 -0
  75. package/src/prompt/ActionPrompt/ActionPrompt.tsx +129 -0
  76. package/src/prompt/ActionPrompt/index.ts +2 -0
  77. package/src/prompt/InlinePrompt/{InlinePrompt.spec.tsx → InlinePrompt.test.tsx} +3 -38
  78. package/src/prompt/PrimitivePrompt/PrimitivePrompt.css +11 -2
  79. package/src/prompt/PrimitivePrompt/PrimitivePrompt.less +12 -2
  80. package/src/prompt/PrimitivePrompt/PrimitivePrompt.test.tsx +161 -0
  81. package/src/prompt/PrimitivePrompt/PrimitivePrompt.tsx +15 -11
  82. package/src/prompt/index.ts +3 -0
  83. package/src/snackbar/{Snackbar.tests.story.tsx → Snackbar.test.story.tsx} +6 -32
  84. package/src/{ssr.spec.tsx → ssr.test.tsx} +1 -0
  85. package/src/statusIcon/StatusIcon.story.tsx +5 -9
  86. package/src/tabs/Tabs.story.tsx +1 -45
  87. package/src/tabs/{Tabs.spec.tsx → Tabs.test.tsx} +0 -22
  88. package/src/tabs/Tabs.tsx +23 -240
  89. package/src/tabs/utils.test.ts +68 -0
  90. package/src/tabs/utils.ts +0 -20
  91. package/src/tooltip/Tooltip.story.tsx +2 -7
  92. package/src/tabs/utils.spec.ts +0 -126
  93. /package/src/accordion/{Accordion.spec.js → Accordion.test.js} +0 -0
  94. /package/src/accordion/AccordionItem/{AccordionItem.spec.js → AccordionItem.test.js} +0 -0
  95. /package/src/accordion/AccordionItem/__snapshots__/{AccordionItem.spec.js.snap → AccordionItem.test.js.snap} +0 -0
  96. /package/src/accordion/__snapshots__/{Accordion.spec.js.snap → Accordion.test.js.snap} +0 -0
  97. /package/src/actionButton/{ActionButton.spec.tsx → ActionButton.test.tsx} +0 -0
  98. /package/src/actionButton/__snapshots__/{ActionButton.spec.tsx.snap → ActionButton.test.tsx.snap} +0 -0
  99. /package/src/actionOption/{ActionOption.spec.tsx → ActionOption.test.tsx} +0 -0
  100. /package/src/alert/{Alert.tests.story.tsx → Alert.test.story.tsx} +0 -0
  101. /package/src/alert/{Alert.spec.tsx → Alert.test.tsx} +0 -0
  102. /package/src/avatar/{Avatar.spec.tsx → Avatar.test.tsx} +0 -0
  103. /package/src/avatarWrapper/{AvatarWrapper.spec.tsx → AvatarWrapper.test.tsx} +0 -0
  104. /package/src/avatarWrapper/__snapshots__/{AvatarWrapper.spec.tsx.snap → AvatarWrapper.test.tsx.snap} +0 -0
  105. /package/src/badge/{Badge.spec.tsx → Badge.test.tsx} +0 -0
  106. /package/src/body/{Body.spec.tsx → Body.test.tsx} +0 -0
  107. /package/src/button/{Button.spec.tsx → Button.test.tsx} +0 -0
  108. /package/src/button/{LegacyButton.spec.tsx → LegacyButton.test.tsx} +0 -0
  109. /package/src/button/_stories/{Button.brightGreen.tests.story.tsx → Button.brightGreen.test.story.tsx} +0 -0
  110. /package/src/button/_stories/{Button.dark.tests.story.tsx → Button.dark.test.story.tsx} +0 -0
  111. /package/src/button/_stories/{Button.default.tests.story.tsx → Button.default.test.story.tsx} +0 -0
  112. /package/src/button/_stories/{Button.forestGreen.tests.story.tsx → Button.forestGreen.test.story.tsx} +0 -0
  113. /package/src/button/legacyUtils/{legacyUtils.spec.tsx → legacyUtils.test.tsx} +0 -0
  114. /package/src/card/{Card.spec.tsx → Card.test.tsx} +0 -0
  115. /package/src/carousel/{Carousel.spec.tsx → Carousel.test.tsx} +0 -0
  116. /package/src/checkbox/{Checkbox.spec.tsx → Checkbox.test.tsx} +0 -0
  117. /package/src/checkbox/__snapshots__/{Checkbox.spec.tsx.snap → Checkbox.test.tsx.snap} +0 -0
  118. /package/src/checkboxButton/{CheckboxButton.spec.tsx → CheckboxButton.test.tsx} +0 -0
  119. /package/src/checkboxOption/{CheckboxOption.spec.tsx → CheckboxOption.test.tsx} +0 -0
  120. /package/src/chevron/{Chevron.spec.tsx → Chevron.test.tsx} +0 -0
  121. /package/src/chevron/__snapshots__/{Chevron.spec.tsx.snap → Chevron.test.tsx.snap} +0 -0
  122. /package/src/chips/{Chips.spec.tsx → Chips.test.tsx} +0 -0
  123. /package/src/chips/__snapshots__/{Chips.spec.tsx.snap → Chips.test.tsx.snap} +0 -0
  124. /package/src/circularButton/{CircularButton.tests.story.tsx → CircularButton.test.story.tsx} +0 -0
  125. /package/src/circularButton/{CircularButton.spec.tsx → CircularButton.test.tsx} +0 -0
  126. /package/src/common/DOMOperations/{DOMOperations.spec.tsx → DOMOperations.test.tsx} +0 -0
  127. /package/src/common/Option/{Option.spec.tsx → Option.test.tsx} +0 -0
  128. /package/src/common/RadioButton/{RadioButton.spec.tsx → RadioButton.test.tsx} +0 -0
  129. /package/src/common/RadioButton/__snapshots__/{RadioButton.spec.tsx.snap → RadioButton.test.tsx.snap} +0 -0
  130. /package/src/common/bottomSheet/{BottomSheet.spec.tsx → BottomSheet.test.tsx} +0 -0
  131. /package/src/common/bottomSheet/__snapshots__/{BottomSheet.spec.tsx.snap → BottomSheet.test.tsx.snap} +0 -0
  132. /package/src/common/card/{Card.spec.tsx → Card.test.tsx} +0 -0
  133. /package/src/common/card/__snapshots__/{Card.spec.tsx.snap → Card.test.tsx.snap} +0 -0
  134. /package/src/common/closeButton/{CloseButton.spec.tsx → CloseButton.test.tsx} +0 -0
  135. /package/src/common/closeButton/__snapshots__/{CloseButton.spec.tsx.snap → CloseButton.test.tsx.snap} +0 -0
  136. /package/src/common/dateUtils/getDayNames/{getDayNames.spec.js → getDayNames.test.js} +0 -0
  137. /package/src/common/dateUtils/getMonthNames/{getMonthNames.spec.js → getMonthNames.test.js} +0 -0
  138. /package/src/common/dateUtils/isDateValid/{isDateValid.spec.ts → isDateValid.test.ts} +0 -0
  139. /package/src/common/dateUtils/isMonthAndYearFormat/{isMonthAndYearFormat.spec.js → isMonthAndYearFormat.test.js} +0 -0
  140. /package/src/common/dateUtils/isWithinRange/{isWithinRange.spec.ts → isWithinRange.test.ts} +0 -0
  141. /package/src/common/dateUtils/moveToWithinRange/{moveToWithinRange.spec.js → moveToWithinRange.test.js} +0 -0
  142. /package/src/common/deviceDetection/{deviceDetection.spec.ts → deviceDetection.test.ts} +0 -0
  143. /package/src/common/domHelpers/{documentIosClick.spec.ts → documentIosClick.test.ts} +0 -0
  144. /package/src/common/flowHeader/{FlowHeader.spec.tsx → FlowHeader.test.tsx} +0 -0
  145. /package/src/common/flowHeader/__snapshots__/{FlowHeader.spec.tsx.snap → FlowHeader.test.tsx.snap} +0 -0
  146. /package/src/common/historyNavigator/{historyNavigator.spec.ts → historyNavigator.test.ts} +0 -0
  147. /package/src/common/hooks/useConditionalListener/{useConditionalListener.spec.js → useConditionalListener.test.js} +0 -0
  148. /package/src/common/hooks/useDirection/{useDirection.spec.js → useDirection.test.js} +0 -0
  149. /package/src/common/hooks/useHasIntersected/{useHasIntersected.spec.js → useHasIntersected.test.js} +0 -0
  150. /package/src/common/hooks/{useMedia.spec.ts → useMedia.test.ts} +0 -0
  151. /package/src/common/{initials.spec.tsx → initials.test.tsx} +0 -0
  152. /package/src/common/locale/{index.spec.ts → index.test.ts} +0 -0
  153. /package/src/common/panel/{Panel.spec.tsx → Panel.test.tsx} +0 -0
  154. /package/src/common/panel/__snapshots__/{Panel.spec.tsx.snap → Panel.test.tsx.snap} +0 -0
  155. /package/src/common/responsivePanel/{ResponsivePanel.spec.js → ResponsivePanel.test.js} +0 -0
  156. /package/src/common/textFormat/formatWithPattern/{formatWithPattern.spec.ts → formatWithPattern.test.ts} +0 -0
  157. /package/src/common/textFormat/getCountOfSymbolsInSelection/{getCountOfSymbolsInSelection.spec.ts → getCountOfSymbolsInSelection.test.ts} +0 -0
  158. /package/src/common/textFormat/getCursorPositionAfterKeystroke/{getCursorPositionAfterKeystroke.spec.ts → getCursorPositionAfterKeystroke.test.ts} +0 -0
  159. /package/src/common/textFormat/getDistanceToSymbol/{getDistanceToSymbol.spec.ts → getDistanceToSymbol.test.ts} +0 -0
  160. /package/src/common/textFormat/getSymbolsInPatternWithPosition/{getSymbolsInPatternWithPosition.spec.ts → getSymbolsInPatternWithPosition.test.ts} +0 -0
  161. /package/src/common/textFormat/unformatWithPattern/{unformatWithPattern.spec.ts → unformatWithPattern.test.ts} +0 -0
  162. /package/src/dateInput/{DateInput.spec.tsx → DateInput.test.tsx} +0 -0
  163. /package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.spec.ts → convertToLocalMidnight.test.ts} +0 -0
  164. /package/src/dateLookup/{DateLookup.tests.story.tsx → DateLookup.test.story.tsx} +0 -0
  165. /package/src/dateLookup/{DateLookup.spec.tsx → DateLookup.test.tsx} +0 -0
  166. /package/src/dateLookup/getFocusableTime/{getFocusable.spec.ts → getFocusable.test.ts} +0 -0
  167. /package/src/dateLookup/getStartOfDay/{getStartOfDay.spec.js → getStartOfDay.test.js} +0 -0
  168. /package/src/decision/{Decision.spec.tsx → Decision.test.tsx} +0 -0
  169. /package/src/dimmer/{Dimmer.spec.tsx → Dimmer.test.tsx} +0 -0
  170. /package/src/divider/{Divider.spec.tsx → Divider.test.tsx} +0 -0
  171. /package/src/drawer/{Drawer.spec.tsx → Drawer.test.tsx} +0 -0
  172. /package/src/emphasis/{Emphasis.spec.tsx → Emphasis.test.tsx} +0 -0
  173. /package/src/emphasis/{EmphasisHtmlTransformer.spec.tsx → EmphasisHtmlTransformer.test.tsx} +0 -0
  174. /package/src/expressiveMoneyInput/{ExpressiveMoneyInput.spec.tsx → ExpressiveMoneyInput.test.tsx} +0 -0
  175. /package/src/expressiveMoneyInput/amountInput/{AmountInput.spec.tsx → AmountInput.test.tsx} +0 -0
  176. /package/src/expressiveMoneyInput/amountInput/{utils.spec.ts → utils.test.ts} +0 -0
  177. /package/src/expressiveMoneyInput/currencySelector/{CurrencySelector.spec.tsx → CurrencySelector.test.tsx} +0 -0
  178. /package/src/field/{Field.spec.tsx → Field.test.tsx} +0 -0
  179. /package/src/flowNavigation/{FlowNavigation.spec.js → FlowNavigation.test.js} +0 -0
  180. /package/src/flowNavigation/__snapshots__/{FlowNavigation.spec.js.snap → FlowNavigation.test.js.snap} +0 -0
  181. /package/src/flowNavigation/animatedLabel/{AnimatedLabel.spec.js → AnimatedLabel.test.js} +0 -0
  182. /package/src/header/{Header.spec.tsx → Header.test.tsx} +0 -0
  183. /package/src/iconButton/{iconButton.spec.tsx → iconButton.test.tsx} +0 -0
  184. /package/src/image/{Image.spec.tsx → Image.test.tsx} +0 -0
  185. /package/src/info/{Info.spec.jsx → Info.test.jsx} +0 -0
  186. /package/src/inlineAlert/{InlineAlert.spec.tsx → InlineAlert.test.tsx} +0 -0
  187. /package/src/inputWithDisplayFormat/{InputWithDisplayFormat.spec.js → InputWithDisplayFormat.test.js} +0 -0
  188. /package/src/inputs/{InputGroup.spec.tsx → InputGroup.test.tsx} +0 -0
  189. /package/src/inputs/{SearchInput.spec.tsx → SearchInput.test.tsx} +0 -0
  190. /package/src/inputs/{SelectInput.spec.tsx → SelectInput.test.tsx} +0 -0
  191. /package/src/instructionsList/{InstructionsList.spec.tsx → InstructionsList.test.tsx} +0 -0
  192. /package/src/label/{Label.spec.tsx → Label.test.tsx} +0 -0
  193. /package/src/legacylistItem/{LegacyListItem.tests.story.tsx → LegacyListItem.test.story.tsx} +0 -0
  194. /package/src/legacylistItem/{LegacyListItem.spec.tsx → LegacyListItem.test.tsx} +0 -0
  195. /package/src/link/{Link.spec.tsx → Link.test.tsx} +0 -0
  196. /package/src/list/{List.spec.tsx → List.test.tsx} +0 -0
  197. /package/src/listItem/AdditionalInfo/{ListItemAdditionalInfo.spec.tsx → ListItemAdditionalInfo.test.tsx} +0 -0
  198. /package/src/listItem/AvatarLayout/{ListItemAvatarLayout.spec.tsx → ListItemAvatarLayout.test.tsx} +0 -0
  199. /package/src/listItem/AvatarView/{ListItemAvatarView.spec.tsx → ListItemAvatarView.test.tsx} +0 -0
  200. /package/src/listItem/Button/{ListItemButton.spec.tsx → ListItemButton.test.tsx} +0 -0
  201. /package/src/listItem/Checkbox/{ListItemCheckbox.spec.tsx → ListItemCheckbox.test.tsx} +0 -0
  202. /package/src/listItem/IconButton/{ListItemIconButton.spec.tsx → ListItemIconButton.test.tsx} +0 -0
  203. /package/src/listItem/Image/{ListItemImage.spec.tsx → ListItemImage.test.tsx} +0 -0
  204. /package/src/listItem/{ListItem.spec.tsx → ListItem.test.tsx} +0 -0
  205. /package/src/listItem/Navigation/{ListItemNavigation.spec.tsx → ListItemNavigation.test.tsx} +0 -0
  206. /package/src/listItem/Prompt/{ListItemPrompt.spec.tsx → ListItemPrompt.test.tsx} +0 -0
  207. /package/src/listItem/Radio/{ListItemRadio.spec.tsx → ListItemRadio.test.tsx} +0 -0
  208. /package/src/listItem/Switch/{ListItemSwitch.spec.tsx → ListItemSwitch.test.tsx} +0 -0
  209. /package/src/loader/{Loader.spec.tsx → Loader.test.tsx} +0 -0
  210. /package/src/logo/{Logo.spec.tsx → Logo.test.tsx} +0 -0
  211. /package/src/logo/__snapshots__/{Logo.spec.tsx.snap → Logo.test.tsx.snap} +0 -0
  212. /package/src/markdown/{Markdown.spec.tsx → Markdown.test.tsx} +0 -0
  213. /package/src/modal/{Modal.spec.tsx → Modal.test.tsx} +0 -0
  214. /package/src/money/{Money.spec.tsx → Money.test.tsx} +0 -0
  215. /package/src/moneyInput/{MoneyInput.spec.tsx → MoneyInput.test.tsx} +0 -0
  216. /package/src/moneyInput/{currencyFormatting.spec.ts → currencyFormatting.test.ts} +0 -0
  217. /package/src/navigationOption/{NavigationOption.spec.tsx → NavigationOption.test.tsx} +0 -0
  218. /package/src/navigationOptionsList/{NavigationOptionsList.spec.tsx → NavigationOptionsList.test.tsx} +0 -0
  219. /package/src/nudge/{Nudge.spec.tsx → Nudge.test.tsx} +0 -0
  220. /package/src/overlayHeader/{OverlayHeader.spec.tsx → OverlayHeader.test.tsx} +0 -0
  221. /package/src/overlayHeader/__snapshots__/{OverlayHeader.spec.tsx.snap → OverlayHeader.test.tsx.snap} +0 -0
  222. /package/src/phoneNumberInput/{PhoneNumberInput.spec.tsx → PhoneNumberInput.test.tsx} +0 -0
  223. /package/src/phoneNumberInput/utils/cleanNumber/{cleanNumber.spec.ts → cleanNumber.test.ts} +0 -0
  224. /package/src/phoneNumberInput/utils/excludeCountries/{excludeCountries.spec.ts → excludeCountries.test.ts} +0 -0
  225. /package/src/phoneNumberInput/utils/explodeNumberModel/{explodeNumberModel.spec.ts → explodeNumberModel.test.ts} +0 -0
  226. /package/src/phoneNumberInput/utils/findCountryByCode/{findCountryByCode.spec.ts → findCountryByCode.test.ts} +0 -0
  227. /package/src/phoneNumberInput/utils/findCountryByPrefix/{findCountryByPrefix.spec.ts → findCountryByPrefix.test.ts} +0 -0
  228. /package/src/phoneNumberInput/utils/groupCountriesByPrefix/{groupCountriesByPrefix.spec.ts → groupCountriesByPrefix.test.ts} +0 -0
  229. /package/src/phoneNumberInput/utils/isStringNumeric/{isStringNumeric.spec.ts → isStringNumeric.test.ts} +0 -0
  230. /package/src/phoneNumberInput/utils/isValidPhoneNumber/{isValidPhoneNumber.spec.ts → isValidPhoneNumber.test.ts} +0 -0
  231. /package/src/phoneNumberInput/utils/longestMatchingPrefix/{longestMatchingPrefix.spec.ts → longestMatchingPrefix.test.ts} +0 -0
  232. /package/src/phoneNumberInput/utils/setDefaultPrefix/{setDefaultPrefix.spec.ts → setDefaultPrefix.test.ts} +0 -0
  233. /package/src/phoneNumberInput/utils/sortArrayByProperty/{sortArrayByProperty.spec.ts → sortArrayByProperty.test.ts} +0 -0
  234. /package/src/popover/{Popover.spec.tsx → Popover.test.tsx} +0 -0
  235. /package/src/popover/__snapshots__/{Popover.spec.tsx.snap → Popover.test.tsx.snap} +0 -0
  236. /package/src/primitives/PrimitiveAnchor/stories/{PrimitiveAnchor.tests.story.tsx → PrimitiveAnchor.test.story.tsx} +0 -0
  237. /package/src/primitives/PrimitiveAnchor/test/{PrimitiveAnchor.spec.tsx → PrimitiveAnchor.test.tsx} +0 -0
  238. /package/src/primitives/PrimitiveButton/stories/{PrimitiveButton.tests.story.tsx → PrimitiveButton.test.story.tsx} +0 -0
  239. /package/src/primitives/PrimitiveButton/test/{PrimitiveButton.spec.tsx → PrimitiveButton.test.tsx} +0 -0
  240. /package/src/processIndicator/{ProcessIndicator.rtl.spec.tsx → ProcessIndicator.rtl.test.tsx} +0 -0
  241. /package/src/progress/{Progress.spec.tsx → Progress.test.tsx} +0 -0
  242. /package/src/progressBar/{ProgressBar.spec.tsx → ProgressBar.test.tsx} +0 -0
  243. /package/src/promoCard/{PromoCard.spec.tsx → PromoCard.test.tsx} +0 -0
  244. /package/src/promoCard/{PromoCardContext.spec.tsx → PromoCardContext.test.tsx} +0 -0
  245. /package/src/promoCard/{PromoCardGroup.spec.tsx → PromoCardGroup.test.tsx} +0 -0
  246. /package/src/promoCard/__snapshots__/{PromoCard.spec.tsx.snap → PromoCard.test.tsx.snap} +0 -0
  247. /package/src/promoCard/__snapshots__/{PromoCardGroup.spec.tsx.snap → PromoCardGroup.test.tsx.snap} +0 -0
  248. /package/src/provider/{Provider.spec.tsx → Provider.test.tsx} +0 -0
  249. /package/src/provider/direction/{DirectionProvider.spec.tsx → DirectionProvider.test.tsx} +0 -0
  250. /package/src/provider/language/{LanguageProvider.spec.tsx → LanguageProvider.test.tsx} +0 -0
  251. /package/src/radio/{Radio.spec.tsx → Radio.test.tsx} +0 -0
  252. /package/src/radioGroup/{RadioGroup.spec.tsx → RadioGroup.test.tsx} +0 -0
  253. /package/src/radioOption/{RadioOption.spec.tsx → RadioOption.test.tsx} +0 -0
  254. /package/src/section/{Section.spec.tsx → Section.test.tsx} +0 -0
  255. /package/src/segmentedControl/{SegmentedControl.spec.tsx → SegmentedControl.test.tsx} +0 -0
  256. /package/src/select/{Select.rtl.spec.tsx → Select.rtl.test.tsx} +0 -0
  257. /package/src/select/{Select.spec.tsx → Select.test.tsx} +0 -0
  258. /package/src/select/option/{Option.spec.tsx → Option.test.tsx} +0 -0
  259. /package/src/select/searchBox/{SearchBox.spec.tsx → SearchBox.test.tsx} +0 -0
  260. /package/src/sentimentSurface/{SentimentSurface.tests.story.tsx → SentimentSurface.test.story.tsx} +0 -0
  261. /package/src/sentimentSurface/{SentimentSurface.spec.tsx → SentimentSurface.test.tsx} +0 -0
  262. /package/src/slidingPanel/{SlidingPanel.spec.tsx → SlidingPanel.test.tsx} +0 -0
  263. /package/src/statusIcon/{StatusIcon.spec.tsx → StatusIcon.test.tsx} +0 -0
  264. /package/src/stepper/{Stepper.tests.story.tsx → Stepper.test.story.tsx} +0 -0
  265. /package/src/stepper/{Stepper.spec.tsx → Stepper.test.tsx} +0 -0
  266. /package/src/stepper/{deviceDetection.spec.ts → deviceDetection.test.ts} +0 -0
  267. /package/src/sticky/{Sticky.spec.tsx → Sticky.test.tsx} +0 -0
  268. /package/src/summary/{Summary.tests.story.tsx → Summary.test.story.tsx} +0 -0
  269. /package/src/summary/{Summary.spec.tsx → Summary.test.tsx} +0 -0
  270. /package/src/switch/{Switch.spec.tsx → Switch.test.tsx} +0 -0
  271. /package/src/switchOption/{SwitchOption.spec.tsx → SwitchOption.test.tsx} +0 -0
  272. /package/src/table/{Table.spec.tsx → Table.test.tsx} +0 -0
  273. /package/src/table/{TableCell.spec.tsx → TableCell.test.tsx} +0 -0
  274. /package/src/table/{TableHeader.spec.tsx → TableHeader.test.tsx} +0 -0
  275. /package/src/table/{TableRow.spec.tsx → TableRow.test.tsx} +0 -0
  276. /package/src/table/{TableStatusText.spec.tsx → TableStatusText.test.tsx} +0 -0
  277. /package/src/textareaWithDisplayFormat/{TextareaWithDisplayFormat.spec.js → TextareaWithDisplayFormat.test.js} +0 -0
  278. /package/src/tile/{Tile.spec.tsx → Tile.test.tsx} +0 -0
  279. /package/src/tile/__snapshots__/{Tile.spec.tsx.snap → Tile.test.tsx.snap} +0 -0
  280. /package/src/title/{Title.spec.tsx → Title.test.tsx} +0 -0
  281. /package/src/tooltip/{Tooltip.spec.tsx → Tooltip.test.tsx} +0 -0
  282. /package/src/tooltip/__snapshots__/{Tooltip.spec.tsx.snap → Tooltip.test.tsx.snap} +0 -0
  283. /package/src/typeahead/{Typeahead.spec.tsx → Typeahead.test.tsx} +0 -0
  284. /package/src/typeahead/typeaheadInput/{TypeaheadInput.spec.tsx → TypeaheadInput.test.tsx} +0 -0
  285. /package/src/typeahead/util/{highlight.spec.tsx → highlight.test.tsx} +0 -0
  286. /package/src/upload/{Upload.tests.story.tsx → Upload.test.story.tsx} +0 -0
  287. /package/src/upload/{Upload.spec.tsx → Upload.test.tsx} +0 -0
  288. /package/src/upload/steps/completeStep/{completeStep.spec.tsx → completeStep.test.tsx} +0 -0
  289. /package/src/upload/steps/processingStep/{processingStep.spec.tsx → processingStep.test.tsx} +0 -0
  290. /package/src/upload/steps/uploadImageStep/{uploadImageStep.spec.tsx → uploadImageStep.test.tsx} +0 -0
  291. /package/src/upload/utils/asyncFileRead/{asyncFileRead.spec.ts → asyncFileRead.test.ts} +0 -0
  292. /package/src/upload/utils/getFileType/{getFileType.spec.ts → getFileType.test.ts} +0 -0
  293. /package/src/upload/utils/isSizeValid/{isSizeValid.spec.ts → isSizeValid.test.ts} +0 -0
  294. /package/src/upload/utils/isTypeValid/{isTypeValid.spec.ts → isTypeValid.test.ts} +0 -0
  295. /package/src/upload/utils/postData/{postData.spec.ts → postData.test.ts} +0 -0
  296. /package/src/uploadInput/{UploadInput.tests.story.tsx → UploadInput.test.story.tsx} +0 -0
  297. /package/src/uploadInput/{UploadInput.spec.tsx → UploadInput.test.tsx} +0 -0
  298. /package/src/uploadInput/uploadButton/{UploadButton.spec.tsx → UploadButton.test.tsx} +0 -0
  299. /package/src/uploadInput/uploadButton/{getAllowedFileTypes.spec.ts → getAllowedFileTypes.test.ts} +0 -0
  300. /package/src/uploadInput/uploadItem/{UploadItem.spec.tsx → UploadItem.test.tsx} +0 -0
  301. /package/src/utilities/deprecatedProperty/{deprecatedProperty.spec.ts → deprecatedProperty.test.ts} +0 -0
  302. /package/src/withDisplayFormat/{WithDisplayFormat.spec.js → WithDisplayFormat.test.js} +0 -0
  303. /package/src/withId/{withId.spec.tsx → withId.test.tsx} +0 -0
  304. /package/src/withNextPortal/{withNextPortal.spec.tsx → withNextPortal.test.tsx} +0 -0
@@ -0,0 +1,184 @@
1
+ import { ReactElement, useState } from 'react';
2
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
3
+ import { fn } from 'storybook/test';
4
+ import { Bank } from '@transferwise/icons';
5
+ import { ActionPrompt } from './ActionPrompt';
6
+ import { lorem10 } from '../../test-utils';
7
+ import { withVariantConfig } from '../../../.storybook/helpers';
8
+
9
+ const meta: Meta<typeof ActionPrompt> = {
10
+ title: 'Prompts/ActionPrompt',
11
+ component: ActionPrompt,
12
+ tags: ['new'],
13
+ };
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof ActionPrompt>;
17
+
18
+ const withComponentGrid =
19
+ ({ maxWidth = 'auto', gap = '1rem' } = {}) =>
20
+ (Story: () => ReactElement) => (
21
+ <div
22
+ style={{
23
+ width: '100%',
24
+ display: 'flex',
25
+ flexDirection: 'column',
26
+ justifyContent: 'flex-start',
27
+ alignItems: 'flex-start',
28
+ alignContent: 'flex-start',
29
+ gap,
30
+ maxWidth,
31
+ }}
32
+ >
33
+ <Story />
34
+ </div>
35
+ );
36
+
37
+ export const AllSentiments: Story = {
38
+ render: () => {
39
+ return (
40
+ <>
41
+ {(['negative', 'warning', 'neutral', 'success', 'proposition'] as const).map(
42
+ (sentiment) => (
43
+ <ActionPrompt
44
+ key={sentiment}
45
+ sentiment={sentiment}
46
+ title="Title"
47
+ description={lorem10}
48
+ action={{ label: 'Primary', onClick: fn() }}
49
+ actionSecondary={{ label: 'Secondary', onClick: fn() }}
50
+ className="m-b-2"
51
+ onDismiss={fn()}
52
+ />
53
+ ),
54
+ )}
55
+ </>
56
+ );
57
+ },
58
+ decorators: [withComponentGrid()],
59
+ };
60
+
61
+ export const Mobile: Story = {
62
+ ...AllSentiments,
63
+ ...withVariantConfig(['mobile'], AllSentiments),
64
+ };
65
+
66
+ export const PrimaryActionOnly: Story = {
67
+ args: {
68
+ sentiment: 'proposition',
69
+ title: 'Payment successful',
70
+ description: 'Your money is on its way',
71
+ action: { label: 'View details', onClick: fn() },
72
+ onDismiss: fn(),
73
+ },
74
+ };
75
+
76
+ export const WithoutDescription: Story = {
77
+ render: () => {
78
+ return (
79
+ <>
80
+ <ActionPrompt
81
+ sentiment="warning"
82
+ title="Session expiring soon"
83
+ action={{ label: 'Stay logged in', onClick: fn() }}
84
+ actionSecondary={{ label: 'Log out', onClick: fn() }}
85
+ onDismiss={fn()}
86
+ />
87
+ <ActionPrompt
88
+ sentiment="success"
89
+ title="Session expiring soon"
90
+ action={{ label: 'Stay logged in', onClick: fn() }}
91
+ />
92
+ <ActionPrompt
93
+ title="Session expiring soon"
94
+ action={{ label: 'Stay logged in', onClick: fn() }}
95
+ />
96
+ </>
97
+ );
98
+ },
99
+ decorators: [withComponentGrid()],
100
+ };
101
+
102
+ export const Media: Story = {
103
+ render: () => {
104
+ return (
105
+ <>
106
+ <ActionPrompt
107
+ sentiment="neutral"
108
+ title="Custom image"
109
+ description={lorem10}
110
+ media={{ imgSrc: '../../wise-card.svg' }}
111
+ action={{ label: 'Invite now', onClick: fn() }}
112
+ />
113
+ <ActionPrompt
114
+ sentiment="neutral"
115
+ title="Profile Image"
116
+ description={lorem10}
117
+ media={{ avatar: { imgSrc: '../../avatar-rectangle-fox.webp' } }}
118
+ action={{ label: 'Invite now', onClick: fn() }}
119
+ />
120
+ <ActionPrompt
121
+ sentiment="proposition"
122
+ title="Business Profile"
123
+ description={lorem10}
124
+ media={{ avatar: { profileType: 'BUSINESS', badge: { flagCode: 'GB' } } }}
125
+ action={{ label: 'Invite now', onClick: fn() }}
126
+ />
127
+ <ActionPrompt
128
+ sentiment="negative"
129
+ title="Personal Profile"
130
+ description={lorem10}
131
+ media={{ avatar: { profileType: 'PERSONAL', badge: { flagCode: 'EU' } } }}
132
+ action={{ label: 'Invite now', onClick: fn() }}
133
+ />
134
+ <ActionPrompt
135
+ sentiment="warning"
136
+ title="Custom Icon"
137
+ description={lorem10}
138
+ media={{ avatar: { asset: <Bank /> } }}
139
+ action={{ label: 'Invite now', onClick: fn() }}
140
+ />
141
+ <ActionPrompt
142
+ sentiment="success"
143
+ title="Initials"
144
+ description={lorem10}
145
+ media={{ avatar: { profileName: 'John Doe' } }}
146
+ action={{ label: 'Invite now', onClick: fn() }}
147
+ actionSecondary={{ label: 'Maybe later', onClick: fn() }}
148
+ />
149
+ </>
150
+ );
151
+ },
152
+ decorators: [withComponentGrid()],
153
+ };
154
+
155
+ export const OnDismiss: Story = {
156
+ render: () => {
157
+ const [showNeutralPrompt, setShowNeutralPrompt] = useState(true);
158
+ const [showSuccessPrompt, setShowSuccessPrompt] = useState(true);
159
+
160
+ return (
161
+ <>
162
+ {showNeutralPrompt && (
163
+ <ActionPrompt
164
+ sentiment="proposition"
165
+ title="Payment successful"
166
+ description="Your money is on its way"
167
+ action={{ label: 'View details', onClick: fn() }}
168
+ className="m-b-2"
169
+ onDismiss={() => setShowNeutralPrompt(false)}
170
+ />
171
+ )}
172
+ {showSuccessPrompt && (
173
+ <ActionPrompt
174
+ sentiment="success"
175
+ title="Payment successful"
176
+ description="Your money is on its way"
177
+ action={{ label: 'View details', onClick: fn() }}
178
+ onDismiss={() => setShowSuccessPrompt(false)}
179
+ />
180
+ )}
181
+ </>
182
+ );
183
+ },
184
+ };
@@ -0,0 +1,256 @@
1
+ import { Sentiment } from '../../common';
2
+ import { mockMatchMedia, render, screen } from '../../test-utils';
3
+ import { ActionPrompt, ActionPromptProps } from './ActionPrompt';
4
+ import { userEvent } from '@testing-library/user-event';
5
+
6
+ mockMatchMedia();
7
+
8
+ describe('ActionPrompt', () => {
9
+ const defaultProps: ActionPromptProps = {
10
+ title: 'Test Title',
11
+ action: {
12
+ label: 'Primary Action',
13
+ onClick: jest.fn(),
14
+ },
15
+ };
16
+
17
+ beforeEach(() => {
18
+ jest.clearAllMocks();
19
+ });
20
+
21
+ describe('Basic rendering', () => {
22
+ it('renders title', () => {
23
+ render(<ActionPrompt {...defaultProps} />);
24
+ expect(screen.getByText('Test Title')).toBeInTheDocument();
25
+ });
26
+
27
+ it('renders description when provided', () => {
28
+ render(<ActionPrompt {...defaultProps} description="Test description" />);
29
+ expect(screen.getByText('Test description')).toBeInTheDocument();
30
+ });
31
+ });
32
+
33
+ [
34
+ { sentiment: 'negative' as const, statusIconLabel: 'Error:' },
35
+ { sentiment: 'warning' as const, statusIconLabel: 'Warning:' },
36
+ { sentiment: 'neutral' as const, statusIconLabel: 'Information:' },
37
+ { sentiment: 'success' as const, statusIconLabel: 'Success:' },
38
+ { sentiment: 'proposition' as const, statusIconLabel: '' },
39
+ ].forEach(({ sentiment, statusIconLabel }) => {
40
+ describe(sentiment, () => {
41
+ if (statusIconLabel) {
42
+ it('should render StatusIcon', () => {
43
+ render(<ActionPrompt {...defaultProps} sentiment={sentiment} />);
44
+ expect(screen.getByLabelText(statusIconLabel)).toBeInTheDocument();
45
+ });
46
+ }
47
+ });
48
+ });
49
+
50
+ describe('Actions', () => {
51
+ it('renders primary action button with correct label', () => {
52
+ render(<ActionPrompt {...defaultProps} />);
53
+ expect(screen.getByText('Primary Action')).toBeInTheDocument();
54
+ });
55
+
56
+ it('calls primary action onClick when clicked', async () => {
57
+ const onClick = jest.fn();
58
+ const user = userEvent.setup();
59
+ render(
60
+ <ActionPrompt {...defaultProps} action={{ label: 'Primary Action', onClick }} />,
61
+ );
62
+ const button = screen.getByRole('button', { name: 'Primary Action' });
63
+ await user.click(button);
64
+ expect(onClick).toHaveBeenCalledTimes(1);
65
+ });
66
+
67
+ it('renders primary action as link when href is provided', () => {
68
+ render(
69
+ <ActionPrompt
70
+ {...defaultProps}
71
+ action={{ label: 'Primary Action', href: '/test-url' }}
72
+ />,
73
+ );
74
+ const link = screen.getByRole('link', { name: 'Primary Action' });
75
+ expect(link).toHaveAttribute('href', '/test-url');
76
+ });
77
+
78
+ it('renders secondary action when provided', () => {
79
+ render(
80
+ <ActionPrompt
81
+ {...defaultProps}
82
+ actionSecondary={{ label: 'Secondary Action', onClick: jest.fn() }}
83
+ />,
84
+ );
85
+ expect(screen.getByText('Secondary Action')).toBeInTheDocument();
86
+ });
87
+
88
+ it('calls secondary action onClick when clicked', async () => {
89
+ const onClick = jest.fn();
90
+ const user = userEvent.setup();
91
+ render(
92
+ <ActionPrompt {...defaultProps} actionSecondary={{ label: 'Secondary Action', onClick }} />,
93
+ );
94
+ const button = screen.getByRole('button', { name: 'Secondary Action' });
95
+ await user.click(button);
96
+ expect(onClick).toHaveBeenCalledTimes(1);
97
+ });
98
+
99
+ it('renders secondary action as link when href is provided', () => {
100
+ render(
101
+ <ActionPrompt
102
+ {...defaultProps}
103
+ actionSecondary={{ label: 'Secondary Action', href: '/secondary-url' }}
104
+ />,
105
+ );
106
+ const link = screen.getByRole('link', { name: 'Secondary Action' });
107
+ expect(link).toHaveAttribute('href', '/secondary-url');
108
+ });
109
+ });
110
+
111
+ describe('Media', () => {
112
+ describe('Image media', () => {
113
+ it('renders custom image when imgSrc is provided', () => {
114
+ render(
115
+ <ActionPrompt
116
+ {...defaultProps}
117
+ media={{ imgSrc: '/test-image.jpg', 'aria-label': 'Test image' }}
118
+ />,
119
+ );
120
+
121
+ const img = screen.getByRole('img', { name: 'Test image' });
122
+
123
+ expect(img).toBeInTheDocument();
124
+ expect(img).toHaveAttribute('src', '/test-image.jpg');
125
+ });
126
+
127
+ it('renders image with empty alt when aria-label is not provided', () => {
128
+ const { container } = render(
129
+ <ActionPrompt {...defaultProps} media={{ imgSrc: '/test-image.jpg' }} />,
130
+ );
131
+ const img = container.querySelector('img[src="/test-image.jpg"]');
132
+ expect(img).toHaveAttribute('alt', '');
133
+ });
134
+ });
135
+
136
+ describe('Avatar media', () => {
137
+ it('renders avatar with image', () => {
138
+ const { container } = render(
139
+ <ActionPrompt {...defaultProps} media={{ avatar: { imgSrc: '/avatar.jpg' } }} />,
140
+ );
141
+ const img = container.querySelector('img[src="/avatar.jpg"]');
142
+ expect(img).toBeInTheDocument();
143
+ expect(img).toHaveAttribute('src', '/avatar.jpg');
144
+ });
145
+
146
+ it('renders avatar with profile name', () => {
147
+ render(<ActionPrompt {...defaultProps} media={{ avatar: { profileName: 'John Doe' } }} />);
148
+ expect(screen.getByText('JD')).toBeInTheDocument();
149
+ });
150
+
151
+ it('renders avatar with custom asset', () => {
152
+ render(
153
+ <ActionPrompt
154
+ {...defaultProps}
155
+ media={{ avatar: { asset: <span data-testid="custom-icon">Icon</span> } }}
156
+ />,
157
+ );
158
+
159
+ expect(screen.getByTestId('custom-icon')).toBeInTheDocument();
160
+ });
161
+
162
+ it('renders avatar with badge', () => {
163
+ render(
164
+ <ActionPrompt
165
+ {...defaultProps}
166
+ media={{ avatar: { profileType: 'BUSINESS', badge: { flagCode: 'GB' } } }}
167
+ />,
168
+ );
169
+
170
+ expect(screen.getByText('Test Title')).toBeInTheDocument();
171
+ });
172
+
173
+ it('applies status badge for non-proposition sentiment when no badge is provided', () => {
174
+ render(
175
+ <ActionPrompt
176
+ {...defaultProps}
177
+ sentiment="success"
178
+ media={{ avatar: { profileType: 'PERSONAL' } }}
179
+ />,
180
+ );
181
+
182
+ expect(screen.getByText('Test Title')).toBeInTheDocument();
183
+ });
184
+
185
+ it('renders avatar for proposition sentiment when no badge is provided', () => {
186
+ render(
187
+ <ActionPrompt
188
+ {...defaultProps}
189
+ sentiment="proposition"
190
+ media={{ avatar: { profileType: 'PERSONAL' } }}
191
+ />,
192
+ );
193
+
194
+ expect(screen.getByText('Test Title')).toBeInTheDocument();
195
+ });
196
+ });
197
+
198
+ describe('Default media', () => {
199
+ it('renders GiftBox for proposition sentiment with no media', () => {
200
+ render(<ActionPrompt {...defaultProps} sentiment="proposition" />);
201
+ expect(screen.getByTestId('gift-box-icon')).toBeInTheDocument();
202
+ });
203
+
204
+ it('renders StatusIcon for non-proposition sentiment with no media', () => {
205
+ render(<ActionPrompt {...defaultProps} sentiment="success" />);
206
+ expect(screen.getByText('Test Title')).toBeInTheDocument();
207
+ });
208
+ });
209
+ });
210
+
211
+ describe('Two actions styling', () => {
212
+ it('applies two actions class when secondary action is provided', () => {
213
+ render(
214
+ <ActionPrompt
215
+ {...defaultProps}
216
+ actionSecondary={{ label: 'Secondary', onClick: jest.fn() }}
217
+ data-testid="prompt"
218
+ />,
219
+ );
220
+
221
+ expect(screen.getByTestId('prompt')).toHaveClass('wds-action-prompt--with-two-actions');
222
+ });
223
+
224
+ it('does not apply two actions class when only primary action is provided', () => {
225
+ render(<ActionPrompt {...defaultProps} data-testid="prompt" />);
226
+ expect(screen.getByTestId('prompt')).not.toHaveClass('wds-action-prompt--with-two-actions');
227
+ });
228
+ });
229
+
230
+ describe('Responsive behavior', () => {
231
+ it('renders buttons as block on mobile', () => {
232
+ // Mock mobile viewport
233
+ const mockMatchMediaFn = window.matchMedia as jest.Mock;
234
+ mockMatchMediaFn.mockImplementation((query: string) => ({
235
+ matches: query === '(max-width: 768px)',
236
+ media: query,
237
+ onchange: null,
238
+ addListener: jest.fn(),
239
+ removeListener: jest.fn(),
240
+ addEventListener: jest.fn(),
241
+ removeEventListener: jest.fn(),
242
+ dispatchEvent: jest.fn(),
243
+ }));
244
+
245
+ render(
246
+ <ActionPrompt
247
+ {...defaultProps}
248
+ actionSecondary={{ label: 'Secondary', onClick: jest.fn() }}
249
+ />,
250
+ );
251
+
252
+ expect(screen.getByText('Primary Action')).toBeInTheDocument();
253
+ expect(screen.getByText('Secondary')).toBeInTheDocument();
254
+ });
255
+ });
256
+ });
@@ -0,0 +1,129 @@
1
+ import { ReactNode } from 'react';
2
+ import { clsx } from 'clsx';
3
+
4
+ import StatusIcon from '../../statusIcon';
5
+ import Body from '../../body';
6
+ import Button from '../../button';
7
+ import { Breakpoint, Typography } from '../../common';
8
+ import AvatarView, { AvatarViewProps } from '../../avatarView';
9
+ import Image from '../../image';
10
+ import { ButtonProps } from '../../button/Button.types';
11
+ import { PrimitivePrompt, PrimitivePromptProps } from '../PrimitivePrompt';
12
+ import { BadgeAssetsProps } from '../../badge';
13
+ import { GiftBox } from '@transferwise/icons';
14
+ import { useScreenSize } from '../../common/hooks/useScreenSize';
15
+
16
+ export type ActionPromptProps = {
17
+ title: ReactNode;
18
+ description?: ReactNode;
19
+ media?: {
20
+ imgSrc?: string;
21
+ avatar?: Pick<AvatarViewProps, 'imgSrc' | 'profileName' | 'profileType'> & {
22
+ asset?: AvatarViewProps['children'];
23
+ badge?: Pick<BadgeAssetsProps, 'flagCode'>;
24
+ };
25
+ 'aria-label'?: string;
26
+ };
27
+ action: Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {
28
+ label: ButtonProps['children'];
29
+ };
30
+ actionSecondary?: Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {
31
+ label: ButtonProps['children'];
32
+ };
33
+ } & Pick<PrimitivePromptProps, 'id' | 'className' | 'data-testid' | 'sentiment' | 'onDismiss'>;
34
+
35
+ export const ActionPrompt = ({
36
+ sentiment = 'neutral',
37
+ title,
38
+ description,
39
+ onDismiss,
40
+ media,
41
+ action,
42
+ actionSecondary,
43
+ id,
44
+ className,
45
+ 'data-testid': testId,
46
+ }: ActionPromptProps) => {
47
+ const isMobile = !useScreenSize(Breakpoint.MEDIUM);
48
+
49
+ const renderMedia = () => {
50
+ if (media?.imgSrc) {
51
+ return (
52
+ <Image
53
+ src={media.imgSrc}
54
+ className="wds-action-prompt--media-image"
55
+ alt={media['aria-label'] ?? ''}
56
+ />
57
+ );
58
+ }
59
+ if (media?.avatar) {
60
+ const badge = media.avatar.badge
61
+ ? media.avatar.badge
62
+ : sentiment === 'proposition'
63
+ ? {}
64
+ : { status: sentiment };
65
+ return (
66
+ <AvatarView {...media.avatar} badge={badge} size={48}>
67
+ {media.avatar.asset}
68
+ </AvatarView>
69
+ );
70
+ }
71
+ return sentiment === 'proposition' ? (
72
+ <AvatarView size={48}>
73
+ <GiftBox />
74
+ </AvatarView>
75
+ ) : (
76
+ <StatusIcon size={48} sentiment={sentiment} />
77
+ );
78
+ };
79
+
80
+ return (
81
+ <PrimitivePrompt
82
+ id={id}
83
+ sentiment={sentiment}
84
+ data-testid={testId}
85
+ className={clsx(
86
+ 'wds-action-prompt',
87
+ { 'wds-action-prompt--with-two-actions': !!actionSecondary },
88
+ className,
89
+ )}
90
+ media={renderMedia()}
91
+ actions={
92
+ <>
93
+ {actionSecondary && (
94
+ // @ts-expect-error onClick type mismatch
95
+ <Button
96
+ v2
97
+ size="md"
98
+ priority="secondary"
99
+ href={actionSecondary.href}
100
+ block={isMobile}
101
+ onClick={actionSecondary?.onClick}
102
+ >
103
+ {actionSecondary.label}
104
+ </Button>
105
+ )}
106
+ {/* @ts-expect-error onClick type mismatch */}
107
+ <Button
108
+ v2
109
+ size="md"
110
+ priority="primary"
111
+ href={action.href}
112
+ block={isMobile}
113
+ onClick={action.onClick}
114
+ >
115
+ {action.label}
116
+ </Button>
117
+ </>
118
+ }
119
+ onDismiss={onDismiss}
120
+ >
121
+ <div className={clsx('d-flex', 'flex-column', 'justify-content-center')}>
122
+ <Body type={Typography.BODY_LARGE_BOLD}>{title}</Body>
123
+ {description && <Body>{description}</Body>}
124
+ </div>
125
+ </PrimitivePrompt>
126
+ );
127
+ };
128
+
129
+ export default ActionPrompt;
@@ -0,0 +1,2 @@
1
+ export type { ActionPromptProps } from './ActionPrompt';
2
+ export { ActionPrompt } from './ActionPrompt';
@@ -30,13 +30,6 @@ describe('InlinePrompt', () => {
30
30
  { sentiment: 'proposition' as const, statusIconLabel: '' },
31
31
  ].forEach(({ sentiment, statusIconLabel }) => {
32
32
  describe(sentiment, () => {
33
- it('should apply correct styles', () => {
34
- render(<InlinePrompt {...defaultProps} sentiment={sentiment} />);
35
- expect(screen.getByText('Prompt message').parentElement?.parentElement).toHaveClass(
36
- `wds-prompt--${sentiment === Sentiment.POSITIVE ? 'success' : sentiment}`,
37
- );
38
- });
39
-
40
33
  if (statusIconLabel) {
41
34
  it('should render StatusIcon', () => {
42
35
  render(<InlinePrompt {...defaultProps} sentiment={sentiment} />);
@@ -113,39 +106,11 @@ describe('InlinePrompt', () => {
113
106
  });
114
107
  });
115
108
 
116
- it('applies custom className, id, and data-testid', () => {
117
- render(
118
- <InlinePrompt
119
- {...defaultProps}
120
- className="custom-class"
121
- id="custom-id"
122
- data-testid="custom-test"
123
- />,
124
- );
109
+ it('forwards props to PrimitivePrompt', () => {
110
+ render(<InlinePrompt {...defaultProps} className="custom-class" data-testid="custom-test" />);
125
111
  const el = screen.getByTestId('custom-test');
126
112
  expect(el).toHaveClass('custom-class');
127
- expect(el).toHaveAttribute('id', 'custom-id');
128
- });
129
-
130
- describe('SentimentSurface integration', () => {
131
- it('maps positive sentiment to success for SentimentSurface', () => {
132
- render(
133
- <InlinePrompt {...defaultProps} sentiment={Sentiment.POSITIVE} data-testid="prompt" />,
134
- );
135
- const el = screen.getByTestId('prompt');
136
- // The component should have both the original class and the SentimentSurface class
137
- expect(el).toHaveClass('wds-prompt--success');
138
- expect(el).toHaveClass('wds-sentiment-surface');
139
- });
140
-
141
- it('passes through other sentiments unchanged', () => {
142
- render(
143
- <InlinePrompt {...defaultProps} sentiment={Sentiment.NEGATIVE} data-testid="prompt" />,
144
- );
145
- const el = screen.getByTestId('prompt');
146
- expect(el).toHaveClass('wds-prompt--negative');
147
- expect(el).toHaveClass('wds-sentiment-surface');
148
- });
113
+ expect(el).toBeInTheDocument();
149
114
  });
150
115
 
151
116
  describe('width', () => {
@@ -1,7 +1,9 @@
1
1
  .wds-prompt {
2
2
  border-radius: 10px;
3
- border-radius: var(--radius-small);
3
+ border-radius: var(--Prompt-border-radius, var(--radius-small));
4
4
  display: flex;
5
+ gap: 16px;
6
+ gap: var(--Prompt-gap, var(--size-16));
5
7
  word-wrap: break-word;
6
8
  padding: 8px;
7
9
  padding: var(--Prompt-padding, var(--padding-x-small));
@@ -17,6 +19,9 @@
17
19
  grid-template-columns: auto 1fr;
18
20
  width: 100%;
19
21
  }
22
+ .wds-prompt__content-wrapper--with-dismiss {
23
+ grid-template-columns: auto 1fr auto;
24
+ }
20
25
  .wds-prompt__media-wrapper {
21
26
  align-self: flex-start;
22
27
  padding-top: calc(4px - 1px);
@@ -32,10 +37,14 @@
32
37
  gap: 8px;
33
38
  gap: var(--Prompt-actions-gap, var(--size-8));
34
39
  grid-column-start: 2;
40
+ grid-column-end: 3;
35
41
  }
36
- @media (max-width: 991px) {
42
+ @media (max-width: 767px) {
37
43
  .wds-prompt__actions-wrapper {
38
44
  grid-column: span 2;
39
45
  width: 100%;
40
46
  }
47
+ .wds-prompt__content-wrapper--with-dismiss .wds-prompt__actions-wrapper {
48
+ grid-column: span 3;
49
+ }
41
50
  }