@etsoo/materialui 1.5.49 → 1.5.51
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/ButtonPopupCheckbox.js +3 -6
- package/lib/cjs/SelectEx.d.ts +11 -0
- package/lib/cjs/SelectEx.js +11 -2
- package/lib/mjs/ButtonPopupCheckbox.js +3 -6
- package/lib/mjs/SelectEx.d.ts +11 -0
- package/lib/mjs/SelectEx.js +11 -2
- package/package.json +1 -1
- package/src/ButtonPopupCheckbox.tsx +3 -6
- package/src/SelectEx.tsx +33 -1
|
@@ -28,13 +28,10 @@ function ButtonPopupList(props) {
|
|
|
28
28
|
// Ref
|
|
29
29
|
const inputRef = react_1.default.useRef(null);
|
|
30
30
|
// State
|
|
31
|
-
const [selectedIds,
|
|
32
|
-
// Sort items
|
|
33
|
-
const setSelectedIds = (ids) => {
|
|
34
|
-
items.sortByProperty("id", ids);
|
|
35
|
-
setSelectedIdsBase(ids);
|
|
36
|
-
};
|
|
31
|
+
const [selectedIds, setSelectedIds] = react_1.default.useState([]);
|
|
37
32
|
react_1.default.useEffect(() => {
|
|
33
|
+
// Sort items by ids for first load
|
|
34
|
+
items.sortByProperty("id", ids);
|
|
38
35
|
// Set selected ids
|
|
39
36
|
setSelectedIds([...ids]);
|
|
40
37
|
}, [ids]);
|
package/lib/cjs/SelectEx.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from "@etsoo/shared";
|
|
3
3
|
import { SelectProps, SelectVariants } from "@mui/material/Select";
|
|
4
|
+
export type SelectExMethods = {
|
|
5
|
+
/**
|
|
6
|
+
* Set open state
|
|
7
|
+
* @param isOpen Open state
|
|
8
|
+
*/
|
|
9
|
+
setOpen: (isOpen: boolean) => void;
|
|
10
|
+
};
|
|
4
11
|
/**
|
|
5
12
|
* Extended select component props
|
|
6
13
|
*/
|
|
@@ -37,6 +44,10 @@ export type SelectExProps<T extends object, D extends DataTypes.Keys<T> = IdDefa
|
|
|
37
44
|
* Load data callback
|
|
38
45
|
*/
|
|
39
46
|
loadData?: () => PromiseLike<T[] | null | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* Methods
|
|
49
|
+
*/
|
|
50
|
+
mRef?: React.Ref<SelectExMethods>;
|
|
40
51
|
/**
|
|
41
52
|
* Item change callback
|
|
42
53
|
*/
|
package/lib/cjs/SelectEx.js
CHANGED
|
@@ -28,7 +28,7 @@ const Refresh_1 = __importDefault(require("@mui/icons-material/Refresh"));
|
|
|
28
28
|
*/
|
|
29
29
|
function SelectEx(props) {
|
|
30
30
|
// Destruct
|
|
31
|
-
const { defaultValue, idField = "id", error, helperText, inputReset, itemIconRenderer, itemStyle, label, labelField = "label", loadData, onItemChange, onItemClick, onLoadData, multiple = false, name, options, refresh, search = false, autoAddBlankItem = search, value, onChange, fullWidth, required, variant = "outlined", ...rest } = props;
|
|
31
|
+
const { defaultValue, idField = "id", error, helperText, inputReset, itemIconRenderer, itemStyle, label, labelField = "label", loadData, mRef, onItemChange, onItemClick, onLoadData, multiple = false, name, options, refresh, search = false, autoAddBlankItem = search, value, onChange, fullWidth, required, variant = "outlined", ...rest } = props;
|
|
32
32
|
// Options state
|
|
33
33
|
const [localOptions, setOptions] = react_1.default.useState([]);
|
|
34
34
|
const isMounted = react_1.default.useRef(false);
|
|
@@ -74,6 +74,12 @@ function SelectEx(props) {
|
|
|
74
74
|
valueRef.current = newValue;
|
|
75
75
|
setValueStateBase(newValue);
|
|
76
76
|
};
|
|
77
|
+
const [open, setOpen] = react_1.default.useState(false);
|
|
78
|
+
react_1.default.useImperativeHandle(mRef, () => ({
|
|
79
|
+
setOpen: (isOpen) => {
|
|
80
|
+
setOpen(isOpen);
|
|
81
|
+
}
|
|
82
|
+
}), []);
|
|
77
83
|
react_1.default.useEffect(() => {
|
|
78
84
|
if (valueSource != null)
|
|
79
85
|
setValueState(valueSource);
|
|
@@ -145,7 +151,10 @@ function SelectEx(props) {
|
|
|
145
151
|
? valueState
|
|
146
152
|
: localOptions.some((o) => o[idField] === valueState)
|
|
147
153
|
? valueState
|
|
148
|
-
: "", input: (0, jsx_runtime_1.jsx)(OutlinedInput_1.default, { notched: true, label: label, required: required, inputProps: {
|
|
154
|
+
: "", input: (0, jsx_runtime_1.jsx)(OutlinedInput_1.default, { notched: true, label: label, required: required, inputProps: {
|
|
155
|
+
"aria-hidden": false,
|
|
156
|
+
"data-reset": inputReset
|
|
157
|
+
} }), open: open, onClose: () => setOpen(false), onOpen: () => setOpen(true), labelId: labelId, name: name, multiple: multiple, onChange: (event, child) => {
|
|
149
158
|
if (onChange) {
|
|
150
159
|
onChange(event, child);
|
|
151
160
|
// event.preventDefault() will block executing
|
|
@@ -22,13 +22,10 @@ function ButtonPopupList(props) {
|
|
|
22
22
|
// Ref
|
|
23
23
|
const inputRef = React.useRef(null);
|
|
24
24
|
// State
|
|
25
|
-
const [selectedIds,
|
|
26
|
-
// Sort items
|
|
27
|
-
const setSelectedIds = (ids) => {
|
|
28
|
-
items.sortByProperty("id", ids);
|
|
29
|
-
setSelectedIdsBase(ids);
|
|
30
|
-
};
|
|
25
|
+
const [selectedIds, setSelectedIds] = React.useState([]);
|
|
31
26
|
React.useEffect(() => {
|
|
27
|
+
// Sort items by ids for first load
|
|
28
|
+
items.sortByProperty("id", ids);
|
|
32
29
|
// Set selected ids
|
|
33
30
|
setSelectedIds([...ids]);
|
|
34
31
|
}, [ids]);
|
package/lib/mjs/SelectEx.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from "@etsoo/shared";
|
|
3
3
|
import { SelectProps, SelectVariants } from "@mui/material/Select";
|
|
4
|
+
export type SelectExMethods = {
|
|
5
|
+
/**
|
|
6
|
+
* Set open state
|
|
7
|
+
* @param isOpen Open state
|
|
8
|
+
*/
|
|
9
|
+
setOpen: (isOpen: boolean) => void;
|
|
10
|
+
};
|
|
4
11
|
/**
|
|
5
12
|
* Extended select component props
|
|
6
13
|
*/
|
|
@@ -37,6 +44,10 @@ export type SelectExProps<T extends object, D extends DataTypes.Keys<T> = IdDefa
|
|
|
37
44
|
* Load data callback
|
|
38
45
|
*/
|
|
39
46
|
loadData?: () => PromiseLike<T[] | null | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* Methods
|
|
49
|
+
*/
|
|
50
|
+
mRef?: React.Ref<SelectExMethods>;
|
|
40
51
|
/**
|
|
41
52
|
* Item change callback
|
|
42
53
|
*/
|
package/lib/mjs/SelectEx.js
CHANGED
|
@@ -22,7 +22,7 @@ import RefreshIcon from "@mui/icons-material/Refresh";
|
|
|
22
22
|
*/
|
|
23
23
|
export function SelectEx(props) {
|
|
24
24
|
// Destruct
|
|
25
|
-
const { defaultValue, idField = "id", error, helperText, inputReset, itemIconRenderer, itemStyle, label, labelField = "label", loadData, onItemChange, onItemClick, onLoadData, multiple = false, name, options, refresh, search = false, autoAddBlankItem = search, value, onChange, fullWidth, required, variant = "outlined", ...rest } = props;
|
|
25
|
+
const { defaultValue, idField = "id", error, helperText, inputReset, itemIconRenderer, itemStyle, label, labelField = "label", loadData, mRef, onItemChange, onItemClick, onLoadData, multiple = false, name, options, refresh, search = false, autoAddBlankItem = search, value, onChange, fullWidth, required, variant = "outlined", ...rest } = props;
|
|
26
26
|
// Options state
|
|
27
27
|
const [localOptions, setOptions] = React.useState([]);
|
|
28
28
|
const isMounted = React.useRef(false);
|
|
@@ -68,6 +68,12 @@ export function SelectEx(props) {
|
|
|
68
68
|
valueRef.current = newValue;
|
|
69
69
|
setValueStateBase(newValue);
|
|
70
70
|
};
|
|
71
|
+
const [open, setOpen] = React.useState(false);
|
|
72
|
+
React.useImperativeHandle(mRef, () => ({
|
|
73
|
+
setOpen: (isOpen) => {
|
|
74
|
+
setOpen(isOpen);
|
|
75
|
+
}
|
|
76
|
+
}), []);
|
|
71
77
|
React.useEffect(() => {
|
|
72
78
|
if (valueSource != null)
|
|
73
79
|
setValueState(valueSource);
|
|
@@ -139,7 +145,10 @@ export function SelectEx(props) {
|
|
|
139
145
|
? valueState
|
|
140
146
|
: localOptions.some((o) => o[idField] === valueState)
|
|
141
147
|
? valueState
|
|
142
|
-
: "", input: _jsx(OutlinedInput, { notched: true, label: label, required: required, inputProps: {
|
|
148
|
+
: "", input: _jsx(OutlinedInput, { notched: true, label: label, required: required, inputProps: {
|
|
149
|
+
"aria-hidden": false,
|
|
150
|
+
"data-reset": inputReset
|
|
151
|
+
} }), open: open, onClose: () => setOpen(false), onOpen: () => setOpen(true), labelId: labelId, name: name, multiple: multiple, onChange: (event, child) => {
|
|
143
152
|
if (onChange) {
|
|
144
153
|
onChange(event, child);
|
|
145
154
|
// event.preventDefault() will block executing
|
package/package.json
CHANGED
|
@@ -140,15 +140,12 @@ function ButtonPopupList<D extends DnDItemType>(
|
|
|
140
140
|
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
141
141
|
|
|
142
142
|
// State
|
|
143
|
-
const [selectedIds,
|
|
143
|
+
const [selectedIds, setSelectedIds] = React.useState<D["id"][]>([]);
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
React.useEffect(() => {
|
|
146
|
+
// Sort items by ids for first load
|
|
147
147
|
items.sortByProperty("id", ids);
|
|
148
|
-
setSelectedIdsBase(ids);
|
|
149
|
-
};
|
|
150
148
|
|
|
151
|
-
React.useEffect(() => {
|
|
152
149
|
// Set selected ids
|
|
153
150
|
setSelectedIds([...ids]);
|
|
154
151
|
}, [ids]);
|
package/src/SelectEx.tsx
CHANGED
|
@@ -22,6 +22,14 @@ import IconButton from "@mui/material/IconButton";
|
|
|
22
22
|
import FormHelperText from "@mui/material/FormHelperText";
|
|
23
23
|
import RefreshIcon from "@mui/icons-material/Refresh";
|
|
24
24
|
|
|
25
|
+
export type SelectExMethods = {
|
|
26
|
+
/**
|
|
27
|
+
* Set open state
|
|
28
|
+
* @param isOpen Open state
|
|
29
|
+
*/
|
|
30
|
+
setOpen: (isOpen: boolean) => void;
|
|
31
|
+
};
|
|
32
|
+
|
|
25
33
|
/**
|
|
26
34
|
* Extended select component props
|
|
27
35
|
*/
|
|
@@ -70,6 +78,11 @@ export type SelectExProps<
|
|
|
70
78
|
*/
|
|
71
79
|
loadData?: () => PromiseLike<T[] | null | undefined>;
|
|
72
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Methods
|
|
83
|
+
*/
|
|
84
|
+
mRef?: React.Ref<SelectExMethods>;
|
|
85
|
+
|
|
73
86
|
/**
|
|
74
87
|
* Item change callback
|
|
75
88
|
*/
|
|
@@ -128,6 +141,7 @@ export function SelectEx<
|
|
|
128
141
|
label,
|
|
129
142
|
labelField = "label" as L,
|
|
130
143
|
loadData,
|
|
144
|
+
mRef,
|
|
131
145
|
onItemChange,
|
|
132
146
|
onItemClick,
|
|
133
147
|
onLoadData,
|
|
@@ -202,6 +216,18 @@ export function SelectEx<
|
|
|
202
216
|
setValueStateBase(newValue);
|
|
203
217
|
};
|
|
204
218
|
|
|
219
|
+
const [open, setOpen] = React.useState(false);
|
|
220
|
+
|
|
221
|
+
React.useImperativeHandle(
|
|
222
|
+
mRef,
|
|
223
|
+
() => ({
|
|
224
|
+
setOpen: (isOpen: boolean) => {
|
|
225
|
+
setOpen(isOpen);
|
|
226
|
+
}
|
|
227
|
+
}),
|
|
228
|
+
[]
|
|
229
|
+
);
|
|
230
|
+
|
|
205
231
|
React.useEffect(() => {
|
|
206
232
|
if (valueSource != null) setValueState(valueSource);
|
|
207
233
|
}, [valueSource]);
|
|
@@ -308,9 +334,15 @@ export function SelectEx<
|
|
|
308
334
|
notched
|
|
309
335
|
label={label}
|
|
310
336
|
required={required}
|
|
311
|
-
inputProps={{
|
|
337
|
+
inputProps={{
|
|
338
|
+
"aria-hidden": false,
|
|
339
|
+
"data-reset": inputReset
|
|
340
|
+
}}
|
|
312
341
|
/>
|
|
313
342
|
}
|
|
343
|
+
open={open}
|
|
344
|
+
onClose={() => setOpen(false)}
|
|
345
|
+
onOpen={() => setOpen(true)}
|
|
314
346
|
labelId={labelId}
|
|
315
347
|
name={name}
|
|
316
348
|
multiple={multiple}
|