@etsoo/materialui 1.5.66 → 1.5.67

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;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.66",
3
+ "version": "1.5.67",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -40,7 +40,7 @@
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",
@@ -81,7 +81,7 @@
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
86
  "typescript": "^5.8.3",
87
87
  "vitest": "^3.2.4"
@@ -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
  }