@dashadmin/dash-components 1.3.25 → 1.3.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +35 -0
  2. package/dist/components/AuditLog/AuditLog.js +345 -1
  3. package/dist/components/AuditLog/index.js +4 -1
  4. package/dist/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.js +630 -3
  5. package/dist/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.js +53 -1
  6. package/dist/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.js +647 -3
  7. package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.js +53 -1
  8. package/dist/components/Json/Json.js +235 -1
  9. package/dist/components/JsonColorSelector/JsonColorSelector.js +1172 -1
  10. package/dist/components/JsonColorSelector/JsonColorSelectorEnhanced.js +863 -2
  11. package/dist/components/JsonColorSelector/JsonCssVarValues.js +738 -1
  12. package/dist/components/JsonColorSelector/components/ColorEditDialog.js +426 -1
  13. package/dist/components/JsonColorSelector/components/ColorPaletteItem.js +75 -1
  14. package/dist/components/JsonColorSelector/components/ImageColorExtractor.js +283 -1
  15. package/dist/components/JsonColorSelector/helpers/functions.js +101 -1
  16. package/dist/components/JsonColorSelector/useAsyncColorThief.js +105 -1
  17. package/dist/components/ListActive/ListActive.js +126 -1
  18. package/dist/components/ListActive/ListBoolean.js +124 -1
  19. package/dist/components/NotificationPreferences/NotificationPreferences.js +317 -1
  20. package/dist/components/NotificationPreferences/index.js +7 -1
  21. package/dist/components/SearchableSelects/RASearchableSelect.js +236 -1
  22. package/dist/components/SearchableSelects/RASearchableSelectCheckboxes.js +479 -1
  23. package/dist/components/SearchableSelects/RASearchableSelectChips.js +465 -1
  24. package/dist/components/SearchableSelects/RASearchableSelectChipsRecordContext.js +295 -1
  25. package/dist/components/SearchableSelects/SearchableSelect.js +202 -1
  26. package/dist/components/SearchableSelects/SearchableSelectCheckboxes.js +290 -1
  27. package/dist/components/SortableDataGrid/SortableDataGrid.js +72 -1
  28. package/dist/components/SortableDataGrid/SortableDataGridBody.js +167 -1
  29. package/dist/components/SortableDataGrid/SortableDataGridHeader.js +109 -1
  30. package/dist/components/SortableDataGrid/SortableDataGridRow.js +283 -1
  31. package/dist/components/Upload/SingleImageUploader.js +40 -1
  32. package/dist/components/custom/PackageCopyMethod.js +78 -1
  33. package/dist/components/custom/PackageRadioButtonGroup.js +45 -1
  34. package/dist/components/dialog/Basic.js +8 -1
  35. package/dist/components/dialog/Correct.js +14 -1
  36. package/dist/components/dialog/Error.js +14 -1
  37. package/dist/components/dialog/Info.js +14 -1
  38. package/dist/components/dialog/InfoV2.js +21 -1
  39. package/dist/components/dialog/NotFound.js +14 -1
  40. package/dist/components/dialog/QuickSearch.js +117 -1
  41. package/dist/components/notifications/NotificationsCenter.js +597 -1
  42. package/dist/components/notifications/index.js +24 -1
  43. package/dist/components/tables/PaginationComponent.js +36 -1
  44. package/dist/components/theme/AppLoadingFallback.js +38 -2
  45. package/dist/components/theme/ErrorBoundary.js +52 -1
  46. package/dist/components/theme/InitialLoader.js +13 -1
  47. package/dist/components/theme/NotFound.js +136 -1
  48. package/dist/components/theme/NotResults.js +38 -1
  49. package/dist/hooks/useDraggable.js +6 -1
  50. package/dist/hooks/useNotifications.js +8 -1
  51. package/dist/hooks/useQuickSearch.js +26 -1
  52. package/dist/index.js +66 -5567
  53. package/dist/utils/setNativeValue.js +17 -1
  54. package/package.json +148 -132
  55. package/src/components/AuditLog/AuditLog.tsx +476 -0
  56. package/src/components/AuditLog/index.ts +2 -0
  57. package/src/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.tsx +917 -0
  58. package/src/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.tsx +39 -0
  59. package/src/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.tsx +916 -0
  60. package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.tsx +44 -0
  61. package/src/components/Json/Json.tsx +312 -0
  62. package/src/components/JsonColorSelector/JsonColorSelector.tsx +1435 -0
  63. package/src/components/JsonColorSelector/JsonColorSelectorEnhanced.tsx +1029 -0
  64. package/src/components/JsonColorSelector/JsonCssVarValues.tsx +863 -0
  65. package/src/components/JsonColorSelector/components/ColorEditDialog.tsx +491 -0
  66. package/src/components/JsonColorSelector/components/ColorPaletteItem.tsx +80 -0
  67. package/src/components/JsonColorSelector/components/ImageColorExtractor.tsx +328 -0
  68. package/src/components/JsonColorSelector/helpers/functions.tsx +123 -0
  69. package/src/components/JsonColorSelector/interfaces/interfaces.tsx +22 -0
  70. package/src/components/JsonColorSelector/useAsyncColorThief.tsx +97 -0
  71. package/src/components/ListActive/ListActive.tsx +106 -0
  72. package/src/components/ListActive/ListBoolean.tsx +96 -0
  73. package/src/components/NotificationPreferences/NotificationPreferences.tsx +463 -0
  74. package/src/components/NotificationPreferences/index.tsx +2 -0
  75. package/src/components/SearchableSelects/RASearchableSelect.tsx +300 -0
  76. package/src/components/SearchableSelects/RASearchableSelectCheckboxes.tsx +604 -0
  77. package/src/components/SearchableSelects/RASearchableSelectChips.tsx +558 -0
  78. package/src/components/SearchableSelects/RASearchableSelectChipsRecordContext.tsx +362 -0
  79. package/src/components/SearchableSelects/SearchableSelect.tsx +321 -0
  80. package/src/components/SearchableSelects/SearchableSelectCheckboxes.tsx +355 -0
  81. package/src/components/SortableDataGrid/SortableDataGrid.tsx +56 -0
  82. package/src/components/SortableDataGrid/SortableDataGridBody.tsx +175 -0
  83. package/src/components/SortableDataGrid/SortableDataGridHeader.tsx +171 -0
  84. package/src/components/SortableDataGrid/SortableDataGridRow.tsx +247 -0
  85. package/src/components/Upload/SingleImageUploader.tsx +55 -0
  86. package/src/components/custom/PackageCopyMethod.tsx +109 -0
  87. package/src/components/custom/PackageRadioButtonGroup.tsx +47 -0
  88. package/src/components/dialog/Basic.tsx +11 -0
  89. package/src/components/dialog/Correct.tsx +16 -0
  90. package/src/components/dialog/Error.tsx +15 -0
  91. package/src/components/dialog/Info.tsx +15 -0
  92. package/src/components/dialog/InfoV2.tsx +35 -0
  93. package/src/components/dialog/NotFound.tsx +18 -0
  94. package/src/components/dialog/QuickSearch.tsx +115 -0
  95. package/src/components/notifications/NotificationsCenter.tsx +792 -0
  96. package/src/components/notifications/index.ts +42 -0
  97. package/src/components/tables/PaginationComponent.tsx +17 -0
  98. package/src/components/theme/AppLoadingFallback.tsx +42 -0
  99. package/src/components/theme/ErrorBoundary.tsx +57 -0
  100. package/src/components/theme/InitialLoader.tsx +16 -0
  101. package/src/components/theme/NotFound.tsx +124 -0
  102. package/src/components/theme/NotResults.tsx +54 -0
  103. package/src/hooks/useDraggable.ts +11 -0
  104. package/src/hooks/useNotifications.ts +14 -0
  105. package/src/hooks/useQuickSearch.tsx +29 -0
  106. package/src/index.tsx +77 -0
  107. package/src/utils/setNativeValue.tsx +23 -0
  108. package/dist/color-thief-CTwGFhOB.js +0 -272
  109. /package/{dist → src}/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +0 -0
  110. /package/{dist → src}/components/JsonColorSelector/JsonColorSelector.tsx.bkup +0 -0
  111. /package/{dist → src}/components/SortableDataGrid/README.md +0 -0
  112. /package/{dist → src}/styles/index.less +0 -0
