@transferwise/components 46.1.0 → 46.2.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 (177) hide show
  1. package/README.md +3 -5
  2. package/build/index.esm.js +44 -23
  3. package/build/index.esm.js.map +1 -1
  4. package/build/index.js +44 -23
  5. package/build/index.js.map +1 -1
  6. package/build/main.css +5494 -1
  7. package/build/styles/accordion/Accordion.css +60 -1
  8. package/build/styles/actionButton/ActionButton.css +53 -1
  9. package/build/styles/avatar/Avatar.css +205 -1
  10. package/build/styles/badge/Badge.css +68 -1
  11. package/build/styles/button/Button.css +20 -1
  12. package/build/styles/card/Card.css +100 -1
  13. package/build/styles/checkboxButton/CheckboxButton.css +24 -1
  14. package/build/styles/chips/Chip.css +190 -1
  15. package/build/styles/circularButton/CircularButton.css +211 -1
  16. package/build/styles/common/Option/Option.css +100 -1
  17. package/build/styles/common/RadioButton/RadioButton.css +4 -1
  18. package/build/styles/common/bottomSheet/BottomSheet.css +53 -1
  19. package/build/styles/common/card/Card.css +49 -1
  20. package/build/styles/common/closeButton/CloseButton.css +79 -1
  21. package/build/styles/common/panel/Panel.css +73 -1
  22. package/build/styles/criticalBanner/CriticalCommsBanner.css +76 -1
  23. package/build/styles/dateInput/DateInput.css +3 -1
  24. package/build/styles/dateLookup/DateLookup.css +98 -1
  25. package/build/styles/dateLookup/dateTrigger/DateTrigger.css +68 -1
  26. package/build/styles/decision/Decision.css +93 -1
  27. package/build/styles/definitionList/DefinitionList.css +53 -1
  28. package/build/styles/dimmer/Dimmer.css +70 -1
  29. package/build/styles/drawer/Drawer.css +100 -1
  30. package/build/styles/dropFade/DropFade.css +19 -1
  31. package/build/styles/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +5 -1
  32. package/build/styles/emphasis/Emphasis.css +31 -1
  33. package/build/styles/flowNavigation/FlowNavigation.css +72 -1
  34. package/build/styles/flowNavigation/animatedLabel/AnimatedLabel.css +21 -1
  35. package/build/styles/flowNavigation/backButton/BackButton.css +32 -1
  36. package/build/styles/header/Header.css +28 -1
  37. package/build/styles/image/Image.css +13 -1
  38. package/build/styles/info/Info.css +32 -1
  39. package/build/styles/inputs/Input.css +105 -1
  40. package/build/styles/inputs/InputGroup.css +62 -1
  41. package/build/styles/inputs/SelectInput.css +374 -1
  42. package/build/styles/inputs/TextArea.css +109 -1
  43. package/build/styles/instructionsList/InstructionsList.css +22 -1
  44. package/build/styles/link/Link.css +15 -1
  45. package/build/styles/listItem/ListItem.css +6 -1
  46. package/build/styles/loader/Loader.css +313 -1
  47. package/build/styles/logo/Logo.css +26 -1
  48. package/build/styles/main.css +5494 -1
  49. package/build/styles/modal/Modal.css +155 -1
  50. package/build/styles/moneyInput/MoneyInput.css +66 -1
  51. package/build/styles/navigationOption/NavigationOption.css +69 -1
  52. package/build/styles/navigationOptionsList/NavigationOptionsList.css +13 -1
  53. package/build/styles/nudge/Nudge.css +179 -1
  54. package/build/styles/overlayHeader/OverlayHeader.css +15 -1
  55. package/build/styles/phoneNumberInput/PhoneNumberInput.css +23 -1
  56. package/build/styles/popover/Popover.css +43 -1
  57. package/build/styles/progress/Progress.css +43 -1
  58. package/build/styles/progressBar/ProgressBar.css +14 -1
  59. package/build/styles/promoCard/PromoCard.css +186 -1
  60. package/build/styles/section/Section.css +10 -1
  61. package/build/styles/select/Select.css +309 -1
  62. package/build/styles/slidingPanel/SlidingPanel.css +105 -1
  63. package/build/styles/snackbar/Snackbar.css +93 -1
  64. package/build/styles/statusIcon/StatusIcon.css +78 -1
  65. package/build/styles/stepper/Stepper.css +108 -1
  66. package/build/styles/summary/Summary.css +81 -1
  67. package/build/styles/switch/Switch.css +68 -1
  68. package/build/styles/tabs/Tabs.css +121 -1
  69. package/build/styles/tile/Tile.css +55 -1
  70. package/build/styles/tooltip/Tooltip.css +50 -1
  71. package/build/styles/typeahead/Typeahead.css +183 -1
  72. package/build/styles/typeahead/typeaheadOption/TypeaheadOption.css +9 -1
  73. package/build/styles/upload/Upload.css +15 -1
  74. package/build/styles/uploadInput/UploadInput.css +71 -1
  75. package/build/styles/uploadInput/uploadButton/UploadButton.css +49 -1
  76. package/build/styles/uploadInput/uploadItem/UploadItem.css +74 -1
  77. package/build/types/accordion/Accordion.d.ts +1 -0
  78. package/build/types/accordion/Accordion.d.ts.map +1 -1
  79. package/build/types/accordion/AccordionItem/AccordionItem.d.ts +3 -0
  80. package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
  81. package/build/types/inputs/SelectInput.d.ts +6 -3
  82. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  83. package/build/types/inputs/_BottomSheet.d.ts +2 -1
  84. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  85. package/build/types/inputs/_Popover.d.ts +2 -1
  86. package/build/types/inputs/_Popover.d.ts.map +1 -1
  87. package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
  88. package/build/types/select/option/Option.d.ts.map +1 -1
  89. package/build/types/typeahead/util/highlight.d.ts +1 -1
  90. package/build/types/typeahead/util/highlight.d.ts.map +1 -1
  91. package/package.json +5 -11
  92. package/src/accordion/Accordion.css +60 -1
  93. package/src/accordion/Accordion.story.tsx +8 -0
  94. package/src/accordion/Accordion.tsx +2 -0
  95. package/src/accordion/AccordionItem/AccordionItem.tsx +5 -0
  96. package/src/actionButton/ActionButton.css +53 -1
  97. package/src/avatar/Avatar.css +205 -1
  98. package/src/badge/Badge.css +68 -1
  99. package/src/button/Button.css +20 -1
  100. package/src/card/Card.css +100 -1
  101. package/src/checkboxButton/CheckboxButton.css +24 -1
  102. package/src/chips/Chip.css +190 -1
  103. package/src/circularButton/CircularButton.css +211 -1
  104. package/src/common/Option/Option.css +100 -1
  105. package/src/common/RadioButton/RadioButton.css +4 -1
  106. package/src/common/bottomSheet/BottomSheet.css +53 -1
  107. package/src/common/card/Card.css +49 -1
  108. package/src/common/closeButton/CloseButton.css +79 -1
  109. package/src/common/panel/Panel.css +73 -1
  110. package/src/criticalBanner/CriticalCommsBanner.css +76 -1
  111. package/src/dateInput/DateInput.css +3 -1
  112. package/src/dateLookup/DateLookup.css +98 -1
  113. package/src/dateLookup/DateLookup.story.js +12 -8
  114. package/src/dateLookup/dateTrigger/DateTrigger.css +68 -1
  115. package/src/decision/Decision.css +93 -1
  116. package/src/definitionList/DefinitionList.css +53 -1
  117. package/src/dimmer/Dimmer.css +70 -1
  118. package/src/drawer/Drawer.css +100 -1
  119. package/src/dropFade/DropFade.css +19 -1
  120. package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +5 -1
  121. package/src/emphasis/Emphasis.css +31 -1
  122. package/src/flowNavigation/FlowNavigation.css +72 -1
  123. package/src/flowNavigation/animatedLabel/AnimatedLabel.css +21 -1
  124. package/src/flowNavigation/backButton/BackButton.css +32 -1
  125. package/src/header/Header.css +28 -1
  126. package/src/image/Image.css +13 -1
  127. package/src/info/Info.css +32 -1
  128. package/src/inputs/Input.css +105 -1
  129. package/src/inputs/InputGroup.css +62 -1
  130. package/src/inputs/SelectInput.css +374 -1
  131. package/src/inputs/SelectInput.spec.tsx +52 -3
  132. package/src/inputs/SelectInput.story.tsx +1 -1
  133. package/src/inputs/SelectInput.tsx +30 -15
  134. package/src/inputs/TextArea.css +109 -1
  135. package/src/inputs/_BottomSheet.tsx +3 -0
  136. package/src/inputs/_Popover.tsx +3 -0
  137. package/src/instructionsList/InstructionsList.css +22 -1
  138. package/src/link/Link.css +15 -1
  139. package/src/listItem/ListItem.css +6 -1
  140. package/src/loader/Loader.css +313 -1
  141. package/src/logo/Logo.css +26 -1
  142. package/src/main.css +5494 -1
  143. package/src/modal/Modal.css +155 -1
  144. package/src/moneyInput/MoneyInput.css +66 -1
  145. package/src/moneyInput/MoneyInput.js +3 -1
  146. package/src/moneyInput/MoneyInput.spec.js +4 -1
  147. package/src/navigationOption/NavigationOption.css +69 -1
  148. package/src/navigationOptionsList/NavigationOptionsList.css +13 -1
  149. package/src/nudge/Nudge.css +179 -1
  150. package/src/overlayHeader/OverlayHeader.css +15 -1
  151. package/src/phoneNumberInput/PhoneNumberInput.css +23 -1
  152. package/src/popover/Popover.css +43 -1
  153. package/src/progress/Progress.css +43 -1
  154. package/src/progressBar/ProgressBar.css +14 -1
  155. package/src/promoCard/PromoCard.css +186 -1
  156. package/src/section/Section.css +10 -1
  157. package/src/select/Select.css +309 -1
  158. package/src/select/Select.less +1 -8
  159. package/src/select/option/Option.spec.js +3 -21
  160. package/src/select/option/Option.tsx +2 -7
  161. package/src/slidingPanel/SlidingPanel.css +105 -1
  162. package/src/snackbar/Snackbar.css +93 -1
  163. package/src/statusIcon/StatusIcon.css +78 -1
  164. package/src/stepper/Stepper.css +108 -1
  165. package/src/summary/Summary.css +81 -1
  166. package/src/switch/Switch.css +68 -1
  167. package/src/tabs/Tabs.css +121 -1
  168. package/src/tile/Tile.css +55 -1
  169. package/src/tooltip/Tooltip.css +50 -1
  170. package/src/typeahead/Typeahead.css +183 -1
  171. package/src/typeahead/typeaheadOption/TypeaheadOption.css +9 -1
  172. package/src/typeahead/typeaheadOption/TypeaheadOption.js +3 -3
  173. package/src/typeahead/util/highlight.js +1 -1
  174. package/src/upload/Upload.css +15 -1
  175. package/src/uploadInput/UploadInput.css +71 -1
  176. package/src/uploadInput/uploadButton/UploadButton.css +49 -1
  177. package/src/uploadInput/uploadItem/UploadItem.css +74 -1
