@alepha/ui 0.32.0 → 0.33.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 (186) hide show
  1. package/dist/account/AccountConnections.js +1 -1
  2. package/dist/account/AccountConnections.js.map +1 -1
  3. package/dist/account/AccountDeleteDialog.d.ts.map +1 -1
  4. package/dist/account/AccountDeleteDialog.js +17 -17
  5. package/dist/account/AccountDeleteDialog.js.map +1 -1
  6. package/dist/account/AccountKeys.js +2 -2
  7. package/dist/account/AccountKeys.js.map +1 -1
  8. package/dist/account/AccountMfaDialog.d.ts.map +1 -1
  9. package/dist/account/AccountMfaDialog.js +19 -25
  10. package/dist/account/AccountMfaDialog.js.map +1 -1
  11. package/dist/account/AccountPasswordDialog.d.ts.map +1 -1
  12. package/dist/account/AccountPasswordDialog.js +25 -24
  13. package/dist/account/AccountPasswordDialog.js.map +1 -1
  14. package/dist/account/AccountProfile.d.ts.map +1 -1
  15. package/dist/account/AccountProfile.js +17 -24
  16. package/dist/account/AccountProfile.js.map +1 -1
  17. package/dist/account/AccountSecurity.d.ts.map +1 -1
  18. package/dist/account/AccountSecurity.js +21 -19
  19. package/dist/account/AccountSecurity.js.map +1 -1
  20. package/dist/account/AccountSessions.js +1 -1
  21. package/dist/account/AccountSessions.js.map +1 -1
  22. package/dist/account/ApiKeyCreateDialog.d.ts.map +1 -1
  23. package/dist/account/ApiKeyCreateDialog.js +8 -12
  24. package/dist/account/ApiKeyCreateDialog.js.map +1 -1
  25. package/dist/admin/AdminFiles.js +1 -1
  26. package/dist/admin/AdminFiles.js.map +1 -1
  27. package/dist/admin/AdminJobs.js +1 -1
  28. package/dist/admin/AdminJobs.js.map +1 -1
  29. package/dist/admin/AdminKeys.js +1 -1
  30. package/dist/admin/AdminKeys.js.map +1 -1
  31. package/dist/admin/AdminParameters.d.ts.map +1 -1
  32. package/dist/admin/AdminParameters.js +7 -5
  33. package/dist/admin/AdminParameters.js.map +1 -1
  34. package/dist/admin/AdminParametersTreeFooterActions.d.ts +2 -2
  35. package/dist/admin/AdminParametersTreeFooterActions.d.ts.map +1 -1
  36. package/dist/admin/AdminParametersTreeFooterActions.js.map +1 -1
  37. package/dist/admin/AdminParametersTreePane.d.ts +2 -2
  38. package/dist/admin/AdminParametersTreePane.d.ts.map +1 -1
  39. package/dist/admin/AdminParametersTreePane.js.map +1 -1
  40. package/dist/admin/AdminRouter.d.ts +1 -3
  41. package/dist/admin/AdminRouter.d.ts.map +1 -1
  42. package/dist/admin/AdminRouter.js +2 -4
  43. package/dist/admin/AdminRouter.js.map +1 -1
  44. package/dist/admin/AdminSessions.js +1 -1
  45. package/dist/admin/AdminSessions.js.map +1 -1
  46. package/dist/admin/AdminUserAvatarControl.d.ts.map +1 -1
  47. package/dist/admin/AdminUserAvatarControl.js +9 -16
  48. package/dist/admin/AdminUserAvatarControl.js.map +1 -1
  49. package/dist/admin/AdminUserDetail.js +4 -4
  50. package/dist/admin/AdminUserDetail.js.map +1 -1
  51. package/dist/admin/AdminUsers.d.ts.map +1 -1
  52. package/dist/admin/AdminUsers.js +10 -12
  53. package/dist/admin/AdminUsers.js.map +1 -1
  54. package/dist/admin/AdminUsersRolesPicker.d.ts +5 -1
  55. package/dist/admin/AdminUsersRolesPicker.d.ts.map +1 -1
  56. package/dist/admin/AdminUsersRolesPicker.js +2 -3
  57. package/dist/admin/AdminUsersRolesPicker.js.map +1 -1
  58. package/dist/admin/analytics/QueryPanel.js +1 -1
  59. package/dist/admin/analytics/QueryPanel.js.map +1 -1
  60. package/dist/admin/useConfirmedAction.d.ts +8 -2
  61. package/dist/admin/useConfirmedAction.d.ts.map +1 -1
  62. package/dist/admin/useConfirmedAction.js +15 -4
  63. package/dist/admin/useConfirmedAction.js.map +1 -1
  64. package/dist/auth/AuthLogin.d.ts.map +1 -1
  65. package/dist/auth/AuthLogin.js +4 -4
  66. package/dist/auth/AuthLogin.js.map +1 -1
  67. package/dist/auth/AuthRegister.js.map +1 -1
  68. package/dist/core/index.js +1 -1
  69. package/dist/form/AutoForm.js +1 -1
  70. package/dist/form/AutoForm.js.map +1 -1
  71. package/dist/form/Control.js +1 -1
  72. package/dist/form/Control.js.map +1 -1
  73. package/dist/form/ControlArray.js +5 -5
  74. package/dist/form/ControlArray.js.map +1 -1
  75. package/dist/form/ControlSelect.js +2 -2
  76. package/dist/form/ControlSelect.js.map +1 -1
  77. package/dist/form/ControlUpload.d.ts +1 -1
  78. package/dist/form/ControlUpload.js.map +1 -1
  79. package/dist/i18n/fr/uiFr.d.ts.map +1 -1
  80. package/dist/i18n/fr/uiFr.js +0 -9
  81. package/dist/i18n/fr/uiFr.js.map +1 -1
  82. package/dist/organizations/MyOrganizationInvitations.js +2 -2
  83. package/dist/organizations/MyOrganizationInvitations.js.map +1 -1
  84. package/dist/organizations/OrganizationInviteDialog.js +1 -1
  85. package/dist/organizations/OrganizationInviteDialog.js.map +1 -1
  86. package/dist/organizations/OrganizationMembers.js +1 -1
  87. package/dist/organizations/OrganizationMembers.js.map +1 -1
  88. package/dist/organizations/OrganizationPendingInvitations.js +1 -1
  89. package/dist/organizations/OrganizationPendingInvitations.js.map +1 -1
  90. package/dist/organizations/OrganizationRanks.js +3 -3
  91. package/dist/organizations/OrganizationRanks.js.map +1 -1
  92. package/dist/organizations/useInviteOrganizationMember.d.ts +6 -1
  93. package/dist/organizations/useInviteOrganizationMember.d.ts.map +1 -1
  94. package/dist/organizations/useInviteOrganizationMember.js +13 -13
  95. package/dist/organizations/useInviteOrganizationMember.js.map +1 -1
  96. package/dist/organizations/useRevokeOrganizationInvitation.d.ts +7 -1
  97. package/dist/organizations/useRevokeOrganizationInvitation.d.ts.map +1 -1
  98. package/dist/organizations/useRevokeOrganizationInvitation.js +13 -2
  99. package/dist/organizations/useRevokeOrganizationInvitation.js.map +1 -1
  100. package/dist/shell/ButtonUser.d.ts +1 -2
  101. package/dist/shell/ButtonUser.d.ts.map +1 -1
  102. package/dist/shell/ButtonUser.js +14 -42
  103. package/dist/shell/ButtonUser.js.map +1 -1
  104. package/dist/shell/ButtonUserContent.d.ts +13 -0
  105. package/dist/shell/ButtonUserContent.d.ts.map +1 -0
  106. package/dist/shell/ButtonUserContent.js +52 -0
  107. package/dist/shell/ButtonUserContent.js.map +1 -0
  108. package/dist/shell/ButtonUserPlaceholder.d.ts +14 -0
  109. package/dist/shell/ButtonUserPlaceholder.d.ts.map +1 -0
  110. package/dist/shell/ButtonUserPlaceholder.js +17 -0
  111. package/dist/shell/ButtonUserPlaceholder.js.map +1 -0
  112. package/dist/styles.css +31 -0
  113. package/dist/table/DataTable.js +1 -1
  114. package/dist/table/DataTable.js.map +1 -1
  115. package/dist/table/DataTableFilterBar.js +2 -2
  116. package/dist/table/DataTableFilterBar.js.map +1 -1
  117. package/dist/table/dataTableBaseProps.d.ts +1 -1
  118. package/dist/table/dataTableTypes.d.ts +3 -3
  119. package/dist/table/dataTableTypes.d.ts.map +1 -1
  120. package/dist/table/useDataTableData.d.ts.map +1 -1
  121. package/dist/table/useDataTableData.js +3 -1
  122. package/dist/table/useDataTableData.js.map +1 -1
  123. package/dist/table/useDataTableRefresh.js +2 -2
  124. package/dist/table/useDataTableRefresh.js.map +1 -1
  125. package/dist/table/useDataTableSummary.d.ts.map +1 -1
  126. package/dist/table/useDataTableSummary.js +2 -1
  127. package/dist/table/useDataTableSummary.js.map +1 -1
  128. package/package.json +6 -6
  129. package/src/account/AccountConnections.tsx +1 -1
  130. package/src/account/AccountDeleteDialog.tsx +25 -31
  131. package/src/account/AccountKeys.tsx +2 -2
  132. package/src/account/AccountMfaDialog.tsx +33 -27
  133. package/src/account/AccountPasswordDialog.tsx +36 -39
  134. package/src/account/AccountProfile.tsx +29 -43
  135. package/src/account/AccountSecurity.tsx +57 -64
  136. package/src/account/AccountSessions.tsx +1 -1
  137. package/src/account/ApiKeyCreateDialog.tsx +12 -20
  138. package/src/account/__tests__/AccountRouter.spec.ts +2 -1
  139. package/src/admin/AdminFiles.tsx +1 -1
  140. package/src/admin/AdminJobs.tsx +1 -1
  141. package/src/admin/AdminKeys.tsx +1 -1
  142. package/src/admin/AdminParameters.tsx +7 -5
  143. package/src/admin/AdminParametersTreeFooterActions.tsx +2 -2
  144. package/src/admin/AdminParametersTreePane.tsx +2 -2
  145. package/src/admin/AdminRouter.tsx +2 -4
  146. package/src/admin/AdminSessions.tsx +1 -1
  147. package/src/admin/AdminUserAvatarControl.tsx +17 -22
  148. package/src/admin/AdminUserDetail.tsx +4 -4
  149. package/src/admin/AdminUsers.tsx +10 -12
  150. package/src/admin/AdminUsersRolesPicker.tsx +11 -4
  151. package/src/admin/__tests__/AdminRouter.spec.ts +3 -2
  152. package/src/admin/analytics/QueryPanel.tsx +1 -1
  153. package/src/admin/useConfirmedAction.tsx +24 -10
  154. package/src/auth/AuthLogin.tsx +10 -9
  155. package/src/auth/AuthRegister.tsx +2 -2
  156. package/src/form/AutoForm.tsx +1 -1
  157. package/src/form/Control.tsx +1 -1
  158. package/src/form/ControlArray.tsx +5 -5
  159. package/src/form/ControlSelect.tsx +2 -2
  160. package/src/form/ControlUpload.tsx +1 -1
  161. package/src/form/__tests__/ControlArrayChildChange.browser.spec.tsx +1 -1
  162. package/src/i18n/fr/uiFr.ts +0 -9
  163. package/src/organizations/MyOrganizationInvitations.tsx +2 -2
  164. package/src/organizations/OrganizationInviteDialog.tsx +1 -1
  165. package/src/organizations/OrganizationMembers.tsx +1 -1
  166. package/src/organizations/OrganizationPendingInvitations.tsx +1 -1
  167. package/src/organizations/OrganizationRanks.tsx +3 -3
  168. package/src/organizations/useInviteOrganizationMember.ts +22 -15
  169. package/src/organizations/useRevokeOrganizationInvitation.ts +23 -4
  170. package/src/shell/ButtonUser.tsx +14 -79
  171. package/src/shell/ButtonUserContent.tsx +92 -0
  172. package/src/shell/ButtonUserPlaceholder.tsx +25 -0
  173. package/src/shell/__tests__/ActionErrorToaster.browser.spec.tsx +1 -1
  174. package/src/shell/__tests__/ActionErrorToasterHandled.browser.spec.tsx +1 -2
  175. package/src/shell/__tests__/AppShell.pageCache.spec.tsx +67 -0
  176. package/src/styles.css +31 -0
  177. package/src/table/DataTable.tsx +1 -1
  178. package/src/table/DataTableFilterBar.tsx +2 -2
  179. package/src/table/__tests__/DataTableFilterDateRange.browser.spec.tsx +1 -1
  180. package/src/table/__tests__/DataTableQuerySeed.browser.spec.tsx +1 -1
  181. package/src/table/__tests__/DataTableShareFilters.browser.spec.tsx +1 -1
  182. package/src/table/dataTableBaseProps.ts +1 -1
  183. package/src/table/dataTableTypes.ts +3 -3
  184. package/src/table/useDataTableData.ts +2 -0
  185. package/src/table/useDataTableRefresh.ts +3 -3
  186. package/src/table/useDataTableSummary.ts +2 -1
