@eifi1/ui-kit 0.27.1 → 0.28.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 (109) hide show
  1. package/README.md +7 -5
  2. package/dist/chart.d.ts +1 -2
  3. package/dist/components/amount-input.d.ts +1 -2
  4. package/dist/components/button-group.d.ts +1 -2
  5. package/dist/components/calculator.d.ts +1 -2
  6. package/dist/components/confirm-dialog.d.ts +1 -2
  7. package/dist/components/copy-button.d.ts +1 -2
  8. package/dist/components/danger-confirm.d.ts +1 -2
  9. package/dist/components/facing-pair.d.ts +1 -2
  10. package/dist/components/file-button.d.ts +1 -2
  11. package/dist/components/file-dropzone.d.ts +1 -2
  12. package/dist/components/form-actions.d.ts +1 -2
  13. package/dist/components/iban-input.d.ts +1 -2
  14. package/dist/components/language-select.d.ts +1 -2
  15. package/dist/components/legal-page.d.ts +261 -0
  16. package/dist/components/legal-page.js +253 -0
  17. package/dist/components/legal-page.js.map +1 -0
  18. package/dist/components/legal.d.ts +70 -87
  19. package/dist/components/legal.js +187 -10
  20. package/dist/components/legal.js.map +1 -1
  21. package/dist/components/money-field.d.ts +1 -2
  22. package/dist/components/number-field.d.ts +1 -2
  23. package/dist/components/number-input.d.ts +1 -2
  24. package/dist/components/numpad-sheet.d.ts +1 -2
  25. package/dist/components/phone-input.d.ts +1 -2
  26. package/dist/components/series-chart.d.ts +1 -2
  27. package/dist/components/settings-fields.d.ts +1 -2
  28. package/dist/components/share-card.d.ts +1 -2
  29. package/dist/components/text-link.d.ts +1 -2
  30. package/dist/components/time-input.d.ts +1 -2
  31. package/dist/components/translation-review.d.ts +2 -1
  32. package/dist/components/translation-review.js.map +1 -1
  33. package/dist/components/ui.d.ts +1 -2
  34. package/dist/feedback/feedback-attachment.d.ts +1 -2
  35. package/dist/feedback/feedback-context.d.ts +1 -2
  36. package/dist/feedback/feedback-crash.d.ts +1 -2
  37. package/dist/feedback/feedback-dialog.d.ts +1 -2
  38. package/dist/feedback/feedback-inbox.d.ts +1 -2
  39. package/dist/feedback/feedback-labels.d.ts +1 -2
  40. package/dist/feedback/feedback-menu.d.ts +1 -2
  41. package/dist/feedback/feedback-record.d.ts +1 -2
  42. package/dist/feedback/feedback-row-detail.d.ts +1 -2
  43. package/dist/feedback/feedback-status-undo.d.ts +1 -2
  44. package/dist/feedback/feedback-submit.d.ts +1 -2
  45. package/dist/feedback/feedback-swipe.d.ts +1 -2
  46. package/dist/feedback/feedback-table.d.ts +1 -2
  47. package/dist/feedback/feedback-thread.d.ts +1 -2
  48. package/dist/feedback.d.ts +1 -2
  49. package/dist/hooks/use-file-drop.d.ts +1 -2
  50. package/dist/hooks/use-noindex.d.ts +26 -0
  51. package/dist/hooks/use-noindex.js +18 -0
  52. package/dist/hooks/use-noindex.js.map +1 -0
  53. package/dist/i18n/defaults.d.ts +1 -2
  54. package/dist/i18n/german.d.ts +1 -2
  55. package/dist/i18n/german.js +87 -1
  56. package/dist/i18n/german.js.map +1 -1
  57. package/dist/i18n/kit-labels.d.ts +1 -2
  58. package/dist/i18n/kit-labels.js.map +1 -1
  59. package/dist/i18n/languages.d.ts +1 -2
  60. package/dist/i18n/locales/de-CH.d.ts +1 -2
  61. package/dist/i18n/locales/en.d.ts +1 -2
  62. package/dist/i18n/locales/es.d.ts +1 -2
  63. package/dist/i18n/locales/es.js +87 -1
  64. package/dist/i18n/locales/es.js.map +1 -1
  65. package/dist/i18n/locales/fr.d.ts +1 -2
  66. package/dist/i18n/locales/fr.js +89 -1
  67. package/dist/i18n/locales/fr.js.map +1 -1
  68. package/dist/i18n/locales/hu.d.ts +1 -2
  69. package/dist/i18n/locales/hu.js +90 -1
  70. package/dist/i18n/locales/hu.js.map +1 -1
  71. package/dist/i18n/locales/it.d.ts +1 -2
  72. package/dist/i18n/locales/it.js +90 -1
  73. package/dist/i18n/locales/it.js.map +1 -1
  74. package/dist/i18n/locales/zh.d.ts +1 -2
  75. package/dist/i18n/locales/zh.js +87 -1
  76. package/dist/i18n/locales/zh.js.map +1 -1
  77. package/dist/i18n/review.d.ts +24 -5
  78. package/dist/i18n/review.js +24 -3
  79. package/dist/i18n/review.js.map +1 -1
  80. package/dist/index.d.ts +5 -4
  81. package/dist/index.js +11 -1
  82. package/dist/index.js.map +1 -1
  83. package/dist/{kit-labels-DQg82eHB.d.ts → kit-labels-SBN0biPl.d.ts} +305 -3
  84. package/dist/lib/translation-review.d.ts +26 -3
  85. package/dist/lib/translation-review.js +10 -2
  86. package/dist/lib/translation-review.js.map +1 -1
  87. package/dist/rhf/fields.d.ts +1 -2
  88. package/dist/rhf/form.d.ts +1 -2
  89. package/dist/rhf.d.ts +1 -2
  90. package/dist/shell/app-shell.d.ts +1 -2
  91. package/dist/shell/top-bar-brand.d.ts +1 -2
  92. package/dist/shell.d.ts +1 -2
  93. package/dist/wizard/stepper-nav.d.ts +1 -2
  94. package/dist/wizard.d.ts +1 -2
  95. package/package.json +1 -1
  96. package/src/components/legal-page.tsx +566 -0
  97. package/src/components/legal.tsx +451 -43
  98. package/src/components/translation-review.tsx +2 -1
  99. package/src/hooks/use-noindex.ts +37 -0
  100. package/src/i18n/german.ts +81 -0
  101. package/src/i18n/kit-labels.tsx +4 -1
  102. package/src/i18n/locales/es.ts +81 -0
  103. package/src/i18n/locales/fr.ts +83 -0
  104. package/src/i18n/locales/hu.ts +84 -0
  105. package/src/i18n/locales/it.ts +84 -0
  106. package/src/i18n/locales/zh.ts +81 -0
  107. package/src/i18n/review.ts +56 -3
  108. package/src/index.ts +32 -2
  109. package/src/lib/translation-review.ts +43 -4
