@etsoo/materialui 1.6.6 → 1.6.8

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.
@@ -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 currentValue = react_1.default.useRef([]);
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
- currentValue.current.forEach((item) => {
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: value, onChange: (event, value, reason, details) => {
66
- currentValue.current = value;
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 }));
@@ -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
- currentValue.current.forEach((item) => {
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
- currentValue.current = value;
78
+ setValueState(value);
81
79
  if (onChange)
82
80
  onChange(event, value, reason, details);
83
81
  }, ...rest }));
@@ -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 currentValue = React.useRef([]);
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
- currentValue.current.forEach((item) => {
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: value, onChange: (event, value, reason, details) => {
60
- currentValue.current = value;
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 }));
@@ -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
- currentValue.current.forEach((item) => {
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
- currentValue.current = value;
72
+ setValueState(value);
75
73
  if (onChange)
76
74
  onChange(event, value, reason, details);
77
75
  }, ...rest }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.6.6",
3
+ "version": "1.6.8",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -42,21 +42,21 @@
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.71",
45
+ "@etsoo/react": "^1.8.72",
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.25.0",
49
+ "@mui/x-data-grid": "^8.26.0",
50
50
  "chart.js": "^4.5.1",
51
51
  "chartjs-plugin-datalabels": "^2.2.0",
52
52
  "dompurify": "^3.3.1",
53
- "eventemitter3": "^5.0.1",
53
+ "eventemitter3": "^5.0.4",
54
54
  "pica": "^9.0.1",
55
55
  "pulltorefreshjs": "^0.1.22",
56
- "react": "^19.2.3",
56
+ "react": "^19.2.4",
57
57
  "react-avatar-editor": "^13.0.2",
58
58
  "react-chartjs-2": "^5.3.1",
59
- "react-dom": "^19.2.3",
59
+ "react-dom": "^19.2.4",
60
60
  "react-draggable": "^4.5.0",
61
61
  "react-imask": "7.6.1"
62
62
  },
@@ -72,16 +72,16 @@
72
72
  "@babel/preset-react": "^7.28.5",
73
73
  "@babel/preset-typescript": "^7.28.5",
74
74
  "@babel/runtime-corejs3": "^7.28.6",
75
- "@testing-library/react": "^16.3.1",
75
+ "@testing-library/react": "^16.3.2",
76
76
  "@types/pica": "^9.0.5",
77
77
  "@types/pulltorefreshjs": "^0.1.7",
78
- "@types/react": "^19.2.8",
78
+ "@types/react": "^19.2.10",
79
79
  "@types/react-avatar-editor": "^13.0.4",
80
80
  "@types/react-dom": "^19.2.3",
81
81
  "@types/react-input-mask": "^3.0.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.17"
85
+ "vitest": "^4.0.18"
86
86
  }
87
87
  }
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
- currentValue.current.forEach((item) => {
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={value}
154
+ value={valueState}
156
155
  onChange={(event, value, reason, details) => {
157
- currentValue.current = value;
156
+ setValueState(value);
158
157
  if (onChange) onChange(event, value, reason, details);
159
158
  }}
160
159
  {...rest}
@@ -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
- currentValue.current.forEach((item) => {
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
- currentValue.current = value;
190
+ setValueState(value);
194
191
  if (onChange) onChange(event, value, reason, details);
195
192
  }}
196
193
  {...rest}