@transferwise/components 46.1.1 → 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 (41) hide show
  1. package/build/index.esm.js +38 -15
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +38 -15
  4. package/build/index.js.map +1 -1
  5. package/build/main.css +26 -13
  6. package/build/styles/common/card/Card.css +0 -4
  7. package/build/styles/criticalBanner/CriticalCommsBanner.css +0 -1
  8. package/build/styles/flowNavigation/FlowNavigation.css +26 -4
  9. package/build/styles/inputs/Input.css +0 -1
  10. package/build/styles/inputs/TextArea.css +0 -1
  11. package/build/styles/main.css +26 -13
  12. package/build/styles/nudge/Nudge.css +0 -3
  13. package/build/types/accordion/Accordion.d.ts +1 -0
  14. package/build/types/accordion/Accordion.d.ts.map +1 -1
  15. package/build/types/accordion/AccordionItem/AccordionItem.d.ts +3 -0
  16. package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
  17. package/build/types/inputs/SelectInput.d.ts +6 -3
  18. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  19. package/build/types/inputs/_BottomSheet.d.ts +2 -1
  20. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  21. package/build/types/inputs/_Popover.d.ts +2 -1
  22. package/build/types/inputs/_Popover.d.ts.map +1 -1
  23. package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
  24. package/package.json +4 -4
  25. package/src/accordion/Accordion.story.tsx +8 -0
  26. package/src/accordion/Accordion.tsx +2 -0
  27. package/src/accordion/AccordionItem/AccordionItem.tsx +5 -0
  28. package/src/common/card/Card.css +0 -4
  29. package/src/criticalBanner/CriticalCommsBanner.css +0 -1
  30. package/src/flowNavigation/FlowNavigation.css +26 -4
  31. package/src/inputs/Input.css +0 -1
  32. package/src/inputs/SelectInput.spec.tsx +52 -3
  33. package/src/inputs/SelectInput.story.tsx +1 -1
  34. package/src/inputs/SelectInput.tsx +30 -15
  35. package/src/inputs/TextArea.css +0 -1
  36. package/src/inputs/_BottomSheet.tsx +3 -0
  37. package/src/inputs/_Popover.tsx +3 -0
  38. package/src/main.css +26 -13
  39. package/src/moneyInput/MoneyInput.js +3 -1
  40. package/src/moneyInput/MoneyInput.spec.js +4 -1
  41. package/src/nudge/Nudge.css +0 -3
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
  })]