@transferwise/components 0.0.0-experimental-a087360 → 0.0.0-experimental-73ab65e

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 (49) hide show
  1. package/build/index.esm.js +91 -68
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +91 -68
  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 +2 -1
  14. package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts.map +1 -1
  15. package/build/types/flowNavigation/backButton/BackButton.d.ts +11 -10
  16. package/build/types/flowNavigation/backButton/BackButton.d.ts.map +1 -1
  17. package/build/types/inputs/SelectInput.d.ts +2 -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 +22 -4
  22. package/src/common/flowHeader/__snapshots__/FlowHeader.spec.js.snap +22 -6
  23. package/src/flowNavigation/FlowNavigation.css +1 -1
  24. package/src/flowNavigation/FlowNavigation.less +9 -0
  25. package/src/flowNavigation/FlowNavigation.spec.js +3 -3
  26. package/src/flowNavigation/FlowNavigation.story.js +189 -22
  27. package/src/flowNavigation/FlowNavigation.tsx +27 -22
  28. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +26 -18
  29. package/src/flowNavigation/animatedLabel/AnimatedLabel.css +1 -1
  30. package/src/flowNavigation/animatedLabel/AnimatedLabel.less +6 -0
  31. package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +21 -7
  32. package/src/flowNavigation/animatedLabel/AnimatedLabel.story.js +22 -0
  33. package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +17 -8
  34. package/src/flowNavigation/animatedLabel/__snapshots__/AnimatedLabel.spec.js.snap +4 -4
  35. package/src/flowNavigation/backButton/BackButton.js +9 -14
  36. package/src/flowNavigation/backButton/BackButton.spec.js +2 -3
  37. package/src/flowNavigation/backButton/__snapshots__/BackButton.spec.js.snap +21 -28
  38. package/src/inputs/SelectInput.css +1 -1
  39. package/src/inputs/SelectInput.less +4 -0
  40. package/src/inputs/SelectInput.spec.tsx +40 -0
  41. package/src/inputs/SelectInput.story.tsx +18 -0
  42. package/src/inputs/SelectInput.tsx +38 -10
  43. package/src/inputs/_BottomSheet.less +1 -1
  44. package/src/main.css +1 -1
  45. package/src/overlayHeader/OverlayHeader.css +1 -1
  46. package/src/overlayHeader/OverlayHeader.js +4 -6
  47. package/src/overlayHeader/OverlayHeader.less +8 -0
  48. package/src/overlayHeader/OverlayHeader.spec.js +1 -1
  49. package/src/overlayHeader/__snapshots__/OverlayHeader.spec.js.snap +14 -10
