@alepha/ui 0.31.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 (188) hide show
  1. package/README.md +1 -1
  2. package/dist/account/AccountConnections.js +1 -1
  3. package/dist/account/AccountConnections.js.map +1 -1
  4. package/dist/account/AccountDeleteDialog.d.ts.map +1 -1
  5. package/dist/account/AccountDeleteDialog.js +17 -17
  6. package/dist/account/AccountDeleteDialog.js.map +1 -1
  7. package/dist/account/AccountKeys.js +2 -2
  8. package/dist/account/AccountKeys.js.map +1 -1
  9. package/dist/account/AccountMfaDialog.d.ts.map +1 -1
  10. package/dist/account/AccountMfaDialog.js +19 -25
  11. package/dist/account/AccountMfaDialog.js.map +1 -1
  12. package/dist/account/AccountPasswordDialog.d.ts.map +1 -1
  13. package/dist/account/AccountPasswordDialog.js +25 -24
  14. package/dist/account/AccountPasswordDialog.js.map +1 -1
  15. package/dist/account/AccountProfile.d.ts.map +1 -1
  16. package/dist/account/AccountProfile.js +17 -24
  17. package/dist/account/AccountProfile.js.map +1 -1
  18. package/dist/account/AccountSecurity.d.ts.map +1 -1
  19. package/dist/account/AccountSecurity.js +21 -19
  20. package/dist/account/AccountSecurity.js.map +1 -1
  21. package/dist/account/AccountSessions.js +1 -1
  22. package/dist/account/AccountSessions.js.map +1 -1
  23. package/dist/account/ApiKeyCreateDialog.d.ts.map +1 -1
  24. package/dist/account/ApiKeyCreateDialog.js +8 -12
  25. package/dist/account/ApiKeyCreateDialog.js.map +1 -1
  26. package/dist/admin/AdminFiles.js +1 -1
  27. package/dist/admin/AdminFiles.js.map +1 -1
  28. package/dist/admin/AdminJobs.js +1 -1
  29. package/dist/admin/AdminJobs.js.map +1 -1
  30. package/dist/admin/AdminKeys.js +1 -1
  31. package/dist/admin/AdminKeys.js.map +1 -1
  32. package/dist/admin/AdminParameters.d.ts.map +1 -1
  33. package/dist/admin/AdminParameters.js +7 -5
  34. package/dist/admin/AdminParameters.js.map +1 -1
  35. package/dist/admin/AdminParametersTreeFooterActions.d.ts +2 -2
  36. package/dist/admin/AdminParametersTreeFooterActions.d.ts.map +1 -1
  37. package/dist/admin/AdminParametersTreeFooterActions.js.map +1 -1
  38. package/dist/admin/AdminParametersTreePane.d.ts +2 -2
  39. package/dist/admin/AdminParametersTreePane.d.ts.map +1 -1
  40. package/dist/admin/AdminParametersTreePane.js.map +1 -1
  41. package/dist/admin/AdminRouter.d.ts +1 -3
  42. package/dist/admin/AdminRouter.d.ts.map +1 -1
  43. package/dist/admin/AdminRouter.js +2 -4
  44. package/dist/admin/AdminRouter.js.map +1 -1
  45. package/dist/admin/AdminSessions.js +1 -1
  46. package/dist/admin/AdminSessions.js.map +1 -1
  47. package/dist/admin/AdminUserAvatarControl.d.ts.map +1 -1
  48. package/dist/admin/AdminUserAvatarControl.js +9 -16
  49. package/dist/admin/AdminUserAvatarControl.js.map +1 -1
  50. package/dist/admin/AdminUserDetail.js +4 -4
  51. package/dist/admin/AdminUserDetail.js.map +1 -1
  52. package/dist/admin/AdminUsers.d.ts.map +1 -1
  53. package/dist/admin/AdminUsers.js +10 -12
  54. package/dist/admin/AdminUsers.js.map +1 -1
  55. package/dist/admin/AdminUsersRolesPicker.d.ts +5 -1
  56. package/dist/admin/AdminUsersRolesPicker.d.ts.map +1 -1
  57. package/dist/admin/AdminUsersRolesPicker.js +2 -3
  58. package/dist/admin/AdminUsersRolesPicker.js.map +1 -1
  59. package/dist/admin/analytics/QueryPanel.js +1 -1
  60. package/dist/admin/analytics/QueryPanel.js.map +1 -1
  61. package/dist/admin/useConfirmedAction.d.ts +8 -2
  62. package/dist/admin/useConfirmedAction.d.ts.map +1 -1
  63. package/dist/admin/useConfirmedAction.js +15 -4
  64. package/dist/admin/useConfirmedAction.js.map +1 -1
  65. package/dist/auth/AuthLogin.d.ts.map +1 -1
  66. package/dist/auth/AuthLogin.js +4 -4
  67. package/dist/auth/AuthLogin.js.map +1 -1
  68. package/dist/auth/AuthRegister.js.map +1 -1
  69. package/dist/form/AutoForm.js +1 -1
  70. package/dist/form/AutoForm.js.map +1 -1
  71. package/dist/form/Control.d.ts.map +1 -1
  72. package/dist/form/Control.js +11 -1
  73. package/dist/form/Control.js.map +1 -1
  74. package/dist/form/ControlArray.js +5 -5
  75. package/dist/form/ControlArray.js.map +1 -1
  76. package/dist/form/ControlSelect.js +2 -2
  77. package/dist/form/ControlSelect.js.map +1 -1
  78. package/dist/form/ControlUpload.d.ts +1 -1
  79. package/dist/form/ControlUpload.js.map +1 -1
  80. package/dist/i18n/fr/uiFr.d.ts.map +1 -1
  81. package/dist/i18n/fr/uiFr.js +0 -9
  82. package/dist/i18n/fr/uiFr.js.map +1 -1
  83. package/dist/organizations/MyOrganizationInvitations.js +2 -2
  84. package/dist/organizations/MyOrganizationInvitations.js.map +1 -1
  85. package/dist/organizations/OrganizationInviteDialog.js +1 -1
  86. package/dist/organizations/OrganizationInviteDialog.js.map +1 -1
  87. package/dist/organizations/OrganizationMembers.js +1 -1
  88. package/dist/organizations/OrganizationMembers.js.map +1 -1
  89. package/dist/organizations/OrganizationPendingInvitations.js +1 -1
  90. package/dist/organizations/OrganizationPendingInvitations.js.map +1 -1
  91. package/dist/organizations/OrganizationRanks.js +3 -3
  92. package/dist/organizations/OrganizationRanks.js.map +1 -1
  93. package/dist/organizations/useInviteOrganizationMember.d.ts +6 -1
  94. package/dist/organizations/useInviteOrganizationMember.d.ts.map +1 -1
  95. package/dist/organizations/useInviteOrganizationMember.js +13 -13
  96. package/dist/organizations/useInviteOrganizationMember.js.map +1 -1
  97. package/dist/organizations/useRevokeOrganizationInvitation.d.ts +7 -1
  98. package/dist/organizations/useRevokeOrganizationInvitation.d.ts.map +1 -1
  99. package/dist/organizations/useRevokeOrganizationInvitation.js +13 -2
  100. package/dist/organizations/useRevokeOrganizationInvitation.js.map +1 -1
  101. package/dist/shell/ButtonUser.d.ts +1 -2
  102. package/dist/shell/ButtonUser.d.ts.map +1 -1
  103. package/dist/shell/ButtonUser.js +14 -42
  104. package/dist/shell/ButtonUser.js.map +1 -1
  105. package/dist/shell/ButtonUserContent.d.ts +13 -0
  106. package/dist/shell/ButtonUserContent.d.ts.map +1 -0
  107. package/dist/shell/ButtonUserContent.js +52 -0
  108. package/dist/shell/ButtonUserContent.js.map +1 -0
  109. package/dist/shell/ButtonUserPlaceholder.d.ts +14 -0
  110. package/dist/shell/ButtonUserPlaceholder.d.ts.map +1 -0
  111. package/dist/shell/ButtonUserPlaceholder.js +17 -0
  112. package/dist/shell/ButtonUserPlaceholder.js.map +1 -0
  113. package/dist/styles.css +94 -0
  114. package/dist/table/DataTable.js +1 -1
  115. package/dist/table/DataTable.js.map +1 -1
  116. package/dist/table/DataTableFilterBar.js +2 -2
  117. package/dist/table/DataTableFilterBar.js.map +1 -1
  118. package/dist/table/dataTableBaseProps.d.ts +1 -1
  119. package/dist/table/dataTableTypes.d.ts +3 -3
  120. package/dist/table/dataTableTypes.d.ts.map +1 -1
  121. package/dist/table/useDataTableData.d.ts.map +1 -1
  122. package/dist/table/useDataTableData.js +3 -1
  123. package/dist/table/useDataTableData.js.map +1 -1
  124. package/dist/table/useDataTableRefresh.js +2 -2
  125. package/dist/table/useDataTableRefresh.js.map +1 -1
  126. package/dist/table/useDataTableSummary.d.ts.map +1 -1
  127. package/dist/table/useDataTableSummary.js +2 -1
  128. package/dist/table/useDataTableSummary.js.map +1 -1
  129. package/package.json +9 -9
  130. package/src/account/AccountConnections.tsx +1 -1
  131. package/src/account/AccountDeleteDialog.tsx +25 -31
  132. package/src/account/AccountKeys.tsx +2 -2
  133. package/src/account/AccountMfaDialog.tsx +33 -27
  134. package/src/account/AccountPasswordDialog.tsx +36 -39
  135. package/src/account/AccountProfile.tsx +29 -43
  136. package/src/account/AccountSecurity.tsx +57 -64
  137. package/src/account/AccountSessions.tsx +1 -1
  138. package/src/account/ApiKeyCreateDialog.tsx +12 -20
  139. package/src/account/__tests__/AccountRouter.spec.ts +2 -1
  140. package/src/admin/AdminFiles.tsx +1 -1
  141. package/src/admin/AdminJobs.tsx +1 -1
  142. package/src/admin/AdminKeys.tsx +1 -1
  143. package/src/admin/AdminParameters.tsx +7 -5
  144. package/src/admin/AdminParametersTreeFooterActions.tsx +2 -2
  145. package/src/admin/AdminParametersTreePane.tsx +2 -2
  146. package/src/admin/AdminRouter.tsx +2 -4
  147. package/src/admin/AdminSessions.tsx +1 -1
  148. package/src/admin/AdminUserAvatarControl.tsx +17 -22
  149. package/src/admin/AdminUserDetail.tsx +4 -4
  150. package/src/admin/AdminUsers.tsx +10 -12
  151. package/src/admin/AdminUsersRolesPicker.tsx +11 -4
  152. package/src/admin/__tests__/AdminRouter.spec.ts +3 -2
  153. package/src/admin/analytics/QueryPanel.tsx +1 -1
  154. package/src/admin/useConfirmedAction.tsx +24 -10
  155. package/src/auth/AuthLogin.tsx +10 -9
  156. package/src/auth/AuthRegister.tsx +2 -2
  157. package/src/form/AutoForm.tsx +1 -1
  158. package/src/form/Control.tsx +14 -1
  159. package/src/form/ControlArray.tsx +5 -5
  160. package/src/form/ControlSelect.tsx +2 -2
  161. package/src/form/ControlUpload.tsx +1 -1
  162. package/src/form/__tests__/ControlArrayChildChange.browser.spec.tsx +1 -1
  163. package/src/form/__tests__/ControlVerbatim.browser.spec.tsx +71 -0
  164. package/src/i18n/fr/uiFr.ts +0 -9
  165. package/src/organizations/MyOrganizationInvitations.tsx +2 -2
  166. package/src/organizations/OrganizationInviteDialog.tsx +1 -1
  167. package/src/organizations/OrganizationMembers.tsx +1 -1
  168. package/src/organizations/OrganizationPendingInvitations.tsx +1 -1
  169. package/src/organizations/OrganizationRanks.tsx +3 -3
  170. package/src/organizations/useInviteOrganizationMember.ts +22 -15
  171. package/src/organizations/useRevokeOrganizationInvitation.ts +23 -4
  172. package/src/shell/ButtonUser.tsx +14 -79
  173. package/src/shell/ButtonUserContent.tsx +92 -0
  174. package/src/shell/ButtonUserPlaceholder.tsx +25 -0
  175. package/src/shell/__tests__/ActionErrorToaster.browser.spec.tsx +1 -1
  176. package/src/shell/__tests__/ActionErrorToasterHandled.browser.spec.tsx +1 -2
  177. package/src/shell/__tests__/AppShell.pageCache.spec.tsx +67 -0
  178. package/src/styles.css +94 -0
  179. package/src/table/DataTable.tsx +1 -1
  180. package/src/table/DataTableFilterBar.tsx +2 -2
  181. package/src/table/__tests__/DataTableFilterDateRange.browser.spec.tsx +1 -1
  182. package/src/table/__tests__/DataTableQuerySeed.browser.spec.tsx +1 -1
  183. package/src/table/__tests__/DataTableShareFilters.browser.spec.tsx +1 -1
  184. package/src/table/dataTableBaseProps.ts +1 -1
  185. package/src/table/dataTableTypes.ts +3 -3
  186. package/src/table/useDataTableData.ts +2 -0
  187. package/src/table/useDataTableRefresh.ts +3 -3
  188. package/src/table/useDataTableSummary.ts +2 -1
