@transferwise/components 45.21.3 → 45.22.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 (50) hide show
  1. package/build/index.esm.js +90 -76
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +90 -76
  4. package/build/index.js.map +1 -1
  5. package/build/main.css +1 -1
  6. package/build/styles/flowNavigation/FlowNavigation.css +1 -1
  7. package/build/styles/flowNavigation/animatedLabel/AnimatedLabel.css +1 -1
  8. package/build/styles/inputs/SelectInput.css +1 -1
  9. package/build/styles/main.css +1 -1
  10. package/build/styles/overlayHeader/OverlayHeader.css +1 -1
  11. package/build/types/common/flowHeader/FlowHeader.d.ts.map +1 -1
  12. package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
  13. package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts +1 -2
  14. package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts.map +1 -1
  15. package/build/types/flowNavigation/backButton/BackButton.d.ts +10 -11
  16. package/build/types/flowNavigation/backButton/BackButton.d.ts.map +1 -1
  17. package/build/types/inputs/SelectInput.d.ts +5 -1
  18. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  19. package/build/types/overlayHeader/OverlayHeader.d.ts.map +1 -1
  20. package/package.json +1 -1
  21. package/src/common/flowHeader/FlowHeader.tsx +4 -22
  22. package/src/common/flowHeader/__snapshots__/FlowHeader.spec.js.snap +6 -22
  23. package/src/flowNavigation/FlowNavigation.css +1 -1
  24. package/src/flowNavigation/FlowNavigation.less +0 -9
  25. package/src/flowNavigation/FlowNavigation.spec.js +3 -3
  26. package/src/flowNavigation/FlowNavigation.story.js +22 -189
  27. package/src/flowNavigation/FlowNavigation.tsx +22 -27
  28. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +18 -26
  29. package/src/flowNavigation/animatedLabel/AnimatedLabel.css +1 -1
  30. package/src/flowNavigation/animatedLabel/AnimatedLabel.less +0 -6
  31. package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +7 -21
  32. package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +8 -17
  33. package/src/flowNavigation/animatedLabel/__snapshots__/AnimatedLabel.spec.js.snap +4 -4
  34. package/src/flowNavigation/backButton/BackButton.js +14 -9
  35. package/src/flowNavigation/backButton/BackButton.spec.js +3 -2
  36. package/src/flowNavigation/backButton/__snapshots__/BackButton.spec.js.snap +28 -21
  37. package/src/inputs/SelectInput.css +1 -1
  38. package/src/inputs/SelectInput.less +7 -10
  39. package/src/inputs/SelectInput.spec.tsx +40 -0
  40. package/src/inputs/SelectInput.story.tsx +18 -0
  41. package/src/inputs/SelectInput.tsx +46 -12
  42. package/src/inputs/_BottomSheet.less +1 -1
  43. package/src/inputs/_Popover.less +1 -0
  44. package/src/main.css +1 -1
  45. package/src/overlayHeader/OverlayHeader.css +1 -1
  46. package/src/overlayHeader/OverlayHeader.js +6 -4
  47. package/src/overlayHeader/OverlayHeader.less +0 -8
  48. package/src/overlayHeader/OverlayHeader.spec.js +1 -1
  49. package/src/overlayHeader/__snapshots__/OverlayHeader.spec.js.snap +10 -14
  50. package/src/flowNavigation/animatedLabel/AnimatedLabel.story.js +0 -22