@@ -1,48 +1,371 @@
1
+ import { createContext, useContext } from "react";
1
2
  import type { ReactNode } from "react";
2
3
 
3
4
  import { useKitLabels } from "../i18n/kit-labels";
5
+ import type { LabelOverride } from "../i18n/kit-labels";
4
6
  import { cn } from "../lib/cn";
7
+ import { countryName } from "../lib/countries";
5
8
  import { AlertBanner } from "./alert-banner";
6
9
  import { TextLink } from "./text-link";
7
10
 
8
11
  /**
9
- * The legal pages' shell — Imprint, Privacy Policy, Terms — for every app (Marcel,
10
- * 2026-10-02: every app has them; docs/i18n-harmonization.md H10).
12
+ * The legal pages — Imprint, Privacy Policy, Terms — for every app.
11
13
  *
12
- * keksdose and kastlan each carried the same shell, written twice: a back link, the
13
- * title, a "closed beta, not yet reviewed by a lawyer" notice, sections of heading +
14
- * running text, and kastlan's row of links to the three pages with the current one
15
- * marked. Kurvenschmiede had none. The words stay in each app — they are the app's
16
- * legal statements, reviewed under the `legal` area of the translation review — and
17
- * only the shape moves here.
14
+ * 0.19 (docs/i18n-harmonization.md H10): keksdose and kastlan each carried the same
15
+ * shell, written twice: a back link, the title, a "closed beta, not yet reviewed by a
16
+ * lawyer" notice, sections of heading + running text, and kastlan's row of links to the
17
+ * three pages with the current one marked. That shape moved here; the words stayed in
18
+ * each app.
18
19
  *
19
- * A CONTENT COLUMN, not a page: keksdose shows its legal pages inside its public
20
- * landing header and footer, kastlan inside `AuthLayout` (`width="wide" card={false}`,
21
- * no title of its own). Both put this inside their chrome; a page-owning layout would
22
- * have fought one of them.
20
+ * 0.28 (docs/legal-harmonization.md) reverses the second half: the wording that is the
21
+ * same in all three apps is the kit's too, in all seven languages, so there is ONE text
22
+ * to change after the lawyer's review instead of three apps drifting apart sentence by
23
+ * sentence. This module holds the labels (every kit-owned legal word, §4.3/§4.4), the
24
+ * column (`LegalLayout`), the section (`LegalSection`, now numbered and cross-referenced
25
+ * inside a `LegalPage`), the links row and the public footer. The page frame, the
26
+ * kit-owned sections and the terms checkbox are in `./legal-page`.
27
+ *
28
+ * `LegalLayout` stays a CONTENT COLUMN, not a page: before 0.28 keksdose showed it inside
29
+ * its public landing header and footer and kastlan inside `AuthLayout`. `LegalPage` is
30
+ * the frame around it that the contract (§3.2) settled on — keksdose's.
23
31
  */
24
32
 
