@transferwise/components 0.0.0-experimental-cc11279 → 0.0.0-experimental-b300585

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.
package/build/index.js CHANGED
@@ -14,11 +14,11 @@ var react$1 = require('@headlessui/react');
14
14
  var mergeProps = require('merge-props');
15
15
  var index_js = require('use-sync-external-store/shim/index.js');
16
16
  var react = require('@floating-ui/react');
17
+ var focus = require('@react-aria/focus');
17
18
  var overlays = require('@react-aria/overlays');
18
19
  var reactTransitionGroup = require('react-transition-group');
19
20
  var neptuneValidation = require('@transferwise/neptune-validation');
20
21
  var reactDom = require('react-dom');
21
- var focus = require('@react-aria/focus');
22
22
  var reactPopper = require('react-popper');
23
23
  var throttle = require('lodash.throttle');
24
24
  var art = require('@wise/art');
@@ -5521,35 +5521,37 @@ function BottomSheet({
5521
5521
  enterFrom: "np-bottom-sheet-v2-content--enter-from",
5522
5522
  leave: "np-bottom-sheet-v2-content--leave",
5523
5523
  leaveTo: "np-bottom-sheet-v2-content--leave-to",
5524
- children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
5525
- context: context,
5526
- initialFocus: initialFocusRef,
5527
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5528
- // Force inner state invalidation on open
5529
- ref: refs.setFloating,
5530
- className: "np-bottom-sheet-v2-content-inner-container",
5531
- ...getFloatingProps(),
5532
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
5533
- className: "np-bottom-sheet-v2-header",
5534
- children: /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
5535
- size: exports.Size.SMALL,
5536
- onClick: () => {
5537
- onClose?.();
5538
- }
5539
- })
5540
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
5541
- className: classNames__default.default('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
5542
- 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
5543
- }),
5544
- children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
5545
- className: "np-bottom-sheet-v2-title np-text-title-body",
5546
- children: title
5547
- }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
5548
- className: "np-bottom-sheet-v2-body np-text-body-default",
5549
- children: children
5524
+ children: /*#__PURE__*/jsxRuntime.jsx(focus.FocusScope, {
5525
+ children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
5526
+ context: context,
5527
+ initialFocus: initialFocusRef,
5528
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5529
+ // Force inner state invalidation on open
5530
+ ref: refs.setFloating,
5531
+ className: "np-bottom-sheet-v2-content-inner-container",
5532
+ ...getFloatingProps(),
5533
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
5534
+ className: "np-bottom-sheet-v2-header",
5535
+ children: /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
5536
+ size: exports.Size.SMALL,
5537
+ onClick: () => {
5538
+ onClose?.();
5539
+ }
5540
+ })
5541
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
5542
+ className: classNames__default.default('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
5543
+ 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
5544
+ }),
5545
+ children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
5546
+ className: "np-bottom-sheet-v2-title np-text-title-body",
5547
+ children: title
5548
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
5549
+ className: "np-bottom-sheet-v2-body np-text-body-default",
5550
+ children: children
5551
+ })]
5550
5552
  })]
5551
- })]
5552
- }, floatingKey)
5553
+ }, floatingKey)
5554
+ })
5553
5555
  })
5554
5556
  })
5555
5557
  })]
@@ -5650,32 +5652,34 @@ function Popover({
5650
5652
  setFloatingKey(prev => prev + 1);
5651
5653
  },
5652
5654
  afterLeave: onCloseEnd,
5653
- children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
5654
- context: context,
5655
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
5656
- // Force inner state invalidation on open
5657
- ref: refs.setFloating,
5658
- className: classNames__default.default('np-popover-v2-container', {
5659
- 'np-popover-v2-container--size-md': size === 'md',
5660
- 'np-popover-v2-container--size-lg': size === 'lg'
5661
- })
5662
- // eslint-disable-next-line react/forbid-dom-props
5663
- ,
5664
- style: floatingStyles,
5665
- ...getFloatingProps(),
5666
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5667
- className: classNames__default.default('np-popover-v2', title && 'np-popover-v2--has-title', {
5668
- 'np-popover-v2--padding-md': padding === 'md'
5669
- }),
5670
- children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
5671
- className: "np-popover-v2-title np-text-title-body",
5672
- children: title
5673
- }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
5674
- className: "np-popover-v2-content np-text-body-default",
5675
- children: children
5676
- })]
5677
- })
5678
- }, floatingKey)
5655
+ children: /*#__PURE__*/jsxRuntime.jsx(focus.FocusScope, {
5656
+ children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
5657
+ context: context,
5658
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
5659
+ // Force inner state invalidation on open
5660
+ ref: refs.setFloating,
5661
+ className: classNames__default.default('np-popover-v2-container', {
5662
+ 'np-popover-v2-container--size-md': size === 'md',
5663
+ 'np-popover-v2-container--size-lg': size === 'lg'
5664
+ })
5665
+ // eslint-disable-next-line react/forbid-dom-props
5666
+ ,
5667
+ style: floatingStyles,
5668
+ ...getFloatingProps(),
5669
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5670
+ className: classNames__default.default('np-popover-v2', title && 'np-popover-v2--has-title', {
5671
+ 'np-popover-v2--padding-md': padding === 'md'
5672
+ }),
5673
+ children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
5674
+ className: "np-popover-v2-title np-text-title-body",
5675
+ children: title
5676
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
5677
+ className: "np-popover-v2-content np-text-body-default",
5678
+ children: children
5679
+ })]
5680
+ })
5681
+ }, floatingKey)
5682
+ })
5679
5683
  })
