@etsoo/materialui 1.5.66 → 1.5.68

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.
@@ -25,19 +25,24 @@ function ButtonPopupList(props) {
25
25
  const { addSplitter = /\s*[,;]\s*/, value = [], items, labelField, labelFormatter, labels, onAdd, onValueChange } = props;
26
26
  // Methods
27
27
  const dndRef = react_1.default.createRef();
28
- // Ref
28
+ // Refs
29
29
  const inputRef = react_1.default.useRef(null);
30
+ const tempSelectedIds = react_1.default.useRef([]);
30
31
  // State
31
32
  const [selectedIds, setSelectedIds] = react_1.default.useState([]);
33
+ const setSelectedIdsHandler = (ids) => {
34
+ tempSelectedIds.current = ids;
35
+ setSelectedIds(ids);
36
+ };
32
37
  react_1.default.useEffect(() => {
33
38
  // Sort items by ids for first load
34
39
  items.sortByProperty("id", value);
35
40
  // Set selected ids
36
- setSelectedIds([...value]);
41
+ setSelectedIdsHandler([...value]);
37
42
  }, [value]);
38
43
  return ((0, jsx_runtime_1.jsxs)(FlexBox_1.VBox, { gap: 2, children: [(0, jsx_runtime_1.jsx)(DnDList_1.DnDList, { component: Grid_1.default, componentProps: { container: true, spacing: 0 }, items: items, labelField: labelField, onFormChange: (items) => {
39
44
  const ids = items
40
- .filter((item) => selectedIds.includes(item.id))
45
+ .filter((item) => tempSelectedIds.current.includes(item.id))
41
46
  .map((item) => item.id);
42
47
  onValueChange(ids);
43
48
  }, itemRenderer: (item, index, nodeRef, actionNodeRef) => ((0, jsx_runtime_1.jsxs)(Grid_1.default, { size: { xs: 12, md: 6, lg: 4 }, display: "flex", justifyContent: "flex-start", alignItems: "center", gap: 1, ...nodeRef, children: [(0, jsx_runtime_1.jsx)(IconButton_1.default, { style: { cursor: "move" }, size: "small", title: labels?.dragIndicator, ...actionNodeRef, children: (0, jsx_runtime_1.jsx)(DragIndicator_1.default, {}) }), (0, jsx_runtime_1.jsx)(FormControlLabel_1.default, { control: (0, jsx_runtime_1.jsx)(Checkbox_1.default, { name: "item", value: item.id, checked: selectedIds.includes(item.id), onChange: (e) => {
@@ -45,7 +50,7 @@ function ButtonPopupList(props) {
45
50
  const newIds = [
46
51
  ...selectedIds.toggleItem(item.id, checked)
47
52
  ];
48
- setSelectedIds(newIds);
53
+ setSelectedIdsHandler(newIds);
49
54
  } }), label: `${index + 1}. ${labelFormatter(item)}` })] })), height: 200, mRef: dndRef }), onAdd && ((0, jsx_runtime_1.jsxs)(FlexBox_1.HBox, { gap: 1, children: [(0, jsx_runtime_1.jsx)(TextField_1.default, { variant: "outlined", label: labels?.more, fullWidth: true, inputRef: inputRef }), (0, jsx_runtime_1.jsx)(Button_1.default, { sx: { width: "120px" }, variant: "contained", startIcon: (0, jsx_runtime_1.jsx)(Add_1.default, {}), size: "small", onClick: async () => {
50
55
  if (inputRef.current == null)
51
56
  return;
@@ -3,7 +3,12 @@ import { SelectExProps } from "./SelectEx";
3
3
  /**
4
4
  * SelectBool props
5
5
  */
6
- export type SelectBoolProps = Omit<SelectExProps<ListType1>, "options" | "loadData">;
6
+ export type SelectBoolProps = Omit<SelectExProps<ListType1>, "options" | "loadData" | "value"> & {
7
+ /**
8
+ * Value
9
+ */
10
+ value?: boolean;
11
+ };
7
12
  /**
8
13
  * SelectBool (yes/no)
9
14
  * @param props Props
@@ -14,11 +14,11 @@ function SelectBool(props) {
14
14
  // Global app
15
15
  const app = (0, ReactApp_1.useAppContext)();
16
16
  // Destruct
17
- const { search = true, autoAddBlankItem = search, ...rest } = props;
17
+ const { search = true, autoAddBlankItem = search, value, ...rest } = props;
18
18
  // Options
19
19
  const options = app?.getBools() ?? [];
20
20
  if (autoAddBlankItem)
21
21
  shared_1.Utils.addBlankItem(options);
22
22
  // Layout
23
- return (0, jsx_runtime_1.jsx)(SelectEx_1.SelectEx, { options: options, search: search, ...rest });
23
+ return ((0, jsx_runtime_1.jsx)(SelectEx_1.SelectEx, { options: options, search: search, value: `${value ?? ""}`, ...rest }));
24
24
  }
@@ -19,19 +19,24 @@ function ButtonPopupList(props) {
19
19
  const { addSplitter = /\s*[,;]\s*/, value = [], items, labelField, labelFormatter, labels, onAdd, onValueChange } = props;
20
20
  // Methods
21
21
  const dndRef = React.createRef();
22
- // Ref
22
+ // Refs
23
23
  const inputRef = React.useRef(null);
24
+ const tempSelectedIds = React.useRef([]);
24
25
  // State
25
26
  const [selectedIds, setSelectedIds] = React.useState([]);
27
+ const setSelectedIdsHandler = (ids) => {
28
+ tempSelectedIds.current = ids;
29
+ setSelectedIds(ids);
30
+ };
26
31
  React.useEffect(() => {
27
32
  // Sort items by ids for first load
28
33
  items.sortByProperty("id", value);
29
34
  // Set selected ids
30
- setSelectedIds([...value]);
35
+ setSelectedIdsHandler([...value]);
31
36
  }, [value]);
32
37
  return (_jsxs(VBox, { gap: 2, children: [_jsx(DnDList, { component: Grid, componentProps: { container: true, spacing: 0 }, items: items, labelField: labelField, onFormChange: (items) => {
33
38
  const ids = items
34
- .filter((item) => selectedIds.includes(item.id))
39
+ .filter((item) => tempSelectedIds.current.includes(item.id))
35
40
  .map((item) => item.id);
36
41
  onValueChange(ids);
37
42
  }, itemRenderer: (item, index, nodeRef, actionNodeRef) => (_jsxs(Grid, { size: { xs: 12, md: 6, lg: 4 }, display: "flex", justifyContent: "flex-start", alignItems: "center", gap: 1, ...nodeRef, children: [_jsx(IconButton, { style: { cursor: "move" }, size: "small", title: labels?.dragIndicator, ...actionNodeRef, children: _jsx(DragIndicatorIcon, {}) }), _jsx(FormControlLabel, { control: _jsx(Checkbox, { name: "item", value: item.id, checked: selectedIds.includes(item.id), onChange: (e) => {
@@ -39,7 +44,7 @@ function ButtonPopupList(props) {
39
44
  const newIds = [
40
45
  ...selectedIds.toggleItem(item.id, checked)
41
46
  ];
42
- setSelectedIds(newIds);
47
+ setSelectedIdsHandler(newIds);
43
48
  } }), label: `${index + 1}. ${labelFormatter(item)}` })] })), height: 200, mRef: dndRef }), onAdd && (_jsxs(HBox, { gap: 1, children: [_jsx(TextField, { variant: "outlined", label: labels?.more, fullWidth: true, inputRef: inputRef }), _jsx(Button, { sx: { width: "120px" }, variant: "contained", startIcon: _jsx(AddIcon, {}), size: "small", onClick: async () => {
44
49
  if (inputRef.current == null)
45
50
  return;
@@ -3,7 +3,12 @@ import { SelectExProps } from "./SelectEx";
3
3
  /**
4
4
  * SelectBool props
5
5
  */
6
- export type SelectBoolProps = Omit<SelectExProps<ListType1>, "options" | "loadData">;
6
+ export type SelectBoolProps = Omit<SelectExProps<ListType1>, "options" | "loadData" | "value"> & {
7
+ /**
8
+ * Value
9
+ */
10
+ value?: boolean;
11
+ };
7
12
  /**
8
13
  * SelectBool (yes/no)
9
14
  * @param props Props
@@ -11,11 +11,11 @@ export function SelectBool(props) {
11
11
  // Global app
12
12
  const app = useAppContext();
13
13
  // Destruct
14
- const { search = true, autoAddBlankItem = search, ...rest } = props;
14
+ const { search = true, autoAddBlankItem = search, value, ...rest } = props;
15
15
  // Options
16
16
  const options = app?.getBools() ?? [];
17
17
  if (autoAddBlankItem)
18
18
  Utils.addBlankItem(options);
19
19
  // Layout
20
- return _jsx(SelectEx, { options: options, search: search, ...rest });
20
+ return (_jsx(SelectEx, { options: options, search: search, value: `${value ?? ""}`, ...rest }));
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.66",
3
+ "version": "1.5.68",
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.1",
43
- "@etsoo/appscript": "^1.6.42",
43
+ "@etsoo/appscript": "^1.6.43",
44
44
  "@etsoo/notificationbase": "^1.1.63",
45
45
  "@etsoo/react": "^1.8.49",
46
46
  "@etsoo/shared": "^1.2.75",
47
47
  "@mui/icons-material": "^7.2.0",
48
48
  "@mui/material": "^7.2.0",
49
- "@mui/x-data-grid": "^8.8.0",
49
+ "@mui/x-data-grid": "^8.9.2",
50
50
  "chart.js": "^4.5.0",
51
51
  "chartjs-plugin-datalabels": "^2.2.0",
52
52
  "dompurify": "^3.2.6",
@@ -72,7 +72,7 @@
72
72
  "@babel/preset-env": "^7.28.0",
73
73
  "@babel/preset-react": "^7.27.1",
74
74
  "@babel/preset-typescript": "^7.27.1",
75
- "@babel/runtime-corejs3": "^7.28.0",
75
+ "@babel/runtime-corejs3": "^7.28.2",
76
76
  "@testing-library/react": "^16.3.0",
77
77
  "@types/pica": "^9.0.5",
78
78
  "@types/pulltorefreshjs": "^0.1.7",
@@ -81,9 +81,9 @@
81
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
- "@vitejs/plugin-react": "^4.6.0",
84
+ "@vitejs/plugin-react": "^4.7.0",
85
85
  "jsdom": "^26.1.0",
86
- "typescript": "^5.8.3",
86
+ "typescript": "^5.9.2",
87
87
  "vitest": "^3.2.4"
88
88
  }
89
89
  }
@@ -136,18 +136,24 @@ function ButtonPopupList<D extends DnDItemType>(
136
136
  // Methods
137
137
  const dndRef = React.createRef<DnDListRef<D>>();
138
138
 
139
- // Ref
139
+ // Refs
140
140
  const inputRef = React.useRef<HTMLInputElement>(null);
141
+ const tempSelectedIds = React.useRef<D["id"][]>([]);
141
142
 
142
143
  // State
143
144
  const [selectedIds, setSelectedIds] = React.useState<D["id"][]>([]);
144
145
 
146
+ const setSelectedIdsHandler = (ids: D["id"][]) => {
147
+ tempSelectedIds.current = ids;
148
+ setSelectedIds(ids);
149
+ };
150
+
145
151
  React.useEffect(() => {
146
152
  // Sort items by ids for first load
147
153
  items.sortByProperty("id", value);
148
154
 
149
155
  // Set selected ids
150
- setSelectedIds([...value]);
156
+ setSelectedIdsHandler([...value]);
151
157
  }, [value]);
152
158
 
153
159
  return (
@@ -159,8 +165,9 @@ function ButtonPopupList<D extends DnDItemType>(
159
165
  labelField={labelField}
160
166
  onFormChange={(items) => {
161
167
  const ids = items
162
- .filter((item) => selectedIds.includes(item.id))
168
+ .filter((item) => tempSelectedIds.current.includes(item.id))
163
169
  .map((item) => item.id);
170
+
164
171
  onValueChange(ids);
165
172
  }}
166
173
  itemRenderer={(item, index, nodeRef, actionNodeRef) => (
@@ -191,7 +198,7 @@ function ButtonPopupList<D extends DnDItemType>(
191
198
  const newIds = [
192
199
  ...selectedIds.toggleItem(item.id, checked)
193
200
  ];
194
- setSelectedIds(newIds);
201
+ setSelectedIdsHandler(newIds);
195
202
  }}
196
203
  />
197
204
  }
@@ -7,8 +7,13 @@ import { useAppContext } from "./app/ReactApp";
7
7
  */
8
8
  export type SelectBoolProps = Omit<
9
9
  SelectExProps<ListType1>,
10
- "options" | "loadData"
11
- >;
10
+ "options" | "loadData" | "value"
11
+ > & {
12
+ /**
13
+ * Value
14
+ */
15
+ value?: boolean;
16
+ };
12
17
 
13
18
  /**
14
19
  * SelectBool (yes/no)
@@ -20,7 +25,7 @@ export function SelectBool(props: SelectBoolProps) {
20
25
  const app = useAppContext();
21
26
 
22
27
  // Destruct
23
- const { search = true, autoAddBlankItem = search, ...rest } = props;
28
+ const { search = true, autoAddBlankItem = search, value, ...rest } = props;
24
29
 
25
30
  // Options
26
31
  const options = app?.getBools() ?? [];
@@ -28,5 +33,12 @@ export function SelectBool(props: SelectBoolProps) {
28
33
  if (autoAddBlankItem) Utils.addBlankItem(options);
29
34
 
30
35
  // Layout
31
- return <SelectEx<ListType1> options={options} search={search} {...rest} />;
36
+ return (
37
+ <SelectEx<ListType1>
38
+ options={options}
39
+ search={search}
40
+ value={`${value ?? ""}`}
41
+ {...rest}
42
+ />
43
+ );
32
44
  }