@@ -5396,8 +5396,19 @@ 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', 'justify-content-between', 'flex__item--12', className),
5400
- children: [leftContent, rightContent, /*#__PURE__*/jsx("div", {
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", {
5401
5412
  className: classNames('align-items-center', 'd-flex', 'justify-content-center', {
5402
5413
  'flex__item--12': isVertical,
5403
5414
  'order-1 flex-grow-1': !isVertical
@@ -5700,16 +5711,19 @@ var messages$5 = defineMessages({
5700
5711
  const AnimatedLabel = ({
5701
5712
  activeLabel,
5702
5713
  className,
5703
- labels
5714
+ labels,
5715
+ 'aria-label': ariaLabel
5704
5716
  }) => {
5705
- return /*#__PURE__*/jsx(Body, {
5706
- type: Typography.BODY_LARGE_BOLD,
5707
- className: classNames('np-animated-label', className),
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),
5708
5721
  children: labels.map((label, index) => {
5709
5722
  const nextLabel = index - 1;
5710
5723
  return /*#__PURE__*/jsx("div", {
5711
- className: classNames('text-xs-center', {
5712
- 'np-animated-label--in text-ellipsis': index === activeLabel
5724
+ className: classNames('text-xs-left', {
5725
+ 'np-animated-label--in': index === activeLabel,
5726
+ 'np-animated-label--out': nextLabel === activeLabel && nextLabel !== numberLabels
5713
5727
  }),
5714
5728
  children: label
5715
5729
  }, nextLabel);
@@ -5718,24 +5732,18 @@ const AnimatedLabel = ({
5718
5732
  };
5719
5733
 
5720
5734
  const BackButton = ({
5735
+ label,
5721
5736
  className,
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
- })
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]
5736
5745
  });
5737
5746
  BackButton.propTypes = {
5738
- 'aria-label': PropTypes.string.isRequired,
5739
5747
  className: PropTypes.string,
5740
5748
  label: PropTypes.element,
5741
5749
  onClick: PropTypes.func
@@ -5765,9 +5773,21 @@ const FlowNavigation = ({
5765
5773
  onClick: onClose
5766
5774
  });
5767
5775
  const isSmall = clientWidth != null && clientWidth < Breakpoint.SMALL;
5768
- const isLarge = clientWidth != null && clientWidth >= Breakpoint.LARGE;
5769
5776
  const newAvatar = done ? null : avatar;
5770
- const displayGoBack = onGoBack != null && activeStep > 0;
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
+ };
5771
5791
  return /*#__PURE__*/jsx("div", {
5772
5792
  ref: reference,
5773
5793
  className: classNames('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {
@@ -5779,24 +5799,12 @@ const FlowNavigation = ({
5779
5799
  'np-flow-navigation--xs-max': isSmall,
5780
5800
  // Size switches on parent container which may or may not have the same size as the window.
5781
5801
  'np-flow-navigation--sm': clientWidth != null && clientWidth >= Breakpoint.SMALL,
5782
- 'np-flow-navigation--lg': isLarge
5802
+ 'np-flow-navigation--lg': clientWidth != null && clientWidth >= Breakpoint.LARGE
5783
5803
  }),
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
- })]
5793
- }),
5794
- rightContent: /*#__PURE__*/jsxs("div", {
5795
- className: classNames('d-flex', 'align-items-center', {
5796
- 'order-2': isLarge
5797
- }),
5804
+ leftContent: isSmall ? getLeftContentSmall() : logo,
5805
+ rightContent: /*#__PURE__*/jsxs(Fragment, {
5798
5806
  children: [newAvatar, newAvatar && closeButton && /*#__PURE__*/jsx("span", {
5799
- className: "m-x-1"
5807
+ className: "separator"
5800
5808
  }), closeButton]
5801
5809
  }),
5802
5810
  bottomContent: !done && /*#__PURE__*/jsx(Stepper, {
@@ -6741,6 +6749,7 @@ function SelectInput({
6741
6749
  value: controlledValue,
6742
6750
  compareValues,
6743
6751
  renderValue = wrapInFragment,
6752
+ renderFooter,
6744
6753
  renderTrigger = defaultRenderTrigger,
6745
6754
  filterable,
6746
6755
  filterPlaceholder,
@@ -6814,6 +6823,7 @@ function SelectInput({
6814
6823
  children: /*#__PURE__*/jsx(SelectInputOptions, {
6815
6824
  items: items,
6816
6825
  renderValue: renderValue,
6826
+ renderFooter: renderFooter,
6817
6827
  filterable: filterable,
6818
6828
  filterPlaceholder: filterPlaceholder,
6819
6829
  searchInputRef: searchInputRef,
@@ -6856,29 +6866,32 @@ const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInput
6856
6866
  useEffect(() => {
6857
6867
  handleAriaActiveDescendantChange(ariaActiveDescendant);
6858
6868
  }, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
6859
- return (
6860
- /*#__PURE__*/
6861
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
6862
- jsx("div", {
6863
- ref: ref,
6864
- onKeyDown: event => {
6865
- // Prevent absorbing dismissal requests too early
6866
- if (event.key === 'Escape') {
6867
- return;
6868
- }
6869
- // Prevent confirmation close without an active item
6870
- if (event.key === 'Enter' && ariaActiveDescendant == null) {
6871
- return;
6872
- }
6873
- onKeyDown?.(event);
6874
- },
6875
- ...restProps
6876
- })
6877
- );
6869
+ return /*#__PURE__*/jsx("div", {
6870
+ ref: ref,
6871
+ role: "none",
6872
+ onKeyDown: event => {
6873
+ // Prevent confirmation close without an active item
6874
+ if (event.key === 'Enter' && ariaActiveDescendant == null) {
6875
+ return;
6876
+ }
6877
+ // Prevent absorbing actions early
6878
+ if (event.key === 'Escape' || event.key === 'Tab') {
6879
+ onKeyDown?.({
6880
+ ...event,
6881
+ preventDefault: () => {},
6882
+ stopPropagation: () => {}
6883
+ });
6884
+ return;
6885
+ }
6886
+ onKeyDown?.(event);
6887
+ },
6888
+ ...restProps
6889
+ });
6878
6890
  });
6879
6891
  function SelectInputOptions({
6880
6892
  items,
6881
6893
  renderValue = wrapInFragment,
6894
+ renderFooter,
6882
6895
  filterable = false,
6883
6896
  filterPlaceholder,
6884
6897
  searchInputRef,
@@ -6936,7 +6949,7 @@ function SelectInputOptions({
6936
6949
  setQuery(event.currentTarget.value);
6937
6950
  }
6938
6951
  })
6939
- }) : null, /*#__PURE__*/jsxs("div", {
6952
+ }) : null, /*#__PURE__*/jsxs("section", {
6940
6953
  ref: listboxContainerRef,
6941
6954
  className: classNames('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
6942
6955
  children: [empty ? /*#__PURE__*/jsxs("div", {
@@ -6951,7 +6964,7 @@ function SelectInputOptions({
6951
6964
  id: listboxId,
6952
6965
  role: "listbox",
6953
6966
  "aria-orientation": "vertical",
6954
- tabIndex: 0,
6967
+ tabIndex: !filterable ? 0 : undefined,
6955
6968
  className: "np-select-input-listbox",
6956
6969
  children: (needle != null ? dedupeSelectInputItems(items) : items).map((item, index) => /*#__PURE__*/jsx(SelectInputItemView
6957
6970
  // eslint-disable-next-line react/no-array-index-key
@@ -6960,7 +6973,19 @@ function SelectInputOptions({
6960
6973
  renderValue: renderValue,
6961
6974
  needle: needle
6962
6975
  }, index))
6963
- })]
6976
+ }), renderFooter != null ? /*#__PURE__*/jsx("footer", {
6977
+ className: "np-select-input-footer",
6978
+ children: /*#__PURE__*/jsx("div", {
6979
+ role: "none",
6980
+ onKeyDown: event => {
6981
+ // Prevent interfering with Headless UI
6982
+ if (event.key !== 'Escape') {
6983
+ event.stopPropagation();
6984
+ }
6985
+ },
6986
+ children: renderFooter(needle)
6987
+ })
6988
+ }) : null]
6964
6989
  })]
6965
6990
  });
6966
6991
  }
@@ -7017,7 +7042,7 @@ function SelectInputGroupItemView({
7017
7042
  className: classNames(needle === null && 'np-select-input-group-item--without-needle'),
7018
7043
  children: [needle == null ? /*#__PURE__*/jsx("header", {
7019
7044
  id: headerId,
7020
- role: "presentation",
7045
+ role: "none",
7021
7046
  className: "np-select-input-group-item-header np-text-title-group",
7022
7047
  children: item.label
7023
7048
  }) : null, item.options.map((option, index) => /*#__PURE__*/jsx(SelectInputItemView
@@ -8795,7 +8820,6 @@ const OverlayHeader = ({
8795
8820
  logo
8796
8821
  }) => {
8797
8822
  const closeButton = onClose && /*#__PURE__*/jsx(CloseButton, {
8798
- size: Size.LARGE,
8799
8823
  onClick: onClose
8800
8824
  });
8801
8825
  return /*#__PURE__*/jsx("div", {
@@ -8803,10 +8827,9 @@ const OverlayHeader = ({
8803
8827
  children: /*#__PURE__*/jsx(FlowHeader, {
8804
8828
  className: "np-overlay-header__content p-a-3",
8805
8829
  leftContent: logo,
8806
- rightContent: /*#__PURE__*/jsxs("div", {
8807
- className: classNames('d-flex', 'align-items-center', 'order-2'),
8830
+ rightContent: /*#__PURE__*/jsxs(Fragment, {
8808
8831
  children: [avatar, avatar && closeButton && /*#__PURE__*/jsx("span", {
8809
- className: classNames('m-x-1')
8832
+ className: "separator"
8810
8833
  }), closeButton]
8811
8834
  })
8812
8835
  })