@@ -1,24 +1,12 @@
1
- import * as React from "react";
2
-
3
- void React;
4
-
5
- import { useAuth } from "alepha/react/auth";
6
- import { LogIn, User } from "lucide-react";
1
+ import { Personal } from "alepha/react";
7
2
  import type { ReactNode } from "react";
8
3
 
9
- import { Button } from "../core/Button.tsx";
10
- import {
11
- DropdownMenu,
12
- DropdownMenuContent,
13
- DropdownMenuTrigger,
14
- } from "../core/DropdownMenu.tsx";
15
- import { Tooltip, TooltipContent, TooltipTrigger } from "../core/Tooltip.tsx";
16
- import { UserAvatar } from "../core/UserAvatar.tsx";
17
4
  import { ButtonUserAccountMenuItem } from "./ButtonUserAccountMenuItem.tsx";
18
5
  import { ButtonUserAdminMenuItem } from "./ButtonUserAdminMenuItem.tsx";
19
- import { ButtonUserDefaultMenu } from "./ButtonUserDefaultMenu.tsx";
6
+ import { ButtonUserContent } from "./ButtonUserContent.tsx";
20
7
  import { ButtonUserEmail } from "./ButtonUserEmail.tsx";
21
8
  import { ButtonUserLogoutMenuItem } from "./ButtonUserLogoutMenuItem.tsx";