33
+ // ── The operator ──────────────────────────────────────────────────────────────
34
+
35
+ /** The three pages, by the key every app uses for them (§4.1). Kurvenschmiede's
36
+ * `imprint` became `impressum`. */
37
+ export type LegalPageKey = "impressum" | "privacy" | "terms";
38
+
39
+ /** The three routes (§3.1): one per page, the language from i18n, no per-language URLs. */
40
+ export const LEGAL_HREFS: Readonly<Record<LegalPageKey, string>> = Object.freeze({
41
+ impressum: "/impressum",
42
+ privacy: "/privacy",
43
+ terms: "/terms",
44
+ });
45
+
46
+ /**
47
+ * Who runs the app — the values the kit's legal sections are filled in with (§5).
48
+ *
49
+ * The kit holds NO personal data: every app passes the same values once, to
50
+ * {@link LegalPage}'s `operator`. Plain strings, so the app's config or env can hold them.
51
+ */
52
+ export interface LegalOperator {
53
+ /** The operator's name, as the imprint prints it. */
54
+ name: string;
55
+ /** "9470"-shaped; printed before the city. */
56
+ postalCode: string;
57
+ /** The place — the imprint's address line and the terms' place of jurisdiction. */
58
+ city: string;
59
+ /** The canton or state, abbreviated as the place of jurisdiction writes it: "SG". */
60
+ region: string;
61
+ /**
62
+ * ISO 3166-1 alpha-2: "CH". A CODE, not a name — the kit names it in the page's
63
+ * language (`Intl.DisplayNames`, see `countryName`), so "Switzerland", "Schweiz",
64
+ * "Suisse" and "瑞士" all come from one value.
65
+ */
66
+ country: string;
67
+ /** The contact address the imprint and the privacy policy print. */
68
+ email: string;
69
+ }
70
+
71
+ /**
72
+ * The operator as the kit's texts read it: {@link LegalOperator} with `country` already
73
+ * NAMED in the page's language ("Schweiz", not "CH").
74
+ *
75
+ * The label functions take this rather than the code so they stay pure string functions
76
+ * of plain values, like every other function label in the kit: a catalogue never calls
77
+ * `Intl`, and a review row can be rendered from placeholders (`{{country}}`).
78
+ */
79
+ export type LegalOperatorText = Readonly<Record<keyof LegalOperator, string>>;
80
+
81
+ /** @internal The operator as the texts read it: its country named in `locale` (English
82
+ * without one — `countryName`'s rule, so an app that set no locale reads English). */
83
+ export function legalOperatorText(operator: LegalOperator, locale: string = "en"): LegalOperatorText {
84
+ return { ...operator, country: countryName(operator.country, locale) };
85
+ }
86
+
25
87
  // ── Labels ────────────────────────────────────────────────────────────────────
26
88
 
89
+ /** A kit section whose text is fixed: a heading and one body. */
90
+ export interface LegalTextSectionLabels {
91
+ title: string;
92
+ body: string;
93
+ }
94
+
95
+ /** A kit section whose text names the operator (§4.3 `{name}`, `{email}`, …). */
96
+ export interface LegalOperatorSectionLabels {
97
+ title: string;
98
+ /** Called with the operator, its country already named in the page's language. Line
99
+ * breaks are kept (`white-space: pre-line`): an address is plain lines. */
100
+ body: (operator: LegalOperatorText) => string;
101
+ }
102
+
103
+ /** A kit section with an app slot (or a list) between its two parts. */
104
+ export interface LegalFramedSectionLabels {
105
+ title: string;
106
+ /** Before the app's part. */
107
+ lead: string;
108
+ /** After it. */
109
+ tail: string;
110
+ }
111
+
112
+ /**
113
+ * Every word of the legal pages that is the kit's — docs/legal-harmonization.md §4.3 and
114
+ * §4.4, verbatim. English, British spelling; the other six languages are in the
115
+ * catalogues (`@eifi1/ui-kit/i18n/<code>`).
116
+ *
117
+ * Keys follow the contract: `sections.<page>.<section key>`, the section keys being
118
+ * keksdose's (`legal_basis`, not `legalBasis`), because the same key is the section's
119
+ * `id` (`/privacy#legal_basis`) and the app's own sections sit beside these under the
120
+ * same names in its catalogue. Titles carry NO number: {@link LegalPage} numbers the
121
+ * privacy and terms sections in render order (§4.1).
122
+ */
27
123
  export interface LegalLabels {
28
- /** The accessible name of {@link LegalLinks}' `<nav>`. */
124
+ /** The accessible name of {@link LegalLinks}' and {@link LegalFooter}'s `<nav>`. */
29
125
  navLabel: string;
126
+ /** The short labels of the three links, everywhere the links appear (§3.3). */
127
+ links: Record<LegalPageKey, string>;
128
+ /** The pages' titles — the `<h1>`, and the links of the terms checkbox. */
129
+ titles: Record<LegalPageKey, string>;
130
+ /** The back link above the title: "← Back to home". */
131
+ backHome: string;
132
+ /**
133
+ * The terms checkbox (§3.4) — ONE template with `{terms}` and `{privacy}`, which
134
+ * become the links (named with `titles`). Not a prefix plus a joiner: a language puts
135
+ * the links where its grammar wants them, articles included, and nothing is added
136
+ * around a placeholder — Italian elides, "e l’{privacy}", with no space.
137
+ */
138
+ accept: string;
139
+ /** The notice under the title (§3.2): `beta` on the imprint and the terms, `privacy`
140
+ * on the privacy policy. */
141
+ notice: {
142
+ beta: string;
143
+ privacy: string;
144
+ };
145
+ /** The kit's sections (§4.3), by page and section key. */
146
+ sections: {
147
+ impressum: {
148
+ operator: LegalOperatorSectionLabels;
149
+ contact: LegalOperatorSectionLabels;
150
+ disclaimer: LegalTextSectionLabels;
151
+ };
152
+ privacy: {
153
+ controller: LegalOperatorSectionLabels;
154
+ /** The app's paragraph follows the body (§4.2): consent, where an app relies on it. */
155
+ legal_basis: LegalTextSectionLabels;
156
+ /** `lead`, then the app's entries as a list, then `tail`, then the app's paragraph. */
157
+ browser: LegalFramedSectionLabels;
158
+ /** `lead` (the rights), then the app's paragraph (export, deletion), then `tail`
159
+ * (the supervisory authorities). */
160
+ rights: LegalFramedSectionLabels;
161
+ contact: LegalOperatorSectionLabels;
162
+ };
163
+ terms: {
164
+ warranty: LegalTextSectionLabels;
165
+ liability: LegalTextSectionLabels;
166
+ changes: LegalTextSectionLabels;
167
+ /** The place of jurisdiction is the operator's `{city} ({region}), {country}`. */
168
+ law: LegalOperatorSectionLabels;
169
+ };
170
+ };
30
171
  }
