@dashadmin/dash-components 1.3.25 → 1.3.28
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/README.md +35 -0
- package/dist/components/AuditLog/AuditLog.js +345 -1
- package/dist/components/AuditLog/index.js +4 -1
- package/dist/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.js +630 -3
- package/dist/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.js +53 -1
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.js +647 -3
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.js +53 -1
- package/dist/components/Json/Json.js +235 -1
- package/dist/components/JsonColorSelector/JsonColorSelector.js +1172 -1
- package/dist/components/JsonColorSelector/JsonColorSelectorEnhanced.js +863 -2
- package/dist/components/JsonColorSelector/JsonCssVarValues.js +738 -1
- package/dist/components/JsonColorSelector/components/ColorEditDialog.js +426 -1
- package/dist/components/JsonColorSelector/components/ColorPaletteItem.js +75 -1
- package/dist/components/JsonColorSelector/components/ImageColorExtractor.js +283 -1
- package/dist/components/JsonColorSelector/helpers/functions.js +101 -1
- package/dist/components/JsonColorSelector/useAsyncColorThief.js +105 -1
- package/dist/components/ListActive/ListActive.js +126 -1
- package/dist/components/ListActive/ListBoolean.js +124 -1
- package/dist/components/NotificationPreferences/NotificationPreferences.js +317 -1
- package/dist/components/NotificationPreferences/index.js +7 -1
- package/dist/components/SearchableSelects/RASearchableSelect.js +236 -1
- package/dist/components/SearchableSelects/RASearchableSelectCheckboxes.js +479 -1
- package/dist/components/SearchableSelects/RASearchableSelectChips.js +465 -1
- package/dist/components/SearchableSelects/RASearchableSelectChipsRecordContext.js +295 -1
- package/dist/components/SearchableSelects/SearchableSelect.js +202 -1
- package/dist/components/SearchableSelects/SearchableSelectCheckboxes.js +290 -1
- package/dist/components/SortableDataGrid/SortableDataGrid.js +72 -1
- package/dist/components/SortableDataGrid/SortableDataGridBody.js +167 -1
- package/dist/components/SortableDataGrid/SortableDataGridHeader.js +109 -1
- package/dist/components/SortableDataGrid/SortableDataGridRow.js +283 -1
- package/dist/components/Upload/SingleImageUploader.js +40 -1
- package/dist/components/custom/PackageCopyMethod.js +78 -1
- package/dist/components/custom/PackageRadioButtonGroup.js +45 -1
- package/dist/components/dialog/Basic.js +8 -1
- package/dist/components/dialog/Correct.js +14 -1
- package/dist/components/dialog/Error.js +14 -1
- package/dist/components/dialog/Info.js +14 -1
- package/dist/components/dialog/InfoV2.js +21 -1
- package/dist/components/dialog/NotFound.js +14 -1
- package/dist/components/dialog/QuickSearch.js +117 -1
- package/dist/components/notifications/NotificationsCenter.js +597 -1
- package/dist/components/notifications/index.js +24 -1
- package/dist/components/tables/PaginationComponent.js +36 -1
- package/dist/components/theme/AppLoadingFallback.js +38 -2
- package/dist/components/theme/ErrorBoundary.js +52 -1
- package/dist/components/theme/InitialLoader.js +13 -1
- package/dist/components/theme/NotFound.js +136 -1
- package/dist/components/theme/NotResults.js +38 -1
- package/dist/hooks/useDraggable.js +6 -1
- package/dist/hooks/useNotifications.js +8 -1
- package/dist/hooks/useQuickSearch.js +26 -1
- package/dist/index.js +66 -5567
- package/dist/utils/setNativeValue.js +17 -1
- package/package.json +148 -132
- package/src/components/AuditLog/AuditLog.tsx +476 -0
- package/src/components/AuditLog/index.ts +2 -0
- package/src/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.tsx +917 -0
- package/src/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.tsx +39 -0
- package/src/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.tsx +916 -0
- package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.tsx +44 -0
- package/src/components/Json/Json.tsx +312 -0
- package/src/components/JsonColorSelector/JsonColorSelector.tsx +1435 -0
- package/src/components/JsonColorSelector/JsonColorSelectorEnhanced.tsx +1029 -0
- package/src/components/JsonColorSelector/JsonCssVarValues.tsx +863 -0
- package/src/components/JsonColorSelector/components/ColorEditDialog.tsx +491 -0
- package/src/components/JsonColorSelector/components/ColorPaletteItem.tsx +80 -0
- package/src/components/JsonColorSelector/components/ImageColorExtractor.tsx +328 -0
- package/src/components/JsonColorSelector/helpers/functions.tsx +123 -0
- package/src/components/JsonColorSelector/interfaces/interfaces.tsx +22 -0
- package/src/components/JsonColorSelector/useAsyncColorThief.tsx +97 -0
- package/src/components/ListActive/ListActive.tsx +106 -0
- package/src/components/ListActive/ListBoolean.tsx +96 -0
- package/src/components/NotificationPreferences/NotificationPreferences.tsx +463 -0
- package/src/components/NotificationPreferences/index.tsx +2 -0
- package/src/components/SearchableSelects/RASearchableSelect.tsx +300 -0
- package/src/components/SearchableSelects/RASearchableSelectCheckboxes.tsx +604 -0
- package/src/components/SearchableSelects/RASearchableSelectChips.tsx +558 -0
- package/src/components/SearchableSelects/RASearchableSelectChipsRecordContext.tsx +362 -0
- package/src/components/SearchableSelects/SearchableSelect.tsx +321 -0
- package/src/components/SearchableSelects/SearchableSelectCheckboxes.tsx +355 -0
- package/src/components/SortableDataGrid/SortableDataGrid.tsx +56 -0
- package/src/components/SortableDataGrid/SortableDataGridBody.tsx +175 -0
- package/src/components/SortableDataGrid/SortableDataGridHeader.tsx +171 -0
- package/src/components/SortableDataGrid/SortableDataGridRow.tsx +247 -0
- package/src/components/Upload/SingleImageUploader.tsx +55 -0
- package/src/components/custom/PackageCopyMethod.tsx +109 -0
- package/src/components/custom/PackageRadioButtonGroup.tsx +47 -0
- package/src/components/dialog/Basic.tsx +11 -0
- package/src/components/dialog/Correct.tsx +16 -0
- package/src/components/dialog/Error.tsx +15 -0
- package/src/components/dialog/Info.tsx +15 -0
- package/src/components/dialog/InfoV2.tsx +35 -0
- package/src/components/dialog/NotFound.tsx +18 -0
- package/src/components/dialog/QuickSearch.tsx +115 -0
- package/src/components/notifications/NotificationsCenter.tsx +792 -0
- package/src/components/notifications/index.ts +42 -0
- package/src/components/tables/PaginationComponent.tsx +17 -0
- package/src/components/theme/AppLoadingFallback.tsx +42 -0
- package/src/components/theme/ErrorBoundary.tsx +57 -0
- package/src/components/theme/InitialLoader.tsx +16 -0
- package/src/components/theme/NotFound.tsx +124 -0
- package/src/components/theme/NotResults.tsx +54 -0
- package/src/hooks/useDraggable.ts +11 -0
- package/src/hooks/useNotifications.ts +14 -0
- package/src/hooks/useQuickSearch.tsx +29 -0
- package/src/index.tsx +77 -0
- package/src/utils/setNativeValue.tsx +23 -0
- package/dist/color-thief-CTwGFhOB.js +0 -272
- /package/{dist → src}/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +0 -0
- /package/{dist → src}/components/JsonColorSelector/JsonColorSelector.tsx.bkup +0 -0
- /package/{dist → src}/components/SortableDataGrid/README.md +0 -0
- /package/{dist → src}/styles/index.less +0 -0
|
@@ -1 +1,479 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
import {
|
|
22
|
+
Box,
|
|
23
|
+
Checkbox,
|
|
24
|
+
CircularProgress,
|
|
25
|
+
TextField,
|
|
26
|
+
Typography,
|
|
27
|
+
Chip,
|
|
28
|
+
List,
|
|
29
|
+
ListItem,
|
|
30
|
+
ListItemButton,
|
|
31
|
+
ListItemIcon,
|
|
32
|
+
ListItemText,
|
|
33
|
+
Paper,
|
|
34
|
+
Popper,
|
|
35
|
+
ClickAwayListener,
|
|
36
|
+
InputAdornment,
|
|
37
|
+
IconButton
|
|
38
|
+
} from "@mui/material";
|
|
39
|
+
import { useEffect, useState, useRef } from "react";
|
|
40
|
+
import { useGetList } from "react-admin";
|
|
41
|
+
import { LoadingIndicator } from "react-admin";
|
|
42
|
+
import SearchIcon from "@mui/icons-material/Search";
|
|
43
|
+
import ClearIcon from "@mui/icons-material/Clear";
|
|
44
|
+
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
45
|
+
import ExpandLessIcon from "@mui/icons-material/ExpandLess";
|
|
46
|
+
const SearchableSelectCheckboxes = ({
|
|
47
|
+
isMultiple = true,
|
|
48
|
+
// Default to true for checkbox version
|
|
49
|
+
searchResults = 50,
|
|
50
|
+
minSearch = 1,
|
|
51
|
+
minOptions = 10,
|
|
52
|
+
timerSearch = 300,
|
|
53
|
+
resource,
|
|
54
|
+
selectLabel,
|
|
55
|
+
renderText,
|
|
56
|
+
transformData = (val) => val,
|
|
57
|
+
queryFilter = "q",
|
|
58
|
+
defaultValues = void 0,
|
|
59
|
+
value,
|
|
60
|
+
onChange,
|
|
61
|
+
isEmpty = false,
|
|
62
|
+
filter,
|
|
63
|
+
isOptionEqualToValue,
|
|
64
|
+
viewAttribute = null,
|
|
65
|
+
valueKeyId = "id",
|
|
66
|
+
transformOption,
|
|
67
|
+
disabled = false,
|
|
68
|
+
placeholder = "",
|
|
69
|
+
emptyText = "",
|
|
70
|
+
fullWidth = true,
|
|
71
|
+
maxHeight = 300,
|
|
72
|
+
showSelectAll = true,
|
|
73
|
+
showSelectedCount = true
|
|
74
|
+
}) => {
|
|
75
|
+
var _a;
|
|
76
|
+
const [open, setOpen] = useState(false);
|
|
77
|
+
const [fullyLoaded, setFullyLoaded] = useState(false);
|
|
78
|
+
const [parsedOptions, setParsedOptions] = useState([]);
|
|
79
|
+
const [q, setQ] = useState("");
|
|
80
|
+
const [selectedOptions, setSelectedOptions] = useState([]);
|
|
81
|
+
const [timeOutSearch, setTimeOutSearch] = useState(void 0);
|
|
82
|
+
const anchorRef = useRef(null);
|
|
83
|
+
const [searchInputValue, setSearchInputValue] = useState("");
|
|
84
|
+
const _transformOption = (option, caller) => {
|
|
85
|
+
if (typeof transformOption === "function") {
|
|
86
|
+
return transformOption(option, parsedOptions, caller);
|
|
87
|
+
}
|
|
88
|
+
return option;
|
|
89
|
+
};
|
|
90
|
+
const getIncludes = () => {
|
|
91
|
+
const currentValue = value || defaultValues;
|
|
92
|
+
if (!currentValue) return [];
|
|
93
|
+
if (Array.isArray(currentValue)) {
|
|
94
|
+
return currentValue.map(
|
|
95
|
+
(item) => typeof item === "object" ? item[valueKeyId] : item
|
|
96
|
+
).filter(Boolean);
|
|
97
|
+
}
|
|
98
|
+
const id = typeof currentValue === "object" ? currentValue[valueKeyId] : currentValue;
|
|
99
|
+
return id ? [id] : [];
|
|
100
|
+
};
|
|
101
|
+
const includes = getIncludes();
|
|
102
|
+
const buildFilterParams = () => {
|
|
103
|
+
const baseFilter = __spreadValues({}, filter);
|
|
104
|
+
if (includes.length > 0) {
|
|
105
|
+
baseFilter.includes = includes;
|
|
106
|
+
}
|
|
107
|
+
if (q && q.length >= minSearch) {
|
|
108
|
+
baseFilter[queryFilter] = q;
|
|
109
|
+
baseFilter.mixed_results = true;
|
|
110
|
+
baseFilter.min_options = minOptions;
|
|
111
|
+
baseFilter.limit = searchResults;
|
|
112
|
+
} else {
|
|
113
|
+
baseFilter.limit = Math.max(minOptions, searchResults);
|
|
114
|
+
}
|
|
115
|
+
return baseFilter;
|
|
116
|
+
};
|
|
117
|
+
const {
|
|
118
|
+
data: resourceSearchResults,
|
|
119
|
+
isLoading: isResourceSearchLoading,
|
|
120
|
+
error: isResourceSearchErrored
|
|
121
|
+
} = useGetList(resource, {
|
|
122
|
+
meta: { removeSortFilters: true },
|
|
123
|
+
filter: buildFilterParams()
|
|
124
|
+
});
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (resourceSearchResults) {
|
|
127
|
+
const resultsArray = Array.isArray(resourceSearchResults) ? resourceSearchResults : Object.values(resourceSearchResults);
|
|
128
|
+
let processedOptions = resultsArray.map((ele, index) => {
|
|
129
|
+
const isSearchMatch = q && q.length >= minSearch ? ele[viewAttribute] && ele[viewAttribute].toLowerCase().includes(q.toLowerCase()) : true;
|
|
130
|
+
return __spreadProps(__spreadValues({}, ele), {
|
|
131
|
+
key: `option-${ele[valueKeyId] || index}`,
|
|
132
|
+
isSearchMatch,
|
|
133
|
+
priority: isSearchMatch ? 1 : 2
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
processedOptions.sort((a, b) => {
|
|
137
|
+
if (a.priority !== b.priority) {
|
|
138
|
+
return a.priority - b.priority;
|
|
139
|
+
}
|
|
140
|
+
const nameA = a[viewAttribute] || a.name || "";
|
|
141
|
+
const nameB = b[viewAttribute] || b.name || "";
|
|
142
|
+
return nameA.localeCompare(nameB);
|
|
143
|
+
});
|
|
144
|
+
if (processedOptions.length > searchResults) {
|
|
145
|
+
processedOptions = processedOptions.slice(0, searchResults);
|
|
146
|
+
}
|
|
147
|
+
setParsedOptions(processedOptions);
|
|
148
|
+
}
|
|
149
|
+
}, [resourceSearchResults, valueKeyId, q, minSearch, viewAttribute, searchResults]);
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
const currentValue = value !== void 0 ? value : defaultValues;
|
|
152
|
+
if (currentValue === null || currentValue === void 0) {
|
|
153
|
+
setSelectedOptions([]);
|
|
154
|
+
setFullyLoaded(true);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
let initialSelectedOptions = [];
|
|
158
|
+
if (Array.isArray(currentValue)) {
|
|
159
|
+
initialSelectedOptions = currentValue;
|
|
160
|
+
} else if (currentValue) {
|
|
161
|
+
initialSelectedOptions = [currentValue];
|
|
162
|
+
}
|
|
163
|
+
setSelectedOptions(initialSelectedOptions);
|
|
164
|
+
setFullyLoaded(true);
|
|
165
|
+
}, [value, defaultValues]);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (parsedOptions.length > 0 && selectedOptions.length > 0) {
|
|
168
|
+
const updatedOptions = selectedOptions.map((selectedOption) => {
|
|
169
|
+
if (typeof selectedOption === "object" && selectedOption[viewAttribute]) {
|
|
170
|
+
return selectedOption;
|
|
171
|
+
}
|
|
172
|
+
const id = typeof selectedOption === "object" ? selectedOption[valueKeyId] : selectedOption;
|
|
173
|
+
return parsedOptions.find((option) => option[valueKeyId] === id) || selectedOption;
|
|
174
|
+
});
|
|
175
|
+
setSelectedOptions(updatedOptions);
|
|
176
|
+
}
|
|
177
|
+
}, [parsedOptions, viewAttribute, valueKeyId]);
|
|
178
|
+
const debounce = (fn, delay = 300) => {
|
|
179
|
+
clearTimeout(timeOutSearch);
|
|
180
|
+
setTimeOutSearch(
|
|
181
|
+
setTimeout(() => {
|
|
182
|
+
fn();
|
|
183
|
+
}, delay)
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
const handleSearchChange = (event) => {
|
|
187
|
+
const searchValue = event.target.value;
|
|
188
|
+
setSearchInputValue(searchValue);
|
|
189
|
+
if (searchValue && searchValue !== "" && searchValue.length >= minSearch) {
|
|
190
|
+
debounce(() => setQ(searchValue), timerSearch);
|
|
191
|
+
} else if (searchValue === "") {
|
|
192
|
+
setQ("");
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const handleClearSearch = () => {
|
|
196
|
+
setSearchInputValue("");
|
|
197
|
+
setQ("");
|
|
198
|
+
};
|
|
199
|
+
const isOptionSelected = (option) => {
|
|
200
|
+
return selectedOptions.some((selected) => {
|
|
201
|
+
const selectedId = typeof selected === "object" ? selected[valueKeyId] : selected;
|
|
202
|
+
const optionId = typeof option === "object" ? option[valueKeyId] : option;
|
|
203
|
+
return selectedId === optionId;
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
const handleOptionToggle = (option) => {
|
|
207
|
+
const isSelected = isOptionSelected(option);
|
|
208
|
+
let newSelectedOptions;
|
|
209
|
+
if (isSelected) {
|
|
210
|
+
newSelectedOptions = selectedOptions.filter((selected) => {
|
|
211
|
+
const selectedId = typeof selected === "object" ? selected[valueKeyId] : selected;
|
|
212
|
+
const optionId = typeof option === "object" ? option[valueKeyId] : option;
|
|
213
|
+
return selectedId !== optionId;
|
|
214
|
+
});
|
|
215
|
+
} else {
|
|
216
|
+
newSelectedOptions = [...selectedOptions, option];
|
|
217
|
+
}
|
|
218
|
+
setSelectedOptions(newSelectedOptions);
|
|
219
|
+
if (onChange) {
|
|
220
|
+
onChange(newSelectedOptions);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const handleSelectAll = () => {
|
|
224
|
+
const allSelected = parsedOptions.every((option) => isOptionSelected(option));
|
|
225
|
+
if (allSelected) {
|
|
226
|
+
const visibleIds = parsedOptions.map(
|
|
227
|
+
(option) => typeof option === "object" ? option[valueKeyId] : option
|
|
228
|
+
);
|
|
229
|
+
const newSelectedOptions = selectedOptions.filter((selected) => {
|
|
230
|
+
const selectedId = typeof selected === "object" ? selected[valueKeyId] : selected;
|
|
231
|
+
return !visibleIds.includes(selectedId);
|
|
232
|
+
});
|
|
233
|
+
setSelectedOptions(newSelectedOptions);
|
|
234
|
+
if (onChange) {
|
|
235
|
+
onChange(newSelectedOptions);
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
const newOptions = parsedOptions.filter((option) => !isOptionSelected(option));
|
|
239
|
+
const newSelectedOptions = [...selectedOptions, ...newOptions];
|
|
240
|
+
setSelectedOptions(newSelectedOptions);
|
|
241
|
+
if (onChange) {
|
|
242
|
+
onChange(newSelectedOptions);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
const getSelectedDisplayText = () => {
|
|
247
|
+
if (selectedOptions.length === 0) {
|
|
248
|
+
return placeholder || "Seleccionar opciones...";
|
|
249
|
+
}
|
|
250
|
+
if (showSelectedCount && selectedOptions.length > 2) {
|
|
251
|
+
return `${selectedOptions.length} elementos seleccionados`;
|
|
252
|
+
}
|
|
253
|
+
return selectedOptions.slice(0, 2).map((option) => renderText(_transformOption(option, "display"), "display")).join(", ") + (selectedOptions.length > 2 ? `, +${selectedOptions.length - 2} m\xE1s` : "");
|
|
254
|
+
};
|
|
255
|
+
const allVisibleSelected = parsedOptions.length > 0 && parsedOptions.every((option) => isOptionSelected(option));
|
|
256
|
+
const someVisibleSelected = parsedOptions.some((option) => isOptionSelected(option));
|
|
257
|
+
if (!fullyLoaded) return /* @__PURE__ */ jsx(LoadingIndicator, {});
|
|
258
|
+
return /* @__PURE__ */ jsxs(Box, { ref: anchorRef, sx: { position: "relative", width: fullWidth ? "100%" : "auto" }, children: [
|
|
259
|
+
/* @__PURE__ */ jsx(
|
|
260
|
+
TextField,
|
|
261
|
+
{
|
|
262
|
+
fullWidth,
|
|
263
|
+
label: selectLabel,
|
|
264
|
+
value: getSelectedDisplayText(),
|
|
265
|
+
onClick: () => setOpen(!open),
|
|
266
|
+
disabled,
|
|
267
|
+
variant: "outlined",
|
|
268
|
+
InputProps: {
|
|
269
|
+
readOnly: true,
|
|
270
|
+
endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(
|
|
271
|
+
IconButton,
|
|
272
|
+
{
|
|
273
|
+
onClick: (e) => {
|
|
274
|
+
e.stopPropagation();
|
|
275
|
+
setOpen(!open);
|
|
276
|
+
},
|
|
277
|
+
edge: "end",
|
|
278
|
+
size: "small",
|
|
279
|
+
children: open ? /* @__PURE__ */ jsx(ExpandLessIcon, {}) : /* @__PURE__ */ jsx(ExpandMoreIcon, {})
|
|
280
|
+
}
|
|
281
|
+
) })
|
|
282
|
+
},
|
|
283
|
+
sx: {
|
|
284
|
+
cursor: "pointer",
|
|
285
|
+
"& .MuiInputBase-input": {
|
|
286
|
+
cursor: "pointer"
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
),
|
|
291
|
+
selectedOptions.length > 0 && /* @__PURE__ */ jsxs(Box, { sx: { mt: 1, display: "flex", flexWrap: "wrap", gap: 0.5 }, children: [
|
|
292
|
+
selectedOptions.slice(0, 5).map((option, index) => /* @__PURE__ */ jsx(
|
|
293
|
+
Chip,
|
|
294
|
+
{
|
|
295
|
+
label: renderText(_transformOption(option, "chip"), "chip"),
|
|
296
|
+
size: "small",
|
|
297
|
+
onDelete: () => handleOptionToggle(option),
|
|
298
|
+
disabled
|
|
299
|
+
},
|
|
300
|
+
`chip-${option[valueKeyId] || index}`
|
|
301
|
+
)),
|
|
302
|
+
selectedOptions.length > 5 && /* @__PURE__ */ jsx(
|
|
303
|
+
Chip,
|
|
304
|
+
{
|
|
305
|
+
label: `+${selectedOptions.length - 5} m\xE1s`,
|
|
306
|
+
size: "small",
|
|
307
|
+
variant: "outlined"
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
] }),
|
|
311
|
+
/* @__PURE__ */ jsx(
|
|
312
|
+
Popper,
|
|
313
|
+
{
|
|
314
|
+
open,
|
|
315
|
+
anchorEl: anchorRef.current,
|
|
316
|
+
placement: "bottom-start",
|
|
317
|
+
style: { zIndex: 1300, width: (_a = anchorRef.current) == null ? void 0 : _a.offsetWidth },
|
|
318
|
+
children: /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: () => setOpen(false), children: /* @__PURE__ */ jsxs(
|
|
319
|
+
Paper,
|
|
320
|
+
{
|
|
321
|
+
elevation: 8,
|
|
322
|
+
sx: {
|
|
323
|
+
maxHeight: maxHeight + 100,
|
|
324
|
+
width: "100%",
|
|
325
|
+
overflow: "hidden",
|
|
326
|
+
display: "flex",
|
|
327
|
+
flexDirection: "column"
|
|
328
|
+
},
|
|
329
|
+
children: [
|
|
330
|
+
/* @__PURE__ */ jsx(Box, { sx: { p: 2, borderBottom: "1px solid #e0e0e0" }, children: /* @__PURE__ */ jsx(
|
|
331
|
+
TextField,
|
|
332
|
+
{
|
|
333
|
+
fullWidth: true,
|
|
334
|
+
size: "small",
|
|
335
|
+
placeholder: "Buscar...",
|
|
336
|
+
value: searchInputValue,
|
|
337
|
+
onChange: handleSearchChange,
|
|
338
|
+
InputProps: {
|
|
339
|
+
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(SearchIcon, { fontSize: "small" }) }),
|
|
340
|
+
endAdornment: searchInputValue && /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(
|
|
341
|
+
IconButton,
|
|
342
|
+
{
|
|
343
|
+
size: "small",
|
|
344
|
+
onClick: handleClearSearch,
|
|
345
|
+
children: /* @__PURE__ */ jsx(ClearIcon, { fontSize: "small" })
|
|
346
|
+
}
|
|
347
|
+
) })
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
) }),
|
|
351
|
+
showSelectAll && parsedOptions.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { borderBottom: "1px solid #e0e0e0" }, children: /* @__PURE__ */ jsx(ListItem, { disablePadding: true, children: /* @__PURE__ */ jsxs(ListItemButton, { onClick: handleSelectAll, dense: true, children: [
|
|
352
|
+
/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(
|
|
353
|
+
Checkbox,
|
|
354
|
+
{
|
|
355
|
+
checked: allVisibleSelected,
|
|
356
|
+
indeterminate: someVisibleSelected && !allVisibleSelected,
|
|
357
|
+
size: "small"
|
|
358
|
+
}
|
|
359
|
+
) }),
|
|
360
|
+
/* @__PURE__ */ jsx(
|
|
361
|
+
ListItemText,
|
|
362
|
+
{
|
|
363
|
+
primary: /* @__PURE__ */ jsxs(Typography, { variant: "body2", fontWeight: "bold", children: [
|
|
364
|
+
allVisibleSelected ? "Deseleccionar todo" : "Seleccionar todo",
|
|
365
|
+
q && ` (${parsedOptions.length} resultados)`
|
|
366
|
+
] })
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
] }) }) }),
|
|
370
|
+
isResourceSearchLoading && /* @__PURE__ */ jsxs(Box, { sx: { p: 2, display: "flex", justifyContent: "center", alignItems: "center" }, children: [
|
|
371
|
+
/* @__PURE__ */ jsx(CircularProgress, { size: 20 }),
|
|
372
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { ml: 1 }, children: "Cargando opciones..." })
|
|
373
|
+
] }),
|
|
374
|
+
!isResourceSearchLoading && /* @__PURE__ */ jsx(
|
|
375
|
+
List,
|
|
376
|
+
{
|
|
377
|
+
sx: {
|
|
378
|
+
maxHeight,
|
|
379
|
+
overflow: "auto",
|
|
380
|
+
py: 0
|
|
381
|
+
},
|
|
382
|
+
children: parsedOptions.length === 0 ? /* @__PURE__ */ jsx(ListItem, { children: /* @__PURE__ */ jsx(
|
|
383
|
+
ListItemText,
|
|
384
|
+
{
|
|
385
|
+
primary: /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", textAlign: "center", children: q ? "No se encontraron resultados" : "No hay opciones disponibles" })
|
|
386
|
+
}
|
|
387
|
+
) }) : parsedOptions.map((option, index) => {
|
|
388
|
+
const isSelected = isOptionSelected(option);
|
|
389
|
+
const isSearchMatch = option.isSearchMatch;
|
|
390
|
+
const hasSearchQuery = q && q.length >= minSearch;
|
|
391
|
+
return /* @__PURE__ */ jsx(ListItem, { disablePadding: true, children: /* @__PURE__ */ jsxs(
|
|
392
|
+
ListItemButton,
|
|
393
|
+
{
|
|
394
|
+
onClick: () => handleOptionToggle(option),
|
|
395
|
+
dense: true,
|
|
396
|
+
sx: {
|
|
397
|
+
// Style search matches differently
|
|
398
|
+
backgroundColor: hasSearchQuery && isSearchMatch ? "rgba(25, 118, 210, 0.04)" : "transparent",
|
|
399
|
+
borderLeft: hasSearchQuery && isSearchMatch ? "3px solid #1976d2" : "none",
|
|
400
|
+
paddingLeft: hasSearchQuery && isSearchMatch ? 1 : 2,
|
|
401
|
+
"&:hover": {
|
|
402
|
+
backgroundColor: hasSearchQuery && isSearchMatch ? "rgba(25, 118, 210, 0.08)" : "rgba(0, 0, 0, 0.04)"
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
children: [
|
|
406
|
+
/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(
|
|
407
|
+
Checkbox,
|
|
408
|
+
{
|
|
409
|
+
checked: isSelected,
|
|
410
|
+
size: "small",
|
|
411
|
+
tabIndex: -1,
|
|
412
|
+
disableRipple: true
|
|
413
|
+
}
|
|
414
|
+
) }),
|
|
415
|
+
/* @__PURE__ */ jsx(
|
|
416
|
+
ListItemText,
|
|
417
|
+
{
|
|
418
|
+
primary: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
419
|
+
/* @__PURE__ */ jsx(
|
|
420
|
+
Typography,
|
|
421
|
+
{
|
|
422
|
+
variant: "body2",
|
|
423
|
+
sx: {
|
|
424
|
+
fontWeight: hasSearchQuery && isSearchMatch ? "bold" : "normal",
|
|
425
|
+
opacity: hasSearchQuery && !isSearchMatch ? 0.7 : 1
|
|
426
|
+
},
|
|
427
|
+
children: renderText(_transformOption(option, "option"), "option")
|
|
428
|
+
}
|
|
429
|
+
),
|
|
430
|
+
hasSearchQuery && isSearchMatch && /* @__PURE__ */ jsx(
|
|
431
|
+
Typography,
|
|
432
|
+
{
|
|
433
|
+
variant: "caption",
|
|
434
|
+
sx: {
|
|
435
|
+
color: "#1976d2",
|
|
436
|
+
fontWeight: "bold",
|
|
437
|
+
fontSize: "0.75rem"
|
|
438
|
+
},
|
|
439
|
+
children: "\u2713"
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
] })
|
|
443
|
+
}
|
|
444
|
+
)
|
|
445
|
+
]
|
|
446
|
+
}
|
|
447
|
+
) }, option.key || `option-${index}`);
|
|
448
|
+
})
|
|
449
|
+
}
|
|
450
|
+
),
|
|
451
|
+
showSelectedCount && selectedOptions.length > 0 && /* @__PURE__ */ jsx(
|
|
452
|
+
Box,
|
|
453
|
+
{
|
|
454
|
+
sx: {
|
|
455
|
+
p: 1,
|
|
456
|
+
borderTop: "1px solid #e0e0e0",
|
|
457
|
+
backgroundColor: "#f5f5f5"
|
|
458
|
+
},
|
|
459
|
+
children: /* @__PURE__ */ jsxs(Typography, { variant: "caption", color: "text.secondary", children: [
|
|
460
|
+
selectedOptions.length,
|
|
461
|
+
" elemento",
|
|
462
|
+
selectedOptions.length !== 1 ? "s" : "",
|
|
463
|
+
" seleccionado",
|
|
464
|
+
selectedOptions.length !== 1 ? "s" : ""
|
|
465
|
+
] })
|
|
466
|
+
}
|
|
467
|
+
)
|
|
468
|
+
]
|
|
469
|
+
}
|
|
470
|
+
) })
|
|
471
|
+
}
|
|
472
|
+
)
|
|
473
|
+
] });
|
|
474
|
+
};
|
|
475
|
+
var RASearchableSelectCheckboxes_default = SearchableSelectCheckboxes;
|
|
476
|
+
export {
|
|
477
|
+
SearchableSelectCheckboxes,
|
|
478
|
+
RASearchableSelectCheckboxes_default as default
|
|
479
|
+
};
|