@alepha/ui 0.25.0

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 (136) hide show
  1. package/README.md +12 -0
  2. package/components.json +20 -0
  3. package/package.json +85 -0
  4. package/src/components/action-error-toaster/action-error-toaster.tsx +70 -0
  5. package/src/components/admin/admin-audits.tsx +247 -0
  6. package/src/components/admin/admin-files.tsx +346 -0
  7. package/src/components/admin/admin-jobs-executions-panel.tsx +235 -0
  8. package/src/components/admin/admin-jobs-status-badge.tsx +33 -0
  9. package/src/components/admin/admin-jobs.tsx +294 -0
  10. package/src/components/admin/admin-keys.tsx +162 -0
  11. package/src/components/admin/admin-notifications.tsx +130 -0
  12. package/src/components/admin/admin-page.tsx +24 -0
  13. package/src/components/admin/admin-parameters.tsx +864 -0
  14. package/src/components/admin/admin-payments.tsx +93 -0
  15. package/src/components/admin/admin-sessions.tsx +174 -0
  16. package/src/components/admin/admin-user-detail-audits-tab.tsx +82 -0
  17. package/src/components/admin/admin-user-detail-identity-aside.tsx +218 -0
  18. package/src/components/admin/admin-user-detail-overview-tab.tsx +87 -0
  19. package/src/components/admin/admin-user-detail-password-dialog.tsx +85 -0
  20. package/src/components/admin/admin-user-detail-password-schema.ts +11 -0
  21. package/src/components/admin/admin-user-detail-profile-schema.ts +19 -0
  22. package/src/components/admin/admin-user-detail-provider-labels.ts +15 -0
  23. package/src/components/admin/admin-user-detail-security-tab.tsx +146 -0
  24. package/src/components/admin/admin-user-detail-sessions-tab.tsx +93 -0
  25. package/src/components/admin/admin-user-detail.tsx +606 -0
  26. package/src/components/admin/admin-users-roles-picker.tsx +126 -0
  27. package/src/components/admin/admin-users-status-filter.tsx +51 -0
  28. package/src/components/admin/admin-users.tsx +518 -0
  29. package/src/components/admin/diff-lines.spec.ts +58 -0
  30. package/src/components/admin/diff-lines.ts +58 -0
  31. package/src/components/admin/parameter-diff-dialog.tsx +119 -0
  32. package/src/components/admin/parameter-history-item.tsx +252 -0
  33. package/src/components/admin/parameter-json-dialog.tsx +93 -0
  34. package/src/components/admin/parameter-save-dialog.tsx +126 -0
  35. package/src/components/admin/use-confirmed-action.tsx +93 -0
  36. package/src/components/alepha-table/__tests__/use-table-selection.browser.spec.tsx +92 -0
  37. package/src/components/alepha-table/alepha-table.tsx +1158 -0
  38. package/src/components/alepha-table/use-table-selection.ts +95 -0
  39. package/src/components/app-shell/app-shell.tsx +568 -0
  40. package/src/components/auth/__tests__/auth-router.spec.ts +52 -0
  41. package/src/components/auth/auth-login.tsx +382 -0
  42. package/src/components/auth/auth-register.tsx +786 -0
  43. package/src/components/auth/auth-reset-password.tsx +349 -0
  44. package/src/components/auth/auth-router.tsx +126 -0
  45. package/src/components/auth/auth-verify-email.tsx +179 -0
  46. package/src/components/auto-form/auto-form.tsx +867 -0
  47. package/src/components/brand-icon/brand-icon.tsx +104 -0
  48. package/src/components/button-dark/button-dark.tsx +78 -0
  49. package/src/components/button-language/button-language.tsx +98 -0
  50. package/src/components/button-theme/button-theme.tsx +148 -0
  51. package/src/components/button-user/button-user.tsx +214 -0
  52. package/src/components/captcha/turnstile-widget.tsx +157 -0
  53. package/src/components/control/control.tsx +735 -0
  54. package/src/components/control-array/control-array.tsx +700 -0
  55. package/src/components/control-base/__tests__/form-field-a11y.browser.spec.tsx +93 -0
  56. package/src/components/control-base/field-i18n.ts +60 -0
  57. package/src/components/control-base/form-field.tsx +275 -0
  58. package/src/components/control-base/grid.tsx +59 -0
  59. package/src/components/control-base/icon-hint.tsx +64 -0
  60. package/src/components/control-date/control-date.tsx +190 -0
  61. package/src/components/control-number/control-number.tsx +136 -0
  62. package/src/components/control-object/control-object.tsx +200 -0
  63. package/src/components/control-select/control-select.tsx +774 -0
  64. package/src/components/control-upload/control-upload.tsx +475 -0
  65. package/src/components/file-image/file-image.tsx +52 -0
  66. package/src/components/language-toggle/language-toggle.tsx +66 -0
  67. package/src/components/markdown-view/markdown-view.css +114 -0
  68. package/src/components/markdown-view/markdown-view.tsx +92 -0
  69. package/src/components/nav-shell/nav-page.tsx +56 -0
  70. package/src/components/nav-shell/nav-shell.tsx +72 -0
  71. package/src/components/nav-shell/nav-tree-util.ts +62 -0
  72. package/src/components/nav-shell/spotlight.tsx +163 -0
  73. package/src/components/nav-shell/use-nav-breadcrumbs.ts +52 -0
  74. package/src/components/nav-shell/use-nav-entries.ts +101 -0
  75. package/src/components/nav-shell/use-nav-tree.ts +61 -0
  76. package/src/components/ui/accordion.tsx +77 -0
  77. package/src/components/ui/alert-dialog.tsx +186 -0
  78. package/src/components/ui/alert.tsx +75 -0
  79. package/src/components/ui/aspect-ratio.tsx +22 -0
  80. package/src/components/ui/avatar.tsx +106 -0
  81. package/src/components/ui/badge.tsx +51 -0
  82. package/src/components/ui/breadcrumb.tsx +121 -0
  83. package/src/components/ui/button-group.tsx +86 -0
  84. package/src/components/ui/button.tsx +83 -0
  85. package/src/components/ui/calendar.tsx +235 -0
  86. package/src/components/ui/card.tsx +102 -0
  87. package/src/components/ui/carousel.tsx +241 -0
  88. package/src/components/ui/chart.tsx +370 -0
  89. package/src/components/ui/checkbox.tsx +27 -0
  90. package/src/components/ui/collapsible.tsx +19 -0
  91. package/src/components/ui/combobox.tsx +298 -0
  92. package/src/components/ui/command.tsx +196 -0
  93. package/src/components/ui/context-menu.tsx +271 -0
  94. package/src/components/ui/dialog.tsx +153 -0
  95. package/src/components/ui/direction.tsx +4 -0
  96. package/src/components/ui/drawer.tsx +130 -0
  97. package/src/components/ui/dropdown-menu.tsx +269 -0
  98. package/src/components/ui/empty.tsx +100 -0
  99. package/src/components/ui/hover-card.tsx +50 -0
  100. package/src/components/ui/input-group.tsx +157 -0
  101. package/src/components/ui/input-otp.tsx +83 -0
  102. package/src/components/ui/input.tsx +19 -0
  103. package/src/components/ui/item.tsx +200 -0
  104. package/src/components/ui/kbd.tsx +26 -0
  105. package/src/components/ui/label.tsx +19 -0
  106. package/src/components/ui/menubar.tsx +283 -0
  107. package/src/components/ui/navigation-menu.tsx +170 -0
  108. package/src/components/ui/pagination.tsx +133 -0
  109. package/src/components/ui/popover.tsx +87 -0
  110. package/src/components/ui/progress.tsx +82 -0
  111. package/src/components/ui/radio-group.tsx +35 -0
  112. package/src/components/ui/resizable.tsx +49 -0
  113. package/src/components/ui/scroll-area.tsx +51 -0
  114. package/src/components/ui/segmented.tsx +232 -0
  115. package/src/components/ui/select.tsx +201 -0
  116. package/src/components/ui/separator.tsx +22 -0
  117. package/src/components/ui/sheet.tsx +133 -0
  118. package/src/components/ui/sidebar.tsx +723 -0
  119. package/src/components/ui/skeleton.tsx +13 -0
  120. package/src/components/ui/slider.tsx +51 -0
  121. package/src/components/ui/sonner.tsx +46 -0
  122. package/src/components/ui/spinner.tsx +15 -0
  123. package/src/components/ui/switch.tsx +29 -0
  124. package/src/components/ui/table.tsx +115 -0
  125. package/src/components/ui/tabs.tsx +79 -0
  126. package/src/components/ui/textarea.tsx +17 -0
  127. package/src/components/ui/toggle-group.tsx +86 -0
  128. package/src/components/ui/toggle.tsx +44 -0
  129. package/src/components/ui/tooltip.tsx +63 -0
  130. package/src/components/use-dialog/use-dialog.tsx +244 -0
  131. package/src/components/use-toast/use-toast.tsx +89 -0
  132. package/src/hooks/use-mobile.ts +21 -0
  133. package/src/lib/__tests__/i18n-fr.spec.ts +72 -0
  134. package/src/lib/i18n-fr.ts +500 -0
  135. package/src/lib/utils.ts +6 -0
  136. package/src/styles.css +129 -0
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # Alepha @alepha/ui
2
+
3
+ Shared shadcn Base UI Nova components for Alepha apps. Edited directly; bugfixes propagate via normal dep updates.
4
+
5
+ ## Installation
6
+
7
+ This package is part of the Alepha framework and can be installed via the all-in-one package:
8
+
9
+ ```bash
10
+ npm install alepha
11
+ ```
12
+
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "base-nova",
4
+ "rsc": false,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "src/styles.css",
9
+ "baseColor": "neutral",
10
+ "cssVariables": true
11
+ },
12
+ "aliases": {
13
+ "components": "@alepha/ui/components",
14
+ "utils": "@alepha/ui/lib/utils",
15
+ "ui": "@alepha/ui/components/ui",
16
+ "lib": "@alepha/ui/lib",
17
+ "hooks": "@alepha/ui/hooks"
18
+ },
19
+ "iconLibrary": "lucide"
20
+ }
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@alepha/ui",
3
+ "description": "Shared shadcn Base UI Nova components for Alepha apps. Edited directly; bugfixes propagate via normal dep updates.",
4
+ "keywords": [
5
+ "alepha",
6
+ "ui",
7
+ "shadcn",
8
+ "base-ui",
9
+ "react",
10
+ "tailwind"
11
+ ],
12
+ "author": "Feunard",
13
+ "version": "0.25.0",
14
+ "type": "module",
15
+ "engines": {
16
+ "node": ">=22.0.0"
17
+ },
18
+ "license": "MIT",
19
+ "homepage": "https://github.com/feunard/alepha",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/feunard/alepha.git"
23
+ },
24
+ "files": [
25
+ "src",
26
+ "components.json"
27
+ ],
28
+ "scripts": {
29
+ "sync": "node scripts/sync.mjs",
30
+ "typecheck": "tsc --noEmit"
31
+ },
32
+ "exports": {
33
+ "./components/*": "./src/components/*.tsx",
34
+ "./hooks/*": "./src/hooks/*.ts",
35
+ "./lib/*": "./src/lib/*.ts",
36
+ "./styles.css": "./src/styles.css"
37
+ },
38
+ "dependencies": {
39
+ "@base-ui/react": "^1.6.0",
40
+ "@fontsource-variable/inter": "^5.3.0",
41
+ "@fontsource-variable/jetbrains-mono": "^5.3.0",
42
+ "class-variance-authority": "^0.7.1",
43
+ "clsx": "^2.1.1",
44
+ "cmdk": "^1.1.1",
45
+ "date-fns": "^4.4.0",
46
+ "embla-carousel-react": "^8.6.0",
47
+ "highlight.js": "^11.11.1",
48
+ "input-otp": "^1.4.2",
49
+ "lucide-react": "^1.28.0",
50
+ "react-day-picker": "^10.0.1",
51
+ "react-is": "^19.2.8",
52
+ "react-markdown": "^10.1.0",
53
+ "react-resizable-panels": "^4.12.2",
54
+ "recharts": "3.10.1",
55
+ "rehype-highlight": "^7.0.2",
56
+ "remark-gfm": "^4.0.1",
57
+ "shadcn": "^4.16.1",
58
+ "sonner": "^2.0.7",
59
+ "tailwind-merge": "^3.6.0",
60
+ "tw-animate-css": "^1.4.0",
61
+ "vaul": "^1.1.2"
62
+ },
63
+ "peerDependencies": {
64
+ "alepha": "0.25.0",
65
+ "react": "*",
66
+ "react-dom": "*",
67
+ "recharts": "^3",
68
+ "tailwindcss": "^4"
69
+ },
70
+ "peerDependenciesMeta": {
71
+ "tailwindcss": {
72
+ "optional": true
73
+ }
74
+ },
75
+ "devDependencies": {
76
+ "@biomejs/biome": "^2.5.6",
77
+ "@testing-library/dom": "^10.4.1",
78
+ "@testing-library/react": "^16.3.2",
79
+ "@types/react": "^19.2.18",
80
+ "alepha": "0.25.0",
81
+ "react": "^19.2.8",
82
+ "react-dom": "^19.2.8",
83
+ "typescript": "^7.0.2"
84
+ }
85
+ }
@@ -0,0 +1,70 @@
1
+ import * as React from "react";
2
+
3
+ void React;
4
+
5
+ import { useToast } from "@alepha/ui/components/use-toast/use-toast";
6
+ import { useEvents } from "alepha/react";
7
+
8
+ export interface ActionErrorToasterProps {
9
+ /**
10
+ * Disable the toaster without unmounting it. Default: enabled.
11
+ */
12
+ enabled?: boolean;
13
+ /**
14
+ * Map an action error to the toast message. Defaults to `error.message`.
15
+ */
16
+ format?: (error: Error, event: ActionErrorEvent) => string;
17
+ /**
18
+ * Return `false` to skip toasting a given error (e.g. a validation error
19
+ * already shown inline). Defaults to toasting every error.
20
+ */
21
+ filter?: (error: Error, event: ActionErrorEvent) => boolean;
22
+ /**
23
+ * Auto-dismiss delay in ms, forwarded to the toast.
24
+ */
25
+ duration?: number;
26
+ }
27
+
28
+ interface ActionErrorEvent {
29
+ id?: string;
30
+ error?: Error;
31
+ }
32
+
33
+ /**
34
+ * Behaviour-only component (renders nothing): subscribes to the
35
+ * `react:action:error` event that every `useAction` / `useQuery` emits on
36
+ * failure and surfaces it as a single toast.
37
+ *
38
+ * This is the "one toast for all" centraliser — with it mounted, call sites no
39
+ * longer need their own `try/catch + toast.error` around every mutation; an
40
+ * unhandled action error becomes a toast automatically.
41
+ *
42
+ * Mounted by default inside {@link AppShell}; opt out with
43
+ * `actionErrorToaster={false}` or pass an options object to configure it.
44
+ * Requires a `<Toaster />` in the tree (AppShell mounts one).
45
+ */
46
+ export const ActionErrorToaster = (props: ActionErrorToasterProps) => {
47
+ const toast = useToast();
48
+ const enabled = props.enabled ?? true;
49
+
50
+ useEvents(
51
+ {
52
+ "react:action:error": (event: ActionErrorEvent) => {
53
+ if (!enabled) return;
54
+ const error = event.error;
55
+ if (!error) return;
56
+ if (props.filter && !props.filter(error, event)) return;
57
+ const message = props.format
58
+ ? props.format(error, event)
59
+ : error.message;
60
+ toast.error(
61
+ message,
62
+ props.duration ? { duration: props.duration } : undefined,
63
+ );
64
+ },
65
+ },
66
+ [enabled, toast, props.format, props.filter, props.duration],
67
+ );
68
+
69
+ return null;
70
+ };
@@ -0,0 +1,247 @@
1
+ import * as React from "react";
2
+
3
+ void React;
4
+
5
+ import { AdminPage } from "@alepha/ui/components/admin/admin-page";
6
+ import { useConfirmedAction } from "@alepha/ui/components/admin/use-confirmed-action";
7
+ import { AlephaTable } from "@alepha/ui/components/alepha-table/alepha-table";
8
+ import { Control } from "@alepha/ui/components/control/control";
9
+ import { Badge } from "@alepha/ui/components/ui/badge";
10
+ import { useToast } from "@alepha/ui/components/use-toast/use-toast";
11
+ import { type Infer, z } from "alepha";
12
+ import type { AdminAuditController, AuditEntity } from "alepha/api/audits";
13
+ import { useClient } from "alepha/react";
14
+ import { useI18n } from "alepha/react/i18n";
15
+ import { useRouter } from "alepha/react/router";
16
+ import { SlidersHorizontal, Trash2, User } from "lucide-react";
17
+ import { useCallback, useEffect, useState } from "react";
18
+
19
+ const auditFiltersSchema = z.object({
20
+ status: z.string().optional(),
21
+ action: z.string().optional(),
22
+ });
23
+ type AuditFilters = Infer<typeof auditFiltersSchema>;
24
+
25
+ export function AdminAudits() {
26
+ const client = useClient<AdminAuditController>();
27
+ const toast = useToast();
28
+ const router = useRouter();
29
+ const { l, tr } = useI18n();
30
+
31
+ const [actions, setActions] = useState<string[]>([]);
32
+
33
+ useEffect(() => {
34
+ let alive = true;
35
+ client
36
+ .getAuditActions()
37
+ .then((rows) => {
38
+ if (!alive) return;
39
+ setActions(rows);
40
+ })
41
+ .catch(() => {});
42
+ return () => {
43
+ alive = false;
44
+ };
45
+ }, [client]);
46
+
47
+ const fetcher = useCallback(
48
+ async (params: {
49
+ page: number;
50
+ size: number;
51
+ sort?: string;
52
+ filters?: AuditFilters;
53
+ }) => {
54
+ const f = params.filters;
55
+ return client.findAudits({
56
+ query: {
57
+ page: params.page,
58
+ size: params.size,
59
+ sort: params.sort,
60
+ action: f?.action || undefined,
61
+ success: f?.status ? f.status === "ok" : undefined,
62
+ },
63
+ });
64
+ },
65
+ [client],
66
+ );
67
+
68
+ const bulkDelete = useConfirmedAction<
69
+ [AuditEntity[], { clearSelection: () => void; refresh: () => void }]
70
+ >(
71
+ {
72
+ confirm: (items) => ({
73
+ title: tr("admin.audits.bulkDeleteTitle", {
74
+ default: "Delete audit entries",
75
+ }),
76
+ description: tr("admin.audits.bulkDeleteConfirm", {
77
+ default: `Delete ${items.length} audit record(s)? Audit logs are usually retained for compliance — this cannot be undone.`,
78
+ args: [String(items.length)],
79
+ }),
80
+ destructive: true,
81
+ }),
82
+ handler: async (items, ctx) => {
83
+ if (items.length === 0) return;
84
+ const res = await client.deleteAudits({
85
+ body: { ids: items.map((a) => a.id) },
86
+ });
87
+ toast.success(
88
+ tr("admin.audits.bulkDeleted", {
89
+ default: `${res.deleted.length} audit(s) deleted`,
90
+ args: [String(res.deleted.length)],
91
+ }),
92
+ );
93
+ ctx.clearSelection();
94
+ ctx.refresh();
95
+ },
96
+ },
97
+ [client, toast, tr],
98
+ );
99
+
100
+ // A resource rendered as an icon + label that links to its admin page.
101
+ const resourceLink = (href: string, icon: React.ReactNode, label: string) => (
102
+ <button
103
+ type="button"
104
+ title={label}
105
+ onClick={() => router.push(href as never)}
106
+ className="hover:text-primary inline-flex items-center gap-1.5 truncate text-left text-xs underline-offset-2 hover:underline"
107
+ >
108
+ {icon}
109
+ <span className="truncate">{label}</span>
110
+ </button>
111
+ );
112
+
113
+ return (
114
+ <AdminPage>
115
+ <AlephaTable<AuditEntity>
116
+ className="min-h-0 flex-1"
117
+ persistenceKey="admin.audits"
118
+ fetch={fetcher}
119
+ bulkActions={[
120
+ {
121
+ label: tr("admin.audits.bulkDelete", {
122
+ default: "Delete selected",
123
+ }),
124
+ icon: Trash2,
125
+ destructive: true,
126
+ onClick: (items, ctx) => bulkDelete.run(items, ctx),
127
+ },
128
+ ]}
129
+ filters={{
130
+ schema: auditFiltersSchema,
131
+ render: (form) => (
132
+ <div className="flex items-center gap-2">
133
+ <Control
134
+ input={form.input.status}
135
+ label=""
136
+ clearable
137
+ clearLabel={String(
138
+ tr("admin.audits.statusAll", { default: "All status" }),
139
+ )}
140
+ triggerClassName="w-40"
141
+ items={[
142
+ {
143
+ value: "ok",
144
+ label: tr("admin.audits.ok", { default: "OK" }),
145
+ },
146
+ {
147
+ value: "failed",
148
+ label: String(
149
+ tr("admin.audits.failed", { default: "Failed" }),
150
+ ),
151
+ },
152
+ ]}
153
+ />
154
+ <Control
155
+ input={form.input.action}
156
+ label=""
157
+ clearable
158
+ clearLabel={String(
159
+ tr("admin.audits.actionAll", { default: "All actions" }),
160
+ )}
161
+ triggerClassName="w-48"
162
+ items={actions.map((action) => ({
163
+ value: action,
164
+ label: action,
165
+ }))}
166
+ />
167
+ </div>
168
+ ),
169
+ }}
170
+ columns={{
171
+ createdAt: {
172
+ label: tr("admin.audits.colWhen", { default: "When" }),
173
+ sortable: true,
174
+ cell: (a) => (
175
+ <span className="text-muted-foreground text-xs">
176
+ {String(l(a.createdAt, { date: "fromNow" }))}
177
+ </span>
178
+ ),
179
+ },
180
+ action: {
181
+ label: tr("admin.audits.colAction", { default: "Action" }),
182
+ cell: (a) => (
183
+ <code className="text-xs font-medium">
184
+ {a.type}:{a.action}
185
+ </code>
186
+ ),
187
+ },
188
+ resource: {
189
+ label: tr("admin.audits.colResource", { default: "Resource" }),
190
+ cell: (a) => {
191
+ if (a.resourceType === "parameter" && a.resourceId) {
192
+ return resourceLink(
193
+ `/admin/parameters?param=${encodeURIComponent(a.resourceId)}`,
194
+ <SlidersHorizontal className="size-3.5 shrink-0" />,
195
+ a.resourceId,
196
+ );
197
+ }
198
+ if (a.resourceType === "user" && a.resourceId) {
199
+ return resourceLink(
200
+ `/admin/users/${a.resourceId}`,
201
+ <User className="size-3.5 shrink-0" />,
202
+ a.resourceId,
203
+ );
204
+ }
205
+ return (
206
+ <span className="font-mono text-xs">
207
+ {a.resourceType
208
+ ? `${a.resourceType}:${a.resourceId ?? "—"}`
209
+ : "—"}
210
+ </span>
211
+ );
212
+ },
213
+ },
214
+ actor: {
215
+ label: tr("admin.audits.colActor", { default: "Actor" }),
216
+ cell: (a) =>
217
+ a.userId ? (
218
+ <button
219
+ type="button"
220
+ onClick={() =>
221
+ router.push(`/admin/users/${a.userId}` as never)
222
+ }
223
+ className="hover:text-primary truncate text-left text-sm underline-offset-2 hover:underline"
224
+ >
225
+ {a.userEmail ?? a.userId}
226
+ </button>
227
+ ) : (
228
+ <span className="text-sm">{a.userEmail ?? "—"}</span>
229
+ ),
230
+ },
231
+ status: {
232
+ label: tr("admin.audits.colStatus", { default: "Status" }),
233
+ cell: (a) => (
234
+ <Badge variant={a.success ? "default" : "destructive"}>
235
+ {a.success
236
+ ? tr("admin.audits.ok", { default: "OK" })
237
+ : tr("admin.audits.failed", { default: "Failed" })}
238
+ </Badge>
239
+ ),
240
+ },
241
+ }}
242
+ />
243
+ </AdminPage>
244
+ );
245
+ }
246
+
247
+ export default AdminAudits;