@eifi1/ui-kit 0.30.0 → 0.31.1

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 (269) hide show
  1. package/README.md +42 -5
  2. package/dist/account/data-export-setting.js +3 -2
  3. package/dist/account/data-export-setting.js.map +1 -1
  4. package/dist/account/delete-account-setting.d.ts +5 -1
  5. package/dist/account/delete-account-setting.js +3 -2
  6. package/dist/account/delete-account-setting.js.map +1 -1
  7. package/dist/account/email-change-setting.js +4 -3
  8. package/dist/account/email-change-setting.js.map +1 -1
  9. package/dist/account/sessions-setting.js +3 -2
  10. package/dist/account/sessions-setting.js.map +1 -1
  11. package/dist/admin/admin-action-confirm.d.ts +5 -1
  12. package/dist/admin/admin-parts.d.ts +8 -1
  13. package/dist/admin/admin-parts.js +1 -1
  14. package/dist/admin/admin-parts.js.map +1 -1
  15. package/dist/admin/invitations-panel.d.ts +5 -1
  16. package/dist/admin/invitations-panel.js +3 -2
  17. package/dist/admin/invitations-panel.js.map +1 -1
  18. package/dist/admin/reviewer-scope-editor.d.ts +5 -1
  19. package/dist/admin/role-select.d.ts +5 -1
  20. package/dist/admin/transfer-ownership-dialog.d.ts +5 -1
  21. package/dist/admin/user-roster.d.ts +5 -1
  22. package/dist/auth/auth-errors.d.ts +24 -6
  23. package/dist/auth/auth-errors.js +7 -1
  24. package/dist/auth/auth-errors.js.map +1 -1
  25. package/dist/auth/register-form.d.ts +5 -1
  26. package/dist/auth/reset-password-form.d.ts +1 -1
  27. package/dist/auth/reset-password-form.js +2 -1
  28. package/dist/auth/reset-password-form.js.map +1 -1
  29. package/dist/auth/sign-in-form.d.ts +15 -1
  30. package/dist/auth/sign-in-form.js +12 -3
  31. package/dist/auth/sign-in-form.js.map +1 -1
  32. package/dist/auth/verify-email.d.ts +4 -0
  33. package/dist/auth/verify-email.js +3 -2
  34. package/dist/auth/verify-email.js.map +1 -1
  35. package/dist/chart.d.ts +5 -1
  36. package/dist/components/account-settings-labels.d.ts +12 -0
  37. package/dist/components/account-settings-labels.js +2 -1
  38. package/dist/components/account-settings-labels.js.map +1 -1
  39. package/dist/components/account-settings.d.ts +8 -2
  40. package/dist/components/account-settings.js +19 -11
  41. package/dist/components/account-settings.js.map +1 -1
  42. package/dist/components/amount-input.d.ts +5 -1
  43. package/dist/components/button-group.d.ts +5 -1
  44. package/dist/components/calculator.d.ts +5 -1
  45. package/dist/components/confirm-dialog.d.ts +5 -1
  46. package/dist/components/confirm-dialog.js +7 -1
  47. package/dist/components/confirm-dialog.js.map +1 -1
  48. package/dist/components/copy-button.d.ts +5 -1
  49. package/dist/components/danger-confirm.d.ts +5 -1
  50. package/dist/components/data-table.js +8 -1
  51. package/dist/components/data-table.js.map +1 -1
  52. package/dist/components/date-picker.js +9 -4
  53. package/dist/components/date-picker.js.map +1 -1
  54. package/dist/components/facing-pair.d.ts +5 -1
  55. package/dist/components/file-button.d.ts +5 -1
  56. package/dist/components/file-dropzone.d.ts +5 -1
  57. package/dist/components/form-actions.d.ts +5 -1
  58. package/dist/components/iban-input.d.ts +5 -1
  59. package/dist/components/language-select.d.ts +5 -1
  60. package/dist/components/legal-page.d.ts +5 -1
  61. package/dist/components/legal.d.ts +5 -1
  62. package/dist/components/money-field.d.ts +5 -1
  63. package/dist/components/number-field.d.ts +5 -1
  64. package/dist/components/number-input.d.ts +5 -1
  65. package/dist/components/numpad-sheet.d.ts +5 -1
  66. package/dist/components/passkeys-setting.js +2 -1
  67. package/dist/components/passkeys-setting.js.map +1 -1
  68. package/dist/components/phone-input.d.ts +5 -1
  69. package/dist/components/series-chart.d.ts +5 -1
  70. package/dist/components/settings-fields.d.ts +40 -3
  71. package/dist/components/settings-fields.js +20 -1
  72. package/dist/components/settings-fields.js.map +1 -1
  73. package/dist/components/share-card.d.ts +5 -1
  74. package/dist/components/text-link.d.ts +5 -1
  75. package/dist/components/time-input.d.ts +5 -1
  76. package/dist/components/ui.d.ts +5 -1
  77. package/dist/{delete-account-setting-CGVMckMw.d.ts → delete-account-setting-CpIhzxxZ.d.ts} +60 -23
  78. package/dist/demo/demo-banner.d.ts +51 -0
  79. package/dist/demo/demo-banner.js +97 -0
  80. package/dist/demo/demo-banner.js.map +1 -0
  81. package/dist/demo/demo-countdown.d.ts +58 -0
  82. package/dist/demo/demo-countdown.js +79 -0
  83. package/dist/demo/demo-countdown.js.map +1 -0
  84. package/dist/demo/demo-ended.d.ts +45 -0
  85. package/dist/demo/demo-ended.js +42 -0
  86. package/dist/demo/demo-ended.js.map +1 -0
  87. package/dist/demo/demo-labels.d.ts +53 -0
  88. package/dist/demo/demo-labels.js +29 -0
  89. package/dist/demo/demo-labels.js.map +1 -0
  90. package/dist/demo/demo-session.d.ts +30 -0
  91. package/dist/demo/demo-session.js +8 -0
  92. package/dist/demo/demo-session.js.map +1 -0
  93. package/dist/demo/demo-start.d.ts +54 -0
  94. package/dist/demo/demo-start.js +68 -0
  95. package/dist/demo/demo-start.js.map +1 -0
  96. package/dist/feedback/feedback-attachment.d.ts +5 -1
  97. package/dist/feedback/feedback-context.d.ts +5 -1
  98. package/dist/feedback/feedback-crash.d.ts +5 -1
  99. package/dist/feedback/feedback-dialog.d.ts +5 -1
  100. package/dist/feedback/feedback-inbox.d.ts +5 -1
  101. package/dist/feedback/feedback-inbox.js +12 -2
  102. package/dist/feedback/feedback-inbox.js.map +1 -1
  103. package/dist/feedback/feedback-labels.d.ts +5 -1
  104. package/dist/feedback/feedback-labels.js +1 -0
  105. package/dist/feedback/feedback-labels.js.map +1 -1
  106. package/dist/feedback/feedback-menu.d.ts +5 -1
  107. package/dist/feedback/feedback-record.d.ts +5 -1
  108. package/dist/feedback/feedback-record.js +2 -0
  109. package/dist/feedback/feedback-record.js.map +1 -1
  110. package/dist/feedback/feedback-row-detail.d.ts +5 -1
  111. package/dist/feedback/feedback-row-detail.js +7 -0
  112. package/dist/feedback/feedback-row-detail.js.map +1 -1
  113. package/dist/feedback/feedback-status-undo.d.ts +5 -1
  114. package/dist/feedback/feedback-submit.d.ts +5 -1
  115. package/dist/feedback/feedback-swipe.d.ts +6 -2
  116. package/dist/feedback/feedback-swipe.js.map +1 -1
  117. package/dist/feedback/feedback-table.d.ts +5 -1
  118. package/dist/feedback/feedback-thread.d.ts +5 -1
  119. package/dist/feedback.d.ts +5 -1
  120. package/dist/hooks/use-file-drop.d.ts +5 -1
  121. package/dist/i18n/defaults.d.ts +5 -1
  122. package/dist/i18n/defaults.js +6 -0
  123. package/dist/i18n/defaults.js.map +1 -1
  124. package/dist/i18n/german.d.ts +5 -1
  125. package/dist/i18n/german.js +85 -2
  126. package/dist/i18n/german.js.map +1 -1
  127. package/dist/i18n/kit-labels.d.ts +5 -1
  128. package/dist/i18n/kit-labels.js.map +1 -1
  129. package/dist/i18n/languages.d.ts +5 -1
  130. package/dist/i18n/locales/de-CH.d.ts +5 -1
  131. package/dist/i18n/locales/en.d.ts +5 -1
  132. package/dist/i18n/locales/es.d.ts +5 -1
  133. package/dist/i18n/locales/es.js +82 -2
  134. package/dist/i18n/locales/es.js.map +1 -1
  135. package/dist/i18n/locales/fr.d.ts +5 -1
  136. package/dist/i18n/locales/fr.js +83 -2
  137. package/dist/i18n/locales/fr.js.map +1 -1
  138. package/dist/i18n/locales/hu.d.ts +5 -1
  139. package/dist/i18n/locales/hu.js +83 -2
  140. package/dist/i18n/locales/hu.js.map +1 -1
  141. package/dist/i18n/locales/it.d.ts +5 -1
  142. package/dist/i18n/locales/it.js +82 -2
  143. package/dist/i18n/locales/it.js.map +1 -1
  144. package/dist/i18n/locales/zh.d.ts +5 -1
  145. package/dist/i18n/locales/zh.js +81 -2
  146. package/dist/i18n/locales/zh.js.map +1 -1
  147. package/dist/i18n/review.d.ts +5 -1
  148. package/dist/i18n/review.js +15 -1
  149. package/dist/i18n/review.js.map +1 -1
  150. package/dist/index.d.ts +25 -3
  151. package/dist/index.js +96 -0
  152. package/dist/index.js.map +1 -1
  153. package/dist/landing/access.d.ts +48 -0
  154. package/dist/landing/access.js +38 -0
  155. package/dist/landing/access.js.map +1 -0
  156. package/dist/landing/landing-actions.d.ts +140 -0
  157. package/dist/landing/landing-actions.js +39 -0
  158. package/dist/landing/landing-actions.js.map +1 -0
  159. package/dist/landing/landing-labels.d.ts +43 -0
  160. package/dist/landing/landing-labels.js +23 -0
  161. package/dist/landing/landing-labels.js.map +1 -0
  162. package/dist/landing/landing-sections.d.ts +218 -0
  163. package/dist/landing/landing-sections.js +167 -0
  164. package/dist/landing/landing-sections.js.map +1 -0
  165. package/dist/landing/page-seo.d.ts +99 -0
  166. package/dist/landing/page-seo.js +121 -0
  167. package/dist/landing/page-seo.js.map +1 -0
  168. package/dist/landing/public-header.d.ts +148 -0
  169. package/dist/landing/public-header.js +49 -0
  170. package/dist/landing/public-header.js.map +1 -0
  171. package/dist/landing/routing.d.ts +231 -0
  172. package/dist/landing/routing.js +84 -0
  173. package/dist/landing/routing.js.map +1 -0
  174. package/dist/rhf/fields.d.ts +5 -1
  175. package/dist/rhf/form.d.ts +5 -1
  176. package/dist/rhf.d.ts +5 -1
  177. package/dist/settings/settings-catalogue.d.ts +84 -0
  178. package/dist/settings/settings-catalogue.js +47 -0
  179. package/dist/settings/settings-catalogue.js.map +1 -0
  180. package/dist/settings/settings-context.d.ts +31 -0
  181. package/dist/settings/settings-context.js +11 -0
  182. package/dist/settings/settings-context.js.map +1 -0
  183. package/dist/settings/settings-heading.d.ts +50 -0
  184. package/dist/settings/settings-heading.js +27 -0
  185. package/dist/settings/settings-heading.js.map +1 -0
  186. package/dist/settings/settings-labels.d.ts +48 -0
  187. package/dist/settings/settings-labels.js +43 -0
  188. package/dist/settings/settings-labels.js.map +1 -0
  189. package/dist/settings/settings-layout.d.ts +77 -0
  190. package/dist/settings/settings-layout.js +242 -0
  191. package/dist/settings/settings-layout.js.map +1 -0
  192. package/dist/settings/settings-section.d.ts +133 -0
  193. package/dist/settings/settings-section.js +63 -0
  194. package/dist/settings/settings-section.js.map +1 -0
  195. package/dist/settings/use-account-language.d.ts +83 -0
  196. package/dist/settings/use-account-language.js +62 -0
  197. package/dist/settings/use-account-language.js.map +1 -0
  198. package/dist/settings/use-settings-focus.d.ts +34 -0
  199. package/dist/settings/use-settings-focus.js +77 -0
  200. package/dist/settings/use-settings-focus.js.map +1 -0
  201. package/dist/settings/use-settings-route.d.ts +118 -0
  202. package/dist/settings/use-settings-route.js +120 -0
  203. package/dist/settings/use-settings-route.js.map +1 -0
  204. package/dist/shell/app-shell.d.ts +11 -1
  205. package/dist/shell/app-shell.js +3 -2
  206. package/dist/shell/app-shell.js.map +1 -1
  207. package/dist/shell/top-bar-brand.d.ts +5 -1
  208. package/dist/shell.d.ts +15 -1
  209. package/dist/shell.js +56 -0
  210. package/dist/shell.js.map +1 -1
  211. package/dist/wizard/stepper-nav.d.ts +5 -1
  212. package/dist/wizard.d.ts +5 -1
  213. package/package.json +2 -1
  214. package/src/account/data-export-setting.tsx +3 -2
  215. package/src/account/delete-account-setting.tsx +3 -2
  216. package/src/account/email-change-setting.tsx +4 -7
  217. package/src/account/sessions-setting.tsx +3 -2
  218. package/src/admin/admin-parts.ts +9 -2
  219. package/src/admin/invitations-panel.tsx +11 -4
  220. package/src/auth/auth-errors.ts +36 -5
  221. package/src/auth/reset-password-form.tsx +6 -2
  222. package/src/auth/sign-in-form.tsx +34 -3
  223. package/src/auth/verify-email.tsx +14 -2
  224. package/src/components/account-settings-labels.ts +13 -0
  225. package/src/components/account-settings.tsx +33 -12
  226. package/src/components/confirm-dialog.tsx +20 -1
  227. package/src/components/data-table.tsx +8 -0
  228. package/src/components/date-picker.tsx +9 -4
  229. package/src/components/passkeys-setting.tsx +2 -1
  230. package/src/components/settings-fields.tsx +50 -1
  231. package/src/demo/demo-banner.tsx +159 -0
  232. package/src/demo/demo-countdown.ts +141 -0
  233. package/src/demo/demo-ended.tsx +89 -0
  234. package/src/demo/demo-labels.ts +78 -0
  235. package/src/demo/demo-session.ts +32 -0
  236. package/src/demo/demo-start.tsx +150 -0
  237. package/src/feedback/feedback-inbox.tsx +21 -8
  238. package/src/feedback/feedback-labels.ts +2 -1
  239. package/src/feedback/feedback-record.ts +10 -7
  240. package/src/feedback/feedback-row-detail.tsx +28 -4
  241. package/src/feedback/feedback-swipe.tsx +1 -1
  242. package/src/i18n/defaults.ts +6 -0
  243. package/src/i18n/german.ts +87 -0
  244. package/src/i18n/kit-labels.tsx +9 -0
  245. package/src/i18n/locales/es.ts +84 -0
  246. package/src/i18n/locales/fr.ts +85 -0
  247. package/src/i18n/locales/hu.ts +85 -0
  248. package/src/i18n/locales/it.ts +84 -0
  249. package/src/i18n/locales/zh.ts +82 -0
  250. package/src/i18n/review.ts +14 -0
  251. package/src/index.ts +98 -1
  252. package/src/landing/access.ts +97 -0
  253. package/src/landing/landing-actions.tsx +96 -0
  254. package/src/landing/landing-labels.ts +59 -0
  255. package/src/landing/landing-sections.tsx +337 -0
  256. package/src/landing/page-seo.ts +251 -0
  257. package/src/landing/public-header.tsx +120 -0
  258. package/src/landing/routing.tsx +226 -0
  259. package/src/settings/settings-catalogue.ts +132 -0
  260. package/src/settings/settings-context.ts +33 -0
  261. package/src/settings/settings-heading.tsx +65 -0
  262. package/src/settings/settings-labels.ts +87 -0
  263. package/src/settings/settings-layout.tsx +379 -0
  264. package/src/settings/settings-section.tsx +108 -0
  265. package/src/settings/use-account-language.ts +146 -0
  266. package/src/settings/use-settings-focus.ts +120 -0
  267. package/src/settings/use-settings-route.ts +258 -0
  268. package/src/shell/app-shell.tsx +10 -2
  269. package/src/shell.ts +51 -0
