@etsoo/materialui 1.6.6 → 1.6.7
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 +5 -6
- package/lib/cjs/TagListPro.js +2 -4
- package/lib/mjs/TagList.js +5 -6
- package/lib/mjs/TagListPro.js +2 -4
- package/package.json +1 -1
- package/src/TagList.tsx +5 -6
- package/src/TagListPro.tsx +2 -5
package/lib/cjs/TagList.js
CHANGED
|
@@ -27,13 +27,12 @@ function TagList(props) {
|
|
|
27
27
|
const [open, setOpen] = react_1.default.useState(false);
|
|
28
28
|
const [options, setOptions] = react_1.default.useState([]);
|
|
29
29
|
const [loading, setLoading] = react_1.default.useState(false);
|
|
30
|
-
const
|
|
31
|
-
currentValue.current = value ?? [];
|
|
30
|
+
const [valueState, setValueState] = react_1.default.useState(value ?? []);
|
|
32
31
|
const loadDataLocal = async (keyword) => {
|
|
33
32
|
setLoading(true);
|
|
34
33
|
const result = (await loadData(keyword, maxItems)) ?? [];
|
|
35
34
|
const len = result.length;
|
|
36
|
-
|
|
35
|
+
valueState.forEach((item) => {
|
|
37
36
|
if (!result.includes(item))
|
|
38
37
|
result.push(item);
|
|
39
38
|
});
|
|
@@ -60,10 +59,10 @@ function TagList(props) {
|
|
|
60
59
|
event.preventDefault();
|
|
61
60
|
event.stopPropagation();
|
|
62
61
|
await loadDataLocal(event.target.value);
|
|
63
|
-
}, ...inputProps, ...params })), getOptionDisabled: (item) => {
|
|
62
|
+
}, ...inputProps, ...params })), getOptionLabel: getOptionLabel, getOptionDisabled: (item) => {
|
|
64
63
|
return item === moreLabel;
|
|
65
|
-
}, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value:
|
|
66
|
-
|
|
64
|
+
}, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value: valueState, onChange: (event, value, reason, details) => {
|
|
65
|
+
setValueState(value);
|
|
67
66
|
if (onChange)
|
|
68
67
|
onChange(event, value, reason, details);
|
|
69
68
|
}, ...rest }));
|
package/lib/cjs/TagListPro.js
CHANGED
|
@@ -29,13 +29,11 @@ function TagListPro(props) {
|
|
|
29
29
|
const [options, setOptions] = react_1.default.useState([]);
|
|
30
30
|
const [loading, setLoading] = react_1.default.useState(false);
|
|
31
31
|
const [valueState, setValueState] = react_1.default.useState(value ?? []);
|
|
32
|
-
const currentValue = react_1.default.useRef([]);
|
|
33
|
-
currentValue.current = valueState;
|
|
34
32
|
const loadDataLocal = async (keyword) => {
|
|
35
33
|
setLoading(true);
|
|
36
34
|
const result = (await loadData(keyword, maxItems)) ?? [];
|
|
37
35
|
const len = result.length;
|
|
38
|
-
|
|
36
|
+
valueState.forEach((item) => {
|
|
39
37
|
if (!result.some((r) => r.id === item.id))
|
|
40
38
|
result.push(item);
|
|
41
39
|
});
|
|
@@ -77,7 +75,7 @@ function TagListPro(props) {
|
|
|
77
75
|
"name" in item &&
|
|
78
76
|
item["name"] === moreLabel);
|
|
79
77
|
}, getOptionKey: getOptionKey, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value: valueState, onChange: (event, value, reason, details) => {
|
|
80
|
-
|
|
78
|
+
setValueState(value);
|
|
81
79
|
if (onChange)
|
|
82
80
|
onChange(event, value, reason, details);
|
|
83
81
|
}, ...rest }));
|
package/lib/mjs/TagList.js
CHANGED
|
@@ -21,13 +21,12 @@ export function TagList(props) {
|
|
|
21
21
|
const [open, setOpen] = React.useState(false);
|
|
22
22
|
const [options, setOptions] = React.useState([]);
|
|
23
23
|
const [loading, setLoading] = React.useState(false);
|
|
24
|
-
const
|
|
25
|
-
currentValue.current = value ?? [];
|
|
24
|
+
const [valueState, setValueState] = React.useState(value ?? []);
|
|
26
25
|
const loadDataLocal = async (keyword) => {
|
|
27
26
|
setLoading(true);
|
|
28
27
|
const result = (await loadData(keyword, maxItems)) ?? [];
|
|
29
28
|
const len = result.length;
|
|
30
|
-
|
|
29
|
+
valueState.forEach((item) => {
|
|
31
30
|
if (!result.includes(item))
|
|
32
31
|
result.push(item);
|
|
33
32
|
});
|
|
@@ -54,10 +53,10 @@ export function TagList(props) {
|
|
|
54
53
|
event.preventDefault();
|
|
55
54
|
event.stopPropagation();
|
|
56
55
|
await loadDataLocal(event.target.value);
|
|
57
|
-
}, ...inputProps, ...params })), getOptionDisabled: (item) => {
|
|
56
|
+
}, ...inputProps, ...params })), getOptionLabel: getOptionLabel, getOptionDisabled: (item) => {
|
|
58
57
|
return item === moreLabel;
|
|
59
|
-
}, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value:
|
|
60
|
-
|
|
58
|
+
}, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value: valueState, onChange: (event, value, reason, details) => {
|
|
59
|
+
setValueState(value);
|
|
61
60
|
if (onChange)
|
|
62
61
|
onChange(event, value, reason, details);
|
|
63
62
|
}, ...rest }));
|
package/lib/mjs/TagListPro.js
CHANGED
|
@@ -23,13 +23,11 @@ export function TagListPro(props) {
|
|
|
23
23
|
const [options, setOptions] = React.useState([]);
|
|
24
24
|
const [loading, setLoading] = React.useState(false);
|
|
25
25
|
const [valueState, setValueState] = React.useState(value ?? []);
|
|
26
|
-
const currentValue = React.useRef([]);
|
|
27
|
-
currentValue.current = valueState;
|
|
28
26
|
const loadDataLocal = async (keyword) => {
|
|
29
27
|
setLoading(true);
|
|
30
28
|
const result = (await loadData(keyword, maxItems)) ?? [];
|
|
31
29
|
const len = result.length;
|
|
32
|
-
|
|
30
|
+
valueState.forEach((item) => {
|
|
33
31
|
if (!result.some((r) => r.id === item.id))
|
|
34
32
|
result.push(item);
|
|
35
33
|
});
|
|
@@ -71,7 +69,7 @@ export function TagListPro(props) {
|
|
|
71
69
|
"name" in item &&
|
|
72
70
|
item["name"] === moreLabel);
|
|
73
71
|
}, getOptionKey: getOptionKey, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value: valueState, onChange: (event, value, reason, details) => {
|
|
74
|
-
|
|
72
|
+
setValueState(value);
|
|
75
73
|
if (onChange)
|
|
76
74
|
onChange(event, value, reason, details);
|
|
77
75
|
}, ...rest }));
|
package/package.json
CHANGED
package/src/TagList.tsx
CHANGED
|
@@ -85,9 +85,7 @@ export function TagList(props: TagListProps) {
|
|
|
85
85
|
const [open, setOpen] = React.useState(false);
|
|
86
86
|
const [options, setOptions] = React.useState<readonly string[]>([]);
|
|
87
87
|
const [loading, setLoading] = React.useState(false);
|
|
88
|
-
|
|
89
|
-
const currentValue = React.useRef<readonly string[]>([]);
|
|
90
|
-
currentValue.current = value ?? [];
|
|
88
|
+
const [valueState, setValueState] = React.useState<string[]>(value ?? []);
|
|
91
89
|
|
|
92
90
|
const loadDataLocal = async (keyword?: string) => {
|
|
93
91
|
setLoading(true);
|
|
@@ -95,7 +93,7 @@ export function TagList(props: TagListProps) {
|
|
|
95
93
|
|
|
96
94
|
const len = result.length;
|
|
97
95
|
|
|
98
|
-
|
|
96
|
+
valueState.forEach((item) => {
|
|
99
97
|
if (!result.includes(item)) result.push(item);
|
|
100
98
|
});
|
|
101
99
|
|
|
@@ -146,15 +144,16 @@ export function TagList(props: TagListProps) {
|
|
|
146
144
|
{...params}
|
|
147
145
|
/>
|
|
148
146
|
)}
|
|
147
|
+
getOptionLabel={getOptionLabel}
|
|
149
148
|
getOptionDisabled={(item) => {
|
|
150
149
|
return item === moreLabel;
|
|
151
150
|
}}
|
|
152
151
|
noOptionsText={noOptionsText}
|
|
153
152
|
loadingText={loadingText}
|
|
154
153
|
openText={openText}
|
|
155
|
-
value={
|
|
154
|
+
value={valueState}
|
|
156
155
|
onChange={(event, value, reason, details) => {
|
|
157
|
-
|
|
156
|
+
setValueState(value);
|
|
158
157
|
if (onChange) onChange(event, value, reason, details);
|
|
159
158
|
}}
|
|
160
159
|
{...rest}
|
package/src/TagListPro.tsx
CHANGED
|
@@ -107,15 +107,12 @@ export function TagListPro<D extends ListType2 = ListType2>(
|
|
|
107
107
|
const [loading, setLoading] = React.useState(false);
|
|
108
108
|
const [valueState, setValueState] = React.useState<D[]>(value ?? []);
|
|
109
109
|
|
|
110
|
-
const currentValue = React.useRef<readonly D[]>([]);
|
|
111
|
-
currentValue.current = valueState;
|
|
112
|
-
|
|
113
110
|
const loadDataLocal = async (keyword?: string) => {
|
|
114
111
|
setLoading(true);
|
|
115
112
|
const result = (await loadData(keyword, maxItems)) ?? [];
|
|
116
113
|
const len = result.length;
|
|
117
114
|
|
|
118
|
-
|
|
115
|
+
valueState.forEach((item) => {
|
|
119
116
|
if (!result.some((r) => r.id === item.id)) result.push(item);
|
|
120
117
|
});
|
|
121
118
|
|
|
@@ -190,7 +187,7 @@ export function TagListPro<D extends ListType2 = ListType2>(
|
|
|
190
187
|
openText={openText}
|
|
191
188
|
value={valueState}
|
|
192
189
|
onChange={(event, value, reason, details) => {
|
|
193
|
-
|
|
190
|
+
setValueState(value);
|
|
194
191
|
if (onChange) onChange(event, value, reason, details);
|
|
195
192
|
}}
|
|
196
193
|
{...rest}
|