9
+ import { ButtonUserPlaceholder } from "./ButtonUserPlaceholder.tsx";
22
10
 
23
11
  export interface ButtonUserProps {
24
12
  /**
@@ -105,71 +93,18 @@ export interface ButtonUserProps {
105
93
  * <DropdownMenuSeparator />
106
94
  * <ButtonUser.LogoutMenuItem />
107
95
  * </ButtonUser>
96
+ *
97
+ * The button reads the visitor, so it is wrapped in `<Personal>`: a page
98
+ * showing it is still cached for everyone (#E78), with a placeholder of the
99
+ * same size in the shared HTML, replaced by the real button right after
100
+ * hydration from the visitor's own state. On a page that is personal anyway,
101
+ * the server renders the real button.
108
102
  */
109
- export const ButtonUser = (props: ButtonUserProps) => {
110
- const auth = useAuth();
111
-
112
- if (!auth.user) {
113
- const signInLabel = props.signInLabel ?? "Sign in";
114
- return (
115
- <Tooltip>
116
- <TooltipTrigger
117
- render={
118
- <Button
119
- variant={props.variant ?? "minimal"}
120
- size="icon"
121
- aria-label={signInLabel}
122
- disabled={!props.onSignIn}
123
- onClick={props.onSignIn}
124
- />
125
- }
126
- >
127
- <LogIn className="size-4" />
128
- </TooltipTrigger>
129
- <TooltipContent>{signInLabel}</TooltipContent>
130
- </Tooltip>
131
- );
132
- }
133
-
134
- const menuLabel = props.menuLabel ?? "Account menu";
135
- const face =
136
- props.avatar ??
137
- (auth.user.picture ? (
138
- <UserAvatar fileId={auth.user.picture} className="size-7" />
139
- ) : (
140
- <User className="size-4" />
141
- ));
142
- return (
143
- <DropdownMenu>
144
- <Tooltip>
145
- <TooltipTrigger
146
- render={
147
- <DropdownMenuTrigger
148
- render={
149
- <Button
150
- variant={props.variant ?? "minimal"}
151
- size="icon"
152
- aria-label={menuLabel}
153
- />
154
- }
155
- />
156
- }
157
- >
158
- {/* The tooltip and `aria-label` are untouched by the avatar: a
159
- face is not a label, and "Account menu" is still the accessible
160
- name of the button. */}
161
- {face}
162
- </TooltipTrigger>
163
- <TooltipContent>{menuLabel}</TooltipContent>
164
- </Tooltip>
165
- <DropdownMenuContent align="end" className="w-56">
166
- {props.children ?? (
167
- <ButtonUserDefaultMenu onAdminClick={props.onAdminClick} />
168
- )}
169
- </DropdownMenuContent>
170
- </DropdownMenu>
171
- );
172
- };
103
+ export const ButtonUser = (props: ButtonUserProps) => (
104
+ <Personal fallback={<ButtonUserPlaceholder variant={props.variant} />}>
105
+ <ButtonUserContent {...props} />
106
+ </Personal>
107
+ );
173
108
 
174
109
  ButtonUser.Email = ButtonUserEmail;
175
110
  ButtonUser.AdminMenuItem = ButtonUserAdminMenuItem;
@@ -0,0 +1,92 @@
1
+ import * as React from "react";
2
+
3
+ void React;
4
+
5
+ import { useAuth } from "alepha/react/auth";
6
+ import { LogIn, User } from "lucide-react";
7
+
8
+ import { Button } from "../core/Button.tsx";
9
+ import {
10
+ DropdownMenu,
11
+ DropdownMenuContent,
12
+ DropdownMenuTrigger,
13
+ } from "../core/DropdownMenu.tsx";
14
+ import { Tooltip, TooltipContent, TooltipTrigger } from "../core/Tooltip.tsx";
15
+ import { UserAvatar } from "../core/UserAvatar.tsx";
16
+ import type { ButtonUserProps } from "./ButtonUser.tsx";
17
+ import { ButtonUserDefaultMenu } from "./ButtonUserDefaultMenu.tsx";
18
+
19
+ /**
20
+ * The account button itself. See {@link ButtonUserProps}.
21
+ */
22
+ export type ButtonUserContentProps = ButtonUserProps;
23
+
24
+ /**
25
+ * What `ButtonUser` renders once it may read the visitor: the sign-in icon
26
+ * when logged out, the avatar and its menu when logged in. Wrapped in
27
+ * `<Personal>` by `ButtonUser`, so a page showing it stays shareable.
28
+ */
29
+ export const ButtonUserContent = (props: ButtonUserContentProps) => {
30
+ const auth = useAuth();
31
+
32
+ if (!auth.user) {
33
+ const signInLabel = props.signInLabel ?? "Sign in";
34
+ return (
35
+ <Tooltip>
36
+ <TooltipTrigger
37
+ render={
38
+ <Button
39
+ variant={props.variant ?? "minimal"}
40
+ size="icon"
41
+ aria-label={signInLabel}
42
+ disabled={!props.onSignIn}
43
+ onClick={props.onSignIn}
44
+ />
45
+ }
46
+ >
47
+ <LogIn className="size-4" />
48
+ </TooltipTrigger>
49
+ <TooltipContent>{signInLabel}</TooltipContent>
50
+ </Tooltip>
51
+ );
52
+ }
53
+
54
+ const menuLabel = props.menuLabel ?? "Account menu";
55
+ const face =
56
+ props.avatar ??
57
+ (auth.user.picture ? (
58
+ <UserAvatar fileId={auth.user.picture} className="size-7" />
59
+ ) : (
60
+ <User className="size-4" />
61
+ ));
62
+ return (
63
+ <DropdownMenu>
64
+ <Tooltip>
65
+ <TooltipTrigger
66
+ render={
67
+ <DropdownMenuTrigger
68
+ render={
69
+ <Button
70
+ variant={props.variant ?? "minimal"}
71
+ size="icon"
72
+ aria-label={menuLabel}
73
+ />
74
+ }
75
+ />
76
+ }
77
+ >
78
+ {/* The tooltip and `aria-label` are untouched by the avatar: a
79
+ face is not a label, and "Account menu" is still the accessible
80
+ name of the button. */}
81
+ {face}
82
+ </TooltipTrigger>
83
+ <TooltipContent>{menuLabel}</TooltipContent>
84
+ </Tooltip>
85
+ <DropdownMenuContent align="end" className="w-56">
86
+ {props.children ?? (
87
+ <ButtonUserDefaultMenu onAdminClick={props.onAdminClick} />
88
+ )}
89
+ </DropdownMenuContent>
90
+ </DropdownMenu>
91
+ );
92
+ };
@@ -0,0 +1,25 @@
1
+ import { cn } from "../core/utils.ts";
2
+
3
+ export interface ButtonUserPlaceholderProps {
4
+ /**
5
+ * The variant of the button it stands for: an outlined button keeps its
6
+ * border, so the swap moves nothing.
7
+ */
8
+ variant?: "minimal" | "outlined";
9
+ }
10
+
11
+ /**
12
+ * What a shared page shows where `ButtonUser` goes, before hydration: an
13
+ * empty slot the size of the icon button. Neither the sign-in icon nor an
14
+ * avatar, since the shared page cannot know which one its visitor gets.
15
+ */
16
+ export const ButtonUserPlaceholder = (props: ButtonUserPlaceholderProps) => (
17
+ <span
18
+ aria-hidden
19
+ data-slot="button-user-placeholder"
20
+ className={cn(
21
+ "inline-block size-9 shrink-0 rounded-md",
22
+ props.variant === "outlined" && "border",
23
+ )}
24
+ />
25
+ );
@@ -58,7 +58,7 @@ describe("ActionErrorToaster", () => {
58
58
  {
59
59
  type: "custom",
60
60
  id: "action",
61
- error: new HttpError({ status, message }),
61
+ error: new HttpError({ status }, { message }),
62
62
  },
63
63
  { catch: true },
64
64
  );
@@ -228,8 +228,7 @@ describe("ActionErrorToaster and handled errors", () => {
228
228
 
229
229
  // The toast would read the error's own message, which is also what the
230
230
  // field renders here: so one element with that text means no toast.
231
- const message =
232
- "Invalid input: Invalid identifier or password, here at /password";
231
+ const message = "Invalid identifier or password, here";
233
232
  await waitFor(() =>
234
233
  expect(screen.getByTestId("password-error").textContent).toBe(message),
235
234
  );
@@ -0,0 +1,67 @@
1
+ import { Alepha } from "alepha";
2
+ import { AlephaReactI18n } from "alepha/react/i18n";
3
+ import { $page, AlephaReactRouter } from "alepha/react/router";
4
+ import { AlephaReactUi, uiAtom } from "alepha/react/ui";
5
+ import { ServerProvider } from "alepha/server";
6
+ import { describe, it } from "vitest";
7
+
8
+ import { AppShell } from "../AppShell.tsx";
9
+
10
+ /**
11
+ * An `AppShell` page reads no UI preference on the server (#E78): its markup
12
+ * is the same whatever the visitor's `alepha-ui` cookie says, so the page
13
+ * cache shares it between visitors who prefer different things.
14
+ */
15
+ describe("AppShell and the page cache", () => {
16
+ class App {
17
+ layout = $page({
18
+ component: () => <AppShell brand="Brand" nav={[]} />,
19
+ children: () => [this.home],
20
+ });
21
+
22
+ home = $page({
23
+ path: "/",
24
+ stream: false,
25
+ component: () => "home",
26
+ });
27
+ }
28
+
29
+ const cookie = (ui: object) =>
30
+ `alepha-ui=${encodeURIComponent(JSON.stringify(ui))}`;
31
+
32
+ it("serves the same cached page to visitors with different ui cookies", async ({
33
+ expect,
34
+ }) => {
35
+ const alepha = Alepha.create()
36
+ .with(AlephaReactRouter)
37
+ .with(AlephaReactI18n)
38
+ .with(AlephaReactUi)
39
+ .with(App);
40
+ await alepha.start();
41
+ const base = alepha.inject(ServerProvider).hostname;
42
+
43
+ const collapsedDark = cookie({
44
+ ...uiAtom.options.default!,
45
+ mode: "dark",
46
+ sidebar: { collapsed: true },
47
+ });
48
+
49
+ const first = await fetch(`${base}/`, {
50
+ headers: { cookie: collapsedDark },
51
+ });
52
+ const firstBody = await first.text();
53
+ await new Promise((resolve) => setTimeout(resolve, 20));
54
+ const second = await fetch(`${base}/`);
55
+ const secondBody = await second.text();
56
+
57
+ // Variant, not shared: the shell is translated, so it reads the language,
58
+ // which every key carries anyway.
59
+ expect(first.headers.get("x-alepha-cache")).toBe("miss; verdict=variant");
60
+ expect(second.headers.get("x-alepha-cache")).toBe("hit; verdict=variant");
61
+
62
+ // The shared part is identical; only each visitor's private script differs.
63
+ const shared = (html: string) =>
64
+ html.replace(/<script id="__ssr_private"[^>]*>.*?<\/script>/, "");
65
+ expect(shared(secondBody)).toBe(shared(firstBody));
66
+ });
67
+ });
package/src/styles.css CHANGED
@@ -893,3 +893,34 @@
893
893
  ) {
894
894
  border-color: var(--border-hover);
895
895
  }
896
+
897
+ /*
898
+ * A collapsed sidebar before hydration (#E78).
899
+ *
900
+ * The server renders the shell expanded for every visitor, so the page cache
901
+ * can share it; the visitor's preference reaches React only on the first
902
+ * commit after hydration. The boot script has already set
903
+ * `data-sidebar="collapsed"` on `<html>` from the `alepha-ui` cookie, so an
904
+ * EXPANDED sidebar under that attribute is the pre-hydration frame: it is held
905
+ * at the icon width, labels clipped, until React renders it collapsed. A
906
+ * sidebar the visitor expands again updates the attribute with it, so the rule
907
+ * never fights React after hydration.
908
+ */
909
+ html[data-sidebar="collapsed"]
910
+ [data-slot="sidebar"][data-state="expanded"]
911
+ [data-slot="sidebar-gap"],
912
+ html[data-sidebar="collapsed"]
913
+ [data-slot="sidebar"][data-state="expanded"]
914
+ [data-slot="sidebar-container"] {
915
+ width: var(--sidebar-width-icon);
916
+ overflow: hidden;
917
+ }
918
+
919
+ html[data-sidebar="collapsed"]
920
+ [data-slot="sidebar"][data-state="expanded"]:is(
921
+ [data-variant="floating"],
922
+ [data-variant="inset"]
923
+ )
924
+ :is([data-slot="sidebar-gap"], [data-slot="sidebar-container"]) {
925
+ width: calc(var(--sidebar-width-icon) + 1rem + 2px);
926
+ }
@@ -287,7 +287,7 @@ export const DataTable = <
287
287
  * Filter VALUES are deliberately not reset here: `useForm` captures its
288
288
  * `initialValues` once, so resetting them is form surgery rather than a
289
289
  * state assignment. They are also not clobbered - the filter-persist effect
290
- * writes only on `form:change` / `form:submit:success`, never on mount - so
290
+ * writes only on `form:changed` / `form:submit:success`, never on mount - so
291
291
  * the stored filters of the project you left stay its own.
292
292
  */
293
293
  const scopeRef = useRef(props.persistenceKey);
@@ -188,10 +188,10 @@ export const DataTableFilterBar = (props: DataTableFilterBarProps) => {
188
188
  const enumValuesOf = (field: DataTableFilterBarField): string[] => {
189
189
  const schema = schemaOf(field);
190
190
  if (!schema) return [];
191
- if (z.schema.isEnum(schema)) return z.schema.enumValues(schema);
191
+ if (z.schema.isEnum(schema)) return z.schema.enumOptions(schema);
192
192
  if (z.schema.isArray(schema)) {
193
193
  const element = z.schema.unwrap(z.schema.element(schema));
194
- if (z.schema.isEnum(element)) return z.schema.enumValues(element);
194
+ if (z.schema.isEnum(element)) return z.schema.enumOptions(element);
195
195
  }
196
196
  return [];
197
197
  };
@@ -91,7 +91,7 @@ describe("DataTable (a date range on the filter bar)", () => {
91
91
  });
92
92
 
93
93
  const mount = async (
94
- url = "/list",
94
+ url: `/${string}` = "/list",
95
95
  options: { seedValues?: { createdAt?: string[] } } = {},
96
96
  ) => {
97
97
  alepha = Alepha.create().with(AlephaReact).with(AlephaReactI18n).with(App);
@@ -73,7 +73,7 @@ describe("DataTable (filters seeded from the query)", () => {
73
73
  window.history.replaceState({}, "", "/");
74
74
  });
75
75
 
76
- const mount = async (url: string, ui: React.ReactNode) => {
76
+ const mount = async (url: `/${string}`, ui: React.ReactNode) => {
77
77
  alepha = Alepha.create().with(AlephaReact).with(AlephaReactI18n).with(App);
78
78
  await alepha.start();
79
79
  const router = alepha.inject(ReactRouter);
@@ -79,7 +79,7 @@ describe("DataTable (share filters)", () => {
79
79
  window.history.replaceState({}, "", "/");
80
80
  });
81
81
 
82
- const mount = async (url: string, ui: React.ReactNode) => {
82
+ const mount = async (url: `/${string}`, ui: React.ReactNode) => {
83
83
  alepha = Alepha.create().with(AlephaReact).with(AlephaReactI18n).with(App);
84
84
  await alepha.start();
85
85
  const router = alepha.inject(ReactRouter);
@@ -390,7 +390,7 @@ export interface DataTableBaseProps<
390
390
  onSortChange?: (sort: SortState | null) => void;
391
391
  /**
392
392
  * When true (default when `filters` is set), the table refetches on
393
- * every `form:change` event, debounced by 250ms. Set to `false` to
393
+ * every `form:changed` event, debounced by 250ms. Set to `false` to
394
394
  * require an explicit submit.
395
395
  */
396
396
  autoApplyFilters?: boolean;
@@ -103,7 +103,7 @@ export interface RowActionContext {
103
103
  export interface RowAction<T> {
104
104
  label: string;
105
105
  icon?: IconType;
106
- onClick: (item: T, ctx: RowActionContext) => void | Promise<void>;
106
+ onClick: (item: T, ctx: RowActionContext) => unknown;
107
107
  destructive?: boolean;
108
108
  disabled?: (item: T) => boolean;
109
109
  /**
@@ -159,7 +159,7 @@ export interface BulkActionContext {
159
159
  export interface BulkAction<T> {
160
160
  label: string;
161
161
  icon?: IconType;
162
- onClick: (selected: T[], ctx: BulkActionContext) => void | Promise<void>;
162
+ onClick: (selected: T[], ctx: BulkActionContext) => unknown;
163
163
  destructive?: boolean;
164
164
  /**
165
165
  * Whether the action is offered for this selection. Absent means always.
@@ -626,7 +626,7 @@ export interface DataTableFilters<
626
626
  * component's `key` to re-seed on a later arrival.
627
627
  *
628
628
  * **Transient, and by construction.** Persistence is written from
629
- * `form:change` / `form:submit:success` only, never on mount — so a seed
629
+ * `form:changed` / `form:submit:success` only, never on mount , so a seed
630
630
  * shows in the toolbar and narrows the fetch without overwriting the
631
631
  * filter the reader chose for themselves last time. Touch any control and
632
632
  * the resulting values (seed included) become the stored choice, which is
@@ -1,4 +1,5 @@
1
1
  import { type Alepha, type Page, type ZObject, z } from "alepha";
2
+ import { ActionErrorPolicy } from "alepha/react";
2
3
  import { type FormModel, useForm } from "alepha/react/form";
3
4
  import {
4
5
  type Dispatch,
@@ -166,6 +167,7 @@ export const useDataTableData = <T>(options: UseDataTableDataOptions<T>) => {
166
167
  type: "custom",
167
168
  id: "data-table:load",
168
169
  error: error as Error,
170
+ handled: ActionErrorPolicy.isHandled(error),
169
171
  });
170
172
  } finally {
171
173
  // Only the newest request clears `loading`: an older one finishing
@@ -98,7 +98,7 @@ export const useDataTableRefresh = <T>(
98
98
  const resetFilters = useCallback(() => {
99
99
  if (!form || !props.filters) return;
100
100
  // Per-field `.set(undefined)` is necessary: `setInitialValues({})`
101
- // doesn't emit `form:change` for deleted keys, so inputs stay
101
+ // doesn't emit `form:changed` for deleted keys, so inputs stay
102
102
  // visually populated and subscribers don't refetch. Explicit set
103
103
  // keeps everyone in sync.
104
104
  for (const key of filterKeys) {
@@ -162,7 +162,7 @@ export const useDataTableRefresh = <T>(
162
162
  useEffect(() => {
163
163
  if (!form || !autoApply) return;
164
164
  let timeout: ReturnType<typeof setTimeout> | undefined;
165
- const unsub = alepha.events.on("form:change", (event) => {
165
+ const unsub = alepha.events.on("form:changed", (event) => {
166
166
  if (event.id !== form.id) return;
167
167
  if (timeout) clearTimeout(timeout);
168
168
  timeout = setTimeout(() => {
@@ -187,7 +187,7 @@ export const useDataTableRefresh = <T>(
187
187
  );
188
188
  };
189
189
  const unsubs = [
190
- alepha.events.on("form:change", (event) => {
190
+ alepha.events.on("form:changed", (event) => {
191
191
  if (event.id !== form.id) return;
192
192
  writeFilters();
193
193
  }),
@@ -1,4 +1,5 @@
1
1
  import type { Alepha, ZObject } from "alepha";
2
+ import { ActionErrorPolicy } from "alepha/react";
2
3
  import type { FormModel } from "alepha/react/form";
3
4
  import { useCallback, useEffect, useRef, useState } from "react";
4
5
 
@@ -101,7 +102,7 @@ export const useDataTableSummary = (options: UseDataTableSummaryOptions) => {
101
102
  type: "custom",
102
103
  id: "data-table:summary",
103
104
  error: error as Error,
104
- handled: onError !== undefined,
105
+ handled: ActionErrorPolicy.isHandled(error, onError),
105
106
  });
106
107
  onError?.(error as Error);
107
108
  })