@@ -1 +1,236 @@
1
- import{Fragment as I,jsx as i,jsxs as K}from"react/jsx-runtime";import{Autocomplete as B,Box as M,CircularProgress as Q,TextField as W}from"@mui/material";import{useEffect as z,useState as g}from"react";import{useController as G}from"react-hook-form";import{useGetList as H}from"react-admin";import{useRecordContext as _}from"react-admin";import{isArray as j}from"lodash";const A=({method:u,attribute:o,isMultiple:d=!1,searchResults:N=50,minSearch:k=3,timerSearch:D=500,resource:L,selectLabel:P,renderText:c,transformData:v,queryFilter:x="q",defaultValues:U=void 0,isEmpty:F=!1,filter:V,isOptionEqualToValue:h=void 0,viewAttribute:f=null,elementKeyId:O="id"})=>{const[S,C]=g(!0),[l,y]=g(null),[b,w]=g(""),a=_(),s=G({name:o.attribute,defaultValue:a?a[o.attribute]:null}),E=a&&a[o.attribute]&&j(a[o.attribute])?a[o.attribute].map(e=>e.hasOwnProperty(O)?e[O]:e):a[o.attribute],{data:p,total:X,isLoading:m,error:Y}=H(L,{filter:{[x]:b,...V,includes:E}},{refetchOnWindowFocus:!1});z(()=>(p&&!m&&(l&&y([...l,...p.map(e=>({...e,key:"option"+e.id}))]),y(p.map(e=>({...e,key:"option"+e.id})))),()=>y([])),[p,m]);const[R,T]=g(void 0),q=(e,t=500)=>{clearTimeout(R),T(setTimeout(()=>{e()},t))};return i(I,{children:l&&i(B,{multiple:d,loading:m&&S,fullWidth:!0,freeSolo:!0,options:l,open:S,onOpen:()=>C(!0),onClose:()=>C(!1),defaultValue:s.field?.value,isOptionEqualToValue:h,autoHighlight:!0,getOptionLabel:e=>{const t=Array.isArray(e)?e:l&&l.find(r=>h(r,s.field.value));if(!t)return b;const n=f&&!c?t[f]:c(t);return console.log("getOptionLabel",l.find(r=>h(r,s.field.value)),n),n||b},renderOption:(e,t)=>{const{key:n,...r}=e;return i(M,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...r,children:f&&!c?t[f]:c(t)},t.key)},onChange:(e,t)=>{console.log("onChange",e,t);let n=t;Array.isArray(t)&&(n=F?[...t,...s.field.value]:[...new Map(n.map(r=>[r.id,r])).values()]),v?s.field.onChange(v(n)):s.field.onChange(n)},renderInput:e=>(console.log("renderInput",e.id),i(W,{...e,label:P,variant:"outlined",onChange:t=>{let n=t.target.value;n&&n!==""&&n.length>=k&&q(()=>w(n),D)},InputProps:{...e.InputProps,autoComplete:"new-password",endAdornment:K(I,{children:[m?i(Q,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})}},e.id))},"autocomplete-"+o.attribute)})},J=({method:u,attribute:o,...d})=>{switch(u){case"edit":case"create":return i(A,{attribute:o,method:u,...d});case"view":return i(A,{attribute:o,method:u,...d})}};var de=J;export{de 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 { Fragment, jsx, jsxs } from "react/jsx-runtime";
33
+ import {
34
+ Autocomplete,
35
+ Box,
36
+ CircularProgress,
37
+ TextField
38
+ } from "@mui/material";
39
+ import { useEffect, useState } from "react";
40
+ import { useController } from "react-hook-form";
41
+ import { useGetList } from "react-admin";
42
+ import { useRecordContext } from "react-admin";
43
+ import { isArray } from "lodash";
44
+ const SearchableSelect = ({
45
+ method,
46
+ attribute,
47
+ isMultiple = false,
48
+ //pagination = true,
49
+ searchResults = 50,
50
+ minSearch = 3,
51
+ timerSearch = 500,
52
+ resource,
53
+ selectLabel,
54
+ renderText,
55
+ transformData,
56
+ queryFilter = "q",
57
+ defaultValues = void 0,
58
+ isEmpty = false,
59
+ filter,
60
+ isOptionEqualToValue = void 0,
61
+ viewAttribute = null,
62
+ elementKeyId = "id"
63
+ }) => {
64
+ var _a;
65
+ const [open, setOpen] = useState(true);
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
+ const includes = record && record[attribute.attribute] && isArray(record[attribute.attribute]) ? record[attribute.attribute].map(
74
+ (element) => element.hasOwnProperty(elementKeyId) ? element[elementKeyId] : element
75
+ ) : record[attribute.attribute];
76
+ const {
77
+ data: resourceData,
78
+ total,
79
+ isLoading,
80
+ error
81
+ } = useGetList(
82
+ resource,
83
+ {
84
+ filter: __spreadProps(__spreadValues({ [queryFilter]: q }, filter), { includes })
85
+ },
86
+ { refetchOnWindowFocus: false }
87
+ );
88
+ useEffect(() => {
89
+ if (resourceData && !isLoading) {
90
+ if (parsedOptions)
91
+ setParsedOptions([
92
+ ...parsedOptions,
93
+ ...resourceData.map((ele) => {
94
+ return __spreadProps(__spreadValues({}, ele), { key: "option" + ele.id });
95
+ })
96
+ ]);
97
+ setParsedOptions(
98
+ resourceData.map((ele) => {
99
+ return __spreadProps(__spreadValues({}, ele), { key: "option" + ele.id });
100
+ })
101
+ );
102
+ }
103
+ return () => setParsedOptions([]);
104
+ }, [resourceData, isLoading]);
105
+ const [timeOutSearch, setTimeOutSearch] = useState(void 0);
106
+ const debounce = (fn, delay = 500) => {
107
+ clearTimeout(timeOutSearch);
108
+ setTimeOutSearch(
109
+ setTimeout(() => {
110
+ fn();
111
+ }, delay)
112
+ );
113
+ };
114
+ return /* @__PURE__ */ jsx(Fragment, { children: parsedOptions && /* @__PURE__ */ jsx(
115
+ Autocomplete,
116
+ {
117
+ multiple: isMultiple,
118
+ loading: isLoading && open,
119
+ fullWidth: true,
120
+ freeSolo: true,
121
+ options: parsedOptions,
122
+ open,
123
+ onOpen: () => setOpen(true),
124
+ onClose: () => setOpen(false),
125
+ defaultValue: (_a = field.field) == null ? void 0 : _a.value,
126
+ isOptionEqualToValue,
127
+ autoHighlight: true,
128
+ getOptionLabel: (option) => {
129
+ const _option = !Array.isArray(option) ? parsedOptions && parsedOptions.find(
130
+ (ele) => isOptionEqualToValue(ele, field.field.value)
131
+ ) : option;
132
+ if (!_option) return q;
133
+ const r = viewAttribute && !renderText ? _option[viewAttribute] : renderText(_option);
134
+ console.log(
135
+ "getOptionLabel",
136
+ parsedOptions.find(
137
+ (ele) => isOptionEqualToValue(ele, field.field.value)
138
+ ),
139
+ r
140
+ );
141
+ if (!r) return q;
142
+ return r;
143
+ },
144
+ renderOption: (props, option) => {
145
+ const _a2 = props, { key } = _a2, newProps = __objRest(_a2, ["key"]);
146
+ return /* @__PURE__ */ jsx(
147
+ Box,
148
+ __spreadProps(__spreadValues({
149
+ component: "li",
150
+ sx: { "& > img": { mr: 2, flexShrink: 0 } }
151
+ }, newProps), {
152
+ children: viewAttribute && !renderText ? option[viewAttribute] : renderText(option)
153
+ }),
154
+ option.key
155
+ );
156
+ },
157
+ onChange: (event, rawValue) => {
158
+ console.log("onChange", event, rawValue);
159
+ let newValue = rawValue;
160
+ if (Array.isArray(rawValue)) {
161
+ newValue = isEmpty ? [...rawValue, ...field.field.value] : [
162
+ ...new Map(
163
+ newValue.map((v) => [v.id, v])
164
+ ).values()
165
+ ];
166
+ }
167
+ transformData ? field.field.onChange(transformData(newValue)) : field.field.onChange(newValue);
168
+ },
169
+ renderInput: (params) => {
170
+ console.log("renderInput", params.id);
171
+ return /* @__PURE__ */ jsx(
172
+ TextField,
173
+ __spreadProps(__spreadValues({}, params), {
174
+ label: selectLabel,
175
+ variant: "outlined",
176
+ onChange: (ev) => {
177
+ let searchValue = ev.target.value;
178
+ if (searchValue && searchValue !== "" && searchValue.length >= minSearch)
179
+ debounce(
180
+ () => setQ(searchValue),
181
+ timerSearch
182
+ );
183
+ },
184
+ InputProps: __spreadProps(__spreadValues({}, params.InputProps), {
185
+ autoComplete: "new-password",
186
+ endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
187
+ isLoading ? /* @__PURE__ */ jsx(
188
+ CircularProgress,
189
+ {
190
+ color: "inherit",
191
+ size: 20
192
+ }
193
+ ) : null,
194
+ params.InputProps.endAdornment
195
+ ] })
196
+ })
197
+ }),
198
+ params.id
199
+ );
200
+ }
201
+ },
202
+ "autocomplete-" + attribute.attribute
203
+ ) });
204
+ };
205
+ const RASearchableSelect = (_a) => {
206
+ var _b = _a, {
207
+ method,
208
+ attribute
209
+ } = _b, props = __objRest(_b, [
210
+ "method",
211
+ "attribute"
212
+ ]);
213
+ switch (method) {
214
+ case "edit":
215
+ case "create":
216
+ return /* @__PURE__ */ jsx(
217
+ SearchableSelect,
218
+ __spreadValues({
219
+ attribute,
220
+ method
221
+ }, props)
222
+ );
223
+ case "view":
224
+ return /* @__PURE__ */ jsx(
225
+ SearchableSelect,
226
+ __spreadValues({
227
+ attribute,
228
+ method
229
+ }, props)
230
+ );
231
+ }
232
+ };
233
+ var RASearchableSelect_default = RASearchableSelect;
234
+ export {
235
+ RASearchableSelect_default as default
236
+ };