@dashadmin/dash-components 1.3.73 → 1.3.74-srcfree.2

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.d.ts +27 -0
  2. package/dist/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.d.ts +22 -0
  3. package/dist/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.d.ts +7 -0
  4. package/dist/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.d.ts +22 -0
  5. package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.d.ts +7 -0
  6. package/dist/components/Json/Json.d.ts +5 -0
  7. package/dist/components/JsonColorSelector/JsonColorSelector.d.ts +5 -0
  8. package/dist/components/JsonColorSelector/JsonColorSelectorEnhanced.d.ts +4 -0
  9. package/dist/components/JsonColorSelector/JsonCssVarValues.d.ts +5 -0
  10. package/dist/components/JsonColorSelector/components/BasicColorSelector.d.ts +9 -0
  11. package/dist/components/JsonColorSelector/components/ColorEditDialog.d.ts +12 -0
  12. package/dist/components/JsonColorSelector/components/ColorPaletteItem.d.ts +7 -0
  13. package/dist/components/JsonColorSelector/components/ImageColorExtractor.d.ts +9 -0
  14. package/dist/components/JsonColorSelector/helpers/functions.d.ts +11 -0
  15. package/dist/components/JsonColorSelector/helpers/paletteDerivation.d.ts +37 -0
  16. package/{src/components/JsonColorSelector/interfaces/interfaces.tsx → dist/components/JsonColorSelector/interfaces/interfaces.d.ts} +6 -8
  17. package/dist/components/JsonColorSelector/useAsyncColorThief.d.ts +11 -0
  18. package/dist/components/ListActive/ListActive.d.ts +10 -0
  19. package/dist/components/ListActive/ListBoolean.d.ts +10 -0
  20. package/dist/components/NotificationPreferences/NotificationPreferences.d.ts +6 -0
  21. package/dist/components/SearchableSelects/RASearchableSelect.d.ts +25 -0
  22. package/dist/components/SearchableSelects/RASearchableSelectCheckboxes.d.ts +35 -0
  23. package/dist/components/SearchableSelects/RASearchableSelectChips.d.ts +33 -0
  24. package/dist/components/SearchableSelects/RASearchableSelectChipsRecordContext.d.ts +30 -0
  25. package/dist/components/SearchableSelects/SearchableSelect.d.ts +25 -0
  26. package/dist/components/SearchableSelects/SearchableSelectCheckboxes.d.ts +29 -0
  27. package/dist/components/SortableDataGrid/SortableDataGrid.d.ts +7 -0
  28. package/dist/components/SortableDataGrid/SortableDataGridBody.d.ts +7 -0
  29. package/dist/components/SortableDataGrid/SortableDataGridHeader.d.ts +6 -0
  30. package/dist/components/SortableDataGrid/SortableDataGridRow.d.ts +5 -0
  31. package/dist/components/Upload/SingleImageUploader.d.ts +8 -0
  32. package/dist/components/custom/PackageCopyMethod.d.ts +15 -0
  33. package/dist/components/custom/PackageRadioButtonGroup.d.ts +8 -0
  34. package/dist/components/dialog/Basic.d.ts +2 -0
  35. package/dist/components/dialog/Correct.d.ts +2 -0
  36. package/dist/components/dialog/Error.d.ts +2 -0
  37. package/dist/components/dialog/Info.d.ts +2 -0
  38. package/dist/components/dialog/InfoV2.d.ts +2 -0
  39. package/dist/components/dialog/NotFound.d.ts +2 -0
  40. package/dist/components/dialog/QuickSearch.d.ts +6 -0
  41. package/dist/components/notifications/NotificationsCenter.d.ts +109 -0
  42. package/dist/components/notifications/index.d.ts +2 -0
  43. package/dist/components/tables/PaginationComponent.d.ts +4 -0
  44. package/dist/components/theme/AppLoadingFallback.d.ts +6 -0
  45. package/dist/components/theme/ErrorBoundary.d.ts +19 -0
  46. package/dist/components/theme/InitialLoader.d.ts +3 -0
  47. package/dist/components/theme/NotFound.d.ts +13 -0
  48. package/dist/components/theme/NotResults.d.ts +7 -0
  49. package/dist/hooks/useDraggable.d.ts +1 -0
  50. package/dist/hooks/useNotifications.d.ts +2 -0
  51. package/dist/hooks/useQuickSearch.d.ts +6 -0
  52. package/{src/index.tsx → dist/index.d.ts} +10 -58
  53. package/dist/utils/setNativeValue.d.ts +2 -0
  54. package/package.json +24 -21
  55. package/src/components/AuditLog/AuditLog.tsx +0 -490
  56. package/src/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.tsx +0 -917
  57. package/src/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.tsx +0 -39
  58. package/src/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.tsx +0 -916
  59. package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +0 -42
  60. package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.tsx +0 -44
  61. package/src/components/Json/Json.tsx +0 -312
  62. package/src/components/JsonColorSelector/JsonColorSelector.tsx +0 -1443
  63. package/src/components/JsonColorSelector/JsonColorSelector.tsx.bkup +0 -746
  64. package/src/components/JsonColorSelector/JsonColorSelectorEnhanced.tsx +0 -1135
  65. package/src/components/JsonColorSelector/JsonCssVarValues.tsx +0 -867
  66. package/src/components/JsonColorSelector/components/BasicColorSelector.tsx +0 -333
  67. package/src/components/JsonColorSelector/components/ColorEditDialog.tsx +0 -495
  68. package/src/components/JsonColorSelector/components/ColorPaletteItem.tsx +0 -80
  69. package/src/components/JsonColorSelector/components/ImageColorExtractor.tsx +0 -420
  70. package/src/components/JsonColorSelector/helpers/functions.tsx +0 -123
  71. package/src/components/JsonColorSelector/helpers/paletteDerivation.ts +0 -367
  72. package/src/components/JsonColorSelector/useAsyncColorThief.tsx +0 -97
  73. package/src/components/ListActive/ListActive.tsx +0 -106
  74. package/src/components/ListActive/ListBoolean.tsx +0 -96
  75. package/src/components/NotificationPreferences/NotificationPreferences.tsx +0 -480
  76. package/src/components/SearchableSelects/RASearchableSelect.tsx +0 -303
  77. package/src/components/SearchableSelects/RASearchableSelectCheckboxes.tsx +0 -617
  78. package/src/components/SearchableSelects/RASearchableSelectChips.tsx +0 -561
  79. package/src/components/SearchableSelects/RASearchableSelectChipsRecordContext.tsx +0 -366
  80. package/src/components/SearchableSelects/SearchableSelect.tsx +0 -323
  81. package/src/components/SearchableSelects/SearchableSelectCheckboxes.tsx +0 -358
  82. package/src/components/SortableDataGrid/README.md +0 -1
  83. package/src/components/SortableDataGrid/SortableDataGrid.tsx +0 -56
  84. package/src/components/SortableDataGrid/SortableDataGridBody.tsx +0 -175
  85. package/src/components/SortableDataGrid/SortableDataGridHeader.tsx +0 -171
  86. package/src/components/SortableDataGrid/SortableDataGridRow.tsx +0 -247
  87. package/src/components/Upload/SingleImageUploader.tsx +0 -55
  88. package/src/components/custom/PackageCopyMethod.tsx +0 -109
  89. package/src/components/custom/PackageRadioButtonGroup.tsx +0 -49
  90. package/src/components/dialog/Basic.tsx +0 -11
  91. package/src/components/dialog/Correct.tsx +0 -16
  92. package/src/components/dialog/Error.tsx +0 -15
  93. package/src/components/dialog/Info.tsx +0 -15
  94. package/src/components/dialog/InfoV2.tsx +0 -35
  95. package/src/components/dialog/NotFound.tsx +0 -18
  96. package/src/components/dialog/QuickSearch.tsx +0 -115
  97. package/src/components/notifications/NotificationsCenter.tsx +0 -743
  98. package/src/components/notifications/index.ts +0 -42
  99. package/src/components/tables/PaginationComponent.tsx +0 -17
  100. package/src/components/theme/AppLoadingFallback.tsx +0 -42
  101. package/src/components/theme/ErrorBoundary.tsx +0 -57
  102. package/src/components/theme/InitialLoader.tsx +0 -16
  103. package/src/components/theme/NotFound.tsx +0 -124
  104. package/src/components/theme/NotResults.tsx +0 -56
  105. package/src/hooks/useDraggable.ts +0 -11
  106. package/src/hooks/useNotifications.ts +0 -14
  107. package/src/hooks/useQuickSearch.tsx +0 -29
  108. package/src/styles/index.less +0 -0
  109. package/src/utils/setNativeValue.tsx +0 -23
  110. /package/{src/components/AuditLog/index.ts → dist/components/AuditLog/index.d.ts} +0 -0
  111. /package/{src/components/NotificationPreferences/index.tsx → dist/components/NotificationPreferences/index.d.ts} +0 -0
