@transferwise/components 0.0.0-experimental-a4458ac → 0.0.0-experimental-210ef2c

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 (45) hide show
  1. package/build/index.esm.js +80 -99
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +80 -99
  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.map +1 -1
  18. package/build/types/overlayHeader/OverlayHeader.d.ts.map +1 -1
  19. package/package.json +1 -1
  20. package/src/common/flowHeader/FlowHeader.tsx +3 -9
  21. package/src/common/flowHeader/__snapshots__/FlowHeader.spec.js.snap +2 -2
  22. package/src/flowNavigation/FlowNavigation.css +1 -1
  23. package/src/flowNavigation/FlowNavigation.less +9 -0
  24. package/src/flowNavigation/FlowNavigation.spec.js +3 -3
  25. package/src/flowNavigation/FlowNavigation.story.js +183 -24
  26. package/src/flowNavigation/FlowNavigation.tsx +13 -9
  27. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +11 -14
  28. package/src/flowNavigation/animatedLabel/AnimatedLabel.css +1 -1
  29. package/src/flowNavigation/animatedLabel/AnimatedLabel.less +6 -0
  30. package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +21 -7
  31. package/src/flowNavigation/animatedLabel/AnimatedLabel.story.js +22 -0
  32. package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +17 -8
  33. package/src/flowNavigation/animatedLabel/__snapshots__/AnimatedLabel.spec.js.snap +4 -4
  34. package/src/flowNavigation/backButton/BackButton.js +9 -14
  35. package/src/flowNavigation/backButton/BackButton.spec.js +2 -3
  36. package/src/flowNavigation/backButton/__snapshots__/BackButton.spec.js.snap +21 -28
  37. package/src/inputs/SelectInput.css +1 -1
  38. package/src/inputs/SelectInput.less +1 -13
  39. package/src/inputs/SelectInput.tsx +61 -80
  40. package/src/main.css +1 -1
  41. package/src/overlayHeader/OverlayHeader.css +1 -1
  42. package/src/overlayHeader/OverlayHeader.js +2 -4
  43. package/src/overlayHeader/OverlayHeader.less +8 -0
  44. package/src/overlayHeader/OverlayHeader.spec.js +1 -1
  45. package/src/overlayHeader/__snapshots__/OverlayHeader.spec.js.snap +3 -3
