@transferwise/components 45.21.3 → 45.23.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 (59) hide show
  1. package/build/index.esm.js +103 -77
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +103 -77
  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/header/Header.css +1 -1
  9. package/build/styles/inputs/SelectInput.css +1 -1
  10. package/build/styles/main.css +1 -1
  11. package/build/styles/overlayHeader/OverlayHeader.css +1 -1
  12. package/build/types/common/flowHeader/FlowHeader.d.ts.map +1 -1
  13. package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
  14. package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts +1 -2
  15. package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts.map +1 -1
  16. package/build/types/flowNavigation/backButton/BackButton.d.ts +10 -11
  17. package/build/types/flowNavigation/backButton/BackButton.d.ts.map +1 -1
  18. package/build/types/header/Header.d.ts +1 -1
  19. package/build/types/header/Header.d.ts.map +1 -1
  20. package/build/types/inputs/SelectInput.d.ts +5 -1
  21. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  22. package/build/types/overlayHeader/OverlayHeader.d.ts.map +1 -1
  23. package/build/types/title/Title.d.ts +1 -1
  24. package/build/types/title/Title.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/common/flowHeader/FlowHeader.tsx +4 -22
  27. package/src/common/flowHeader/__snapshots__/FlowHeader.spec.js.snap +6 -22
  28. package/src/flowNavigation/FlowNavigation.css +1 -1
  29. package/src/flowNavigation/FlowNavigation.less +0 -9
  30. package/src/flowNavigation/FlowNavigation.spec.js +3 -3
  31. package/src/flowNavigation/FlowNavigation.story.js +22 -189
  32. package/src/flowNavigation/FlowNavigation.tsx +22 -27
  33. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +18 -26
  34. package/src/flowNavigation/animatedLabel/AnimatedLabel.css +1 -1
  35. package/src/flowNavigation/animatedLabel/AnimatedLabel.less +0 -6
  36. package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +7 -21
  37. package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +8 -17
  38. package/src/flowNavigation/animatedLabel/__snapshots__/AnimatedLabel.spec.js.snap +4 -4
  39. package/src/flowNavigation/backButton/BackButton.js +14 -9
  40. package/src/flowNavigation/backButton/BackButton.spec.js +3 -2
  41. package/src/flowNavigation/backButton/__snapshots__/BackButton.spec.js.snap +28 -21
  42. package/src/header/Header.css +1 -1
  43. package/src/header/Header.less +5 -0
  44. package/src/header/Header.tsx +21 -2
  45. package/src/inputs/SelectInput.css +1 -1
  46. package/src/inputs/SelectInput.less +7 -10
  47. package/src/inputs/SelectInput.spec.tsx +40 -0
  48. package/src/inputs/SelectInput.story.tsx +18 -0
  49. package/src/inputs/SelectInput.tsx +46 -12
  50. package/src/inputs/_BottomSheet.less +1 -1
  51. package/src/inputs/_Popover.less +1 -0
  52. package/src/main.css +1 -1
  53. package/src/overlayHeader/OverlayHeader.css +1 -1
  54. package/src/overlayHeader/OverlayHeader.js +6 -4
  55. package/src/overlayHeader/OverlayHeader.less +0 -8
  56. package/src/overlayHeader/OverlayHeader.spec.js +1 -1
  57. package/src/overlayHeader/__snapshots__/OverlayHeader.spec.js.snap +10 -14
  58. package/src/title/Title.tsx +1 -1
  59. 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, {
@@ -5859,6 +5851,18 @@ const Header = ({
5859
5851
  title,
5860
5852
  className
5861
5853
  }) => {
5854
+ if (!action) {
5855
+ return /*#__PURE__*/jsx(Title, {
5856
+ as: as,
5857
+ type: Typography.TITLE_GROUP,
5858
+ className: classNames('np-header', 'np-header__title', className),
5859
+ children: title
5860
+ });
5861
+ }
5862
+ if (as === 'legend') {
5863
+ // eslint-disable-next-line no-console
5864
+ console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
5865
+ }
5862
5866
  return /*#__PURE__*/jsxs("div", {
5863
5867
  className: classNames('np-header', className),
5864
5868
  children: [/*#__PURE__*/jsx(Title, {
@@ -5866,7 +5870,7 @@ const Header = ({
5866
5870
  type: Typography.TITLE_GROUP,
5867
5871
  className: "np-header__title",
5868
5872
  children: title
5869
- }), action && /*#__PURE__*/jsx(HeaderAction, {
5873
+ }), /*#__PURE__*/jsx(HeaderAction, {
5870
5874
  action: action
5871
5875
  })]
5872
5876
  });
@@ -6749,6 +6753,7 @@ function SelectInput({
6749
6753
  value: controlledValue,
6750
6754
  compareValues,
6751
6755
  renderValue = wrapInFragment,
6756
+ renderFooter,
6752
6757
  renderTrigger = defaultRenderTrigger,
6753
6758
  filterable,
6754
6759
  filterPlaceholder,
@@ -6822,6 +6827,7 @@ function SelectInput({
6822
6827
  children: /*#__PURE__*/jsx(SelectInputOptions, {
6823
6828
  items: items,
6824
6829
  renderValue: renderValue,
6830
+ renderFooter: renderFooter,
6825
6831
  filterable: filterable,
6826
6832
  filterPlaceholder: filterPlaceholder,
6827
6833
  searchInputRef: searchInputRef,
@@ -6864,29 +6870,32 @@ const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInput
6864
6870
  useEffect(() => {
6865
6871
  handleAriaActiveDescendantChange(ariaActiveDescendant);
6866
6872
  }, [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
- );
6873
+ return /*#__PURE__*/jsx("div", {
6874
+ ref: ref,
6875
+ role: "none",
6876
+ onKeyDown: event => {
6877
+ // Prevent confirmation close without an active item
6878
+ if (event.key === 'Enter' && ariaActiveDescendant == null) {
6879
+ return;
6880
+ }
6881
+ // Prevent absorbing actions early
6882
+ if (event.key === 'Escape' || event.key === 'Tab') {
6883
+ onKeyDown?.({
6884
+ ...event,
6885
+ preventDefault: () => {},
6886
+ stopPropagation: () => {}
6887
+ });
6888
+ return;
6889
+ }
6890
+ onKeyDown?.(event);
6891
+ },
6892
+ ...restProps
6893
+ });
6886
6894
  });
6887
6895
  function SelectInputOptions({
6888
6896
  items,
6889
6897
  renderValue = wrapInFragment,
6898
+ renderFooter,
6890
6899
  filterable = false,
6891
6900
  filterPlaceholder,
6892
6901
  searchInputRef,
@@ -6901,14 +6910,14 @@ function SelectInputOptions({
6901
6910
  }
6902
6911
  return undefined;
6903
6912
  }, [filterable, query]);
6904
- const empty = needle != null && filterSelectInputItems(items, needle).length === 0;
6913
+ const resultsEmpty = needle != null && filterSelectInputItems(items, needle).length === 0;
6905
6914
  const listboxContainerRef = useRef(null);
6906
6915
  useEffect(() => {
6907
6916
  if (listboxContainerRef.current != null) {
6908
6917
  listboxContainerRef.current.style.setProperty('--initial-height', `${listboxContainerRef.current.offsetHeight}px`);
6909
6918
  }
6910
6919
  }, []);
6911
- const showStatus = empty;
6920
+ const showStatus = resultsEmpty;
6912
6921
  const statusId = useId();
6913
6922
  const listboxId = useId();
6914
6923
  return /*#__PURE__*/jsxs(Listbox.Options, {
@@ -6944,10 +6953,10 @@ function SelectInputOptions({
6944
6953
  setQuery(event.currentTarget.value);
6945
6954
  }
6946
6955
  })
6947
- }) : null, /*#__PURE__*/jsxs("div", {
6956
+ }) : null, /*#__PURE__*/jsxs("section", {
6948
6957
  ref: listboxContainerRef,
6949
6958
  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", {
6959
+ children: [resultsEmpty ? /*#__PURE__*/jsxs("div", {
6951
6960
  id: statusId,
6952
6961
  className: "np-select-input-options-status",
6953
6962
  children: [/*#__PURE__*/jsx(CrossCircle, {
@@ -6968,7 +6977,22 @@ function SelectInputOptions({
6968
6977
  renderValue: renderValue,
6969
6978
  needle: needle
6970
6979
  }, index))
6971
- })]
6980
+ }), renderFooter != null ? /*#__PURE__*/jsx("footer", {
6981
+ className: "np-select-input-footer",
6982
+ children: /*#__PURE__*/jsx("div", {
6983
+ role: "none",
6984
+ onKeyDown: event => {
6985
+ // Prevent interfering with Headless UI
6986
+ if (event.key !== 'Escape') {
6987
+ event.stopPropagation();
6988
+ }
6989
+ },
6990
+ children: renderFooter({
6991
+ resultsEmpty,
6992
+ normalizedQuery: needle
6993
+ })
6994
+ })
6995
+ }) : null]
6972
6996
  })]
6973
6997
  });
6974
6998
  }
@@ -7025,7 +7049,7 @@ function SelectInputGroupItemView({
7025
7049
  className: classNames(needle === null && 'np-select-input-group-item--without-needle'),
7026
7050
  children: [needle == null ? /*#__PURE__*/jsx("header", {
7027
7051
  id: headerId,
7028
- role: "presentation",
7052
+ role: "none",
7029
7053
  className: "np-select-input-group-item-header np-text-title-group",
7030
7054
  children: item.label
7031
7055
  }) : null, item.options.map((option, index) => /*#__PURE__*/jsx(SelectInputItemView
@@ -8803,6 +8827,7 @@ const OverlayHeader = ({
8803
8827
  logo
8804
8828
  }) => {
8805
8829
  const closeButton = onClose && /*#__PURE__*/jsx(CloseButton, {
8830
+ size: Size.LARGE,
8806
8831
  onClick: onClose
8807
8832
  });
8808
8833
  return /*#__PURE__*/jsx("div", {
@@ -8810,9 +8835,10 @@ const OverlayHeader = ({
8810
8835
  children: /*#__PURE__*/jsx(FlowHeader, {
8811
8836
  className: "np-overlay-header__content p-a-3",
8812
8837
  leftContent: logo,
8813
- rightContent: /*#__PURE__*/jsxs(Fragment, {
8838
+ rightContent: /*#__PURE__*/jsxs("div", {
8839
+ className: classNames('d-flex', 'align-items-center', 'order-2'),
8814
8840
  children: [avatar, avatar && closeButton && /*#__PURE__*/jsx("span", {
8815
- className: "separator"
8841
+ className: classNames('m-x-1')
8816
8842
  }), closeButton]
8817
8843
  })
8818
8844
  })