@festo-ui/react 4.0.2 → 4.0.3-pre-20221007.4
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/index.js
CHANGED
|
@@ -3360,7 +3360,8 @@ function Segment(props) {
|
|
|
3360
3360
|
legend,
|
|
3361
3361
|
config,
|
|
3362
3362
|
onChange,
|
|
3363
|
-
className
|
|
3363
|
+
className,
|
|
3364
|
+
value: valueProps
|
|
3364
3365
|
} = props;
|
|
3365
3366
|
const innerConfig = Object.assign(Object.assign({}, defaultConfig$1), config);
|
|
3366
3367
|
let useIcon = false;
|
|
@@ -3385,7 +3386,10 @@ function Segment(props) {
|
|
|
3385
3386
|
|
|
3386
3387
|
return null;
|
|
3387
3388
|
});
|
|
3388
|
-
const [value, setValue] =
|
|
3389
|
+
const [value, setValue] = useControlled({
|
|
3390
|
+
controlled: valueProps,
|
|
3391
|
+
default: tmpValue
|
|
3392
|
+
});
|
|
3389
3393
|
|
|
3390
3394
|
const handleChange = (event, _value) => {
|
|
3391
3395
|
if (onChange) {
|
|
@@ -3414,14 +3418,11 @@ function Segment(props) {
|
|
|
3414
3418
|
return null;
|
|
3415
3419
|
}
|
|
3416
3420
|
|
|
3417
|
-
|
|
3418
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
3419
|
-
key: id,
|
|
3420
|
-
id,
|
|
3421
|
+
return /*#__PURE__*/React.cloneElement(child, Object.assign(Object.assign({}, child.props), {
|
|
3421
3422
|
onChange: handleChange,
|
|
3422
3423
|
iconOnly: innerConfig.iconOnly,
|
|
3423
3424
|
checked: child.props.value === value
|
|
3424
|
-
});
|
|
3425
|
+
}));
|
|
3425
3426
|
})
|
|
3426
3427
|
}))]
|
|
3427
3428
|
}));
|
|
@@ -3437,9 +3438,10 @@ function SegmentControl(props) {
|
|
|
3437
3438
|
icon,
|
|
3438
3439
|
onChange,
|
|
3439
3440
|
iconOnly,
|
|
3440
|
-
id
|
|
3441
|
+
id,
|
|
3441
3442
|
className
|
|
3442
3443
|
} = props;
|
|
3444
|
+
const componentId = useRef(id !== null && id !== void 0 ? id : (Math.random() * Date.now()).toString().replace('.', '-'));
|
|
3443
3445
|
let viewMode = 'text';
|
|
3444
3446
|
|
|
3445
3447
|
if (icon) {
|
|
@@ -3463,7 +3465,7 @@ function SegmentControl(props) {
|
|
|
3463
3465
|
children: [jsx("input", {
|
|
3464
3466
|
className: "fwe-segment-input",
|
|
3465
3467
|
type: "radio",
|
|
3466
|
-
id:
|
|
3468
|
+
id: componentId.current,
|
|
3467
3469
|
name: name,
|
|
3468
3470
|
value: value,
|
|
3469
3471
|
checked: checked,
|
|
@@ -3471,7 +3473,7 @@ function SegmentControl(props) {
|
|
|
3471
3473
|
onChange: e => handleChange(e)
|
|
3472
3474
|
}), jsxs("label", Object.assign({
|
|
3473
3475
|
className: classNames('fwe-segment-label', className),
|
|
3474
|
-
htmlFor:
|
|
3476
|
+
htmlFor: componentId.current
|
|
3475
3477
|
}, {
|
|
3476
3478
|
children: [viewMode === 'icon' && jsxs(Fragment, {
|
|
3477
3479
|
children: [jsx("span", Object.assign({
|
|
@@ -8,6 +8,7 @@ interface SegmentProps extends ClassNamePropsWithChildren {
|
|
|
8
8
|
legend: string;
|
|
9
9
|
config?: SegmentComponentConfiguration;
|
|
10
10
|
onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: any) => void;
|
|
11
|
+
value?: any;
|
|
11
12
|
}
|
|
12
13
|
export declare function Segment(props: SegmentProps): JSX.Element;
|
|
13
14
|
export default Segment;
|