@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
package/build/index.js CHANGED
@@ -5430,8 +5430,19 @@ const FlowHeader = /*#__PURE__*/React__namespace.forwardRef(({
5430
5430
  const isVertical = layout === exports.Layout.VERTICAL;
5431
5431
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
5432
5432
  ref: reference,
5433
- className: classNames__default.default('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', 'justify-content-between', 'flex__item--12', className),
5434
- children: [leftContent, rightContent, /*#__PURE__*/jsxRuntime.jsx("div", {
5433
+ className: classNames__default.default('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', className),
5434
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
5435
+ className: classNames__default.default('np-flow-header__left', {
5436
+ 'flex__item--8': isVertical
5437
+ }),
5438
+ children: leftContent
5439
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
5440
+ className: classNames__default.default('align-items-center', 'd-flex', 'np-flow-header__right', 'justify-content-end', {
5441
+ 'flex__item--4 ': isVertical,
5442
+ 'order-2': !isVertical
5443
+ }),
5444
+ children: rightContent
5445
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
5435
5446
  className: classNames__default.default('align-items-center', 'd-flex', 'justify-content-center', {
5436
5447
  'flex__item--12': isVertical,
5437
5448
  'order-1 flex-grow-1': !isVertical
@@ -5734,16 +5745,19 @@ var messages$5 = reactIntl.defineMessages({
5734
5745
  const AnimatedLabel = ({
5735
5746
  activeLabel,
5736
5747
  className,
5737
- labels
5748
+ labels,
5749
+ 'aria-label': ariaLabel
5738
5750
  }) => {
5739
- return /*#__PURE__*/jsxRuntime.jsx(Body, {
5740
- type: exports.Typography.BODY_LARGE_BOLD,
5741
- className: classNames__default.default('np-animated-label', className),
5751
+ const numberLabels = labels.length - 1;
5752
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
5753
+ "aria-label": ariaLabel,
5754
+ className: classNames__default.default('np-animated-label', 'np-text-body-large-bold', className),
5742
5755
  children: labels.map((label, index) => {
5743
5756
  const nextLabel = index - 1;
5744
5757
  return /*#__PURE__*/jsxRuntime.jsx("div", {
5745
- className: classNames__default.default('text-xs-center', {
5746
- 'np-animated-label--in text-ellipsis': index === activeLabel
5758
+ className: classNames__default.default('text-xs-left', {
5759
+ 'np-animated-label--in': index === activeLabel,
5760
+ 'np-animated-label--out': nextLabel === activeLabel && nextLabel !== numberLabels
5747
5761
  }),
5748
5762
  children: label
5749
5763
  }, nextLabel);
@@ -5752,24 +5766,18 @@ const AnimatedLabel = ({
5752
5766
  };
5753
5767
 
5754
5768
  const BackButton = ({
5769
+ label,
5755
5770
  className,
5756
- onClick,
5757
- 'aria-label': ariaLabel
5758
- }) => /*#__PURE__*/jsxRuntime.jsx(Avatar, {
5759
- type: exports.AvatarType.ICON,
5760
- size: 40,
5761
- children: /*#__PURE__*/jsxRuntime.jsx("button", {
5762
- type: "button",
5763
- "aria-label": ariaLabel,
5764
- className: classNames__default.default('np-back-button', 'btn-unstyled', className),
5765
- onClick: onClick,
5766
- children: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowLeft, {
5767
- size: 24
5768
- })
5769
- })
5771
+ onClick
5772
+ }) => /*#__PURE__*/jsxRuntime.jsxs("button", {
5773
+ type: "button",
5774
+ className: classNames__default.default('np-back-button', 'align-items-center', 'btn-unstyled', className),
5775
+ onClick: onClick,
5776
+ children: [/*#__PURE__*/jsxRuntime.jsx(icons.ArrowLeft, {
5777
+ size: 24
5778
+ }), label]
5770
5779
  });
5771
5780
  BackButton.propTypes = {
5772
- 'aria-label': PropTypes__default.default.string.isRequired,
5773
5781
  className: PropTypes__default.default.string,
5774
5782
  label: PropTypes__default.default.element,
5775
5783
  onClick: PropTypes__default.default.func
@@ -5799,9 +5807,21 @@ const FlowNavigation = ({
5799
5807
  onClick: onClose
5800
5808
  });
5801
5809
  const isSmall = clientWidth != null && clientWidth < exports.Breakpoint.SMALL;
5802
- const isLarge = clientWidth != null && clientWidth >= exports.Breakpoint.LARGE;
5803
5810
  const newAvatar = done ? null : avatar;
5804
- const displayGoBack = onGoBack != null && activeStep > 0;
5811
+ const getLeftContentSmall = () => {
5812
+ const displayGoBack = onGoBack != null && activeStep > 0;
5813
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
5814
+ children: displayGoBack ? /*#__PURE__*/jsxRuntime.jsx(BackButton$1, {
5815
+ label: /*#__PURE__*/jsxRuntime.jsx(AnimatedLabel, {
5816
+ className: "m-x-1",
5817
+ labels: steps.map(step => step.label),
5818
+ activeLabel: activeStep - 1,
5819
+ "aria-label": intl.formatMessage(messages$5.back)
5820
+ }),
5821
+ onClick: onGoBack
5822
+ }) : logo
5823
+ });
5824
+ };
5805
5825
  return /*#__PURE__*/jsxRuntime.jsx("div", {
5806
5826
  ref: reference,
5807
5827
  className: classNames__default.default('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {
@@ -5813,24 +5833,12 @@ const FlowNavigation = ({
5813
5833
  'np-flow-navigation--xs-max': isSmall,
5814
5834
  // Size switches on parent container which may or may not have the same size as the window.
5815
5835
  'np-flow-navigation--sm': clientWidth != null && clientWidth >= exports.Breakpoint.SMALL,
5816
- 'np-flow-navigation--lg': isLarge
5836
+ 'np-flow-navigation--lg': clientWidth != null && clientWidth >= exports.Breakpoint.LARGE
5817
5837
  }),
5818
- leftContent: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5819
- children: [isSmall && displayGoBack ? /*#__PURE__*/jsxRuntime.jsx(BackButton$1, {
5820
- "aria-label": intl.formatMessage(messages$5.back),
5821
- onClick: onGoBack
5822
- }) : logo, isSmall && /*#__PURE__*/jsxRuntime.jsx(AnimatedLabel, {
5823
- className: "m-x-1",
5824
- labels: steps.map(step => step.label),
5825
- activeLabel: activeStep
5826
- })]
5827
- }),
5828
- rightContent: /*#__PURE__*/jsxRuntime.jsxs("div", {
5829
- className: classNames__default.default('d-flex', 'align-items-center', {
5830
- 'order-2': isLarge
5831
- }),
5838
+ leftContent: isSmall ? getLeftContentSmall() : logo,
5839
+ rightContent: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5832
5840
  children: [newAvatar, newAvatar && closeButton && /*#__PURE__*/jsxRuntime.jsx("span", {
5833
- className: "m-x-1"
5841
+ className: "separator"
5834
5842
  }), closeButton]
5835
5843
  }),
5836
5844
  bottomContent: !done && /*#__PURE__*/jsxRuntime.jsx(Stepper, {
@@ -6775,6 +6783,7 @@ function SelectInput({
6775
6783
  value: controlledValue,
6776
6784
  compareValues,
6777
6785
  renderValue = wrapInFragment,
6786
+ renderFooter,
6778
6787
  renderTrigger = defaultRenderTrigger,
6779
6788
  filterable,
6780
6789
  filterPlaceholder,
@@ -6848,6 +6857,7 @@ function SelectInput({
6848
6857
  children: /*#__PURE__*/jsxRuntime.jsx(SelectInputOptions, {
6849
6858
  items: items,
6850
6859
  renderValue: renderValue,
6860
+ renderFooter: renderFooter,
6851
6861
  filterable: filterable,
6852
6862
  filterPlaceholder: filterPlaceholder,
6853
6863
  searchInputRef: searchInputRef,
@@ -6890,29 +6900,32 @@ const SelectInputOptionsContainer = /*#__PURE__*/React.forwardRef(function Selec
6890
6900
  React.useEffect(() => {
6891
6901
  handleAriaActiveDescendantChange(ariaActiveDescendant);
6892
6902
  }, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
6893
- return (
6894
- /*#__PURE__*/
6895
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
6896
- jsxRuntime.jsx("div", {
6897
- ref: ref,
6898
- onKeyDown: event => {
6899
- // Prevent absorbing dismissal requests too early
6900
- if (event.key === 'Escape') {
6901
- return;
6902
- }
6903
- // Prevent confirmation close without an active item
6904
- if (event.key === 'Enter' && ariaActiveDescendant == null) {
6905
- return;
6906
- }
6907
- onKeyDown?.(event);
6908
- },
6909
- ...restProps
6910
- })
6911
- );
6903
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
6904
+ ref: ref,
6905
+ role: "none",
6906
+ onKeyDown: event => {
6907
+ // Prevent confirmation close without an active item
6908
+ if (event.key === 'Enter' && ariaActiveDescendant == null) {
6909
+ return;
6910
+ }
6911
+ // Prevent absorbing actions early
6912
+ if (event.key === 'Escape' || event.key === 'Tab') {
6913
+ onKeyDown?.({
6914
+ ...event,
6915
+ preventDefault: () => {},
6916
+ stopPropagation: () => {}
6917
+ });
6918
+ return;
6919
+ }
6920
+ onKeyDown?.(event);
6921
+ },
6922
+ ...restProps
6923
+ });
6912
6924
  });
6913
6925
  function SelectInputOptions({
6914
6926
  items,
6915
6927
  renderValue = wrapInFragment,
6928
+ renderFooter,
6916
6929
  filterable = false,
6917
6930
  filterPlaceholder,
6918
6931
  searchInputRef,
@@ -6970,7 +6983,7 @@ function SelectInputOptions({
6970
6983
  setQuery(event.currentTarget.value);
6971
6984
  }
6972
6985
  })
6973
- }) : null, /*#__PURE__*/jsxRuntime.jsxs("div", {
6986
+ }) : null, /*#__PURE__*/jsxRuntime.jsxs("section", {
6974
6987
  ref: listboxContainerRef,
6975
6988
  className: classNames__default.default('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
6976
6989
  children: [empty ? /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -6985,7 +6998,7 @@ function SelectInputOptions({
6985
6998
  id: listboxId,
6986
6999
  role: "listbox",
6987
7000
  "aria-orientation": "vertical",
6988
- tabIndex: 0,
7001
+ tabIndex: !filterable ? 0 : undefined,
6989
7002
  className: "np-select-input-listbox",
6990
7003
  children: (needle != null ? dedupeSelectInputItems(items) : items).map((item, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
6991
7004
  // eslint-disable-next-line react/no-array-index-key
@@ -6994,7 +7007,19 @@ function SelectInputOptions({
6994
7007
  renderValue: renderValue,
6995
7008
  needle: needle
6996
7009
  }, index))
6997
- })]
7010
+ }), renderFooter != null ? /*#__PURE__*/jsxRuntime.jsx("footer", {
7011
+ className: "np-select-input-footer",
7012
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
7013
+ role: "none",
7014
+ onKeyDown: event => {
7015
+ // Prevent interfering with Headless UI
7016
+ if (event.key !== 'Escape') {
7017
+ event.stopPropagation();
7018
+ }
7019
+ },
7020
+ children: renderFooter(needle)
7021
+ })
7022
+ }) : null]
6998
7023
  })]
6999
7024
  });
7000
7025
  }
@@ -7051,7 +7076,7 @@ function SelectInputGroupItemView({
7051
7076
  className: classNames__default.default(needle === null && 'np-select-input-group-item--without-needle'),
7052
7077
  children: [needle == null ? /*#__PURE__*/jsxRuntime.jsx("header", {
7053
7078
  id: headerId,
7054
- role: "presentation",
7079
+ role: "none",
7055
7080
  className: "np-select-input-group-item-header np-text-title-group",
7056
7081
  children: item.label
7057
7082
  }) : null, item.options.map((option, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
@@ -8829,7 +8854,6 @@ const OverlayHeader = ({
8829
8854
  logo
8830
8855
  }) => {
8831
8856
  const closeButton = onClose && /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
8832
- size: exports.Size.LARGE,
8833
8857
  onClick: onClose
8834
8858
  });
8835
8859
  return /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -8837,10 +8861,9 @@ const OverlayHeader = ({
8837
8861
  children: /*#__PURE__*/jsxRuntime.jsx(FlowHeader, {
8838
8862
  className: "np-overlay-header__content p-a-3",
8839
8863
  leftContent: logo,
8840
- rightContent: /*#__PURE__*/jsxRuntime.jsxs("div", {
8841
- className: classNames__default.default('d-flex', 'align-items-center', 'order-2'),
8864
+ rightContent: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
8842
8865
  children: [avatar, avatar && closeButton && /*#__PURE__*/jsxRuntime.jsx("span", {
8843
- className: classNames__default.default('m-x-1')
8866
+ className: "separator"
8844
8867
  }), closeButton]
8845
8868
  })
8846
8869
  })