@dashadmin/dash-components 1.3.73 → 1.3.74-srcfree.1
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/package.json +24 -21
- package/src/components/AuditLog/AuditLog.tsx +0 -490
- package/src/components/AuditLog/index.ts +0 -2
- package/src/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.tsx +0 -917
- package/src/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.tsx +0 -39
- package/src/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.tsx +0 -916
- package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +0 -42
- package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.tsx +0 -44
- package/src/components/Json/Json.tsx +0 -312
- package/src/components/JsonColorSelector/JsonColorSelector.tsx +0 -1443
- package/src/components/JsonColorSelector/JsonColorSelector.tsx.bkup +0 -746
- package/src/components/JsonColorSelector/JsonColorSelectorEnhanced.tsx +0 -1135
- package/src/components/JsonColorSelector/JsonCssVarValues.tsx +0 -867
- package/src/components/JsonColorSelector/components/BasicColorSelector.tsx +0 -333
- package/src/components/JsonColorSelector/components/ColorEditDialog.tsx +0 -495
- package/src/components/JsonColorSelector/components/ColorPaletteItem.tsx +0 -80
- package/src/components/JsonColorSelector/components/ImageColorExtractor.tsx +0 -420
- package/src/components/JsonColorSelector/helpers/functions.tsx +0 -123
- package/src/components/JsonColorSelector/helpers/paletteDerivation.ts +0 -367
- package/src/components/JsonColorSelector/interfaces/interfaces.tsx +0 -22
- package/src/components/JsonColorSelector/useAsyncColorThief.tsx +0 -97
- package/src/components/ListActive/ListActive.tsx +0 -106
- package/src/components/ListActive/ListBoolean.tsx +0 -96
- package/src/components/NotificationPreferences/NotificationPreferences.tsx +0 -480
- package/src/components/NotificationPreferences/index.tsx +0 -2
- package/src/components/SearchableSelects/RASearchableSelect.tsx +0 -303
- package/src/components/SearchableSelects/RASearchableSelectCheckboxes.tsx +0 -617
- package/src/components/SearchableSelects/RASearchableSelectChips.tsx +0 -561
- package/src/components/SearchableSelects/RASearchableSelectChipsRecordContext.tsx +0 -366
- package/src/components/SearchableSelects/SearchableSelect.tsx +0 -323
- package/src/components/SearchableSelects/SearchableSelectCheckboxes.tsx +0 -358
- package/src/components/SortableDataGrid/README.md +0 -1
- package/src/components/SortableDataGrid/SortableDataGrid.tsx +0 -56
- package/src/components/SortableDataGrid/SortableDataGridBody.tsx +0 -175
- package/src/components/SortableDataGrid/SortableDataGridHeader.tsx +0 -171
- package/src/components/SortableDataGrid/SortableDataGridRow.tsx +0 -247
- package/src/components/Upload/SingleImageUploader.tsx +0 -55
- package/src/components/custom/PackageCopyMethod.tsx +0 -109
- package/src/components/custom/PackageRadioButtonGroup.tsx +0 -49
- package/src/components/dialog/Basic.tsx +0 -11
- package/src/components/dialog/Correct.tsx +0 -16
- package/src/components/dialog/Error.tsx +0 -15
- package/src/components/dialog/Info.tsx +0 -15
- package/src/components/dialog/InfoV2.tsx +0 -35
- package/src/components/dialog/NotFound.tsx +0 -18
- package/src/components/dialog/QuickSearch.tsx +0 -115
- package/src/components/notifications/NotificationsCenter.tsx +0 -743
- package/src/components/notifications/index.ts +0 -42
- package/src/components/tables/PaginationComponent.tsx +0 -17
- package/src/components/theme/AppLoadingFallback.tsx +0 -42
- package/src/components/theme/ErrorBoundary.tsx +0 -57
- package/src/components/theme/InitialLoader.tsx +0 -16
- package/src/components/theme/NotFound.tsx +0 -124
- package/src/components/theme/NotResults.tsx +0 -56
- package/src/hooks/useDraggable.ts +0 -11
- package/src/hooks/useNotifications.ts +0 -14
- package/src/hooks/useQuickSearch.tsx +0 -29
- package/src/index.tsx +0 -77
- package/src/styles/index.less +0 -0
- package/src/utils/setNativeValue.tsx +0 -23
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ISearchableSelect for AutoAdmin for ReactAdmin
|
|
3
|
-
* @author Franisco Aranda <francisco.aranda@sudo.cl> <faranda@gmail.com>
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
Autocomplete,
|
|
8
|
-
Box,
|
|
9
|
-
CircularProgress,
|
|
10
|
-
InputLabel,
|
|
11
|
-
TextField,
|
|
12
|
-
} from "@mui/material";
|
|
13
|
-
import React, { useEffect, useState } from "react";
|
|
14
|
-
import { useController } from "react-hook-form";
|
|
15
|
-
import { useGetList } from "react-admin";
|
|
16
|
-
|
|
17
|
-
import { useRecordContext } from "react-admin";
|
|
18
|
-
import { Loading } from "react-admin";
|
|
19
|
-
import { isArray } from "lodash";
|
|
20
|
-
import { IDashAutoAdminCustomFieldComponent } from "dash-auto-admin";
|
|
21
|
-
|
|
22
|
-
interface ISearchableSelect extends IDashAutoAdminCustomFieldComponent {
|
|
23
|
-
name?: string;
|
|
24
|
-
resource?: string;
|
|
25
|
-
selectLabel?: string;
|
|
26
|
-
title?: string;
|
|
27
|
-
renderText?: (object: any) => any;
|
|
28
|
-
transformData?: (val: string) => any;
|
|
29
|
-
defaultValues?: any;
|
|
30
|
-
isMultiple?: boolean;
|
|
31
|
-
//pagination?: boolean,
|
|
32
|
-
minSearch?: number;
|
|
33
|
-
searchResults?: number;
|
|
34
|
-
timerSearch?: number;
|
|
35
|
-
isEmpty?: boolean;
|
|
36
|
-
filter?: { [x: string]: any };
|
|
37
|
-
queryFilter?: string;
|
|
38
|
-
isOptionEqualToValue?: (option, value) => boolean;
|
|
39
|
-
viewAttribute: string;
|
|
40
|
-
elementKeyId?: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const SearchableSelect: React.FC<ISearchableSelect> = ({
|
|
44
|
-
method,
|
|
45
|
-
attribute,
|
|
46
|
-
isMultiple = false,
|
|
47
|
-
//pagination = true,
|
|
48
|
-
searchResults = 50,
|
|
49
|
-
minSearch = 3,
|
|
50
|
-
timerSearch = 500,
|
|
51
|
-
resource,
|
|
52
|
-
selectLabel,
|
|
53
|
-
renderText,
|
|
54
|
-
transformData,
|
|
55
|
-
queryFilter = "q",
|
|
56
|
-
defaultValues = undefined,
|
|
57
|
-
isEmpty = false,
|
|
58
|
-
filter,
|
|
59
|
-
isOptionEqualToValue = undefined,
|
|
60
|
-
viewAttribute = null,
|
|
61
|
-
elementKeyId = "id",
|
|
62
|
-
}) => {
|
|
63
|
-
//const element_key = "system_marketplace_category_id";
|
|
64
|
-
const [open, setOpen] = useState(true);
|
|
65
|
-
/* parsedOptions se setea null, esto para que el control no aparezca hasta que se obtenga la data */
|
|
66
|
-
const [parsedOptions, setParsedOptions] = useState(null);
|
|
67
|
-
const [q, setQ] = useState("");
|
|
68
|
-
const record = useRecordContext();
|
|
69
|
-
const field = useController({
|
|
70
|
-
name: attribute.attribute,
|
|
71
|
-
defaultValue: record ? record[attribute.attribute] : null,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const includes =
|
|
75
|
-
record &&
|
|
76
|
-
record[attribute.attribute] &&
|
|
77
|
-
isArray(record[attribute.attribute])
|
|
78
|
-
? record[attribute.attribute].map((element) =>
|
|
79
|
-
element.hasOwnProperty(elementKeyId)
|
|
80
|
-
? element[elementKeyId]
|
|
81
|
-
: element
|
|
82
|
-
)
|
|
83
|
-
: record[attribute.attribute];
|
|
84
|
-
|
|
85
|
-
const {
|
|
86
|
-
data: resourceData,
|
|
87
|
-
total,
|
|
88
|
-
isLoading,
|
|
89
|
-
error,
|
|
90
|
-
} = useGetList(
|
|
91
|
-
resource,
|
|
92
|
-
{
|
|
93
|
-
filter: { [queryFilter]: q, ...filter, includes: includes },
|
|
94
|
-
},
|
|
95
|
-
{ refetchOnWindowFocus: false }
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
if (resourceData && !isLoading) {
|
|
100
|
-
//Le agrega el key, para evitar el warning de react.
|
|
101
|
-
//setParsedOptions([...parsedOptions,...resourceData.map(ele => { return {...ele,key:"option"+ele.id}})])
|
|
102
|
-
if (parsedOptions)
|
|
103
|
-
setParsedOptions([
|
|
104
|
-
...parsedOptions,
|
|
105
|
-
...resourceData.map((ele) => {
|
|
106
|
-
return { ...ele, key: "option" + ele.id };
|
|
107
|
-
}),
|
|
108
|
-
]);
|
|
109
|
-
setParsedOptions(
|
|
110
|
-
resourceData.map((ele) => {
|
|
111
|
-
return { ...ele, key: "option" + ele.id };
|
|
112
|
-
})
|
|
113
|
-
);
|
|
114
|
-
} /*else {
|
|
115
|
-
// Setea la data a un arreglo vacío, ya que si es null, se ocultará el componente.
|
|
116
|
-
//setParsedOptions([]);
|
|
117
|
-
}*/
|
|
118
|
-
return () => setParsedOptions([]);
|
|
119
|
-
// TODO! reset callback, empty parsedOptions.
|
|
120
|
-
}, [resourceData, isLoading]);
|
|
121
|
-
|
|
122
|
-
const [timeOutSearch, setTimeOutSearch] = useState(undefined);
|
|
123
|
-
|
|
124
|
-
const debounce = (fn: Function, delay = 500) => {
|
|
125
|
-
clearTimeout(timeOutSearch);
|
|
126
|
-
setTimeOutSearch(
|
|
127
|
-
setTimeout(() => {
|
|
128
|
-
fn();
|
|
129
|
-
}, delay)
|
|
130
|
-
);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<>
|
|
135
|
-
{parsedOptions && (
|
|
136
|
-
<Autocomplete
|
|
137
|
-
key={"autocomplete-" + attribute.attribute}
|
|
138
|
-
multiple={isMultiple}
|
|
139
|
-
loading={isLoading && open}
|
|
140
|
-
//sx={{ width: 373 }}
|
|
141
|
-
fullWidth
|
|
142
|
-
freeSolo={true}
|
|
143
|
-
//options={!resourceData ? [] : !defaultValues ? resourceData : resourceData}
|
|
144
|
-
//options={resourceData ? resourceData.map(ele => { return {...ele,key:ele.id}} ) : []}
|
|
145
|
-
options={parsedOptions}
|
|
146
|
-
open={open}
|
|
147
|
-
onOpen={() => setOpen(true)}
|
|
148
|
-
onClose={() => setOpen(false)}
|
|
149
|
-
/*defaultValue={field.field?.value && field.field.value.map(item => parsedOptions.find(
|
|
150
|
-
(element) => {
|
|
151
|
-
|
|
152
|
-
return element.id === item.id
|
|
153
|
-
}))}*/
|
|
154
|
-
//value={isOptionEqualToValue && parsedOptions ? parsedOptions.find(ele => isOptionEqualToValue(ele,field.field.value))[viewAttribute] : field.field.value}
|
|
155
|
-
|
|
156
|
-
defaultValue={field.field?.value}
|
|
157
|
-
//value={field.field.value}
|
|
158
|
-
|
|
159
|
-
isOptionEqualToValue={isOptionEqualToValue}
|
|
160
|
-
autoHighlight
|
|
161
|
-
//{...(!isEmpty && { value: field.field.value })}
|
|
162
|
-
//{...(isEmpty && { renderTags: (value, getTagProps) => <></> })}
|
|
163
|
-
// 8
|
|
164
|
-
|
|
165
|
-
getOptionLabel={(option: any) => {
|
|
166
|
-
const _option = !Array.isArray(option) // si es un numero como 'id', busca la opción en los valores con isOptionEqualToValue, sino devuelve el objeto original.
|
|
167
|
-
? parsedOptions &&
|
|
168
|
-
parsedOptions.find((ele) =>
|
|
169
|
-
isOptionEqualToValue(ele, field.field.value)
|
|
170
|
-
)
|
|
171
|
-
: option;
|
|
172
|
-
if (!_option) return q; //es posbile que no se haya encontrado en parsedOptions o que parsedOptions aún no esté definido.
|
|
173
|
-
const r =
|
|
174
|
-
viewAttribute && !renderText
|
|
175
|
-
? _option[viewAttribute]
|
|
176
|
-
: renderText(_option);
|
|
177
|
-
console.log(
|
|
178
|
-
"getOptionLabel",
|
|
179
|
-
parsedOptions.find((ele) =>
|
|
180
|
-
isOptionEqualToValue(ele, field.field.value)
|
|
181
|
-
),
|
|
182
|
-
r
|
|
183
|
-
);
|
|
184
|
-
if (!r) return q;
|
|
185
|
-
return r;
|
|
186
|
-
}}
|
|
187
|
-
//getOptionLabel={(option: any) => option}
|
|
188
|
-
|
|
189
|
-
renderOption={(props, option: any) => {
|
|
190
|
-
const { key, ...newProps } = props as any;
|
|
191
|
-
|
|
192
|
-
return (
|
|
193
|
-
<Box
|
|
194
|
-
key={option.key}
|
|
195
|
-
component="li"
|
|
196
|
-
sx={{ "& > img": { mr: 2, flexShrink: 0 } }}
|
|
197
|
-
{...newProps}
|
|
198
|
-
>
|
|
199
|
-
{viewAttribute && !renderText
|
|
200
|
-
? option[viewAttribute]
|
|
201
|
-
: renderText(option)}
|
|
202
|
-
</Box>
|
|
203
|
-
);
|
|
204
|
-
}}
|
|
205
|
-
onChange={(event: any, rawValue) => {
|
|
206
|
-
console.log("onChange", event, rawValue);
|
|
207
|
-
let newValue = rawValue;
|
|
208
|
-
|
|
209
|
-
if (Array.isArray(rawValue)) {
|
|
210
|
-
newValue = isEmpty
|
|
211
|
-
? [...rawValue, ...field.field.value]
|
|
212
|
-
: [
|
|
213
|
-
...new Map(
|
|
214
|
-
newValue.map((v) => [v.id, v])
|
|
215
|
-
).values(),
|
|
216
|
-
];
|
|
217
|
-
}
|
|
218
|
-
transformData
|
|
219
|
-
? field.field.onChange(transformData(newValue))
|
|
220
|
-
: field.field.onChange(newValue);
|
|
221
|
-
}}
|
|
222
|
-
renderInput={(params) => {
|
|
223
|
-
console.log("renderInput", params.id);
|
|
224
|
-
return (
|
|
225
|
-
<TextField
|
|
226
|
-
key={params.id}
|
|
227
|
-
{...params}
|
|
228
|
-
label={selectLabel}
|
|
229
|
-
variant="outlined"
|
|
230
|
-
onChange={(ev) => {
|
|
231
|
-
// dont fire API if the user delete or not entered anything
|
|
232
|
-
let searchValue = ev.target.value;
|
|
233
|
-
//onSearch={(searchValue) => {}
|
|
234
|
-
|
|
235
|
-
if (
|
|
236
|
-
searchValue &&
|
|
237
|
-
searchValue !== "" &&
|
|
238
|
-
searchValue.length >= minSearch
|
|
239
|
-
)
|
|
240
|
-
debounce(
|
|
241
|
-
() => setQ(searchValue),
|
|
242
|
-
timerSearch
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
/*if (ev.target.value !== "" || ev.target.value !== null) {
|
|
246
|
-
setQ(ev.target.value);
|
|
247
|
-
}*/
|
|
248
|
-
}}
|
|
249
|
-
slotProps={{
|
|
250
|
-
...params.slotProps,
|
|
251
|
-
|
|
252
|
-
input: {
|
|
253
|
-
...params.slotProps.input,
|
|
254
|
-
autoComplete: "new-password",
|
|
255
|
-
endAdornment: (
|
|
256
|
-
<>
|
|
257
|
-
{isLoading ? (
|
|
258
|
-
<CircularProgress
|
|
259
|
-
color="inherit"
|
|
260
|
-
size={20}
|
|
261
|
-
/>
|
|
262
|
-
) : null}
|
|
263
|
-
{params.slotProps.input.endAdornment}
|
|
264
|
-
</>
|
|
265
|
-
),
|
|
266
|
-
}
|
|
267
|
-
}}
|
|
268
|
-
/>
|
|
269
|
-
);
|
|
270
|
-
}}
|
|
271
|
-
/>
|
|
272
|
-
)}
|
|
273
|
-
</>
|
|
274
|
-
);
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
const RASearchableSelect = ({
|
|
278
|
-
method,
|
|
279
|
-
attribute,
|
|
280
|
-
...props
|
|
281
|
-
}: ISearchableSelect) => {
|
|
282
|
-
switch (method) {
|
|
283
|
-
case "edit":
|
|
284
|
-
case "create":
|
|
285
|
-
return (
|
|
286
|
-
<SearchableSelect
|
|
287
|
-
attribute={attribute}
|
|
288
|
-
method={method}
|
|
289
|
-
{...props}
|
|
290
|
-
/>
|
|
291
|
-
);
|
|
292
|
-
case "view":
|
|
293
|
-
return (
|
|
294
|
-
<SearchableSelect
|
|
295
|
-
attribute={attribute}
|
|
296
|
-
method={method}
|
|
297
|
-
{...props}
|
|
298
|
-
/>
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
export default RASearchableSelect;
|