@etsoo/materialui 1.5.37 → 1.5.39

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
  };
@@ -55,13 +55,15 @@ function CommonPage(props) {
55
55
  }
56
56
  }
57
57
  : undefined, [onUpdateAll, onUpdate, onRefresh]);
58
+ const stateDetector = react_1.default.useMemo(() => update && app?.stateDetector({ targetFields, update }), [update, targetFields]);
58
59
  react_1.default.useEffect(() => {
59
60
  if (updateRef.current && update) {
60
61
  update(true, []);
62
+ updateRef.current = false;
61
63
  }
62
64
  }, [update]);
63
65
  // Return the UI
64
- return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [update && app?.stateDetector({ targetFields, update }), (0, jsx_runtime_1.jsxs)(Container_1.default, { disableGutters: disableGutters, maxWidth: maxWidth, sx: sx, id: "page-container", ...rest, children: [(0, jsx_runtime_1.jsxs)(FabBox_1.FabBox, { sx: {
66
+ return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [stateDetector, (0, jsx_runtime_1.jsxs)(Container_1.default, { disableGutters: disableGutters, maxWidth: maxWidth, sx: sx, id: "page-container", ...rest, children: [(0, jsx_runtime_1.jsxs)(FabBox_1.FabBox, { sx: {
65
67
  zIndex: 1,
66
68
  ...(typeof fabTop === "function"
67
69
  ? fabTop(theme, fabPadding)
@@ -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
  };
@@ -49,13 +49,15 @@ export function CommonPage(props) {
49
49
  }
50
50
  }
51
51
  : undefined, [onUpdateAll, onUpdate, onRefresh]);
52
+ const stateDetector = React.useMemo(() => update && app?.stateDetector({ targetFields, update }), [update, targetFields]);
52
53
  React.useEffect(() => {
53
54
  if (updateRef.current && update) {
54
55
  update(true, []);
56
+ updateRef.current = false;
55
57
  }
56
58
  }, [update]);
57
59
  // Return the UI
58
- return (_jsxs(React.Fragment, { children: [update && app?.stateDetector({ targetFields, update }), _jsxs(Container, { disableGutters: disableGutters, maxWidth: maxWidth, sx: sx, id: "page-container", ...rest, children: [_jsxs(FabBox, { sx: {
60
+ return (_jsxs(React.Fragment, { children: [stateDetector, _jsxs(Container, { disableGutters: disableGutters, maxWidth: maxWidth, sx: sx, id: "page-container", ...rest, children: [_jsxs(FabBox, { sx: {
59
61
  zIndex: 1,
60
62
  ...(typeof fabTop === "function"
61
63
  ? fabTop(theme, fabPadding)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.37",
3
+ "version": "1.5.39",
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.32",
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,19 +66,19 @@
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",
79
79
  "@types/react": "^18.3.20",
80
80
  "@types/react-avatar-editor": "^13.0.4",
81
- "@types/react-dom": "^18.3.6",
81
+ "@types/react-dom": "^18.3.7",
82
82
  "@types/react-input-mask": "^3.0.6",
83
83
  "@types/react-window": "^1.8.8",
84
84
  "@vitejs/plugin-react": "^4.4.1",
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
  };
@@ -168,16 +168,22 @@ export function CommonPage(props: CommonPageProps) {
168
168
  [onUpdateAll, onUpdate, onRefresh]
169
169
  );
170
170
 
171
+ const stateDetector = React.useMemo(
172
+ () => update && app?.stateDetector({ targetFields, update }),
173
+ [update, targetFields]
174
+ );
175
+
171
176
  React.useEffect(() => {
172
177
  if (updateRef.current && update) {
173
178
  update(true, []);
179
+ updateRef.current = false;
174
180
  }
175
181
  }, [update]);
176
182
 
177
183
  // Return the UI
178
184
  return (
179
185
  <React.Fragment>
180
- {update && app?.stateDetector({ targetFields, update })}
186
+ {stateDetector}
181
187
  <Container
182
188
  disableGutters={disableGutters}
183
189
  maxWidth={maxWidth}