package/build/index.js CHANGED
@@ -675,6 +675,7 @@ const AccordionItem = ({
675
675
  'aria-label': ariaLabel,
676
676
  id,
677
677
  title,
678
+ subtitle,
678
679
  content,
679
680
  onClick,
680
681
  open,
@@ -696,6 +697,7 @@ const AccordionItem = ({
696
697
  as: "button",
697
698
  media: iconElement,
698
699
  title: title,
700
+ content: subtitle,
699
701
  button: /*#__PURE__*/jsxRuntime.jsx(Chevron, {
700
702
  orientation: open ? exports.Position.TOP : exports.Position.BOTTOM,
701
703
  size: exports.Size.MEDIUM
@@ -745,6 +747,7 @@ const Accordion = ({
745
747
  children: items.map((item, index) => /*#__PURE__*/jsxRuntime.jsx(AccordionItem, {
746
748
  open: itemsOpen[index],
747
749
  title: item.title,
750
+ subtitle: item.subtitle,
748
751
  content: item.content,
749
752
  icon: item.icon,
750
753
  onClick: () => handleOnClick(index)
@@ -6511,7 +6514,8 @@ function BottomSheet({
6511
6514
  initialFocusRef,
6512
6515
  padding = 'md',
6513
6516
  children,
6514
- onClose
6517
+ onClose,
6518
+ onCloseEnd
6515
6519
  }) {
6516
6520
  const {
6517
6521
  refs,
@@ -6550,6 +6554,7 @@ function BottomSheet({
6550
6554
  beforeEnter: () => {
6551
6555
  setFloatingKey(prev => prev + 1);
6552
6556
  },
6557
+ afterLeave: onCloseEnd,
6553
6558
  children: /*#__PURE__*/jsxRuntime.jsxs(FocusBoundary, {
6554
6559
  children: [/*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
6555
6560
  enter: "np-bottom-sheet-v2-backdrop-container--enter",
@@ -6640,7 +6645,8 @@ function Popover({
6640
6645
  size = 'md',
6641
6646
  padding = 'md',
6642
6647
  children,
6643
- onClose
6648
+ onClose,
6649
+ onCloseEnd
6644
6650
  }) {
6645
6651
  const {
6646
6652
  refs,
@@ -6697,6 +6703,7 @@ function Popover({
6697
6703
  beforeEnter: () => {
6698
6704
  setFloatingKey(prev => prev + 1);
6699
6705
  },
6706
+ afterLeave: onCloseEnd,
6700
6707
  children: /*#__PURE__*/jsxRuntime.jsx(FocusBoundary, {
6701
6708
  children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
6702
6709
  context: context,
@@ -6850,6 +6857,7 @@ function SelectInputClearButton({
6850
6857
  })
6851
6858
  });
6852
6859
  }
6860
+ const noop = () => {};
6853
6861
  function SelectInput({
6854
6862
  name,
6855
6863
  placeholder,
@@ -6865,11 +6873,19 @@ function SelectInput({
6865
6873
  disabled,
6866
6874
  size = 'md',
6867
6875
  className,
6876
+ onFilterChange = noop,
6868
6877
  onChange,
6869
- onSearchChange,
6870
6878
  onClear
6871
6879
  }) {
6872
6880
  const [open, setOpen] = React.useState(false);
6881
+ const [filterQuery, _setFilterQuery] = React.useState('');
6882
+ const setFilterQuery = useEffectEvent(query => {
6883
+ _setFilterQuery(query);
6884
+ onFilterChange({
6885
+ query,
6886
+ queryNormalized: query ? searchableString(query) : null
6887
+ });
6888
+ });
6873
6889
  const triggerRef = React.useRef(null);
6874
6890
  const screenSm = useScreenSize(exports.Breakpoint.SMALL);
6875
6891
  const OptionsOverlay = screenSm ? Popover : BottomSheet;
@@ -6936,6 +6952,11 @@ function SelectInput({
6936
6952
  onClose: () => {
6937
6953
  setOpen(false);
6938
6954
  },
6955
+ onCloseEnd: () => {
6956
+ if (filterQuery !== '') {
6957
+ setFilterQuery('');
6958
+ }
6959
+ },
6939
6960
  children: /*#__PURE__*/jsxRuntime.jsx(SelectInputOptions, {
6940
6961
  items: items,
6941
6962
  renderValue: renderValue,
@@ -6944,7 +6965,8 @@ function SelectInput({
6944
6965
  filterPlaceholder: filterPlaceholder,
6945
6966
  searchInputRef: searchInputRef,
6946
6967
  listboxRef: listboxRef,
6947
- onSearchChange: onSearchChange
6968
+ filterQuery: filterQuery,
6969
+ onFilterChange: setFilterQuery
6948
6970
  })
6949
6971
  })
6950
6972
  });
@@ -7015,17 +7037,17 @@ function SelectInputOptions({
7015
7037
  filterPlaceholder,
7016
7038
  searchInputRef,
7017
7039
  listboxRef,
7018
- onSearchChange
7040
+ filterQuery,
7041
+ onFilterChange
7019
7042
  }) {
7020
7043
  const intl = reactIntl.useIntl();
7021
7044
  const controllerRef = filterable ? searchInputRef : listboxRef;
7022
- const [query, setQuery] = React.useState('');
7023
7045
  const needle = React.useMemo(() => {
7024
7046
  if (filterable) {
7025
- return query ? searchableString(query) : null;
7047
+ return filterQuery ? searchableString(filterQuery) : null;
7026
7048
  }
7027
7049
  return undefined;
7028
- }, [filterable, query]);
7050
+ }, [filterQuery, filterable]);
7029
7051
  const resultsEmpty = needle != null && filterSelectInputItems(items, needle).length === 0;
7030
7052
  const listboxContainerRef = React.useRef(null);
7031
7053
  React.useEffect(() => {
@@ -7055,7 +7077,7 @@ function SelectInputOptions({
7055
7077
  ref: searchInputRef,
7056
7078
  shape: "rectangle",
7057
7079
  placeholder: filterPlaceholder,
7058
- value: query,
7080
+ value: filterQuery,
7059
7081
  "aria-controls": listboxId,
7060
7082
  "aria-describedby": showStatus ? statusId : undefined,
7061
7083
  onKeyDown: event => {
@@ -7066,10 +7088,7 @@ function SelectInputOptions({
7066
7088
  }
7067
7089
  },
7068
7090
  onChange: event => {
7069
- setQuery(event.currentTarget.value);
7070
- if (onSearchChange) {
7071
- onSearchChange(event.currentTarget.value);
7072
- }
7091
+ onFilterChange(event.currentTarget.value);
7073
7092
  }
7074
7093
  })
7075
7094
  }) : null, /*#__PURE__*/jsxRuntime.jsxs("section", {
@@ -7108,7 +7127,7 @@ function SelectInputOptions({
7108
7127
  },
7109
7128
  children: renderFooter({
7110
7129
  resultsEmpty,
7111
- normalizedQuery: needle
7130
+ queryNormalized: needle
7112
7131
  })
7113
7132
  })
7114
7133
  }) : null]
@@ -8120,7 +8139,11 @@ class MoneyInput extends React.Component {
8120
8139
  disabled: disabled,
8121
8140
  size: size,
8122
8141
  onChange: this.handleSelectChange,
8123
- onSearchChange: this.handleSearchChange,
8142
+ onFilterChange: ({
8143
+ queryNormalized
8144
+ }) => {
8145
+ this.handleSearchChange(queryNormalized ?? '');
8146
+ },
8124
8147
  ...selectProps
8125
8148
  })
8126
8149
  })]
@@ -10613,7 +10636,6 @@ var messages$2 = reactIntl.defineMessages({
10613
10636
  }
10614
10637
  });
10615
10638
 
10616
- // Option.tsx NEW
10617
10639
  function Option$1({
10618
10640
  label,
10619
10641
  currency = '',
@@ -10626,13 +10648,12 @@ function Option$1({
10626
10648
  const {
10627
10649
  isModern
10628
10650
  } = componentsTheming.useTheme();
10629
- const style = classes => classes.map(className => classNames[className] || className).join(' ');
10630
- const currencyClassNames = currency ? style(['currency-flag', `currency-flag-${currency.toLowerCase()}`]) : undefined;
10631
10651
  const iconElement = icon ? /*#__PURE__*/React.cloneElement(icon, {
10632
10652
  size: 24,
10633
10653
  className: 'tw-icon'
10634
- }) : currency && /*#__PURE__*/jsxRuntime.jsx("i", {
10635
- className: currencyClassNames
10654
+ }) : currency && /*#__PURE__*/jsxRuntime.jsx(art.Flag, {
10655
+ code: currency.toLowerCase(),
10656
+ intrinsicSize: 24
10636
10657
  });
10637
10658
  const titleAndNoteElement = /*#__PURE__*/jsxRuntime.jsxs(Body, {
10638
10659
  as: "span",
@@ -12505,7 +12526,7 @@ TypeaheadInput.defaultProps = {
12505
12526
  selected: []
12506
12527
  };
12507
12528
 
12508
- function hightlight(value, query) {
12529
+ function highlight(value, query) {
12509
12530
  if (value && query) {
12510
12531
  const highlightStart = value.toUpperCase().indexOf(query.trim().toUpperCase());
12511
12532
  const highlightEnd = highlightStart + query.trim().length;
@@ -12545,13 +12566,13 @@ const Option = props => {
12545
12566
  tabIndex: -1,
12546
12567
  onClick: onClick,
12547
12568
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
12548
- children: hightlight(label, query)
12569
+ children: highlight(label, query)
12549
12570
  }), note && /*#__PURE__*/jsxRuntime.jsx("span", {
12550
12571
  className: "np-text-body-default m-l-1",
12551
12572
  children: note
12552
12573
  }), secondary && /*#__PURE__*/jsxRuntime.jsx("span", {
12553
12574
  className: "np-text-body-default text-ellipsis",
12554
- children: hightlight(secondary, query)
12575
+ children: highlight(secondary, query)
12555
12576
  })]
12556
12577
  })
12557
12578
  });