@etsoo/materialui 1.5.37 → 1.5.38

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.
@@ -51,7 +51,11 @@ function SelectEx(props) {
51
51
  const v = defaultValue ?? value;
52
52
  const valueSource = react_1.default.useMemo(() => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""), [multiple, v]);
53
53
  const setOptionsAdd = react_1.default.useCallback((options) => {
54
- setOptions(options);
54
+ const localOptions = [...options];
55
+ if (autoAddBlankItem) {
56
+ shared_1.Utils.addBlankItem(localOptions, idField, labelField);
57
+ }
58
+ setOptions(localOptions);
55
59
  if (valueSource != null)
56
60
  doItemChange(options, valueSource, false);
57
61
  }, [valueSource]);
@@ -114,9 +118,6 @@ function SelectEx(props) {
114
118
  return;
115
119
  if (onLoadData)
116
120
  onLoadData(result);
117
- if (autoAddBlankItem) {
118
- shared_1.Utils.addBlankItem(result, idField, labelField);
119
- }
120
121
  setOptionsAdd(result);
121
122
  });
122
123
  };
@@ -45,7 +45,11 @@ export function SelectEx(props) {
45
45
  const v = defaultValue ?? value;
46
46
  const valueSource = React.useMemo(() => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""), [multiple, v]);
47
47
  const setOptionsAdd = React.useCallback((options) => {
48
- setOptions(options);
48
+ const localOptions = [...options];
49
+ if (autoAddBlankItem) {
50
+ Utils.addBlankItem(localOptions, idField, labelField);
51
+ }
52
+ setOptions(localOptions);
49
53
  if (valueSource != null)
50
54
  doItemChange(options, valueSource, false);
51
55
  }, [valueSource]);
@@ -108,9 +112,6 @@ export function SelectEx(props) {
108
112
  return;
109
113
  if (onLoadData)
110
114
  onLoadData(result);
111
- if (autoAddBlankItem) {
112
- Utils.addBlankItem(result, idField, labelField);
113
- }
114
115
  setOptionsAdd(result);
115
116
  });
116
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.37",
3
+ "version": "1.5.38",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -40,13 +40,13 @@
40
40
  "@dnd-kit/sortable": "^10.0.0",
41
41
  "@emotion/react": "^11.14.0",
42
42
  "@emotion/styled": "^11.14.0",
43
- "@etsoo/appscript": "^1.6.29",
43
+ "@etsoo/appscript": "^1.6.31",
44
44
  "@etsoo/notificationbase": "^1.1.60",
45
45
  "@etsoo/react": "^1.8.40",
46
46
  "@etsoo/shared": "^1.2.70",
47
47
  "@mui/icons-material": "^7.0.2",
48
48
  "@mui/material": "^7.0.2",
49
- "@mui/x-data-grid": "^8.1.0",
49
+ "@mui/x-data-grid": "^8.2.0",
50
50
  "chart.js": "^4.4.9",
51
51
  "chartjs-plugin-datalabels": "^2.2.0",
52
52
  "dompurify": "^3.2.5",
@@ -66,13 +66,13 @@
66
66
  "@emotion/react": "$@emotion/react"
67
67
  },
68
68
  "devDependencies": {
69
- "@babel/cli": "^7.27.0",
70
- "@babel/core": "^7.26.10",
71
- "@babel/plugin-transform-runtime": "^7.26.10",
72
- "@babel/preset-env": "^7.26.9",
73
- "@babel/preset-react": "^7.26.3",
74
- "@babel/preset-typescript": "^7.27.0",
75
- "@babel/runtime-corejs3": "^7.27.0",
69
+ "@babel/cli": "^7.27.1",
70
+ "@babel/core": "^7.27.1",
71
+ "@babel/plugin-transform-runtime": "^7.27.1",
72
+ "@babel/preset-env": "^7.27.1",
73
+ "@babel/preset-react": "^7.27.1",
74
+ "@babel/preset-typescript": "^7.27.1",
75
+ "@babel/runtime-corejs3": "^7.27.1",
76
76
  "@testing-library/react": "^16.3.0",
77
77
  "@types/pica": "^9.0.5",
78
78
  "@types/pulltorefreshjs": "^0.1.7",
package/src/SelectEx.tsx CHANGED
@@ -176,7 +176,11 @@ export function SelectEx<
176
176
 
177
177
  const setOptionsAdd = React.useCallback(
178
178
  (options: readonly T[]) => {
179
- setOptions(options);
179
+ const localOptions = [...options];
180
+ if (autoAddBlankItem) {
181
+ Utils.addBlankItem(localOptions, idField, labelField);
182
+ }
183
+ setOptions(localOptions);
180
184
  if (valueSource != null) doItemChange(options, valueSource, false);
181
185
  },
182
186
  [valueSource]
@@ -246,9 +250,6 @@ export function SelectEx<
246
250
  loadData().then((result) => {
247
251
  if (result == null || !isMounted.current) return;
248
252
  if (onLoadData) onLoadData(result);
249
- if (autoAddBlankItem) {
250
- Utils.addBlankItem(result, idField, labelField);
251
- }
252
253
  setOptionsAdd(result);
253
254
  });
254
255
  };