@etsoo/materialui 1.6.18 → 1.6.19
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/cjs/ComboBoxMultiple.js +5 -0
- package/lib/cjs/custom/CustomFieldUI.js +8 -15
- package/lib/cjs/custom/FieldCombobox.js +1 -1
- package/lib/mjs/ComboBoxMultiple.js +5 -0
- package/lib/mjs/custom/CustomFieldUI.js +8 -12
- package/lib/mjs/custom/FieldCombobox.js +1 -1
- package/package.json +1 -1
- package/src/ComboBoxMultiple.tsx +6 -0
- package/src/custom/CustomFieldUI.tsx +11 -16
- package/src/custom/FieldCombobox.tsx +1 -1
|
@@ -58,6 +58,11 @@ function ComboBoxMultiple(props) {
|
|
|
58
58
|
Object.assign(params, { readOnly });
|
|
59
59
|
}
|
|
60
60
|
Object.assign(params.inputProps, { "data-reset": inputReset });
|
|
61
|
+
params.inputProps.onInvalid = (event) => {
|
|
62
|
+
if (inputRequired && stateValue != null && stateValue.length > 0) {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
61
66
|
if (dataReadonly) {
|
|
62
67
|
params.inputProps.onKeyDown = (event) => {
|
|
63
68
|
if (shared_1.Keyboard.isTypingContent(event.key)) {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.CustomFieldUI = CustomFieldUI;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
4
|
const CustomFieldUtils_1 = require("./CustomFieldUtils");
|
|
9
5
|
/**
|
|
10
6
|
* CustomFieldUI component
|
|
@@ -13,17 +9,14 @@ const CustomFieldUtils_1 = require("./CustomFieldUtils");
|
|
|
13
9
|
*/
|
|
14
10
|
function CustomFieldUI(props) {
|
|
15
11
|
// Destruct
|
|
16
|
-
const { fields, onChange, value } = props;
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
const { fields, onChange, value = {} } = props;
|
|
13
|
+
// Layout
|
|
14
|
+
return CustomFieldUtils_1.CustomFieldUtils.create(fields, {}, (field) => {
|
|
19
15
|
if (!field.name)
|
|
20
16
|
return undefined;
|
|
21
|
-
return value
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, []);
|
|
27
|
-
// Layout
|
|
28
|
-
return CustomFieldUtils_1.CustomFieldUtils.create(fields, {}, getValue, doChange);
|
|
17
|
+
return value[field.name];
|
|
18
|
+
}, (name, fieldValue) => {
|
|
19
|
+
value[name] = fieldValue;
|
|
20
|
+
onChange?.(value, name, fieldValue);
|
|
21
|
+
});
|
|
29
22
|
}
|
|
@@ -39,7 +39,7 @@ const FieldCombobox = ({ field, mref, onChange, defaultValue }) => {
|
|
|
39
39
|
return ((0, jsx_runtime_1.jsxs)(Typography_1.default, { children: ["No name for FieldCombobox ", JSON.stringify(field)] }));
|
|
40
40
|
}
|
|
41
41
|
const { required, inputRequired, ...mainRests } = field.mainSlotProps || {};
|
|
42
|
-
return ((0, jsx_runtime_1.jsx)(ComboBoxMultiple_1.ComboBoxMultiple, { label: field.label ?? "", inputHelperText: field.helperText, name: name, options: field.options, fullWidth: true, idValues: ids,
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)(ComboBoxMultiple_1.ComboBoxMultiple, { label: field.label ?? "", inputHelperText: field.helperText, inputRequired: required || inputRequired, name: name, options: field.options, fullWidth: true, idValues: ids, onChange: (_event, value) => {
|
|
43
43
|
const ids = value.map((v) => v.id);
|
|
44
44
|
setIds(ids);
|
|
45
45
|
onChange(name, ids);
|
|
@@ -52,6 +52,11 @@ export function ComboBoxMultiple(props) {
|
|
|
52
52
|
Object.assign(params, { readOnly });
|
|
53
53
|
}
|
|
54
54
|
Object.assign(params.inputProps, { "data-reset": inputReset });
|
|
55
|
+
params.inputProps.onInvalid = (event) => {
|
|
56
|
+
if (inputRequired && stateValue != null && stateValue.length > 0) {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
55
60
|
if (dataReadonly) {
|
|
56
61
|
params.inputProps.onKeyDown = (event) => {
|
|
57
62
|
if (Keyboard.isTypingContent(event.key)) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { CustomFieldUtils } from "./CustomFieldUtils";
|
|
3
2
|
/**
|
|
4
3
|
* CustomFieldUI component
|
|
@@ -7,17 +6,14 @@ import { CustomFieldUtils } from "./CustomFieldUtils";
|
|
|
7
6
|
*/
|
|
8
7
|
export function CustomFieldUI(props) {
|
|
9
8
|
// Destruct
|
|
10
|
-
const { fields, onChange, value } = props;
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const { fields, onChange, value = {} } = props;
|
|
10
|
+
// Layout
|
|
11
|
+
return CustomFieldUtils.create(fields, {}, (field) => {
|
|
13
12
|
if (!field.name)
|
|
14
13
|
return undefined;
|
|
15
|
-
return value
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, []);
|
|
21
|
-
// Layout
|
|
22
|
-
return CustomFieldUtils.create(fields, {}, getValue, doChange);
|
|
14
|
+
return value[field.name];
|
|
15
|
+
}, (name, fieldValue) => {
|
|
16
|
+
value[name] = fieldValue;
|
|
17
|
+
onChange?.(value, name, fieldValue);
|
|
18
|
+
});
|
|
23
19
|
}
|
|
@@ -33,7 +33,7 @@ export const FieldCombobox = ({ field, mref, onChange, defaultValue }) => {
|
|
|
33
33
|
return (_jsxs(Typography, { children: ["No name for FieldCombobox ", JSON.stringify(field)] }));
|
|
34
34
|
}
|
|
35
35
|
const { required, inputRequired, ...mainRests } = field.mainSlotProps || {};
|
|
36
|
-
return (_jsx(ComboBoxMultiple, { label: field.label ?? "", inputHelperText: field.helperText, name: name, options: field.options, fullWidth: true, idValues: ids,
|
|
36
|
+
return (_jsx(ComboBoxMultiple, { label: field.label ?? "", inputHelperText: field.helperText, inputRequired: required || inputRequired, name: name, options: field.options, fullWidth: true, idValues: ids, onChange: (_event, value) => {
|
|
37
37
|
const ids = value.map((v) => v.id);
|
|
38
38
|
setIds(ids);
|
|
39
39
|
onChange(name, ids);
|
package/package.json
CHANGED
package/src/ComboBoxMultiple.tsx
CHANGED
|
@@ -167,6 +167,12 @@ export function ComboBoxMultiple<
|
|
|
167
167
|
|
|
168
168
|
Object.assign(params.inputProps, { "data-reset": inputReset });
|
|
169
169
|
|
|
170
|
+
params.inputProps.onInvalid = (event) => {
|
|
171
|
+
if (inputRequired && stateValue != null && stateValue.length > 0) {
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
170
176
|
if (dataReadonly) {
|
|
171
177
|
params.inputProps.onKeyDown = (event) => {
|
|
172
178
|
if (Keyboard.isTypingContent(event.key)) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CustomFieldData } from "@etsoo/appscript";
|
|
2
|
-
import React from "react";
|
|
3
2
|
import { CustomFieldUtils } from "./CustomFieldUtils";
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -38,23 +37,19 @@ export function CustomFieldUI<D extends CustomFieldData = CustomFieldData>(
|
|
|
38
37
|
props: CustomFieldUIProps<D>
|
|
39
38
|
) {
|
|
40
39
|
// Destruct
|
|
41
|
-
const { fields, onChange, value } = props;
|
|
40
|
+
const { fields, onChange, value = {} } = props;
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
// Layout
|
|
43
|
+
return CustomFieldUtils.create(
|
|
44
|
+
fields,
|
|
45
|
+
{},
|
|
46
|
+
(field) => {
|
|
47
47
|
if (!field.name) return undefined;
|
|
48
|
-
return value
|
|
48
|
+
return value[field.name];
|
|
49
49
|
},
|
|
50
|
-
|
|
50
|
+
(name, fieldValue) => {
|
|
51
|
+
value[name] = fieldValue;
|
|
52
|
+
onChange?.(value, name, fieldValue);
|
|
53
|
+
}
|
|
51
54
|
);
|
|
52
|
-
|
|
53
|
-
const doChange = React.useCallback((name: string, value: unknown) => {
|
|
54
|
-
data.current[name] = value;
|
|
55
|
-
onChange?.(data.current, name, value);
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
|
-
// Layout
|
|
59
|
-
return CustomFieldUtils.create(fields, {}, getValue, doChange);
|
|
60
55
|
}
|
|
@@ -50,11 +50,11 @@ export const FieldCombobox: ICustomFieldReact<IdType[]> = ({
|
|
|
50
50
|
<ComboBoxMultiple
|
|
51
51
|
label={field.label ?? ""}
|
|
52
52
|
inputHelperText={field.helperText}
|
|
53
|
+
inputRequired={required || inputRequired}
|
|
53
54
|
name={name}
|
|
54
55
|
options={field.options}
|
|
55
56
|
fullWidth
|
|
56
57
|
idValues={ids}
|
|
57
|
-
inputRequired={required || inputRequired}
|
|
58
58
|
onChange={(_event, value) => {
|
|
59
59
|
const ids = value.map((v) => v.id);
|
|
60
60
|
setIds(ids);
|