@alepha/ui 0.13.1 → 0.13.3

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 (118) hide show
  1. package/dist/admin/AdminLayout-JakF7ESb.js +388 -0
  2. package/dist/admin/AdminLayout-JakF7ESb.js.map +1 -0
  3. package/dist/admin/AdminLayout-qNsIyl30.js +3 -0
  4. package/dist/admin/AdminNotifications-BPrxALdS.js +154 -0
  5. package/dist/admin/AdminNotifications-BPrxALdS.js.map +1 -0
  6. package/dist/admin/AdminNotifications-DV-35Fi3.js +3 -0
  7. package/dist/admin/{AdminSessions-CmDVneE2.js → AdminSessions-CMmBtbSw.js} +36 -9
  8. package/dist/admin/AdminSessions-CMmBtbSw.js.map +1 -0
  9. package/dist/admin/AdminSessions-Df2VYzlE.js +3 -0
  10. package/dist/admin/AdminUserCreate-Coa_yi6m.js +103 -0
  11. package/dist/admin/AdminUserCreate-Coa_yi6m.js.map +1 -0
  12. package/dist/admin/AdminUserCreate-DjiCcAk0.js +3 -0
  13. package/dist/admin/AdminUserDetails-BCFwOm9w.js +221 -0
  14. package/dist/admin/AdminUserDetails-BCFwOm9w.js.map +1 -0
  15. package/dist/admin/AdminUserDetails-C5yeJNa3.js +3 -0
  16. package/dist/admin/AdminUserLayout-B8ga5QvP.js +3 -0
  17. package/dist/admin/AdminUserLayout-CR2OqV9Z.js +153 -0
  18. package/dist/admin/AdminUserLayout-CR2OqV9Z.js.map +1 -0
  19. package/dist/admin/AdminUserSessions-A_5KkqTY.js +3 -0
  20. package/dist/admin/AdminUserSessions-Bcf6-rjG.js +129 -0
  21. package/dist/admin/AdminUserSessions-Bcf6-rjG.js.map +1 -0
  22. package/dist/admin/AdminUserSettings-DAsAhFjX.js +3 -0
  23. package/dist/admin/AdminUserSettings-DRYVdW6S.js +164 -0
  24. package/dist/admin/AdminUserSettings-DRYVdW6S.js.map +1 -0
  25. package/dist/admin/AdminUsers-Dd9a5UqO.js +3 -0
  26. package/dist/admin/{AdminUsers-88De5pev.js → AdminUsers-IN_2yHKt.js} +32 -14
  27. package/dist/admin/AdminUsers-IN_2yHKt.js.map +1 -0
  28. package/dist/admin/index.d.ts +6052 -908
  29. package/dist/admin/index.js +299 -41
  30. package/dist/admin/index.js.map +1 -1
  31. package/dist/auth/AuthLayout-BSL8ZHgr.js +19 -0
  32. package/dist/auth/AuthLayout-BSL8ZHgr.js.map +1 -0
  33. package/dist/auth/Login-DDsyCNAA.js +4 -0
  34. package/dist/auth/{Login-OCrvjs9U.js → Login-kBfaRgKG.js} +5 -4
  35. package/dist/auth/Login-kBfaRgKG.js.map +1 -0
  36. package/dist/auth/{Register-Ei34GSba.js → Register-BxJmOqpF.js} +9 -6
  37. package/dist/auth/Register-BxJmOqpF.js.map +1 -0
  38. package/dist/auth/Register-D10MnlQc.js +4 -0
  39. package/dist/auth/{ResetPassword-tO0oMzfo.js → ResetPassword-BhyZ9ek4.js} +3 -3
  40. package/dist/auth/ResetPassword-BhyZ9ek4.js.map +1 -0
  41. package/dist/auth/ResetPassword-llBG-STp.js +3 -0
  42. package/dist/auth/VerifyEmail-BvOG-IUC.js +3 -0
  43. package/dist/auth/VerifyEmail-DeLct3oQ.js +131 -0
  44. package/dist/auth/VerifyEmail-DeLct3oQ.js.map +1 -0
  45. package/dist/auth/index.d.ts +3773 -3568
  46. package/dist/auth/index.js +96 -20
  47. package/dist/auth/index.js.map +1 -1
  48. package/dist/core/index.d.ts +340 -155
  49. package/dist/core/index.js +1391 -395
  50. package/dist/core/index.js.map +1 -1
  51. package/package.json +11 -8
  52. package/src/admin/AdminRouter.ts +116 -29
  53. package/src/admin/MainRouter.ts +23 -0
  54. package/src/admin/components/AdminLayout.tsx +86 -103
  55. package/src/admin/components/AdminNotifications.tsx +196 -12
  56. package/src/admin/components/AdminParameters.tsx +1 -1
  57. package/src/admin/components/AdminSessions.tsx +43 -7
  58. package/src/admin/components/AdminUserCreate.tsx +84 -0
  59. package/src/admin/components/AdminUserDetails.tsx +180 -0
  60. package/src/admin/components/AdminUserLayout.tsx +172 -0
  61. package/src/admin/components/AdminUserSessions.tsx +158 -0
  62. package/src/admin/components/AdminUserSettings.tsx +165 -0
  63. package/src/admin/components/AdminUsers.tsx +29 -9
  64. package/src/admin/index.ts +12 -3
  65. package/src/auth/AuthI18n.ts +22 -0
  66. package/src/auth/AuthRouter.ts +82 -8
  67. package/src/auth/components/AuthLayout.tsx +12 -0
  68. package/src/auth/components/Login.tsx +13 -11
  69. package/src/auth/components/Register.tsx +6 -5
  70. package/src/auth/components/ResetPassword.tsx +1 -1
  71. package/src/auth/components/VerifyEmail.tsx +102 -0
  72. package/src/auth/components/buttons/UserButton.tsx +6 -2
  73. package/src/auth/index.ts +1 -0
  74. package/src/core/components/buttons/ActionButton.tsx +11 -4
  75. package/src/core/components/buttons/DarkModeButton.tsx +1 -1
  76. package/src/core/components/buttons/OmnibarButton.tsx +10 -5
  77. package/src/core/components/buttons/ThemeButton.tsx +31 -0
  78. package/src/core/components/layout/AdminShell.tsx +4 -2
  79. package/src/core/components/layout/AlephaMantineProvider.tsx +10 -4
  80. package/src/core/components/layout/Omnibar.tsx +27 -10
  81. package/src/core/components/layout/Sidebar.tsx +33 -15
  82. package/src/core/components/table/DataTable.tsx +9 -5
  83. package/src/core/hooks/useTheme.ts +25 -0
  84. package/src/core/index.ts +9 -4
  85. package/src/core/providers/ThemeProvider.ts +87 -0
  86. package/src/core/themes/aurora.ts +107 -0
  87. package/src/core/themes/crystal.ts +107 -0
  88. package/src/core/themes/default.ts +7 -0
  89. package/src/core/themes/ember.ts +107 -0
  90. package/src/core/themes/index.ts +7 -0
  91. package/src/core/themes/midnight.ts +104 -0
  92. package/src/core/themes/remoraid.ts +278 -0
  93. package/src/core/themes/slate.ts +81 -0
  94. package/dist/admin/AdminJobs-BOq6AZOW.js +0 -3
  95. package/dist/admin/AdminJobs-CDnVxEv6.js +0 -125
  96. package/dist/admin/AdminJobs-CDnVxEv6.js.map +0 -1
  97. package/dist/admin/AdminLayout-Bgx25J8m.js +0 -3
  98. package/dist/admin/AdminLayout-CervL8LV.js +0 -88
  99. package/dist/admin/AdminLayout-CervL8LV.js.map +0 -1
  100. package/dist/admin/AdminNotifications-BDQXt3-e.js +0 -3
  101. package/dist/admin/AdminNotifications-DvI2989x.js +0 -40
  102. package/dist/admin/AdminNotifications-DvI2989x.js.map +0 -1
  103. package/dist/admin/AdminParameters-CWi7crdn.js +0 -40
  104. package/dist/admin/AdminParameters-CWi7crdn.js.map +0 -1
  105. package/dist/admin/AdminParameters-DKRAVen3.js +0 -3
  106. package/dist/admin/AdminSessions-CmDVneE2.js.map +0 -1
  107. package/dist/admin/AdminSessions-Dkk_fzWK.js +0 -3
  108. package/dist/admin/AdminUsers-88De5pev.js.map +0 -1
  109. package/dist/admin/AdminUsers-oyAXqZ5l.js +0 -3
  110. package/dist/admin/AdminVerifications-D93TKymL.js +0 -3
  111. package/dist/admin/AdminVerifications-DBVEoqJe.js +0 -40
  112. package/dist/admin/AdminVerifications-DBVEoqJe.js.map +0 -1
  113. package/dist/auth/Login-BC2jTczq.js +0 -4
  114. package/dist/auth/Login-OCrvjs9U.js.map +0 -1
  115. package/dist/auth/Register-Dh0lsQmI.js +0 -4
  116. package/dist/auth/Register-Ei34GSba.js.map +0 -1
  117. package/dist/auth/ResetPassword-BnlAQAOE.js +0 -3
  118. package/dist/auth/ResetPassword-tO0oMzfo.js.map +0 -1
