@dartech/arsenal-ui 1.4.38 → 1.4.39
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +15 -2
- package/package.json +1 -1
package/index.js
CHANGED
@@ -709,6 +709,17 @@ const ControlRadio = ({
|
|
709
709
|
if (typeof option === 'string') return option;
|
710
710
|
return labelKey ? option[labelKey] : option.label;
|
711
711
|
}, [labelKey]);
|
712
|
+
const setChecked = useCallback(optionValue => {
|
713
|
+
if (typeof optionValue === 'string') return optionValue === fieldProps.value;
|
714
|
+
return optionValue === (typeof fieldProps.value === 'string' ? fieldProps.value === 'true' : fieldProps.value);
|
715
|
+
}, [fieldProps.value]);
|
716
|
+
const localOnChange = useCallback(e => {
|
717
|
+
if (e.target.value === 'true' || e.target.value === 'false') {
|
718
|
+
onChange(e.target.value === 'true');
|
719
|
+
} else {
|
720
|
+
onChange(e);
|
721
|
+
}
|
722
|
+
}, [onChange]);
|
712
723
|
return jsxs(FormControl, Object.assign({
|
713
724
|
disabled: disabled,
|
714
725
|
error: !!error
|
@@ -720,11 +731,13 @@ const ControlRadio = ({
|
|
720
731
|
})), jsx(RadioGroup, Object.assign({}, fieldProps, {
|
721
732
|
row: row,
|
722
733
|
"aria-labelledby": "radio-buttons-group",
|
723
|
-
onChange: customOnChange ? customOnChange :
|
734
|
+
onChange: customOnChange ? customOnChange : localOnChange
|
724
735
|
}, {
|
725
736
|
children: _values.map((item, i) => jsx(FormControlLabel, {
|
726
737
|
value: getValue(item),
|
727
|
-
control: jsx(Radio, Object.assign({}, radioProps
|
738
|
+
control: jsx(Radio, Object.assign({}, radioProps, {
|
739
|
+
checked: setChecked(getValue(item))
|
740
|
+
})),
|
728
741
|
label: getLabel(item)
|
729
742
|
}, i))
|
730
743
|
})), !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message) && jsx(FormHelperText, Object.assign({
|