@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 +69 -66
- package/build/index.js.map +1 -1
- package/build/index.mjs +69 -66
- package/build/index.mjs.map +1 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
- package/build/types/inputs/_Popover.d.ts.map +1 -1
- package/build/types/segmentedControl/SegmentedControl.d.ts +2 -2
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/inputs/_BottomSheet.tsx +33 -28
- package/src/inputs/_Popover.tsx +23 -20
- package/src/segmentedControl/SegmentedControl.spec.tsx +39 -1
- package/src/segmentedControl/SegmentedControl.story.tsx +54 -16
- package/src/segmentedControl/SegmentedControl.tsx +11 -18
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(
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
'np-bottom-sheet-v2-content-inner
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
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
|
-
}
|
|
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(
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
'np-popover-v2-container
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
'np-popover-v2
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
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
|
-
|
|
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 ===
|
|
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,
|
|
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':
|
|
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:
|
|
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:
|
|
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":
|
|
10062
|
+
"aria-selected": value === segment.value,
|
|
10060
10063
|
className: classNames__default.default('segmented-control__segment', 'segmented-control__button', {
|
|
10061
|
-
'segmented-control__selected-segment':
|
|
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:
|
|
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);
|