@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.
Files changed (111) hide show
  1. package/dist/components/AuditLog/AuditLog.js +345 -1
  2. package/dist/components/AuditLog/index.js +4 -1
  3. package/dist/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.js +630 -3
  4. package/dist/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.js +53 -1
  5. package/dist/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.js +647 -3
  6. package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.js +53 -1
  7. package/dist/components/Json/Json.js +235 -1
  8. package/dist/components/JsonColorSelector/JsonColorSelector.js +1172 -1
  9. package/dist/components/JsonColorSelector/JsonColorSelectorEnhanced.js +863 -2
  10. package/dist/components/JsonColorSelector/JsonCssVarValues.js +738 -1
  11. package/dist/components/JsonColorSelector/components/ColorEditDialog.js +426 -1
  12. package/dist/components/JsonColorSelector/components/ColorPaletteItem.js +75 -1
  13. package/dist/components/JsonColorSelector/components/ImageColorExtractor.js +283 -1
  14. package/dist/components/JsonColorSelector/helpers/functions.js +101 -1
  15. package/dist/components/JsonColorSelector/useAsyncColorThief.js +105 -1
  16. package/dist/components/ListActive/ListActive.js +126 -1
  17. package/dist/components/ListActive/ListBoolean.js +124 -1
  18. package/dist/components/NotificationPreferences/NotificationPreferences.js +317 -1
  19. package/dist/components/NotificationPreferences/index.js +7 -1
  20. package/dist/components/SearchableSelects/RASearchableSelect.js +236 -1
  21. package/dist/components/SearchableSelects/RASearchableSelectCheckboxes.js +479 -1
  22. package/dist/components/SearchableSelects/RASearchableSelectChips.js +465 -1
  23. package/dist/components/SearchableSelects/RASearchableSelectChipsRecordContext.js +295 -1
  24. package/dist/components/SearchableSelects/SearchableSelect.js +202 -1
  25. package/dist/components/SearchableSelects/SearchableSelectCheckboxes.js +290 -1
  26. package/dist/components/SortableDataGrid/SortableDataGrid.js +72 -1
  27. package/dist/components/SortableDataGrid/SortableDataGridBody.js +167 -1
  28. package/dist/components/SortableDataGrid/SortableDataGridHeader.js +109 -1
  29. package/dist/components/SortableDataGrid/SortableDataGridRow.js +283 -1
  30. package/dist/components/Upload/SingleImageUploader.js +40 -1
  31. package/dist/components/custom/PackageCopyMethod.js +78 -1
  32. package/dist/components/custom/PackageRadioButtonGroup.js +45 -1
  33. package/dist/components/dialog/Basic.js +8 -1
  34. package/dist/components/dialog/Correct.js +14 -1
  35. package/dist/components/dialog/Error.js +14 -1
  36. package/dist/components/dialog/Info.js +14 -1
  37. package/dist/components/dialog/InfoV2.js +21 -1
  38. package/dist/components/dialog/NotFound.js +14 -1
  39. package/dist/components/dialog/QuickSearch.js +117 -1
  40. package/dist/components/notifications/NotificationsCenter.js +597 -1
  41. package/dist/components/notifications/index.js +24 -1
  42. package/dist/components/tables/PaginationComponent.js +36 -1
  43. package/dist/components/theme/AppLoadingFallback.js +38 -2
  44. package/dist/components/theme/ErrorBoundary.js +52 -1
  45. package/dist/components/theme/InitialLoader.js +13 -1
  46. package/dist/components/theme/NotFound.js +136 -1
  47. package/dist/components/theme/NotResults.js +38 -1
  48. package/dist/hooks/useDraggable.js +6 -1
  49. package/dist/hooks/useNotifications.js +8 -1
  50. package/dist/hooks/useQuickSearch.js +26 -1
  51. package/dist/index.js +66 -5567
  52. package/dist/utils/setNativeValue.js +17 -1
  53. package/package.json +149 -132
  54. package/src/components/AuditLog/AuditLog.tsx +476 -0
  55. package/src/components/AuditLog/index.ts +2 -0
  56. package/src/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.tsx +917 -0
  57. package/src/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.tsx +39 -0
  58. package/src/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.tsx +916 -0
  59. package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.tsx +44 -0
  60. package/src/components/Json/Json.tsx +312 -0
  61. package/src/components/JsonColorSelector/JsonColorSelector.tsx +1435 -0
  62. package/src/components/JsonColorSelector/JsonColorSelectorEnhanced.tsx +1029 -0
  63. package/src/components/JsonColorSelector/JsonCssVarValues.tsx +863 -0
  64. package/src/components/JsonColorSelector/components/ColorEditDialog.tsx +491 -0
  65. package/src/components/JsonColorSelector/components/ColorPaletteItem.tsx +80 -0
  66. package/src/components/JsonColorSelector/components/ImageColorExtractor.tsx +328 -0
  67. package/src/components/JsonColorSelector/helpers/functions.tsx +123 -0
  68. package/src/components/JsonColorSelector/interfaces/interfaces.tsx +22 -0
  69. package/src/components/JsonColorSelector/useAsyncColorThief.tsx +97 -0
  70. package/src/components/ListActive/ListActive.tsx +106 -0
  71. package/src/components/ListActive/ListBoolean.tsx +96 -0
  72. package/src/components/NotificationPreferences/NotificationPreferences.tsx +463 -0
  73. package/src/components/NotificationPreferences/index.tsx +2 -0
  74. package/src/components/SearchableSelects/RASearchableSelect.tsx +300 -0
  75. package/src/components/SearchableSelects/RASearchableSelectCheckboxes.tsx +604 -0
  76. package/src/components/SearchableSelects/RASearchableSelectChips.tsx +558 -0
  77. package/src/components/SearchableSelects/RASearchableSelectChipsRecordContext.tsx +362 -0
  78. package/src/components/SearchableSelects/SearchableSelect.tsx +321 -0
  79. package/src/components/SearchableSelects/SearchableSelectCheckboxes.tsx +355 -0
  80. package/src/components/SortableDataGrid/SortableDataGrid.tsx +56 -0
  81. package/src/components/SortableDataGrid/SortableDataGridBody.tsx +175 -0
  82. package/src/components/SortableDataGrid/SortableDataGridHeader.tsx +171 -0
  83. package/src/components/SortableDataGrid/SortableDataGridRow.tsx +247 -0
  84. package/src/components/Upload/SingleImageUploader.tsx +55 -0
  85. package/src/components/custom/PackageCopyMethod.tsx +109 -0
  86. package/src/components/custom/PackageRadioButtonGroup.tsx +47 -0
  87. package/src/components/dialog/Basic.tsx +11 -0
  88. package/src/components/dialog/Correct.tsx +16 -0
  89. package/src/components/dialog/Error.tsx +15 -0
  90. package/src/components/dialog/Info.tsx +15 -0
  91. package/src/components/dialog/InfoV2.tsx +35 -0
  92. package/src/components/dialog/NotFound.tsx +18 -0
  93. package/src/components/dialog/QuickSearch.tsx +115 -0
  94. package/src/components/notifications/NotificationsCenter.tsx +792 -0
  95. package/src/components/notifications/index.ts +42 -0
  96. package/src/components/tables/PaginationComponent.tsx +17 -0
  97. package/src/components/theme/AppLoadingFallback.tsx +42 -0
  98. package/src/components/theme/ErrorBoundary.tsx +57 -0
  99. package/src/components/theme/InitialLoader.tsx +16 -0
  100. package/src/components/theme/NotFound.tsx +124 -0
  101. package/src/components/theme/NotResults.tsx +54 -0
  102. package/src/hooks/useDraggable.ts +11 -0
  103. package/src/hooks/useNotifications.ts +14 -0
  104. package/src/hooks/useQuickSearch.tsx +29 -0
  105. package/src/index.tsx +77 -0
  106. package/src/utils/setNativeValue.tsx +23 -0
  107. package/dist/color-thief-CTwGFhOB.js +0 -272
  108. /package/{dist → src}/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +0 -0
  109. /package/{dist → src}/components/JsonColorSelector/JsonColorSelector.tsx.bkup +0 -0
  110. /package/{dist → src}/components/SortableDataGrid/README.md +0 -0
  111. /package/{dist → src}/styles/index.less +0 -0
