@alepha/ui 0.25.0 → 0.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/package.json +4 -5
  2. package/src/components/account/__tests__/account-router.spec.ts +201 -0
  3. package/src/components/account/account-connections.tsx +103 -0
  4. package/src/components/account/account-delete-dialog.tsx +184 -0
  5. package/src/components/account/account-header.tsx +57 -0
  6. package/src/components/account/account-keys.tsx +221 -0
  7. package/src/components/account/account-layout.tsx +63 -0
  8. package/src/components/account/account-password-dialog.tsx +152 -0
  9. package/src/components/account/account-profile.tsx +229 -0
  10. package/src/components/account/account-router-options.tsx +74 -0
  11. package/src/components/account/account-router-page.tsx +69 -0
  12. package/src/components/account/account-router.tsx +214 -0
  13. package/src/components/account/account-security.tsx +150 -0
  14. package/src/components/account/account-sessions.tsx +140 -0
  15. package/src/components/admin/__tests__/admin-keys-token-dialog.browser.spec.tsx +62 -0
  16. package/src/components/admin/__tests__/admin-layout.browser.spec.tsx +82 -0
  17. package/src/components/admin/__tests__/admin-router-page.spec.ts +54 -0
  18. package/src/components/admin/__tests__/admin-router.spec.ts +208 -0
  19. package/src/components/admin/__tests__/admin-user-cell.browser.spec.tsx +99 -0
  20. package/src/components/admin/__tests__/admin-user-detail.spec.ts +29 -0
  21. package/src/components/admin/admin-analytics-query-panel.tsx +149 -0
  22. package/src/components/admin/admin-analytics-results.tsx +95 -0
  23. package/src/components/admin/admin-analytics.tsx +104 -0
  24. package/src/components/admin/admin-audits.tsx +12 -15
  25. package/src/components/admin/admin-files.tsx +10 -18
  26. package/src/components/admin/admin-jobs-executions-panel.tsx +2 -1
  27. package/src/components/admin/admin-jobs.tsx +3 -1
  28. package/src/components/admin/admin-keys-token-dialog.tsx +123 -0
  29. package/src/components/admin/admin-keys.tsx +54 -3
  30. package/src/components/admin/admin-layout.tsx +107 -0
  31. package/src/components/admin/admin-payments.tsx +4 -5
  32. package/src/components/admin/admin-router-options.tsx +130 -0
  33. package/src/components/admin/admin-router-page.tsx +74 -0
  34. package/src/components/admin/admin-router.tsx +379 -0
  35. package/src/components/admin/admin-sessions.tsx +2 -16
  36. package/src/components/admin/admin-user-cell.tsx +70 -0
  37. package/src/components/admin/admin-user-detail-overview-tab.tsx +28 -0
  38. package/src/components/admin/admin-user-detail-profile-policy.spec.ts +146 -0
  39. package/src/components/admin/admin-user-detail-profile-policy.ts +147 -0
  40. package/src/components/admin/admin-user-detail-security-tab.tsx +1 -1
  41. package/src/components/admin/admin-user-detail.tsx +76 -32
  42. package/src/components/admin/admin-users-status-filter.tsx +2 -0
  43. package/src/components/admin/admin-workflows-execution-sheet.tsx +277 -0
  44. package/src/components/admin/admin-workflows-executions-panel.tsx +170 -0
  45. package/src/components/admin/admin-workflows-status-badge.tsx +40 -0
  46. package/src/components/admin/admin-workflows.tsx +207 -0
  47. package/src/components/alepha-table/alepha-table.tsx +73 -17
  48. package/src/components/app-actions/__tests__/app-actions.browser.spec.tsx +79 -0
  49. package/src/components/app-actions/app-actions.tsx +113 -0
  50. package/src/components/app-shell/app-shell.tsx +122 -0
  51. package/src/components/auth/auth-reset-password.tsx +81 -8
  52. package/src/components/button-user/button-user.tsx +58 -1
  53. package/src/components/control/control.tsx +14 -71
  54. package/src/components/control-password/control-password.tsx +87 -0
  55. package/src/components/control-select/__tests__/control-select-clear-label.browser.spec.tsx +101 -0
  56. package/src/components/control-select/__tests__/control-select-deselect.browser.spec.tsx +126 -0
  57. package/src/components/control-select/__tests__/control-select-searchable.browser.spec.tsx +142 -0
  58. package/src/components/control-select/control-select.tsx +133 -111
  59. package/src/components/control-upload/control-upload.tsx +27 -1
  60. package/src/components/markdown-view/markdown-view.tsx +6 -0
  61. package/src/components/nav-shell/nav-page.tsx +3 -3
  62. package/src/components/settings/__tests__/settings-nav.browser.spec.tsx +123 -0
  63. package/src/components/settings/__tests__/settings-section.browser.spec.tsx +130 -0
  64. package/src/components/settings/settings-danger-section.tsx +59 -0
  65. package/src/components/settings/settings-layout.tsx +56 -0
  66. package/src/components/settings/settings-nav.tsx +131 -0
  67. package/src/components/settings/settings-row.tsx +81 -0
  68. package/src/components/settings/settings-section.tsx +64 -0
  69. package/src/components/ui/alert-dialog.tsx +1 -1
  70. package/src/components/ui/avatar.tsx +2 -0
  71. package/src/components/ui/breadcrumb.tsx +1 -1
  72. package/src/components/ui/calendar.tsx +11 -6
  73. package/src/components/ui/card.tsx +5 -5
  74. package/src/components/ui/carousel.tsx +4 -4
  75. package/src/components/ui/chart.tsx +2 -0
  76. package/src/components/ui/collapsible.tsx +2 -0
  77. package/src/components/ui/combobox.tsx +3 -1
  78. package/src/components/ui/context-menu.tsx +3 -3
  79. package/src/components/ui/dialog.tsx +6 -1
  80. package/src/components/ui/direction.tsx +2 -0
  81. package/src/components/ui/drawer.tsx +134 -37
  82. package/src/components/ui/dropdown-menu.tsx +13 -3
  83. package/src/components/ui/empty.tsx +4 -1
  84. package/src/components/ui/input-otp.tsx +2 -0
  85. package/src/components/ui/menubar.tsx +2 -2
  86. package/src/components/ui/pagination.tsx +2 -2
  87. package/src/components/ui/popover.tsx +2 -0
  88. package/src/components/ui/radio-group.tsx +2 -0
  89. package/src/components/ui/scroll-area.tsx +2 -0
  90. package/src/components/ui/select.tsx +1 -1
  91. package/src/components/ui/separator.tsx +2 -0
  92. package/src/components/ui/sheet.tsx +4 -1
  93. package/src/components/ui/sidebar.tsx +1 -1
  94. package/src/components/ui/spinner.tsx +1 -0
  95. package/src/components/ui/switch.tsx +2 -0
  96. package/src/components/ui/tabs.tsx +2 -0
  97. package/src/components/ui/toggle-group.tsx +2 -0
  98. package/src/components/ui/tooltip.tsx +2 -0
  99. package/src/lib/__tests__/rehype-safe-img.spec.ts +121 -0
  100. package/src/lib/i18n-fr.ts +68 -0
  101. package/src/lib/rehype-safe-img.ts +150 -0
  102. package/src/lib/resize-image.ts +135 -0
  103. package/src/styles.css +126 -1
  104. /package/src/components/{admin/admin-user-detail-provider-labels.ts → auth/provider-labels.ts} +0 -0