31
172
 
32
173
  export const DEFAULT_LEGAL_LABELS: LegalLabels = {
33
174
  navLabel: "Legal",
175
+ links: {
176
+ impressum: "Imprint",
177
+ privacy: "Privacy Policy",
178
+ terms: "Terms",
179
+ },
180
+ titles: {
181
+ impressum: "Imprint",
182
+ privacy: "Privacy Policy",
183
+ terms: "Terms of Service",
184
+ },
185
+ backHome: "Back to home",
186
+ accept: "I accept the {terms} and the {privacy}",
187
+ notice: {
188
+ beta: "Closed beta. These texts have not been reviewed by a lawyer yet and will be before a public launch.",
189
+ privacy:
190
+ "Closed beta. The legal wording below has not been reviewed by a lawyer yet and will be before a public launch. The technical descriptions — what is stored, where, and who can read it — describe what the software actually does today, and are meant to be checked against it.",
191
+ },
192
+ sections: {
193
+ impressum: {
194
+ operator: {
195
+ title: "Operator",
196
+ body: (o) =>
197
+ `${o.name}\n${o.postalCode} ${o.city}\n${o.country}\n\nThe full postal address is supplied on request to anyone with a legitimate legal interest; write to the contact address below.`,
198
+ },
199
+ contact: {
200
+ title: "Contact",
201
+ body: (o) => `Email: ${o.email}`,
202
+ },
203
+ disclaimer: {
204
+ title: "Liability for content and links",
205
+ body: "This is a private, non-commercial project offered during a closed beta, without warranty. External sites we link to are the responsibility of their respective operators; we have no control over their content.",
206
+ },
207
+ },
208
+ privacy: {
209
+ controller: {
210
+ title: "Controller",
211
+ body: (o) =>
212
+ `The party responsible for processing personal data in this service is:\n${o.name}\n${o.postalCode} ${o.city}, ${o.country}\nEmail: ${o.email}\n\nThe full postal address is supplied on request to data subjects and supervisory authorities.`,
213
+ },
214
+ legal_basis: {
215
+ title: "Legal basis",
216
+ body: "As the operator is based in Switzerland, processing is governed by the Swiss Federal Act on Data Protection (FADP). Where the EU General Data Protection Regulation (GDPR) applies to you, we rely on the performance of a contract to provide the service (Art. 6(1)(b) GDPR) and our legitimate interest in operating and securing it (Art. 6(1)(f) GDPR).",
217
+ },
218
+ browser: {
219
+ title: "What your browser stores",
220
+ lead: "No cookies. The app keeps the following in your browser's storage:",
221
+ tail: "None of it is used to track you. Entries waiting to be sent are sent to us as soon as they can be; everything else stays on your device. All of it disappears when you clear the site's data, and signing out removes the sign-in tokens.",
222
+ },
223
+ rights: {
224
+ title: "Your rights",
225
+ lead: "You have the right to access, rectification, erasure, restriction, data portability and objection.",
226
+ tail: "If you are in Switzerland you may contact the Federal Data Protection and Information Commissioner (FDPIC); if you are in the EU you may lodge a complaint with your local supervisory authority.",
227
+ },
228
+ contact: {
229
+ title: "Contact for data protection",
230
+ body: (o) => `For any privacy request, contact: ${o.email}`,
231
+ },
232
+ },
233
+ terms: {
234
+ warranty: {
235
+ title: "No warranty",
236
+ body: 'The service is provided "as is" and "as available", without warranties of any kind to the extent permitted by law. As a beta it may contain errors, change, or be interrupted at any time — keep your own backups of important data.',
237
+ },
238
+ liability: {
239
+ title: "Limitation of liability",
240
+ body: "To the extent permitted by applicable law, the operator is not liable for any indirect or consequential damage arising from the use of, or inability to use, the service. Nothing here limits liability that cannot be limited by law.",
241
+ },
242
+ changes: {
243
+ title: "Changes to these terms",
244
+ body: "These terms may be updated as the service evolves. Material changes will be announced by email or in the app; continued use after a change means you accept it.",
245
+ },
246
+ law: {
247
+ title: "Governing law",
248
+ body: (o) =>
249
+ `These terms are governed by Swiss law, excluding its conflict-of-laws rules. As far as legally permissible, the place of jurisdiction is ${o.city} (${o.region}), ${o.country}.`,
250
+ },
251
+ },
252
+ },
34
253
  };