5680
5684
  })
5681
5685
  })
@@ -9973,12 +9977,11 @@ Select.defaultProps = {
9973
9977
 
9974
9978
  const SegmentedControl = ({
9975
9979
  name,
9976
- defaultValue,
9980
+ value,
9977
9981
  mode = 'input',
9978
9982
  segments,
9979
9983
  onChange
9980
9984
  }) => {
9981
- const [selectedValue, setSelectedValue] = React.useState(defaultValue || segments[0].value);
9982
9985
  const [animate, setAnimate] = React.useState(false);
9983
9986
  const segmentsRef = React.useRef(null);
9984
9987
  if (segments.length > 3) {
@@ -9989,7 +9992,7 @@ const SegmentedControl = ({
9989
9992
  ref: /*#__PURE__*/React.createRef()
9990
9993
  }));
9991
9994
  const updateSegmentPosition = () => {
9992
- const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value === selectedValue)?.ref;
9995
+ const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value === value)?.ref;
9993
9996
  // We grab the active segments style object from the ref
9994
9997
  // and set the css variables to the selected segments width and x position.
9995
9998
  // This is so we can animate the highlight to the selected segment
@@ -10002,6 +10005,7 @@ const SegmentedControl = ({
10002
10005
  }
10003
10006
  };
10004
10007
  React.useEffect(() => {
10008
+ setAnimate(true);
10005
10009
  updateSegmentPosition();
10006
10010
  const handleWindowSizeChange = () => {
10007
10011
  setAnimate(false);
@@ -10012,7 +10016,7 @@ const SegmentedControl = ({
10012
10016
  window.removeEventListener('resize', handleWindowSizeChange);
10013
10017
  };
10014
10018
  // eslint-disable-next-line react-hooks/exhaustive-deps
10015
- }, [segmentsWithRefs, selectedValue]);
10019
+ }, [segmentsWithRefs, value]);
10016
10020
  return /*#__PURE__*/jsxRuntime.jsx("div", {
10017
10021
  ref: segmentsRef,
10018
10022
  "data-testid": "segmented-control",
@@ -10027,14 +10031,13 @@ const SegmentedControl = ({
10027
10031
  children: segmentsWithRefs.map(segment => {
10028
10032
  const onSelect = () => {
10029
10033
  setAnimate(true);
10030
- setSelectedValue(segment.value);
10031
10034
  onChange(segment.value);
10032
10035
  };
10033
10036
  return mode === 'input' ? /*#__PURE__*/jsxRuntime.jsxs("label", {
10034
10037
  ref: segment.ref,
10035
10038
  htmlFor: segment.id,
10036
10039
  className: classNames__default.default('segmented-control__segment', {
10037
- 'segmented-control__selected-segment': selectedValue === segment.value
10040
+ 'segmented-control__selected-segment': value === segment.value
10038
10041
  }),
10039
10042
  children: [/*#__PURE__*/jsxRuntime.jsx("input", {
10040
10043
  type: "radio",
@@ -10042,12 +10045,12 @@ const SegmentedControl = ({
10042
10045
  id: segment.id,
10043
10046
  name: name,
10044
10047
  value: segment.value,
10045
- checked: selectedValue === segment.value,
10048
+ checked: value === segment.value,
10046
10049
  onChange: onSelect
10047
10050
  }), /*#__PURE__*/jsxRuntime.jsx(Body, {
10048
10051
  className: "segmented-control__text",
10049
10052
  as: "span",
10050
- type: selectedValue === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
10053
+ type: value === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
10051
10054
  children: segment.label
10052
10055
  })]
10053
10056
  }, segment.id) : /*#__PURE__*/jsxRuntime.jsx("button", {
@@ -10056,15 +10059,15 @@ const SegmentedControl = ({
10056
10059
  role: "tab",
10057
10060
  id: segment.id,
10058
10061
  "aria-controls": segment.controls,
10059
- "aria-selected": selectedValue === segment.value,
10062
+ "aria-selected": value === segment.value,
10060
10063
  className: classNames__default.default('segmented-control__segment', 'segmented-control__button', {
10061
- 'segmented-control__selected-segment': selectedValue === segment.value
10064
+ 'segmented-control__selected-segment': value === segment.value
10062
10065
  }),
10063
10066
  onClick: onSelect,
10064
10067
  children: /*#__PURE__*/jsxRuntime.jsx(Body, {
10065
10068
  as: "span",
10066
10069
  className: "segmented-control__text",
10067
- type: selectedValue === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
10070
+ type: value === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
10068
10071
  children: segment.label
10069
10072
  })
10070
10073
  }, segment.id);