@etsoo/materialui 1.0.65 → 1.0.67
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/lib/OptionGroup.js +9 -3
- package/package.json +1 -1
- package/src/OptionGroup.tsx +16 -7
package/lib/OptionGroup.js
CHANGED
|
@@ -8,6 +8,7 @@ import React from 'react';
|
|
|
8
8
|
* @returns Component
|
|
9
9
|
*/
|
|
10
10
|
export function OptionGroup(props) {
|
|
11
|
+
var _a;
|
|
11
12
|
// Destruct
|
|
12
13
|
const { getOptionLabel, defaultValue, idField = 'id', label, labelField = 'label', multiple = false, mRef, name, onValueChange, options, readOnly, row, itemSize, helperText, variant, required, ...rest } = props;
|
|
13
14
|
// Theme
|
|
@@ -21,11 +22,16 @@ export function OptionGroup(props) {
|
|
|
21
22
|
return value;
|
|
22
23
|
};
|
|
23
24
|
// Checkbox values
|
|
24
|
-
const [values, setValues] = React.useState(
|
|
25
|
+
const [values, setValues] = React.useState([]);
|
|
26
|
+
// Values
|
|
27
|
+
const dv = React.useMemo(() => defaultValue == null
|
|
25
28
|
? []
|
|
26
29
|
: Array.isArray(defaultValue)
|
|
27
30
|
? defaultValue
|
|
28
|
-
: [defaultValue]);
|
|
31
|
+
: [defaultValue], [defaultValue]);
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
setValues(dv);
|
|
34
|
+
}, [dv]);
|
|
29
35
|
// Disabled ids
|
|
30
36
|
const [disabledIds, setDisabledIds] = React.useState();
|
|
31
37
|
// Item checked
|
|
@@ -78,7 +84,7 @@ export function OptionGroup(props) {
|
|
|
78
84
|
return (React.createElement(FormControlLabel, { key: value, control: control, value: value, label: label }));
|
|
79
85
|
});
|
|
80
86
|
// Group
|
|
81
|
-
const group = multiple ? (React.createElement(FormGroup, { row: row }, list)) : (React.createElement(RadioGroup, { row: row, name: name, value: values[0], onChange: (_event, value) => {
|
|
87
|
+
const group = multiple ? (React.createElement(FormGroup, { row: row }, list)) : (React.createElement(RadioGroup, { row: row, name: name, value: (_a = values[0]) !== null && _a !== void 0 ? _a : '', onChange: (_event, value) => {
|
|
82
88
|
if (firstOptionValue == null)
|
|
83
89
|
return;
|
|
84
90
|
const typeValue = Utils.parseString(value, firstOptionValue);
|
package/package.json
CHANGED
package/src/OptionGroup.tsx
CHANGED
|
@@ -154,14 +154,23 @@ export function OptionGroup<
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
// Checkbox values
|
|
157
|
-
const [values, setValues] = React.useState(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
const [values, setValues] = React.useState<T[D][]>([]);
|
|
158
|
+
|
|
159
|
+
// Values
|
|
160
|
+
const dv = React.useMemo(
|
|
161
|
+
() =>
|
|
162
|
+
defaultValue == null
|
|
163
|
+
? []
|
|
164
|
+
: Array.isArray(defaultValue)
|
|
165
|
+
? defaultValue
|
|
166
|
+
: [defaultValue],
|
|
167
|
+
[defaultValue]
|
|
163
168
|
);
|
|
164
169
|
|
|
170
|
+
React.useEffect(() => {
|
|
171
|
+
setValues(dv);
|
|
172
|
+
}, [dv]);
|
|
173
|
+
|
|
165
174
|
// Disabled ids
|
|
166
175
|
const [disabledIds, setDisabledIds] = React.useState<unknown[]>();
|
|
167
176
|
|
|
@@ -255,7 +264,7 @@ export function OptionGroup<
|
|
|
255
264
|
<RadioGroup
|
|
256
265
|
row={row}
|
|
257
266
|
name={name}
|
|
258
|
-
value={values[0]}
|
|
267
|
+
value={values[0] ?? ''}
|
|
259
268
|
onChange={(_event, value) => {
|
|
260
269
|
if (firstOptionValue == null) return;
|
|
261
270
|
const typeValue = Utils.parseString(value, firstOptionValue);
|