@eifi1/ui-kit 0.28.1 → 0.29.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 (160) hide show
  1. package/README.md +21 -3
  2. package/dist/auth/accept-invitation.d.ts +90 -0
  3. package/dist/auth/accept-invitation.js +117 -0
  4. package/dist/auth/accept-invitation.js.map +1 -0
  5. package/dist/auth/auth-errors.d.ts +60 -0
  6. package/dist/auth/auth-errors.js +32 -0
  7. package/dist/auth/auth-errors.js.map +1 -0
  8. package/dist/auth/complete-name-dialog.d.ts +71 -0
  9. package/dist/auth/complete-name-dialog.js +168 -0
  10. package/dist/auth/complete-name-dialog.js.map +1 -0
  11. package/dist/auth/email-tag.d.ts +60 -0
  12. package/dist/auth/email-tag.js +23 -0
  13. package/dist/auth/email-tag.js.map +1 -0
  14. package/dist/auth/forgot-password-form.d.ts +79 -0
  15. package/dist/auth/forgot-password-form.js +120 -0
  16. package/dist/auth/forgot-password-form.js.map +1 -0
  17. package/dist/auth/form-rules.d.ts +27 -0
  18. package/dist/auth/form-rules.js +23 -0
  19. package/dist/auth/form-rules.js.map +1 -0
  20. package/dist/auth/new-password-fields.d.ts +38 -0
  21. package/dist/auth/new-password-fields.js +54 -0
  22. package/dist/auth/new-password-fields.js.map +1 -0
  23. package/dist/auth/not-found-page.d.ts +57 -0
  24. package/dist/auth/not-found-page.js +40 -0
  25. package/dist/auth/not-found-page.js.map +1 -0
  26. package/dist/auth/register-form.d.ts +86 -0
  27. package/dist/auth/register-form.js +268 -0
  28. package/dist/auth/register-form.js.map +1 -0
  29. package/dist/auth/reset-password-form.d.ts +124 -0
  30. package/dist/auth/reset-password-form.js +164 -0
  31. package/dist/auth/reset-password-form.js.map +1 -0
  32. package/dist/auth/sign-in-form.d.ts +243 -0
  33. package/dist/auth/sign-in-form.js +345 -0
  34. package/dist/auth/sign-in-form.js.map +1 -0
  35. package/dist/auth/status-parts.d.ts +78 -0
  36. package/dist/auth/status-parts.js +83 -0
  37. package/dist/auth/status-parts.js.map +1 -0
  38. package/dist/auth/verify-email.d.ts +121 -0
  39. package/dist/auth/verify-email.js +207 -0
  40. package/dist/auth/verify-email.js.map +1 -0
  41. package/dist/chart.d.ts +17 -2
  42. package/dist/components/amount-input.d.ts +18 -2
  43. package/dist/components/button-group.d.ts +18 -2
  44. package/dist/components/calculator.d.ts +18 -2
  45. package/dist/components/confirm-dialog.d.ts +18 -2
  46. package/dist/components/copy-button.d.ts +18 -2
  47. package/dist/components/danger-confirm.d.ts +18 -2
  48. package/dist/components/facing-pair.d.ts +18 -2
  49. package/dist/components/file-button.d.ts +18 -2
  50. package/dist/components/file-dropzone.d.ts +18 -2
  51. package/dist/components/form-actions.d.ts +18 -2
  52. package/dist/components/iban-input.d.ts +18 -2
  53. package/dist/components/language-select.d.ts +18 -9
  54. package/dist/components/legal-page.d.ts +18 -2
  55. package/dist/components/legal.d.ts +18 -2
  56. package/dist/components/money-field.d.ts +18 -2
  57. package/dist/components/number-field.d.ts +18 -2
  58. package/dist/components/number-input.d.ts +18 -2
  59. package/dist/components/numpad-sheet.d.ts +18 -2
  60. package/dist/components/phone-input.d.ts +18 -2
  61. package/dist/components/series-chart.d.ts +18 -2
  62. package/dist/components/settings-fields.d.ts +15 -2
  63. package/dist/components/share-card.d.ts +18 -2
  64. package/dist/components/text-link.d.ts +18 -2
  65. package/dist/components/time-input.d.ts +18 -2
  66. package/dist/components/ui.d.ts +17 -1
  67. package/dist/components/user-avatar.d.ts +16 -2
  68. package/dist/components/user-avatar.js +7 -3
  69. package/dist/components/user-avatar.js.map +1 -1
  70. package/dist/feedback/feedback-attachment.d.ts +18 -2
  71. package/dist/feedback/feedback-context.d.ts +18 -2
  72. package/dist/feedback/feedback-crash.d.ts +18 -2
  73. package/dist/feedback/feedback-dialog.d.ts +18 -2
  74. package/dist/feedback/feedback-inbox.d.ts +18 -2
  75. package/dist/feedback/feedback-labels.d.ts +18 -2
  76. package/dist/feedback/feedback-menu.d.ts +18 -2
  77. package/dist/feedback/feedback-record.d.ts +18 -2
  78. package/dist/feedback/feedback-row-detail.d.ts +18 -2
  79. package/dist/feedback/feedback-status-undo.d.ts +18 -2
  80. package/dist/feedback/feedback-submit.d.ts +18 -2
  81. package/dist/feedback/feedback-swipe.d.ts +18 -2
  82. package/dist/feedback/feedback-table.d.ts +18 -2
  83. package/dist/feedback/feedback-thread.d.ts +18 -2
  84. package/dist/feedback.d.ts +18 -2
  85. package/dist/hooks/use-file-drop.d.ts +18 -2
  86. package/dist/i18n/defaults.d.ts +18 -2
  87. package/dist/i18n/defaults.js +18 -0
  88. package/dist/i18n/defaults.js.map +1 -1
  89. package/dist/i18n/german.d.ts +18 -2
  90. package/dist/i18n/german.js +137 -0
  91. package/dist/i18n/german.js.map +1 -1
  92. package/dist/i18n/kit-labels.d.ts +18 -2
  93. package/dist/i18n/kit-labels.js.map +1 -1
  94. package/dist/i18n/languages.d.ts +13 -201
  95. package/dist/i18n/locales/de-CH.d.ts +18 -2
  96. package/dist/i18n/locales/en.d.ts +18 -2
  97. package/dist/i18n/locales/es.d.ts +18 -2
  98. package/dist/i18n/locales/es.js +137 -1
  99. package/dist/i18n/locales/es.js.map +1 -1
  100. package/dist/i18n/locales/fr.d.ts +18 -2
  101. package/dist/i18n/locales/fr.js +139 -0
  102. package/dist/i18n/locales/fr.js.map +1 -1
  103. package/dist/i18n/locales/hu.d.ts +18 -2
  104. package/dist/i18n/locales/hu.js +139 -1
  105. package/dist/i18n/locales/hu.js.map +1 -1
  106. package/dist/i18n/locales/it.d.ts +18 -2
  107. package/dist/i18n/locales/it.js +137 -0
  108. package/dist/i18n/locales/it.js.map +1 -1
  109. package/dist/i18n/locales/zh.d.ts +18 -2
  110. package/dist/i18n/locales/zh.js +137 -0
  111. package/dist/i18n/locales/zh.js.map +1 -1
  112. package/dist/i18n/review.d.ts +18 -2
  113. package/dist/i18n/review.js +9 -1
  114. package/dist/i18n/review.js.map +1 -1
  115. package/dist/index.d.ts +13 -2
  116. package/dist/index.js +36 -0
  117. package/dist/index.js.map +1 -1
  118. package/dist/lib/person-name.d.ts +69 -0
  119. package/dist/lib/person-name.js +65 -0
  120. package/dist/lib/person-name.js.map +1 -0
  121. package/dist/{kit-labels-Du0uHBq4.d.ts → register-form-V1OeNlMr.d.ts} +383 -2
  122. package/dist/rhf/fields.d.ts +18 -2
  123. package/dist/rhf/form.d.ts +18 -2
  124. package/dist/rhf.d.ts +18 -2
  125. package/dist/shell/app-shell.d.ts +18 -2
  126. package/dist/shell/company-switcher.d.ts +59 -0
  127. package/dist/shell/company-switcher.js +85 -0
  128. package/dist/shell/company-switcher.js.map +1 -0
  129. package/dist/shell/top-bar-brand.d.ts +18 -2
  130. package/dist/shell/topbar-action-menu.d.ts +1 -0
  131. package/dist/shell.d.ts +12 -2
  132. package/dist/wizard/stepper-nav.d.ts +18 -2
  133. package/dist/wizard.d.ts +18 -2
  134. package/package.json +1 -1
  135. package/src/auth/accept-invitation.tsx +227 -0
  136. package/src/auth/auth-errors.ts +105 -0
  137. package/src/auth/complete-name-dialog.tsx +253 -0
  138. package/src/auth/email-tag.ts +75 -0
  139. package/src/auth/forgot-password-form.tsx +213 -0
  140. package/src/auth/form-rules.ts +40 -0
  141. package/src/auth/new-password-fields.tsx +85 -0
  142. package/src/auth/not-found-page.tsx +98 -0
  143. package/src/auth/register-form.tsx +459 -0
  144. package/src/auth/reset-password-form.tsx +337 -0
  145. package/src/auth/sign-in-form.tsx +687 -0
  146. package/src/auth/status-parts.tsx +138 -0
  147. package/src/auth/verify-email.tsx +358 -0
  148. package/src/components/user-avatar.tsx +22 -4
  149. package/src/i18n/defaults.ts +18 -0
  150. package/src/i18n/german.ts +143 -0
  151. package/src/i18n/kit-labels.tsx +27 -0
  152. package/src/i18n/locales/es.ts +144 -1
  153. package/src/i18n/locales/fr.ts +147 -0
  154. package/src/i18n/locales/hu.ts +147 -1
  155. package/src/i18n/locales/it.ts +143 -0
  156. package/src/i18n/locales/zh.ts +138 -0
  157. package/src/i18n/review.ts +8 -0
  158. package/src/index.ts +53 -0
  159. package/src/lib/person-name.ts +157 -0
  160. package/src/shell/company-switcher.tsx +140 -0