35
254
 
255
+ /** The `legal` namespace, resolved: defaults < provider < `labels` prop. The prop may be
256
+ * partial at every depth (`{ titles: { terms: "…" } }`), as the provider's is. */
257
+ export function useLegalLabels(labels?: LabelOverride<LegalLabels>): LegalLabels {
258
+ return useKitLabels("legal", DEFAULT_LEGAL_LABELS, labels as Partial<LegalLabels> | undefined);
259
+ }
260
+
261
+ // ── What a LegalPage tells the sections inside it ─────────────────────────────
262
+
263
+ /** Where a `{ref:key}` points: the section's number on a numbered page, else its heading. */
264
+ export interface LegalRefTarget {
265
+ number?: number;
266
+ heading: ReactNode;
267
+ }
268
+
269
+ /** @internal Set by `LegalPage` around its column; `null` outside one. */
270
+ export interface LegalPageContextValue {
271
+ page: LegalPageKey;
272
+ /** The operator with its country named — what the kit sections are filled in with. */
273
+ operator: LegalOperatorText;
274
+ /** The heading level of a section that does not choose one: one below the title. */
275
+ sectionHeading: "h2" | "h3";
276
+ /** Every section's key, in render order — known BEFORE any section renders, so a
277
+ * reference can point forward (keksdose's section 2 refers to section 10). */
278
+ targets: ReadonlyMap<string, LegalRefTarget>;
279
+ }
280
+
281
+ /** @internal */
282
+ export const LegalPageContext = createContext<LegalPageContextValue | null>(null);
283
+
284
+ /** @internal The place `LegalPage` gave one section: its key and its number. Reset to
285
+ * `null` inside a section, so a section nested in another's children takes neither. */
286
+ export interface LegalSectionSlot {
287
+ id?: string;
288
+ number?: number;
289
+ }
290
+
291
+ /** @internal */
292
+ export const LegalSlotContext = createContext<LegalSectionSlot | null>(null);
293
+
294
+ /** @internal `{ref:retention}`. A key is a section key: letters, digits, `_` and `-`. */
295
+ const REF_TOKEN = /\{ref:([A-Za-z0-9_-]+)\}/g;
296
+
297
+ /**
298
+ * A development build's console note — never in production (the consumer's bundler
299
+ * makes `import.meta.env.DEV` false) and never under vitest. Optional-chained:
300
+ * `import.meta.env` is a Vite injection, absent under plain Node.
301
+ */
302
+ function devWarnings(): boolean {
303
+ return Boolean(import.meta.env?.DEV) && !import.meta.env?.VITEST;
304
+ }
305
+ const warned = new Set<string>();
306
+ /** @internal Once per message. */
307
+ export function warnLegalOnce(message: string): void {
308
+ if (!devWarnings() || warned.has(message)) return;
309
+ warned.add(message);
310
+ console.warn(`[ui-kit] ${message}`);
311
+ }
312
+
313
+ /**
314
+ * `text` with every `{ref:key}` replaced by a link to `#key` that reads the section's
315
+ * number — the words around it stay the app's ("see section {ref:retention}", "siehe
316
+ * Abschnitt {ref:retention}"), so each language keeps its grammar (§4.1). On the imprint,
317
+ * which is not numbered, the link reads the section's heading instead.
318
+ *
319
+ * Outside a {@link LegalPage} the text is returned as it is: there is no order to count.
320
+ * A key the page has no section for stays visible as the raw token — a broken reference
321
+ * an app test can find (`not.toHaveTextContent("{ref:")`), not a silently wrong number.
322
+ */
323
+ export function resolveLegalRefs(text: string, page: LegalPageContextValue | null): ReactNode {
324
+ if (!page || !text.includes("{ref:")) return text;
325
+ const out: ReactNode[] = [];
326
+ let last = 0;
327
+ for (const match of text.matchAll(REF_TOKEN)) {
328
+ const at = match.index ?? 0;
329
+ if (at > last) out.push(text.slice(last, at));
330
+ const key = match[1];
331
+ const target = page.targets.get(key);
332
+ if (target) {
333
+ out.push(
334
+ <TextLink key={`${key}@${at}`} href={`#${key}`}>
335
+ {target.number ?? target.heading}
336
+ </TextLink>,
337
+ );
338
+ } else {
339
+ warnLegalOnce(`{ref:${key}} on the ${page.page} page points at no section of it.`);
340
+ out.push(match[0]);
341
+ }
342
+ last = at + match[0].length;
343
+ }
344
+ if (last < text.length) out.push(text.slice(last));
345
+ return out;
346
+ }
347
+
348
+ /** @internal Running text — one translation string — with its line breaks kept and its
349
+ * `{ref:key}` tokens resolved. */
350
+ export function LegalText({ text, className }: { text: string; className?: string }) {
351
+ const page = useContext(LegalPageContext);
352
+ // `break-words`: an address, an email or a URL in a translation is one long word, and
353
+ // on a 390px phone it would push the column wider than the screen.
354
+ return <p className={cn("whitespace-pre-line break-words", className)}>{resolveLegalRefs(text, page)}</p>;
355
+ }
356
+
36
357
  // ── Links ─────────────────────────────────────────────────────────────────────
