@etsoo/materialui 1.0.57 → 1.0.58
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.
- package/__tests__/SelectEx.tsx +9 -2
- package/lib/SelectEx.js +3 -7
- package/package.json +1 -1
- package/src/SelectEx.tsx +7 -8
package/__tests__/SelectEx.tsx
CHANGED
|
@@ -86,15 +86,22 @@ it('Render multiple SelectEx', async () => {
|
|
|
86
86
|
fireEvent.mouseDown(button); // Not click
|
|
87
87
|
|
|
88
88
|
// Get list item
|
|
89
|
+
const itemName1 = await findByText(baseElement, 'Name 1');
|
|
90
|
+
const checkbox1 = itemName1.closest('li')?.querySelector('input');
|
|
91
|
+
|
|
92
|
+
expect(checkbox1?.checked).toBeTruthy();
|
|
93
|
+
|
|
89
94
|
const itemName3 = await findByText(baseElement, 'Name 3');
|
|
90
95
|
expect(itemName3.nodeName).toBe('SPAN');
|
|
91
96
|
|
|
92
97
|
// Checkbox
|
|
93
|
-
const
|
|
98
|
+
const checkbox3 = itemName3.closest('li')?.querySelector('input');
|
|
94
99
|
|
|
95
100
|
act(() => {
|
|
96
|
-
|
|
101
|
+
checkbox3?.click();
|
|
97
102
|
});
|
|
98
103
|
|
|
104
|
+
expect(checkbox3?.checked).toBeTruthy();
|
|
105
|
+
|
|
99
106
|
expect(itemChangeCallback).toBeCalledTimes(2);
|
|
100
107
|
});
|
package/lib/SelectEx.js
CHANGED
|
@@ -66,12 +66,6 @@ export function SelectEx(props) {
|
|
|
66
66
|
}, [valueSource]);
|
|
67
67
|
// Label id
|
|
68
68
|
const labelId = `selectex-label-${name}`;
|
|
69
|
-
// Item checked or not
|
|
70
|
-
const itemChecked = (id) => {
|
|
71
|
-
if (Array.isArray(valueState))
|
|
72
|
-
return valueState.indexOf(id) !== -1;
|
|
73
|
-
return valueState === id;
|
|
74
|
-
};
|
|
75
69
|
// Set item
|
|
76
70
|
const setItemValue = (id) => {
|
|
77
71
|
var _a;
|
|
@@ -183,7 +177,9 @@ export function SelectEx(props) {
|
|
|
183
177
|
}, style: itemStyle == null
|
|
184
178
|
? undefined
|
|
185
179
|
: itemStyle(option) },
|
|
186
|
-
multiple && (React.createElement(Checkbox, { checked:
|
|
180
|
+
multiple && (React.createElement(Checkbox, { checked: Array.isArray(valueState)
|
|
181
|
+
? valueState.includes(id)
|
|
182
|
+
: valueState === id })),
|
|
187
183
|
React.createElement(ListItemText, { primary: label }),
|
|
188
184
|
itemIconRenderer && (React.createElement(ListItemRightIcon, null, itemIconRenderer(option[idField])))));
|
|
189
185
|
})),
|
package/package.json
CHANGED
package/src/SelectEx.tsx
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
MenuItem,
|
|
9
9
|
OutlinedInput,
|
|
10
10
|
Select,
|
|
11
|
-
SelectChangeEvent,
|
|
12
11
|
SelectProps,
|
|
13
12
|
Stack
|
|
14
13
|
} from '@mui/material';
|
|
@@ -202,12 +201,6 @@ export function SelectEx<
|
|
|
202
201
|
// Label id
|
|
203
202
|
const labelId = `selectex-label-${name}`;
|
|
204
203
|
|
|
205
|
-
// Item checked or not
|
|
206
|
-
const itemChecked = (id: unknown) => {
|
|
207
|
-
if (Array.isArray(valueState)) return valueState.indexOf(id) !== -1;
|
|
208
|
-
return valueState === id;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
204
|
// Set item
|
|
212
205
|
const setItemValue = (id: unknown) => {
|
|
213
206
|
if (id != valueRef.current) {
|
|
@@ -376,7 +369,13 @@ export function SelectEx<
|
|
|
376
369
|
}
|
|
377
370
|
>
|
|
378
371
|
{multiple && (
|
|
379
|
-
<Checkbox
|
|
372
|
+
<Checkbox
|
|
373
|
+
checked={
|
|
374
|
+
Array.isArray(valueState)
|
|
375
|
+
? valueState.includes(id)
|
|
376
|
+
: valueState === id
|
|
377
|
+
}
|
|
378
|
+
/>
|
|
380
379
|
)}
|
|
381
380
|
<ListItemText primary={label} />
|
|
382
381
|
{itemIconRenderer && (
|