@@ -0,0 +1,86 @@
1
+ import 'react';
2
+ export { cr as DEFAULT_REGISTER_LABELS, dS as RegisterForm, dT as RegisterFormProps, dU as RegisterLabels, dV as RegisterValues } from '../register-form-V1OeNlMr.js';
3
+ import '../data-table-labels-DUELeXpa.js';
4
+ import '../components/data-table-sort.js';
5
+ import '../components/swipeable-row.js';
6
+ import '../components/mini-calendar.js';
7
+ import '../components/calendar-heatmap.js';
8
+ import '../components/popover.js';
9
+ import '../components/chip.js';
10
+ import 'lucide-react';
11
+ import '../components/field-sync.js';
12
+ import '../components/tooltip.js';
13
+ import '../hooks/use-anchored-rect.js';
14
+ import '../lib/clipping.js';
15
+ import '../components/field-parts.js';
16
+ import '../wizard/types.js';
17
+ import '../tour/tour.js';
18
+ import '../search/command-palette.js';
19
+ import '../search/global-search.js';
20
+ import '../search/search-index.js';
21
+ import '../components/month-picker.js';
22
+ import '../components/page-contents.js';
23
+ import '../components/series-chart-labels.js';
24
+ import '../components/pie-chart-labels.js';
25
+ import '../components/sparkline.js';
26
+ import '../components/stat-tile.js';
27
+ import '../components/signature-pad.js';
28
+ import '../components/password-strength.js';
29
+ import '../components/swatch-picker.js';
30
+ import '../components/tile-radio.js';
31
+ import '../components/icon-picker.js';
32
+ import '../components/dialog-frame.js';
33
+ import '../components/modal.js';
34
+ import '../hooks/use-search-param-state.js';
35
+ import '../components/measured-grid.js';
36
+ import '../components/user-avatar.js';
37
+ import '../lib/person-name.js';
38
+ import '../components/status-dot.js';
39
+ import '../components/progress-bar.js';
40
+ import '../components/signed-amount.js';
41
+ import '../shell/topbar-action-menu.js';
42
+ import '../components/menu-item.js';
43
+ import '../components/floating-panel.js';
44
+ import '../hooks/use-authed-src.js';
45
+ import '../components/account-settings-labels.js';
46
+ import '../components/bulk-action-bar.js';
47
+ import '../components/list.js';
48
+ import '../components/breadcrumbs.js';
49
+ import '../components/toast.js';
50
+ import '../components/description-list.js';
51
+ import '../components/line-items.js';
52
+ import '../components/error-boundary.js';
53
+ import '../components/authed-image.js';
54
+ import '../components/image-grid.js';
55
+ import '../components/lightbox.js';
56
+ import '../components/write-lock.js';
57
+ import './sign-in-form.js';
58
+ import './complete-name-dialog.js';
59
+ import './forgot-password-form.js';
60
+ import './status-parts.js';
61
+ import './reset-password-form.js';
62
+ import './verify-email.js';
63
+ import './not-found-page.js';
64
+ import './accept-invitation.js';
65
+ import '../shell/company-switcher.js';
66
+ import '../components/account-chips.js';
67
+ import '../lib/format.js';
68
+ import '../components/reauth-dialog.js';
69
+ import '../components/server-wake.js';
70
+ import '../lib/server-wake.js';
71
+ import '../components/translation-review-labels.js';
72
+ import '../lib/translation-review.js';
73
+ import '../components/country-select.js';
74
+ import '../components/inline-edit-field.js';
75
+ import '../lib/iban.js';
76
+ import '../lib/phone.js';
77
+ import '../components/sign-chip.js';
78
+ import '../components/column-mapper.js';
79
+ import '../lib/column-mapping.js';
80
+ import '../lib/table-text.js';
81
+ import '../shell/topbar-controls.js';
82
+ import '../theme/palette-presets.js';
83
+ import '../theme/chart-palette.js';
84
+ import '../theme/theme-store.js';
85
+ import 'zustand/middleware';
86
+ import 'zustand';
@@ -0,0 +1,268 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useRef, useState } from "react";
4
+ import { useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
5
+ import { KIT_LANGUAGES, resolveLanguage } from "../i18n/languages.js";
6
+ import { cn } from "../lib/cn.js";
7
+ import { AlertBanner } from "../components/alert-banner.js";
8
+ import { hasMessage } from "../components/choice-parts.js";
9
+ import { LanguageSelect } from "../components/language-select.js";
10
+ import { LegalAcceptCheckbox } from "../components/legal-page.js";
11
+ import { TextLink } from "../components/text-link.js";
12
+ import { Button, Input } from "../components/ui.js";
13
+ import { authErrorCode } from "./auth-errors.js";
14
+ import { emailParts, taggedEmail } from "./email-tag.js";
15
+ import { newPasswordProblem, personNameOk, PERSON_NAME_MAX_LENGTH } from "./form-rules.js";
16
+ import { NewPasswordFields } from "./new-password-fields.js";
17
+ const DEFAULT_REGISTER_LABELS = {
18
+ firstName: "First name",
19
+ lastName: "Last name",
20
+ email: "Email",
21
+ emailTagUse: (address) => `Use ${address}`,
22
+ emailTagHint: "Many providers deliver name+tag@\u2026 to the same inbox, so mail from this app is easy to filter and trace. Check yours does before you rely on it: you would sign in with the tagged address.",
23
+ invitedEmailHint: "The address your invitation was sent to.",
24
+ invitedTagNote: "The tagged address gets a confirmation mail of its own.",
25
+ password: "Password",
26
+ confirmPassword: "Repeat password",
27
+ passwordMismatch: "The passwords don't match.",
28
+ language: "Language",
29
+ submit: "Create account",
30
+ haveAccount: "Already have an account?",
31
+ signIn: "Sign in",
32
+ emailTaken: "An account with this email address already exists.",
33
+ registrationClosed: "New accounts are by invitation only. Ask the operator to invite your email address.",
34
+ invitationInvalid: "This invitation link is not valid.",
35
+ invitationExpired: "This invitation has expired. Ask for a new one.",
36
+ failed: "Registration failed. Please try again."
37
+ };
38
+ const ALL_CODES = KIT_LANGUAGES.map((language) => language.code);
39
+ function browserLanguages() {
40
+ if (typeof navigator === "undefined") return [];
41
+ return navigator.languages?.length ? navigator.languages : [navigator.language];
42
+ }
43
+ function RegisterForm({
44
+ onSubmit,
45
+ emailTag,
46
+ invitedEmail,
47
+ locale: localeProp,
48
+ defaultLocale,
49
+ onLocaleChange,
50
+ languages = ALL_CODES,
51
+ languageField,
52
+ aboveForm,
53
+ underEmail,
54
+ appFields,
55
+ afterFields,
56
+ appFieldsComplete = true,
57
+ termsHref,
58
+ privacyHref,
59
+ signInHref,
60
+ describeError,
61
+ labels: labelsProp,
62
+ className,
63
+ ...rest
64
+ }) {
65
+ const labels = useKitLabels("register", DEFAULT_REGISTER_LABELS, labelsProp);
66
+ const kitLocale = useKitLocale();
67
+ const invited = invitedEmail !== void 0;
68
+ const [firstName, setFirstName] = useState("");
69
+ const [lastName, setLastName] = useState("");
70
+ const [email, setEmail] = useState(invitedEmail ?? "");
71
+ const [password, setPassword] = useState("");
72
+ const [confirm, setConfirm] = useState("");
73
+ const [ownLocale, setOwnLocale] = useState(
74
+ () => defaultLocale ?? resolveLanguage([kitLocale, ...browserLanguages()], languages)
75
+ );
76
+ const [accepted, setAccepted] = useState(false);
77
+ const [busy, setBusy] = useState(null);
78
+ const [taken, setTaken] = useState(null);
79
+ const [failure, setFailure] = useState(null);
80
+ const emailRef = useRef(null);
81
+ const tagHintId = useId();
82
+ const mounted = useRef(true);
83
+ useEffect(() => {
84
+ mounted.current = true;
85
+ return () => {
86
+ mounted.current = false;
87
+ };
88
+ }, []);
89
+ const locale = resolveLanguage([localeProp ?? ownLocale], languages);
90
+ const changeLocale = (code) => {
91
+ if (localeProp === void 0) setOwnLocale(code);
92
+ onLocaleChange?.(code);
93
+ };
94
+ const working = busy !== null;
95
+ const suggestion = emailTag ? taggedEmail(email, emailTag) : null;
96
+ const backToInvited = invitedEmail !== void 0 && email.trim() !== invitedEmail.trim() ? invitedEmail.trim() : null;
97
+ const canSubmit = personNameOk(firstName) && personNameOk(lastName) && emailParts(email) !== null && newPasswordProblem(password, confirm) === null && accepted && appFieldsComplete;
98
+ const submit = (e) => {
99
+ e.preventDefault();
100
+ if (!canSubmit || working) return;
101
+ const values = {
102
+ firstName: firstName.trim(),
103
+ lastName: lastName.trim(),
104
+ email: email.trim(),
105
+ password,
106
+ locale
107
+ };
108
+ setBusy("sending");
109
+ setFailure(null);
110
+ setTaken(null);
111
+ let result;
112
+ try {
113
+ result = Promise.resolve(onSubmit(values));
114
+ } catch (error) {
115
+ result = Promise.reject(error);
116
+ }
117
+ result.then(
118
+ () => {
119
+ if (mounted.current) setBusy("done");
120
+ },
121
+ (error) => {
122
+ if (!mounted.current) return;
123
+ setBusy(null);
124
+ const own = describeError?.(error);
125
+ const code = authErrorCode(error);
126
+ if (code === "email_taken" && !hasMessage(own)) {
127
+ setTaken(values.email);
128
+ emailRef.current?.focus();
129
+ return;
130
+ }
131
+ setFailure(
132
+ hasMessage(own) ? own : code === "registration_closed" ? labels.registrationClosed : code === "invitation_invalid" ? labels.invitationInvalid : code === "invitation_expired" ? labels.invitationExpired : labels.failed
133
+ );
134
+ }
135
+ );
136
+ };
137
+ return /* @__PURE__ */ jsxs("div", { ...rest, className: cn("@container space-y-4", className), children: [
138
+ aboveForm,
139
+ /* @__PURE__ */ jsxs("form", { className: "space-y-3", noValidate: true, onSubmit: submit, children: [
140
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-3 @xs:grid-cols-2", children: [
141
+ /* @__PURE__ */ jsx(
142
+ Input,
143
+ {
144
+ name: "given-name",
145
+ autoComplete: "given-name",
146
+ label: labels.firstName,
147
+ value: firstName,
148
+ onChange: (e) => setFirstName(e.target.value),
149
+ maxLength: PERSON_NAME_MAX_LENGTH,
150
+ readOnly: working,
151
+ required: true
152
+ }
153
+ ),
154
+ /* @__PURE__ */ jsx(
155
+ Input,
156
+ {
157
+ name: "family-name",
158
+ autoComplete: "family-name",
159
+ label: labels.lastName,
160
+ value: lastName,
161
+ onChange: (e) => setLastName(e.target.value),
162
+ maxLength: PERSON_NAME_MAX_LENGTH,
163
+ readOnly: working,
164
+ required: true
165
+ }
166
+ )
167
+ ] }),
168
+ /* @__PURE__ */ jsxs("div", { children: [
169
+ /* @__PURE__ */ jsx(
170
+ Input,
171
+ {
172
+ ref: emailRef,
173
+ type: "email",
174
+ name: "email",
175
+ autoComplete: "email",
176
+ label: labels.email,
177
+ value: email,
178
+ onChange: (e) => setEmail(e.target.value),
179
+ readOnly: invited || working,
180
+ hint: invited ? labels.invitedEmailHint : void 0,
181
+ error: taken !== null && taken === email.trim() ? labels.emailTaken : void 0,
182
+ required: true
183
+ }
184
+ ),
185
+ suggestion && /* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-[var(--text-muted)]", children: [
186
+ /* @__PURE__ */ jsx(
187
+ Button,
188
+ {
189
+ type: "button",
190
+ variant: "link",
191
+ size: "sm",
192
+ className: "h-auto p-0 align-baseline",
193
+ disabled: working,
194
+ "aria-describedby": tagHintId,
195
+ onClick: () => setEmail(suggestion),
196
+ children: labels.emailTagUse(suggestion)
197
+ }
198
+ ),
199
+ " ",
200
+ /* @__PURE__ */ jsx("span", { id: tagHintId, children: labels.emailTagHint })
201
+ ] }),
202
+ backToInvited !== null && /* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-[var(--text-muted)]", children: [
203
+ /* @__PURE__ */ jsx("span", { children: labels.invitedTagNote }),
204
+ " ",
205
+ /* @__PURE__ */ jsx(
206
+ Button,
207
+ {
208
+ type: "button",
209
+ variant: "link",
210
+ size: "sm",
211
+ className: "h-auto p-0 align-baseline",
212
+ disabled: working,
213
+ onClick: () => setEmail(backToInvited),
214
+ children: labels.emailTagUse(backToInvited)
215
+ }
216
+ )
217
+ ] }),
218
+ underEmail
219
+ ] }),
220
+ /* @__PURE__ */ jsx(
221
+ NewPasswordFields,
222
+ {
223
+ password,
224
+ confirm,
225
+ onPasswordChange: setPassword,
226
+ onConfirmChange: setConfirm,
227
+ busy: working,
228
+ text: { password: labels.password, confirm: labels.confirmPassword, mismatch: labels.passwordMismatch }
229
+ }
230
+ ),
231
+ languageField === void 0 ? /* @__PURE__ */ jsx(
232
+ LanguageSelect,
233
+ {
234
+ name: "locale",
235
+ label: labels.language,
236
+ value: locale,
237
+ codes: languages,
238
+ onChange: changeLocale,
239
+ disabled: working
240
+ }
241
+ ) : languageField,
242
+ appFields,
243
+ afterFields,
244
+ /* @__PURE__ */ jsx(
245
+ LegalAcceptCheckbox,
246
+ {
247
+ checked: accepted,
248
+ onCheckedChange: setAccepted,
249
+ termsHref,
250
+ privacyHref,
251
+ disabled: working
252
+ }
253
+ ),
254
+ hasMessage(failure) && /* @__PURE__ */ jsx(AlertBanner, { tone: "danger", size: "sm", role: "alert", children: failure }),
255
+ /* @__PURE__ */ jsx(Button, { type: "submit", className: "w-full", disabled: !working && !canSubmit, pending: working, children: labels.submit })
256
+ ] }),
257
+ signInHref !== void 0 && /* @__PURE__ */ jsxs("p", { className: "text-center text-sm text-[var(--text-secondary)]", children: [
258
+ labels.haveAccount,
259
+ " ",
260
+ /* @__PURE__ */ jsx(TextLink, { href: signInHref, tone: "primary", children: labels.signIn })
261
+ ] })
262
+ ] });
263
+ }
264
+ export {
265
+ DEFAULT_REGISTER_LABELS,
266
+ RegisterForm
267
+ };
268
+ //# sourceMappingURL=register-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/auth/register-form.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, FormEvent, ReactNode } from \"react\";\n\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { KIT_LANGUAGES, resolveLanguage } from \"../i18n/languages\";\nimport type { KitLanguageCode } from \"../i18n/languages\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport { LanguageSelect } from \"../components/language-select\";\nimport { LegalAcceptCheckbox } from \"../components/legal-page\";\nimport { TextLink } from \"../components/text-link\";\nimport { Button, Input } from \"../components/ui\";\nimport { authErrorCode } from \"./auth-errors\";\nimport { emailParts, taggedEmail } from \"./email-tag\";\nimport { newPasswordProblem, personNameOk, PERSON_NAME_MAX_LENGTH } from \"./form-rules\";\nimport { NewPasswordFields } from \"./new-password-fields\";\n\n/** What `RegisterForm` hands `onSubmit` — the core of `POST /auth/register` (§4.2). The\n * app adds its own fields (kastlan's company, keksdose's currency) and the\n * `invite_token` it read from the URL. */\nexport interface RegisterValues {\n /** Trimmed, 1–120 characters. */\n firstName: string;\n /** Trimmed, 1–120 characters. */\n lastName: string;\n /** Trimmed. Lower-casing is the server's (§3.1); a tag is never stripped (§4.5). */\n email: string;\n /** As typed: at least 8 characters, at most 72 bytes. */\n password: string;\n /** The language picked — one of `languages` — for every mail to the user (§3.1). */\n locale: KitLanguageCode;\n}\n\n/**\n * Every string `RegisterForm` renders — the `register` namespace of `<UiKitProvider\n * labels>`, overridable per instance through `labels`. keksdose's words where it has\n * them. The terms checkbox speaks `legal.accept`, the strength meter `passwordStrength`.\n */\nexport interface RegisterLabels {\n firstName: string;\n lastName: string;\n email: string;\n /** The address-tag button (§4.5), given the exact address it would use — and, with an\n * invitation, the button back to the invited address. */\n emailTagUse: (address: string) => string;\n /** The line after the address-tag button. */\n emailTagHint: string;\n /** Under an invited (read-only) email field. */\n invitedEmailHint: string;\n /** Once the invitee took the tagged address: it is not the invited one, so it is\n * confirmed by a mail of its own (§4.3). */\n invitedTagNote: string;\n password: string;\n confirmPassword: string;\n passwordMismatch: string;\n language: string;\n /** The submit button. */\n submit: string;\n /** Before the link to `signInHref`. */\n haveAccount: string;\n /** The link to `signInHref`. */\n signIn: string;\n /** `email_taken`, under the email field. */\n emailTaken: string;\n /** `registration_closed` — the gate refused the address (§4.3). */\n registrationClosed: string;\n /** `invitation_invalid` — the invitation link is unknown or spent. */\n invitationInvalid: string;\n /** `invitation_expired`. */\n invitationExpired: string;\n /** Any other failure. */\n failed: string;\n}\n\nexport const DEFAULT_REGISTER_LABELS: RegisterLabels = {\n firstName: \"First name\",\n lastName: \"Last name\",\n email: \"Email\",\n emailTagUse: (address) => `Use ${address}`,\n emailTagHint:\n \"Many providers deliver name+tag@… to the same inbox, so mail from this app is easy to filter and trace. Check yours does before you rely on it: you would sign in with the tagged address.\",\n invitedEmailHint: \"The address your invitation was sent to.\",\n invitedTagNote: \"The tagged address gets a confirmation mail of its own.\",\n password: \"Password\",\n confirmPassword: \"Repeat password\",\n passwordMismatch: \"The passwords don't match.\",\n language: \"Language\",\n submit: \"Create account\",\n haveAccount: \"Already have an account?\",\n signIn: \"Sign in\",\n emailTaken: \"An account with this email address already exists.\",\n registrationClosed: \"New accounts are by invitation only. Ask the operator to invite your email address.\",\n invitationInvalid: \"This invitation link is not valid.\",\n invitationExpired: \"This invitation has expired. Ask for a new one.\",\n failed: \"Registration failed. Please try again.\",\n};\n\nexport interface RegisterFormProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSubmit\" | \"children\"> {\n /**\n * The form was submitted with everything filled in. Send it (`POST /auth/register`,\n * §4.2) and resolve once the user is signed in, or reject with the client's error:\n * `email_taken` shows under the email field, `registration_closed` and the\n * invitation codes above the button, anything else as \"Registration failed\". The form\n * never sends a request itself (§8): keksdose must see the password on its way.\n *\n * On resolve the form stays busy while the app navigates.\n */\n onSubmit: (values: RegisterValues) => Promise<unknown>;\n /**\n * The app's address tag (`\"kastlan\"`, §4.5). Once the email is plausible, a button\n * under it offers the tagged address — \"Use ada+kastlan@example.com\" — with a line on\n * why; one click puts it in the field. Never applied on its own. Left out, no offer.\n */\n emailTag?: string;\n /**\n * The address of the invitation this sign-up comes from (§4.4): the field starts with\n * it and is read-only. With `emailTag`, the invitee may still take the tagged form of\n * it — the server accepts exactly that variant — and go back.\n */\n invitedEmail?: string;\n /**\n * The language field's value — controlled. Pass the app's UI language\n * (`i18n.resolvedLanguage`) with `onLocaleChange` switching it, and the field IS the\n * app's language switch, with no copy of its own to drift from a second switcher on\n * the page (keksdose's register page has one in its header). Any tag; it shows (and\n * submits) the offered code it resolves to. Left out, the form keeps its own, starting\n * from `defaultLocale`, else the provider's language, else the browser's.\n */\n locale?: string;\n /** The uncontrolled language field's start value. */\n defaultLocale?: string;\n /** A language was picked. */\n onLocaleChange?: (code: KitLanguageCode) => void;\n /** The languages to offer, in order. Default all seven. */\n languages?: readonly KitLanguageCode[];\n /**\n * The app's own language field in place of the kit's select — keksdose's\n * `LanguageSetting` bound to its i18n. `null` draws none (an app with one language);\n * the submitted `locale` is then `locale`'s.\n */\n languageField?: ReactNode;\n /** Above the form — keksdose's closed-beta banner. */\n aboveForm?: ReactNode;\n /** Under the email field and its tag offer — an app's own hint. */\n underEmail?: ReactNode;\n /** The app's sign-up fields (§4.1 item 7): kastlan's Company, keksdose's reporting\n * currency. Their values are the app's; say whether they are complete with\n * `appFieldsComplete`. */\n appFields?: ReactNode;\n /** After the app fields, before the terms — keksdose's privacy-mode note. */\n afterFields?: ReactNode;\n /** Whether the app fields are filled in as required — kastlan's Company without an\n * invitation. The submit waits for it. Default `true`. */\n appFieldsComplete?: boolean;\n /** The terms checkbox's links. Default `/terms` and `/privacy`. */\n termsHref?: string;\n privacyHref?: string;\n /** \"Already have an account? Sign in\" goes here — `/login`. Left out, no line. */\n signInHref?: string;\n /** The app's own words for a failure the kit cannot know (a throttled attempt), or\n * `undefined` for the kit's. Asked first, for every failure. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: Partial<RegisterLabels>;\n}\n\nconst ALL_CODES: readonly KitLanguageCode[] = KIT_LANGUAGES.map((language) => language.code);\n\n/** The browser's languages, in its order — absent outside a browser. */\nfunction browserLanguages(): readonly string[] {\n if (typeof navigator === \"undefined\") return [];\n return navigator.languages?.length ? navigator.languages : [navigator.language];\n}\n\ntype Busy = \"sending\" | \"done\" | null;\n\n/**\n * Sign-up for every app (docs/auth-harmonization.md §4.1, §8): first and last name,\n * email with the address-tag offer, password with the strength meter and its\n * confirmation, language, the app's own fields in a slot, and the terms. keksdose's\n * `RegisterPage` (features/auth/register-page.tsx) with its slots made props.\n *\n * **It never sends a request.** `onSubmit` gets the values; what the request carries\n * besides them (kastlan's company, keksdose's currency, the `invite_token`) is the\n * app's, as are the role and the associations, which never come from the form (§4.3).\n *\n * **The submit waits for a complete form**: both names (1–120 characters after\n * trimming), a plausible address, a password of at least 8 characters and at most 72\n * bytes, the same password again, the terms ticked, and `appFieldsComplete`. Nothing\n * else is a rule — the strength checklist is advice (keksdose #124), and the kit adds\n * none of its own (§8). So there is never a failed attempt for a missing field, and no\n * field error to show for one.\n *\n * **The address tag** (§4.5) is offered under the email field as one click with the\n * exact result on the button, never applied: sub-addressing is a convention the\n * receiving server may or may not implement, and a silent rewrite would send the\n * verification mail down a path nobody checked. With an invitation the field is fixed\n * to the invited address; the invitee may still take its tagged form, and is told it\n * will be confirmed by a mail of its own (§4.3).\n *\n * **Refusals** are read by code ({@link authErrorCode}): `email_taken` under the email\n * field, which takes the focus; `registration_closed`, `invitation_invalid` and\n * `invitation_expired` above the button; anything else as \"Registration failed\", unless\n * `describeError` has the app's words.\n *\n * Laid out for a 390 px phone: the names sit side by side only where the form is at\n * least 20rem wide (a container query), which the narrow `AuthLayout` card is on a\n * desktop and a phone is not.\n */\nexport function RegisterForm({\n onSubmit,\n emailTag,\n invitedEmail,\n locale: localeProp,\n defaultLocale,\n onLocaleChange,\n languages = ALL_CODES,\n languageField,\n aboveForm,\n underEmail,\n appFields,\n afterFields,\n appFieldsComplete = true,\n termsHref,\n privacyHref,\n signInHref,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: RegisterFormProps) {\n const labels = useKitLabels(\"register\", DEFAULT_REGISTER_LABELS, labelsProp);\n const kitLocale = useKitLocale();\n const invited = invitedEmail !== undefined;\n const [firstName, setFirstName] = useState(\"\");\n const [lastName, setLastName] = useState(\"\");\n const [email, setEmail] = useState(invitedEmail ?? \"\");\n const [password, setPassword] = useState(\"\");\n const [confirm, setConfirm] = useState(\"\");\n const [ownLocale, setOwnLocale] = useState<string>(\n () => defaultLocale ?? resolveLanguage([kitLocale, ...browserLanguages()], languages),\n );\n const [accepted, setAccepted] = useState(false);\n const [busy, setBusy] = useState<Busy>(null);\n // `email_taken` belongs to the address it was answered for; another one clears it.\n const [taken, setTaken] = useState<string | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const emailRef = useRef<HTMLInputElement>(null);\n const tagHintId = useId();\n\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n // What the field shows is what is submitted: the offered code the value resolves to.\n const locale = resolveLanguage([localeProp ?? ownLocale], languages);\n const changeLocale = (code: KitLanguageCode) => {\n if (localeProp === undefined) setOwnLocale(code);\n onLocaleChange?.(code);\n };\n\n const working = busy !== null;\n const suggestion = emailTag ? taggedEmail(email, emailTag) : null;\n // The invitee took the tagged address: offer the way back to the invited one.\n const backToInvited =\n invitedEmail !== undefined && email.trim() !== invitedEmail.trim() ? invitedEmail.trim() : null;\n const canSubmit =\n personNameOk(firstName) &&\n personNameOk(lastName) &&\n emailParts(email) !== null &&\n newPasswordProblem(password, confirm) === null &&\n accepted &&\n appFieldsComplete;\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n if (!canSubmit || working) return;\n const values: RegisterValues = {\n firstName: firstName.trim(),\n lastName: lastName.trim(),\n email: email.trim(),\n password,\n locale,\n };\n setBusy(\"sending\");\n setFailure(null);\n setTaken(null);\n let result: Promise<unknown>;\n try {\n result = Promise.resolve(onSubmit(values));\n } catch (error) {\n result = Promise.reject(error);\n }\n result.then(\n () => {\n if (mounted.current) setBusy(\"done\");\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusy(null);\n const own = describeError?.(error);\n const code = authErrorCode(error);\n if (code === \"email_taken\" && !hasMessage(own)) {\n setTaken(values.email);\n emailRef.current?.focus();\n return;\n }\n setFailure(\n hasMessage(own)\n ? own\n : code === \"registration_closed\"\n ? labels.registrationClosed\n : code === \"invitation_invalid\"\n ? labels.invitationInvalid\n : code === \"invitation_expired\"\n ? labels.invitationExpired\n : labels.failed,\n );\n },\n );\n };\n\n return (\n <div {...rest} className={cn(\"@container space-y-4\", className)}>\n {aboveForm}\n <form className=\"space-y-3\" noValidate onSubmit={submit}>\n <div className=\"grid gap-3 @xs:grid-cols-2\">\n <Input\n name=\"given-name\"\n autoComplete=\"given-name\"\n label={labels.firstName}\n value={firstName}\n onChange={(e) => setFirstName(e.target.value)}\n maxLength={PERSON_NAME_MAX_LENGTH}\n readOnly={working}\n required\n />\n <Input\n name=\"family-name\"\n autoComplete=\"family-name\"\n label={labels.lastName}\n value={lastName}\n onChange={(e) => setLastName(e.target.value)}\n maxLength={PERSON_NAME_MAX_LENGTH}\n readOnly={working}\n required\n />\n </div>\n\n <div>\n <Input\n ref={emailRef}\n type=\"email\"\n name=\"email\"\n autoComplete=\"email\"\n label={labels.email}\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n readOnly={invited || working}\n hint={invited ? labels.invitedEmailHint : undefined}\n error={taken !== null && taken === email.trim() ? labels.emailTaken : undefined}\n required\n />\n {/* The tag, offered rather than applied (§4.5): one click, the exact address\n on the button, reversible by typing — or, invited, by the button back. */}\n {suggestion && (\n <p className=\"mt-1 text-xs text-[var(--text-muted)]\">\n <Button\n type=\"button\"\n variant=\"link\"\n size=\"sm\"\n className=\"h-auto p-0 align-baseline\"\n disabled={working}\n aria-describedby={tagHintId}\n onClick={() => setEmail(suggestion)}\n >\n {labels.emailTagUse(suggestion)}\n </Button>{\" \"}\n <span id={tagHintId}>{labels.emailTagHint}</span>\n </p>\n )}\n {backToInvited !== null && (\n <p className=\"mt-1 text-xs text-[var(--text-muted)]\">\n <span>{labels.invitedTagNote}</span>{\" \"}\n <Button\n type=\"button\"\n variant=\"link\"\n size=\"sm\"\n className=\"h-auto p-0 align-baseline\"\n disabled={working}\n onClick={() => setEmail(backToInvited)}\n >\n {labels.emailTagUse(backToInvited)}\n </Button>\n </p>\n )}\n {underEmail}\n </div>\n\n <NewPasswordFields\n password={password}\n confirm={confirm}\n onPasswordChange={setPassword}\n onConfirmChange={setConfirm}\n busy={working}\n text={{ password: labels.password, confirm: labels.confirmPassword, mismatch: labels.passwordMismatch }}\n />\n\n {languageField === undefined ? (\n <LanguageSelect\n name=\"locale\"\n label={labels.language}\n value={locale}\n codes={languages}\n onChange={changeLocale}\n disabled={working}\n />\n ) : (\n languageField\n )}\n\n {appFields}\n {afterFields}\n\n {/* The kit's terms checkbox (legal contract §3.4). Never an error: an unticked\n box keeps the submit disabled, so there is no failed attempt to explain. */}\n <LegalAcceptCheckbox\n checked={accepted}\n onCheckedChange={setAccepted}\n termsHref={termsHref}\n privacyHref={privacyHref}\n disabled={working}\n />\n\n {hasMessage(failure) && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure}\n </AlertBanner>\n )}\n\n <Button type=\"submit\" className=\"w-full\" disabled={!working && !canSubmit} pending={working}>\n {labels.submit}\n </Button>\n </form>\n {signInHref !== undefined && (\n <p className=\"text-center text-sm text-[var(--text-secondary)]\">\n {labels.haveAccount}{\" \"}\n <TextLink href={signInHref} tone=\"primary\">\n {labels.signIn}\n </TextLink>\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";AA0UQ,SACE,KADF;AA1UR,SAAS,WAAW,OAAO,QAAQ,gBAAgB;AAGnD,SAAS,cAAc,oBAAoB;AAC3C,SAAS,eAAe,uBAAuB;AAE/C,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AACzB,SAAS,QAAQ,aAAa;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,YAAY,mBAAmB;AACxC,SAAS,oBAAoB,cAAc,8BAA8B;AACzE,SAAS,yBAAyB;AA2D3B,MAAM,0BAA0C;AAAA,EACrD,WAAW;AAAA,EACX,UAAU;AAAA,EACV,OAAO;AAAA,EACP,aAAa,CAAC,YAAY,OAAO,OAAO;AAAA,EACxC,cACE;AAAA,EACF,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,QAAQ;AACV;AAsEA,MAAM,YAAwC,cAAc,IAAI,CAAC,aAAa,SAAS,IAAI;AAG3F,SAAS,mBAAsC;AAC7C,MAAI,OAAO,cAAc,YAAa,QAAO,CAAC;AAC9C,SAAO,UAAU,WAAW,SAAS,UAAU,YAAY,CAAC,UAAU,QAAQ;AAChF;AAq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,qBAAC,OAAE,WAAU,oDACV;AAAA,aAAO;AAAA,MAAa;AAAA,MACrB,oBAAC,YAAS,MAAM,YAAY,MAAK,WAC9B,iBAAO,QACV;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
@@ -0,0 +1,124 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ComponentPropsWithoutRef } from 'react';
3
+ import { AuthHeadingLevel } from './status-parts.js';
4
+
5
+ /** Every string the form renders — the `resetPassword` namespace. keksdose's words
6
+ * (`auth.reset.*`), which kastlan took over. */
7
+ interface ResetPasswordLabels {
8
+ /** The heading, on every state. */
9
+ title: string;
10
+ /** While the link is checked. */
11
+ checking: string;
12
+ /** Over the fields, given the account's address (when the check returned one). */
13
+ intro: (email: string) => string;
14
+ newPassword: string;
15
+ confirmPassword: string;
16
+ /** Under the confirmation while it differs. */
17
+ mismatch: string;
18
+ submit: string;
19
+ /** The new password was not saved, for a reason that is not the link. */
20
+ failed: string;
21
+ /** The page was opened without a `token`. */
22
+ noToken: string;
23
+ /** The link is unknown, spent or expired — one sentence, as the server gives one
24
+ * code (`token_invalid`). */
25
+ invalid: string;
26
+ /** Under it. */
27
+ invalidHint: string;
28
+ /** The way forward from an invalid link: back to "Forgot password". */
29
+ requestNew: string;
30
+ /** Done. */
31
+ success: string;
32
+ /** Under it: a reset ends every session (§6.3). */
33
+ sessionsEnded: string;
34
+ /** The button out — to sign-in, with the address filled in. */
35
+ signIn: string;
36
+ }
37
+ declare const DEFAULT_RESET_PASSWORD_LABELS: ResetPasswordLabels;
38
+ /** What `onCheck` may resolve with — keksdose's `/password-reset/check` answer. */
39
+ interface ResetPasswordCheck {
40
+ /** The account's address: named over the fields ("You're setting a new password for
41
+ * …") and handed to the password manager, which files the new password under it. */
42
+ email?: string;
43
+ /** The app's notices over the fields, shown BEFORE the password is typed — keksdose's
44
+ * "your account is end-to-end encrypted: this restores your sign-in, not your data". */
45
+ notices?: ReactNode;
46
+ }
47
+ /** What `onSubmit` hands over. */
48
+ interface ResetPasswordValues {
49
+ token: string;
50
+ password: string;
51
+ }
52
+ /** What `onSubmit` resolves with — keksdose's `/password-reset/confirm` answer, which
53
+ * carries no tokens (§6.3). */
54
+ interface ResetPasswordResult {
55
+ /** The account's address — the sign-in it leads to is filled in with it. */
56
+ email: string;
57
+ /** The app's outcomes, shown on the done state: keksdose's recovery-code notice for an
58
+ * encrypted account, "Your 2 personal access tokens were revoked". */
59
+ notices?: ReactNode;
60
+ }
61
+ interface ResetPasswordFormProps extends Omit<ComponentPropsWithoutRef<"div">, "onSubmit" | "children" | "title"> {
62
+ /** The link's token — the app's `?token=` (keksdose, kastlan: `/reset-password?token=…`).
63
+ * Empty: the link was cut short, and the page says so without asking anyone. */
64
+ token: string;
65
+ /**
66
+ * Check the link before the form shows (`/auth/password-reset/check`) — once per
67
+ * token, on mount. Checking does not use it up, so a reload is free. Resolve (with
68
+ * the address and any notices) for a live link; reject for a dead one, and the page
69
+ * says "This link is invalid or has expired" with the way to a new one.
70
+ */
71
+ onCheck: (token: string) => Promise<ResetPasswordCheck | void | undefined>;
72
+ /**
73
+ * The new password was submitted: send `/auth/password-reset/confirm`. Resolve with
74
+ * the account's address (and the app's notices) — no tokens: a reset is not a sign-in
75
+ * (§6.3). Reject with the client's error: `token_invalid` (the link expired or was
76
+ * used in another tab while the form was open) goes to the invalid state; anything
77
+ * else stays on the form with the password kept.
78
+ */
79
+ onSubmit: (values: ResetPasswordValues) => Promise<ResetPasswordResult>;
80
+ /** "Go to sign in" calls this with the address, for an app that routes in code.
81
+ * Without it, the button is a link to `signInHref`. */
82
+ onSignIn?: (email: string) => void;
83
+ /** Where "Go to sign in" leads, with `?email=` added — read it into `SignInForm`'s
84
+ * `defaultEmail`. Default `/login`. */
85
+ signInHref?: string;
86
+ /** "Request a new link" — the app's "Forgot password" page. Default
87
+ * `/forgot-password`. */
88
+ forgotHref?: string;
89
+ /** The app's words for a failed save (a `429`, the device offline), or `undefined`
90
+ * for the kit's `failed`. Not asked for `token_invalid`, which is a state. */
91
+ describeError?: (error: unknown) => ReactNode | undefined;
92
+ /** The heading. Default `labels.title`; `null` draws none, for a page that puts it
93
+ * in `AuthLayout`'s `title` instead. */
94
+ title?: ReactNode;
95
+ /** The heading's level. Default `h2`, under the page's `h1`. */
96
+ headingAs?: AuthHeadingLevel;
97
+ labels?: Partial<ResetPasswordLabels>;
98
+ }
99
+ /**
100
+ * Redeem a password-reset link (`/reset-password?token=…`, docs/auth-harmonization.md
101
+ * §6.3, §7) — keksdose's `ResetPasswordPage` (features/auth/reset-password-page.tsx),
102
+ * which kastlan built its own on.
103
+ *
104
+ * **The link is checked first** (`onCheck`), and only then does the form appear: an
105
+ * expired link should say so before someone types a new password twice, not after.
106
+ *
107
+ * **A reset is not a sign-in** (§6.3, §10.11). The confirm answers without tokens, so a
108
+ * 2FA account cannot skip its second factor by way of its inbox, and the page ends on
109
+ * "Go to sign in" with the address filled in — the person has just typed the new
110
+ * password twice; signing in is one step. What else the reset did is said there:
111
+ * every other session ended (the kit's line, true in all three apps), and the app's own
112
+ * outcomes in `notices` — keksdose's recovery-code notice and its revoked API tokens.
113
+ *
114
+ * **The password** is chosen with the same fields as `RegisterForm` and `SignInForm`'s
115
+ * set-password step ({@link NewPasswordFields}): the strength meter and its checklist as
116
+ * advice, and only the two hard rules — at least 8 characters, at most 72 bytes (§8).
117
+ * The submit waits for both and a matching confirmation.
118
+ *
119
+ * The form never sends a request itself (§8): the token and the password go to the
120
+ * callbacks, and the page renders what they resolve with.
121
+ */
122
+ declare function ResetPasswordForm({ token, onCheck, onSubmit, onSignIn, signInHref, forgotHref, describeError, title, headingAs: Heading, labels: labelsProp, className, ...rest }: ResetPasswordFormProps): react.JSX.Element;
123
+
124
+ export { DEFAULT_RESET_PASSWORD_LABELS, type ResetPasswordCheck, ResetPasswordForm, type ResetPasswordFormProps, type ResetPasswordLabels, type ResetPasswordResult, type ResetPasswordValues };