dynamic-mui 1.0.80 → 1.0.82
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.
|
@@ -32,34 +32,35 @@ const getValue = function () {
|
|
|
32
32
|
let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
33
33
|
let isMultiple = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
34
34
|
if (isMultiple) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return dValueSet === null || dValueSet === void 0 ? void 0 : dValueSet.has(value);
|
|
43
|
-
});
|
|
35
|
+
const values = Array.isArray(defaultValue) ? defaultValue : (() => {
|
|
36
|
+
let sep = ',';
|
|
37
|
+
if (defaultValue.includes(';')) sep = ';';
|
|
38
|
+
return defaultValue.split(sep).map(v => v.trim());
|
|
39
|
+
})();
|
|
40
|
+
const dValueSet = new Set(values);
|
|
41
|
+
return options.filter(opt => dValueSet.has(opt.value));
|
|
44
42
|
}
|
|
45
|
-
return options.find(
|
|
43
|
+
return options.find(_ref => {
|
|
46
44
|
let {
|
|
47
45
|
value
|
|
48
|
-
} =
|
|
46
|
+
} = _ref;
|
|
49
47
|
return value === defaultValue;
|
|
50
48
|
});
|
|
51
49
|
};
|
|
52
|
-
function Select(
|
|
50
|
+
function Select(_ref2) {
|
|
53
51
|
let {
|
|
54
52
|
attributes,
|
|
55
53
|
onChange
|
|
56
|
-
} =
|
|
54
|
+
} = _ref2;
|
|
57
55
|
const {
|
|
58
56
|
MuiAttributes = {},
|
|
59
57
|
options = [],
|
|
60
58
|
MuiBoxAttributes = {},
|
|
61
59
|
id = '',
|
|
62
|
-
InputProps = {}
|
|
60
|
+
InputProps = {},
|
|
61
|
+
additionalProps = {
|
|
62
|
+
split: ','
|
|
63
|
+
}
|
|
63
64
|
} = attributes;
|
|
64
65
|
const [value, setValue] = _react.default.useState((attributes === null || attributes === void 0 ? void 0 : attributes.value) && getValue(options, attributes === null || attributes === void 0 ? void 0 : attributes.value, MuiAttributes.multiple));
|
|
65
66
|
const getMuiAttributes = () => {
|
|
@@ -89,7 +90,7 @@ function Select(_ref3) {
|
|
|
89
90
|
const data = MuiAttributes.multiple ? newValue.map(extractValue) : extractValue(newValue);
|
|
90
91
|
onChange({
|
|
91
92
|
id,
|
|
92
|
-
value: MuiAttributes.multiple ? data.
|
|
93
|
+
value: MuiAttributes.multiple ? data === null || data === void 0 ? void 0 : data.join(additionalProps === null || additionalProps === void 0 ? void 0 : additionalProps.split) : data,
|
|
93
94
|
option: newValue
|
|
94
95
|
});
|
|
95
96
|
} else onChange({
|