@etsoo/materialui 1.6.3 → 1.6.4
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/TagList.js +1 -0
- package/lib/cjs/TagListPro.d.ts +4 -0
- package/lib/cjs/TagListPro.js +14 -3
- package/lib/mjs/TagList.js +1 -0
- package/lib/mjs/TagListPro.d.ts +4 -0
- package/lib/mjs/TagListPro.js +14 -3
- package/package.json +8 -8
- package/src/TagList.tsx +1 -0
- package/src/TagListPro.tsx +19 -2
package/lib/cjs/TagList.js
CHANGED
|
@@ -53,6 +53,7 @@ function TagList(props) {
|
|
|
53
53
|
loadDataLocal();
|
|
54
54
|
}
|
|
55
55
|
}, onClose: () => {
|
|
56
|
+
setOptions([]);
|
|
56
57
|
setOpen(false);
|
|
57
58
|
}, options: options, loading: loading, disableCloseOnSelect: disableCloseOnSelect, clearOnBlur: true, openOnFocus: openOnFocus, renderOption: renderOption, renderValue: renderValue, renderInput: (params) => ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { label: label, onChangeDelay: async (event) => {
|
|
58
59
|
// Stop bubble
|
package/lib/cjs/TagListPro.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export type TagListProProps<D extends ListType2 = ListType2> = Omit<Autocomplete
|
|
|
10
10
|
* Load data callback
|
|
11
11
|
*/
|
|
12
12
|
loadData: (keyword: string | undefined, items: number) => PromiseLike<D[] | null | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Load value from ids
|
|
15
|
+
*/
|
|
16
|
+
loadIdValue?: () => PromiseLike<D[] | null | undefined>;
|
|
13
17
|
/**
|
|
14
18
|
* Input props
|
|
15
19
|
*/
|
package/lib/cjs/TagListPro.js
CHANGED
|
@@ -25,12 +25,13 @@ function TagListPro(props) {
|
|
|
25
25
|
const { getOptionKey = (option) => typeof option === "string" ? option : option.id, renderOption = ({ key, ...props }, option, { selected }) => ((0, jsx_runtime_1.jsx)("li", { ...props, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Checkbox_1.default, { icon: (0, jsx_runtime_1.jsx)(CheckBoxOutlineBlank_1.default, { fontSize: "small" }), checkedIcon: (0, jsx_runtime_1.jsx)(CheckBox_1.default, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), getLabel(option)] }) }, key)), renderValue = (value, getTagProps) => value.map((option, index) => {
|
|
26
26
|
const { key, ...rest } = getTagProps({ index });
|
|
27
27
|
return ((0, jsx_runtime_1.jsx)(Chip_1.default, { variant: "outlined", label: getLabel(option), ...rest }, key));
|
|
28
|
-
}), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, maxItems = 16, disableCloseOnSelect = true, openOnFocus = true, label, inputProps, onChange, value, ...rest } = props;
|
|
28
|
+
}), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, loadIdValue, maxItems = 16, disableCloseOnSelect = true, openOnFocus = true, label, inputProps, onChange, value, ...rest } = props;
|
|
29
29
|
const [open, setOpen] = react_1.default.useState(false);
|
|
30
30
|
const [options, setOptions] = react_1.default.useState([]);
|
|
31
31
|
const [loading, setLoading] = react_1.default.useState(false);
|
|
32
|
+
const [valueState, setValueState] = react_1.default.useState(value ?? []);
|
|
32
33
|
const currentValue = react_1.default.useRef([]);
|
|
33
|
-
currentValue.current =
|
|
34
|
+
currentValue.current = valueState;
|
|
34
35
|
const loadDataLocal = async (keyword) => {
|
|
35
36
|
setLoading(true);
|
|
36
37
|
const result = (await loadData(keyword, maxItems)) ?? [];
|
|
@@ -49,12 +50,22 @@ function TagListPro(props) {
|
|
|
49
50
|
setOptions(result);
|
|
50
51
|
setLoading(false);
|
|
51
52
|
};
|
|
53
|
+
react_1.default.useEffect(() => {
|
|
54
|
+
if (loadIdValue) {
|
|
55
|
+
loadIdValue().then((result) => {
|
|
56
|
+
if (result == null)
|
|
57
|
+
return;
|
|
58
|
+
setValueState(result);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, [loadIdValue]);
|
|
52
62
|
return ((0, jsx_runtime_1.jsx)(Autocomplete_1.default, { multiple: true, filterOptions: (options, _state) => options, open: open, onOpen: () => {
|
|
53
63
|
setOpen(true);
|
|
54
64
|
if (options.length === 0) {
|
|
55
65
|
loadDataLocal();
|
|
56
66
|
}
|
|
57
67
|
}, onClose: () => {
|
|
68
|
+
setOptions([]);
|
|
58
69
|
setOpen(false);
|
|
59
70
|
}, options: options, loading: loading, disableCloseOnSelect: disableCloseOnSelect, openOnFocus: openOnFocus, renderOption: renderOption, renderValue: renderValue, renderInput: (params) => ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { label: label, onChangeDelay: async (event) => {
|
|
60
71
|
// Stop bubble
|
|
@@ -65,7 +76,7 @@ function TagListPro(props) {
|
|
|
65
76
|
return (typeof item.id === "number" &&
|
|
66
77
|
item.id < 0 &&
|
|
67
78
|
getLabel(item) === moreLabel);
|
|
68
|
-
}, getOptionLabel: (item) => getLabel(item), getOptionKey: getOptionKey, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value:
|
|
79
|
+
}, getOptionLabel: (item) => getLabel(item), getOptionKey: getOptionKey, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value: valueState, onChange: (event, value, reason, details) => {
|
|
69
80
|
currentValue.current = value;
|
|
70
81
|
if (onChange)
|
|
71
82
|
onChange(event, value, reason, details);
|
package/lib/mjs/TagList.js
CHANGED
|
@@ -47,6 +47,7 @@ export function TagList(props) {
|
|
|
47
47
|
loadDataLocal();
|
|
48
48
|
}
|
|
49
49
|
}, onClose: () => {
|
|
50
|
+
setOptions([]);
|
|
50
51
|
setOpen(false);
|
|
51
52
|
}, options: options, loading: loading, disableCloseOnSelect: disableCloseOnSelect, clearOnBlur: true, openOnFocus: openOnFocus, renderOption: renderOption, renderValue: renderValue, renderInput: (params) => (_jsx(InputField, { label: label, onChangeDelay: async (event) => {
|
|
52
53
|
// Stop bubble
|
package/lib/mjs/TagListPro.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export type TagListProProps<D extends ListType2 = ListType2> = Omit<Autocomplete
|
|
|
10
10
|
* Load data callback
|
|
11
11
|
*/
|
|
12
12
|
loadData: (keyword: string | undefined, items: number) => PromiseLike<D[] | null | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Load value from ids
|
|
15
|
+
*/
|
|
16
|
+
loadIdValue?: () => PromiseLike<D[] | null | undefined>;
|
|
13
17
|
/**
|
|
14
18
|
* Input props
|
|
15
19
|
*/
|
package/lib/mjs/TagListPro.js
CHANGED
|
@@ -19,12 +19,13 @@ export function TagListPro(props) {
|
|
|
19
19
|
const { getOptionKey = (option) => typeof option === "string" ? option : option.id, renderOption = ({ key, ...props }, option, { selected }) => (_jsx("li", { ...props, children: _jsxs(_Fragment, { children: [_jsx(Checkbox, { icon: _jsx(CheckBoxOutlineBlankIcon, { fontSize: "small" }), checkedIcon: _jsx(CheckBoxIcon, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), getLabel(option)] }) }, key)), renderValue = (value, getTagProps) => value.map((option, index) => {
|
|
20
20
|
const { key, ...rest } = getTagProps({ index });
|
|
21
21
|
return (_jsx(Chip, { variant: "outlined", label: getLabel(option), ...rest }, key));
|
|
22
|
-
}), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, maxItems = 16, disableCloseOnSelect = true, openOnFocus = true, label, inputProps, onChange, value, ...rest } = props;
|
|
22
|
+
}), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, loadIdValue, maxItems = 16, disableCloseOnSelect = true, openOnFocus = true, label, inputProps, onChange, value, ...rest } = props;
|
|
23
23
|
const [open, setOpen] = React.useState(false);
|
|
24
24
|
const [options, setOptions] = React.useState([]);
|
|
25
25
|
const [loading, setLoading] = React.useState(false);
|
|
26
|
+
const [valueState, setValueState] = React.useState(value ?? []);
|
|
26
27
|
const currentValue = React.useRef([]);
|
|
27
|
-
currentValue.current =
|
|
28
|
+
currentValue.current = valueState;
|
|
28
29
|
const loadDataLocal = async (keyword) => {
|
|
29
30
|
setLoading(true);
|
|
30
31
|
const result = (await loadData(keyword, maxItems)) ?? [];
|
|
@@ -43,12 +44,22 @@ export function TagListPro(props) {
|
|
|
43
44
|
setOptions(result);
|
|
44
45
|
setLoading(false);
|
|
45
46
|
};
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
if (loadIdValue) {
|
|
49
|
+
loadIdValue().then((result) => {
|
|
50
|
+
if (result == null)
|
|
51
|
+
return;
|
|
52
|
+
setValueState(result);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}, [loadIdValue]);
|
|
46
56
|
return (_jsx(Autocomplete, { multiple: true, filterOptions: (options, _state) => options, open: open, onOpen: () => {
|
|
47
57
|
setOpen(true);
|
|
48
58
|
if (options.length === 0) {
|
|
49
59
|
loadDataLocal();
|
|
50
60
|
}
|
|
51
61
|
}, onClose: () => {
|
|
62
|
+
setOptions([]);
|
|
52
63
|
setOpen(false);
|
|
53
64
|
}, options: options, loading: loading, disableCloseOnSelect: disableCloseOnSelect, openOnFocus: openOnFocus, renderOption: renderOption, renderValue: renderValue, renderInput: (params) => (_jsx(InputField, { label: label, onChangeDelay: async (event) => {
|
|
54
65
|
// Stop bubble
|
|
@@ -59,7 +70,7 @@ export function TagListPro(props) {
|
|
|
59
70
|
return (typeof item.id === "number" &&
|
|
60
71
|
item.id < 0 &&
|
|
61
72
|
getLabel(item) === moreLabel);
|
|
62
|
-
}, getOptionLabel: (item) => getLabel(item), getOptionKey: getOptionKey, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value:
|
|
73
|
+
}, getOptionLabel: (item) => getLabel(item), getOptionKey: getOptionKey, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value: valueState, onChange: (event, value, reason, details) => {
|
|
63
74
|
currentValue.current = value;
|
|
64
75
|
if (onChange)
|
|
65
76
|
onChange(event, value, reason, details);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"@emotion/styled": "^11.14.1",
|
|
43
43
|
"@etsoo/appscript": "^1.6.53",
|
|
44
44
|
"@etsoo/notificationbase": "^1.1.66",
|
|
45
|
-
"@etsoo/react": "^1.8.
|
|
45
|
+
"@etsoo/react": "^1.8.71",
|
|
46
46
|
"@etsoo/shared": "^1.2.80",
|
|
47
47
|
"@mui/icons-material": "^7.3.7",
|
|
48
48
|
"@mui/material": "^7.3.7",
|
|
49
|
-
"@mui/x-data-grid": "^8.
|
|
49
|
+
"@mui/x-data-grid": "^8.25.0",
|
|
50
50
|
"chart.js": "^4.5.1",
|
|
51
51
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
52
52
|
"dompurify": "^3.3.1",
|
|
@@ -65,13 +65,13 @@
|
|
|
65
65
|
"react-dom": "$react-dom"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@babel/cli": "^7.28.
|
|
69
|
-
"@babel/core": "^7.28.
|
|
68
|
+
"@babel/cli": "^7.28.6",
|
|
69
|
+
"@babel/core": "^7.28.6",
|
|
70
70
|
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
71
|
-
"@babel/preset-env": "^7.28.
|
|
71
|
+
"@babel/preset-env": "^7.28.6",
|
|
72
72
|
"@babel/preset-react": "^7.28.5",
|
|
73
73
|
"@babel/preset-typescript": "^7.28.5",
|
|
74
|
-
"@babel/runtime-corejs3": "^7.28.
|
|
74
|
+
"@babel/runtime-corejs3": "^7.28.6",
|
|
75
75
|
"@testing-library/react": "^16.3.1",
|
|
76
76
|
"@types/pica": "^9.0.5",
|
|
77
77
|
"@types/pulltorefreshjs": "^0.1.7",
|
|
@@ -82,6 +82,6 @@
|
|
|
82
82
|
"@vitejs/plugin-react": "^5.1.2",
|
|
83
83
|
"jsdom": "^27.4.0",
|
|
84
84
|
"typescript": "^5.9.3",
|
|
85
|
-
"vitest": "^4.0.
|
|
85
|
+
"vitest": "^4.0.17"
|
|
86
86
|
}
|
|
87
87
|
}
|
package/src/TagList.tsx
CHANGED
package/src/TagListPro.tsx
CHANGED
|
@@ -25,6 +25,11 @@ export type TagListProProps<D extends ListType2 = ListType2> = Omit<
|
|
|
25
25
|
items: number
|
|
26
26
|
) => PromiseLike<D[] | null | undefined>;
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Load value from ids
|
|
30
|
+
*/
|
|
31
|
+
loadIdValue?: () => PromiseLike<D[] | null | undefined>;
|
|
32
|
+
|
|
28
33
|
/**
|
|
29
34
|
* Input props
|
|
30
35
|
*/
|
|
@@ -87,6 +92,7 @@ export function TagListPro<D extends ListType2 = ListType2>(
|
|
|
87
92
|
loadingText = loadingLabel,
|
|
88
93
|
openText = openDefault,
|
|
89
94
|
loadData,
|
|
95
|
+
loadIdValue,
|
|
90
96
|
maxItems = 16,
|
|
91
97
|
disableCloseOnSelect = true,
|
|
92
98
|
openOnFocus = true,
|
|
@@ -100,9 +106,10 @@ export function TagListPro<D extends ListType2 = ListType2>(
|
|
|
100
106
|
const [open, setOpen] = React.useState(false);
|
|
101
107
|
const [options, setOptions] = React.useState<readonly D[]>([]);
|
|
102
108
|
const [loading, setLoading] = React.useState(false);
|
|
109
|
+
const [valueState, setValueState] = React.useState<D[]>(value ?? []);
|
|
103
110
|
|
|
104
111
|
const currentValue = React.useRef<readonly D[]>([]);
|
|
105
|
-
currentValue.current =
|
|
112
|
+
currentValue.current = valueState;
|
|
106
113
|
|
|
107
114
|
const loadDataLocal = async (keyword?: string) => {
|
|
108
115
|
setLoading(true);
|
|
@@ -124,6 +131,15 @@ export function TagListPro<D extends ListType2 = ListType2>(
|
|
|
124
131
|
setLoading(false);
|
|
125
132
|
};
|
|
126
133
|
|
|
134
|
+
React.useEffect(() => {
|
|
135
|
+
if (loadIdValue) {
|
|
136
|
+
loadIdValue().then((result) => {
|
|
137
|
+
if (result == null) return;
|
|
138
|
+
setValueState(result);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}, [loadIdValue]);
|
|
142
|
+
|
|
127
143
|
return (
|
|
128
144
|
<Autocomplete<D, true, false, false>
|
|
129
145
|
multiple
|
|
@@ -136,6 +152,7 @@ export function TagListPro<D extends ListType2 = ListType2>(
|
|
|
136
152
|
}
|
|
137
153
|
}}
|
|
138
154
|
onClose={() => {
|
|
155
|
+
setOptions([]);
|
|
139
156
|
setOpen(false);
|
|
140
157
|
}}
|
|
141
158
|
options={options}
|
|
@@ -171,7 +188,7 @@ export function TagListPro<D extends ListType2 = ListType2>(
|
|
|
171
188
|
noOptionsText={noOptionsText}
|
|
172
189
|
loadingText={loadingText}
|
|
173
190
|
openText={openText}
|
|
174
|
-
value={
|
|
191
|
+
value={valueState}
|
|
175
192
|
onChange={(event, value, reason, details) => {
|
|
176
193
|
currentValue.current = value;
|
|
177
194
|
if (onChange) onChange(event, value, reason, details);
|