@@ -0,0 +1,388 @@
1
+ import { ActionButton, AdminShell, OmnibarButton, ThemeButton } from "@alepha/ui";
2
+ import { UserButton } from "@alepha/ui/auth";
3
+ import { NestedView, useAction, useActive, useRouter, useStore } from "@alepha/react";
4
+ import { IconArrowLeft, IconCheck, IconChevronRight, IconLayoutSidebarLeftCollapse, IconLayoutSidebarRightCollapse } from "@tabler/icons-react";
5
+ import { Anchor, Button, Flex as Flex$1, Menu, ThemeIcon, Tooltip } from "@mantine/core";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { useFormState } from "@alepha/react/form";
8
+ import { Children, isValidElement } from "react";
9
+
10
+ //#region src/core/constants/ui.ts
11
+ const ui = {
12
+ colors: {
13
+ transparent: "transparent",
14
+ background: "var(--alepha-background)",
15
+ surface: "var(--alepha-surface)",
16
+ elevated: "var(--alepha-elevated)",
17
+ border: "var(--alepha-border)"
18
+ },
19
+ sizes: { icon: {
20
+ xs: 12,
21
+ sm: 16,
22
+ md: 20,
23
+ lg: 24,
24
+ xl: 32
25
+ } }
26
+ };
27
+
28
+ //#endregion
29
+ //#region src/core/components/buttons/ActionButton.tsx
30
+ const ActionMenuItem = (props) => {
31
+ const { item, index } = props;
32
+ const router = useRouter();
33
+ const action = useAction({ handler: async (e) => {
34
+ await item.onClick?.();
35
+ } }, [item.onClick]);
36
+ if (item.type === "divider") return /* @__PURE__ */ jsx(Menu.Divider, {}, index);
37
+ if (item.type === "label") return /* @__PURE__ */ jsx(Menu.Label, { children: item.label }, index);
38
+ if (item.children && item.children.length > 0) return /* @__PURE__ */ jsxs(Menu, {
39
+ trigger: "hover",
40
+ position: "right-start",
41
+ offset: 2,
42
+ children: [/* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(Menu.Item, {
43
+ leftSection: item.icon,
44
+ rightSection: /* @__PURE__ */ jsx(IconChevronRight, { size: 14 }),
45
+ children: item.label
46
+ }) }), /* @__PURE__ */ jsx(Menu.Dropdown, { children: item.children.map((child, childIndex) => /* @__PURE__ */ jsx(ActionMenuItem, {
47
+ item: child,
48
+ index: childIndex
49
+ }, childIndex)) })]
50
+ }, index);
51
+ const menuItemProps = {};
52
+ if (props.item.onClick) menuItemProps.onClick = action.run;
53
+ else if (props.item.href) Object.assign(menuItemProps, router.anchor(props.item.href));
54
+ return /* @__PURE__ */ jsx(Menu.Item, {
55
+ leftSection: item.icon,
56
+ onClick: item.onClick,
57
+ color: item.color,
58
+ rightSection: item.active ? /* @__PURE__ */ jsx(ThemeIcon, {
59
+ size: "xs",
60
+ variant: "transparent",
61
+ children: /* @__PURE__ */ jsx(IconCheck, {})
62
+ }) : void 0,
63
+ ...menuItemProps,
64
+ children: item.label
65
+ }, index);
66
+ };
67
+ const ActionButton$1 = (_props) => {
68
+ const props = {
69
+ variant: "subtle",
70
+ ..._props
71
+ };
72
+ const { tooltip, menu, icon, ...restProps } = props;
73
+ restProps.color ??= "gray";
74
+ if (props.icon) {
75
+ const icon$1 = isComponentType(props.icon) ? /* @__PURE__ */ jsx(props.icon, { size: ui.sizes.icon.md }) : /* @__PURE__ */ jsx(ThemeIcon, {
76
+ w: 24,
77
+ variant: "transparent",
78
+ size: "sm",
79
+ c: "var(--mantine-color-text)",
80
+ ...props.themeIconProps,
81
+ children: props.icon
82
+ });
83
+ if (!props.children) {
84
+ restProps.children = Children.only(icon$1);
85
+ restProps.px ??= "xs";
86
+ } else restProps.leftSection = icon$1;
87
+ }
88
+ if (props.leftSection && !props.children) restProps.px ??= "xs";
89
+ if (props.textVisibleFrom) {
90
+ const { children, textVisibleFrom, leftSection, ...rest } = restProps;
91
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Flex$1, {
92
+ w: "100%",
93
+ visibleFrom: textVisibleFrom,
94
+ children: /* @__PURE__ */ jsx(ActionButton$1, {
95
+ flex: 1,
96
+ ...rest,
97
+ leftSection,
98
+ tooltip,
99
+ menu,
100
+ children
101
+ })
102
+ }), /* @__PURE__ */ jsx(Flex$1, {
103
+ w: "100%",
104
+ hiddenFrom: textVisibleFrom,
105
+ children: /* @__PURE__ */ jsx(ActionButton$1, {
106
+ px: "xs",
107
+ ...rest,
108
+ tooltip,
109
+ menu,
110
+ children: leftSection
111
+ })
112
+ })] });
113
+ }
114
+ const renderAction = () => {
115
+ if ("href" in restProps && restProps.href) {
116
+ if (restProps.href.startsWith("http") || restProps.target) return /* @__PURE__ */ jsx(ActionHrefButton, {
117
+ ...restProps,
118
+ href: restProps.href,
119
+ children: restProps.children
120
+ });
121
+ return /* @__PURE__ */ jsx(ActionNavigationButton, {
122
+ ...restProps,
123
+ href: restProps.href,
124
+ children: restProps.children
125
+ });
126
+ }
127
+ delete restProps.classNameActive;
128
+ delete restProps.variantActive;
129
+ if ("action" in restProps && restProps.action) return /* @__PURE__ */ jsx(ActionHookButton, {
130
+ ...restProps,
131
+ action: restProps.action,
132
+ children: restProps.children
133
+ });
134
+ if ("onClick" in restProps && restProps.onClick) return /* @__PURE__ */ jsx(ActionClickButton, {
135
+ ...restProps,
136
+ onClick: restProps.onClick,
137
+ children: restProps.children
138
+ });
139
+ if ("form" in restProps && restProps.form) {
140
+ if (restProps.type === "reset") return /* @__PURE__ */ jsx(ActionResetButton, {
141
+ ...restProps,
142
+ form: restProps.form,
143
+ children: restProps.children
144
+ });
145
+ return /* @__PURE__ */ jsx(ActionSubmitButton, {
146
+ ...restProps,
147
+ form: restProps.form,
148
+ children: restProps.children
149
+ });
150
+ }
151
+ return /* @__PURE__ */ jsx(Button, {
152
+ ...restProps,
153
+ children: restProps.children
154
+ });
155
+ };
156
+ let actionElement = renderAction();
157
+ if (menu) actionElement = /* @__PURE__ */ jsxs(Menu, {
158
+ position: menu.position || "bottom-start",
159
+ width: menu.width || 200,
160
+ shadow: menu.shadow || "md",
161
+ trigger: menu.on === "hover" ? "hover" : "click",
162
+ ...menu.menuProps,
163
+ children: [/* @__PURE__ */ jsx(Menu.Target, {
164
+ ...menu.targetProps,
165
+ children: actionElement
166
+ }), /* @__PURE__ */ jsx(Menu.Dropdown, { children: menu.items.map((item, index) => /* @__PURE__ */ jsx(ActionMenuItem, {
167
+ item,
168
+ index
169
+ }, index)) })]
170
+ });
171
+ if (tooltip) {
172
+ const defaultTooltipProps = { openDelay: 1e3 };
173
+ return /* @__PURE__ */ jsx(Tooltip, { ...typeof tooltip === "string" ? {
174
+ ...defaultTooltipProps,
175
+ label: tooltip,
176
+ children: actionElement
177
+ } : {
178
+ ...defaultTooltipProps,
179
+ ...tooltip,
180
+ children: actionElement
181
+ } });
182
+ }
183
+ return actionElement;
184
+ };
185
+ var ActionButton_default = ActionButton$1;
186
+ /**
187
+ * Action button that submits a form with loading and disabled state handling.
188
+ */
189
+ const ActionSubmitButton = (props) => {
190
+ const { form, ...buttonProps } = props;
191
+ const state = useFormState(form);
192
+ return /* @__PURE__ */ jsx(Button, {
193
+ ...buttonProps,
194
+ loading: state.loading,
195
+ disabled: state.loading,
196
+ type: "submit",
197
+ children: props.children
198
+ });
199
+ };
200
+ const ActionResetButton = (props) => {
201
+ const { form, ...buttonProps } = props;
202
+ const state = useFormState(form);
203
+ return /* @__PURE__ */ jsx(Button, {
204
+ ...buttonProps,
205
+ disabled: state.loading,
206
+ type: "reset",
207
+ children: props.children
208
+ });
209
+ };
210
+ /**
211
+ * Action button that integrates with useAction hook return value.
212
+ * Automatically handles loading state and executes the action on click.
213
+ *
214
+ * @example
215
+ * ```tsx
216
+ * const saveAction = useAction({
217
+ * handler: async (data) => {
218
+ * await api.save(data);
219
+ * }
220
+ * }, []);
221
+ *
222
+ * <ActionButton action={saveAction}>
223
+ * Save
224
+ * </ActionButton>
225
+ * ```
226
+ */
227
+ const ActionHookButton = (props) => {
228
+ const { action, ...buttonProps } = props;
229
+ return /* @__PURE__ */ jsx(Button, {
230
+ ...buttonProps,
231
+ disabled: action.loading || props.disabled,
232
+ loading: action.loading,
233
+ onClick: () => action.run(),
234
+ children: props.children
235
+ });
236
+ };
237
+ /**
238
+ * Basic action button that handles click events with loading and error handling.
239
+ *
240
+ * @example
241
+ * ```tsx
242
+ * <ActionButton onClick={() => api.doSomething()}>
243
+ * Do Something
244
+ * </ActionButton>
245
+ * ```
246
+ */
247
+ const ActionClickButton = (props) => {
248
+ const action = useAction({ handler: async (e) => {
249
+ await props.onClick(e);
250
+ } }, [props.onClick]);
251
+ return /* @__PURE__ */ jsx(Button, {
252
+ ...props,
253
+ disabled: action.loading || props.disabled,
254
+ loading: action.loading,
255
+ onClick: action.run,
256
+ children: props.children
257
+ });
258
+ };
259
+ /**
260
+ * Action for navigation with active state support.
261
+ */
262
+ const ActionNavigationButton = (props) => {
263
+ const { active: options, classNameActive, variantActive, routerGoOptions, ...buttonProps } = props;
264
+ const router = useRouter();
265
+ const { isPending, isActive } = useActive(options ? {
266
+ href: props.href,
267
+ ...options
268
+ } : { href: props.href });
269
+ const anchorProps = router.anchor(props.href, routerGoOptions);
270
+ const className = buttonProps.className || "";
271
+ if (isActive && options !== false && classNameActive) buttonProps.className = `${className} ${classNameActive}`.trim();
272
+ if (props.anchorProps) return /* @__PURE__ */ jsx(Anchor, {
273
+ component: "a",
274
+ ...anchorProps,
275
+ ...props.anchorProps,
276
+ children: props.children
277
+ });
278
+ return /* @__PURE__ */ jsx(Button, {
279
+ component: "a",
280
+ loading: isPending,
281
+ ...buttonProps,
282
+ ...anchorProps,
283
+ variant: isActive && options !== false ? variantActive ?? "filled" : buttonProps.variant ?? "subtle",
284
+ children: props.children
285
+ });
286
+ };
287
+ const ActionHrefButton = (props) => {
288
+ const { active: options, classNameActive, variantActive, routerGoOptions, target, ...buttonProps } = props;
289
+ return /* @__PURE__ */ jsx(Button, {
290
+ component: "a",
291
+ target,
292
+ ...buttonProps,
293
+ children: props.children
294
+ });
295
+ };
296
+ function isComponentType(param) {
297
+ if (isValidElement(param)) return false;
298
+ return typeof param === "function" || typeof param === "object" && param !== null && "$$typeof" in param;
299
+ }
300
+
301
+ //#endregion
302
+ //#region src/core/components/buttons/ToggleSidebarButton.tsx
303
+ const ToggleSidebarButton = () => {
304
+ const [collapsed, setCollapsed] = useStore("alepha.ui.sidebar.collapsed");
305
+ return /* @__PURE__ */ jsx(ActionButton_default, {
306
+ icon: collapsed ? /* @__PURE__ */ jsx(IconLayoutSidebarRightCollapse, {}) : /* @__PURE__ */ jsx(IconLayoutSidebarLeftCollapse, {}),
307
+ variant: "subtle",
308
+ size: "md",
309
+ onClick: () => setCollapsed(!collapsed),
310
+ tooltip: {
311
+ position: "right",
312
+ label: collapsed ? "Show sidebar" : "Hide sidebar"
313
+ }
314
+ });
315
+ };
316
+ var ToggleSidebarButton_default = ToggleSidebarButton;
317
+
318
+ //#endregion
319
+ //#region src/admin/components/AdminLayout.tsx
320
+ const AdminLayout = () => {
321
+ const router = useRouter();
322
+ return /* @__PURE__ */ jsx(AdminShell, {
323
+ appShellMainProps: { bg: "var(--alepha-surface)" },
324
+ appShellHeaderProps: { bg: "var(--alepha-background)" },
325
+ appShellNavbarProps: {},
326
+ appShellProps: {},
327
+ appShellFooterProps: { bg: "var(--alepha-background)" },
328
+ footer: /* @__PURE__ */ jsx(Flex$1, { h: 12 }),
329
+ appBarProps: { items: [
330
+ {
331
+ element: /* @__PURE__ */ jsx(ActionButton, {
332
+ icon: IconArrowLeft,
333
+ href: "/"
334
+ }),
335
+ position: "left"
336
+ },
337
+ {
338
+ element: /* @__PURE__ */ jsx(OmnibarButton, { actionProps: { variant: "outline" } }),
339
+ position: "right"
340
+ },
341
+ {
342
+ element: /* @__PURE__ */ jsx(UserButton, {}),
343
+ position: "right"
344
+ },
345
+ {
346
+ element: /* @__PURE__ */ jsx(ThemeButton, {}),
347
+ position: "right"
348
+ },
349
+ {
350
+ type: "dark",
351
+ position: "right"
352
+ }
353
+ ] },
354
+ sidebarProps: {
355
+ gap: "xs",
356
+ menu: [
357
+ { element: /* @__PURE__ */ jsx(ToggleSidebarButton_default, {}) },
358
+ { type: "spacer" },
359
+ {
360
+ ...router.node("adminUsers"),
361
+ description: void 0
362
+ },
363
+ {
364
+ ...router.node("adminSessions"),
365
+ description: void 0
366
+ },
367
+ {
368
+ ...router.node("adminNotifications"),
369
+ description: void 0
370
+ },
371
+ {
372
+ ...router.node("adminFiles"),
373
+ description: void 0
374
+ }
375
+ ]
376
+ },
377
+ children: /* @__PURE__ */ jsx(Flex$1, {
378
+ flex: 1,
379
+ bg: "var(--alepha-surface)",
380
+ children: /* @__PURE__ */ jsx(NestedView, {})
381
+ })
382
+ });
383
+ };
384
+ var AdminLayout_default = AdminLayout;
385
+
386
+ //#endregion
387
+ export { AdminLayout_default as t };
388
+ //# sourceMappingURL=AdminLayout-JakF7ESb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdminLayout-JakF7ESb.js","names":["menuItemProps: MenuItemProps & ButtonHTMLAttributes<unknown>","ActionButton","icon","Flex","defaultTooltipProps: Partial<TooltipProps>","ActionButton","Flex","ToggleSidebarButton"],"sources":["../../src/core/constants/ui.ts","../../src/core/components/buttons/ActionButton.tsx","../../src/core/components/buttons/ToggleSidebarButton.tsx","../../src/admin/components/AdminLayout.tsx"],"sourcesContent":["export const ui = {\n colors: {\n transparent: \"transparent\",\n background: \"var(--alepha-background)\",\n surface: \"var(--alepha-surface)\",\n elevated: \"var(--alepha-elevated)\",\n border: \"var(--alepha-border)\",\n },\n sizes: {\n icon: {\n xs: 12,\n sm: 16,\n md: 20,\n lg: 24,\n xl: 32,\n },\n },\n};\n","import {\n type RouterGoOptions,\n type UseActionReturn,\n type UseActiveOptions,\n useAction,\n useActive,\n useRouter,\n} from \"@alepha/react\";\nimport { type FormModel, useFormState } from \"@alepha/react/form\";\nimport {\n Anchor,\n type AnchorProps,\n Button,\n type ButtonProps,\n Flex,\n Menu,\n type MenuItemProps,\n type MenuProps,\n type MenuTargetProps,\n ThemeIcon,\n type ThemeIconProps,\n Tooltip,\n type TooltipProps,\n} from \"@mantine/core\";\nimport { IconCheck, IconChevronRight } from \"@tabler/icons-react\";\nimport {\n type ButtonHTMLAttributes,\n Children,\n type ComponentType,\n isValidElement,\n type ReactNode,\n} from \"react\";\nimport { ui } from \"../../constants/ui.ts\";\n\nexport interface ActionMenuItem {\n /**\n * Menu item type\n */\n type?: \"item\" | \"divider\" | \"label\";\n\n /**\n * Label text for the menu item\n */\n label?: string | ReactNode;\n\n /**\n * Icon element to display before the label\n */\n icon?: ReactNode;\n\n /**\n * Click handler for menu items\n */\n onClick?: () => void;\n\n /**\n * Href for navigation menu items\n */\n href?: string;\n\n /**\n * Color for the menu item (e.g., \"red\" for danger actions)\n */\n color?: string;\n\n /**\n * Nested submenu items\n */\n children?: ActionMenuItem[];\n\n /**\n * Whether the menu item is active\n */\n active?: boolean;\n}\n\nexport interface ActionMenuConfig {\n /**\n * Array of menu items to display\n */\n items: ActionMenuItem[];\n\n /**\n * Menu position relative to the button\n */\n position?:\n | \"bottom\"\n | \"bottom-start\"\n | \"bottom-end\"\n | \"top\"\n | \"top-start\"\n | \"top-end\"\n | \"left\"\n | \"right\";\n\n /**\n * Menu width\n */\n width?: number | string;\n\n /**\n * Menu shadow\n */\n shadow?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\n on?: \"hover\" | \"click\";\n\n targetProps?: MenuTargetProps;\n\n menuProps?: MenuProps;\n}\n\nexport interface ActionCommonProps extends ButtonProps {\n children?: ReactNode;\n\n textVisibleFrom?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\n /**\n * Tooltip to display on hover. Can be a string for simple tooltips\n * or a TooltipProps object for advanced configuration.\n */\n tooltip?: string | TooltipProps;\n\n /**\n * Menu configuration. When provided, the action will display a dropdown menu.\n */\n menu?: ActionMenuConfig;\n\n /**\n * If set, a confirmation dialog will be shown before performing the action.\n * If `true`, a default title and message will be used.\n * If a string, it will be used as the message with a default title.\n * If an object, it can contain `title` and `message` properties to customize the dialog.\n */\n confirm?: boolean | string | { title?: string; message: string };\n\n /**\n * Icon to display on the left side of the button.\n * If no children are provided, the button will be styled as an icon-only button.\n */\n icon?: ReactNode | ComponentType;\n\n /**\n * Additional props to pass to the ThemeIcon wrapping the icon.\n */\n themeIconProps?: ThemeIconProps;\n\n /**\n * Visual intent of the action button.\n */\n intent?: \"primary\" | \"success\" | \"danger\" | \"warning\" | \"info\";\n}\n\nexport type ActionProps = ActionCommonProps &\n (\n | ActionNavigationButtonProps\n | ActionClickButtonProps\n | ActionSubmitButtonProps\n | ActionHookButtonProps\n | {}\n );\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n// Helper function to render menu items recursively\nconst ActionMenuItem = (props: {\n item: ActionMenuItem;\n index: number;\n}): ReactNode => {\n const { item, index } = props;\n\n const router = useRouter();\n const action = useAction(\n {\n handler: async (e: any) => {\n await item.onClick?.();\n },\n },\n [item.onClick],\n );\n\n // Render divider\n if (item.type === \"divider\") {\n return <Menu.Divider key={index} />;\n }\n\n // Render label\n if (item.type === \"label\") {\n return <Menu.Label key={index}>{item.label}</Menu.Label>;\n }\n\n // Render submenu if it has children\n if (item.children && item.children.length > 0) {\n return (\n <Menu key={index} trigger=\"hover\" position=\"right-start\" offset={2}>\n <Menu.Target>\n <Menu.Item\n leftSection={item.icon}\n rightSection={<IconChevronRight size={14} />}\n >\n {item.label}\n </Menu.Item>\n </Menu.Target>\n <Menu.Dropdown>\n {item.children.map((child, childIndex) => (\n <ActionMenuItem item={child} index={childIndex} key={childIndex} />\n ))}\n </Menu.Dropdown>\n </Menu>\n );\n }\n\n const menuItemProps: MenuItemProps & ButtonHTMLAttributes<unknown> = {};\n if (props.item.onClick) {\n menuItemProps.onClick = action.run;\n } else if (props.item.href) {\n Object.assign(menuItemProps, router.anchor(props.item.href));\n }\n\n // render regular menu item\n return (\n <Menu.Item\n key={index}\n leftSection={item.icon}\n onClick={item.onClick}\n color={item.color}\n rightSection={\n item.active ? (\n <ThemeIcon size={\"xs\"} variant={\"transparent\"}>\n <IconCheck />\n </ThemeIcon>\n ) : undefined\n }\n {...menuItemProps}\n >\n {item.label}\n </Menu.Item>\n );\n};\n\nconst ActionButton = (_props: ActionProps) => {\n const props = { variant: \"subtle\", ..._props };\n const { tooltip, menu, icon, ...restProps } = props;\n\n // set default color to gray (not colored)\n restProps.color ??= \"gray\";\n\n if (props.icon) {\n const icon = isComponentType(props.icon) ? (\n <props.icon size={ui.sizes.icon.md} />\n ) : (\n <ThemeIcon\n w={24} // TODO: make size configurable\n variant={\"transparent\"}\n size={\"sm\"}\n c={\"var(--mantine-color-text)\"}\n {...props.themeIconProps}\n >\n {props.icon as ReactNode}\n </ThemeIcon>\n );\n\n if (!props.children) {\n restProps.children = Children.only(icon);\n restProps.px ??= \"xs\";\n } else {\n restProps.leftSection = icon;\n }\n }\n\n if (props.leftSection && !props.children) {\n restProps.px ??= \"xs\";\n }\n\n if (props.textVisibleFrom) {\n const { children, textVisibleFrom, leftSection, ...rest } = restProps;\n return (\n <>\n <Flex w={\"100%\"} visibleFrom={textVisibleFrom}>\n <ActionButton\n flex={1}\n {...rest}\n leftSection={leftSection}\n tooltip={tooltip}\n menu={menu}\n >\n {children}\n </ActionButton>\n </Flex>\n <Flex w={\"100%\"} hiddenFrom={textVisibleFrom}>\n <ActionButton px={\"xs\"} {...rest} tooltip={tooltip} menu={menu}>\n {leftSection}\n </ActionButton>\n </Flex>\n </>\n );\n }\n\n const renderAction = () => {\n if (\"href\" in restProps && restProps.href) {\n if (restProps.href.startsWith(\"http\") || restProps.target) {\n return (\n <ActionHrefButton {...restProps} href={restProps.href}>\n {restProps.children}\n </ActionHrefButton>\n );\n }\n return (\n <ActionNavigationButton {...restProps} href={restProps.href}>\n {restProps.children}\n </ActionNavigationButton>\n );\n }\n\n delete (restProps as any).classNameActive;\n delete (restProps as any).variantActive;\n\n if (\"action\" in restProps && restProps.action) {\n return (\n <ActionHookButton {...restProps} action={restProps.action}>\n {restProps.children}\n </ActionHookButton>\n );\n }\n\n if (\"onClick\" in restProps && restProps.onClick) {\n return (\n <ActionClickButton {...restProps} onClick={restProps.onClick}>\n {restProps.children}\n </ActionClickButton>\n );\n }\n\n if (\"form\" in restProps && restProps.form) {\n if (restProps.type === \"reset\") {\n return (\n <ActionResetButton {...restProps} form={restProps.form}>\n {restProps.children}\n </ActionResetButton>\n );\n }\n return (\n <ActionSubmitButton {...restProps} form={restProps.form}>\n {restProps.children}\n </ActionSubmitButton>\n );\n }\n\n return <Button {...(restProps as any)}>{restProps.children}</Button>;\n };\n\n let actionElement = renderAction();\n\n // wrap with Menu if provided\n if (menu) {\n actionElement = (\n <Menu\n position={menu.position || \"bottom-start\"}\n width={menu.width || 200}\n shadow={menu.shadow || \"md\"}\n trigger={menu.on === \"hover\" ? \"hover\" : \"click\"}\n {...menu.menuProps}\n >\n <Menu.Target {...menu.targetProps}>{actionElement}</Menu.Target>\n <Menu.Dropdown>\n {menu.items.map((item, index) => (\n <ActionMenuItem item={item} index={index} key={index} />\n ))}\n </Menu.Dropdown>\n </Menu>\n );\n }\n\n // Wrap with Tooltip if provided\n if (tooltip) {\n // openDelay: 1000 -> like HTML title attribute\n const defaultTooltipProps: Partial<TooltipProps> = {\n openDelay: 1000,\n };\n const tooltipProps: TooltipProps =\n typeof tooltip === \"string\"\n ? {\n ...defaultTooltipProps,\n label: tooltip,\n children: actionElement,\n }\n : { ...defaultTooltipProps, ...tooltip, children: actionElement };\n\n return <Tooltip {...tooltipProps} />;\n }\n\n return actionElement;\n};\n\nexport default ActionButton;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n// Action Submit\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface ActionSubmitButtonProps extends ButtonProps {\n form: FormModel<any>;\n type?: \"submit\" | \"reset\";\n}\n\n/**\n * Action button that submits a form with loading and disabled state handling.\n */\nconst ActionSubmitButton = (props: ActionSubmitButtonProps) => {\n const { form, ...buttonProps } = props;\n const state = useFormState(form);\n return (\n <Button\n {...buttonProps}\n loading={state.loading}\n disabled={state.loading}\n type={\"submit\"}\n >\n {props.children}\n </Button>\n );\n};\n\nconst ActionResetButton = (props: ActionSubmitButtonProps) => {\n const { form, ...buttonProps } = props;\n const state = useFormState(form);\n return (\n <Button {...buttonProps} disabled={state.loading} type={\"reset\"}>\n {props.children}\n </Button>\n );\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n// Action with useAction Hook\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface ActionHookButtonProps extends ButtonProps {\n action: UseActionReturn<any[], any>;\n}\n\n/**\n * Action button that integrates with useAction hook return value.\n * Automatically handles loading state and executes the action on click.\n *\n * @example\n * ```tsx\n * const saveAction = useAction({\n * handler: async (data) => {\n * await api.save(data);\n * }\n * }, []);\n *\n * <ActionButton action={saveAction}>\n * Save\n * </ActionButton>\n * ```\n */\nconst ActionHookButton = (props: ActionHookButtonProps) => {\n const { action, ...buttonProps } = props;\n\n return (\n <Button\n {...buttonProps}\n disabled={action.loading || props.disabled}\n loading={action.loading}\n onClick={() => action.run()}\n >\n {props.children}\n </Button>\n );\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n// Action Click\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface ActionClickButtonProps extends ButtonProps {\n onClick: (e: any) => any;\n}\n\n/**\n * Basic action button that handles click events with loading and error handling.\n *\n * @example\n * ```tsx\n * <ActionButton onClick={() => api.doSomething()}>\n * Do Something\n * </ActionButton>\n * ```\n */\nconst ActionClickButton = (props: ActionClickButtonProps) => {\n const action = useAction(\n {\n handler: async (e: any) => {\n await props.onClick(e);\n },\n },\n [props.onClick],\n );\n\n return (\n <Button\n {...props}\n disabled={action.loading || props.disabled}\n loading={action.loading}\n onClick={action.run}\n >\n {props.children}\n </Button>\n );\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n// Action Navigation\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface ActionNavigationButtonProps extends ButtonProps {\n href: string;\n active?: Partial<UseActiveOptions> | false;\n routerGoOptions?: RouterGoOptions;\n classNameActive?: string;\n variantActive?: ButtonProps[\"variant\"];\n target?: string;\n anchorProps?: AnchorProps;\n}\n\n/**\n * Action for navigation with active state support.\n */\nconst ActionNavigationButton = (props: ActionNavigationButtonProps) => {\n const {\n active: options,\n classNameActive,\n variantActive,\n routerGoOptions,\n ...buttonProps\n } = props;\n const router = useRouter();\n const { isPending, isActive } = useActive(\n options ? { href: props.href, ...options } : { href: props.href },\n );\n const anchorProps = router.anchor(props.href, routerGoOptions);\n\n const className = buttonProps.className || \"\";\n if (isActive && options !== false && classNameActive) {\n buttonProps.className = `${className} ${classNameActive}`.trim();\n }\n\n if (props.anchorProps) {\n return (\n <Anchor component={\"a\"} {...anchorProps} {...props.anchorProps}>\n {props.children}\n </Anchor>\n );\n }\n\n return (\n <Button\n component={\"a\"}\n loading={isPending}\n {...buttonProps}\n {...anchorProps}\n variant={\n isActive && options !== false\n ? (variantActive ?? \"filled\")\n : (buttonProps.variant ?? \"subtle\")\n }\n >\n {props.children}\n </Button>\n );\n};\n\nconst ActionHrefButton = (props: ActionNavigationButtonProps) => {\n const {\n active: options,\n classNameActive,\n variantActive,\n routerGoOptions,\n target,\n ...buttonProps\n } = props;\n\n return (\n <Button component={\"a\"} target={target} {...buttonProps}>\n {props.children}\n </Button>\n );\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport function isComponentType(param: any): param is ComponentType<any> {\n if (isValidElement(param)) return false;\n return (\n typeof param === \"function\" ||\n (typeof param === \"object\" && param !== null && \"$$typeof\" in param)\n );\n}\n\nexport const renderIcon = (icon: ReactNode | ComponentType): ReactNode => {\n if (!icon) return null;\n if (isValidElement(icon)) return icon;\n if (isComponentType(icon)) {\n const IconComponent = icon;\n return <IconComponent size={ui.sizes.icon.md} />;\n }\n return icon as ReactNode;\n};\n","import { useStore } from \"@alepha/react\";\nimport {\n IconLayoutSidebarLeftCollapse,\n IconLayoutSidebarRightCollapse,\n} from \"@tabler/icons-react\";\nimport ActionButton from \"./ActionButton.tsx\";\n\nconst ToggleSidebarButton = () => {\n const [collapsed, setCollapsed] = useStore(\"alepha.ui.sidebar.collapsed\");\n\n return (\n <ActionButton\n icon={\n collapsed ? (\n <IconLayoutSidebarRightCollapse />\n ) : (\n <IconLayoutSidebarLeftCollapse />\n )\n }\n variant={\"subtle\"}\n size={\"md\"}\n onClick={() => setCollapsed(!collapsed)}\n tooltip={{\n position: \"right\",\n label: collapsed ? \"Show sidebar\" : \"Hide sidebar\",\n }}\n />\n );\n};\n\nexport default ToggleSidebarButton;\n","import { NestedView, useRouter } from \"@alepha/react\";\nimport {\n ActionButton,\n AdminShell,\n OmnibarButton,\n ThemeButton,\n} from \"@alepha/ui\";\nimport { UserButton } from \"@alepha/ui/auth\";\nimport { Flex } from \"@mantine/core\";\nimport { IconArrowLeft } from \"@tabler/icons-react\";\nimport ToggleSidebarButton from \"../../core/components/buttons/ToggleSidebarButton.tsx\";\nimport type { AdminRouter } from \"../AdminRouter.ts\";\n\nconst AdminLayout = () => {\n const router = useRouter<AdminRouter>();\n return (\n <AdminShell\n appShellMainProps={{\n bg: \"var(--alepha-surface)\",\n }}\n appShellHeaderProps={{\n bg: \"var(--alepha-background)\",\n }}\n appShellNavbarProps={\n {\n // bg: \"var(--alepha-background)\",\n }\n }\n appShellProps={\n {\n // withBorder: false,\n }\n }\n appShellFooterProps={{\n bg: \"var(--alepha-background)\",\n }}\n footer={<Flex h={12} />}\n appBarProps={{\n items: [\n {\n element: <ActionButton icon={IconArrowLeft} href={\"/\"} />,\n position: \"left\",\n },\n {\n element: <OmnibarButton actionProps={{ variant: \"outline\" }} />,\n position: \"right\",\n },\n {\n element: <UserButton />,\n position: \"right\",\n },\n {\n element: <ThemeButton />,\n position: \"right\",\n },\n {\n type: \"dark\",\n position: \"right\",\n },\n ],\n }}\n sidebarProps={{\n gap: \"xs\",\n menu: [\n {\n element: <ToggleSidebarButton />,\n },\n {\n type: \"spacer\",\n },\n {\n ...router.node(\"adminUsers\"),\n description: undefined,\n },\n {\n ...router.node(\"adminSessions\"),\n description: undefined,\n },\n {\n ...router.node(\"adminNotifications\"),\n description: undefined,\n },\n {\n ...router.node(\"adminFiles\"),\n description: undefined,\n },\n ],\n }}\n >\n <Flex flex={1} bg={\"var(--alepha-surface)\"}>\n <NestedView />\n </Flex>\n </AdminShell>\n );\n};\n\nexport default AdminLayout;\n"],"mappings":";;;;;;;;;;AAAA,MAAa,KAAK;CAChB,QAAQ;EACN,aAAa;EACb,YAAY;EACZ,SAAS;EACT,UAAU;EACV,QAAQ;EACT;CACD,OAAO,EACL,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACL,EACF;CACF;;;;ACo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import { t as AdminLayout_default } from "./AdminLayout-JakF7ESb.js";
2
+
3
+ export { AdminLayout_default as default };
@@ -0,0 +1,154 @@
1
+ import { DataTable, Flex, Text } from "@alepha/ui";
2
+ import { t } from "alepha";
3
+ import { useClient } from "@alepha/react";
4
+ import { IconAlertCircle, IconCheck, IconClock, IconMail, IconMessage } from "@tabler/icons-react";
5
+ import { useI18n } from "@alepha/react/i18n";
6
+ import { Badge, Tooltip } from "@mantine/core";
7
+ import { jsx } from "react/jsx-runtime";
8
+
9
+ //#region src/admin/components/AdminNotifications.tsx
10
+ const AdminNotifications = () => {
11
+ const client = useClient();
12
+ const { l } = useI18n();
13
+ const filters = t.object({
14
+ type: t.optional(t.enum(["email", "sms"], { title: "Type" })),
15
+ status: t.optional(t.enum([
16
+ "pending",
17
+ "sent",
18
+ "failed"
19
+ ], { title: "Status" })),
20
+ template: t.optional(t.string({ title: "Template" })),
21
+ contact: t.optional(t.string({ title: "Contact" }))
22
+ });
23
+ const getStatus = (item) => {
24
+ if (item.error) return "failed";
25
+ if (item.sentAt) return "sent";
26
+ return "pending";
27
+ };
28
+ const getStatusBadge = (item) => {
29
+ switch (getStatus(item)) {
30
+ case "sent": return /* @__PURE__ */ jsx(Badge, {
31
+ size: "sm",
32
+ variant: "light",
33
+ color: "green",
34
+ leftSection: /* @__PURE__ */ jsx(IconCheck, { size: 12 }),
35
+ children: "Sent"
36
+ });
37
+ case "failed": return /* @__PURE__ */ jsx(Tooltip, {
38
+ label: item.error?.message,
39
+ multiline: true,
40
+ maw: 300,
41
+ children: /* @__PURE__ */ jsx(Badge, {
42
+ size: "sm",
43
+ variant: "light",
44
+ color: "red",
45
+ leftSection: /* @__PURE__ */ jsx(IconAlertCircle, { size: 12 }),
46
+ children: "Failed"
47
+ })
48
+ });
49
+ default: return /* @__PURE__ */ jsx(Badge, {
50
+ size: "sm",
51
+ variant: "light",
52
+ color: "yellow",
53
+ leftSection: /* @__PURE__ */ jsx(IconClock, { size: 12 }),
54
+ children: "Pending"
55
+ });
56
+ }
57
+ };
58
+ return /* @__PURE__ */ jsx(Flex, {
59
+ flex: 1,
60
+ direction: "column",
61
+ children: /* @__PURE__ */ jsx(DataTable, {
62
+ submitOnInit: true,
63
+ defaultSize: 10,
64
+ typeFormProps: {
65
+ skipSubmitButton: true,
66
+ columns: 4
67
+ },
68
+ tableProps: {
69
+ horizontalSpacing: "xs",
70
+ verticalSpacing: "xs"
71
+ },
72
+ onFilterChange: (_key, _value, form) => {
73
+ return form.submit();
74
+ },
75
+ filters,
76
+ tableTrProps: (item) => {
77
+ if (getStatus(item) === "failed") return { bg: "var(--mantine-color-red-light)" };
78
+ return {};
79
+ },
80
+ items: async (filters$1) => {
81
+ return await client.findNotifications({ query: filters$1 });
82
+ },
83
+ columns: {
84
+ type: {
85
+ label: "Type",
86
+ fit: true,
87
+ value: (item) => /* @__PURE__ */ jsx(Badge, {
88
+ size: "sm",
89
+ variant: "outline",
90
+ leftSection: item.type === "email" ? /* @__PURE__ */ jsx(IconMail, { size: 12 }) : /* @__PURE__ */ jsx(IconMessage, { size: 12 }),
91
+ children: item.type.toUpperCase()
92
+ })
93
+ },
94
+ template: {
95
+ label: "Template",
96
+ value: (item) => /* @__PURE__ */ jsx(Text, {
97
+ size: "sm",
98
+ fw: 500,
99
+ children: item.template
100
+ })
101
+ },
102
+ contact: {
103
+ label: "Contact",
104
+ value: (item) => /* @__PURE__ */ jsx(Text, {
105
+ size: "sm",
106
+ ff: "monospace",
107
+ children: item.contact
108
+ })
109
+ },
110
+ category: {
111
+ label: "Category",
112
+ fit: true,
113
+ value: (item) => item.category ? /* @__PURE__ */ jsx(Badge, {
114
+ size: "xs",
115
+ variant: "light",
116
+ children: item.category
117
+ }) : /* @__PURE__ */ jsx(Text, {
118
+ size: "xs",
119
+ c: "dimmed",
120
+ children: "-"
121
+ })
122
+ },
123
+ status: {
124
+ label: "Status",
125
+ fit: true,
126
+ value: (item) => getStatusBadge(item)
127
+ },
128
+ sentAt: {
129
+ label: "Sent",
130
+ fit: true,
131
+ value: (item) => /* @__PURE__ */ jsx(Text, {
132
+ size: "xs",
133
+ c: "dimmed",
134
+ children: item.sentAt ? l(item.sentAt, { date: "fromNow" }) : "-"
135
+ })
136
+ },
137
+ createdAt: {
138
+ label: "Created",
139
+ fit: true,
140
+ value: (item) => /* @__PURE__ */ jsx(Text, {
141
+ size: "xs",
142
+ c: "dimmed",
143
+ children: l(item.createdAt, { date: "fromNow" })
144
+ })
145
+ }
146
+ }
147
+ })
148
+ });
149
+ };
150
+ var AdminNotifications_default = AdminNotifications;
151
+
152
+ //#endregion
153
+ export { AdminNotifications_default as t };
154
+ //# sourceMappingURL=AdminNotifications-BPrxALdS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdminNotifications-BPrxALdS.js","names":["filters"],"sources":["../../src/admin/components/AdminNotifications.tsx"],"sourcesContent":["import { useClient } from \"@alepha/react\";\nimport { useI18n } from \"@alepha/react/i18n\";\nimport { DataTable, Flex, Text } from \"@alepha/ui\";\nimport { Badge, Tooltip } from \"@mantine/core\";\nimport {\n IconAlertCircle,\n IconCheck,\n IconClock,\n IconMail,\n IconMessage,\n} from \"@tabler/icons-react\";\nimport { type Page, t } from \"alepha\";\nimport type {\n NotificationController,\n NotificationEntity,\n} from \"alepha/api/notifications\";\n\nconst AdminNotifications = () => {\n const client = useClient<NotificationController>();\n const { l } = useI18n();\n\n const filters = t.object({\n type: t.optional(\n t.enum([\"email\", \"sms\"], {\n title: \"Type\",\n }),\n ),\n status: t.optional(\n t.enum([\"pending\", \"sent\", \"failed\"], {\n title: \"Status\",\n }),\n ),\n template: t.optional(\n t.string({\n title: \"Template\",\n }),\n ),\n contact: t.optional(\n t.string({\n title: \"Contact\",\n }),\n ),\n });\n\n const getStatus = (item: NotificationEntity) => {\n if (item.error) return \"failed\";\n if (item.sentAt) return \"sent\";\n return \"pending\";\n };\n\n const getStatusBadge = (item: NotificationEntity) => {\n const status = getStatus(item);\n switch (status) {\n case \"sent\":\n return (\n <Badge\n size=\"sm\"\n variant=\"light\"\n color=\"green\"\n leftSection={<IconCheck size={12} />}\n >\n Sent\n </Badge>\n );\n case \"failed\":\n return (\n <Tooltip label={item.error?.message} multiline maw={300}>\n <Badge\n size=\"sm\"\n variant=\"light\"\n color=\"red\"\n leftSection={<IconAlertCircle size={12} />}\n >\n Failed\n </Badge>\n </Tooltip>\n );\n default:\n return (\n <Badge\n size=\"sm\"\n variant=\"light\"\n color=\"yellow\"\n leftSection={<IconClock size={12} />}\n >\n Pending\n </Badge>\n );\n }\n };\n\n return (\n <Flex flex={1} direction=\"column\">\n <DataTable<NotificationEntity, typeof filters>\n submitOnInit\n defaultSize={10}\n typeFormProps={{\n skipSubmitButton: true,\n columns: 4,\n }}\n tableProps={{\n horizontalSpacing: \"xs\",\n verticalSpacing: \"xs\",\n }}\n onFilterChange={(_key, _value, form) => {\n return form.submit();\n }}\n filters={filters}\n tableTrProps={(item) => {\n const status = getStatus(item);\n if (status === \"failed\") {\n return {\n bg: \"var(--mantine-color-red-light)\",\n };\n }\n return {};\n }}\n items={async (filters) => {\n const response = await client.findNotifications({\n query: filters,\n });\n\n return response as Page<NotificationEntity>;\n }}\n columns={{\n type: {\n label: \"Type\",\n fit: true,\n value: (item) => (\n <Badge\n size=\"sm\"\n variant=\"outline\"\n leftSection={\n item.type === \"email\" ? (\n <IconMail size={12} />\n ) : (\n <IconMessage size={12} />\n )\n }\n >\n {item.type.toUpperCase()}\n </Badge>\n ),\n },\n template: {\n label: \"Template\",\n value: (item) => (\n <Text size=\"sm\" fw={500}>\n {item.template}\n </Text>\n ),\n },\n contact: {\n label: \"Contact\",\n value: (item) => (\n <Text size=\"sm\" ff=\"monospace\">\n {item.contact}\n </Text>\n ),\n },\n category: {\n label: \"Category\",\n fit: true,\n value: (item) =>\n item.category ? (\n <Badge size=\"xs\" variant=\"light\">\n {item.category}\n </Badge>\n ) : (\n <Text size=\"xs\" c=\"dimmed\">\n -\n </Text>\n ),\n },\n status: {\n label: \"Status\",\n fit: true,\n value: (item) => getStatusBadge(item),\n },\n sentAt: {\n label: \"Sent\",\n fit: true,\n value: (item) => (\n <Text size=\"xs\" c=\"dimmed\">\n {item.sentAt ? l(item.sentAt, { date: \"fromNow\" }) : \"-\"}\n </Text>\n ),\n },\n createdAt: {\n label: \"Created\",\n fit: true,\n value: (item) => (\n <Text size=\"xs\" c=\"dimmed\">\n {l(item.createdAt, { date: \"fromNow\" })}\n </Text>\n ),\n },\n }}\n />\n </Flex>\n );\n};\n\nexport default AdminNotifications;\n"],"mappings":";;;;;;;;;AAiBA,MAAM,2BAA2B;CAC/B,MAAM,SAAS,WAAmC;CAClD,MAAM,EAAE,MAAM,SAAS;CAEvB,MAAM,UAAU,EAAE,OAAO;EACvB,MAAM,EAAE,SACN,EAAE,KAAK,CAAC,SAAS,MAAM,EAAE,EACvB,OAAO,QACR,CAAC,CACH;EACD,QAAQ,EAAE,SACR,EAAE,KAAK;GAAC;GAAW;GAAQ;GAAS,EAAE,EACpC,OAAO,UACR,CAAC,CACH;EACD,UAAU,EAAE,SACV,EAAE,OAAO,EACP,OAAO,YACR,CAAC,CACH;EACD,SAAS,EAAE,SACT,EAAE,OAAO,EACP,OAAO,WACR,CAAC,CACH;EACF,CAAC;CAEF,MAAM,aAAa,SAA6B;AAC9C,MAAI,KAAK,MAAO,QAAO;AACvB,MAAI,KAAK,OAAQ,QAAO;AACxB,SAAO;;CAGT,MAAM,kBAAkB,SAA6B;AAEnD,UADe,UAAU,KAAK,EAC9B;GACE,KAAK,OACH,QACE,oBAAC;IACC,MAAK;IACL,SAAQ;IACR,OAAM;IACN,aAAa,oBAAC,aAAU,MAAM,KAAM;cACrC;KAEO;GAEZ,KAAK,SACH,QACE,oBAAC;IAAQ,OAAO,KAAK,OAAO;IAAS;IAAU,KAAK;cAClD,oBAAC;KACC,MAAK;KACL,SAAQ;KACR,OAAM;KACN,aAAa,oBAAC,mBAAgB,MAAM,KAAM;eAC3C;MAEO;KACA;GAEd,QACE,QACE,o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S,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC,GAAG;OAChD;KAEV;IACD,WAAW;KACT,OAAO;KACP,KAAK;KACL,QAAQ,SACN,oBAAC;MAAK,MAAK;MAAK,GAAE;gBACf,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;OAClC;KAEV;IACF;IACD;GACG;;AAIX,iCAAe"}
@@ -0,0 +1,3 @@
1
+ import { t as AdminNotifications_default } from "./AdminNotifications-BPrxALdS.js";
2
+
3
+ export { AdminNotifications_default as default };