@@ -5396,19 +5396,8 @@ const FlowHeader = /*#__PURE__*/React.forwardRef(({
5396
5396
  const isVertical = layout === Layout$1.VERTICAL;
5397
5397
  return /*#__PURE__*/jsxs("div", {
5398
5398
  ref: reference,
5399
- className: classNames('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', className),
5400
- children: [/*#__PURE__*/jsx("div", {
5401
- className: classNames('np-flow-header__left', {
5402
- 'flex__item--8': isVertical
5403
- }),
5404
- children: leftContent
5405
- }), /*#__PURE__*/jsx("div", {
5406
- className: classNames('align-items-center', 'd-flex', 'np-flow-header__right', 'justify-content-end', {
5407
- 'flex__item--4 ': isVertical,
5408
- 'order-2': !isVertical
5409
- }),
5410
- children: rightContent
5411
- }), /*#__PURE__*/jsx("div", {
5399
+ className: classNames('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', 'justify-content-between', 'flex__item--12', className),
5400
+ children: [leftContent, rightContent, /*#__PURE__*/jsx("div", {
5412
5401
  className: classNames('align-items-center', 'd-flex', 'justify-content-center', {
5413
5402
  'flex__item--12': isVertical,
5414
5403
  'order-1 flex-grow-1': !isVertical
@@ -5711,19 +5700,16 @@ var messages$5 = defineMessages({
5711
5700
  const AnimatedLabel = ({
5712
5701
  activeLabel,
5713
5702
  className,
5714
- labels,
5715
- 'aria-label': ariaLabel
5703
+ labels
5716
5704
  }) => {
5717
- const numberLabels = labels.length - 1;
5718
- return /*#__PURE__*/jsx("div", {
5719
- "aria-label": ariaLabel,
5720
- className: classNames('np-animated-label', 'np-text-body-large-bold', className),
5705
+ return /*#__PURE__*/jsx(Body, {
5706
+ type: Typography.BODY_LARGE_BOLD,
5707
+ className: classNames('np-animated-label', className),
5721
5708
  children: labels.map((label, index) => {
5722
5709
  const nextLabel = index - 1;
5723
5710
  return /*#__PURE__*/jsx("div", {
5724
- className: classNames('text-xs-left', {
5725
- 'np-animated-label--in': index === activeLabel,
5726
- 'np-animated-label--out': nextLabel === activeLabel && nextLabel !== numberLabels
5711
+ className: classNames('text-xs-center', {
5712
+ 'np-animated-label--in text-ellipsis': index === activeLabel
5727
5713
  }),
5728
5714
  children: label
5729
5715
  }, nextLabel);
@@ -5732,18 +5718,24 @@ const AnimatedLabel = ({
5732
5718
  };
5733
5719
 
5734
5720
  const BackButton = ({
5735
- label,
5736
5721
  className,
5737
- onClick
5738
- }) => /*#__PURE__*/jsxs("button", {
5739
- type: "button",
5740
- className: classNames('np-back-button', 'align-items-center', 'btn-unstyled', className),
5741
- onClick: onClick,
5742
- children: [/*#__PURE__*/jsx(ArrowLeft, {
5743
- size: 24
5744
- }), label]
5722
+ onClick,
5723
+ 'aria-label': ariaLabel
5724
+ }) => /*#__PURE__*/jsx(Avatar, {
5725
+ type: AvatarType.ICON,
5726
+ size: 40,
5727
+ children: /*#__PURE__*/jsx("button", {
5728
+ type: "button",
5729
+ "aria-label": ariaLabel,
5730
+ className: classNames('np-back-button', 'btn-unstyled', className),
5731
+ onClick: onClick,
5732
+ children: /*#__PURE__*/jsx(ArrowLeft, {
5733
+ size: 24
5734
+ })
5735
+ })
5745
5736
  });
5746
5737
  BackButton.propTypes = {
5738
+ 'aria-label': PropTypes.string.isRequired,
5747
5739
  className: PropTypes.string,
5748
5740
  label: PropTypes.element,
5749
5741
  onClick: PropTypes.func
@@ -5773,21 +5765,9 @@ const FlowNavigation = ({
5773
5765
  onClick: onClose
5774
5766
  });
5775
5767
  const isSmall = clientWidth != null && clientWidth < Breakpoint.SMALL;
5768
+ const isLarge = clientWidth != null && clientWidth >= Breakpoint.LARGE;
5776
5769
  const newAvatar = done ? null : avatar;
5777
- const getLeftContentSmall = () => {
5778
- const displayGoBack = onGoBack != null && activeStep > 0;
5779
- return /*#__PURE__*/jsx(Fragment, {
5780
- children: displayGoBack ? /*#__PURE__*/jsx(BackButton$1, {
5781
- label: /*#__PURE__*/jsx(AnimatedLabel, {
5782
- className: "m-x-1",
5783
- labels: steps.map(step => step.label),
5784
- activeLabel: activeStep - 1,
5785
- "aria-label": intl.formatMessage(messages$5.back)
5786
- }),
5787
- onClick: onGoBack
5788
- }) : logo
5789
- });
5790
- };
5770
+ const displayGoBack = onGoBack != null && activeStep > 0;
5791
5771
  return /*#__PURE__*/jsx("div", {
5792
5772
  ref: reference,
5793
5773
  className: classNames('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {
@@ -5799,12 +5779,24 @@ const FlowNavigation = ({
5799
5779
  'np-flow-navigation--xs-max': isSmall,
5800
5780
  // Size switches on parent container which may or may not have the same size as the window.
5801
5781
  'np-flow-navigation--sm': clientWidth != null && clientWidth >= Breakpoint.SMALL,
5802
- 'np-flow-navigation--lg': clientWidth != null && clientWidth >= Breakpoint.LARGE
5782
+ 'np-flow-navigation--lg': isLarge
5783
+ }),
5784
+ leftContent: /*#__PURE__*/jsxs(Fragment, {
5785
+ children: [isSmall && displayGoBack ? /*#__PURE__*/jsx(BackButton$1, {
5786
+ "aria-label": intl.formatMessage(messages$5.back),
5787
+ onClick: onGoBack
5788
+ }) : logo, isSmall && /*#__PURE__*/jsx(AnimatedLabel, {
5789
+ className: "m-x-1",
5790
+ labels: steps.map(step => step.label),
5791
+ activeLabel: activeStep
5792
+ })]
5803
5793
  }),
5804
- leftContent: isSmall ? getLeftContentSmall() : logo,
5805
- rightContent: /*#__PURE__*/jsxs(Fragment, {
5794
+ rightContent: /*#__PURE__*/jsxs("div", {
5795
+ className: classNames('d-flex', 'align-items-center', {
5796
+ 'order-2': isLarge
5797
+ }),
5806
5798
  children: [newAvatar, newAvatar && closeButton && /*#__PURE__*/jsx("span", {
5807
- className: "separator"
5799
+ className: "m-x-1"
5808
5800
  }), closeButton]
5809
5801
  }),
5810
5802
  bottomContent: !done && /*#__PURE__*/jsx(Stepper, {
@@ -6749,6 +6741,7 @@ function SelectInput({
6749
6741
  value: controlledValue,
6750
6742
  compareValues,
6751
6743
  renderValue = wrapInFragment,
6744
+ renderFooter,
6752
6745
  renderTrigger = defaultRenderTrigger,
6753
6746
  filterable,
6754
6747
  filterPlaceholder,
@@ -6822,6 +6815,7 @@ function SelectInput({
6822
6815
  children: /*#__PURE__*/jsx(SelectInputOptions, {
6823
6816
  items: items,
6824
6817
  renderValue: renderValue,
6818
+ renderFooter: renderFooter,
6825
6819
  filterable: filterable,
6826
6820
  filterPlaceholder: filterPlaceholder,
6827
6821
  searchInputRef: searchInputRef,
@@ -6864,29 +6858,32 @@ const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInput
6864
6858
  useEffect(() => {
6865
6859
  handleAriaActiveDescendantChange(ariaActiveDescendant);
6866
6860
  }, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
6867
- return (
6868
- /*#__PURE__*/
6869
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
6870
- jsx("div", {
6871
- ref: ref,
6872
- onKeyDown: event => {
6873
- // Prevent absorbing dismissal requests too early
6874
- if (event.key === 'Escape') {
6875
- return;
6876
- }
6877
- // Prevent confirmation close without an active item
6878
- if (event.key === 'Enter' && ariaActiveDescendant == null) {
6879
- return;
6880
- }
6881
- onKeyDown?.(event);
6882
- },
6883
- ...restProps
6884
- })
6885
- );
6861
+ return /*#__PURE__*/jsx("div", {
6862
+ ref: ref,
6863
+ role: "none",
6864
+ onKeyDown: event => {
6865
+ // Prevent confirmation close without an active item
6866
+ if (event.key === 'Enter' && ariaActiveDescendant == null) {
6867
+ return;
6868
+ }
6869
+ // Prevent absorbing actions early
6870
+ if (event.key === 'Escape' || event.key === 'Tab') {
6871
+ onKeyDown?.({
6872
+ ...event,
6873
+ preventDefault: () => {},
6874
+ stopPropagation: () => {}
6875
+ });
6876
+ return;
6877
+ }
6878
+ onKeyDown?.(event);
6879
+ },
6880
+ ...restProps
6881
+ });
6886
6882
  });
6887
6883
  function SelectInputOptions({
6888
6884
  items,
6889
6885
  renderValue = wrapInFragment,
6886
+ renderFooter,
6890
6887
  filterable = false,
6891
6888
  filterPlaceholder,
6892
6889
  searchInputRef,
@@ -6901,14 +6898,14 @@ function SelectInputOptions({
6901
6898
  }
6902
6899
  return undefined;
6903
6900
  }, [filterable, query]);
6904
- const empty = needle != null && filterSelectInputItems(items, needle).length === 0;
6901
+ const resultsEmpty = needle != null && filterSelectInputItems(items, needle).length === 0;
6905
6902
  const listboxContainerRef = useRef(null);
6906
6903
  useEffect(() => {
6907
6904
  if (listboxContainerRef.current != null) {
6908
6905
  listboxContainerRef.current.style.setProperty('--initial-height', `${listboxContainerRef.current.offsetHeight}px`);
6909
6906
  }
6910
6907
  }, []);
6911
- const showStatus = empty;
6908
+ const showStatus = resultsEmpty;
6912
6909
  const statusId = useId();
6913
6910
  const listboxId = useId();
6914
6911
  return /*#__PURE__*/jsxs(Listbox.Options, {
@@ -6944,10 +6941,10 @@ function SelectInputOptions({
6944
6941
  setQuery(event.currentTarget.value);
6945
6942
  }
6946
6943
  })
6947
- }) : null, /*#__PURE__*/jsxs("div", {
6944
+ }) : null, /*#__PURE__*/jsxs("section", {
6948
6945
  ref: listboxContainerRef,
6949
6946
  className: classNames('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
6950
- children: [empty ? /*#__PURE__*/jsxs("div", {
6947
+ children: [resultsEmpty ? /*#__PURE__*/jsxs("div", {
6951
6948
  id: statusId,
6952
6949
  className: "np-select-input-options-status",
6953
6950
  children: [/*#__PURE__*/jsx(CrossCircle, {
@@ -6968,7 +6965,22 @@ function SelectInputOptions({
6968
6965
  renderValue: renderValue,
6969
6966
  needle: needle
6970
6967
  }, index))
6971
- })]
6968
+ }), renderFooter != null ? /*#__PURE__*/jsx("footer", {
6969
+ className: "np-select-input-footer",
6970
+ children: /*#__PURE__*/jsx("div", {
6971
+ role: "none",
6972
+ onKeyDown: event => {
6973
+ // Prevent interfering with Headless UI
6974
+ if (event.key !== 'Escape') {
6975
+ event.stopPropagation();
6976
+ }
6977
+ },
6978
+ children: renderFooter({
6979
+ resultsEmpty,
6980
+ normalizedQuery: needle
6981
+ })
6982
+ })
6983
+ }) : null]
6972
6984
  })]
6973
6985
  });
6974
6986
  }
@@ -7025,7 +7037,7 @@ function SelectInputGroupItemView({
7025
7037
  className: classNames(needle === null && 'np-select-input-group-item--without-needle'),
7026
7038
  children: [needle == null ? /*#__PURE__*/jsx("header", {
7027
7039
  id: headerId,
7028
- role: "presentation",
7040
+ role: "none",
7029
7041
  className: "np-select-input-group-item-header np-text-title-group",
7030
7042
  children: item.label
7031
7043
  }) : null, item.options.map((option, index) => /*#__PURE__*/jsx(SelectInputItemView
@@ -8803,6 +8815,7 @@ const OverlayHeader = ({
8803
8815
  logo
8804
8816
  }) => {
8805
8817
  const closeButton = onClose && /*#__PURE__*/jsx(CloseButton, {
8818
+ size: Size.LARGE,
8806
8819
  onClick: onClose
8807
8820
  });
8808
8821
  return /*#__PURE__*/jsx("div", {
@@ -8810,9 +8823,10 @@ const OverlayHeader = ({
8810
8823
  children: /*#__PURE__*/jsx(FlowHeader, {
8811
8824
  className: "np-overlay-header__content p-a-3",
8812
8825
  leftContent: logo,
8813
- rightContent: /*#__PURE__*/jsxs(Fragment, {
8826
+ rightContent: /*#__PURE__*/jsxs("div", {
8827
+ className: classNames('d-flex', 'align-items-center', 'order-2'),
8814
8828
  children: [avatar, avatar && closeButton && /*#__PURE__*/jsx("span", {
8815
- className: "separator"
8829
+ className: classNames('m-x-1')
8816
8830
  }), closeButton]
8817
8831
  })
8818
8832
  })