@dashadmin/dash-components 1.3.24 → 1.3.26
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/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 +149 -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,465 @@
|
|
|
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
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
+
import {
|
|
34
|
+
Autocomplete,
|
|
35
|
+
Box,
|
|
36
|
+
Chip,
|
|
37
|
+
CircularProgress,
|
|
38
|
+
TextField
|
|
39
|
+
} from "@mui/material";
|
|
40
|
+
import { useEffect, useState } from "react";
|
|
41
|
+
import { useGetList } from "react-admin";
|
|
42
|
+
import { LoadingIndicator } from "react-admin";
|
|
43
|
+
const SearchableSelectChips = ({
|
|
44
|
+
isMultiple = false,
|
|
45
|
+
searchResults = 50,
|
|
46
|
+
minSearch = 2,
|
|
47
|
+
minOptions = 10,
|
|
48
|
+
timerSearch = 500,
|
|
49
|
+
resource,
|
|
50
|
+
selectLabel,
|
|
51
|
+
renderText,
|
|
52
|
+
transformData = (val) => val,
|
|
53
|
+
queryFilter = "q",
|
|
54
|
+
defaultValues = void 0,
|
|
55
|
+
value,
|
|
56
|
+
onChange,
|
|
57
|
+
isEmpty = false,
|
|
58
|
+
filter,
|
|
59
|
+
isOptionEqualToValue,
|
|
60
|
+
viewAttribute = null,
|
|
61
|
+
valueKeyId = "id",
|
|
62
|
+
transformOption,
|
|
63
|
+
disabled = false,
|
|
64
|
+
placeholder = "",
|
|
65
|
+
emptyText = "",
|
|
66
|
+
fullWidth = true,
|
|
67
|
+
// 🔥 NEW: Mixed results props
|
|
68
|
+
enableMixedResults = false
|
|
69
|
+
}) => {
|
|
70
|
+
const [open, setOpen] = useState(false);
|
|
71
|
+
const [fullyLoaded, setFullyLoaded] = useState(false);
|
|
72
|
+
const [parsedOptions, setParsedOptions] = useState([]);
|
|
73
|
+
const [q, setQ] = useState("");
|
|
74
|
+
const [selectedOptions, setSelectedOptions] = useState([]);
|
|
75
|
+
const [timeOutSearch, setTimeOutSearch] = useState(void 0);
|
|
76
|
+
const _transformOption = (option, caller) => {
|
|
77
|
+
if (typeof transformOption === "function") {
|
|
78
|
+
return transformOption(option, parsedOptions, caller);
|
|
79
|
+
}
|
|
80
|
+
return option;
|
|
81
|
+
};
|
|
82
|
+
const getIncludes = () => {
|
|
83
|
+
const currentValue = value || defaultValues;
|
|
84
|
+
if (!currentValue) return [];
|
|
85
|
+
if (Array.isArray(currentValue)) {
|
|
86
|
+
return currentValue.map(
|
|
87
|
+
(item) => typeof item === "object" ? item[valueKeyId] : item
|
|
88
|
+
).filter(Boolean);
|
|
89
|
+
}
|
|
90
|
+
const id = typeof currentValue === "object" ? currentValue[valueKeyId] : currentValue;
|
|
91
|
+
return id ? [id] : [];
|
|
92
|
+
};
|
|
93
|
+
const includes = getIncludes();
|
|
94
|
+
const buildFilterParams = () => {
|
|
95
|
+
const baseFilter = __spreadValues({}, filter);
|
|
96
|
+
if (includes.length > 0) {
|
|
97
|
+
baseFilter.includes = includes;
|
|
98
|
+
}
|
|
99
|
+
console.log("\u{1F527} SearchableSelectChips DEBUG - buildFilterParams called:", {
|
|
100
|
+
resource,
|
|
101
|
+
enableMixedResults,
|
|
102
|
+
searchQuery: q,
|
|
103
|
+
hasSearch: q && q.length >= minSearch,
|
|
104
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
105
|
+
});
|
|
106
|
+
if (enableMixedResults) {
|
|
107
|
+
const mixedResultsValue = minOptions;
|
|
108
|
+
baseFilter.mixedResults = mixedResultsValue;
|
|
109
|
+
console.log("\u{1F525} SearchableSelectChips DEBUG - Mixed results enabled via query param:", {
|
|
110
|
+
resource,
|
|
111
|
+
mixedResults: mixedResultsValue,
|
|
112
|
+
searchQuery: q,
|
|
113
|
+
hasSearch: q && q.length >= minSearch,
|
|
114
|
+
baseFilter,
|
|
115
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
116
|
+
});
|
|
117
|
+
if (q && q.length >= minSearch) {
|
|
118
|
+
baseFilter[queryFilter] = q;
|
|
119
|
+
}
|
|
120
|
+
baseFilter.limit = searchResults;
|
|
121
|
+
} else {
|
|
122
|
+
if (q && q.length >= minSearch) {
|
|
123
|
+
baseFilter[queryFilter] = q;
|
|
124
|
+
baseFilter.mixed_results = true;
|
|
125
|
+
baseFilter.min_options = minOptions;
|
|
126
|
+
baseFilter.limit = searchResults;
|
|
127
|
+
console.log("\u{1F50D} SearchableSelectChips DEBUG - Legacy mixed results enabled:", {
|
|
128
|
+
resource,
|
|
129
|
+
searchQuery: q,
|
|
130
|
+
minOptions,
|
|
131
|
+
searchResults,
|
|
132
|
+
mixed_results: true,
|
|
133
|
+
baseFilter,
|
|
134
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
135
|
+
});
|
|
136
|
+
} else if (q === "") {
|
|
137
|
+
baseFilter.limit = Math.max(minOptions, searchResults);
|
|
138
|
+
} else {
|
|
139
|
+
baseFilter.limit = Math.max(minOptions, searchResults);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
console.log("\u{1F680} SearchableSelectChips DEBUG - Final filter params:", {
|
|
143
|
+
resource,
|
|
144
|
+
filterParams: baseFilter,
|
|
145
|
+
enableMixedResults,
|
|
146
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
147
|
+
});
|
|
148
|
+
return baseFilter;
|
|
149
|
+
};
|
|
150
|
+
const filterParams = buildFilterParams();
|
|
151
|
+
const {
|
|
152
|
+
data: resourceSearchResults,
|
|
153
|
+
isLoading: isResourceSearchLoading,
|
|
154
|
+
error: isResourceSearchErrored
|
|
155
|
+
} = useGetList(resource, {
|
|
156
|
+
meta: { removeSortFilters: true },
|
|
157
|
+
filter: filterParams
|
|
158
|
+
});
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (resourceSearchResults) {
|
|
161
|
+
const resultsArray = Array.isArray(resourceSearchResults) ? resourceSearchResults : Object.values(resourceSearchResults);
|
|
162
|
+
console.log("\u{1F4CA} SearchableSelectChips DEBUG - Processing results:", {
|
|
163
|
+
resource,
|
|
164
|
+
totalResults: resultsArray.length,
|
|
165
|
+
searchQuery: q,
|
|
166
|
+
hasSearch: q && q.length >= minSearch,
|
|
167
|
+
enableMixedResults,
|
|
168
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
169
|
+
});
|
|
170
|
+
let processedOptions = resultsArray.map((ele, index) => {
|
|
171
|
+
const isSearchMatch = q && q.length >= minSearch ? ele[viewAttribute] && ele[viewAttribute].toLowerCase().includes(q.toLowerCase()) : true;
|
|
172
|
+
return __spreadProps(__spreadValues({}, ele), {
|
|
173
|
+
key: `option-${ele[valueKeyId] || index}`,
|
|
174
|
+
isSearchMatch,
|
|
175
|
+
priority: isSearchMatch ? 1 : 2
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
processedOptions.sort((a, b) => {
|
|
179
|
+
if (a.priority !== b.priority) {
|
|
180
|
+
return a.priority - b.priority;
|
|
181
|
+
}
|
|
182
|
+
const nameA = a[viewAttribute] || a.name || "";
|
|
183
|
+
const nameB = b[viewAttribute] || b.name || "";
|
|
184
|
+
return nameA.localeCompare(nameB);
|
|
185
|
+
});
|
|
186
|
+
const searchMatches = processedOptions.filter((opt) => opt.isSearchMatch);
|
|
187
|
+
const nonMatches = processedOptions.filter((opt) => !opt.isSearchMatch);
|
|
188
|
+
console.log("\u{1F3AF} SearchableSelectChips DEBUG - Results breakdown:", {
|
|
189
|
+
resource,
|
|
190
|
+
searchQuery: q,
|
|
191
|
+
totalProcessed: processedOptions.length,
|
|
192
|
+
searchMatches: searchMatches.length,
|
|
193
|
+
nonMatches: nonMatches.length,
|
|
194
|
+
enableMixedResults,
|
|
195
|
+
mixedResultsParam: enableMixedResults ? minOptions : "disabled",
|
|
196
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
197
|
+
});
|
|
198
|
+
if (processedOptions.length > searchResults) {
|
|
199
|
+
processedOptions = processedOptions.slice(0, searchResults);
|
|
200
|
+
}
|
|
201
|
+
setParsedOptions(processedOptions);
|
|
202
|
+
}
|
|
203
|
+
}, [resourceSearchResults, valueKeyId, q, minSearch, viewAttribute, searchResults, minOptions, enableMixedResults]);
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
console.log("\u{1F50D} SearchableSelectChips DEBUG - Component initialized with resource:", {
|
|
206
|
+
resource,
|
|
207
|
+
resourceType: typeof resource,
|
|
208
|
+
selectLabel,
|
|
209
|
+
isMultiple,
|
|
210
|
+
minOptions,
|
|
211
|
+
searchResults,
|
|
212
|
+
minSearch,
|
|
213
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
214
|
+
});
|
|
215
|
+
}, []);
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
const currentValue = value !== void 0 ? value : defaultValues;
|
|
218
|
+
console.log("\u{1F3AF} SearchableSelectChips DEBUG - Value changed:", {
|
|
219
|
+
resource,
|
|
220
|
+
currentValue,
|
|
221
|
+
valueType: typeof currentValue,
|
|
222
|
+
isArray: Array.isArray(currentValue),
|
|
223
|
+
isMultiple,
|
|
224
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
225
|
+
});
|
|
226
|
+
if (currentValue === null || currentValue === void 0) {
|
|
227
|
+
setSelectedOptions([]);
|
|
228
|
+
setFullyLoaded(true);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
let initialSelectedOptions = [];
|
|
232
|
+
if (isMultiple) {
|
|
233
|
+
if (Array.isArray(currentValue)) {
|
|
234
|
+
initialSelectedOptions = currentValue;
|
|
235
|
+
} else if (currentValue) {
|
|
236
|
+
initialSelectedOptions = [currentValue];
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
if (currentValue) {
|
|
240
|
+
initialSelectedOptions = [currentValue];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
console.log("\u{1F3AF} SearchableSelectChips DEBUG - Selected options set:", {
|
|
244
|
+
resource,
|
|
245
|
+
currentValue,
|
|
246
|
+
initialSelectedOptions,
|
|
247
|
+
isMultiple,
|
|
248
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
249
|
+
});
|
|
250
|
+
setSelectedOptions(initialSelectedOptions);
|
|
251
|
+
setFullyLoaded(true);
|
|
252
|
+
}, [value, defaultValues, isMultiple]);
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
if (parsedOptions.length > 0 && selectedOptions.length > 0) {
|
|
255
|
+
const updatedOptions = selectedOptions.map((selectedOption) => {
|
|
256
|
+
if (typeof selectedOption === "object" && selectedOption[viewAttribute]) {
|
|
257
|
+
return selectedOption;
|
|
258
|
+
}
|
|
259
|
+
const id = typeof selectedOption === "object" ? selectedOption[valueKeyId] : selectedOption;
|
|
260
|
+
return parsedOptions.find((option) => option[valueKeyId] === id) || selectedOption;
|
|
261
|
+
});
|
|
262
|
+
setSelectedOptions(updatedOptions);
|
|
263
|
+
}
|
|
264
|
+
}, [parsedOptions, viewAttribute, valueKeyId]);
|
|
265
|
+
const debounce = (fn, delay = 500) => {
|
|
266
|
+
clearTimeout(timeOutSearch);
|
|
267
|
+
setTimeOutSearch(
|
|
268
|
+
setTimeout(() => {
|
|
269
|
+
fn();
|
|
270
|
+
}, delay)
|
|
271
|
+
);
|
|
272
|
+
};
|
|
273
|
+
const updateFieldValue = (newSelectedOptions) => {
|
|
274
|
+
setSelectedOptions(newSelectedOptions || []);
|
|
275
|
+
if (onChange) {
|
|
276
|
+
if (isMultiple) {
|
|
277
|
+
onChange(newSelectedOptions || []);
|
|
278
|
+
} else {
|
|
279
|
+
onChange(newSelectedOptions && newSelectedOptions.length > 0 ? newSelectedOptions[0] : null);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
if (!fullyLoaded) return /* @__PURE__ */ jsx(LoadingIndicator, {});
|
|
284
|
+
return /* @__PURE__ */ jsx(
|
|
285
|
+
Autocomplete,
|
|
286
|
+
{
|
|
287
|
+
multiple: isMultiple,
|
|
288
|
+
loading: isResourceSearchLoading,
|
|
289
|
+
fullWidth,
|
|
290
|
+
freeSolo: false,
|
|
291
|
+
options: parsedOptions,
|
|
292
|
+
open,
|
|
293
|
+
onOpen: () => setOpen(true),
|
|
294
|
+
onClose: () => setOpen(false),
|
|
295
|
+
value: isMultiple ? selectedOptions : selectedOptions[0] || null,
|
|
296
|
+
isOptionEqualToValue,
|
|
297
|
+
autoHighlight: true,
|
|
298
|
+
disabled,
|
|
299
|
+
getOptionLabel: (option) => {
|
|
300
|
+
if (!option) return "";
|
|
301
|
+
return renderText(_transformOption(option, "optionlabel"), "optionlabel") || "";
|
|
302
|
+
},
|
|
303
|
+
renderOption: (props, option) => {
|
|
304
|
+
const _a = props, { key } = _a, newProps = __objRest(_a, ["key"]);
|
|
305
|
+
const isSearchMatch = option.isSearchMatch;
|
|
306
|
+
const hasSearchQuery = q && q.length >= minSearch;
|
|
307
|
+
return /* @__PURE__ */ jsxs(
|
|
308
|
+
Box,
|
|
309
|
+
__spreadProps(__spreadValues({
|
|
310
|
+
component: "li",
|
|
311
|
+
sx: {
|
|
312
|
+
"& > img": { mr: 2, flexShrink: 0 },
|
|
313
|
+
// 🔥 ENHANCED: Better visual distinction for mixed results
|
|
314
|
+
fontWeight: hasSearchQuery && isSearchMatch ? "bold" : "normal",
|
|
315
|
+
opacity: hasSearchQuery && !isSearchMatch ? 0.7 : 1,
|
|
316
|
+
borderLeft: hasSearchQuery && isSearchMatch ? "3px solid #1976d2" : "none",
|
|
317
|
+
paddingLeft: hasSearchQuery && isSearchMatch ? 1 : 2,
|
|
318
|
+
backgroundColor: hasSearchQuery && isSearchMatch ? "rgba(25, 118, 210, 0.04)" : "transparent",
|
|
319
|
+
// 🔥 NEW: Add subtle separator between search matches and other options
|
|
320
|
+
borderTop: hasSearchQuery && !isSearchMatch && option.priority === 2 ? "1px solid rgba(0,0,0,0.1)" : "none",
|
|
321
|
+
marginTop: hasSearchQuery && !isSearchMatch && option.priority === 2 ? 0.5 : 0
|
|
322
|
+
}
|
|
323
|
+
}, newProps), {
|
|
324
|
+
children: [
|
|
325
|
+
hasSearchQuery && option.priority === 2 && parsedOptions.indexOf(option) === parsedOptions.findIndex((opt) => opt.priority === 2) && /* @__PURE__ */ jsx(
|
|
326
|
+
Box,
|
|
327
|
+
{
|
|
328
|
+
sx: {
|
|
329
|
+
position: "absolute",
|
|
330
|
+
top: -20,
|
|
331
|
+
left: 0,
|
|
332
|
+
right: 0,
|
|
333
|
+
fontSize: "0.7rem",
|
|
334
|
+
color: "text.secondary",
|
|
335
|
+
backgroundColor: "background.paper",
|
|
336
|
+
padding: "2px 8px",
|
|
337
|
+
borderBottom: "1px solid rgba(0,0,0,0.1)",
|
|
338
|
+
fontWeight: "bold"
|
|
339
|
+
},
|
|
340
|
+
children: "Otras opciones"
|
|
341
|
+
}
|
|
342
|
+
),
|
|
343
|
+
renderText(_transformOption(option, "option"), "option"),
|
|
344
|
+
hasSearchQuery && isSearchMatch && /* @__PURE__ */ jsxs(
|
|
345
|
+
Box,
|
|
346
|
+
{
|
|
347
|
+
component: "span",
|
|
348
|
+
sx: {
|
|
349
|
+
ml: "auto",
|
|
350
|
+
fontSize: "0.75rem",
|
|
351
|
+
color: "#1976d2",
|
|
352
|
+
fontWeight: "bold",
|
|
353
|
+
display: "flex",
|
|
354
|
+
alignItems: "center",
|
|
355
|
+
gap: 0.5
|
|
356
|
+
},
|
|
357
|
+
children: [
|
|
358
|
+
/* @__PURE__ */ jsx(
|
|
359
|
+
Box,
|
|
360
|
+
{
|
|
361
|
+
component: "span",
|
|
362
|
+
sx: {
|
|
363
|
+
width: 6,
|
|
364
|
+
height: 6,
|
|
365
|
+
borderRadius: "50%",
|
|
366
|
+
backgroundColor: "#1976d2"
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
),
|
|
370
|
+
"Coincidencia"
|
|
371
|
+
]
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
]
|
|
375
|
+
}),
|
|
376
|
+
option.key || `option-${option[valueKeyId]}`
|
|
377
|
+
);
|
|
378
|
+
},
|
|
379
|
+
renderValue: (tagValue, getTagProps) => {
|
|
380
|
+
return tagValue.map((option, index) => {
|
|
381
|
+
const chipProps = getTagProps({ index });
|
|
382
|
+
return /* @__PURE__ */ jsx(
|
|
383
|
+
Chip,
|
|
384
|
+
__spreadValues({
|
|
385
|
+
label: renderText(_transformOption(option, "chip"), "chip")
|
|
386
|
+
}, chipProps),
|
|
387
|
+
`chip-${option[valueKeyId] || index}`
|
|
388
|
+
);
|
|
389
|
+
});
|
|
390
|
+
},
|
|
391
|
+
onChange: (event, rawValue) => {
|
|
392
|
+
console.log("\u{1F504} SearchableSelectChips DEBUG - Autocomplete onChange:", {
|
|
393
|
+
resource,
|
|
394
|
+
rawValue,
|
|
395
|
+
isMultiple,
|
|
396
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
397
|
+
});
|
|
398
|
+
if (isMultiple) {
|
|
399
|
+
updateFieldValue(Array.isArray(rawValue) ? rawValue : []);
|
|
400
|
+
} else {
|
|
401
|
+
updateFieldValue(rawValue ? [rawValue] : []);
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
renderInput: (params) => /* @__PURE__ */ jsx(
|
|
405
|
+
TextField,
|
|
406
|
+
__spreadProps(__spreadValues({}, params), {
|
|
407
|
+
label: selectLabel,
|
|
408
|
+
variant: "outlined",
|
|
409
|
+
placeholder,
|
|
410
|
+
onChange: (ev) => {
|
|
411
|
+
const searchValue = ev.target.value;
|
|
412
|
+
console.log("\u{1F50D} SearchableSelectChips DEBUG - Search input changed:", {
|
|
413
|
+
resource,
|
|
414
|
+
searchValue,
|
|
415
|
+
searchLength: searchValue.length,
|
|
416
|
+
minSearch,
|
|
417
|
+
willTriggerSearch: searchValue.length >= minSearch,
|
|
418
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
419
|
+
});
|
|
420
|
+
if (searchValue && searchValue !== "" && searchValue.length >= minSearch) {
|
|
421
|
+
debounce(() => {
|
|
422
|
+
console.log("\u{1F680} SearchableSelectChips DEBUG - Triggering search:", {
|
|
423
|
+
resource,
|
|
424
|
+
searchValue,
|
|
425
|
+
minOptions,
|
|
426
|
+
searchResults,
|
|
427
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
428
|
+
});
|
|
429
|
+
setQ(searchValue);
|
|
430
|
+
}, timerSearch);
|
|
431
|
+
} else if (searchValue === "") {
|
|
432
|
+
console.log("\u{1F504} SearchableSelectChips DEBUG - Clearing search:", {
|
|
433
|
+
resource,
|
|
434
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
435
|
+
});
|
|
436
|
+
setQ("");
|
|
437
|
+
}
|
|
438
|
+
},
|
|
439
|
+
slotProps: {
|
|
440
|
+
input: __spreadProps(__spreadValues({}, params.InputProps), {
|
|
441
|
+
autoComplete: "new-password",
|
|
442
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
443
|
+
isResourceSearchLoading && /* @__PURE__ */ jsx(CircularProgress, { color: "inherit", size: 20 }),
|
|
444
|
+
params.InputProps.endAdornment
|
|
445
|
+
] })
|
|
446
|
+
})
|
|
447
|
+
}
|
|
448
|
+
})
|
|
449
|
+
),
|
|
450
|
+
ListboxProps: {
|
|
451
|
+
sx: {
|
|
452
|
+
maxHeight: 400,
|
|
453
|
+
"& .MuiAutocomplete-option": {
|
|
454
|
+
position: "relative"
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
};
|
|
461
|
+
var RASearchableSelectChips_default = SearchableSelectChips;
|
|
462
|
+
export {
|
|
463
|
+
SearchableSelectChips,
|
|
464
|
+
RASearchableSelectChips_default as default
|
|
465
|
+
};
|