@@ -0,0 +1,130 @@
1
+ import { render, screen } from "@testing-library/react";
2
+ import { describe, expect, it } from "vitest";
3
+ import { SettingsDangerSection } from "../settings-danger-section.tsx";
4
+ import { SettingsRow } from "../settings-row.tsx";
5
+ import { SettingsSection } from "../settings-section.tsx";
6
+
7
+ /**
8
+ * These pin the padding contract, which is the one thing about this kit that
9
+ * is invisible in a screenshot review and has already gone wrong four times
10
+ * by hand in `apps/lore`: the card must carry `py-0` and each row its own
11
+ * `py-3`. Doubling them produces a thick blank band top and bottom.
12
+ */
13
+ describe("SettingsSection", () => {
14
+ it("opts the card out of vertical padding so rows own it", () => {
15
+ const { container } = render(
16
+ <SettingsSection title="General">
17
+ <SettingsRow label="Name">control</SettingsRow>
18
+ </SettingsSection>,
19
+ );
20
+
21
+ const card = container.querySelector('[data-slot="card"]');
22
+ expect(card?.className).toContain("py-0");
23
+ // A numeric py-* on the card is the anti-pattern, not a smaller variant.
24
+ expect(card?.className).not.toMatch(/\bpy-[1-9]/);
25
+
26
+ const row = container.querySelector('[data-slot="card-content"]');
27
+ expect(row?.className).toContain("py-3");
28
+ });
29
+
30
+ it("divides rows and keeps the card gapless", () => {
31
+ const { container } = render(
32
+ <SettingsSection>
33
+ <SettingsRow label="One" />
34
+ <SettingsRow label="Two" />
35
+ </SettingsSection>,
36
+ );
37
+
38
+ const card = container.querySelector('[data-slot="card"]');
39
+ expect(card?.className).toContain("divide-y");
40
+ expect(card?.className).toContain("gap-0");
41
+ expect(
42
+ container.querySelectorAll('[data-slot="card-content"]'),
43
+ ).toHaveLength(2);
44
+ });
45
+
46
+ it("renders no heading block when given neither title nor description", () => {
47
+ const { container } = render(
48
+ <SettingsSection>
49
+ <SettingsRow label="Only" />
50
+ </SettingsSection>,
51
+ );
52
+
53
+ // Heading block + card would be two children; without a heading, one.
54
+ expect(container.firstElementChild?.children).toHaveLength(1);
55
+ });
56
+
57
+ it("renders title and description when both are given", () => {
58
+ render(
59
+ <SettingsSection title="General" description="Who you are">
60
+ <SettingsRow label="Name" />
61
+ </SettingsSection>,
62
+ );
63
+
64
+ expect(screen.getByText("General")).toBeTruthy();
65
+ expect(screen.getByText("Who you are")).toBeTruthy();
66
+ });
67
+ });
68
+
69
+ describe("SettingsRow", () => {
70
+ it("keeps the label column shrinkable so a long label cannot push the control out", () => {
71
+ const { container } = render(
72
+ <SettingsRow label="Name">control</SettingsRow>,
73
+ );
74
+
75
+ const row = container.querySelector('[data-slot="card-content"]');
76
+ expect(row?.className).toContain("sm:grid-cols-[minmax(0,1fr)_auto]");
77
+ });
78
+
79
+ it("omits the description line entirely when not given", () => {
80
+ const { container } = render(<SettingsRow label="Name" />);
81
+
82
+ // An empty <span> would still occupy a grid row and add a gap under the
83
+ // label, so "absent" has to mean absent, not blank.
84
+ const labelColumn = container.querySelector(
85
+ '[data-slot="card-content"] > div',
86
+ );
87
+ expect(labelColumn?.children).toHaveLength(1);
88
+ expect(labelColumn?.textContent).toBe("Name");
89
+ });
90
+
91
+ it("renders the control when given", () => {
92
+ render(
93
+ <SettingsRow label="Name" description="Your display name">
94
+ <button type="button">Edit</button>
95
+ </SettingsRow>,
96
+ );
97
+
98
+ expect(screen.getByRole("button", { name: "Edit" })).toBeTruthy();
99
+ expect(screen.getByText("Your display name")).toBeTruthy();
100
+ });
101
+ });
102
+
103
+ describe("SettingsDangerSection", () => {
104
+ it("defaults its title and tints the border without shouting", () => {
105
+ const { container } = render(
106
+ <SettingsDangerSection>
107
+ <SettingsRow label="Delete account" />
108
+ </SettingsDangerSection>,
109
+ );
110
+
111
+ expect(screen.getByText("Danger zone")).toBeTruthy();
112
+
113
+ const card = container.querySelector('[data-slot="card"]');
114
+ expect(card?.className).toContain("border-destructive/30");
115
+ // Full-strength destructive reads as "this page is broken".
116
+ expect(card?.className).not.toMatch(/border-destructive(?![/-])/);
117
+ });
118
+
119
+ it("keeps the same padding contract as a normal section", () => {
120
+ const { container } = render(
121
+ <SettingsDangerSection title="Danger">
122
+ <SettingsRow label="Delete account" />
123
+ </SettingsDangerSection>,
124
+ );
125
+
126
+ const card = container.querySelector('[data-slot="card"]');
127
+ expect(card?.className).toContain("py-0");
128
+ expect(card?.className).not.toMatch(/\bpy-[1-9]/);
129
+ });
130
+ });
@@ -0,0 +1,59 @@
1
+ import { Card } from "@alepha/ui/components/ui/card";
2
+ import { cn } from "@alepha/ui/lib/utils";
3
+ import type { ReactNode } from "react";
4
+
5
+ export interface SettingsDangerSectionProps {
6
+ /**
7
+ * Heading above the card.
8
+ *
9
+ * @default "Danger zone"
10
+ */
11
+ title?: ReactNode;
12
+
13
+ /**
14
+ * One line under the title.
15
+ */
16
+ description?: ReactNode;
17
+
18
+ /**
19
+ * {@link SettingsRow}s, each holding a `variant="destructive"` control.
20
+ */
21
+ children: ReactNode;
22
+
23
+ className?: string;
24
+ }
25
+
26
+ /**
27
+ * {@link SettingsSection} for irreversible actions — delete, leave, revoke
28
+ * everything.
29
+ *
30
+ * Identical in structure, with a destructive-tinted border and title. The
31
+ * colour is doing real work rather than decorating: these rows sit in the
32
+ * same visual rhythm as every harmless row above them, and without a boundary
33
+ * the only thing separating "change your display name" from "delete your
34
+ * account" is the button colour at the moment of the click.
35
+ *
36
+ * The tint stays at 30–40% opacity on purpose. A full-strength destructive
37
+ * border reads as *"something is wrong"* rather than *"be careful here"*, and
38
+ * a settings page that looks like it is erroring every time you open it
39
+ * teaches people to ignore the colour.
40
+ */
41
+ export const SettingsDangerSection = (props: SettingsDangerSectionProps) => {
42
+ const { title = "Danger zone" } = props;
43
+
44
+ return (
45
+ <div className={cn("flex flex-col gap-2", props.className)}>
46
+ <div className="flex flex-col gap-0.5">
47
+ <span className="text-destructive text-sm">{title}</span>
48
+ {props.description != null ? (
49
+ <span className="text-muted-foreground text-xs">
50
+ {props.description}
51
+ </span>
52
+ ) : null}
53
+ </div>
54
+ <Card className="gap-0 divide-y divide-destructive/20 rounded-lg border border-destructive/30 bg-card py-0">
55
+ {props.children}
56
+ </Card>
57
+ </div>
58
+ );
59
+ };
@@ -0,0 +1,56 @@
1
+ import { cn } from "@alepha/ui/lib/utils";
2
+ import type { ReactNode } from "react";
3
+
4
+ export interface SettingsLayoutProps {
5
+ /**
6
+ * The left rail — normally a {@link SettingsNav}. Omit for a settings page
7
+ * with a single screen and nothing to navigate between.
8
+ */
9
+ nav?: ReactNode;
10
+
11
+ /**
12
+ * Full-width block above both columns: an identity card, a page title, a
13
+ * back link. Rendered inside the centred container, so it lines up with the
14
+ * content rather than the viewport.
15
+ */
16
+ header?: ReactNode;
17
+
18
+ /**
19
+ * The routed content — normally a `NestedView`.
20
+ */
21
+ children: ReactNode;
22
+
23
+ className?: string;
24
+ }
25
+
26
+ /**
27
+ * Centred two-column shell for a settings area: sticky rail on the left,
28
+ * content on the right, stacked on small screens.
29
+ *
30
+ * `min-w-0` on the content column is load-bearing. A grid/flex child defaults
31
+ * to `min-width: auto`, which is the *content's* intrinsic width — so one
32
+ * unbreakable string (an API key, a long email, a `<pre>` block) makes the
33
+ * column refuse to shrink and pushes the whole page into horizontal scroll,
34
+ * rail included. `min-w-0` lets it shrink and lets the child's own
35
+ * `overflow` handle it.
36
+ *
37
+ * There is no scroll container here on purpose: the page scrolls. A nested
38
+ * `overflow-auto` would clip the flush left/right card borders that
39
+ * {@link SettingsSection} depends on, and would strand the sticky rail
40
+ * against the wrong scroll root.
41
+ */
42
+ export const SettingsLayout = (props: SettingsLayoutProps) => {
43
+ return (
44
+ <div
45
+ className={cn("mx-auto w-full max-w-5xl p-4 md:pt-10", props.className)}
46
+ >
47
+ {props.header ? <div className="mb-6">{props.header}</div> : null}
48
+ <div className="flex flex-col gap-6 md:flex-row md:items-start">
49
+ {props.nav}
50
+ <div className="flex min-w-0 flex-1 flex-col gap-8">
51
+ {props.children}
52
+ </div>
53
+ </div>
54
+ </div>
55
+ );
56
+ };
@@ -0,0 +1,131 @@
1
+ import { cn } from "@alepha/ui/lib/utils";
2
+ import { Link } from "alepha/react/router";
3
+ import { type ReactNode, useMemo } from "react";
4
+
5
+ export interface SettingsNavItem {
6
+ /**
7
+ * Stable key. The route name when these come from `useNavEntries`.
8
+ */
9
+ name: string;
10
+
11
+ /**
12
+ * Fully resolved href — every `:param` already substituted. See
13
+ * {@link SettingsNav} for why this component refuses to resolve them itself.
14
+ */
15
+ href: string;
16
+
17
+ label: ReactNode;
18
+ icon?: ReactNode;
19
+
20
+ /**
21
+ * Heading this entry sits under. Entries with no group render first, in a
22
+ * block of their own, without a heading.
23
+ */
24
+ group?: string;
25
+
26
+ /**
27
+ * The current route is on or under this entry.
28
+ */
29
+ active: boolean;
30
+
31
+ /**
32
+ * Visible but not reachable — rendered muted and inert rather than hidden,
33
+ * so the entry can explain a capability the viewer does not currently have.
34
+ */
35
+ disabled?: boolean;
36
+ }
37
+
38
+ export interface SettingsNavProps {
39
+ /**
40
+ * Entries in final display order. Grouping preserves first appearance, so
41
+ * sort before passing — `useNavEntries` already returns them sorted by
42
+ * group order then item order.
43
+ */
44
+ items: SettingsNavItem[];
45
+
46
+ className?: string;
47
+ }
48
+
49
+ /**
50
+ * The left-hand rail of a settings page: a sticky, grouped list of links.
51
+ *
52
+ * ⚠️ **It takes resolved `items`, not a `root` route name, and that is the
53
+ * whole design.** Deriving entries internally from `useNavEntries({ root })`
54
+ * would be a smaller API and works fine for a static subtree such as
55
+ * `/account/*` — but `NavEntry.href` is `page.match`, the raw route
56
+ * *pattern*. Point it at a parameterised subtree like
57
+ * `/:projectSlug/settings/...` and every href in the rail comes out
58
+ * containing a literal `:projectSlug`, which is a dead link that renders
59
+ * perfectly.
60
+ *
61
+ * So resolution is the caller's job and presentation is this component's. A
62
+ * static subtree passes `useNavEntries({ root: "account" })` straight through
63
+ * ({@link SettingsNavItem} is structurally a subset of `NavEntry`, so no
64
+ * mapping is needed); a parameterised one passes its own
65
+ * `router.path(name, { params })` list.
66
+ */
67
+ export const SettingsNav = (props: SettingsNavProps) => {
68
+ const groups = useMemo(() => {
69
+ const ordered: Array<{ key: string; label?: string }> = [];
70
+ const byKey = new Map<string, SettingsNavItem[]>();
71
+
72
+ for (const item of props.items) {
73
+ const key = item.group ?? "";
74
+ let bucket = byKey.get(key);
75
+ if (!bucket) {
76
+ bucket = [];
77
+ byKey.set(key, bucket);
78
+ ordered.push({ key, label: item.group });
79
+ }
80
+ bucket.push(item);
81
+ }
82
+
83
+ return ordered.map((g) => ({ ...g, items: byKey.get(g.key) ?? [] }));
84
+ }, [props.items]);
85
+
86
+ return (
87
+ <nav
88
+ className={cn(
89
+ "flex shrink-0 flex-col gap-4 md:sticky md:top-0 md:w-48 md:self-start",
90
+ props.className,
91
+ )}
92
+ >
93
+ {groups.map((group) => (
94
+ <div key={group.key} className="flex flex-col gap-1">
95
+ {group.label ? (
96
+ <span className="px-3 font-semibold text-[11px] text-muted-foreground uppercase tracking-wider">
97
+ {group.label}
98
+ </span>
99
+ ) : null}
100
+ {group.items.map((item) =>
101
+ item.disabled ? (
102
+ <span
103
+ key={item.name}
104
+ aria-disabled="true"
105
+ className="flex items-center gap-2 whitespace-nowrap rounded-md px-3 py-2 text-left text-muted-foreground/50 text-sm"
106
+ >
107
+ {item.icon}
108
+ {item.label}
109
+ </span>
110
+ ) : (
111
+ <Link
112
+ key={item.name}
113
+ href={item.href}
114
+ aria-current={item.active ? "page" : undefined}
115
+ className={cn(
116
+ "flex items-center gap-2 whitespace-nowrap rounded-md px-3 py-2 text-left text-sm transition-colors",
117
+ item.active
118
+ ? "bg-muted font-medium"
119
+ : "text-muted-foreground hover:bg-muted/60",
120
+ )}
121
+ >
122
+ {item.icon}
123
+ {item.label}
124
+ </Link>
125
+ ),
126
+ )}
127
+ </div>
128
+ ))}
129
+ </nav>
130
+ );
131
+ };
@@ -0,0 +1,81 @@
1
+ import { CardContent } from "@alepha/ui/components/ui/card";
2
+ import { cn } from "@alepha/ui/lib/utils";
3
+ import type { ReactNode } from "react";
4
+
5
+ export interface SettingsRowProps {
6
+ /**
7
+ * What the row is about. Rendered as the emphasised left-hand text.
8
+ */
9
+ label: ReactNode;
10
+
11
+ /**
12
+ * One line of explanation under the label. Omit when the label says it all
13
+ * — an empty helper line is worse than none.
14
+ */
15
+ description?: ReactNode;
16
+
17
+ /**
18
+ * `id` of the form control this row labels. Set it whenever `children` is an
19
+ * input: the label then renders as a real `<label htmlFor>` rather than a
20
+ * `<span>`, which is what gives the control an accessible name and makes
21
+ * clicking the label focus it.
22
+ *
23
+ * Without it the row is a `<span>` — correct for a row whose control is a
24
+ * button or a read-only value, where the button carries its own name and a
25
+ * `<label>` pointing at nothing would be worse than none.
26
+ */
27
+ htmlFor?: string;
28
+
29
+ /**
30
+ * The control this row exists for: a button, a switch, a badge, a value.
31
+ * Sits right of the label on `sm` and up, and underneath it below that.
32
+ */
33
+ children?: ReactNode;
34
+
35
+ className?: string;
36
+ }
37
+
38
+ /**
39
+ * One line of a settings card: label and optional help on the left, a single
40
+ * control on the right.
41
+ *
42
+ * The grid is `minmax(0,1fr) auto`, not `justify-between`. The difference
43
+ * matters when the label is long: `minmax(0,…)` lets the text column shrink
44
+ * and wrap, where a flex row would let it push the control off the card. It
45
+ * collapses to a stacked `flex-col` below `sm`, because a button crushed into
46
+ * a 90px column is worse than a button on its own line.
47
+ *
48
+ * Rows carry all the vertical padding (`py-3`) and {@link SettingsSection}'s
49
+ * card carries none (`py-0`) — see that component for why the two must not
50
+ * both have it.
51
+ */
52
+ export const SettingsRow = (props: SettingsRowProps) => {
53
+ return (
54
+ <CardContent
55
+ className={cn(
56
+ "flex flex-col gap-3 px-4 py-3 sm:grid sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center sm:gap-6",
57
+ props.className,
58
+ )}
59
+ >
60
+ <div className="flex flex-col gap-0.5">
61
+ {props.htmlFor ? (
62
+ <label htmlFor={props.htmlFor} className="font-medium text-sm">
63
+ {props.label}
64
+ </label>
65
+ ) : (
66
+ <span className="font-medium text-sm">{props.label}</span>
67
+ )}
68
+ {props.description ? (
69
+ <span className="text-muted-foreground text-xs">
70
+ {props.description}
71
+ </span>
72
+ ) : null}
73
+ </div>
74
+ {props.children ? (
75
+ <div className="flex justify-start sm:justify-end">
76
+ {props.children}
77
+ </div>
78
+ ) : null}
79
+ </CardContent>
80
+ );
81
+ };
@@ -0,0 +1,64 @@
1
+ import { Card } from "@alepha/ui/components/ui/card";
2
+ import { cn } from "@alepha/ui/lib/utils";
3
+ import type { ReactNode } from "react";
4
+
5
+ export interface SettingsSectionProps {
6
+ /**
7
+ * Heading above the card. Optional — a page whose first section needs no
8
+ * heading (because the page title already says it) omits it.
9
+ */
10
+ title?: ReactNode;
11
+
12
+ /**
13
+ * One line under the title, for context the rows themselves should not
14
+ * each repeat.
15
+ */
16
+ description?: ReactNode;
17
+
18
+ /**
19
+ * {@link SettingsRow}s. Anything else works too, but the divider and the
20
+ * padding contract below assume rows.
21
+ */
22
+ children: ReactNode;
23
+
24
+ className?: string;
25
+ }
26
+
27
+ /**
28
+ * A titled group of settings rows in one bordered card — the GitHub-settings
29
+ * shape.
30
+ *
31
+ * ⚠️ **The card is `py-0` and that is deliberate.** `Card` ships its own
32
+ * vertical padding (`py-(--card-spacing)`), and every {@link SettingsRow}
33
+ * brings `py-3`. Leave both on and the two stack into a visibly thick blank
34
+ * band at the top and bottom of the card. `py-0` opts the card out so each
35
+ * row's own padding is the only vertical space, which is also what makes
36
+ * `divide-y` land flush between rows.
37
+ *
38
+ * The rule is one or the other, never both — so do **not** "fix" this to a
39
+ * numeric `py-4` / `py-3`. Several pages in `apps/lore`'s project settings did
40
+ * exactly that and they are the ones that look wrong next to these.
41
+ */
42
+ export const SettingsSection = (props: SettingsSectionProps) => {
43
+ const hasHeading = props.title != null || props.description != null;
44
+
45
+ return (
46
+ <div className={cn("flex flex-col gap-2", props.className)}>
47
+ {hasHeading ? (
48
+ <div className="flex flex-col gap-0.5">
49
+ {props.title != null ? (
50
+ <span className="text-sm">{props.title}</span>
51
+ ) : null}
52
+ {props.description != null ? (
53
+ <span className="text-muted-foreground text-xs">
54
+ {props.description}
55
+ </span>
56
+ ) : null}
57
+ </div>
58
+ ) : null}
59
+ <Card className="gap-0 divide-y rounded-lg border bg-card py-0">
60
+ {props.children}
61
+ </Card>
62
+ </div>
63
+ );
64
+ };
@@ -116,7 +116,7 @@ function AlertDialogTitle({
116
116
  <AlertDialogPrimitive.Title
117
117
  data-slot="alert-dialog-title"
118
118
  className={cn(
119
- "text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
119
+ "cn-font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
120
120
  className,
121
121
  )}
122
122
  {...props}
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import { cn } from "@alepha/ui/lib/utils";
2
4
  import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";
3
5
  import type * as React from "react";
@@ -84,7 +84,7 @@ function BreadcrumbSeparator({
84
84
  className={cn("[&>svg]:size-3.5", className)}
85
85
  {...props}
86
86
  >
87
- {children ?? <ChevronRightIcon />}
87
+ {children ?? <ChevronRightIcon className="cn-rtl-flip" />}
88
88
  </li>
89
89
  );
90
90
  }
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import { Button, buttonVariants } from "@alepha/ui/components/ui/button";
2
4
  import { cn } from "@alepha/ui/lib/utils";
3
5
  import { useI18n } from "alepha/react/i18n";
@@ -84,7 +86,7 @@ function Calendar({
84
86
  defaultClassNames.dropdowns,
85
87
  ),
86
88
  dropdown_root: cn(
87
- "relative rounded-(--cell-radius)",
89
+ "cn-calendar-dropdown-root relative rounded-(--cell-radius)",
88
90
  defaultClassNames.dropdown_root,
89
91
  ),
90
92
  dropdown: cn(
@@ -94,11 +96,11 @@ function Calendar({
94
96
  caption_label: cn(
95
97
  "font-medium select-none",
96
98
  captionLayout === "label"
97
- ? "text-sm"
98
- : "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
99
+ ? "cn-calendar-caption text-sm"
100
+ : "cn-calendar-caption-label flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
99
101
  defaultClassNames.caption_label,
100
102
  ),
101
- month_grid: "w-full border-collapse",
103
+ month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
102
104
  weekdays: cn("flex", defaultClassNames.weekdays),
103
105
  weekday: cn(
104
106
  "flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
@@ -158,14 +160,17 @@ function Calendar({
158
160
  Chevron: ({ className, orientation, ...props }) => {
159
161
  if (orientation === "left") {
160
162
  return (
161
- <ChevronLeftIcon className={cn("size-4", className)} {...props} />
163
+ <ChevronLeftIcon
164
+ className={cn("cn-rtl-flip size-4", className)}
165
+ {...props}
166
+ />
162
167
  );
163
168
  }
164
169
 
165
170
  if (orientation === "right") {
166
171
  return (
167
172
  <ChevronRightIcon
168
- className={cn("size-4", className)}
173
+ className={cn("cn-rtl-flip size-4", className)}
169
174
  {...props}
170
175
  />
171
176
  );
@@ -11,7 +11,7 @@ function Card({
11
11
  data-slot="card"
12
12
  data-size={size}
13
13
  className={cn(
14
- "group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
14
+ "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
15
15
  className,
16
16
  )}
17
17
  {...props}
@@ -24,7 +24,7 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
24
24
  <div
25
25
  data-slot="card-header"
26
26
  className={cn(
27
- "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
27
+ "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
28
28
  className,
29
29
  )}
30
30
  {...props}
@@ -37,7 +37,7 @@ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
37
37
  <div
38
38
  data-slot="card-title"
39
39
  className={cn(
40
- "text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
40
+ "cn-font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
41
41
  className,
42
42
  )}
43
43
  {...props}
@@ -72,7 +72,7 @@ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
72
72
  return (
73
73
  <div
74
74
  data-slot="card-content"
75
- className={cn("px-4 group-data-[size=sm]/card:px-3", className)}
75
+ className={cn("px-(--card-spacing)", className)}
76
76
  {...props}
77
77
  />
78
78
  );
@@ -83,7 +83,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
83
83
  <div
84
84
  data-slot="card-footer"
85
85
  className={cn(
86
- "flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",
86
+ "flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",
87
87
  className,
88
88
  )}
89
89
  {...props}
@@ -186,7 +186,7 @@ function CarouselPrevious({
186
186
  className={cn(
187
187
  "absolute touch-manipulation rounded-full",
188
188
  orientation === "horizontal"
189
- ? "top-1/2 -left-12 -translate-y-1/2"
189
+ ? "inset-y-0 -left-12 my-auto"
190
190
  : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
191
191
  className,
192
192
  )}
@@ -194,7 +194,7 @@ function CarouselPrevious({
194
194
  onClick={scrollPrev}
195
195
  {...props}
196
196
  >
197
- <ChevronLeftIcon />
197
+ <ChevronLeftIcon className="cn-rtl-flip" />
198
198
  <span className="sr-only">Previous slide</span>
199
199
  </Button>
200
200
  );
@@ -216,7 +216,7 @@ function CarouselNext({
216
216
  className={cn(
217
217
  "absolute touch-manipulation rounded-full",
218
218
  orientation === "horizontal"
219
- ? "top-1/2 -right-12 -translate-y-1/2"
219
+ ? "inset-y-0 -right-12 my-auto"
220
220
  : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
221
221
  className,
222
222
  )}
@@ -224,7 +224,7 @@ function CarouselNext({
224
224
  onClick={scrollNext}
225
225
  {...props}
226
226
  >
227
- <ChevronRightIcon />
227
+ <ChevronRightIcon className="cn-rtl-flip" />
228
228
  <span className="sr-only">Next slide</span>
229
229
  </Button>
230
230
  );