@@ -1 +1,290 @@
1
- import{Fragment as T,jsx as r,jsxs as g}from"react/jsx-runtime";import{Autocomplete as oe,Box as re,Checkbox as se,CircularProgress as R,TextField as ae}from"@mui/material";import le,{useEffect as i,useState as o}from"react";import ie from"@mui/icons-material/CheckBoxOutlineBlank";import ce from"@mui/icons-material/CheckBox";import{useAxios as ue}from"@dashadmin/dash-axios-hook";const de=r(ie,{fontSize:"small"}),pe=r(ce,{fontSize:"small"}),F=function({...L}){const{multiple:c,freeSolo:z,minSearch:B=3,timerSearch:D=500,checkboxes:S=!1,resource:w,selectLabel:v,renderText:a,queryFilter:J="q",defaultValues:f=null,elementKeyId:u="id",isEmpty:fe=!1,filter:K,isOptionEqualToValue:X=(e,n)=>n===e,renderAttribute:l=null,name:_,onChange:x,renderInputTextFieldProps:H,selectedIds:M,useDefaultSearch:k=!1,...Q}=L,[I,O]=o(!1),[s,b]=o(null),[h,W]=o(null),[y,j]=o(null),[d,C]=o(!1),[p,G]=o(null),N=f&&Array.isArray(f)?f.map(e=>e[u]?e[u]:e):c&&p?p:f,[U,A]=o(N),[m,P]=o(null),Y=ue();i(()=>{G(M)},[]);const V=(e,n)=>{Array.isArray(e)?(P(e),n==="onChange"&&A(e.map(t=>t[u]))):(P(e),n==="onChange"&&A(e[u]))},q=async()=>{C(!0);try{const e={[J]:h,...K,includes:U},{data:n}=await Y.get(w,{params:e});j(n.data)}catch(e){console.error(e)}finally{C(!1)}};i(()=>{q()},[]),i(()=>{h&&h!==""&&!k&&q()},[h]),i(()=>(y&&!d&&(s&&b([...s,...y.map(e=>({...e,key:"option"+e.id}))]),b(y.map(e=>({...e,key:"option"+e.id})))),()=>b([])),[y,d]);const[Z,$]=o(void 0),ee=(e,n=500)=>{clearTimeout(Z),$(setTimeout(()=>{e()},n))},ne=S?(e,n,{selected:t})=>{const{key:E,...te}=e;return g("li",{...te,children:[r(se,{icon:de,checkedIcon:pe,style:{marginRight:8},checked:t}),l&&!a?n[l]:a(n)]},n.key)}:(e,n)=>{const{key:t,...E}=e;return r(re,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...E,children:l&&!a?n[l]:a(n)},n.key)};return i(()=>{if(c&&s&&p){const e=s.filter(n=>p.includes(n[u]));V(e,"selectedIds")}},[s,p,c]),i(()=>{x&&m&&x(null,m,null)},[m]),g(T,{children:[d&&!s?r(R,{color:"inherit",size:20}):r(T,{}),s&&r(oe,{multiple:c,freeSolo:z,loading:d&&I,...S&&{disableCloseOnSelect:!0},options:s,open:I,onOpen:()=>O(!0),onClose:()=>O(!1),value:m||(c?[]:null),isOptionEqualToValue:X,autoHighlight:!0,getOptionLabel:e=>l&&!a?e[l]:a?a(e):e,renderOption:ne,onChange:(e,n,t)=>{V(n,"onChange")},renderInput:e=>r(ae,{...e,label:v,variant:"outlined",onChange:n=>{if(k!==!0){const t=n.target.value;t&&t!==""&&t.length>=B&&ee(()=>W(t),D)}},InputProps:{...e.InputProps,autoComplete:"new-password",endAdornment:g(T,{children:[d?r(R,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})},...H},e.id),...Q},"autocomplete-"+_)]})},Ae=le.memo(F,()=>!0);var Pe=F;export{Ae as MemoizedSearchableSelectCheckboxes,Pe as default};
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
- import{jsx as r}from"react/jsx-runtime";import{memo as l}from"react";import{Datagrid as s}from"react-admin";import m from"./SortableDataGridBody";import{SortableDatagridHeader as f}from"./SortableDataGridHeader";import g from"./SortableDataGridRow";import b from"react";const D=a=>{const{children:e,onOrderUpdate:t,...d}=a,i=b.useRef(null),n=o=>{t&&t(o)},p=l(o=>r(s,{...o,header:r(f,{}),body:r(m,{onOrderUpdate:n,ref:i,row:r(g,{})})}),()=>!0);return r("div",{id:"sortable-list",children:r(p,{...d,children:e})})};var x=D;export{x as default};
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
- import{jsx as r}from"react/jsx-runtime";import*as D from"react";import{cloneElement as T,memo as k,forwardRef as v}from"react";import{TableBody as A}from"@mui/material";import{DatagridRow as F,PureDatagridRow as I}from"react-admin";import{DragDropContext as $,Droppable as q,Draggable as w}from"@hello-pangea/dnd";const H=r(F,{}),O=[],f=v(({children:d,className:_,data:s=O,expand:c,hasBulkActions:y=!1,hover:u,onToggleItem:B,resource:P,row:x=H,rowClick:C,rowStyle:i,selectedIds:l,isRowSelectable:g,onOrderUpdate:p,...E},z)=>{D.useEffect(()=>{console.log("data has been updated")},[s]);const[m,R]=D.useState(s),S=(a,e,t)=>{const o=Array.from(a),[n]=o.splice(e,1);return o.splice(t,0,n),o},h=(a,e)=>({border:a?"1px dashed #ccc":"none",...e});return r($,{onDragEnd:a=>{if(!a.destination)return;const e=S(m,a.source.index,a.destination.index);R(e),p&&p(e)},children:r(q,{droppableId:"droppable",children:a=>r(A,{ref:a.innerRef,className:"datagrid-body",...E,children:m.map((e,t)=>r(w,{draggableId:"q-"+e.id,index:t,children:(o,n)=>{const N=i?i(e,t):{};return T(x,{ref:o.innerRef,...o.draggableProps,...o.dragHandleProps,expand:c,hasBulkActions:y&&!!l,hover:u,id:e.id??`row${t}`,key:e.id??`row${t}`,onToggleItem:B,record:e,resource:P,rowClick:C,selectable:!g||g(e),selected:l?.includes(e.id),style:{...N,...h(n.isDragging,o.draggableProps.style)}},d)}},e.id))})})})});f.muiName="TableBody";const b=k(d=>r(f,{row:r(I,{}),...d}),()=>!0);b.muiName="TableBody";var W=b;export{b as PureSortableDatagridBody,W as default};
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{jsx as s,jsxs as M}from"react/jsx-runtime";import{Children as N,isValidElement as k,useCallback as u}from"react";import{useListContext as w,useResourceContext as R}from"react-admin";import{Checkbox as A,TableCell as g,TableHead as P,TableRow as E}from"@mui/material";import c from"clsx";import{DatagridClasses as t,DatagridHeader as I,DatagridHeaderCell as L,useDatagridContext as B,useTranslate as _}from"react-admin";import F from"@mui/icons-material/Menu";const W=n=>{const{children:h,className:C,hasExpand:O=!1,hasSort:b=!0,hasBulkActions:S=!1,isRowSelectable:l}=n,f=R(n),x=_(),{sort:r,data:d,onSelect:p,selectedIds:o,setSort:i}=w(n),{expandSingle:V}=B(),y=u(e=>{e.stopPropagation();const a=e.currentTarget.dataset.field,T=r.field===a?r.order&&r.order.toLocaleLowerCase()==="asc"?"ASC":"DESC":e.currentTarget.dataset.order;i({field:a,order:T})},[r.field,r.order,i]),D=i?y:null,H=u(e=>p(e.target.checked?o.concat(d.filter(a=>!o.includes(a.id)).filter(a=>l?l(a):!0).map(a=>a.id)):[]),[d,p,l,o]),m=Array.isArray(d)?l?d.filter(e=>l(e)).map(e=>e.id):d.map(e=>e.id):[];return s(P,{className:c(C,t.thead),children:M(E,{className:c(t.row,t.headerRow),children:[b&&s(g,{padding:"none",className:c(t.headerCell,t.expandHeader),children:s(F,{sx:{cursor:"pointer"},className:"handle"})}),S&&o&&s(g,{padding:"checkbox",className:t.headerCell,children:s(A,{"aria-label":x("ra.action.select_all",{_:"Select all"}),className:"select-all",color:"primary",checked:o.length>0&&m.length>0&&m.every(e=>o.includes(e)),onChange:H})}),N.map(h,(e,a)=>k(e)?s(L,{className:c(t.headerCell,`column-${e.props.source}`),sort:r,field:e,isSorting:r.field===(e.props.sortBy||e.props.source),resource:f,updateSort:D},e.props.source||a):null)]})})};I.displayName="DatagridHeader";export{W as SortableDatagridHeader};
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
+ };