@etsoo/materialui 1.5.36 → 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.
@@ -47,10 +47,10 @@ export type ButtonPopupCheckboxProps<D extends DnDItemType> = Omit<ButtonProps,
47
47
  */
48
48
  onAdd?: (ids: string[]) => Promise<false | D[]>;
49
49
  /**
50
- * On change handler
50
+ * On value change handler
51
51
  * @param ids Ids
52
52
  */
53
- onChange?: (ids: D["id"][]) => void;
53
+ onValueChange?: (ids: D["id"][]) => void;
54
54
  /**
55
55
  * Popup title
56
56
  */
@@ -71,7 +71,7 @@ function ButtonPopupCheckbox(props) {
71
71
  // App
72
72
  const app = (0, ReactApp_1.useRequiredAppContext)();
73
73
  // Destruct
74
- const { addSplitter, ids, inputName, label, labelEnd, labelFormatter, labelField, labels = {}, loadData, onAdd, onChange, popupTitle = label, popupMessage, required = false, sx = { gap: 1, justifyContent: "flex-start" }, variant = "outlined", ...rest } = props;
74
+ const { addSplitter, ids, inputName, label, labelEnd, labelFormatter, labelField, labels = {}, loadData, onAdd, onValueChange, popupTitle = label, popupMessage, required = false, sx = { gap: 1, justifyContent: "flex-start" }, variant = "outlined", ...rest } = props;
75
75
  // Default labels
76
76
  if (!labels.add)
77
77
  labels.add = app.get("add");
@@ -103,7 +103,7 @@ function ButtonPopupCheckbox(props) {
103
103
  return false;
104
104
  }
105
105
  setValues(item);
106
- onChange?.(item);
106
+ onValueChange?.(item);
107
107
  },
108
108
  inputs: ((0, jsx_runtime_1.jsx)(ButtonPopupList, { addSplitter: addSplitter, ids: values, labelFormatter: labelFormatter, labelField: labelField, labels: labels, loadData: loadData, onAdd: onAdd })),
109
109
  fullScreen: app.smDown
@@ -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
  };
@@ -47,10 +47,10 @@ export type ButtonPopupCheckboxProps<D extends DnDItemType> = Omit<ButtonProps,
47
47
  */
48
48
  onAdd?: (ids: string[]) => Promise<false | D[]>;
49
49
  /**
50
- * On change handler
50
+ * On value change handler
51
51
  * @param ids Ids
52
52
  */
53
- onChange?: (ids: D["id"][]) => void;
53
+ onValueChange?: (ids: D["id"][]) => void;
54
54
  /**
55
55
  * Popup title
56
56
  */
@@ -65,7 +65,7 @@ export function ButtonPopupCheckbox(props) {
65
65
  // App
66
66
  const app = useRequiredAppContext();
67
67
  // Destruct
68
- const { addSplitter, ids, inputName, label, labelEnd, labelFormatter, labelField, labels = {}, loadData, onAdd, onChange, popupTitle = label, popupMessage, required = false, sx = { gap: 1, justifyContent: "flex-start" }, variant = "outlined", ...rest } = props;
68
+ const { addSplitter, ids, inputName, label, labelEnd, labelFormatter, labelField, labels = {}, loadData, onAdd, onValueChange, popupTitle = label, popupMessage, required = false, sx = { gap: 1, justifyContent: "flex-start" }, variant = "outlined", ...rest } = props;
69
69
  // Default labels
70
70
  if (!labels.add)
71
71
  labels.add = app.get("add");
@@ -97,7 +97,7 @@ export function ButtonPopupCheckbox(props) {
97
97
  return false;
98
98
  }
99
99
  setValues(item);
100
- onChange?.(item);
100
+ onValueChange?.(item);
101
101
  },
102
102
  inputs: (_jsx(ButtonPopupList, { addSplitter: addSplitter, ids: values, labelFormatter: labelFormatter, labelField: labelField, labels: labels, loadData: loadData, onAdd: onAdd })),
103
103
  fullScreen: app.smDown
@@ -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.36",
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",
@@ -75,10 +75,10 @@ export type ButtonPopupCheckboxProps<D extends DnDItemType> = Omit<
75
75
  onAdd?: (ids: string[]) => Promise<false | D[]>;
76
76
 
77
77
  /**
78
- * On change handler
78
+ * On value change handler
79
79
  * @param ids Ids
80
80
  */
81
- onChange?: (ids: D["id"][]) => void;
81
+ onValueChange?: (ids: D["id"][]) => void;
82
82
 
83
83
  /**
84
84
  * Popup title
@@ -258,7 +258,7 @@ export function ButtonPopupCheckbox<D extends DnDItemType>(
258
258
  labels = {},
259
259
  loadData,
260
260
  onAdd,
261
- onChange,
261
+ onValueChange,
262
262
  popupTitle = label,
263
263
  popupMessage,
264
264
  required = false,
@@ -299,7 +299,7 @@ export function ButtonPopupCheckbox<D extends DnDItemType>(
299
299
 
300
300
  setValues(item);
301
301
 
302
- onChange?.(item);
302
+ onValueChange?.(item);
303
303
  },
304
304
  inputs: (
305
305
  <ButtonPopupList
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
  };