@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,490 +0,0 @@
1
- import React, { useState, useMemo, useCallback } from "react";
2
- import { useRecordContext, useGetList, Loading } from "react-admin";
3
- import {
4
- Box,
5
- Typography,
6
- Paper,
7
- Button,
8
- Dialog,
9
- DialogTitle,
10
- DialogContent,
11
- DialogActions,
12
- IconButton,
13
- Chip,
14
- Tooltip,
15
- } from "@mui/material";
16
- import {
17
- DataGrid as MUIGrid,
18
- GridColDef,
19
- GridRowParams,
20
- GridPaginationModel,
21
- GridToolbarContainer,
22
- GridToolbarExport,
23
- } from "@mui/x-data-grid";
24
- import VisibilityIcon from "@mui/icons-material/Visibility";
25
- import CloseIcon from "@mui/icons-material/Close";
26
- import HistoryIcon from "@mui/icons-material/History";
27
-
28
- /**
29
- * AuditLog Component (Generic)
30
- *
31
- * A reusable component that displays audit logs (activity logs) for any model.
32
- * Uses Spatie Activity Log data from the backend.
33
- *
34
- * Features:
35
- * - Paginated DataGrid with sorting
36
- * - Export functionality (CSV, Print)
37
- * - JSON detail dialog for viewing full log properties
38
- * - Works with any model that has audit logging enabled
39
- *
40
- * @example
41
- * // In your schema file:
42
- * import { AuditLog } from 'dash-components';
43
- *
44
- * const myModelSchema = [
45
- * // ... other fields
46
- * {
47
- * tab: 'Audit',
48
- * attribute: 'audit_logs',
49
- * label: 'Audit Logs',
50
- * type: Array,
51
- * inList: false,
52
- * inEdit: true,
53
- * inShow: true,
54
- * inCreate: false,
55
- * readOnly: true,
56
- * custom: true,
57
- * component: AuditLog,
58
- * },
59
- * ];
60
- */
61
-
62
- /**
63
- * Props interface for the AuditLog component
64
- * Compatible with dash-auto-admin custom field components
65
- */
66
- export interface AuditLogProps {
67
- /** The resource configuration from dash-auto-admin */
68
- resourceConfig?: {
69
- model?: string;
70
- [key: string]: any;
71
- };
72
- /** The current mode: 'create', 'edit', 'view', 'list' */
73
- method?: 'create' | 'edit' | 'view' | 'list' | 'show';
74
- /** Optional custom resource path override */
75
- resource?: string;
76
- /** Any additional props */
77
- [key: string]: any;
78
- }
79
-
80
- /**
81
- * Activity log record interface from Spatie Activity Log
82
- */
83
- export interface ActivityLogRecord {
84
- id: number;
85
- log_name: string;
86
- description: string;
87
- subject_type: string | null;
88
- subject_id: number | null;
89
- causer_type: string | null;
90
- causer_id: number | null;
91
- causer_name?: string;
92
- properties: Record<string, any>;
93
- event: string | null;
94
- batch_uuid: string | null;
95
- created_at: string;
96
- updated_at: string;
97
- }
98
-
99
- interface DialogState {
100
- open: boolean;
101
- log: ActivityLogRecord | null;
102
- }
103
-
104
- /**
105
- * Custom toolbar with export functionality
106
- */
107
- const AuditToolbar: React.FC = () => {
108
- return (
109
- <GridToolbarContainer>
110
- <GridToolbarExport
111
- csvOptions={{
112
- fileName: 'audit-logs-export',
113
- delimiter: ',',
114
- utf8WithBom: true,
115
- }}
116
- printOptions={{
117
- hideFooter: true,
118
- hideToolbar: true,
119
- }}
120
- />
121
- </GridToolbarContainer>
122
- );
123
- };
124
-
125
- /**
126
- * JSON Viewer Dialog for audit log details
127
- */
128
- interface JsonDialogProps {
129
- open: boolean;
130
- log: ActivityLogRecord | null;
131
- onClose: () => void;
132
- }
133
-
134
- const AuditJsonDialog: React.FC<JsonDialogProps> = ({ open, log, onClose }) => {
135
- if (!log) return null;
136
-
137
- const formatJson = (obj: any): string => {
138
- try {
139
- return JSON.stringify(obj, null, 2);
140
- } catch {
141
- return String(obj);
142
- }
143
- };
144
-
145
- return (
146
- <Dialog
147
- open={open}
148
- onClose={onClose}
149
- maxWidth="md"
150
- fullWidth
151
- aria-labelledby="audit-log-dialog-title"
152
- >
153
- <DialogTitle id="audit-log-dialog-title">
154
- <Box
155
- sx={{
156
- display: "flex",
157
- justifyContent: "space-between",
158
- alignItems: "center"
159
- }}>
160
- <Typography variant="h6">
161
- Audit Log Details - {log.event || log.description}
162
- </Typography>
163
- <IconButton
164
- edge="end"
165
- color="inherit"
166
- onClick={onClose}
167
- aria-label="close"
168
- >
169
- <CloseIcon />
170
- </IconButton>
171
- </Box>
172
- </DialogTitle>
173
- <DialogContent dividers>
174
- <Box sx={{
175
- mb: 2
176
- }}>
177
- <Typography variant="subtitle2" color="textSecondary">
178
- Event Information
179
- </Typography>
180
- <Paper variant="outlined" sx={{ p: 2, mt: 1 }}>
181
- <Typography variant="body2">
182
- <strong>ID:</strong> {log.id}
183
- </Typography>
184
- <Typography variant="body2">
185
- <strong>Event:</strong> {log.event || 'N/A'}
186
- </Typography>
187
- <Typography variant="body2">
188
- <strong>Description:</strong> {log.description}
189
- </Typography>
190
- <Typography variant="body2">
191
- <strong>Log Name:</strong> {log.log_name}
192
- </Typography>
193
- <Typography variant="body2">
194
- <strong>Created At:</strong> {new Date(log.created_at).toLocaleString()}
195
- </Typography>
196
- {log.causer_name && (
197
- <Typography variant="body2">
198
- <strong>Changed By:</strong> {log.causer_name}
199
- </Typography>
200
- )}
201
- </Paper>
202
- </Box>
203
-
204
- <Box>
205
- <Typography variant="subtitle2" color="textSecondary">
206
- Properties (JSON)
207
- </Typography>
208
- <Paper
209
- variant="outlined"
210
- sx={{
211
- p: 2,
212
- mt: 1,
213
- bgcolor: 'grey.900',
214
- color: 'grey.100',
215
- maxHeight: 400,
216
- overflow: 'auto',
217
- }}
218
- >
219
- <pre style={{ margin: 0, whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}>
220
- {formatJson(log.properties)}
221
- </pre>
222
- </Paper>
223
- </Box>
224
- </DialogContent>
225
- <DialogActions>
226
- <Button onClick={onClose} color="primary">
227
- Close
228
- </Button>
229
- </DialogActions>
230
- </Dialog>
231
- );
232
- };
233
-
234
- /**
235
- * Get event color chip based on event type
236
- */
237
- const getEventChip = (event: string | null, logName?: string): React.ReactNode => {
238
- const eventLower = (event || '').toLowerCase();
239
- let color: 'success' | 'warning' | 'error' | 'info' | 'default' = 'default';
240
-
241
- switch (eventLower) {
242
- case 'created':
243
- color = 'success';
244
- break;
245
- case 'updated':
246
- color = 'warning';
247
- break;
248
- case 'deleted':
249
- color = 'error';
250
- break;
251
- case 'restored':
252
- color = 'info';
253
- break;
254
- default:
255
- color = 'default';
256
- }
257
-
258
- return (
259
- <Chip
260
- label={event || 'N/A'}
261
- color={color}
262
- size="small"
263
- variant="outlined"
264
- />
265
- );
266
- };
267
-
268
- /**
269
- * View mode - Display audit logs as a DataGrid
270
- */
271
- const AuditLogView: React.FC<AuditLogProps> = ({ resourceConfig, resource: resourceOverride }) => {
272
- const record = useRecordContext();
273
- const [paginationModel, setPaginationModel] = useState<GridPaginationModel>({
274
- page: 0,
275
- pageSize: 10,
276
- });
277
- const [dialogState, setDialogState] = useState<DialogState>({
278
- open: false,
279
- log: null,
280
- });
281
-
282
- // Build the audit endpoint URL - uses resource override, resourceConfig model, or default
283
- const baseResource = resourceOverride || resourceConfig?.model || '';
284
- const auditResource = `${baseResource}/audit`;
285
-
286
- const { data, total, isLoading, error } = useGetList<ActivityLogRecord>(
287
- auditResource,
288
- {
289
- pagination: {
290
- page: paginationModel.page + 1,
291
- perPage: paginationModel.pageSize,
292
- },
293
- sort: { field: 'created_at', order: 'DESC' },
294
- filter: { subject_id: record?.id },
295
- },
296
- { enabled: !!record?.id, refetchOnWindowFocus: false }
297
- );
298
-
299
- const handleViewLog = useCallback((log: ActivityLogRecord) => {
300
- setDialogState({ open: true, log });
301
- }, []);
302
-
303
- const handleCloseDialog = useCallback(() => {
304
- setDialogState({ open: false, log: null });
305
- }, []);
306
-
307
- const columns: GridColDef[] = useMemo(
308
- () => [
309
- {
310
- field: 'id',
311
- headerName: 'ID',
312
- type: 'number',
313
- width: 80,
314
- },
315
- {
316
- field: 'event',
317
- headerName: 'Event',
318
- width: 120,
319
- renderCell: (params) => getEventChip(params.value),
320
- },
321
- {
322
- field: 'description',
323
- headerName: 'Description',
324
- flex: 1,
325
- minWidth: 200,
326
- },
327
- {
328
- field: 'causer_name',
329
- headerName: 'Changed By',
330
- width: 150,
331
- valueGetter: (value, row) => row.causer_name || 'System',
332
- },
333
- {
334
- field: 'created_at',
335
- headerName: 'Date',
336
- width: 180,
337
- valueFormatter: (value) =>
338
- value ? new Date(value).toLocaleString() : '',
339
- },
340
- {
341
- field: 'actions',
342
- headerName: 'Actions',
343
- type: 'actions',
344
- width: 100,
345
- getActions: (params: GridRowParams<ActivityLogRecord>) => [
346
- <Tooltip title="View Details" key="view">
347
- <IconButton
348
- size="small"
349
- onClick={() => handleViewLog(params.row)}
350
- color="primary"
351
- >
352
- <VisibilityIcon fontSize="small" />
353
- </IconButton>
354
- </Tooltip>,
355
- ],
356
- },
357
- ],
358
- [handleViewLog]
359
- );
360
-
361
- if (!record?.id) {
362
- return (
363
- <Paper variant="outlined" sx={{ p: 3, textAlign: 'center' }}>
364
- <HistoryIcon sx={{ fontSize: 48, color: 'text.secondary', mb: 1 }} />
365
- <Typography variant="body1" sx={{
366
- color: "text.secondary"
367
- }}>
368
- Save the record first to view audit logs
369
- </Typography>
370
- </Paper>
371
- );
372
- }
373
-
374
- if (isLoading) {
375
- return <Loading />;
376
- }
377
-
378
- if (error) {
379
- return (
380
- <Paper variant="outlined" sx={{ p: 2 }}>
381
- <Typography color="error">
382
- Error loading audit logs: {(error as any)?.message || 'Unknown error'}
383
- </Typography>
384
- </Paper>
385
- );
386
- }
387
-
388
- if (!data || data.length === 0) {
389
- return (
390
- <Paper variant="outlined" sx={{ p: 3, textAlign: 'center' }}>
391
- <HistoryIcon sx={{ fontSize: 48, color: 'text.secondary', mb: 1 }} />
392
- <Typography variant="body1" sx={{
393
- color: "text.secondary"
394
- }}>
395
- No audit logs available for this record
396
- </Typography>
397
- </Paper>
398
- );
399
- }
400
-
401
- return (
402
- <>
403
- <Box sx={{ width: '100%' }}>
404
- <Paper variant="outlined">
405
- <MUIGrid
406
- rows={data}
407
- columns={columns}
408
- rowCount={total || 0}
409
- loading={isLoading}
410
- pageSizeOptions={[5, 10, 25, 50]}
411
- paginationModel={paginationModel}
412
- paginationMode="server"
413
- onPaginationModelChange={setPaginationModel}
414
- disableRowSelectionOnClick
415
- autoHeight
416
- slots={{
417
- toolbar: AuditToolbar,
418
- }}
419
- sx={{
420
- '& .MuiDataGrid-cell:focus': {
421
- outline: 'none',
422
- },
423
- }}
424
- />
425
- </Paper>
426
- </Box>
427
-
428
- <AuditJsonDialog
429
- open={dialogState.open}
430
- log={dialogState.log}
431
- onClose={handleCloseDialog}
432
- />
433
- </>
434
- );
435
- };
436
-
437
- /**
438
- * Edit mode - Same as view mode for audit logs (read-only)
439
- */
440
- const AuditLogEdit: React.FC<AuditLogProps> = (props) => {
441
- return <AuditLogView {...props} />;
442
- };
443
-
444
- /**
445
- * List mode - Display placeholder (audit logs viewed in detail)
446
- */
447
- const AuditLogList: React.FC<AuditLogProps> = () => {
448
- return (
449
- <Typography variant="body2" sx={{
450
- color: "text.secondary"
451
- }}>—
452
- </Typography>
453
- );
454
- };
455
-
456
- /**
457
- * Main Component - Routes to appropriate view based on method
458
- *
459
- * @param props - Component props including resourceConfig and method
460
- * @returns The appropriate audit log view component
461
- */
462
- const AuditLog: React.FC<AuditLogProps> = (props) => {
463
- const { method } = props;
464
-
465
- switch (method) {
466
- case 'view':
467
- case 'show':
468
- return <AuditLogView {...props} />;
469
- case 'edit':
470
- return <AuditLogEdit {...props} />;
471
- case 'list':
472
- return <AuditLogList {...props} />;
473
- case 'create':
474
- // No audit logs for new records
475
- return (
476
- <Paper variant="outlined" sx={{ p: 3, textAlign: 'center' }}>
477
- <HistoryIcon sx={{ fontSize: 48, color: 'text.secondary', mb: 1 }} />
478
- <Typography variant="body1" sx={{
479
- color: "text.secondary"
480
- }}>
481
- Audit logs will be available after the record is created
482
- </Typography>
483
- </Paper>
484
- );
485
- default:
486
- return <AuditLogView {...props} />;
487
- }
488
- };
489
-
490
- export default AuditLog;