@@ -1,6 +1,7 @@
1
1
  import type { OrganizationInvitationController } from "alepha/api/organizations";
2
- import { useAction, useClient } from "alepha/react";
2
+ import { type RunResult, useAction, useClient } from "alepha/react";
3
3
  import { useI18n } from "alepha/react/i18n";
4
+ import { useCallback } from "react";
4
5
 
5
6
  import { useToast } from "../core/useToast.tsx";
6
7
 
@@ -15,13 +16,17 @@ export interface InviteOrganizationMember {
15
16
  * because a rank says what you may do as staff and a role says whether you
16
17
  * are a coach, and the framework has no business knowing that club has
17
18
  * coaches.
19
+ *
20
+ * Resolves `{ ok: true }` once sent, `{ ok: false, reason: "cancelled" }`
21
+ * when a local check refused it (an empty address, toasted here), and
22
+ * `useAction`'s other results otherwise.
18
23
  */
19
24
  invite: (
20
25
  organizationId: string,
21
26
  email: string,
22
27
  rank: string | undefined,
23
28
  metadata?: Record<string, unknown>,
24
- ) => Promise<boolean | undefined>;
29
+ ) => Promise<RunResult<void>>;
25
30
  loading: boolean;
26
31
  can: boolean;
27
32
  }