37
358
 
38
359
  export interface LegalLink {
39
360
  href: string;
40
- /** "Imprint", "Privacy Policy", "Terms" — the app's words. */
361
+ /** "Imprint", "Privacy Policy", "Terms". */
41
362
  label: ReactNode;
42
363
  }
43
364
 
44
365
  export interface LegalLinksProps {
45
- links: readonly LegalLink[];
366
+ /** Default (0.28): the three routes, `/impressum`, `/privacy` and `/terms`, with the
367
+ * kit's short link labels (`legal.links`), in the contract's order. */
368
+ links?: readonly LegalLink[];
46
369
  /** The page being shown; its link is marked `aria-current="page"`. Usually the
47
370
  * router's pathname. */
48
371
  currentHref?: string;
@@ -52,20 +375,37 @@ export interface LegalLinksProps {
52
375
  * links, so in a plain container — Kurvenschmiede's account-menu `<li>` — they ran
53
376
  * together as "ImpressumDatenschutzerklärungNutz…" and overflowed). Default true. */
54
377
  nav?: boolean;
55
- labels?: Partial<LegalLabels>;
378
+ labels?: LabelOverride<LegalLabels>;
56
379
  className?: string;
57
380
  }
58
381
 
59
- /** The legal pages as a row of quiet links, the one you are on marked (kastlan's
60
- * `LegalLinks`). Wraps on a phone. */
382
+ /** The default links: the three routes under the kit's short labels. */
383
+ function defaultLinks(labels: LegalLabels): LegalLink[] {
384
+ return (["impressum", "privacy", "terms"] as const).map((page) => ({
385
+ href: LEGAL_HREFS[page],
386
+ label: labels.links[page],
387
+ }));
388
+ }
389
+
390
+ /**
391
+ * The legal pages as a row of quiet links, the one you are on marked (kastlan's
392
+ * `LegalLinks`). Wraps on a phone.
393
+ *
394
+ * 0.28: `·` separators between the links, keksdose's footer style, wherever the links
395
+ * appear — the account menu included (§3.3). The dots are `aria-hidden`: a screen reader
396
+ * already hears three links, and "middle dot" between them is noise. They are flex items
397
+ * of the row like the links, so the row's gap spaces them evenly.
398
+ */
61
399
  export function LegalLinks({ links, currentHref, nav = true, labels: labelsProp, className }: LegalLinksProps) {
62
- const labels = useKitLabels("legal", DEFAULT_LEGAL_LABELS, labelsProp);
63
- const items = links.map((link) => (
400
+ const labels = useLegalLabels(labelsProp);
401
+ const shown = links ?? defaultLinks(labels);
402
+ const items = shown.flatMap((link, i) => [
403
+ ...(i > 0 ? [<span key={`sep-${link.href}`} aria-hidden="true">·</span>] : []),
64
404
  <TextLink key={link.href} href={link.href} tone="muted" current={link.href === currentHref}>
65
405
  {link.label}
66
- </TextLink>
67
- ));
68
- const rowClass = cn("flex flex-wrap gap-x-4 gap-y-1 text-xs", className);
406
+ </TextLink>,
407
+ ]);
408
+ const rowClass = cn("flex flex-wrap items-center gap-x-4 gap-y-1 text-xs", className);
69
409
  if (!nav) return <div className={rowClass}>{items}</div>;
70
410
  return (
71
411
  <nav aria-label={labels.navLabel} className={rowClass}>
@@ -74,31 +414,100 @@ export function LegalLinks({ links, currentHref, nav = true, labels: labelsProp,
74
414
  );
75
415
  }
76
416
 
417
+ // ── Footer ────────────────────────────────────────────────────────────────────
418
+
419
+ export interface LegalFooterProps {
420
+ /** Under the links, centred — the app's tagline (keksdose: "Self-hosted household
421
+ * budgeting & bookkeeping."). */
422
+ children?: ReactNode;
423
+ /** Default: the three routes with the kit's link labels — see {@link LegalLinks}. */
424
+ links?: readonly LegalLink[];
425
+ /** Marks that link `aria-current="page"`. {@link LegalPage}'s default footer passes
426
+ * its own page. */
427
+ currentHref?: string;
428
+ className?: string;
429
+ labels?: LabelOverride<LegalLabels>;
430
+ }
431
+
432
+ /**
433
+ * The public footer (§3.3): the three links, centred, with their separators, in a
434
+ * `<nav aria-label="Legal">` — on the landing or home page, every signed-out page the app
435
+ * has, the legal pages and the 404. The rule behind it: from every page a signed-out
436
+ * visitor can reach, the three links are one click away.
437
+ *
438
+ * keksdose's `SiteFooter` (features/landing/site-footer.tsx), which carried them on its
439
+ * landing, auth, legal and 404 pages; kastlan and Kurvenschmiede had them on some pages
440
+ * only. Its palette classes (`border-slate-200 bg-white dark:…`) became the surface and
441
+ * border tokens, so it follows the theme like the rest of the kit.
442
+ */
443
+ export function LegalFooter({ children, links, currentHref, className, labels }: LegalFooterProps) {
444
+ return (
445
+ <footer className={cn("border-t border-[var(--border)] bg-[var(--bg-surface)]", className)}>
446
+ <div className="mx-auto max-w-5xl px-4 py-8 text-sm text-[var(--text-muted)]">
447
+ <LegalLinks
448
+ links={links}
449
+ currentHref={currentHref}
450
+ labels={labels}
451
+ className="justify-center gap-y-2 text-sm"
452
+ />
453
+ {children !== undefined && children !== null && <p className="mt-4 text-center">{children}</p>}
454
+ </div>
455
+ </footer>
456
+ );
457
+ }
458
+
77
459
  // ── Section ───────────────────────────────────────────────────────────────────
78
460
 
79
461
  export interface LegalSectionProps {
80
462
  heading: ReactNode;
81
463
  /** Running text. Line breaks in it are kept (`white-space: pre-line`), so a
82
- * translation can hold an address or a list as plain lines. */
464
+ * translation can hold an address or a list as plain lines. Inside a
465
+ * {@link LegalPage}, `{ref:key}` becomes the number of section `key`, linked. */
83
466
  body?: string;
84
- /** Anything richer than plain text — links, a list — after `body`. */
467
+ /** Anything richer than plain text — links, a list — after `body`. A plain string
468
+ * here has its `{ref:key}` tokens resolved too. */
85
469
  children?: ReactNode;
86
- /** The section's `id`, for a link to it from elsewhere ("see §4"). */
470
+ /**
471
+ * The section's `id`, for a link to it from elsewhere. Inside a {@link LegalPage} it
472
+ * defaults to the element's React `key` — keksdose's
473
+ * `SECTIONS.map((s) => <LegalSection key={s} … />)` gets `id="retention"` with
474
+ * nothing added — and it is the key a `{ref:…}` names.
475
+ */
87
476
  id?: string;
88
- /** The heading's element. Default `h2`, under the layout's `h1`. */
477
+ /** The heading's element. Default `h2` under the layout's `h1` (inside a
478
+ * `LegalPage`, one level below its title). */
89
479
  headingAs?: "h2" | "h3";
90
480
  }
91
481
 
92
- export function LegalSection({ heading, body, children, id, headingAs: Heading = "h2" }: LegalSectionProps) {
482
+ /**
483
+ * One section: heading and running text.
484
+ *
485
+ * 0.28, inside a {@link LegalPage}: its `id` (the `key` unless given), its number on the
486
+ * privacy policy and the terms ("3. Legal basis" — titles carry no number, §4.1), and
487
+ * `{ref:key}` resolution in `body`. Outside one it is exactly the 0.19 section.
488
+ */
489
+ export function LegalSection({ heading, body, children, id: idProp, headingAs }: LegalSectionProps) {
490
+ const page = useContext(LegalPageContext);
491
+ const slot = useContext(LegalSlotContext);
492
+ const id = idProp ?? slot?.id;
493
+ const number = slot?.number;
494
+ const Heading = headingAs ?? page?.sectionHeading ?? "h2";
93
495
  return (
94
496
  <section id={id} className="scroll-mt-20">
95
- <Heading className="text-lg font-semibold text-[var(--text-primary)]">{heading}</Heading>
96
- {body !== undefined && (
97
- <p className="mt-2 whitespace-pre-line text-sm leading-relaxed text-[var(--text-secondary)]">{body}</p>
98
- )}
99
- {children !== undefined && (
100
- <div className="mt-2 text-sm leading-relaxed text-[var(--text-secondary)]">{children}</div>
101
- )}
497
+ <Heading className="text-lg font-semibold break-words text-[var(--text-primary)]">
498
+ {number !== undefined && `${number}. `}
499
+ {heading}
500
+ </Heading>
501
+ <LegalSlotContext.Provider value={null}>
502
+ {body !== undefined && (
503
+ <LegalText text={body} className="mt-2 text-sm leading-relaxed text-[var(--text-secondary)]" />
504
+ )}
505
+ {children !== undefined && (
506
+ <div className="mt-2 text-sm leading-relaxed break-words text-[var(--text-secondary)]">
507
+ {typeof children === "string" ? resolveLegalRefs(children, page) : children}
508
+ </div>
509
+ )}
510
+ </LegalSlotContext.Provider>
102
511
  </section>
103
512
  );
104
513
  }
@@ -108,27 +517,26 @@ export function LegalSection({ heading, body, children, id, headingAs: Heading =
108
517
  export interface LegalLayoutProps {
109
518
  /** "Imprint", "Privacy Policy", "Terms". */
110
519
  title: ReactNode;
111
- /** Above the title — the app's "← Back" link (`<TextLink icon={ArrowLeft}>`), whose
112
- * target differs per app (keksdose's start page, kastlan's sign-in). */
520
+ /** Above the title — the app's "← Back" link (`<TextLink icon={ArrowLeft}>`). Inside
521
+ * a {@link LegalPage}, "← Back to home". */
113
522
  back?: ReactNode;
114
523
  /**
115
524
  * A notice under the title, as a warning banner with `role="note"` — page furniture,
116
- * not an alert. Both apps say their legal texts await a lawyer's review; keksdose's
117
- * privacy page says something more precise than the others (its technical sections
118
- * describe running code), so the notice is per page, not per layout.
525
+ * not an alert. Per page, not per layout: the privacy page says something more precise
526
+ * than the others (its technical sections describe running code).
119
527
  */
120
528
  notice?: ReactNode;
121
529
  /** The sections — {@link LegalSection}s. */
122
530
  children: ReactNode;
123
531
  /** The three pages, linked at the end of the column with the current one marked.
124
- * Leave out when the page's chrome already shows them (kastlan's AuthLayout footer). */
532
+ * Leave out when the page's chrome already shows them (a {@link LegalFooter}). */
125
533
  links?: readonly LegalLink[];
126
534
  currentHref?: string;
127
535
  /** Default `h1`: the page's heading. */
128
536
  headingAs?: "h1" | "h2";
129
537
  /** Extra classes on the column — `px-0 py-0` inside a chrome that pads already. */
130
538
  className?: string;
131
- labels?: Partial<LegalLabels>;
539
+ labels?: LabelOverride<LegalLabels>;
132
540
  }
133
541
 
134
542
  export function LegalLayout({
@@ -145,7 +553,7 @@ export function LegalLayout({
145
553
  return (
146
554
  <article className={cn("mx-auto w-full max-w-3xl px-4 py-12", className)}>
147
555
  {back !== undefined && <div className="mb-4 text-sm">{back}</div>}
148
- <Heading className="text-3xl font-bold tracking-tight text-[var(--text-primary)]">{title}</Heading>
556
+ <Heading className="text-3xl font-bold tracking-tight break-words text-[var(--text-primary)]">{title}</Heading>
149
557
  {notice !== undefined && notice !== null && (
150
558
  <AlertBanner tone="warning" role="note" className="mt-4">
151
559
  {notice}
@@ -139,7 +139,8 @@ export interface TranslationReviewPanelProps {
139
139
  areas?: readonly string[] | null;
140
140
  /** An area's name for the notice ("the legal pages (Imprint, …)"). Default: the key. */
141
141
  areaLabels?: Readonly<Record<string, string>>;
142
- /** Default `keyInArea`: the key is the area or sits under it (`legal.…`, `legal:…`). */
142
+ /** Default `keyInArea`: the key is the area or sits under it (`legal.…`, `legal:…`,
143
+ * and the kit's `kit.legal.…` since 0.28). */
143
144
  inArea?: (key: string, area: string) => boolean;
144
145
  /** A source's name for the source filter, which appears once the rows come from more
145
146
  * than one (kastlan: `{ screen: "Screen", documents: "PDFs and emails" }`). Default:
@@ -0,0 +1,37 @@
1
+ import { useEffect } from "react";
2
+
3
+ /**
4
+ * Marks the current page as not for search engines: a `<meta name="robots"
5
+ * content="noindex">` in the document head while the calling component is mounted.
6
+ *
7
+ * keksdose's hook (shared/hooks/use-noindex.ts, feedback #97 and #129), for every app:
8
+ * the contract puts it on the three legal pages and on every auth page
9
+ * (docs/legal-harmonization.md §3.2). {@link LegalPage} calls it itself.
10
+ *
11
+ * It is the best-effort, client-side half. The authoritative half is the web server's
12
+ * `X-Robots-Tag: noindex` on those routes (keksdose's Caddy `@noindex`), which a crawler
13
+ * reads without running any script; this covers the dev server and any setup without
14
+ * that header.
15
+ *
16
+ * The cleanup is the point of a hook rather than a tag in `index.html`: in a single-page
17
+ * app the head outlives the page, so without it a visitor's navigation from a legal page
18
+ * into the app would carry the marker onto pages that should be indexed. Each call adds
19
+ * its OWN element and removes exactly that one, so two mounted callers (a page and a
20
+ * dialog on it) never take each other's marker away.
21
+ *
22
+ * `active = false` adds nothing — for a page component that is also rendered as a
23
+ * preview inside another page (the showcase), where the host page's indexing is not its
24
+ * business. Hooks cannot be called conditionally, so the switch is an argument.
25
+ */
26
+ export function useNoIndex(active: boolean = true): void {
27
+ useEffect(() => {
28
+ if (!active) return;
29
+ const meta = document.createElement("meta");
30
+ meta.name = "robots";
31
+ meta.content = "noindex";
32
+ document.head.appendChild(meta);
33
+ return () => {
34
+ meta.remove();
35
+ };
36
+ }, [active]);
37
+ }