@dashadmin/dash-components 1.3.72 → 1.3.74-srcfree.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/package.json +24 -21
  2. package/src/components/AuditLog/AuditLog.tsx +0 -490
  3. package/src/components/AuditLog/index.ts +0 -2
  4. package/src/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.tsx +0 -917
  5. package/src/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.tsx +0 -39
  6. package/src/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.tsx +0 -916
  7. package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +0 -42
  8. package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.tsx +0 -44
  9. package/src/components/Json/Json.tsx +0 -312
  10. package/src/components/JsonColorSelector/JsonColorSelector.tsx +0 -1443
  11. package/src/components/JsonColorSelector/JsonColorSelector.tsx.bkup +0 -746
  12. package/src/components/JsonColorSelector/JsonColorSelectorEnhanced.tsx +0 -1135
  13. package/src/components/JsonColorSelector/JsonCssVarValues.tsx +0 -867
  14. package/src/components/JsonColorSelector/components/BasicColorSelector.tsx +0 -333
  15. package/src/components/JsonColorSelector/components/ColorEditDialog.tsx +0 -495
  16. package/src/components/JsonColorSelector/components/ColorPaletteItem.tsx +0 -80
  17. package/src/components/JsonColorSelector/components/ImageColorExtractor.tsx +0 -420
  18. package/src/components/JsonColorSelector/helpers/functions.tsx +0 -123
  19. package/src/components/JsonColorSelector/helpers/paletteDerivation.ts +0 -367
  20. package/src/components/JsonColorSelector/interfaces/interfaces.tsx +0 -22
  21. package/src/components/JsonColorSelector/useAsyncColorThief.tsx +0 -97
  22. package/src/components/ListActive/ListActive.tsx +0 -106
  23. package/src/components/ListActive/ListBoolean.tsx +0 -96
  24. package/src/components/NotificationPreferences/NotificationPreferences.tsx +0 -480
  25. package/src/components/NotificationPreferences/index.tsx +0 -2
  26. package/src/components/SearchableSelects/RASearchableSelect.tsx +0 -303
  27. package/src/components/SearchableSelects/RASearchableSelectCheckboxes.tsx +0 -617
  28. package/src/components/SearchableSelects/RASearchableSelectChips.tsx +0 -561
  29. package/src/components/SearchableSelects/RASearchableSelectChipsRecordContext.tsx +0 -366
  30. package/src/components/SearchableSelects/SearchableSelect.tsx +0 -323
  31. package/src/components/SearchableSelects/SearchableSelectCheckboxes.tsx +0 -358
  32. package/src/components/SortableDataGrid/README.md +0 -1
  33. package/src/components/SortableDataGrid/SortableDataGrid.tsx +0 -56
  34. package/src/components/SortableDataGrid/SortableDataGridBody.tsx +0 -175
  35. package/src/components/SortableDataGrid/SortableDataGridHeader.tsx +0 -171
  36. package/src/components/SortableDataGrid/SortableDataGridRow.tsx +0 -247
  37. package/src/components/Upload/SingleImageUploader.tsx +0 -55
  38. package/src/components/custom/PackageCopyMethod.tsx +0 -109
  39. package/src/components/custom/PackageRadioButtonGroup.tsx +0 -49
  40. package/src/components/dialog/Basic.tsx +0 -11
  41. package/src/components/dialog/Correct.tsx +0 -16
  42. package/src/components/dialog/Error.tsx +0 -15
  43. package/src/components/dialog/Info.tsx +0 -15
  44. package/src/components/dialog/InfoV2.tsx +0 -35
  45. package/src/components/dialog/NotFound.tsx +0 -18
  46. package/src/components/dialog/QuickSearch.tsx +0 -115
  47. package/src/components/notifications/NotificationsCenter.tsx +0 -743
  48. package/src/components/notifications/index.ts +0 -42
  49. package/src/components/tables/PaginationComponent.tsx +0 -17
  50. package/src/components/theme/AppLoadingFallback.tsx +0 -42
  51. package/src/components/theme/ErrorBoundary.tsx +0 -57
  52. package/src/components/theme/InitialLoader.tsx +0 -16
  53. package/src/components/theme/NotFound.tsx +0 -124
  54. package/src/components/theme/NotResults.tsx +0 -56
  55. package/src/hooks/useDraggable.ts +0 -11
  56. package/src/hooks/useNotifications.ts +0 -14
  57. package/src/hooks/useQuickSearch.tsx +0 -29
  58. package/src/index.tsx +0 -77
  59. package/src/styles/index.less +0 -0
  60. package/src/utils/setNativeValue.tsx +0 -23
@@ -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;