@@ -40,18 +45,7 @@ export const useInviteOrganizationMember = (): InviteOrganizationMember => {
40
45
  boolean
41
46
  >(
42
47
  {
43
- handler: async (organizationId, email, rank, passed) => {
44
- /**
45
- * ⚠️ `useAction` appends `{ signal }` as the LAST argument to the
46
- * handler, so a caller passing three arguments lands its abort signal
47
- * in this fourth parameter. Reading it as metadata put an
48
- * `AbortSignal` on the invitation row.
49
- *
50
- * Hence the shape check rather than a plain `?? undefined`: an
51
- * application's metadata is its own object, and the framework's is the
52
- * one carrying `signal`.
53
- */
54
- const metadata = passed && !("signal" in passed) ? passed : undefined;
48
+ handler: async (_ctx, organizationId, email, rank, metadata) => {
55
49
  const trimmed = email.trim();
56
50
  if (!trimmed) {
57
51
  toaster.error(
@@ -81,8 +75,21 @@ export const useInviteOrganizationMember = (): InviteOrganizationMember => {
81
75
  [api, toaster, tr],
82
76
  );
83
77
 
78
+ const invite = useCallback(
79
+ async (
80
+ ...args: Parameters<typeof action.run>
81
+ ): Promise<RunResult<void>> => {
82
+ const result = await action.run(...args);
83
+ if (!result.ok) return result;
84
+ return result.value
85
+ ? { ok: true, value: undefined }
86
+ : { ok: false, reason: "cancelled" };
87
+ },
88
+ [action.run],
89
+ );
90
+
84
91
  return {
85
- invite: action.run,
92
+ invite,
86
93
  loading: action.loading,
87
94
  can: api.createOrganizationInvitation.can(),
88
95
  };
@@ -1,16 +1,22 @@
1
1
  import type { OrganizationInvitationController } from "alepha/api/organizations";
2
- import { useAction, useClient } from "alepha/react";
2
+ import { type RunResult, useAction, useClient } from "alepha/react";
3
3
  import { useI18n } from "alepha/react/i18n";
4
+ import { useCallback } from "react";
4
5
 
5
6
  import { useDialog } from "../core/useDialog.tsx";
6
7
  import { useToast } from "../core/useToast.tsx";
7
8
 
8
9
  export interface RevokeOrganizationInvitation {
10
+ /**
11
+ * Ask, then revoke. Resolves `{ ok: true }` once revoked,
12
+ * `{ ok: false, reason: "cancelled" }` when the user declined the confirm,
13
+ * and `useAction`'s other results otherwise.
14
+ */
9
15
  revoke: (
10
16
  organizationId: string,
11
17
  invitationId: string,
12
18
  email: string,
13
- ) => Promise<boolean | undefined>;
19
+ ) => Promise<RunResult<void>>;
14
20
  loading: boolean;
15
21
  can: boolean;
16
22
  }
@@ -26,7 +32,7 @@ export const useRevokeOrganizationInvitation =
26
32
  boolean
27
33
  >(
28
34
  {
29
- handler: async (organizationId, invitationId, email) => {
35
+ handler: async (_ctx, organizationId, invitationId, email) => {
30
36
  const confirmed = await dialog.confirm({
31
37
  title: tr("organizations.invitations.revokeTitle", {
32
38
  default: "Revoke the invitation for $1?",
@@ -58,8 +64,21 @@ export const useRevokeOrganizationInvitation =
58
64
  [api, dialog, toaster, tr],
59
65
  );
60
66
 
67
+ const revoke = useCallback(
68
+ async (
69
+ ...args: Parameters<typeof action.run>
70
+ ): Promise<RunResult<void>> => {
71
+ const result = await action.run(...args);
72
+ if (!result.ok) return result;
73
+ return result.value
74
+ ? { ok: true, value: undefined }
75
+ : { ok: false, reason: "cancelled" };
76
+ },
77
+ [action.run],
78
+ );
79
+
61
80
  return {
62
- revoke: action.run,
81
+ revoke,
63
82
  loading: action.loading,
64
83
  can: api.revokeOrganizationInvitation.can(),
65
84
  };
@@ -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
@@ -87,6 +87,41 @@
87
87
  }
88
88
  }
89
89
 
90
+ /*
91
+ * Safe areas, opt-in: padding that keeps content clear of a notch, the
92
+ * status bar and the home indicator in an edge-to-edge native shell.
93
+ *
94
+ * `--safe-area-inset-*` first: Capacitor's `SystemBars` injects them, because
95
+ * Android WebViews older than 140 misreport `env(safe-area-inset-*)`. Then
96
+ * `env()`, which is all an iPhone needs. Both resolve to 0 in a browser and
97
+ * in any document without `viewport-fit=cover`, so the same markup serves the
98
+ * website unchanged. Each sets the padding outright: put the inset on an
99
+ * element of its own, not on one that has a padding utility already.
100
+ */
101
+ @utility pt-safe {
102
+ padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
103
+ }
104
+
105
+ @utility pb-safe {
106
+ padding-bottom: var(
107
+ --safe-area-inset-bottom,
108
+ env(safe-area-inset-bottom, 0px)
109
+ );
110
+ }
111
+
112
+ @utility pl-safe {
113
+ padding-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
114
+ }
115
+
116
+ @utility pr-safe {
117
+ padding-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
118
+ }
119
+
120
+ @utility px-safe {
121
+ padding-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
122
+ padding-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
123
+ }
124
+
90
125
  @theme inline {
91
126
  --color-background: var(--background);
92
127
  --color-foreground: var(--foreground);
@@ -435,6 +470,34 @@
435
470
  @apply bg-background text-foreground;
436
471
  }
437
472
 
473
+ /*
474
+ * Browser tells removed inside a native shell only (`data-native`, set by
475
+ * `@alepha/capacitor`): no grey flash on tap, no rubber band past the page,
476
+ * no long-press preview of links and images. Selection is never touched,
477
+ * and fields and editable text keep their callout, so typing, copying and
478
+ * assistive technology work as they do on the web.
479
+ */
480
+ html[data-native] {
481
+ -webkit-tap-highlight-color: transparent;
482
+ overscroll-behavior: none;
483
+ }
484
+
485
+ html[data-native] body {
486
+ -webkit-touch-callout: none;
487
+ }
488
+
489
+ html[data-native]
490
+ :is(
491
+ input,
492
+ textarea,
493
+ select,
494
+ [contenteditable]:not([contenteditable="false"]),
495
+ .select-text,
496
+ .select-all
497
+ ) {
498
+ -webkit-touch-callout: default;
499
+ }
500
+
438
501
  /*
439
502
  * The heading face. This rule is the whole of what makes `--font-heading`
440
503
  * exist - see the token's own note in `:root` for the dead one it replaces.
@@ -830,3 +893,34 @@
830
893
  ) {
831
894
  border-color: var(--border-hover);
832
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