@@ -1,42 +0,0 @@
1
- import { AutocompleteInputProps, RaRecord } from 'react-admin/src';
2
- /* TODO: AutoCompleteCheckBoxInputAutoSearch doesn't exists! */
3
- /* @ts-ignore */
4
- import { AutocompleteCheckBoxInputAutoSearch } from './AutoCompleteCheckBoxInputAutoSearch';
5
- import React from 'react';
6
-
7
- export const AutocompleteCheckBoxArrayInputAutoSearch = <
8
- OptionType extends RaRecord = RaRecord,
9
- DisableClearable extends boolean | undefined = boolean | undefined,
10
- SupportCreate extends boolean | undefined = false,
11
- >({
12
- defaultValue,
13
- ...props
14
- }: AutocompleteArrayInputProps<
15
- OptionType,
16
- DisableClearable,
17
- SupportCreate
18
- >) => {
19
- return (
20
- <AutocompleteCheckBoxInputAutoSearch<
21
- OptionType,
22
- true,
23
- DisableClearable,
24
- SupportCreate
25
- >
26
- {...props}
27
- multiple
28
- defaultValue={defaultValue ?? []}
29
- />
30
- );
31
- };
32
-
33
- export type AutocompleteArrayInputProps<
34
- OptionType = RaRecord,
35
- DisableClearable extends boolean | undefined = false,
36
- SupportCreate extends boolean | undefined = false,
37
- > = Omit<
38
- AutocompleteInputProps<OptionType, true, DisableClearable, SupportCreate>,
39
- 'defaultValue'
40
- > & {
41
- defaultValue?: any[];
42
- };
@@ -1,44 +0,0 @@
1
- import { AutocompleteInputProps, RaRecord } from 'react-admin';
2
-
3
- import React from 'react';
4
-
5
- const AutocompleteCheckBoxArrayInput = <
6
- OptionType extends RaRecord = RaRecord,
7
- DisableClearable extends boolean | undefined = boolean | undefined,
8
- SupportCreate extends boolean | undefined = false,
9
- >({
10
- defaultValue,
11
- ...props
12
- }: AutocompleteArrayInputProps<
13
- OptionType,
14
- DisableClearable,
15
- SupportCreate
16
- >) => {
17
- return (
18
- /* @ts-ignore Expected */
19
- <AutocompleteCheckBoxInput<
20
- OptionType,
21
- true,
22
- DisableClearable,
23
- SupportCreate
24
- >
25
- {...props}
26
- multiple
27
- defaultValue={defaultValue ?? []}
28
- />
29
- );
30
- };
31
-
32
- export type AutocompleteArrayInputProps<
33
- OptionType = RaRecord,
34
- DisableClearable extends boolean | undefined = false,
35
- SupportCreate extends boolean | undefined = false,
36
- > = Omit<
37
- AutocompleteInputProps<OptionType, true, DisableClearable, SupportCreate>,
38
- 'defaultValue'
39
- > & {
40
- defaultValue?: any[];
41
- };
42
-
43
-
44
- export default AutocompleteCheckBoxArrayInput;
@@ -1,312 +0,0 @@
1
- import { IDashAutoAdminCustomFieldComponent } from 'dash-auto-admin';
2
- import { useRecordContext } from 'react-admin';
3
- import { useFormContext } from 'react-hook-form';
4
- import {
5
- Box,
6
- Button,
7
- IconButton,
8
- TextField,
9
- Typography,
10
- Table,
11
- TableBody,
12
- TableCell,
13
- TableContainer,
14
- TableHead,
15
- TableRow,
16
- Paper
17
- } from '@mui/material';
18
- import DeleteIcon from '@mui/icons-material/Delete';
19
- import AddIcon from '@mui/icons-material/Add';
20
- import { useState, useEffect } from 'react';
21
-
22
- interface KeyValuePair {
23
- key: string;
24
- value: string;
25
- id: string; // For React key prop
26
- }
27
-
28
- export const JsonEdit: React.FC<IDashAutoAdminCustomFieldComponent> = (props) => {
29
- const { method, attribute, resourceConfig } = props;
30
- const record = useRecordContext();
31
- const { setValue, getValues } = useFormContext();
32
-
33
- // Extract the nested path from the attribute
34
- const attributePath = attribute.attribute;
35
- const isNestedSetting = attributePath.startsWith('settings.');
36
- const settingsPath = isNestedSetting ? attributePath.split('.').slice(1).join('.') : attributePath;
37
-
38
- // State for key-value pairs
39
- const [pairs, setPairs] = useState<KeyValuePair[]>([]);
40
- const [keyError, setKeyError] = useState<{[key: string]: string}>({});
41
-
42
- // Initialize the component with the current value
43
- useEffect(() => {
44
- let initialValue: Record<string, any> = {};
45
-
46
- if (isNestedSetting && record?.settings) {
47
- // For nested settings, get from record.settings
48
- const settings = record.settings || {};
49
- initialValue = getNestedValue(settings, settingsPath) || {};
50
- } else if (record?.[attributePath]) {
51
- // For direct attributes
52
- initialValue = record[attributePath] || {};
53
- }
54
-
55
- // Convert object to array of key-value pairs
56
- const initialPairs = Object.entries(initialValue).map(([key, value]) => ({
57
- key,
58
- value: typeof value === 'object' ? JSON.stringify(value) : String(value),
59
- id: generateId()
60
- }));
61
-
62
- setPairs(initialPairs);
63
- }, [record, attributePath]);
64
-
65
- // Helper function to get a nested value from an object
66
- const getNestedValue = (obj: any, path: string): any => {
67
- if (!path) return obj;
68
- const keys = path.split('.');
69
- return keys.reduce((o, key) => (o && o[key] !== undefined ? o[key] : {}), obj);
70
- };
71
-
72
- // Helper function to set a nested value in an object
73
- const setNestedValue = (obj: any, path: string, value: any): any => {
74
- if (!path) return value;
75
-
76
- const keys = path.split('.');
77
- const lastKey = keys.pop();
78
- const lastObj = keys.reduce((o, key) => {
79
- if (o[key] === undefined) o[key] = {};
80
- return o[key];
81
- }, obj);
82
-
83
- if (lastKey) {
84
- lastObj[lastKey] = value;
85
- }
86
- return obj;
87
- };
88
-
89
- // Generate a unique ID for React keys
90
- const generateId = (): string => {
91
- return Math.random().toString(36).substring(2, 11);
92
- };
93
-
94
- // Add a new empty key-value pair
95
- const addPair = () => {
96
- setPairs([...pairs, { key: '', value: '', id: generateId() }]);
97
- };
98
-
99
- // Remove a key-value pair
100
- const removePair = (id: string) => {
101
- setPairs(pairs.filter(pair => pair.id !== id));
102
- updateFormValue(pairs.filter(pair => pair.id !== id));
103
- };
104
-
105
- // Handle key change
106
- const handleKeyChange = (id: string, newKey: string) => {
107
- // Check for duplicate keys
108
- const isDuplicate = pairs.some(pair => pair.id !== id && pair.key === newKey);
109
-
110
- if (isDuplicate) {
111
- setKeyError({...keyError, [id]: 'Duplicate key'});
112
- } else {
113
- setKeyError({...keyError, [id]: ''});
114
- }
115
-
116
- const updatedPairs = pairs.map(pair =>
117
- pair.id === id ? { ...pair, key: newKey } : pair
118
- );
119
-
120
- setPairs(updatedPairs);
121
- updateFormValue(updatedPairs);
122
- };
123
-
124
- // Handle value change
125
- const handleValueChange = (id: string, newValue: string) => {
126
- const updatedPairs = pairs.map(pair =>
127
- pair.id === id ? { ...pair, value: newValue } : pair
128
- );
129
-
130
- setPairs(updatedPairs);
131
- updateFormValue(updatedPairs);
132
- };
133
-
134
- // Update the form value
135
- const updateFormValue = (currentPairs: KeyValuePair[]) => {
136
- // Convert array of pairs to object
137
- const obj = currentPairs.reduce((acc, pair) => {
138
- if (pair.key.trim()) {
139
- let parsedValue: any = pair.value;
140
-
141
- // Try to parse JSON values
142
- try {
143
- if (pair.value.trim().startsWith('{') ||
144
- pair.value.trim().startsWith('[') ||
145
- pair.value.trim() === 'true' ||
146
- pair.value.trim() === 'false' ||
147
- !isNaN(Number(pair.value.trim()))) {
148
- parsedValue = JSON.parse(pair.value);
149
- }
150
- } catch (e) {
151
- // If parsing fails, use the string value
152
- }
153
-
154
- acc[pair.key] = parsedValue;
155
- }
156
- return acc;
157
- }, {} as Record<string, any>);
158
-
159
- // Update the form
160
- if (isNestedSetting) {
161
- const currentSettings = getValues('settings') || {};
162
- const updatedSettings = setNestedValue({...currentSettings}, settingsPath, obj);
163
- setValue('settings', updatedSettings, { shouldDirty: true });
164
- } else {
165
- setValue(attributePath, obj, { shouldDirty: true });
166
- }
167
- };
168
-
169
- return (
170
- <Box sx={{ mt: 1, mb: 2 }}>
171
- <Typography variant="subtitle1" gutterBottom>
172
- {attribute.label || 'Settings Editor'}
173
- </Typography>
174
-
175
- <TableContainer component={Paper} sx={{ mb: 2 }}>
176
- <Table size="small">
177
- <TableHead>
178
- <TableRow>
179
- <TableCell width="40%">Key</TableCell>
180
- <TableCell width="50%">Value</TableCell>
181
- <TableCell width="10%" align="center">Actions</TableCell>
182
- </TableRow>
183
- </TableHead>
184
- <TableBody>
185
- {pairs.map((pair) => (
186
- <TableRow key={pair.id}>
187
- <TableCell>
188
- <TextField
189
- fullWidth
190
- size="small"
191
- value={pair.key}
192
- onChange={(e) => handleKeyChange(pair.id, e.target.value)}
193
- error={!!keyError[pair.id]}
194
- helperText={keyError[pair.id]}
195
- />
196
- </TableCell>
197
- <TableCell>
198
- <TextField
199
- fullWidth
200
- size="small"
201
- value={pair.value}
202
- onChange={(e) => handleValueChange(pair.id, e.target.value)}
203
- />
204
- </TableCell>
205
- <TableCell align="center">
206
- <IconButton
207
- size="small"
208
- onClick={() => removePair(pair.id)}
209
- color="error"
210
- >
211
- <DeleteIcon fontSize="small" />
212
- </IconButton>
213
- </TableCell>
214
- </TableRow>
215
- ))}
216
- </TableBody>
217
- </Table>
218
- </TableContainer>
219
-
220
- <Button
221
- startIcon={<AddIcon />}
222
- variant="outlined"
223
- size="small"
224
- onClick={addPair}
225
- >
226
- +
227
- </Button>
228
-
229
-
230
- </Box>
231
- );
232
- };
233
-
234
- export const JsonView: React.FC<IDashAutoAdminCustomFieldComponent> = (props) => {
235
- const { attribute } = props;
236
- const record = useRecordContext();
237
-
238
- // Extract the nested path from the attribute
239
- const attributePath = attribute.attribute;
240
- const isNestedSetting = attributePath.startsWith('settings.');
241
- const settingsPath = isNestedSetting ? attributePath.split('.').slice(1).join('.') : attributePath;
242
-
243
- // Get the value to display
244
- let displayValue: Record<string, any> = {};
245
-
246
- if (isNestedSetting && record?.settings) {
247
- // For nested settings
248
- const settings = record.settings || {};
249
- if (settingsPath) {
250
- const keys = settingsPath.split('.');
251
- displayValue = keys.reduce((o, key) => (o && o[key] !== undefined ? o[key] : {}), settings);
252
- } else {
253
- displayValue = settings;
254
- }
255
- } else if (record?.[attributePath]) {
256
- // For direct attributes
257
- displayValue = record[attributePath];
258
- }
259
-
260
- return (
261
- <Box sx={{ mt: 1, mb: 2 }}>
262
- <Typography variant="subtitle1" gutterBottom>
263
- {attribute.label || 'Settings'}
264
- </Typography>
265
-
266
- {Object.keys(displayValue).length > 0 ? (
267
- <TableContainer component={Paper}>
268
- <Table size="small">
269
- <TableHead>
270
- <TableRow>
271
- <TableCell width="40%">Key</TableCell>
272
- <TableCell width="60%">Value</TableCell>
273
- </TableRow>
274
- </TableHead>
275
- <TableBody>
276
- {Object.entries(displayValue).map(([key, value]) => (
277
- <TableRow key={key}>
278
- <TableCell>{key}</TableCell>
279
- <TableCell>
280
- {typeof value === 'object'
281
- ? JSON.stringify(value)
282
- : String(value)
283
- }
284
- </TableCell>
285
- </TableRow>
286
- ))}
287
- </TableBody>
288
- </Table>
289
- </TableContainer>
290
- ) : (
291
- <Typography variant="body2" color="textSecondary">
292
- No settings configured
293
- </Typography>
294
- )}
295
- </Box>
296
- );
297
- };
298
-
299
- const Json = ({ method, attribute, resourceConfig }: IDashAutoAdminCustomFieldComponent) => {
300
- switch (method) {
301
- case 'edit':
302
- return <JsonEdit attribute={attribute} method={method} resourceConfig={resourceConfig} />;
303
- case 'create':
304
- return <JsonEdit attribute={attribute} method={method} resourceConfig={resourceConfig} />;
305
- case 'view':
306
- return <JsonView attribute={attribute} method={method} resourceConfig={resourceConfig} />;
307
- default:
308
- return null;
309
- }
310
- };
311
-
312
- export default Json;