@@ -5398,7 +5398,7 @@ const FlowHeader = /*#__PURE__*/React.forwardRef(({
5398
5398
  ref: reference,
5399
5399
  className: classNames('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', className),
5400
5400
  children: [/*#__PURE__*/jsx("div", {
5401
- className: classNames('np-flow-header__left', 'd-flex', 'align-items-center', 'justify-content-between', {
5401
+ className: classNames('np-flow-header__left', {
5402
5402
  'flex__item--8': isVertical
5403
5403
  }),
5404
5404
  children: leftContent
@@ -5711,16 +5711,19 @@ var messages$5 = defineMessages({
5711
5711
  const AnimatedLabel = ({
5712
5712
  activeLabel,
5713
5713
  className,
5714
- labels
5714
+ labels,
5715
+ 'aria-label': ariaLabel
5715
5716
  }) => {
5716
- return /*#__PURE__*/jsx(Body, {
5717
- type: Typography.BODY_LARGE_BOLD,
5718
- 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),
5719
5721
  children: labels.map((label, index) => {
5720
5722
  const nextLabel = index - 1;
5721
5723
  return /*#__PURE__*/jsx("div", {
5722
- className: classNames('text-xs-center', {
5723
- '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
5724
5727
  }),
5725
5728
  children: label
5726
5729
  }, nextLabel);
@@ -5729,24 +5732,18 @@ const AnimatedLabel = ({
5729
5732
  };
5730
5733
 
5731
5734
  const BackButton = ({
5735
+ label,
5732
5736
  className,
5733
- onClick,
5734
- 'aria-label': ariaLabel
5735
- }) => /*#__PURE__*/jsx(Avatar, {
5736
- type: AvatarType.ICON,
5737
- size: 40,
5738
- children: /*#__PURE__*/jsx("button", {
5739
- type: "button",
5740
- "aria-label": ariaLabel,
5741
- className: classNames('np-back-button', 'btn-unstyled', className),
5742
- onClick: onClick,
5743
- children: /*#__PURE__*/jsx(ArrowLeft, {
5744
- size: 24
5745
- })
5746
- })
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]
5747
5745
  });
5748
5746
  BackButton.propTypes = {
5749
- 'aria-label': PropTypes.string.isRequired,
5750
5747
  className: PropTypes.string,
5751
5748
  label: PropTypes.element,
5752
5749
  onClick: PropTypes.func
@@ -5779,17 +5776,16 @@ const FlowNavigation = ({
5779
5776
  const newAvatar = done ? null : avatar;
5780
5777
  const getLeftContentSmall = () => {
5781
5778
  const displayGoBack = onGoBack != null && activeStep > 0;
5782
- return /*#__PURE__*/jsxs(Fragment, {
5783
- children: [displayGoBack ? /*#__PURE__*/jsx(BackButton$1, {
5784
- "aria-label": intl.formatMessage(messages$5.back),
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
+ }),
5785
5787
  onClick: onGoBack
5786
- }) : logo, /*#__PURE__*/jsx(AnimatedLabel, {
5787
- className: "m-x-1",
5788
- labels: steps.map(step => step.label),
5789
- activeLabel: activeStep
5790
- }), /*#__PURE__*/jsx("span", {
5791
- className: "m-x-1"
5792
- })]
5788
+ }) : logo
5793
5789
  });
5794
5790
  };
5795
5791
  return /*#__PURE__*/jsx("div", {
@@ -5798,7 +5794,7 @@ const FlowNavigation = ({
5798
5794
  'np-flow-navigation--border-bottom': !done
5799
5795
  }),
5800
5796
  children: /*#__PURE__*/jsx(FlowHeader, {
5801
- className: classNames('np-flow-navigation__content', isSmall ? 'p-x-2' : 'p-x-3', {
5797
+ className: classNames('np-flow-navigation__content p-x-3', {
5802
5798
  'np-flow-navigation--hidden': !clientWidth,
5803
5799
  'np-flow-navigation--xs-max': isSmall,
5804
5800
  // Size switches on parent container which may or may not have the same size as the window.
@@ -5808,7 +5804,7 @@ const FlowNavigation = ({
5808
5804
  leftContent: isSmall ? getLeftContentSmall() : logo,
5809
5805
  rightContent: /*#__PURE__*/jsxs(Fragment, {
5810
5806
  children: [newAvatar, newAvatar && closeButton && /*#__PURE__*/jsx("span", {
5811
- className: "m-x-1"
5807
+ className: "separator"
5812
5808
  }), closeButton]
5813
5809
  }),
5814
5810
  bottomContent: !done && /*#__PURE__*/jsx(Stepper, {
@@ -6641,13 +6637,6 @@ function inferSearchableStrings(value) {
6641
6637
  }
6642
6638
  return [];
6643
6639
  }
6644
- const SelectInputItemCheckPaddingContext = /*#__PURE__*/createContext(false);
6645
- function useSelectInputItemCheckPadding() {
6646
- const checkPadding = useContext(SelectInputItemCheckPaddingContext);
6647
- // Avoid layout shifts during transitions via caching
6648
- const [initialCheckPadding] = useState(checkPadding);
6649
- return initialCheckPadding;
6650
- }
6651
6640
  const SelectInputTriggerButtonPropsContext = /*#__PURE__*/createContext({});
6652
6641
  const SelectInputOptionContentWithinTriggerContext = /*#__PURE__*/createContext(false);
6653
6642
  function dedupeSelectInputOptionItem(item, existingValues) {
@@ -6792,54 +6781,51 @@ function SelectInput({
6792
6781
  children: ({
6793
6782
  disabled: uiDisabled,
6794
6783
  value
6795
- }) => /*#__PURE__*/jsx(SelectInputItemCheckPaddingContext.Provider, {
6796
- value: Boolean(filterable) || value != null,
6797
- children: /*#__PURE__*/jsx(OptionsOverlay, {
6798
- placement: "bottom-start",
6799
- open: open,
6800
- renderTrigger: ({
6801
- ref,
6802
- getInteractionProps
6803
- }) => /*#__PURE__*/jsx(SelectInputTriggerButtonPropsContext.Provider, {
6804
- // eslint-disable-next-line react/jsx-no-constructed-context-values
6805
- value: {
6806
- ref: mergeRefs([ref, triggerRef]),
6807
- ...mergeProps({
6808
- onClick: () => {
6809
- setOpen(prev => !prev);
6810
- }
6811
- }, getInteractionProps())
6812
- },
6813
- children: renderTrigger({
6814
- content: value != null ? /*#__PURE__*/jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
6815
- value: true,
6816
- children: renderValue(value, true)
6817
- }) : placeholder,
6818
- placeholderShown: value == null,
6819
- clear: onClear != null ? () => {
6820
- onClear();
6821
- triggerRef.current?.focus({
6822
- preventScroll: true
6823
- });
6824
- } : undefined,
6825
- disabled: uiDisabled,
6826
- size,
6827
- className
6828
- })
6829
- }),
6830
- initialFocusRef: controllerRef,
6831
- padding: "none",
6832
- onClose: () => {
6833
- setOpen(false);
6784
+ }) => /*#__PURE__*/jsx(OptionsOverlay, {
6785
+ placement: "bottom-start",
6786
+ open: open,
6787
+ renderTrigger: ({
6788
+ ref,
6789
+ getInteractionProps
6790
+ }) => /*#__PURE__*/jsx(SelectInputTriggerButtonPropsContext.Provider, {
6791
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
6792
+ value: {
6793
+ ref: mergeRefs([ref, triggerRef]),
6794
+ ...mergeProps({
6795
+ onClick: () => {
6796
+ setOpen(prev => !prev);
6797
+ }
6798
+ }, getInteractionProps())
6834
6799
  },
6835
- children: /*#__PURE__*/jsx(SelectInputOptions, {
6836
- items: items,
6837
- renderValue: renderValue,
6838
- filterable: filterable,
6839
- filterPlaceholder: filterPlaceholder,
6840
- searchInputRef: searchInputRef,
6841
- listboxRef: listboxRef
6800
+ children: renderTrigger({
6801
+ content: value != null ? /*#__PURE__*/jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
6802
+ value: true,
6803
+ children: renderValue(value, true)
6804
+ }) : placeholder,
6805
+ placeholderShown: value == null,
6806
+ clear: onClear != null ? () => {
6807
+ onClear();
6808
+ triggerRef.current?.focus({
6809
+ preventScroll: true
6810
+ });
6811
+ } : undefined,
6812
+ disabled: uiDisabled,
6813
+ size,
6814
+ className
6842
6815
  })
6816
+ }),
6817
+ initialFocusRef: controllerRef,
6818
+ padding: "none",
6819
+ onClose: () => {
6820
+ setOpen(false);
6821
+ },
6822
+ children: /*#__PURE__*/jsx(SelectInputOptions, {
6823
+ items: items,
6824
+ renderValue: renderValue,
6825
+ filterable: filterable,
6826
+ filterPlaceholder: filterPlaceholder,
6827
+ searchInputRef: searchInputRef,
6828
+ listboxRef: listboxRef
6843
6829
  })
6844
6830
  })
6845
6831
  });
@@ -7029,7 +7015,6 @@ function SelectInputGroupItemView({
7029
7015
  needle
7030
7016
  }) {
7031
7017
  const headerId = useId();
7032
- const checkPadding = useSelectInputItemCheckPadding();
7033
7018
  return (
7034
7019
  /*#__PURE__*/
7035
7020
  // An empty container may be rendered when no options match `needle`
@@ -7038,13 +7023,11 @@ function SelectInputGroupItemView({
7038
7023
  role: "group",
7039
7024
  "aria-labelledby": headerId,
7040
7025
  className: classNames(needle === null && 'np-select-input-group-item--without-needle'),
7041
- children: [needle == null ? /*#__PURE__*/jsxs("header", {
7026
+ children: [needle == null ? /*#__PURE__*/jsx("header", {
7042
7027
  id: headerId,
7043
7028
  role: "presentation",
7044
7029
  className: "np-select-input-group-item-header np-text-title-group",
7045
- children: [checkPadding ? /*#__PURE__*/jsx("span", {
7046
- className: "np-select-input-option-check-placeholder"
7047
- }) : null, item.label]
7030
+ children: item.label
7048
7031
  }) : null, item.options.map((option, index) => /*#__PURE__*/jsx(SelectInputItemView
7049
7032
  // eslint-disable-next-line react/no-array-index-key
7050
7033
  , {
@@ -7060,7 +7043,6 @@ function SelectInputOption({
7060
7043
  disabled,
7061
7044
  children
7062
7045
  }) {
7063
- const checkPadding = useSelectInputItemCheckPadding();
7064
7046
  return /*#__PURE__*/jsx(Listbox.Option, {
7065
7047
  as: "div",
7066
7048
  value: value,
@@ -7072,12 +7054,12 @@ function SelectInputOption({
7072
7054
  children: ({
7073
7055
  selected
7074
7056
  }) => /*#__PURE__*/jsxs(Fragment, {
7075
- children: [checkPadding ? /*#__PURE__*/jsx(Check, {
7076
- size: 16,
7077
- className: classNames('np-select-input-option-check', !selected && 'np-select-input-option-check--not-selected')
7078
- }) : null, /*#__PURE__*/jsx("div", {
7057
+ children: [/*#__PURE__*/jsx("div", {
7079
7058
  className: "np-select-input-option",
7080
7059
  children: children
7060
+ }), /*#__PURE__*/jsx(Check, {
7061
+ size: 16,
7062
+ className: classNames('np-select-input-option-check', !selected && 'np-select-input-option-check--not-selected')
7081
7063
  })]
7082
7064
  })
7083
7065
  });
@@ -8821,7 +8803,6 @@ const OverlayHeader = ({
8821
8803
  logo
8822
8804
  }) => {
8823
8805
  const closeButton = onClose && /*#__PURE__*/jsx(CloseButton, {
8824
- size: Size.LARGE,
8825
8806
  onClick: onClose
8826
8807
  });
8827
8808
  return /*#__PURE__*/jsx("div", {
@@ -8831,7 +8812,7 @@ const OverlayHeader = ({
8831
8812
  leftContent: logo,
8832
8813
  rightContent: /*#__PURE__*/jsxs(Fragment, {
8833
8814
  children: [avatar, avatar && closeButton && /*#__PURE__*/jsx("span", {
8834
- className: classNames('m-x-1')
8815
+ className: "separator"
8835
8816
  }), closeButton]
8836
8817
  })
8837
8818
  })