@eifi1/ui-kit 0.27.0 → 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.
- package/README.md +7 -5
- package/dist/chart.d.ts +1 -2
- package/dist/components/amount-input.d.ts +1 -2
- package/dist/components/button-group.d.ts +1 -2
- package/dist/components/calculator.d.ts +1 -2
- package/dist/components/confirm-dialog.d.ts +1 -2
- package/dist/components/copy-button.d.ts +1 -2
- package/dist/components/danger-confirm.d.ts +1 -2
- package/dist/components/facing-pair.d.ts +1 -2
- package/dist/components/file-button.d.ts +1 -2
- package/dist/components/file-dropzone.d.ts +1 -2
- package/dist/components/form-actions.d.ts +1 -2
- package/dist/components/iban-input.d.ts +1 -2
- package/dist/components/language-select.d.ts +1 -2
- package/dist/components/legal-page.d.ts +261 -0
- package/dist/components/legal-page.js +253 -0
- package/dist/components/legal-page.js.map +1 -0
- package/dist/components/legal.d.ts +70 -84
- package/dist/components/legal.js +190 -19
- package/dist/components/legal.js.map +1 -1
- package/dist/components/money-field.d.ts +1 -2
- package/dist/components/number-field.d.ts +1 -2
- package/dist/components/number-input.d.ts +1 -2
- package/dist/components/numpad-sheet.d.ts +1 -2
- package/dist/components/phone-input.d.ts +1 -2
- package/dist/components/series-chart.d.ts +1 -2
- package/dist/components/settings-fields.d.ts +1 -2
- package/dist/components/share-card.d.ts +1 -2
- package/dist/components/text-link.d.ts +1 -2
- package/dist/components/time-input.d.ts +1 -2
- package/dist/components/translation-review.d.ts +2 -1
- package/dist/components/translation-review.js.map +1 -1
- package/dist/components/ui.d.ts +1 -2
- package/dist/feedback/feedback-attachment.d.ts +1 -2
- package/dist/feedback/feedback-context.d.ts +1 -2
- package/dist/feedback/feedback-crash.d.ts +1 -2
- package/dist/feedback/feedback-dialog.d.ts +1 -2
- package/dist/feedback/feedback-inbox.d.ts +1 -2
- package/dist/feedback/feedback-labels.d.ts +1 -2
- package/dist/feedback/feedback-menu.d.ts +1 -2
- package/dist/feedback/feedback-record.d.ts +1 -2
- package/dist/feedback/feedback-row-detail.d.ts +1 -2
- package/dist/feedback/feedback-status-undo.d.ts +1 -2
- package/dist/feedback/feedback-submit.d.ts +1 -2
- package/dist/feedback/feedback-swipe.d.ts +1 -2
- package/dist/feedback/feedback-table.d.ts +1 -2
- package/dist/feedback/feedback-thread.d.ts +1 -2
- package/dist/feedback.d.ts +1 -2
- package/dist/hooks/use-file-drop.d.ts +1 -2
- package/dist/hooks/use-noindex.d.ts +26 -0
- package/dist/hooks/use-noindex.js +18 -0
- package/dist/hooks/use-noindex.js.map +1 -0
- package/dist/i18n/defaults.d.ts +1 -2
- package/dist/i18n/german.d.ts +1 -2
- package/dist/i18n/german.js +87 -1
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +1 -2
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +1 -2
- package/dist/i18n/locales/de-CH.d.ts +1 -2
- package/dist/i18n/locales/en.d.ts +1 -2
- package/dist/i18n/locales/es.d.ts +1 -2
- package/dist/i18n/locales/es.js +87 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +1 -2
- package/dist/i18n/locales/fr.js +89 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +1 -2
- package/dist/i18n/locales/hu.js +90 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +1 -2
- package/dist/i18n/locales/it.js +90 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +1 -2
- package/dist/i18n/locales/zh.js +87 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +24 -5
- package/dist/i18n/review.js +24 -3
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/{kit-labels-DQg82eHB.d.ts → kit-labels-SBN0biPl.d.ts} +305 -3
- package/dist/lib/translation-review.d.ts +26 -3
- package/dist/lib/translation-review.js +10 -2
- package/dist/lib/translation-review.js.map +1 -1
- package/dist/rhf/fields.d.ts +1 -2
- package/dist/rhf/form.d.ts +1 -2
- package/dist/rhf.d.ts +1 -2
- package/dist/shell/app-shell.d.ts +1 -2
- package/dist/shell/top-bar-brand.d.ts +1 -2
- package/dist/shell.d.ts +1 -2
- package/dist/wizard/stepper-nav.d.ts +1 -2
- package/dist/wizard.d.ts +1 -2
- package/package.json +1 -1
- package/src/components/legal-page.tsx +566 -0
- package/src/components/legal.tsx +458 -49
- package/src/components/translation-review.tsx +2 -1
- package/src/hooks/use-noindex.ts +37 -0
- package/src/i18n/german.ts +81 -0
- package/src/i18n/kit-labels.tsx +4 -1
- package/src/i18n/locales/es.ts +81 -0
- package/src/i18n/locales/fr.ts +83 -0
- package/src/i18n/locales/hu.ts +84 -0
- package/src/i18n/locales/it.ts +84 -0
- package/src/i18n/locales/zh.ts +81 -0
- package/src/i18n/review.ts +56 -3
- package/src/index.ts +32 -2
- package/src/lib/translation-review.ts +43 -4
package/src/components/legal.tsx
CHANGED
|
@@ -1,103 +1,513 @@
|
|
|
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
|
|
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
|
|
13
|
-
* title, a "closed beta, not yet reviewed by a
|
|
14
|
-
* running text, and kastlan's row of links to the
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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"
|
|
361
|
+
/** "Imprint", "Privacy Policy", "Terms". */
|
|
41
362
|
label: ReactNode;
|
|
42
363
|
}
|
|
43
364
|
|
|
44
365
|
export interface LegalLinksProps {
|
|
45
|
-
|
|
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;
|
|
49
|
-
/** `false` renders the links without the `<nav>` — inside `AuthLayout`'s
|
|
50
|
-
*
|
|
372
|
+
/** `false` renders the links without the `<nav>` landmark — inside `AuthLayout`'s
|
|
373
|
+
* `footer` or `TopBarActionMenu`'s `footer`, which are named `<nav>`s already. The row
|
|
374
|
+
* keeps its spacing and `className` either way (0.27.1: it used to return the bare
|
|
375
|
+
* links, so in a plain container — Kurvenschmiede's account-menu `<li>` — they ran
|
|
376
|
+
* together as "ImpressumDatenschutzerklärungNutz…" and overflowed). Default true. */
|
|
51
377
|
nav?: boolean;
|
|
52
|
-
labels?:
|
|
378
|
+
labels?: LabelOverride<LegalLabels>;
|
|
53
379
|
className?: string;
|
|
54
380
|
}
|
|
55
381
|
|
|
56
|
-
/** The
|
|
57
|
-
|
|
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
|
+
*/
|
|
58
399
|
export function LegalLinks({ links, currentHref, nav = true, labels: labelsProp, className }: LegalLinksProps) {
|
|
59
|
-
const labels =
|
|
60
|
-
const
|
|
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>] : []),
|
|
61
404
|
<TextLink key={link.href} href={link.href} tone="muted" current={link.href === currentHref}>
|
|
62
405
|
{link.label}
|
|
63
|
-
</TextLink
|
|
64
|
-
)
|
|
65
|
-
|
|
406
|
+
</TextLink>,
|
|
407
|
+
]);
|
|
408
|
+
const rowClass = cn("flex flex-wrap items-center gap-x-4 gap-y-1 text-xs", className);
|
|
409
|
+
if (!nav) return <div className={rowClass}>{items}</div>;
|
|
66
410
|
return (
|
|
67
|
-
<nav
|
|
68
|
-
aria-label={labels.navLabel}
|
|
69
|
-
className={cn("flex flex-wrap gap-x-4 gap-y-1 text-xs", className)}
|
|
70
|
-
>
|
|
411
|
+
<nav aria-label={labels.navLabel} className={rowClass}>
|
|
71
412
|
{items}
|
|
72
413
|
</nav>
|
|
73
414
|
);
|
|
74
415
|
}
|
|
75
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
|
+
|
|
76
459
|
// ── Section ───────────────────────────────────────────────────────────────────
|
|
77
460
|
|
|
78
461
|
export interface LegalSectionProps {
|
|
79
462
|
heading: ReactNode;
|
|
80
463
|
/** Running text. Line breaks in it are kept (`white-space: pre-line`), so a
|
|
81
|
-
* 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. */
|
|
82
466
|
body?: string;
|
|
83
|
-
/** 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. */
|
|
84
469
|
children?: ReactNode;
|
|
85
|
-
/**
|
|
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
|
+
*/
|
|
86
476
|
id?: string;
|
|
87
|
-
/** The heading's element. Default `h2
|
|
477
|
+
/** The heading's element. Default `h2` under the layout's `h1` (inside a
|
|
478
|
+
* `LegalPage`, one level below its title). */
|
|
88
479
|
headingAs?: "h2" | "h3";
|
|
89
480
|
}
|
|
90
481
|
|
|
91
|
-
|
|
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";
|
|
92
495
|
return (
|
|
93
496
|
<section id={id} className="scroll-mt-20">
|
|
94
|
-
<Heading className="text-lg font-semibold text-[var(--text-primary)]">
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
{
|
|
99
|
-
|
|
100
|
-
|
|
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>
|
|
101
511
|
</section>
|
|
102
512
|
);
|
|
103
513
|
}
|
|
@@ -107,27 +517,26 @@ export function LegalSection({ heading, body, children, id, headingAs: Heading =
|
|
|
107
517
|
export interface LegalLayoutProps {
|
|
108
518
|
/** "Imprint", "Privacy Policy", "Terms". */
|
|
109
519
|
title: ReactNode;
|
|
110
|
-
/** Above the title — the app's "← Back" link (`<TextLink icon={ArrowLeft}>`)
|
|
111
|
-
*
|
|
520
|
+
/** Above the title — the app's "← Back" link (`<TextLink icon={ArrowLeft}>`). Inside
|
|
521
|
+
* a {@link LegalPage}, "← Back to home". */
|
|
112
522
|
back?: ReactNode;
|
|
113
523
|
/**
|
|
114
524
|
* A notice under the title, as a warning banner with `role="note"` — page furniture,
|
|
115
|
-
* not an alert.
|
|
116
|
-
*
|
|
117
|
-
* 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).
|
|
118
527
|
*/
|
|
119
528
|
notice?: ReactNode;
|
|
120
529
|
/** The sections — {@link LegalSection}s. */
|
|
121
530
|
children: ReactNode;
|
|
122
531
|
/** The three pages, linked at the end of the column with the current one marked.
|
|
123
|
-
* Leave out when the page's chrome already shows them (
|
|
532
|
+
* Leave out when the page's chrome already shows them (a {@link LegalFooter}). */
|
|
124
533
|
links?: readonly LegalLink[];
|
|
125
534
|
currentHref?: string;
|
|
126
535
|
/** Default `h1`: the page's heading. */
|
|
127
536
|
headingAs?: "h1" | "h2";
|
|
128
537
|
/** Extra classes on the column — `px-0 py-0` inside a chrome that pads already. */
|
|
129
538
|
className?: string;
|
|
130
|
-
labels?:
|
|
539
|
+
labels?: LabelOverride<LegalLabels>;
|
|
131
540
|
}
|
|
132
541
|
|
|
133
542
|
export function LegalLayout({
|
|
@@ -144,7 +553,7 @@ export function LegalLayout({
|
|
|
144
553
|
return (
|
|
145
554
|
<article className={cn("mx-auto w-full max-w-3xl px-4 py-12", className)}>
|
|
146
555
|
{back !== undefined && <div className="mb-4 text-sm">{back}</div>}
|
|
147
|
-
<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>
|
|
148
557
|
{notice !== undefined && notice !== null && (
|
|
149
558
|
<AlertBanner tone="warning" role="note" className="mt-4">
|
|
150
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
|
+
}
|