@dashadmin/dash-components 1.3.25 → 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,290 @@
|
|
|
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
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
53
|
+
import {
|
|
54
|
+
Autocomplete,
|
|
55
|
+
Box,
|
|
56
|
+
Checkbox,
|
|
57
|
+
CircularProgress,
|
|
58
|
+
TextField
|
|
59
|
+
} from "@mui/material";
|
|
60
|
+
import React, { useEffect, useState } from "react";
|
|
61
|
+
import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank";
|
|
62
|
+
import CheckBoxIcon from "@mui/icons-material/CheckBox";
|
|
63
|
+
import { useAxios } from "dash-axios-hook";
|
|
64
|
+
const icon = /* @__PURE__ */ jsx(CheckBoxOutlineBlankIcon, { fontSize: "small" });
|
|
65
|
+
const checkedIcon = /* @__PURE__ */ jsx(CheckBoxIcon, { fontSize: "small" });
|
|
66
|
+
const SearchableSelectCheckboxes = function WrappedAutoComplete(_a) {
|
|
67
|
+
var props = __objRest(_a, []);
|
|
68
|
+
const _a2 = props, {
|
|
69
|
+
multiple,
|
|
70
|
+
freeSolo,
|
|
71
|
+
minSearch = 3,
|
|
72
|
+
timerSearch = 500,
|
|
73
|
+
checkboxes = false,
|
|
74
|
+
resource,
|
|
75
|
+
selectLabel,
|
|
76
|
+
renderText,
|
|
77
|
+
queryFilter = "q",
|
|
78
|
+
defaultValues = null,
|
|
79
|
+
elementKeyId = "id",
|
|
80
|
+
isEmpty = false,
|
|
81
|
+
filter,
|
|
82
|
+
isOptionEqualToValue = (option, value) => value === option,
|
|
83
|
+
renderAttribute = null,
|
|
84
|
+
name,
|
|
85
|
+
onChange,
|
|
86
|
+
renderInputTextFieldProps,
|
|
87
|
+
selectedIds,
|
|
88
|
+
useDefaultSearch = false
|
|
89
|
+
} = _a2, rest = __objRest(_a2, [
|
|
90
|
+
"multiple",
|
|
91
|
+
"freeSolo",
|
|
92
|
+
"minSearch",
|
|
93
|
+
"timerSearch",
|
|
94
|
+
"checkboxes",
|
|
95
|
+
"resource",
|
|
96
|
+
"selectLabel",
|
|
97
|
+
"renderText",
|
|
98
|
+
"queryFilter",
|
|
99
|
+
"defaultValues",
|
|
100
|
+
"elementKeyId",
|
|
101
|
+
"isEmpty",
|
|
102
|
+
"filter",
|
|
103
|
+
"isOptionEqualToValue",
|
|
104
|
+
"renderAttribute",
|
|
105
|
+
"name",
|
|
106
|
+
"onChange",
|
|
107
|
+
"renderInputTextFieldProps",
|
|
108
|
+
"selectedIds",
|
|
109
|
+
"useDefaultSearch"
|
|
110
|
+
]);
|
|
111
|
+
const [open, setOpen] = useState(false);
|
|
112
|
+
const [parsedOptions, setParsedOptions] = useState(null);
|
|
113
|
+
const [q, setQ] = useState(null);
|
|
114
|
+
const [resourceData, setResourceData] = useState(null);
|
|
115
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
116
|
+
const [initialSelectedIds, setInitalSelectedIds] = useState(null);
|
|
117
|
+
const initialIncludes = defaultValues && Array.isArray(defaultValues) ? defaultValues.map((element) => element[elementKeyId] ? element[elementKeyId] : element) : multiple && initialSelectedIds ? initialSelectedIds : defaultValues;
|
|
118
|
+
const [includes, setIncludes] = useState(initialIncludes);
|
|
119
|
+
const [controlledValue, setControlledValue] = useState(null);
|
|
120
|
+
const axios = useAxios();
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
setInitalSelectedIds(selectedIds);
|
|
123
|
+
}, []);
|
|
124
|
+
const updateControlledValue = (val, origin) => {
|
|
125
|
+
if (Array.isArray(val)) {
|
|
126
|
+
setControlledValue(val);
|
|
127
|
+
if (origin === "onChange") {
|
|
128
|
+
setIncludes(val.map((v) => v[elementKeyId]));
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
setControlledValue(val);
|
|
132
|
+
if (origin === "onChange") {
|
|
133
|
+
setIncludes(val[elementKeyId]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const search = () => __async(null, null, function* () {
|
|
138
|
+
setIsLoading(true);
|
|
139
|
+
try {
|
|
140
|
+
const params = __spreadProps(__spreadValues({ [queryFilter]: q }, filter), { includes });
|
|
141
|
+
const { data } = yield axios.get(resource, {
|
|
142
|
+
params
|
|
143
|
+
});
|
|
144
|
+
setResourceData(data.data);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
console.error(e);
|
|
147
|
+
} finally {
|
|
148
|
+
setIsLoading(false);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
search();
|
|
153
|
+
}, []);
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (q && q !== "" && !useDefaultSearch) {
|
|
156
|
+
search();
|
|
157
|
+
}
|
|
158
|
+
}, [q]);
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (resourceData && !isLoading) {
|
|
161
|
+
if (parsedOptions)
|
|
162
|
+
setParsedOptions([
|
|
163
|
+
...parsedOptions,
|
|
164
|
+
...resourceData.map((ele) => {
|
|
165
|
+
return __spreadProps(__spreadValues({}, ele), { key: "option" + ele.id });
|
|
166
|
+
})
|
|
167
|
+
]);
|
|
168
|
+
setParsedOptions(
|
|
169
|
+
resourceData.map((ele) => {
|
|
170
|
+
return __spreadProps(__spreadValues({}, ele), { key: "option" + ele.id });
|
|
171
|
+
})
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return () => setParsedOptions([]);
|
|
175
|
+
}, [resourceData, isLoading]);
|
|
176
|
+
const [timeOutSearch, setTimeOutSearch] = useState(void 0);
|
|
177
|
+
const debounce = (fn, delay = 500) => {
|
|
178
|
+
clearTimeout(timeOutSearch);
|
|
179
|
+
setTimeOutSearch(
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
fn();
|
|
182
|
+
}, delay)
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
const checkboxRenderOptions = (p, option, { selected }) => {
|
|
186
|
+
const _a3 = p, { key } = _a3, r = __objRest(_a3, ["key"]);
|
|
187
|
+
return /* @__PURE__ */ jsxs("li", __spreadProps(__spreadValues({}, r), { children: [
|
|
188
|
+
/* @__PURE__ */ jsx(
|
|
189
|
+
Checkbox,
|
|
190
|
+
{
|
|
191
|
+
icon,
|
|
192
|
+
checkedIcon,
|
|
193
|
+
style: { marginRight: 8 },
|
|
194
|
+
checked: selected
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
renderAttribute && !renderText ? option[renderAttribute] : renderText(option)
|
|
198
|
+
] }), option.key);
|
|
199
|
+
};
|
|
200
|
+
const boxRenderOptions = (p, option) => {
|
|
201
|
+
const _a3 = p, { key } = _a3, newProps = __objRest(_a3, ["key"]);
|
|
202
|
+
return /* @__PURE__ */ jsx(
|
|
203
|
+
Box,
|
|
204
|
+
__spreadProps(__spreadValues({
|
|
205
|
+
component: "li",
|
|
206
|
+
sx: { "& > img": { mr: 2, flexShrink: 0 } }
|
|
207
|
+
}, newProps), {
|
|
208
|
+
children: renderAttribute && !renderText ? option[renderAttribute] : renderText(option)
|
|
209
|
+
}),
|
|
210
|
+
option.key
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
const _renderOption = checkboxes ? checkboxRenderOptions : boxRenderOptions;
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
if (multiple && parsedOptions && initialSelectedIds) {
|
|
216
|
+
const values = parsedOptions.filter(
|
|
217
|
+
(option) => initialSelectedIds.includes(option[elementKeyId])
|
|
218
|
+
);
|
|
219
|
+
updateControlledValue(values, "selectedIds");
|
|
220
|
+
}
|
|
221
|
+
}, [parsedOptions, initialSelectedIds, multiple]);
|
|
222
|
+
useEffect(() => {
|
|
223
|
+
if (onChange && controlledValue) {
|
|
224
|
+
onChange(null, controlledValue, null);
|
|
225
|
+
}
|
|
226
|
+
}, [controlledValue]);
|
|
227
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
228
|
+
isLoading && !parsedOptions ? /* @__PURE__ */ jsx(CircularProgress, { color: "inherit", size: 20 }) : /* @__PURE__ */ jsx(Fragment, {}),
|
|
229
|
+
parsedOptions && /* @__PURE__ */ jsx(
|
|
230
|
+
Autocomplete,
|
|
231
|
+
__spreadValues(__spreadProps(__spreadValues({
|
|
232
|
+
multiple,
|
|
233
|
+
freeSolo,
|
|
234
|
+
loading: isLoading && open
|
|
235
|
+
}, checkboxes && { disableCloseOnSelect: true }), {
|
|
236
|
+
options: parsedOptions,
|
|
237
|
+
open,
|
|
238
|
+
onOpen: () => setOpen(true),
|
|
239
|
+
onClose: () => setOpen(false),
|
|
240
|
+
value: controlledValue ? controlledValue : multiple ? [] : null,
|
|
241
|
+
isOptionEqualToValue,
|
|
242
|
+
autoHighlight: true,
|
|
243
|
+
getOptionLabel: (option) => {
|
|
244
|
+
return renderAttribute && !renderText ? option[renderAttribute] : renderText ? renderText(option) : option;
|
|
245
|
+
},
|
|
246
|
+
renderOption: _renderOption,
|
|
247
|
+
onChange: (event, rawValue, _reason) => {
|
|
248
|
+
updateControlledValue(rawValue, "onChange");
|
|
249
|
+
},
|
|
250
|
+
renderInput: (params) => {
|
|
251
|
+
return /* @__PURE__ */ jsx(
|
|
252
|
+
TextField,
|
|
253
|
+
__spreadValues(__spreadProps(__spreadValues({}, params), {
|
|
254
|
+
label: selectLabel,
|
|
255
|
+
variant: "outlined",
|
|
256
|
+
onChange: (ev) => {
|
|
257
|
+
if (useDefaultSearch !== true) {
|
|
258
|
+
const searchValue = ev.target.value;
|
|
259
|
+
if (searchValue && searchValue !== "" && searchValue.length >= minSearch) {
|
|
260
|
+
debounce(() => setQ(searchValue), timerSearch);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
InputProps: __spreadProps(__spreadValues({}, params.InputProps), {
|
|
265
|
+
autoComplete: "new-password",
|
|
266
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
267
|
+
isLoading ? /* @__PURE__ */ jsx(CircularProgress, { color: "inherit", size: 20 }) : null,
|
|
268
|
+
params.InputProps.endAdornment
|
|
269
|
+
] })
|
|
270
|
+
})
|
|
271
|
+
}), renderInputTextFieldProps),
|
|
272
|
+
params.id
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
}), rest),
|
|
276
|
+
"autocomplete-" + name
|
|
277
|
+
)
|
|
278
|
+
] });
|
|
279
|
+
};
|
|
280
|
+
const MemoizedSearchableSelectCheckboxes = React.memo(
|
|
281
|
+
SearchableSelectCheckboxes,
|
|
282
|
+
() => {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
var SearchableSelectCheckboxes_default = SearchableSelectCheckboxes;
|
|
287
|
+
export {
|
|
288
|
+
MemoizedSearchableSelectCheckboxes,
|
|
289
|
+
SearchableSelectCheckboxes_default as default
|
|
290
|
+
};
|
|
@@ -1 +1,72 @@
|
|
|
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 { jsx } from "react/jsx-runtime";
|
|
33
|
+
import {
|
|
34
|
+
memo
|
|
35
|
+
} from "react";
|
|
36
|
+
import { Datagrid } from "react-admin";
|
|
37
|
+
import SortableDatagridBody from "./SortableDataGridBody";
|
|
38
|
+
import { SortableDatagridHeader } from "./SortableDataGridHeader";
|
|
39
|
+
import SortableDatagridRow from "./SortableDataGridRow";
|
|
40
|
+
import React from "react";
|
|
41
|
+
const SortableDatagrid = (props) => {
|
|
42
|
+
const _a = props, { children, onOrderUpdate } = _a, rest = __objRest(_a, ["children", "onOrderUpdate"]);
|
|
43
|
+
const bodyRef = React.useRef(null);
|
|
44
|
+
const _onOrderUpdate = (d) => {
|
|
45
|
+
if (onOrderUpdate) {
|
|
46
|
+
onOrderUpdate(d);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const SortableRootDatagrid = (p) => /* @__PURE__ */ jsx(
|
|
50
|
+
Datagrid,
|
|
51
|
+
__spreadProps(__spreadValues({}, p), {
|
|
52
|
+
header: /* @__PURE__ */ jsx(SortableDatagridHeader, {}),
|
|
53
|
+
body: /* @__PURE__ */ jsx(
|
|
54
|
+
SortableDatagridBody,
|
|
55
|
+
{
|
|
56
|
+
onOrderUpdate: _onOrderUpdate,
|
|
57
|
+
ref: bodyRef,
|
|
58
|
+
row: /* @__PURE__ */ jsx(SortableDatagridRow, {})
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
const SortableRootDatagridPure = memo(
|
|
64
|
+
SortableRootDatagrid,
|
|
65
|
+
() => true
|
|
66
|
+
);
|
|
67
|
+
return /* @__PURE__ */ jsx("div", { id: "sortable-list", children: /* @__PURE__ */ jsx(SortableRootDatagridPure, __spreadProps(__spreadValues({}, rest), { children })) });
|
|
68
|
+
};
|
|
69
|
+
var SortableDataGrid_default = SortableDatagrid;
|
|
70
|
+
export {
|
|
71
|
+
SortableDataGrid_default as default
|
|
72
|
+
};
|
|
@@ -1 +1,167 @@
|
|
|
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 { jsx } from "react/jsx-runtime";
|
|
33
|
+
import * as React from "react";
|
|
34
|
+
import { cloneElement, memo, forwardRef } from "react";
|
|
35
|
+
import { TableBody } from "@mui/material";
|
|
36
|
+
import {
|
|
37
|
+
DatagridRow,
|
|
38
|
+
PureDatagridRow
|
|
39
|
+
} from "react-admin";
|
|
40
|
+
import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
|
|
41
|
+
const defaultChildren = /* @__PURE__ */ jsx(DatagridRow, {});
|
|
42
|
+
const defaultData = [];
|
|
43
|
+
const SortableDatagridBody = forwardRef(
|
|
44
|
+
(_a, _ref) => {
|
|
45
|
+
var _b = _a, {
|
|
46
|
+
children,
|
|
47
|
+
className,
|
|
48
|
+
data = defaultData,
|
|
49
|
+
expand,
|
|
50
|
+
hasBulkActions = false,
|
|
51
|
+
hover,
|
|
52
|
+
onToggleItem,
|
|
53
|
+
resource,
|
|
54
|
+
row = defaultChildren,
|
|
55
|
+
rowClick,
|
|
56
|
+
rowStyle,
|
|
57
|
+
selectedIds,
|
|
58
|
+
isRowSelectable,
|
|
59
|
+
onOrderUpdate
|
|
60
|
+
} = _b, rest = __objRest(_b, [
|
|
61
|
+
"children",
|
|
62
|
+
"className",
|
|
63
|
+
"data",
|
|
64
|
+
"expand",
|
|
65
|
+
"hasBulkActions",
|
|
66
|
+
"hover",
|
|
67
|
+
"onToggleItem",
|
|
68
|
+
"resource",
|
|
69
|
+
"row",
|
|
70
|
+
"rowClick",
|
|
71
|
+
"rowStyle",
|
|
72
|
+
"selectedIds",
|
|
73
|
+
"isRowSelectable",
|
|
74
|
+
"onOrderUpdate"
|
|
75
|
+
]);
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
console.log("data has been updated");
|
|
78
|
+
}, [data]);
|
|
79
|
+
const [orderedData, setOrderedData] = React.useState(data);
|
|
80
|
+
const reorder = (list, startIndex, endIndex) => {
|
|
81
|
+
const result = Array.from(list);
|
|
82
|
+
const [removed] = result.splice(startIndex, 1);
|
|
83
|
+
result.splice(endIndex, 0, removed);
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
86
|
+
const getItemStyle = (isDragging, draggableStyle) => __spreadValues({
|
|
87
|
+
border: isDragging ? "1px dashed #ccc" : "none"
|
|
88
|
+
}, draggableStyle);
|
|
89
|
+
const onDragEnd = (result) => {
|
|
90
|
+
if (!result.destination) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const movedItems = reorder(
|
|
94
|
+
orderedData,
|
|
95
|
+
result.source.index,
|
|
96
|
+
result.destination.index
|
|
97
|
+
);
|
|
98
|
+
setOrderedData(movedItems);
|
|
99
|
+
if (onOrderUpdate) {
|
|
100
|
+
onOrderUpdate(movedItems);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return /* @__PURE__ */ jsx(DragDropContext, { onDragEnd, children: /* @__PURE__ */ jsx(Droppable, { droppableId: "droppable", children: (provided) => (
|
|
104
|
+
/* @ts-ignore Expected KnownIssue1 */
|
|
105
|
+
/* @__PURE__ */ jsx(
|
|
106
|
+
TableBody,
|
|
107
|
+
__spreadProps(__spreadValues({
|
|
108
|
+
ref: provided.innerRef,
|
|
109
|
+
className: "datagrid-body"
|
|
110
|
+
}, rest), {
|
|
111
|
+
children: orderedData.map((record, rowIndex) => {
|
|
112
|
+
return /* @__PURE__ */ jsx(
|
|
113
|
+
Draggable,
|
|
114
|
+
{
|
|
115
|
+
draggableId: "q-" + record.id,
|
|
116
|
+
index: rowIndex,
|
|
117
|
+
children: (p, snapshot) => {
|
|
118
|
+
var _a2, _b2;
|
|
119
|
+
const defaultStyles = rowStyle ? rowStyle(record, rowIndex) : {};
|
|
120
|
+
return cloneElement(
|
|
121
|
+
row,
|
|
122
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
123
|
+
ref: p.innerRef
|
|
124
|
+
}, p.draggableProps), p.dragHandleProps), {
|
|
125
|
+
/*className: clsx(DatagridClasses.row, {
|
|
126
|
+
[DatagridClasses.rowEven]: rowIndex % 2 === 0,
|
|
127
|
+
[DatagridClasses.rowOdd]: rowIndex % 2 !== 0,
|
|
128
|
+
}),*/
|
|
129
|
+
expand,
|
|
130
|
+
hasBulkActions: hasBulkActions && !!selectedIds,
|
|
131
|
+
hover,
|
|
132
|
+
id: (_a2 = record.id) != null ? _a2 : `row${rowIndex}`,
|
|
133
|
+
key: (_b2 = record.id) != null ? _b2 : `row${rowIndex}`,
|
|
134
|
+
onToggleItem,
|
|
135
|
+
record,
|
|
136
|
+
resource,
|
|
137
|
+
rowClick,
|
|
138
|
+
selectable: !isRowSelectable || isRowSelectable(record),
|
|
139
|
+
selected: selectedIds == null ? void 0 : selectedIds.includes(record.id),
|
|
140
|
+
style: __spreadValues(__spreadValues({}, defaultStyles), getItemStyle(
|
|
141
|
+
snapshot.isDragging,
|
|
142
|
+
p.draggableProps.style
|
|
143
|
+
))
|
|
144
|
+
}),
|
|
145
|
+
children
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
record.id
|
|
150
|
+
);
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
)
|
|
154
|
+
) }) });
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
SortableDatagridBody.muiName = "TableBody";
|
|
158
|
+
const PureSortableDatagridBody = memo(
|
|
159
|
+
(props) => /* @__PURE__ */ jsx(SortableDatagridBody, __spreadValues({ row: /* @__PURE__ */ jsx(PureDatagridRow, {}) }, props)),
|
|
160
|
+
() => true
|
|
161
|
+
);
|
|
162
|
+
PureSortableDatagridBody.muiName = "TableBody";
|
|
163
|
+
var SortableDataGridBody_default = PureSortableDatagridBody;
|
|
164
|
+
export {
|
|
165
|
+
PureSortableDatagridBody,
|
|
166
|
+
SortableDataGridBody_default as default
|
|
167
|
+
};
|
|
@@ -1 +1,109 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, isValidElement, useCallback } from "react";
|
|
3
|
+
import {
|
|
4
|
+
useListContext,
|
|
5
|
+
useResourceContext
|
|
6
|
+
} from "react-admin";
|
|
7
|
+
import { Checkbox, TableCell, TableHead, TableRow } from "@mui/material";
|
|
8
|
+
import clsx from "clsx";
|
|
9
|
+
import {
|
|
10
|
+
DatagridClasses,
|
|
11
|
+
DatagridHeader,
|
|
12
|
+
DatagridHeaderCell,
|
|
13
|
+
useDatagridContext,
|
|
14
|
+
useTranslate
|
|
15
|
+
} from "react-admin";
|
|
16
|
+
import MenuIcon from "@mui/icons-material/Menu";
|
|
17
|
+
const SortableDatagridHeader = (props) => {
|
|
18
|
+
const {
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
22
|
+
hasExpand = false,
|
|
23
|
+
hasSort = true,
|
|
24
|
+
hasBulkActions = false,
|
|
25
|
+
isRowSelectable
|
|
26
|
+
} = props;
|
|
27
|
+
{
|
|
28
|
+
}
|
|
29
|
+
const resource = useResourceContext(props);
|
|
30
|
+
const translate = useTranslate();
|
|
31
|
+
{
|
|
32
|
+
}
|
|
33
|
+
const { sort, data, onSelect, selectedIds, setSort } = useListContext(props);
|
|
34
|
+
const { expandSingle } = useDatagridContext();
|
|
35
|
+
const updateSortCallback = useCallback(
|
|
36
|
+
(event) => {
|
|
37
|
+
event.stopPropagation();
|
|
38
|
+
const newField = event.currentTarget.dataset.field;
|
|
39
|
+
const newOrder = sort.field === newField ? sort.order && sort.order.toLocaleLowerCase() === "asc" ? "ASC" : "DESC" : event.currentTarget.dataset.order;
|
|
40
|
+
setSort({ field: newField, order: newOrder });
|
|
41
|
+
},
|
|
42
|
+
[sort.field, sort.order, setSort]
|
|
43
|
+
);
|
|
44
|
+
const updateSort = setSort ? updateSortCallback : null;
|
|
45
|
+
const handleSelectAll = useCallback(
|
|
46
|
+
(event) => onSelect(
|
|
47
|
+
event.target.checked ? selectedIds.concat(
|
|
48
|
+
data.filter((record) => !selectedIds.includes(record.id)).filter(
|
|
49
|
+
(record) => isRowSelectable ? isRowSelectable(record) : true
|
|
50
|
+
).map((record) => record.id)
|
|
51
|
+
) : []
|
|
52
|
+
),
|
|
53
|
+
[data, onSelect, isRowSelectable, selectedIds]
|
|
54
|
+
);
|
|
55
|
+
const selectableIds = Array.isArray(data) ? isRowSelectable ? data.filter((record) => isRowSelectable(record)).map((record) => record.id) : data.map((record) => record.id) : [];
|
|
56
|
+
return /* @__PURE__ */ jsx(TableHead, { className: clsx(className, DatagridClasses.thead), children: /* @__PURE__ */ jsxs(
|
|
57
|
+
TableRow,
|
|
58
|
+
{
|
|
59
|
+
className: clsx(DatagridClasses.row, DatagridClasses.headerRow),
|
|
60
|
+
children: [
|
|
61
|
+
hasSort && /* @__PURE__ */ jsx(
|
|
62
|
+
TableCell,
|
|
63
|
+
{
|
|
64
|
+
padding: "none",
|
|
65
|
+
className: clsx(
|
|
66
|
+
DatagridClasses.headerCell,
|
|
67
|
+
DatagridClasses.expandHeader
|
|
68
|
+
),
|
|
69
|
+
children: /* @__PURE__ */ jsx(MenuIcon, { sx: { cursor: "pointer" }, className: "handle" })
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
hasBulkActions && selectedIds && /* @__PURE__ */ jsx(TableCell, { padding: "checkbox", className: DatagridClasses.headerCell, children: /* @__PURE__ */ jsx(
|
|
73
|
+
Checkbox,
|
|
74
|
+
{
|
|
75
|
+
"aria-label": translate("ra.action.select_all", {
|
|
76
|
+
_: "Select all"
|
|
77
|
+
}),
|
|
78
|
+
className: "select-all",
|
|
79
|
+
color: "primary",
|
|
80
|
+
checked: selectedIds.length > 0 && selectableIds.length > 0 && selectableIds.every((id) => selectedIds.includes(id)),
|
|
81
|
+
onChange: handleSelectAll
|
|
82
|
+
}
|
|
83
|
+
) }),
|
|
84
|
+
Children.map(
|
|
85
|
+
children,
|
|
86
|
+
(field, index) => isValidElement(field) ? /* @__PURE__ */ jsx(
|
|
87
|
+
DatagridHeaderCell,
|
|
88
|
+
{
|
|
89
|
+
className: clsx(
|
|
90
|
+
DatagridClasses.headerCell,
|
|
91
|
+
`column-${field.props.source}`
|
|
92
|
+
),
|
|
93
|
+
sort,
|
|
94
|
+
field,
|
|
95
|
+
isSorting: sort.field === (field.props.sortBy || field.props.source),
|
|
96
|
+
resource,
|
|
97
|
+
updateSort
|
|
98
|
+
},
|
|
99
|
+
field.props.source || index
|
|
100
|
+
) : null
|
|
101
|
+
)
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
) });
|
|
105
|
+
};
|
|
106
|
+
DatagridHeader.displayName = "DatagridHeader";
|
|
107
|
+
export {
|
|
108
|
+
SortableDatagridHeader
|
|
109
|
+
};
|