@@ -0,0 +1,120 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { useLocation, useNavigate } from "react-router";
3
+
4
+ /**
5
+ * The ring a `?focus=` target wears for {@link SETTINGS_FOCUS_MS} — keksdose's
6
+ * `HIGHLIGHT`, in tokens: `--brand` for the ring and the page's own surface for the gap,
7
+ * where keksdose named a slate for the dark theme. A ring rather than a background
8
+ * flash: the destructive cards already own a background tint, and a ring reads the same
9
+ * on every card.
10
+ */
11
+ export const SETTINGS_FOCUS_RING = ["ring-2", "ring-[var(--brand)]", "ring-offset-2", "ring-offset-[var(--bg-page)]"];
12
+
13
+ /** How long the ring stays (§3.5). */
14
+ export const SETTINGS_FOCUS_MS = 1800;
15
+
16
+ /** How long a target that is not on the page yet (a lazy card, a card waiting for its
17
+ * data) is waited for before the hook gives up on it. */
18
+ const WAIT_MS = 5000;
19
+
20
+ const HEADING = "[data-settings-heading], h1, h2, h3, h4, h5, h6";
21
+
22
+ function prefersReducedMotion(): boolean {
23
+ return typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
24
+ }
25
+
26
+ /**
27
+ * `?focus=<anchor>` (docs/settings-harmonization.md §3.5): scroll the card into view, ring
28
+ * it for 1.8 s, move focus to its heading for a screen reader, then remove `focus` — and
29
+ * ONLY `focus` — with a replace, so a reload does not ring it again. Every other
30
+ * parameter stays: a tour's `tour` / `tourStep`, the admin roster's filters (dropping URL
31
+ * parts broke keksdose's tours once, dev#495). The hash and `location.state` stay too.
32
+ *
33
+ * A search hit, ⌘K, a tour and a mail link all arrive this way. `SettingsLayout` calls it
34
+ * for its own page; an app's own page can call it with no argument to act on its URL.
35
+ *
36
+ * `anchor`:
37
+ * - left out: the URL's `focus` parameter;
38
+ * - a string: that anchor (the layout passes the URL's, once its route is canonical);
39
+ * - `null`: nothing to do yet — the layout passes it while the address is about to be
40
+ * replaced, so a removal here cannot undo a redirect there.
41
+ *
42
+ * "Once its group has rendered": the effect runs after the commit that mounted the
43
+ * group's cards, so the card is there; a card that mounts later (lazy, or behind its
44
+ * data) is waited for, for a few seconds, before the hook gives up and leaves the URL
45
+ * as it is.
46
+ */
47
+ export function useSettingsFocus(anchor?: string | null): void {
48
+ const location = useLocation();
49
+ const navigate = useNavigate();
50
+ const target = anchor === undefined ? new URLSearchParams(location.search).get("focus") : anchor;
51
+ // The ring outlives the effect that drew it: removing `focus` from the URL re-runs the
52
+ // effect (and cleans it up) at once, and the ring must still stay its 1.8 s.
53
+ const ring = useRef<{ el: HTMLElement; timer: number } | null>(null);
54
+
55
+ useEffect(() => {
56
+ if (!target) return;
57
+ const { pathname, search, hash, state } = location;
58
+
59
+ const land = (el: HTMLElement) => {
60
+ el.scrollIntoView?.({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "center" });
61
+
62
+ if (ring.current) {
63
+ window.clearTimeout(ring.current.timer);
64
+ ring.current.el.classList.remove(...SETTINGS_FOCUS_RING);
65
+ }
66
+ el.classList.add(...SETTINGS_FOCUS_RING);
67
+ el.setAttribute("data-settings-focus", "");
68
+ const timer = window.setTimeout(() => {
69
+ el.classList.remove(...SETTINGS_FOCUS_RING);
70
+ el.removeAttribute("data-settings-focus");
71
+ if (ring.current?.el === el) ring.current = null;
72
+ }, SETTINGS_FOCUS_MS);
73
+ ring.current = { el, timer };
74
+
75
+ // The heading, so a screen reader starts at the card's name; the card itself when
76
+ // it has none. `preventScroll`: the smooth scroll above is already on its way.
77
+ const heading = el.querySelector<HTMLElement>(HEADING) ?? el;
78
+ if (!heading.hasAttribute("tabindex")) heading.setAttribute("tabindex", "-1");
79
+ heading.focus({ preventScroll: true });
80
+
81
+ const params = new URLSearchParams(search);
82
+ if (params.get("focus") !== target) return;
83
+ params.delete("focus");
84
+ const rest = params.toString();
85
+ navigate({ pathname, search: rest ? `?${rest}` : "", hash }, { replace: true, state });
86
+ };
87
+
88
+ const found = document.getElementById(target);
89
+ if (found) {
90
+ land(found);
91
+ return;
92
+ }
93
+ const observer = new MutationObserver(() => {
94
+ const el = document.getElementById(target);
95
+ if (!el) return;
96
+ observer.disconnect();
97
+ window.clearTimeout(giveUp);
98
+ land(el);
99
+ });
100
+ observer.observe(document.body, { childList: true, subtree: true });
101
+ const giveUp = window.setTimeout(() => observer.disconnect(), WAIT_MS);
102
+ return () => {
103
+ observer.disconnect();
104
+ window.clearTimeout(giveUp);
105
+ };
106
+ // `location`, a new object per navigation: the same hit picked twice is two
107
+ // navigations, and rings twice.
108
+ }, [target, location, navigate]);
109
+
110
+ useEffect(
111
+ () => () => {
112
+ const current = ring.current;
113
+ if (!current) return;
114
+ window.clearTimeout(current.timer);
115
+ current.el.classList.remove(...SETTINGS_FOCUS_RING);
116
+ current.el.removeAttribute("data-settings-focus");
117
+ },
118
+ [],
119
+ );
120
+ }
@@ -0,0 +1,258 @@
1
+ import { useCallback, useEffect, useMemo } from "react";
2
+ import { useLocation, useNavigate } from "react-router";
3
+ import { useMediaQuery } from "../hooks/use-media-query";
4
+ import { PHONE_QUERY } from "../components/ui";
5
+ import { normalizeSettingsBase, visibleSettingsGroups } from "./settings-catalogue";
6
+ import type { SettingsEntry, SettingsGroup } from "./settings-catalogue";
7
+
8
+ /**
9
+ * Which layout the settings page is in. `"auto"` follows the screen ({@link PHONE_QUERY},
10
+ * as `Tabs` does); `"desktop"` / `"phone"` pin one — for a preview of both side by side,
11
+ * where the window is one width.
12
+ */
13
+ export type SettingsLayoutMode = "auto" | "desktop" | "phone";
14
+
15
+ export interface UseSettingsRouteOptions<G extends string> {
16
+ groups: readonly SettingsGroup<G>[];
17
+ /** The catalogue's entries. Given, a group with no visible entry is hidden (§4.1), and
18
+ * `/settings?focus=<anchor>` finds the anchor's group. */
19
+ entries?: readonly SettingsEntry<G>[];
20
+ /** `/settings` or `/admin`. */
21
+ basePath: string;
22
+ /** The group `/settings` opens on a desktop. Default: the first visible group (§4.1). */
23
+ defaultGroup?: G;
24
+ /** Retired group ids and their successors — `{ overview: "metrics" }` — applied with a
25
+ * replace (§3.1, keksdose's admin). */
26
+ aliases?: Readonly<Partial<Record<string, G>>>;
27
+ /** See {@link SettingsLayoutMode}. Default `"auto"`. */
28
+ layout?: SettingsLayoutMode;
29
+ }
30
+
31
+ export interface SettingsRoute<G extends string> {
32
+ /** The group on screen. `null` on a phone's list (and while there is no visible group). */
33
+ group: G | null;
34
+ /** The segment after the group, owned by a card; `null` without one. */
35
+ sub: string | null;
36
+ /** `?focus=<anchor>`, or `null`. */
37
+ focus: string | null;
38
+ /** Open a group: a PUSH on a phone, so the system back gesture returns to the list; a
39
+ * REPLACE on a desktop, so back leaves settings instead of walking every group looked
40
+ * at (§3.1, keksdose's rule). */
41
+ select: (group: G) => void;
42
+ /** See {@link SettingsLayoutContextValue.selectSub}. */
43
+ selectSub: (sub: string | null) => void;
44
+ /** To the list: `navigate(-1)` when the list is the previous entry, else a replace to
45
+ * the base path — so a deep link from a mail never sends "back" out of the app. */
46
+ back: () => void;
47
+ /** The visible groups, in order. */
48
+ groups: SettingsGroup<G>[];
49
+ /** Whether the phone layout is in force. */
50
+ phone: boolean;
51
+ /** Whether this location is about to be replaced (a legacy hash, an alias, an unknown
52
+ * group): what renders meanwhile is already the destination's, but nothing should
53
+ * act on the URL until it is. */
54
+ redirecting: boolean;
55
+ /** Whether the list is the entry before this one (the marker {@link select} and the
56
+ * list's links leave in `location.state`). */
57
+ fromList: boolean;
58
+ }
59
+
60
+ /**
61
+ * The `location.state` key that says "the list is the entry before this one". Written by
62
+ * the phone list's links and {@link SettingsRoute.select}; carried over by every replace
63
+ * the page makes, since a replace does not change what came before.
64
+ */
65
+ export const SETTINGS_FROM_LIST_STATE = "eifi1.settings.fromList";
66
+
67
+ /** `location.state` with the marker set — for an app's own link to a group page that is
68
+ * opened FROM the list it renders. */
69
+ export function settingsFromListState(): Record<string, true> {
70
+ return { [SETTINGS_FROM_LIST_STATE]: true };
71
+ }
72
+
73
+ function isFromList(state: unknown): boolean {
74
+ return typeof state === "object" && state !== null && (state as Record<string, unknown>)[SETTINGS_FROM_LIST_STATE] === true;
75
+ }
76
+
77
+ export interface SettingsLocation {
78
+ pathname: string;
79
+ search: string;
80
+ hash: string;
81
+ }
82
+
83
+ export interface SettingsLocationRules<G extends string> {
84
+ basePath: string;
85
+ /** The visible group ids. */
86
+ groups: readonly G[];
87
+ /** The resolved default group, `null` with no visible group. */
88
+ defaultGroup: G | null;
89
+ aliases?: Readonly<Partial<Record<string, G>>>;
90
+ /** Anchor → group, for `/settings?focus=<anchor>` with no group named. */
91
+ anchorGroup?: ReadonlyMap<string, G>;
92
+ phone: boolean;
93
+ }
94
+
95
+ export interface SettingsLocationResult<G extends string> {
96
+ group: G | null;
97
+ sub: string | null;
98
+ /** The path (with query) to replace the location with, or `null` when it is already
99
+ * canonical. */
100
+ redirect: string | null;
101
+ }
102
+
103
+ /**
104
+ * Where a location lands on the settings page — pure, so the rules of §3.1 are testable
105
+ * without a router:
106
+ *
107
+ * - `/settings` → the default group on a desktop (a replace), the list on a phone;
108
+ * - `/settings/<group>[/<sub>]` → that group, the rest of the path as `sub`;
109
+ * - an alias → its successor, with a replace, `sub`, query and hash kept;
110
+ * - an unknown or hidden group → the default group (desktop) or the list (phone), with
111
+ * a replace and the query kept — never a 404, so an old bookmark still lands;
112
+ * - keksdose's legacy `/settings?<query>#<group>[/<sub>]` →
113
+ * `/settings/<group>[/<sub>]?<query>`, the WHOLE query carried (a tour's
114
+ * `tour`/`tourStep` as well as `focus`), then resolved by the rules above;
115
+ * - `/settings?focus=<anchor>` with no group → the anchor's group, where it can ring.
116
+ */
117
+ export function resolveSettingsLocation<G extends string>(
118
+ location: SettingsLocation,
119
+ rules: SettingsLocationRules<G>,
120
+ ): SettingsLocationResult<G> {
121
+ const base = normalizeSettingsBase(rules.basePath);
122
+ const { pathname, search, hash } = location;
123
+ const known = new Set<string>(rules.groups);
124
+ const atBase = pathname === base || pathname === `${base}/` || (base === "" && pathname === "/");
125
+
126
+ if (atBase) {
127
+ const legacy = hash.replace(/^#/, "").replace(/^\/+/, "");
128
+ if (legacy) {
129
+ // The hash becomes the path; whatever the path then says (an alias, an unknown
130
+ // group) is resolved in the same step, so the history sees one replace.
131
+ const converted = `${base}/${legacy}`;
132
+ const next = resolveSettingsLocation({ pathname: converted, search, hash: "" }, rules);
133
+ return { ...next, redirect: next.redirect ?? `${converted}${search}` };
134
+ }
135
+ const anchor = new URLSearchParams(search).get("focus");
136
+ const anchorGroup = anchor ? rules.anchorGroup?.get(anchor) : undefined;
137
+ if (anchorGroup && known.has(anchorGroup)) {
138
+ return { group: anchorGroup, sub: null, redirect: `${base}/${anchorGroup}${search}` };
139
+ }
140
+ if (rules.phone || rules.defaultGroup === null) return { group: null, sub: null, redirect: null };
141
+ return { group: rules.defaultGroup, sub: null, redirect: `${base}/${rules.defaultGroup}${search}` };
142
+ }
143
+
144
+ if (!pathname.startsWith(`${base}/`)) {
145
+ // Mounted somewhere `basePath` does not name: a misconfiguration, not a link to
146
+ // correct. Show what the base path would, and leave the address alone.
147
+ return { group: rules.phone ? null : rules.defaultGroup, sub: null, redirect: null };
148
+ }
149
+ const rest = pathname.slice(base.length + 1);
150
+ const [segment = "", ...subParts] = rest.split("/");
151
+ const sub = subParts.filter(Boolean).join("/") || null;
152
+ if (known.has(segment)) return { group: segment as G, sub, redirect: null };
153
+
154
+ const successor = rules.aliases?.[segment];
155
+ if (successor !== undefined && known.has(successor)) {
156
+ return {
157
+ group: successor,
158
+ sub,
159
+ redirect: `${base}/${successor}${sub ? `/${sub}` : ""}${search}${hash}`,
160
+ };
161
+ }
162
+
163
+ // Unknown or hidden. The hash is dropped: on the list it would read as a legacy group
164
+ // and send the page round again.
165
+ if (rules.phone || rules.defaultGroup === null) {
166
+ return { group: null, sub: null, redirect: `${base || "/"}${search}` };
167
+ }
168
+ return { group: rules.defaultGroup, sub: null, redirect: `${base}/${rules.defaultGroup}${search}` };
169
+ }
170
+
171
+ /**
172
+ * The settings page's route (docs/settings-harmonization.md §3.1): which group the URL
173
+ * names, and the history rules for moving between groups.
174
+ *
175
+ * The URL IS the selection, as it was in keksdose (where it was the hash): there is no
176
+ * state to keep in step with it, so a deep link, a reload, back and forward all land
177
+ * where the address says. Everything that is not canonical — `/settings` on a desktop, a
178
+ * legacy hash, an alias, an unknown or hidden group — is replaced by its canonical path.
179
+ *
180
+ * **The replace runs on every navigation**, keyed on `location.key`, not once on mount:
181
+ * the router keeps the page mounted across links followed inside the app — keksdose's
182
+ * inbox renders admin-typed URLs, and a push click routes an open window without a
183
+ * reload — so a legacy `/settings#security` arriving while the page is open converts too
184
+ * (§10.1).
185
+ */
186
+ export function useSettingsRoute<G extends string>(options: UseSettingsRouteOptions<G>): SettingsRoute<G> {
187
+ const { groups, entries, basePath, defaultGroup, aliases, layout = "auto" } = options;
188
+ const location = useLocation();
189
+ const navigate = useNavigate();
190
+ const narrow = useMediaQuery(PHONE_QUERY, false);
191
+ const phone = layout === "phone" || (layout === "auto" && narrow);
192
+ const base = normalizeSettingsBase(basePath);
193
+
194
+ const visible = useMemo(() => visibleSettingsGroups(groups, entries), [groups, entries]);
195
+ const anchorGroup = useMemo(() => {
196
+ const map = new Map<string, G>();
197
+ for (const e of entries ?? []) if (e.visible !== false && !map.has(e.anchor)) map.set(e.anchor, e.group);
198
+ return map;
199
+ }, [entries]);
200
+ const ids = visible.map((g) => g.id);
201
+ const fallback =
202
+ defaultGroup !== undefined && ids.includes(defaultGroup) ? defaultGroup : (ids[0] ?? null);
203
+
204
+ const { group, sub, redirect } = resolveSettingsLocation(location, {
205
+ basePath: base,
206
+ groups: ids,
207
+ defaultGroup: fallback,
208
+ aliases,
209
+ anchorGroup,
210
+ phone,
211
+ });
212
+
213
+ const { key, state, search } = location;
214
+ useEffect(() => {
215
+ // `state` rides along: the marker describes the entry BEFORE this one, which a
216
+ // replace does not change.
217
+ if (redirect) navigate(redirect, { replace: true, state });
218
+ }, [key, redirect, state, navigate]);
219
+
220
+ const select = useCallback(
221
+ (next: G) => {
222
+ const to = `${base}/${next}`;
223
+ // From the list, the push marks it, so the group page's back is a real back.
224
+ if (phone) navigate(to, group === null ? { state: settingsFromListState() } : undefined);
225
+ // A new group is a new page: the old one's query (a focus, a roster filter) stays
226
+ // behind, as keksdose's `selectGroup` left it.
227
+ else navigate(to, { replace: true, state });
228
+ },
229
+ [base, phone, group, state, navigate],
230
+ );
231
+
232
+ const selectSub = useCallback(
233
+ (next: string | null) => {
234
+ if (group === null) return;
235
+ navigate(`${base}/${group}${next ? `/${next}` : ""}${search}`, { replace: true, state });
236
+ },
237
+ [base, group, search, state, navigate],
238
+ );
239
+
240
+ const fromList = isFromList(state);
241
+ const back = useCallback(() => {
242
+ if (fromList) navigate(-1);
243
+ else navigate(base || "/", { replace: true });
244
+ }, [fromList, base, navigate]);
245
+
246
+ return {
247
+ group,
248
+ sub,
249
+ focus: new URLSearchParams(search).get("focus"),
250
+ select,
251
+ selectSub,
252
+ back,
253
+ groups: visible,
254
+ phone,
255
+ redirecting: redirect !== null,
256
+ fromList,
257
+ };
258
+ }
@@ -37,6 +37,12 @@ export interface AppShellNavItem {
37
37
  * shortening the real label, which the sidebar has ample room for and which is the
38
38
  * name the rest of the product uses. */
39
39
  shortLabel?: string;
40
+ /** 0.31.0: leave this entry out of the MOBILE BOTTOM BAR; the sidebar keeps it.
41
+ * For an entry a phone reaches another way — the brand link to the start page —
42
+ * when one cell fewer is what keeps the others' labels whole (the bar divides its
43
+ * width evenly, see `shortLabel`). Its group's sub-row still shows while one of its
44
+ * pages is open. Named like `DataTable`'s column `mobileHidden`. */
45
+ mobileHidden?: boolean;
40
46
  icon: LucideIcon;
41
47
  /** Passed to NavLink's `end` (exact match). Defaults to true. */
42
48
  end?: boolean;
@@ -272,6 +278,8 @@ export function AppShell({
272
278
  ...rest
273
279
  }: AppShellProps) {
274
280
  const embedded = useContext(AppShellNesting) || !!embeddedProp;
281
+ // The bottom bar's cells: every entry the phone does not reach another way.
282
+ const barNav = nav.filter((item) => !item.mobileHidden);
275
283
  // An embedded shell sharing the default key would overwrite the outer app's sidebar
276
284
  // preference with its own — so it persists only when given a key of its own.
277
285
  const collapseStorageKey =
@@ -448,9 +456,9 @@ export function AppShell({
448
456
  <nav
449
457
  data-tour="nav"
450
458
  className="grid"
451
- style={{ gridTemplateColumns: `repeat(${nav.length}, minmax(0, 1fr))` }}
459
+ style={{ gridTemplateColumns: `repeat(${barNav.length}, minmax(0, 1fr))` }}
452
460
  >
453
- {nav.map((item) => (
461
+ {barNav.map((item) => (
454
462
  <MobileNavItem key={item.to} item={item} />
455
463
  ))}
456
464
  </nav>
package/src/shell.ts CHANGED
@@ -10,3 +10,54 @@ export * from "./shell/role-switcher";
10
10
  export * from "./shell/topbar-action-menu";
11
11
  export * from "./shell/top-bar-brand";
12
12
  export * from "./shell/auth-layout";
13
+ // 0.31.0: the settings and admin pages' shell (docs/settings-harmonization.md §3, §5).
14
+ export { SettingsLayout, SETTINGS_SEARCH_THRESHOLD } from "./settings/settings-layout";
15
+ export type { SettingsLayoutProps, SettingsLayoutWidth } from "./settings/settings-layout";
16
+ export {
17
+ useSettingsRoute,
18
+ resolveSettingsLocation,
19
+ settingsFromListState,
20
+ SETTINGS_FROM_LIST_STATE,
21
+ } from "./settings/use-settings-route";
22
+ export type {
23
+ UseSettingsRouteOptions,
24
+ SettingsRoute,
25
+ SettingsLayoutMode,
26
+ SettingsLocation,
27
+ SettingsLocationRules,
28
+ SettingsLocationResult,
29
+ } from "./settings/use-settings-route";
30
+ export { useSettingsFocus, SETTINGS_FOCUS_RING, SETTINGS_FOCUS_MS } from "./settings/use-settings-focus";
31
+ export { SettingsSection } from "./settings/settings-section";
32
+ export type { SettingsSectionProps } from "./settings/settings-section";
33
+ export { useSettingsLayout } from "./settings/settings-context";
34
+ export type { SettingsLayoutContextValue } from "./settings/settings-context";
35
+ export { SettingsHeadingLevel, useSettingsHeadingLevel } from "./settings/settings-heading";
36
+ export type { SettingsHeadingLevelProps, SettingsHeadingTag } from "./settings/settings-heading";
37
+ export {
38
+ settingsSearchEntries,
39
+ visibleSettingsGroups,
40
+ visibleSettingsEntries,
41
+ settingsHref,
42
+ } from "./settings/settings-catalogue";
43
+ export type { SettingsGroup, SettingsEntry, SettingsSearchEntriesOptions } from "./settings/settings-catalogue";
44
+ // 0.31.0: the public pages' header and the resume (docs/landing-demo-harmonization.md §3, §4.1).
45
+ export {
46
+ RootEntry,
47
+ RedirectIfAuthed,
48
+ useLastVisitedPage,
49
+ readLastVisitedPage,
50
+ clearLastVisitedPage,
51
+ safeNextPath,
52
+ NEXT_PARAM,
53
+ DEFAULT_LAST_VISITED_EXCLUDES,
54
+ } from "./landing/routing";
55
+ export type {
56
+ RootEntryProps,
57
+ RedirectIfAuthedProps,
58
+ RoutingSession,
59
+ LastVisitedPageOptions,
60
+ PathPattern,
61
+ } from "./landing/routing";
62
+ export { PublicHeader } from "./landing/public-header";
63
+ export type { PublicHeaderProps, PublicHeaderBrand } from "./landing/public-header";