@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,345 @@
1
- import{Fragment as K,jsx as e,jsxs as t}from"react/jsx-runtime";import{useState as v,useMemo as T,useCallback as w}from"react";import{useRecordContext as P,useGetList as R,Loading as _}from"react-admin";import{Box as c,Typography as a,Paper as l,Button as k,Dialog as N,DialogTitle as B,DialogContent as G,DialogActions as I,IconButton as x,Chip as M,Tooltip as z}from"@mui/material";import{DataGrid as F,GridToolbarContainer as E,GridToolbarExport as O}from"@mui/x-data-grid";import J from"@mui/icons-material/Visibility";import W from"@mui/icons-material/Close";import u from"@mui/icons-material/History";const V=()=>e(E,{children:e(O,{csvOptions:{fileName:"audit-logs-export",delimiter:",",utf8WithBom:!0},printOptions:{hideFooter:!0,hideToolbar:!0}})}),H=({open:r,log:o,onClose:n})=>{if(!o)return null;const i=d=>{try{return JSON.stringify(d,null,2)}catch{return String(d)}};return t(N,{open:r,onClose:n,maxWidth:"md",fullWidth:!0,"aria-labelledby":"audit-log-dialog-title",children:[e(B,{id:"audit-log-dialog-title",children:t(c,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[t(a,{variant:"h6",children:["Audit Log Details - ",o.event||o.description]}),e(x,{edge:"end",color:"inherit",onClick:n,"aria-label":"close",children:e(W,{})})]})}),t(G,{dividers:!0,children:[t(c,{mb:2,children:[e(a,{variant:"subtitle2",color:"textSecondary",children:"Event Information"}),t(l,{variant:"outlined",sx:{p:2,mt:1},children:[t(a,{variant:"body2",children:[e("strong",{children:"ID:"})," ",o.id]}),t(a,{variant:"body2",children:[e("strong",{children:"Event:"})," ",o.event||"N/A"]}),t(a,{variant:"body2",children:[e("strong",{children:"Description:"})," ",o.description]}),t(a,{variant:"body2",children:[e("strong",{children:"Log Name:"})," ",o.log_name]}),t(a,{variant:"body2",children:[e("strong",{children:"Created At:"})," ",new Date(o.created_at).toLocaleString()]}),o.causer_name&&t(a,{variant:"body2",children:[e("strong",{children:"Changed By:"})," ",o.causer_name]})]})]}),t(c,{children:[e(a,{variant:"subtitle2",color:"textSecondary",children:"Properties (JSON)"}),e(l,{variant:"outlined",sx:{p:2,mt:1,bgcolor:"grey.900",color:"grey.100",maxHeight:400,overflow:"auto"},children:e("pre",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i(o.properties)})})]})]}),e(I,{children:e(k,{onClick:n,color:"primary",children:"Close"})})]})},j=(r,o)=>{const n=(r||"").toLowerCase();let i="default";switch(n){case"created":i="success";break;case"updated":i="warning";break;case"deleted":i="error";break;case"restored":i="info";break;default:i="default"}return e(M,{label:r||"N/A",color:i,size:"small",variant:"outlined"})},p=({resourceConfig:r,resource:o})=>{const n=P(),[i,d]=v({page:0,pageSize:10}),[y,m]=v({open:!1,log:null}),C=`${o||r?.model||""}/audit`,{data:g,total:A,isLoading:h,error:f}=R(C,{pagination:{page:i.page+1,perPage:i.pageSize},sort:{field:"created_at",order:"DESC"},filter:{subject_id:n?.id}},{enabled:!!n?.id,refetchOnWindowFocus:!1}),b=w(s=>{m({open:!0,log:s})},[]),D=w(()=>{m({open:!1,log:null})},[]),L=T(()=>[{field:"id",headerName:"ID",type:"number",width:80},{field:"event",headerName:"Event",width:120,renderCell:s=>j(s.value)},{field:"description",headerName:"Description",flex:1,minWidth:200},{field:"causer_name",headerName:"Changed By",width:150,valueGetter:(s,S)=>S.causer_name||"System"},{field:"created_at",headerName:"Date",width:180,valueFormatter:s=>s?new Date(s).toLocaleString():""},{field:"actions",headerName:"Actions",type:"actions",width:100,getActions:s=>[e(z,{title:"View Details",children:e(x,{size:"small",onClick:()=>b(s.row),color:"primary",children:e(J,{fontSize:"small"})})},"view")]}],[b]);return n?.id?h?e(_,{}):f?e(l,{variant:"outlined",sx:{p:2},children:t(a,{color:"error",children:["Error loading audit logs: ",f?.message||"Unknown error"]})}):!g||g.length===0?t(l,{variant:"outlined",sx:{p:3,textAlign:"center"},children:[e(u,{sx:{fontSize:48,color:"text.secondary",mb:1}}),e(a,{variant:"body1",color:"text.secondary",children:"No audit logs available for this record"})]}):t(K,{children:[e(c,{sx:{width:"100%"},children:e(l,{variant:"outlined",children:e(F,{rows:g,columns:L,rowCount:A||0,loading:h,pageSizeOptions:[5,10,25,50],paginationModel:i,paginationMode:"server",onPaginationModelChange:d,disableRowSelectionOnClick:!0,autoHeight:!0,slots:{toolbar:V},sx:{"& .MuiDataGrid-cell:focus":{outline:"none"}}})})}),e(H,{open:y.open,log:y.log,onClose:D})]}):t(l,{variant:"outlined",sx:{p:3,textAlign:"center"},children:[e(u,{sx:{fontSize:48,color:"text.secondary",mb:1}}),e(a,{variant:"body1",color:"text.secondary",children:"Save the record first to view audit logs"})]})},U=r=>e(p,{...r}),$=()=>e(a,{variant:"body2",color:"text.secondary",children:"\u2014"}),q=r=>{const{method:o}=r;switch(o){case"view":case"show":return e(p,{...r});case"edit":return e(U,{...r});case"list":return e($,{...r});case"create":return t(l,{variant:"outlined",sx:{p:3,textAlign:"center"},children:[e(u,{sx:{fontSize:48,color:"text.secondary",mb:1}}),e(a,{variant:"body1",color:"text.secondary",children:"Audit logs will be available after the record is created"})]});default:return e(p,{...r})}};var le=q;export{le as default};
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
18
+ import { useState, useMemo, useCallback } from "react";
19
+ import { useRecordContext, useGetList, Loading } from "react-admin";
20
+ import {
21
+ Box,
22
+ Typography,
23
+ Paper,
24
+ Button,
25
+ Dialog,
26
+ DialogTitle,
27
+ DialogContent,
28
+ DialogActions,
29
+ IconButton,
30
+ Chip,
31
+ Tooltip
32
+ } from "@mui/material";
33
+ import {
34
+ DataGrid as MUIGrid,
35
+ GridToolbarContainer,
36
+ GridToolbarExport
37
+ } from "@mui/x-data-grid";
38
+ import VisibilityIcon from "@mui/icons-material/Visibility";
39
+ import CloseIcon from "@mui/icons-material/Close";
40
+ import HistoryIcon from "@mui/icons-material/History";
41
+ const AuditToolbar = () => {
42
+ return /* @__PURE__ */ jsx(GridToolbarContainer, { children: /* @__PURE__ */ jsx(
43
+ GridToolbarExport,
44
+ {
45
+ csvOptions: {
46
+ fileName: "audit-logs-export",
47
+ delimiter: ",",
48
+ utf8WithBom: true
49
+ },
50
+ printOptions: {
51
+ hideFooter: true,
52
+ hideToolbar: true
53
+ }
54
+ }
55
+ ) });
56
+ };
57
+ const AuditJsonDialog = ({ open, log, onClose }) => {
58
+ if (!log) return null;
59
+ const formatJson = (obj) => {
60
+ try {
61
+ return JSON.stringify(obj, null, 2);
62
+ } catch (e) {
63
+ return String(obj);
64
+ }
65
+ };
66
+ return /* @__PURE__ */ jsxs(
67
+ Dialog,
68
+ {
69
+ open,
70
+ onClose,
71
+ maxWidth: "md",
72
+ fullWidth: true,
73
+ "aria-labelledby": "audit-log-dialog-title",
74
+ children: [
75
+ /* @__PURE__ */ jsx(DialogTitle, { id: "audit-log-dialog-title", children: /* @__PURE__ */ jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "center", children: [
76
+ /* @__PURE__ */ jsxs(Typography, { variant: "h6", children: [
77
+ "Audit Log Details - ",
78
+ log.event || log.description
79
+ ] }),
80
+ /* @__PURE__ */ jsx(
81
+ IconButton,
82
+ {
83
+ edge: "end",
84
+ color: "inherit",
85
+ onClick: onClose,
86
+ "aria-label": "close",
87
+ children: /* @__PURE__ */ jsx(CloseIcon, {})
88
+ }
89
+ )
90
+ ] }) }),
91
+ /* @__PURE__ */ jsxs(DialogContent, { dividers: true, children: [
92
+ /* @__PURE__ */ jsxs(Box, { mb: 2, children: [
93
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", color: "textSecondary", children: "Event Information" }),
94
+ /* @__PURE__ */ jsxs(Paper, { variant: "outlined", sx: { p: 2, mt: 1 }, children: [
95
+ /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
96
+ /* @__PURE__ */ jsx("strong", { children: "ID:" }),
97
+ " ",
98
+ log.id
99
+ ] }),
100
+ /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
101
+ /* @__PURE__ */ jsx("strong", { children: "Event:" }),
102
+ " ",
103
+ log.event || "N/A"
104
+ ] }),
105
+ /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
106
+ /* @__PURE__ */ jsx("strong", { children: "Description:" }),
107
+ " ",
108
+ log.description
109
+ ] }),
110
+ /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
111
+ /* @__PURE__ */ jsx("strong", { children: "Log Name:" }),
112
+ " ",
113
+ log.log_name
114
+ ] }),
115
+ /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
116
+ /* @__PURE__ */ jsx("strong", { children: "Created At:" }),
117
+ " ",
118
+ new Date(log.created_at).toLocaleString()
119
+ ] }),
120
+ log.causer_name && /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
121
+ /* @__PURE__ */ jsx("strong", { children: "Changed By:" }),
122
+ " ",
123
+ log.causer_name
124
+ ] })
125
+ ] })
126
+ ] }),
127
+ /* @__PURE__ */ jsxs(Box, { children: [
128
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", color: "textSecondary", children: "Properties (JSON)" }),
129
+ /* @__PURE__ */ jsx(
130
+ Paper,
131
+ {
132
+ variant: "outlined",
133
+ sx: {
134
+ p: 2,
135
+ mt: 1,
136
+ bgcolor: "grey.900",
137
+ color: "grey.100",
138
+ maxHeight: 400,
139
+ overflow: "auto"
140
+ },
141
+ children: /* @__PURE__ */ jsx("pre", { style: { margin: 0, whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: formatJson(log.properties) })
142
+ }
143
+ )
144
+ ] })
145
+ ] }),
146
+ /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsx(Button, { onClick: onClose, color: "primary", children: "Close" }) })
147
+ ]
148
+ }
149
+ );
150
+ };
151
+ const getEventChip = (event, logName) => {
152
+ const eventLower = (event || "").toLowerCase();
153
+ let color = "default";
154
+ switch (eventLower) {
155
+ case "created":
156
+ color = "success";
157
+ break;
158
+ case "updated":
159
+ color = "warning";
160
+ break;
161
+ case "deleted":
162
+ color = "error";
163
+ break;
164
+ case "restored":
165
+ color = "info";
166
+ break;
167
+ default:
168
+ color = "default";
169
+ }
170
+ return /* @__PURE__ */ jsx(
171
+ Chip,
172
+ {
173
+ label: event || "N/A",
174
+ color,
175
+ size: "small",
176
+ variant: "outlined"
177
+ }
178
+ );
179
+ };
180
+ const AuditLogView = ({ resourceConfig, resource: resourceOverride }) => {
181
+ const record = useRecordContext();
182
+ const [paginationModel, setPaginationModel] = useState({
183
+ page: 0,
184
+ pageSize: 10
185
+ });
186
+ const [dialogState, setDialogState] = useState({
187
+ open: false,
188
+ log: null
189
+ });
190
+ const baseResource = resourceOverride || (resourceConfig == null ? void 0 : resourceConfig.model) || "";
191
+ const auditResource = `${baseResource}/audit`;
192
+ const { data, total, isLoading, error } = useGetList(
193
+ auditResource,
194
+ {
195
+ pagination: {
196
+ page: paginationModel.page + 1,
197
+ perPage: paginationModel.pageSize
198
+ },
199
+ sort: { field: "created_at", order: "DESC" },
200
+ filter: { subject_id: record == null ? void 0 : record.id }
201
+ },
202
+ { enabled: !!(record == null ? void 0 : record.id), refetchOnWindowFocus: false }
203
+ );
204
+ const handleViewLog = useCallback((log) => {
205
+ setDialogState({ open: true, log });
206
+ }, []);
207
+ const handleCloseDialog = useCallback(() => {
208
+ setDialogState({ open: false, log: null });
209
+ }, []);
210
+ const columns = useMemo(
211
+ () => [
212
+ {
213
+ field: "id",
214
+ headerName: "ID",
215
+ type: "number",
216
+ width: 80
217
+ },
218
+ {
219
+ field: "event",
220
+ headerName: "Event",
221
+ width: 120,
222
+ renderCell: (params) => getEventChip(params.value)
223
+ },
224
+ {
225
+ field: "description",
226
+ headerName: "Description",
227
+ flex: 1,
228
+ minWidth: 200
229
+ },
230
+ {
231
+ field: "causer_name",
232
+ headerName: "Changed By",
233
+ width: 150,
234
+ valueGetter: (value, row) => row.causer_name || "System"
235
+ },
236
+ {
237
+ field: "created_at",
238
+ headerName: "Date",
239
+ width: 180,
240
+ valueFormatter: (value) => value ? new Date(value).toLocaleString() : ""
241
+ },
242
+ {
243
+ field: "actions",
244
+ headerName: "Actions",
245
+ type: "actions",
246
+ width: 100,
247
+ getActions: (params) => [
248
+ /* @__PURE__ */ jsx(Tooltip, { title: "View Details", children: /* @__PURE__ */ jsx(
249
+ IconButton,
250
+ {
251
+ size: "small",
252
+ onClick: () => handleViewLog(params.row),
253
+ color: "primary",
254
+ children: /* @__PURE__ */ jsx(VisibilityIcon, { fontSize: "small" })
255
+ }
256
+ ) }, "view")
257
+ ]
258
+ }
259
+ ],
260
+ [handleViewLog]
261
+ );
262
+ if (!(record == null ? void 0 : record.id)) {
263
+ return /* @__PURE__ */ jsxs(Paper, { variant: "outlined", sx: { p: 3, textAlign: "center" }, children: [
264
+ /* @__PURE__ */ jsx(HistoryIcon, { sx: { fontSize: 48, color: "text.secondary", mb: 1 } }),
265
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", color: "text.secondary", children: "Save the record first to view audit logs" })
266
+ ] });
267
+ }
268
+ if (isLoading) {
269
+ return /* @__PURE__ */ jsx(Loading, {});
270
+ }
271
+ if (error) {
272
+ return /* @__PURE__ */ jsx(Paper, { variant: "outlined", sx: { p: 2 }, children: /* @__PURE__ */ jsxs(Typography, { color: "error", children: [
273
+ "Error loading audit logs: ",
274
+ (error == null ? void 0 : error.message) || "Unknown error"
275
+ ] }) });
276
+ }
277
+ if (!data || data.length === 0) {
278
+ return /* @__PURE__ */ jsxs(Paper, { variant: "outlined", sx: { p: 3, textAlign: "center" }, children: [
279
+ /* @__PURE__ */ jsx(HistoryIcon, { sx: { fontSize: 48, color: "text.secondary", mb: 1 } }),
280
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", color: "text.secondary", children: "No audit logs available for this record" })
281
+ ] });
282
+ }
283
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
284
+ /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsx(Paper, { variant: "outlined", children: /* @__PURE__ */ jsx(
285
+ MUIGrid,
286
+ {
287
+ rows: data,
288
+ columns,
289
+ rowCount: total || 0,
290
+ loading: isLoading,
291
+ pageSizeOptions: [5, 10, 25, 50],
292
+ paginationModel,
293
+ paginationMode: "server",
294
+ onPaginationModelChange: setPaginationModel,
295
+ disableRowSelectionOnClick: true,
296
+ autoHeight: true,
297
+ slots: {
298
+ toolbar: AuditToolbar
299
+ },
300
+ sx: {
301
+ "& .MuiDataGrid-cell:focus": {
302
+ outline: "none"
303
+ }
304
+ }
305
+ }
306
+ ) }) }),
307
+ /* @__PURE__ */ jsx(
308
+ AuditJsonDialog,
309
+ {
310
+ open: dialogState.open,
311
+ log: dialogState.log,
312
+ onClose: handleCloseDialog
313
+ }
314
+ )
315
+ ] });
316
+ };
317
+ const AuditLogEdit = (props) => {
318
+ return /* @__PURE__ */ jsx(AuditLogView, __spreadValues({}, props));
319
+ };
320
+ const AuditLogList = () => {
321
+ return /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: "\u2014" });
322
+ };
323
+ const AuditLog = (props) => {
324
+ const { method } = props;
325
+ switch (method) {
326
+ case "view":
327
+ case "show":
328
+ return /* @__PURE__ */ jsx(AuditLogView, __spreadValues({}, props));
329
+ case "edit":
330
+ return /* @__PURE__ */ jsx(AuditLogEdit, __spreadValues({}, props));
331
+ case "list":
332
+ return /* @__PURE__ */ jsx(AuditLogList, __spreadValues({}, props));
333
+ case "create":
334
+ return /* @__PURE__ */ jsxs(Paper, { variant: "outlined", sx: { p: 3, textAlign: "center" }, children: [
335
+ /* @__PURE__ */ jsx(HistoryIcon, { sx: { fontSize: 48, color: "text.secondary", mb: 1 } }),
336
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", color: "text.secondary", children: "Audit logs will be available after the record is created" })
337
+ ] });
338
+ default:
339
+ return /* @__PURE__ */ jsx(AuditLogView, __spreadValues({}, props));
340
+ }
341
+ };
342
+ var AuditLog_default = AuditLog;
343
+ export {
344
+ AuditLog_default as default
345
+ };
@@ -1 +1,4 @@
1
- import{default as r}from"./AuditLog";export{r as AuditLog};
1
+ import { default as default2 } from "./AuditLog";
2
+ export {
3
+ default2 as AuditLog
4
+ };