@transferwise/components 0.0.0-experimental-c736330 → 0.0.0-experimental-a2f2fc6
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 +46 -48
- package/build/index.js.map +1 -1
- package/build/index.mjs +46 -48
- package/build/index.mjs.map +1 -1
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/inputs/InputGroup.tsx +3 -3
- package/src/segmentedControl/SegmentedControl.spec.tsx +49 -1
- package/src/segmentedControl/SegmentedControl.tsx +11 -16
package/build/index.mjs
CHANGED
|
@@ -5816,9 +5816,9 @@ function InputAddon({
|
|
|
5816
5816
|
const ref = useRef(null);
|
|
5817
5817
|
useResizeObserver(ref, entry => {
|
|
5818
5818
|
// TODO: Remove fallback once most browsers support `borderBoxSize`
|
|
5819
|
-
|
|
5820
|
-
if (
|
|
5821
|
-
setInputPadding(
|
|
5819
|
+
const inlineSize = entry.borderBoxSize?.[0]?.inlineSize;
|
|
5820
|
+
if (inlineSize != null) {
|
|
5821
|
+
setInputPadding(inlineSize);
|
|
5822
5822
|
} else {
|
|
5823
5823
|
const targetStyle = getComputedStyle(entry.target);
|
|
5824
5824
|
setInputPadding(entry.contentRect.width + Number.parseFloat(targetStyle.paddingInlineStart) + Number.parseFloat(targetStyle.paddingInlineEnd));
|
|
@@ -10480,9 +10480,6 @@ const SegmentedControl = ({
|
|
|
10480
10480
|
};
|
|
10481
10481
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10482
10482
|
}, [segmentsWithRefs, selectedValue]);
|
|
10483
|
-
useEffect(() => {
|
|
10484
|
-
onChange(selectedValue);
|
|
10485
|
-
}, [onChange, selectedValue]);
|
|
10486
10483
|
return /*#__PURE__*/jsx("div", {
|
|
10487
10484
|
ref: segmentsRef,
|
|
10488
10485
|
"data-testid": "segmented-control",
|
|
@@ -10494,50 +10491,51 @@ const SegmentedControl = ({
|
|
|
10494
10491
|
'segmented-control__segments--no-animate': !animate
|
|
10495
10492
|
}),
|
|
10496
10493
|
role: mode !== 'input' ? 'tablist' : undefined,
|
|
10497
|
-
children: segmentsWithRefs.map(segment =>
|
|
10498
|
-
|
|
10499
|
-
htmlFor: segment.id,
|
|
10500
|
-
className: classNames('segmented-control__segment', {
|
|
10501
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10502
|
-
}),
|
|
10503
|
-
children: [/*#__PURE__*/jsx("input", {
|
|
10504
|
-
type: "radio",
|
|
10505
|
-
className: "segmented-control__radio-input",
|
|
10506
|
-
id: segment.id,
|
|
10507
|
-
name: name,
|
|
10508
|
-
value: segment.value,
|
|
10509
|
-
checked: selectedValue === segment.value,
|
|
10510
|
-
onChange: () => {
|
|
10511
|
-
setAnimate(true);
|
|
10512
|
-
setSelectedValue(segment.value);
|
|
10513
|
-
}
|
|
10514
|
-
}), /*#__PURE__*/jsx(Body, {
|
|
10515
|
-
className: "segmented-control__text",
|
|
10516
|
-
as: "span",
|
|
10517
|
-
type: selectedValue === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10518
|
-
children: segment.label
|
|
10519
|
-
})]
|
|
10520
|
-
}, segment.id) : /*#__PURE__*/jsx("button", {
|
|
10521
|
-
ref: segment.ref,
|
|
10522
|
-
type: "button",
|
|
10523
|
-
role: "tab",
|
|
10524
|
-
id: segment.id,
|
|
10525
|
-
"aria-controls": segment.controls,
|
|
10526
|
-
"aria-selected": selectedValue === segment.value,
|
|
10527
|
-
className: classNames('segmented-control__segment', 'segmented-control__button', {
|
|
10528
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10529
|
-
}),
|
|
10530
|
-
onClick: () => {
|
|
10494
|
+
children: segmentsWithRefs.map(segment => {
|
|
10495
|
+
const onSelect = () => {
|
|
10531
10496
|
setAnimate(true);
|
|
10532
10497
|
setSelectedValue(segment.value);
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
|
|
10498
|
+
onChange(segment.value);
|
|
10499
|
+
};
|
|
10500
|
+
return mode === 'input' ? /*#__PURE__*/jsxs("label", {
|
|
10501
|
+
ref: segment.ref,
|
|
10502
|
+
htmlFor: segment.id,
|
|
10503
|
+
className: classNames('segmented-control__segment', {
|
|
10504
|
+
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10505
|
+
}),
|
|
10506
|
+
children: [/*#__PURE__*/jsx("input", {
|
|
10507
|
+
type: "radio",
|
|
10508
|
+
className: "segmented-control__radio-input",
|
|
10509
|
+
id: segment.id,
|
|
10510
|
+
name: name,
|
|
10511
|
+
value: segment.value,
|
|
10512
|
+
checked: selectedValue === segment.value,
|
|
10513
|
+
onChange: onSelect
|
|
10514
|
+
}), /*#__PURE__*/jsx(Body, {
|
|
10515
|
+
className: "segmented-control__text",
|
|
10516
|
+
as: "span",
|
|
10517
|
+
type: selectedValue === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10518
|
+
children: segment.label
|
|
10519
|
+
})]
|
|
10520
|
+
}, segment.id) : /*#__PURE__*/jsx("button", {
|
|
10521
|
+
ref: segment.ref,
|
|
10522
|
+
type: "button",
|
|
10523
|
+
role: "tab",
|
|
10524
|
+
id: segment.id,
|
|
10525
|
+
"aria-controls": segment.controls,
|
|
10526
|
+
"aria-selected": selectedValue === segment.value,
|
|
10527
|
+
className: classNames('segmented-control__segment', 'segmented-control__button', {
|
|
10528
|
+
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10529
|
+
}),
|
|
10530
|
+
onClick: onSelect,
|
|
10531
|
+
children: /*#__PURE__*/jsx(Body, {
|
|
10532
|
+
as: "span",
|
|
10533
|
+
className: "segmented-control__text",
|
|
10534
|
+
type: selectedValue === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10535
|
+
children: segment.label
|
|
10536
|
+
})
|
|
10537
|
+
}, segment.id);
|
|
10538
|
+
})
|
|
10541
10539
|
})
|
|
10542
10540
|
});
|
|
10543
10541
|
};
|