@m4l/components 9.4.8 → 9.4.9
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/components/CheckableList/CheckableList.js +46 -23
- package/components/CheckableList/CheckableList.test.d.ts +1 -0
- package/components/CheckableList/dictionary.d.ts +1 -0
- package/components/CheckableList/hooks/useCheckableListHandlers.test.d.ts +1 -0
- package/components/CheckableList/hooks/useCheckableListItems.js +8 -6
- package/components/CheckableList/hooks/useCheckableListItems.test.d.ts +1 -0
- package/components/CheckableList/hooks/useCheckableListRender.js +44 -29
- package/components/CheckableList/hooks/useCheckableListRender.test.d.ts +1 -0
- package/components/CheckableList/hooks/useCheckableListSelection.test.d.ts +1 -0
- package/components/CheckableList/hooks/useCheckableListState.test.d.ts +1 -0
- package/components/CheckableList/hooks/useCheckableListVirtualization.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -143,9 +143,19 @@ const CheckableList = (props) => {
|
|
|
143
143
|
ownerState,
|
|
144
144
|
className: clsx(className, CHECKABLE_LIST_CLASSES.root),
|
|
145
145
|
"data-testid": dataTestId,
|
|
146
|
-
"aria-label": ariaLabel,
|
|
146
|
+
"aria-label": ariaLabel || "checkable list",
|
|
147
147
|
"aria-labelledby": ariaLabelledBy,
|
|
148
|
-
children: /* @__PURE__ */ jsx(LoadingContainerStyled, { ownerState, children: /* @__PURE__ */ jsx(
|
|
148
|
+
children: /* @__PURE__ */ jsx(LoadingContainerStyled, { ownerState, children: /* @__PURE__ */ jsx(
|
|
149
|
+
Skeleton,
|
|
150
|
+
{
|
|
151
|
+
variant: "rectangular",
|
|
152
|
+
width: "100%",
|
|
153
|
+
height: 200,
|
|
154
|
+
role: "status",
|
|
155
|
+
"aria-label": "Cargando lista de elementos",
|
|
156
|
+
"aria-live": "polite"
|
|
157
|
+
}
|
|
158
|
+
) })
|
|
149
159
|
}
|
|
150
160
|
);
|
|
151
161
|
}
|
|
@@ -156,24 +166,28 @@ const CheckableList = (props) => {
|
|
|
156
166
|
ownerState,
|
|
157
167
|
className: clsx(className, CHECKABLE_LIST_CLASSES.root),
|
|
158
168
|
"data-testid": dataTestId,
|
|
159
|
-
"
|
|
169
|
+
role: "group",
|
|
170
|
+
"aria-label": ariaLabel || "checkable list",
|
|
160
171
|
"aria-labelledby": ariaLabelledBy,
|
|
161
172
|
children: [
|
|
162
|
-
searchable && /* @__PURE__ */ jsx(SearchContainerStyled, { ownerState, children: /* @__PURE__ */ jsx(
|
|
173
|
+
searchable && /* @__PURE__ */ jsx(SearchContainerStyled, { ownerState, role: "search", children: /* @__PURE__ */ jsx(
|
|
163
174
|
SearchInputStyled,
|
|
164
175
|
{
|
|
176
|
+
role: "searchbox",
|
|
177
|
+
"aria-label": "search",
|
|
165
178
|
ownerState,
|
|
166
179
|
value: searchQuery,
|
|
167
180
|
onChange: (e) => setSearchQuery(e.target.value),
|
|
168
181
|
placeholder: getLabel(DICCTIONARY.label_search_placeholder),
|
|
169
182
|
size,
|
|
183
|
+
className: CHECKABLE_LIST_CLASSES.searchInput,
|
|
170
184
|
variant: "contained",
|
|
171
185
|
InputProps: {
|
|
172
186
|
startAdornment: /* @__PURE__ */ jsx(Icon, { src: urlIconSearch })
|
|
173
187
|
}
|
|
174
188
|
}
|
|
175
189
|
) }),
|
|
176
|
-
selectAll && hasItems && /* @__PURE__ */ jsxs(SelectAllContainerStyled, { ownerState, children: [
|
|
190
|
+
selectAll && hasItems && /* @__PURE__ */ jsxs(SelectAllContainerStyled, { ownerState, role: "group", "aria-label": "Seleccionar todo", children: [
|
|
177
191
|
/* @__PURE__ */ jsx(
|
|
178
192
|
SelectAllCheckboxStyled,
|
|
179
193
|
{
|
|
@@ -196,26 +210,35 @@ const CheckableList = (props) => {
|
|
|
196
210
|
}
|
|
197
211
|
)
|
|
198
212
|
] }),
|
|
199
|
-
/* @__PURE__ */ jsx(
|
|
200
|
-
|
|
201
|
-
{
|
|
202
|
-
ref: listRef,
|
|
203
|
-
height: refHeight.current,
|
|
204
|
-
width,
|
|
205
|
-
itemCount: virtualizedItems.length,
|
|
206
|
-
itemSize: getItemSize,
|
|
207
|
-
itemData: virtualizedItems,
|
|
208
|
-
layout: "vertical",
|
|
209
|
-
children: renderVirtualizedItem
|
|
210
|
-
}
|
|
211
|
-
) : null : /* @__PURE__ */ jsx(EmptyMessageWrapperStyled, { ownerState, children: /* @__PURE__ */ jsx(
|
|
212
|
-
ImageText,
|
|
213
|
+
/* @__PURE__ */ jsx(
|
|
214
|
+
ListContainerStyled,
|
|
213
215
|
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
ref: setContainerElement,
|
|
217
|
+
ownerState: { ...ownerState },
|
|
218
|
+
"aria-multiselectable": multiple ? "true" : "false",
|
|
219
|
+
children: hasItems ? refHeight.current > 0 ? /* @__PURE__ */ jsx(
|
|
220
|
+
VirtualizedListStyled,
|
|
221
|
+
{
|
|
222
|
+
ref: listRef,
|
|
223
|
+
height: refHeight.current,
|
|
224
|
+
width,
|
|
225
|
+
itemCount: virtualizedItems.length,
|
|
226
|
+
itemSize: getItemSize,
|
|
227
|
+
itemData: virtualizedItems,
|
|
228
|
+
layout: "vertical",
|
|
229
|
+
className: CHECKABLE_LIST_CLASSES.virtualizedList,
|
|
230
|
+
children: renderVirtualizedItem
|
|
231
|
+
}
|
|
232
|
+
) : null : /* @__PURE__ */ jsx(EmptyMessageWrapperStyled, { ownerState, role: "status", "aria-live": "polite", children: /* @__PURE__ */ jsx(
|
|
233
|
+
ImageText,
|
|
234
|
+
{
|
|
235
|
+
title: getLabel(DICCTIONARY.label_no_results),
|
|
236
|
+
message: getLabel(DICCTIONARY.label_no_results_description),
|
|
237
|
+
imageUrl: urlIconNoResults
|
|
238
|
+
}
|
|
239
|
+
) })
|
|
217
240
|
}
|
|
218
|
-
)
|
|
241
|
+
)
|
|
219
242
|
]
|
|
220
243
|
}
|
|
221
244
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,5 +10,6 @@ export declare const DICCTIONARY: {
|
|
|
10
10
|
readonly label_no_results_description: "checkable_list.label_no_results_description";
|
|
11
11
|
readonly label_group_title: "checkable_list.label_group_title";
|
|
12
12
|
readonly label_select_all: "checkable_list.label_select_all";
|
|
13
|
+
readonly label_loading: "checkable_list.label_loading";
|
|
13
14
|
};
|
|
14
15
|
export type TypeDictionary = typeof DICCTIONARY;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -14,25 +14,27 @@ const useCheckableListItems = ({
|
|
|
14
14
|
return items;
|
|
15
15
|
}, [items, groups, isGrouped]);
|
|
16
16
|
const filteredItems = useMemo(() => {
|
|
17
|
-
|
|
17
|
+
const trimmedQuery = searchQuery.trim();
|
|
18
|
+
if (!trimmedQuery) {
|
|
18
19
|
return normalizedItems;
|
|
19
20
|
}
|
|
20
|
-
const query =
|
|
21
|
+
const query = trimmedQuery.toLowerCase();
|
|
21
22
|
const defaultFilter = (item) => item.label.toLowerCase().includes(query) || item.description?.toLowerCase().includes(query);
|
|
22
23
|
return normalizedItems.filter(
|
|
23
|
-
(item) => filterFn ? filterFn(item,
|
|
24
|
+
(item) => filterFn ? filterFn(item, trimmedQuery) : defaultFilter(item)
|
|
24
25
|
);
|
|
25
26
|
}, [normalizedItems, searchQuery, filterFn]);
|
|
26
27
|
const filteredGroups = useMemo(() => {
|
|
27
|
-
|
|
28
|
+
const trimmedQuery = searchQuery.trim();
|
|
29
|
+
if (!isGrouped || !trimmedQuery) {
|
|
28
30
|
return groups || [];
|
|
29
31
|
}
|
|
30
|
-
const normalizedQuery =
|
|
32
|
+
const normalizedQuery = trimmedQuery.toLowerCase();
|
|
31
33
|
const defaultGroupFilter = (candidate) => candidate.label.toLowerCase().includes(normalizedQuery) || candidate.description?.toLowerCase().includes(normalizedQuery);
|
|
32
34
|
return (groups || []).map((group) => ({
|
|
33
35
|
...group,
|
|
34
36
|
items: group.items.filter(
|
|
35
|
-
(groupItem) => filterFn ? filterFn(groupItem,
|
|
37
|
+
(groupItem) => filterFn ? filterFn(groupItem, trimmedQuery) : defaultGroupFilter(groupItem)
|
|
36
38
|
)
|
|
37
39
|
})).filter((group) => group.items.length > 0);
|
|
38
40
|
}, [groups, isGrouped, searchQuery, filterFn]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -65,6 +65,10 @@ const useCheckableListRender = ({
|
|
|
65
65
|
ItemWrapperStyled,
|
|
66
66
|
{
|
|
67
67
|
ownerState: { size, variant, disabled: itemDisabled, selected: checked },
|
|
68
|
+
role: "option",
|
|
69
|
+
"aria-label": "item",
|
|
70
|
+
"aria-selected": checked,
|
|
71
|
+
"aria-disabled": itemDisabled,
|
|
68
72
|
onClick: () => !itemDisabled && handleItemToggle(item.id),
|
|
69
73
|
children: [
|
|
70
74
|
/* @__PURE__ */ jsx(
|
|
@@ -160,37 +164,48 @@ const useCheckableListRender = ({
|
|
|
160
164
|
)
|
|
161
165
|
] });
|
|
162
166
|
const groupBodyContent = customGroupContent ?? fallbackGroupLabel;
|
|
163
|
-
return /* @__PURE__ */ jsx(
|
|
164
|
-
|
|
167
|
+
return /* @__PURE__ */ jsx(
|
|
168
|
+
GroupWrapperStyled,
|
|
165
169
|
{
|
|
166
|
-
ownerState: { size, variant,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
170
|
+
ownerState: { size, variant, grouped: true, selected: checkboxState === true },
|
|
171
|
+
role: "group",
|
|
172
|
+
"aria-label": group.label,
|
|
173
|
+
"aria-expanded": isExpanded,
|
|
174
|
+
"aria-disabled": groupDisabled,
|
|
175
|
+
children: /* @__PURE__ */ jsxs(
|
|
176
|
+
GroupHeaderStyled,
|
|
177
|
+
{
|
|
178
|
+
ownerState: { size, variant, disabled: groupDisabled },
|
|
179
|
+
onClick: handleExpand,
|
|
180
|
+
children: [
|
|
181
|
+
showCheckboxOnGroup && /* @__PURE__ */ jsx(
|
|
182
|
+
GroupCheckboxStyled,
|
|
183
|
+
{
|
|
184
|
+
checked: checkboxState === true,
|
|
185
|
+
indeterminate: checkboxState === "indeterminate",
|
|
186
|
+
disabled: groupDisabled,
|
|
187
|
+
size: checkboxSize,
|
|
188
|
+
onChange: handleToggleGroup,
|
|
189
|
+
onClick: (e) => e.stopPropagation()
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
group.icon && /* @__PURE__ */ jsx(GroupIconStyled, { children: group.icon }),
|
|
193
|
+
/* @__PURE__ */ jsx("div", { style: { flex: 1, minWidth: 0 }, children: groupBodyContent }),
|
|
194
|
+
groupable && /* @__PURE__ */ jsx(
|
|
195
|
+
GroupToggleButtonStyled,
|
|
196
|
+
{
|
|
197
|
+
size,
|
|
198
|
+
variant: "text",
|
|
199
|
+
icon: isExpanded ? urlIconCompact : urlIconExpanded,
|
|
200
|
+
onClick: handleExpand,
|
|
201
|
+
"aria-label": isExpanded ? "Colapsar grupo" : "Expandir grupo"
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
)
|
|
192
207
|
}
|
|
193
|
-
)
|
|
208
|
+
);
|
|
194
209
|
},
|
|
195
210
|
[expandedGroups, disabled, isGroupFullySelected, isGroupPartiallySelected, getGroupItems, indeterminateBehavior, renderGroup, size, variant, showCheckboxOnGroup, checkboxSize, groupable, urlIconCompact, urlIconExpanded, handleGroupExpandToggle, handleGroupToggle, isItemSelected]
|
|
196
211
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|