@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.
- package/README.md +35 -0
- package/dist/components/AuditLog/AuditLog.js +345 -1
- package/dist/components/AuditLog/index.js +4 -1
- package/dist/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.js +630 -3
- package/dist/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.js +53 -1
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.js +647 -3
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.js +53 -1
- package/dist/components/Json/Json.js +235 -1
- package/dist/components/JsonColorSelector/JsonColorSelector.js +1172 -1
- package/dist/components/JsonColorSelector/JsonColorSelectorEnhanced.js +863 -2
- package/dist/components/JsonColorSelector/JsonCssVarValues.js +738 -1
- package/dist/components/JsonColorSelector/components/ColorEditDialog.js +426 -1
- package/dist/components/JsonColorSelector/components/ColorPaletteItem.js +75 -1
- package/dist/components/JsonColorSelector/components/ImageColorExtractor.js +283 -1
- package/dist/components/JsonColorSelector/helpers/functions.js +101 -1
- package/dist/components/JsonColorSelector/useAsyncColorThief.js +105 -1
- package/dist/components/ListActive/ListActive.js +126 -1
- package/dist/components/ListActive/ListBoolean.js +124 -1
- package/dist/components/NotificationPreferences/NotificationPreferences.js +317 -1
- package/dist/components/NotificationPreferences/index.js +7 -1
- package/dist/components/SearchableSelects/RASearchableSelect.js +236 -1
- package/dist/components/SearchableSelects/RASearchableSelectCheckboxes.js +479 -1
- package/dist/components/SearchableSelects/RASearchableSelectChips.js +465 -1
- package/dist/components/SearchableSelects/RASearchableSelectChipsRecordContext.js +295 -1
- package/dist/components/SearchableSelects/SearchableSelect.js +202 -1
- package/dist/components/SearchableSelects/SearchableSelectCheckboxes.js +290 -1
- package/dist/components/SortableDataGrid/SortableDataGrid.js +72 -1
- package/dist/components/SortableDataGrid/SortableDataGridBody.js +167 -1
- package/dist/components/SortableDataGrid/SortableDataGridHeader.js +109 -1
- package/dist/components/SortableDataGrid/SortableDataGridRow.js +283 -1
- package/dist/components/Upload/SingleImageUploader.js +40 -1
- package/dist/components/custom/PackageCopyMethod.js +78 -1
- package/dist/components/custom/PackageRadioButtonGroup.js +45 -1
- package/dist/components/dialog/Basic.js +8 -1
- package/dist/components/dialog/Correct.js +14 -1
- package/dist/components/dialog/Error.js +14 -1
- package/dist/components/dialog/Info.js +14 -1
- package/dist/components/dialog/InfoV2.js +21 -1
- package/dist/components/dialog/NotFound.js +14 -1
- package/dist/components/dialog/QuickSearch.js +117 -1
- package/dist/components/notifications/NotificationsCenter.js +597 -1
- package/dist/components/notifications/index.js +24 -1
- package/dist/components/tables/PaginationComponent.js +36 -1
- package/dist/components/theme/AppLoadingFallback.js +38 -2
- package/dist/components/theme/ErrorBoundary.js +52 -1
- package/dist/components/theme/InitialLoader.js +13 -1
- package/dist/components/theme/NotFound.js +136 -1
- package/dist/components/theme/NotResults.js +38 -1
- package/dist/hooks/useDraggable.js +6 -1
- package/dist/hooks/useNotifications.js +8 -1
- package/dist/hooks/useQuickSearch.js +26 -1
- package/dist/index.js +66 -5567
- package/dist/utils/setNativeValue.js +17 -1
- package/package.json +148 -132
- package/src/components/AuditLog/AuditLog.tsx +476 -0
- package/src/components/AuditLog/index.ts +2 -0
- package/src/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.tsx +917 -0
- package/src/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.tsx +39 -0
- package/src/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.tsx +916 -0
- package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.tsx +44 -0
- package/src/components/Json/Json.tsx +312 -0
- package/src/components/JsonColorSelector/JsonColorSelector.tsx +1435 -0
- package/src/components/JsonColorSelector/JsonColorSelectorEnhanced.tsx +1029 -0
- package/src/components/JsonColorSelector/JsonCssVarValues.tsx +863 -0
- package/src/components/JsonColorSelector/components/ColorEditDialog.tsx +491 -0
- package/src/components/JsonColorSelector/components/ColorPaletteItem.tsx +80 -0
- package/src/components/JsonColorSelector/components/ImageColorExtractor.tsx +328 -0
- package/src/components/JsonColorSelector/helpers/functions.tsx +123 -0
- package/src/components/JsonColorSelector/interfaces/interfaces.tsx +22 -0
- package/src/components/JsonColorSelector/useAsyncColorThief.tsx +97 -0
- package/src/components/ListActive/ListActive.tsx +106 -0
- package/src/components/ListActive/ListBoolean.tsx +96 -0
- package/src/components/NotificationPreferences/NotificationPreferences.tsx +463 -0
- package/src/components/NotificationPreferences/index.tsx +2 -0
- package/src/components/SearchableSelects/RASearchableSelect.tsx +300 -0
- package/src/components/SearchableSelects/RASearchableSelectCheckboxes.tsx +604 -0
- package/src/components/SearchableSelects/RASearchableSelectChips.tsx +558 -0
- package/src/components/SearchableSelects/RASearchableSelectChipsRecordContext.tsx +362 -0
- package/src/components/SearchableSelects/SearchableSelect.tsx +321 -0
- package/src/components/SearchableSelects/SearchableSelectCheckboxes.tsx +355 -0
- package/src/components/SortableDataGrid/SortableDataGrid.tsx +56 -0
- package/src/components/SortableDataGrid/SortableDataGridBody.tsx +175 -0
- package/src/components/SortableDataGrid/SortableDataGridHeader.tsx +171 -0
- package/src/components/SortableDataGrid/SortableDataGridRow.tsx +247 -0
- package/src/components/Upload/SingleImageUploader.tsx +55 -0
- package/src/components/custom/PackageCopyMethod.tsx +109 -0
- package/src/components/custom/PackageRadioButtonGroup.tsx +47 -0
- package/src/components/dialog/Basic.tsx +11 -0
- package/src/components/dialog/Correct.tsx +16 -0
- package/src/components/dialog/Error.tsx +15 -0
- package/src/components/dialog/Info.tsx +15 -0
- package/src/components/dialog/InfoV2.tsx +35 -0
- package/src/components/dialog/NotFound.tsx +18 -0
- package/src/components/dialog/QuickSearch.tsx +115 -0
- package/src/components/notifications/NotificationsCenter.tsx +792 -0
- package/src/components/notifications/index.ts +42 -0
- package/src/components/tables/PaginationComponent.tsx +17 -0
- package/src/components/theme/AppLoadingFallback.tsx +42 -0
- package/src/components/theme/ErrorBoundary.tsx +57 -0
- package/src/components/theme/InitialLoader.tsx +16 -0
- package/src/components/theme/NotFound.tsx +124 -0
- package/src/components/theme/NotResults.tsx +54 -0
- package/src/hooks/useDraggable.ts +11 -0
- package/src/hooks/useNotifications.ts +14 -0
- package/src/hooks/useQuickSearch.tsx +29 -0
- package/src/index.tsx +77 -0
- package/src/utils/setNativeValue.tsx +23 -0
- package/dist/color-thief-CTwGFhOB.js +0 -272
- /package/{dist → src}/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +0 -0
- /package/{dist → src}/components/JsonColorSelector/JsonColorSelector.tsx.bkup +0 -0
- /package/{dist → src}/components/SortableDataGrid/README.md +0 -0
- /package/{dist → src}/styles/index.less +0 -0
|
@@ -1 +1,597 @@
|
|
|
1
|
-
|
|
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
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
import { useState, useCallback, useEffect } from "react";
|
|
22
|
+
import {
|
|
23
|
+
Button,
|
|
24
|
+
Badge,
|
|
25
|
+
Menu,
|
|
26
|
+
MenuItem,
|
|
27
|
+
Typography,
|
|
28
|
+
Divider,
|
|
29
|
+
Box,
|
|
30
|
+
IconButton,
|
|
31
|
+
Chip,
|
|
32
|
+
Snackbar,
|
|
33
|
+
Alert,
|
|
34
|
+
Stack,
|
|
35
|
+
Paper,
|
|
36
|
+
Portal
|
|
37
|
+
} from "@mui/material";
|
|
38
|
+
import {
|
|
39
|
+
NotificationsNone,
|
|
40
|
+
NotificationsActive,
|
|
41
|
+
Close as CloseIcon,
|
|
42
|
+
Clear as ClearIcon,
|
|
43
|
+
Person as PersonIcon,
|
|
44
|
+
Store as StoreIcon,
|
|
45
|
+
DragIndicator as DragIcon
|
|
46
|
+
} from "@mui/icons-material";
|
|
47
|
+
const defaultConfig = {
|
|
48
|
+
maxNotifications: 50,
|
|
49
|
+
toastAutoHideDuration: 8e3,
|
|
50
|
+
baseZIndex: 1e5,
|
|
51
|
+
menuMaxHeight: 480,
|
|
52
|
+
menuWidth: 360,
|
|
53
|
+
labels: {
|
|
54
|
+
title: "Notifications",
|
|
55
|
+
markAll: "Mark all",
|
|
56
|
+
noNotifications: "No notifications",
|
|
57
|
+
close: "Close",
|
|
58
|
+
acknowledge: "Got it",
|
|
59
|
+
customer: "Customer:",
|
|
60
|
+
store: "Store:",
|
|
61
|
+
received: "Received:",
|
|
62
|
+
now: "Now",
|
|
63
|
+
minutesAgo: "m",
|
|
64
|
+
hoursAgo: "h",
|
|
65
|
+
daysAgo: "d"
|
|
66
|
+
},
|
|
67
|
+
icons: {}
|
|
68
|
+
};
|
|
69
|
+
const formatTimeAgo = (timestamp, labels) => {
|
|
70
|
+
const now = /* @__PURE__ */ new Date();
|
|
71
|
+
const notificationTime = new Date(timestamp);
|
|
72
|
+
const diffInMinutes = Math.floor((now.getTime() - notificationTime.getTime()) / (1e3 * 60));
|
|
73
|
+
const l = __spreadValues(__spreadValues({}, defaultConfig.labels), labels);
|
|
74
|
+
if (diffInMinutes < 1) return l.now || "Now";
|
|
75
|
+
if (diffInMinutes < 60) return `${diffInMinutes}${l.minutesAgo}`;
|
|
76
|
+
if (diffInMinutes < 1440) return `${Math.floor(diffInMinutes / 60)}${l.hoursAgo}`;
|
|
77
|
+
return `${Math.floor(diffInMinutes / 1440)}${l.daysAgo}`;
|
|
78
|
+
};
|
|
79
|
+
const generateNotificationId = () => {
|
|
80
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
81
|
+
};
|
|
82
|
+
const useNotificationsCenter = (config = {}) => {
|
|
83
|
+
const mergedConfig = __spreadValues(__spreadValues({}, defaultConfig), config);
|
|
84
|
+
const [notifications, setNotifications] = useState([]);
|
|
85
|
+
const [toastNotifications, setToastNotifications] = useState([]);
|
|
86
|
+
const [dialogNotifications, setDialogNotifications] = useState([]);
|
|
87
|
+
const unreadCount = notifications.filter((n) => !n.isRead).length;
|
|
88
|
+
const addNotification = useCallback((notification, options = {}) => {
|
|
89
|
+
const { showDialog = true, showToast = true, toastSeverity = "warning" } = options;
|
|
90
|
+
const processedNotification = __spreadProps(__spreadValues({}, notification), {
|
|
91
|
+
id: generateNotificationId(),
|
|
92
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
93
|
+
isRead: false
|
|
94
|
+
});
|
|
95
|
+
setNotifications((prev) => [processedNotification, ...prev.slice(0, mergedConfig.maxNotifications - 1)]);
|
|
96
|
+
if (showDialog) {
|
|
97
|
+
setDialogNotifications((prev) => {
|
|
98
|
+
const dialogCount = prev.length;
|
|
99
|
+
const baseX = 20;
|
|
100
|
+
const baseY = typeof window !== "undefined" ? window.innerHeight - 250 : 600;
|
|
101
|
+
const offsetY = dialogCount * -220;
|
|
102
|
+
const dialogNotification = __spreadProps(__spreadValues({}, processedNotification), {
|
|
103
|
+
position: { x: baseX, y: baseY + offsetY },
|
|
104
|
+
zIndex: mergedConfig.baseZIndex + dialogCount + 1
|
|
105
|
+
});
|
|
106
|
+
return [...prev, dialogNotification];
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (showToast) {
|
|
110
|
+
const toastId = `toast-${processedNotification.id}`;
|
|
111
|
+
setToastNotifications((prev) => [...prev, {
|
|
112
|
+
id: toastId,
|
|
113
|
+
title: processedNotification.title,
|
|
114
|
+
message: `${processedNotification.customer || ""} ${processedNotification.store ? `- ${processedNotification.store}` : ""}`.trim(),
|
|
115
|
+
severity: toastSeverity
|
|
116
|
+
}]);
|
|
117
|
+
}
|
|
118
|
+
}, [mergedConfig.maxNotifications, mergedConfig.baseZIndex]);
|
|
119
|
+
const markAsRead = useCallback((notificationId) => {
|
|
120
|
+
setNotifications(
|
|
121
|
+
(prev) => prev.map((n) => n.id === notificationId ? __spreadProps(__spreadValues({}, n), { isRead: true }) : n)
|
|
122
|
+
);
|
|
123
|
+
}, []);
|
|
124
|
+
const markAllAsRead = useCallback(() => {
|
|
125
|
+
setNotifications((prev) => prev.map((n) => __spreadProps(__spreadValues({}, n), { isRead: true })));
|
|
126
|
+
}, []);
|
|
127
|
+
const removeNotification = useCallback((notificationId) => {
|
|
128
|
+
setNotifications((prev) => prev.filter((n) => n.id !== notificationId));
|
|
129
|
+
}, []);
|
|
130
|
+
const clearAllNotifications = useCallback(() => {
|
|
131
|
+
setNotifications([]);
|
|
132
|
+
}, []);
|
|
133
|
+
const closeToast = useCallback((toastId) => {
|
|
134
|
+
setToastNotifications((prev) => prev.filter((t) => t.id !== toastId));
|
|
135
|
+
}, []);
|
|
136
|
+
const closeDialog = useCallback((notificationId) => {
|
|
137
|
+
setDialogNotifications((prev) => prev.filter((d) => d.id !== notificationId));
|
|
138
|
+
markAsRead(notificationId);
|
|
139
|
+
}, [markAsRead]);
|
|
140
|
+
const acknowledgeDialog = useCallback((notificationId) => {
|
|
141
|
+
markAsRead(notificationId);
|
|
142
|
+
setDialogNotifications((prev) => prev.filter((d) => d.id !== notificationId));
|
|
143
|
+
}, [markAsRead]);
|
|
144
|
+
const bringDialogToFront = useCallback((notificationId) => {
|
|
145
|
+
setDialogNotifications((prev) => {
|
|
146
|
+
const maxZ = Math.max(...prev.map((p) => p.zIndex), mergedConfig.baseZIndex);
|
|
147
|
+
return prev.map(
|
|
148
|
+
(d) => d.id === notificationId ? __spreadProps(__spreadValues({}, d), { zIndex: maxZ + 1 }) : d
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
}, [mergedConfig.baseZIndex]);
|
|
152
|
+
const updateDialogPosition = useCallback((notificationId, newPosition) => {
|
|
153
|
+
setDialogNotifications(
|
|
154
|
+
(prev) => prev.map(
|
|
155
|
+
(d) => d.id === notificationId ? __spreadProps(__spreadValues({}, d), { position: newPosition }) : d
|
|
156
|
+
)
|
|
157
|
+
);
|
|
158
|
+
}, []);
|
|
159
|
+
return {
|
|
160
|
+
notifications,
|
|
161
|
+
toastNotifications,
|
|
162
|
+
dialogNotifications,
|
|
163
|
+
unreadCount,
|
|
164
|
+
addNotification,
|
|
165
|
+
markAsRead,
|
|
166
|
+
markAllAsRead,
|
|
167
|
+
removeNotification,
|
|
168
|
+
clearAllNotifications,
|
|
169
|
+
closeToast,
|
|
170
|
+
closeDialog,
|
|
171
|
+
acknowledgeDialog,
|
|
172
|
+
bringDialogToFront,
|
|
173
|
+
updateDialogPosition
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
const NotificationButton = ({
|
|
177
|
+
unreadCount,
|
|
178
|
+
onClick,
|
|
179
|
+
icons
|
|
180
|
+
}) => {
|
|
181
|
+
return /* @__PURE__ */ jsx(
|
|
182
|
+
IconButton,
|
|
183
|
+
{
|
|
184
|
+
onClick,
|
|
185
|
+
"aria-label": "notifications",
|
|
186
|
+
color: "inherit",
|
|
187
|
+
children: /* @__PURE__ */ jsx(Badge, { badgeContent: unreadCount, color: "error", max: 99, children: unreadCount > 0 ? (icons == null ? void 0 : icons.active) || /* @__PURE__ */ jsx(NotificationsActive, {}) : (icons == null ? void 0 : icons.empty) || /* @__PURE__ */ jsx(NotificationsNone, {}) })
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
};
|
|
191
|
+
const NotificationMenuItem = ({
|
|
192
|
+
notification,
|
|
193
|
+
onMarkAsRead,
|
|
194
|
+
onRemove,
|
|
195
|
+
formatTimeAgo: formatTimeAgo2
|
|
196
|
+
}) => {
|
|
197
|
+
return /* @__PURE__ */ jsx(
|
|
198
|
+
MenuItem,
|
|
199
|
+
{
|
|
200
|
+
onClick: () => onMarkAsRead(notification.id),
|
|
201
|
+
sx: {
|
|
202
|
+
backgroundColor: notification.isRead ? "transparent" : "action.hover",
|
|
203
|
+
borderLeft: notification.isRead ? "none" : "4px solid #ff9800",
|
|
204
|
+
whiteSpace: "normal",
|
|
205
|
+
alignItems: "flex-start",
|
|
206
|
+
py: 1.5
|
|
207
|
+
},
|
|
208
|
+
children: /* @__PURE__ */ jsxs(Box, { sx: { width: "100%" }, children: [
|
|
209
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", mb: 0.5 }, children: [
|
|
210
|
+
/* @__PURE__ */ jsx(Typography, { variant: "subtitle2", sx: { fontWeight: notification.isRead ? "normal" : "bold" }, children: notification.title }),
|
|
211
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
|
|
212
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: formatTimeAgo2(notification.timestamp) }),
|
|
213
|
+
/* @__PURE__ */ jsx(
|
|
214
|
+
IconButton,
|
|
215
|
+
{
|
|
216
|
+
size: "small",
|
|
217
|
+
onClick: (e) => {
|
|
218
|
+
e.stopPropagation();
|
|
219
|
+
onRemove(notification.id);
|
|
220
|
+
},
|
|
221
|
+
children: /* @__PURE__ */ jsx(CloseIcon, { fontSize: "small" })
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
] })
|
|
225
|
+
] }),
|
|
226
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", sx: { mb: 1 }, children: notification.message }),
|
|
227
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", gap: 0.5, flexWrap: "wrap" }, children: [
|
|
228
|
+
notification.customer && /* @__PURE__ */ jsx(
|
|
229
|
+
Chip,
|
|
230
|
+
{
|
|
231
|
+
label: notification.customer,
|
|
232
|
+
size: "small",
|
|
233
|
+
variant: "outlined",
|
|
234
|
+
color: "primary"
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
notification.store && /* @__PURE__ */ jsx(
|
|
238
|
+
Chip,
|
|
239
|
+
{
|
|
240
|
+
label: notification.store,
|
|
241
|
+
size: "small",
|
|
242
|
+
variant: "outlined",
|
|
243
|
+
color: "secondary"
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
] })
|
|
247
|
+
] })
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
const NotificationsMenu = ({
|
|
252
|
+
anchorEl,
|
|
253
|
+
notifications,
|
|
254
|
+
onClose,
|
|
255
|
+
onMarkAsRead,
|
|
256
|
+
onMarkAllAsRead,
|
|
257
|
+
onRemove,
|
|
258
|
+
onClearAll,
|
|
259
|
+
config = {}
|
|
260
|
+
}) => {
|
|
261
|
+
const mergedConfig = __spreadValues(__spreadValues({}, defaultConfig), config);
|
|
262
|
+
const labels = __spreadValues(__spreadValues({}, defaultConfig.labels), config.labels);
|
|
263
|
+
const open = Boolean(anchorEl);
|
|
264
|
+
const unreadCount = notifications.filter((n) => !n.isRead).length;
|
|
265
|
+
return /* @__PURE__ */ jsxs(
|
|
266
|
+
Menu,
|
|
267
|
+
{
|
|
268
|
+
anchorEl,
|
|
269
|
+
open,
|
|
270
|
+
onClose,
|
|
271
|
+
PaperProps: {
|
|
272
|
+
style: {
|
|
273
|
+
maxHeight: mergedConfig.menuMaxHeight,
|
|
274
|
+
width: mergedConfig.menuWidth
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
transformOrigin: { horizontal: "right", vertical: "top" },
|
|
278
|
+
anchorOrigin: { horizontal: "right", vertical: "bottom" },
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ jsxs(Box, { sx: { p: 2, display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
281
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h6", children: labels.title }),
|
|
282
|
+
notifications.length > 0 && /* @__PURE__ */ jsxs(Box, { children: [
|
|
283
|
+
unreadCount > 0 && /* @__PURE__ */ jsx(Button, { size: "small", onClick: onMarkAllAsRead, sx: { mr: 1 }, children: labels.markAll }),
|
|
284
|
+
/* @__PURE__ */ jsx(IconButton, { size: "small", onClick: onClearAll, children: /* @__PURE__ */ jsx(ClearIcon, { fontSize: "small" }) })
|
|
285
|
+
] })
|
|
286
|
+
] }),
|
|
287
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
288
|
+
notifications.length === 0 ? /* @__PURE__ */ jsx(MenuItem, { disabled: true, children: /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: labels.noNotifications }) }) : notifications.map((notification) => /* @__PURE__ */ jsx(
|
|
289
|
+
NotificationMenuItem,
|
|
290
|
+
{
|
|
291
|
+
notification,
|
|
292
|
+
onMarkAsRead,
|
|
293
|
+
onRemove,
|
|
294
|
+
formatTimeAgo: (ts) => formatTimeAgo(ts, labels)
|
|
295
|
+
},
|
|
296
|
+
notification.id
|
|
297
|
+
))
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
};
|
|
302
|
+
const ToastNotificationsStack = ({
|
|
303
|
+
toasts,
|
|
304
|
+
onClose,
|
|
305
|
+
autoHideDuration = 8e3,
|
|
306
|
+
baseZIndex = 1e5
|
|
307
|
+
}) => {
|
|
308
|
+
return /* @__PURE__ */ jsx(
|
|
309
|
+
Stack,
|
|
310
|
+
{
|
|
311
|
+
spacing: 1,
|
|
312
|
+
sx: {
|
|
313
|
+
position: "fixed",
|
|
314
|
+
top: 16,
|
|
315
|
+
right: 16,
|
|
316
|
+
zIndex: baseZIndex,
|
|
317
|
+
maxWidth: 400
|
|
318
|
+
},
|
|
319
|
+
children: toasts.map((toast) => /* @__PURE__ */ jsx(
|
|
320
|
+
Snackbar,
|
|
321
|
+
{
|
|
322
|
+
open: true,
|
|
323
|
+
autoHideDuration,
|
|
324
|
+
onClose: () => onClose(toast.id),
|
|
325
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
326
|
+
sx: { position: "relative", zIndex: baseZIndex },
|
|
327
|
+
children: /* @__PURE__ */ jsxs(
|
|
328
|
+
Alert,
|
|
329
|
+
{
|
|
330
|
+
onClose: () => onClose(toast.id),
|
|
331
|
+
severity: toast.severity,
|
|
332
|
+
variant: "filled",
|
|
333
|
+
sx: { width: "100%" },
|
|
334
|
+
children: [
|
|
335
|
+
/* @__PURE__ */ jsx(Typography, { variant: "subtitle2", children: toast.title }),
|
|
336
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", children: toast.message })
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
)
|
|
340
|
+
},
|
|
341
|
+
toast.id
|
|
342
|
+
))
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
};
|
|
346
|
+
const DraggableNotificationDialog = ({
|
|
347
|
+
notification,
|
|
348
|
+
onClose,
|
|
349
|
+
onAcknowledge,
|
|
350
|
+
onFocus,
|
|
351
|
+
onPositionChange,
|
|
352
|
+
config = {}
|
|
353
|
+
}) => {
|
|
354
|
+
const labels = __spreadValues(__spreadValues({}, defaultConfig.labels), config.labels);
|
|
355
|
+
const icons = __spreadValues(__spreadValues({}, defaultConfig.icons), config.icons);
|
|
356
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
357
|
+
const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 });
|
|
358
|
+
const handleMouseDown = useCallback((e) => {
|
|
359
|
+
if (e.target.closest(".drag-handle")) {
|
|
360
|
+
e.preventDefault();
|
|
361
|
+
onFocus();
|
|
362
|
+
setIsDragging(true);
|
|
363
|
+
setDragOffset({
|
|
364
|
+
x: e.clientX - notification.position.x,
|
|
365
|
+
y: e.clientY - notification.position.y
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}, [onFocus, notification.position]);
|
|
369
|
+
const handleMouseMove = useCallback((e) => {
|
|
370
|
+
if (isDragging) {
|
|
371
|
+
e.preventDefault();
|
|
372
|
+
const newX = Math.max(0, Math.min(window.innerWidth - 400, e.clientX - dragOffset.x));
|
|
373
|
+
const newY = Math.max(0, Math.min(window.innerHeight - 200, e.clientY - dragOffset.y));
|
|
374
|
+
onPositionChange({ x: newX, y: newY });
|
|
375
|
+
}
|
|
376
|
+
}, [isDragging, dragOffset, onPositionChange]);
|
|
377
|
+
const handleMouseUp = useCallback(() => {
|
|
378
|
+
if (isDragging) {
|
|
379
|
+
setIsDragging(false);
|
|
380
|
+
}
|
|
381
|
+
}, [isDragging]);
|
|
382
|
+
useEffect(() => {
|
|
383
|
+
if (isDragging) {
|
|
384
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
385
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
386
|
+
document.body.style.userSelect = "none";
|
|
387
|
+
return () => {
|
|
388
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
389
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
390
|
+
document.body.style.userSelect = "";
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
394
|
+
return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(
|
|
395
|
+
"div",
|
|
396
|
+
{
|
|
397
|
+
style: {
|
|
398
|
+
position: "fixed",
|
|
399
|
+
left: notification.position.x,
|
|
400
|
+
top: notification.position.y,
|
|
401
|
+
zIndex: notification.zIndex,
|
|
402
|
+
pointerEvents: "auto"
|
|
403
|
+
},
|
|
404
|
+
onMouseDown: handleMouseDown,
|
|
405
|
+
children: /* @__PURE__ */ jsxs(
|
|
406
|
+
Paper,
|
|
407
|
+
{
|
|
408
|
+
elevation: 8,
|
|
409
|
+
sx: {
|
|
410
|
+
width: 400,
|
|
411
|
+
borderRadius: 2,
|
|
412
|
+
overflow: "hidden",
|
|
413
|
+
boxShadow: "0 8px 32px rgba(0,0,0,0.24)",
|
|
414
|
+
cursor: isDragging ? "grabbing" : "default",
|
|
415
|
+
"&:hover": {
|
|
416
|
+
boxShadow: "0 12px 40px rgba(0,0,0,0.3)"
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
children: [
|
|
420
|
+
/* @__PURE__ */ jsxs(
|
|
421
|
+
Box,
|
|
422
|
+
{
|
|
423
|
+
className: "drag-handle",
|
|
424
|
+
sx: {
|
|
425
|
+
backgroundColor: "warning.main",
|
|
426
|
+
color: "warning.contrastText",
|
|
427
|
+
p: 2,
|
|
428
|
+
display: "flex",
|
|
429
|
+
alignItems: "center",
|
|
430
|
+
gap: 1,
|
|
431
|
+
cursor: isDragging ? "grabbing" : "grab",
|
|
432
|
+
userSelect: "none"
|
|
433
|
+
},
|
|
434
|
+
children: [
|
|
435
|
+
/* @__PURE__ */ jsx(DragIcon, { sx: { mr: 1 } }),
|
|
436
|
+
/* @__PURE__ */ jsx(NotificationsActive, {}),
|
|
437
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { flexGrow: 1, fontSize: "1rem" }, children: notification.title }),
|
|
438
|
+
/* @__PURE__ */ jsx(
|
|
439
|
+
IconButton,
|
|
440
|
+
{
|
|
441
|
+
size: "small",
|
|
442
|
+
onClick: (e) => {
|
|
443
|
+
e.stopPropagation();
|
|
444
|
+
onClose();
|
|
445
|
+
},
|
|
446
|
+
sx: { color: "warning.contrastText" },
|
|
447
|
+
children: /* @__PURE__ */ jsx(CloseIcon, { fontSize: "small" })
|
|
448
|
+
}
|
|
449
|
+
)
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
),
|
|
453
|
+
/* @__PURE__ */ jsxs(Box, { sx: { p: 2 }, children: [
|
|
454
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { mb: 2 }, children: notification.message }),
|
|
455
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
|
|
456
|
+
notification.customer && /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
457
|
+
icons.customer || /* @__PURE__ */ jsx(PersonIcon, { color: "primary" }),
|
|
458
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: labels.customer }),
|
|
459
|
+
/* @__PURE__ */ jsx(
|
|
460
|
+
Chip,
|
|
461
|
+
{
|
|
462
|
+
label: notification.customer,
|
|
463
|
+
size: "small",
|
|
464
|
+
color: "primary",
|
|
465
|
+
variant: "outlined"
|
|
466
|
+
}
|
|
467
|
+
)
|
|
468
|
+
] }),
|
|
469
|
+
notification.store && /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
470
|
+
icons.store || /* @__PURE__ */ jsx(StoreIcon, { color: "secondary" }),
|
|
471
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: labels.store }),
|
|
472
|
+
/* @__PURE__ */ jsx(
|
|
473
|
+
Chip,
|
|
474
|
+
{
|
|
475
|
+
label: notification.store,
|
|
476
|
+
size: "small",
|
|
477
|
+
color: "secondary",
|
|
478
|
+
variant: "outlined"
|
|
479
|
+
}
|
|
480
|
+
)
|
|
481
|
+
] }),
|
|
482
|
+
/* @__PURE__ */ jsx(Box, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 1 }, children: /* @__PURE__ */ jsxs(Typography, { variant: "caption", color: "text.secondary", children: [
|
|
483
|
+
labels.received,
|
|
484
|
+
" ",
|
|
485
|
+
formatTimeAgo(notification.timestamp, labels)
|
|
486
|
+
] }) })
|
|
487
|
+
] })
|
|
488
|
+
] }),
|
|
489
|
+
/* @__PURE__ */ jsxs(Box, { sx: { p: 2, pt: 0, display: "flex", gap: 1, justifyContent: "flex-end" }, children: [
|
|
490
|
+
/* @__PURE__ */ jsx(
|
|
491
|
+
Button,
|
|
492
|
+
{
|
|
493
|
+
onClick: (e) => {
|
|
494
|
+
e.stopPropagation();
|
|
495
|
+
onClose();
|
|
496
|
+
},
|
|
497
|
+
color: "inherit",
|
|
498
|
+
variant: "outlined",
|
|
499
|
+
size: "small",
|
|
500
|
+
children: labels.close
|
|
501
|
+
}
|
|
502
|
+
),
|
|
503
|
+
/* @__PURE__ */ jsx(
|
|
504
|
+
Button,
|
|
505
|
+
{
|
|
506
|
+
onClick: (e) => {
|
|
507
|
+
e.stopPropagation();
|
|
508
|
+
onAcknowledge();
|
|
509
|
+
},
|
|
510
|
+
color: "primary",
|
|
511
|
+
variant: "contained",
|
|
512
|
+
size: "small",
|
|
513
|
+
children: labels.acknowledge
|
|
514
|
+
}
|
|
515
|
+
)
|
|
516
|
+
] })
|
|
517
|
+
]
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
}
|
|
521
|
+
) });
|
|
522
|
+
};
|
|
523
|
+
const NotificationsCenter = ({
|
|
524
|
+
config = {},
|
|
525
|
+
notificationsHook
|
|
526
|
+
}) => {
|
|
527
|
+
const internalHook = useNotificationsCenter(config);
|
|
528
|
+
const hook = notificationsHook || internalHook;
|
|
529
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
530
|
+
const handleNotificationClick = (event) => {
|
|
531
|
+
setAnchorEl(event.currentTarget);
|
|
532
|
+
};
|
|
533
|
+
const handleClose = () => {
|
|
534
|
+
setAnchorEl(null);
|
|
535
|
+
};
|
|
536
|
+
const handleClearAll = () => {
|
|
537
|
+
hook.clearAllNotifications();
|
|
538
|
+
handleClose();
|
|
539
|
+
};
|
|
540
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
541
|
+
/* @__PURE__ */ jsx(
|
|
542
|
+
NotificationButton,
|
|
543
|
+
{
|
|
544
|
+
unreadCount: hook.unreadCount,
|
|
545
|
+
onClick: handleNotificationClick,
|
|
546
|
+
icons: config.icons
|
|
547
|
+
}
|
|
548
|
+
),
|
|
549
|
+
/* @__PURE__ */ jsx(
|
|
550
|
+
NotificationsMenu,
|
|
551
|
+
{
|
|
552
|
+
anchorEl,
|
|
553
|
+
notifications: hook.notifications,
|
|
554
|
+
onClose: handleClose,
|
|
555
|
+
onMarkAsRead: hook.markAsRead,
|
|
556
|
+
onMarkAllAsRead: hook.markAllAsRead,
|
|
557
|
+
onRemove: hook.removeNotification,
|
|
558
|
+
onClearAll: handleClearAll,
|
|
559
|
+
config
|
|
560
|
+
}
|
|
561
|
+
),
|
|
562
|
+
hook.dialogNotifications.map((dialogNotification) => /* @__PURE__ */ jsx(
|
|
563
|
+
DraggableNotificationDialog,
|
|
564
|
+
{
|
|
565
|
+
notification: dialogNotification,
|
|
566
|
+
onClose: () => hook.closeDialog(dialogNotification.id),
|
|
567
|
+
onAcknowledge: () => hook.acknowledgeDialog(dialogNotification.id),
|
|
568
|
+
onFocus: () => hook.bringDialogToFront(dialogNotification.id),
|
|
569
|
+
onPositionChange: (newPosition) => hook.updateDialogPosition(dialogNotification.id, newPosition),
|
|
570
|
+
config
|
|
571
|
+
},
|
|
572
|
+
dialogNotification.id
|
|
573
|
+
)),
|
|
574
|
+
/* @__PURE__ */ jsx(
|
|
575
|
+
ToastNotificationsStack,
|
|
576
|
+
{
|
|
577
|
+
toasts: hook.toastNotifications,
|
|
578
|
+
onClose: hook.closeToast,
|
|
579
|
+
autoHideDuration: config.toastAutoHideDuration,
|
|
580
|
+
baseZIndex: config.baseZIndex
|
|
581
|
+
}
|
|
582
|
+
)
|
|
583
|
+
] });
|
|
584
|
+
};
|
|
585
|
+
var NotificationsCenter_default = NotificationsCenter;
|
|
586
|
+
export {
|
|
587
|
+
DraggableNotificationDialog,
|
|
588
|
+
NotificationButton,
|
|
589
|
+
NotificationMenuItem,
|
|
590
|
+
NotificationsCenter,
|
|
591
|
+
NotificationsMenu,
|
|
592
|
+
ToastNotificationsStack,
|
|
593
|
+
NotificationsCenter_default as default,
|
|
594
|
+
formatTimeAgo,
|
|
595
|
+
generateNotificationId,
|
|
596
|
+
useNotificationsCenter
|
|
597
|
+
};
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
NotificationsCenter,
|
|
3
|
+
NotificationButton,
|
|
4
|
+
NotificationsMenu,
|
|
5
|
+
NotificationMenuItem,
|
|
6
|
+
ToastNotificationsStack,
|
|
7
|
+
DraggableNotificationDialog,
|
|
8
|
+
useNotificationsCenter,
|
|
9
|
+
formatTimeAgo,
|
|
10
|
+
generateNotificationId
|
|
11
|
+
} from "./NotificationsCenter";
|
|
12
|
+
import { default as default2 } from "./NotificationsCenter";
|
|
13
|
+
export {
|
|
14
|
+
DraggableNotificationDialog,
|
|
15
|
+
NotificationButton,
|
|
16
|
+
NotificationMenuItem,
|
|
17
|
+
NotificationsCenter,
|
|
18
|
+
NotificationsMenu,
|
|
19
|
+
ToastNotificationsStack,
|
|
20
|
+
default2 as default,
|
|
21
|
+
formatTimeAgo,
|
|
22
|
+
generateNotificationId,
|
|
23
|
+
useNotificationsCenter
|
|
24
|
+
};
|
|
@@ -1 +1,36 @@
|
|
|
1
|
-
|
|
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 { jsx } from "react/jsx-runtime";
|
|
18
|
+
import { Pagination } from "react-admin";
|
|
19
|
+
const PaginationComponent = (props) => {
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
className: "dash-pagination-component",
|
|
24
|
+
children: /* @__PURE__ */ jsx(
|
|
25
|
+
Pagination,
|
|
26
|
+
__spreadValues({
|
|
27
|
+
rowsPerPageOptions: [10, 25, 50, 100, 250, 500, 1e3]
|
|
28
|
+
}, props)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
var PaginationComponent_default = PaginationComponent;
|
|
34
|
+
export {
|
|
35
|
+
PaginationComponent_default as default
|
|
36
|
+
};
|