@eifi1/ui-kit 0.28.0 → 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 (166) hide show
  1. package/README.md +22 -4
  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 +26 -4
  55. package/dist/components/legal-page.js +24 -5
  56. package/dist/components/legal-page.js.map +1 -1
  57. package/dist/components/legal.d.ts +18 -2
  58. package/dist/components/legal.js +49 -5
  59. package/dist/components/legal.js.map +1 -1
  60. package/dist/components/money-field.d.ts +18 -2
  61. package/dist/components/number-field.d.ts +18 -2
  62. package/dist/components/number-input.d.ts +18 -2
  63. package/dist/components/numpad-sheet.d.ts +18 -2
  64. package/dist/components/phone-input.d.ts +18 -2
  65. package/dist/components/series-chart.d.ts +18 -2
  66. package/dist/components/settings-fields.d.ts +15 -2
  67. package/dist/components/share-card.d.ts +18 -2
  68. package/dist/components/text-link.d.ts +18 -2
  69. package/dist/components/time-input.d.ts +18 -2
  70. package/dist/components/ui.d.ts +17 -1
  71. package/dist/components/user-avatar.d.ts +16 -2
  72. package/dist/components/user-avatar.js +7 -3
  73. package/dist/components/user-avatar.js.map +1 -1
  74. package/dist/feedback/feedback-attachment.d.ts +18 -2
  75. package/dist/feedback/feedback-context.d.ts +18 -2
  76. package/dist/feedback/feedback-crash.d.ts +18 -2
  77. package/dist/feedback/feedback-dialog.d.ts +18 -2
  78. package/dist/feedback/feedback-inbox.d.ts +18 -2
  79. package/dist/feedback/feedback-labels.d.ts +18 -2
  80. package/dist/feedback/feedback-menu.d.ts +18 -2
  81. package/dist/feedback/feedback-record.d.ts +18 -2
  82. package/dist/feedback/feedback-row-detail.d.ts +18 -2
  83. package/dist/feedback/feedback-status-undo.d.ts +18 -2
  84. package/dist/feedback/feedback-submit.d.ts +18 -2
  85. package/dist/feedback/feedback-swipe.d.ts +18 -2
  86. package/dist/feedback/feedback-table.d.ts +18 -2
  87. package/dist/feedback/feedback-thread.d.ts +18 -2
  88. package/dist/feedback.d.ts +18 -2
  89. package/dist/hooks/use-file-drop.d.ts +18 -2
  90. package/dist/i18n/defaults.d.ts +18 -2
  91. package/dist/i18n/defaults.js +18 -0
  92. package/dist/i18n/defaults.js.map +1 -1
  93. package/dist/i18n/german.d.ts +18 -2
  94. package/dist/i18n/german.js +145 -0
  95. package/dist/i18n/german.js.map +1 -1
  96. package/dist/i18n/kit-labels.d.ts +18 -2
  97. package/dist/i18n/kit-labels.js.map +1 -1
  98. package/dist/i18n/languages.d.ts +13 -201
  99. package/dist/i18n/locales/de-CH.d.ts +18 -2
  100. package/dist/i18n/locales/en.d.ts +18 -2
  101. package/dist/i18n/locales/es.d.ts +18 -2
  102. package/dist/i18n/locales/es.js +147 -3
  103. package/dist/i18n/locales/es.js.map +1 -1
  104. package/dist/i18n/locales/fr.d.ts +18 -2
  105. package/dist/i18n/locales/fr.js +147 -0
  106. package/dist/i18n/locales/fr.js.map +1 -1
  107. package/dist/i18n/locales/hu.d.ts +18 -2
  108. package/dist/i18n/locales/hu.js +149 -3
  109. package/dist/i18n/locales/hu.js.map +1 -1
  110. package/dist/i18n/locales/it.d.ts +18 -2
  111. package/dist/i18n/locales/it.js +146 -1
  112. package/dist/i18n/locales/it.js.map +1 -1
  113. package/dist/i18n/locales/zh.d.ts +18 -2
  114. package/dist/i18n/locales/zh.js +146 -1
  115. package/dist/i18n/locales/zh.js.map +1 -1
  116. package/dist/i18n/review.d.ts +18 -2
  117. package/dist/i18n/review.js +17 -7
  118. package/dist/i18n/review.js.map +1 -1
  119. package/dist/index.d.ts +13 -2
  120. package/dist/index.js +49 -1
  121. package/dist/index.js.map +1 -1
  122. package/dist/lib/person-name.d.ts +69 -0
  123. package/dist/lib/person-name.js +65 -0
  124. package/dist/lib/person-name.js.map +1 -0
  125. package/dist/{kit-labels-SBN0biPl.d.ts → register-form-V1OeNlMr.d.ts} +423 -6
  126. package/dist/rhf/fields.d.ts +18 -2
  127. package/dist/rhf/form.d.ts +18 -2
  128. package/dist/rhf.d.ts +18 -2
  129. package/dist/shell/app-shell.d.ts +18 -2
  130. package/dist/shell/company-switcher.d.ts +59 -0
  131. package/dist/shell/company-switcher.js +85 -0
  132. package/dist/shell/company-switcher.js.map +1 -0
  133. package/dist/shell/top-bar-brand.d.ts +18 -2
  134. package/dist/shell/topbar-action-menu.d.ts +1 -0
  135. package/dist/shell.d.ts +12 -2
  136. package/dist/wizard/stepper-nav.d.ts +18 -2
  137. package/dist/wizard.d.ts +18 -2
  138. package/package.json +1 -1
  139. package/src/auth/accept-invitation.tsx +227 -0
  140. package/src/auth/auth-errors.ts +105 -0
  141. package/src/auth/complete-name-dialog.tsx +253 -0
  142. package/src/auth/email-tag.ts +75 -0
  143. package/src/auth/forgot-password-form.tsx +213 -0
  144. package/src/auth/form-rules.ts +40 -0
  145. package/src/auth/new-password-fields.tsx +85 -0
  146. package/src/auth/not-found-page.tsx +98 -0
  147. package/src/auth/register-form.tsx +459 -0
  148. package/src/auth/reset-password-form.tsx +337 -0
  149. package/src/auth/sign-in-form.tsx +687 -0
  150. package/src/auth/status-parts.tsx +138 -0
  151. package/src/auth/verify-email.tsx +358 -0
  152. package/src/components/legal-page.tsx +35 -0
  153. package/src/components/legal.tsx +93 -7
  154. package/src/components/user-avatar.tsx +22 -4
  155. package/src/i18n/defaults.ts +18 -0
  156. package/src/i18n/german.ts +153 -0
  157. package/src/i18n/kit-labels.tsx +27 -0
  158. package/src/i18n/locales/es.ts +156 -3
  159. package/src/i18n/locales/fr.ts +157 -0
  160. package/src/i18n/locales/hu.ts +159 -3
  161. package/src/i18n/locales/it.ts +154 -1
  162. package/src/i18n/locales/zh.ts +149 -1
  163. package/src/i18n/review.ts +15 -6
  164. package/src/index.ts +63 -1
  165. package/src/lib/person-name.ts +157 -0
  166. package/src/shell/company-switcher.tsx +140 -0
@@ -0,0 +1,54 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { PasswordStrengthMeter } from "../components/password-strength.js";
4
+ import { Input } from "../components/ui.js";
5
+ import { PASSWORD_MAX_BYTES, PASSWORD_MIN_LENGTH } from "./form-rules.js";
6
+ function NewPasswordFields({
7
+ password,
8
+ confirm,
9
+ onPasswordChange,
10
+ onConfirmChange,
11
+ text,
12
+ busy = false,
13
+ passwordRef
14
+ }) {
15
+ const mismatch = confirm !== "" && confirm !== password;
16
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
17
+ /* @__PURE__ */ jsxs("div", { children: [
18
+ /* @__PURE__ */ jsx(
19
+ Input,
20
+ {
21
+ ref: passwordRef,
22
+ type: "password",
23
+ name: "new-password",
24
+ autoComplete: "new-password",
25
+ label: text.password,
26
+ value: password,
27
+ onChange: (e) => onPasswordChange(e.target.value),
28
+ minLength: PASSWORD_MIN_LENGTH,
29
+ readOnly: busy,
30
+ required: true
31
+ }
32
+ ),
33
+ /* @__PURE__ */ jsx(PasswordStrengthMeter, { value: password, minLength: PASSWORD_MIN_LENGTH, maxBytes: PASSWORD_MAX_BYTES })
34
+ ] }),
35
+ /* @__PURE__ */ jsx(
36
+ Input,
37
+ {
38
+ type: "password",
39
+ name: "confirm-password",
40
+ autoComplete: "new-password",
41
+ label: text.confirm,
42
+ value: confirm,
43
+ onChange: (e) => onConfirmChange(e.target.value),
44
+ readOnly: busy,
45
+ error: mismatch ? text.mismatch : void 0,
46
+ required: true
47
+ }
48
+ )
49
+ ] });
50
+ }
51
+ export {
52
+ NewPasswordFields
53
+ };
54
+ //# sourceMappingURL=new-password-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/auth/new-password-fields.tsx"],"sourcesContent":["import type { ReactNode, Ref } from \"react\";\nimport { PasswordStrengthMeter } from \"../components/password-strength\";\nimport { Input } from \"../components/ui\";\nimport { PASSWORD_MAX_BYTES, PASSWORD_MIN_LENGTH } from \"./form-rules\";\n\n/** @internal The words the fields show — the host form's own labels. */\nexport interface NewPasswordFieldsText {\n password: ReactNode;\n confirm: ReactNode;\n mismatch: ReactNode;\n}\n\n/** @internal */\nexport interface NewPasswordFieldsProps {\n password: string;\n confirm: string;\n onPasswordChange: (value: string) => void;\n onConfirmChange: (value: string) => void;\n text: NewPasswordFieldsText;\n /** A request is running: both fields `readOnly` (not `disabled`, which would drop\n * the focus of the one being typed in). */\n busy?: boolean;\n passwordRef?: Ref<HTMLInputElement>;\n}\n\n/**\n * \"Choose a password\": the field, the strength meter with its advisory checklist, and\n * the confirmation — keksdose's `PasswordFields`, which its register form, its reset\n * page and its forced-change step share so that every screen choosing a password does\n * it under the same rules and the same feedback. Here `RegisterForm` and\n * `SignInForm`'s set-a-new-password step share it.\n *\n * Both fields are `new-password`: a password manager offers to generate one and never\n * fills in the current one. The confirmation carries the mismatch as its own `error`,\n * attached with `aria-describedby`; the key is always passed, so the message coming and\n * going never remounts the field under the typist.\n *\n * @internal Not part of the barrel; the forms are.\n */\nexport function NewPasswordFields({\n password,\n confirm,\n onPasswordChange,\n onConfirmChange,\n text,\n busy = false,\n passwordRef,\n}: NewPasswordFieldsProps) {\n const mismatch = confirm !== \"\" && confirm !== password;\n return (\n <>\n <div>\n <Input\n ref={passwordRef}\n type=\"password\"\n name=\"new-password\"\n autoComplete=\"new-password\"\n label={text.password}\n value={password}\n onChange={(e) => onPasswordChange(e.target.value)}\n minLength={PASSWORD_MIN_LENGTH}\n readOnly={busy}\n required\n />\n {/* The 72-byte cap is passed because a SIGN-IN password has one (bcrypt); the\n minimum is passed rather than left to the meter's own default 8, so the two\n cannot drift apart. */}\n <PasswordStrengthMeter value={password} minLength={PASSWORD_MIN_LENGTH} maxBytes={PASSWORD_MAX_BYTES} />\n </div>\n {/* A typo'd password costs a reset mail — and under keksdose's end-to-end\n encryption, data (feedback #124) — so it is typed twice. */}\n <Input\n type=\"password\"\n name=\"confirm-password\"\n autoComplete=\"new-password\"\n label={text.confirm}\n value={confirm}\n onChange={(e) => onConfirmChange(e.target.value)}\n readOnly={busy}\n error={mismatch ? text.mismatch : undefined}\n required\n />\n </>\n );\n}\n"],"mappings":";AAkDI,mBAEI,KADF,YADF;AAjDJ,SAAS,6BAA6B;AACtC,SAAS,aAAa;AACtB,SAAS,oBAAoB,2BAA2B;AAoCjD,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AACF,GAA2B;AACzB,QAAM,WAAW,YAAY,MAAM,YAAY;AAC/C,SACE,iCACE;AAAA,yBAAC,SACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,KAAK;AAAA,UACL,MAAK;AAAA,UACL,MAAK;AAAA,UACL,cAAa;AAAA,UACb,OAAO,KAAK;AAAA,UACZ,OAAO;AAAA,UACP,UAAU,CAAC,MAAM,iBAAiB,EAAE,OAAO,KAAK;AAAA,UAChD,WAAW;AAAA,UACX,UAAU;AAAA,UACV,UAAQ;AAAA;AAAA,MACV;AAAA,MAIA,oBAAC,yBAAsB,OAAO,UAAU,WAAW,qBAAqB,UAAU,oBAAoB;AAAA,OACxG;AAAA,IAGA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,MAAK;AAAA,QACL,cAAa;AAAA,QACb,OAAO,KAAK;AAAA,QACZ,OAAO;AAAA,QACP,UAAU,CAAC,MAAM,gBAAgB,EAAE,OAAO,KAAK;AAAA,QAC/C,UAAU;AAAA,QACV,OAAO,WAAW,KAAK,WAAW;AAAA,QAClC,UAAQ;AAAA;AAAA,IACV;AAAA,KACF;AAEJ;","names":[]}
@@ -0,0 +1,57 @@
1
+ import * as react from 'react';
2
+ import { ComponentPropsWithoutRef, ReactNode } from 'react';
3
+ import { AuthHeadingLevel } from './status-parts.js';
4
+
5
+ /** Every string the page renders — the `notFound` namespace. keksdose's words
6
+ * (`error.not_found_*`), which kastlan took over. */
7
+ interface NotFoundLabels {
8
+ /** The heading. */
9
+ title: string;
10
+ /** Under it. */
11
+ body: string;
12
+ /** The way out for everyone — to `homeHref`. */
13
+ home: string;
14
+ /** The second way out for someone signed in — to `appHref`. */
15
+ app: string;
16
+ }
17
+ declare const DEFAULT_NOT_FOUND_LABELS: NotFoundLabels;
18
+ interface NotFoundPageProps extends Omit<ComponentPropsWithoutRef<"div">, "children" | "title"> {
19
+ /** "Go to the start page". Default `/`, which takes a signed-in user into the app and
20
+ * anyone else to sign-in in all three apps. */
21
+ homeHref?: string;
22
+ /**
23
+ * "Back to the app", beside it — pass it while someone is signed in. A LITERAL page
24
+ * (keksdose's `/budget`), never the "last visited page" an app restores on start: a
25
+ * stale one of those pointing at a route that is gone is the likeliest way a
26
+ * signed-in user lands here (keksdose's not-found-page.tsx).
27
+ */
28
+ appHref?: string;
29
+ /** App content under the text — a search field, a support address. */
30
+ children?: ReactNode;
31
+ /** `false` adds no `noindex` — for a preview inside another page. Default `true`. */
32
+ noIndex?: boolean;
33
+ /** The heading's level. Default `h2`, under `AuthLayout`'s `h1`; `h1` where the page
34
+ * stands alone (inside the app shell). */
35
+ headingAs?: AuthHeadingLevel;
36
+ labels?: Partial<NotFoundLabels>;
37
+ }
38
+ /**
39
+ * What an unknown address renders (the router's catch-all), signed out and signed in —
40
+ * keksdose's `NotFoundPage` (app/not-found-page.tsx, feedback #129), which kastlan took
41
+ * over on `AuthLayout` (docs/auth-harmonization.md §7).
42
+ *
43
+ * In place of the silent `<Navigate to="/">` keksdose had: bouncing every typo, dead link
44
+ * and fabricated URL to the start page is what Search Console reports as a soft 404, and
45
+ * it hid broken links. An SPA cannot send a real 404 status — the web server answers
46
+ * every path with index.html — so the page says it in words and calls
47
+ * {@link useNoIndex}, which makes a crawler drop it (the server's `X-Robots-Tag` is the
48
+ * authoritative half).
49
+ *
50
+ * It is the page's CONTENT, not a frame, so it sits in either: as `AuthLayout`'s child
51
+ * for a visitor (`headingAs` default `h2`, under the layout's title), or bare inside the
52
+ * app shell for someone signed in (`headingAs="h1"`, and `appHref`). The large "404" is
53
+ * decoration — the heading says it in words — and hidden from a screen reader.
54
+ */
55
+ declare function NotFoundPage({ homeHref, appHref, children, noIndex, headingAs: Heading, labels: labelsProp, className, ...rest }: NotFoundPageProps): react.JSX.Element;
56
+
57
+ export { DEFAULT_NOT_FOUND_LABELS, type NotFoundLabels, NotFoundPage, type NotFoundPageProps };
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { cn } from "../lib/cn.js";
4
+ import { useKitLabels } from "../i18n/kit-labels.js";
5
+ import { useNoIndex } from "../hooks/use-noindex.js";
6
+ import { Button } from "../components/ui.js";
7
+ const DEFAULT_NOT_FOUND_LABELS = {
8
+ title: "Page not found",
9
+ body: "This address doesn\u2019t exist (any more). It may be a typo, or the page has moved.",
10
+ home: "Go to the start page",
11
+ app: "Back to the app"
12
+ };
13
+ function NotFoundPage({
14
+ homeHref = "/",
15
+ appHref,
16
+ children,
17
+ noIndex = true,
18
+ headingAs: Heading = "h2",
19
+ labels: labelsProp,
20
+ className,
21
+ ...rest
22
+ }) {
23
+ const labels = useKitLabels("notFound", DEFAULT_NOT_FOUND_LABELS, labelsProp);
24
+ useNoIndex(noIndex);
25
+ return /* @__PURE__ */ jsxs("div", { ...rest, className: cn("flex flex-col items-center gap-2 py-4 text-center", className), children: [
26
+ /* @__PURE__ */ jsx("p", { "aria-hidden": true, className: "text-6xl font-bold leading-none tracking-tight text-[var(--text-placeholder)]", children: "404" }),
27
+ /* @__PURE__ */ jsx(Heading, { className: "mt-2 text-xl font-semibold text-[var(--text-primary)]", children: labels.title }),
28
+ /* @__PURE__ */ jsx("p", { className: "max-w-prose text-sm text-[var(--text-secondary)]", children: labels.body }),
29
+ children,
30
+ /* @__PURE__ */ jsxs("div", { className: "mt-4 flex flex-wrap justify-center gap-3", children: [
31
+ /* @__PURE__ */ jsx(Button, { href: homeHref, variant: "brand", children: labels.home }),
32
+ appHref !== void 0 && /* @__PURE__ */ jsx(Button, { href: appHref, variant: "secondary", children: labels.app })
33
+ ] })
34
+ ] });
35
+ }
36
+ export {
37
+ DEFAULT_NOT_FOUND_LABELS,
38
+ NotFoundPage
39
+ };
40
+ //# sourceMappingURL=not-found-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/auth/not-found-page.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { useNoIndex } from \"../hooks/use-noindex\";\nimport { Button } from \"../components/ui\";\nimport type { AuthHeadingLevel } from \"./status-parts\";\n\n/** Every string the page renders — the `notFound` namespace. keksdose's words\n * (`error.not_found_*`), which kastlan took over. */\nexport interface NotFoundLabels {\n /** The heading. */\n title: string;\n /** Under it. */\n body: string;\n /** The way out for everyone — to `homeHref`. */\n home: string;\n /** The second way out for someone signed in — to `appHref`. */\n app: string;\n}\n\nexport const DEFAULT_NOT_FOUND_LABELS: NotFoundLabels = {\n title: \"Page not found\",\n body: \"This address doesn’t exist (any more). It may be a typo, or the page has moved.\",\n home: \"Go to the start page\",\n app: \"Back to the app\",\n};\n\nexport interface NotFoundPageProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"title\"> {\n /** \"Go to the start page\". Default `/`, which takes a signed-in user into the app and\n * anyone else to sign-in in all three apps. */\n homeHref?: string;\n /**\n * \"Back to the app\", beside it — pass it while someone is signed in. A LITERAL page\n * (keksdose's `/budget`), never the \"last visited page\" an app restores on start: a\n * stale one of those pointing at a route that is gone is the likeliest way a\n * signed-in user lands here (keksdose's not-found-page.tsx).\n */\n appHref?: string;\n /** App content under the text — a search field, a support address. */\n children?: ReactNode;\n /** `false` adds no `noindex` — for a preview inside another page. Default `true`. */\n noIndex?: boolean;\n /** The heading's level. Default `h2`, under `AuthLayout`'s `h1`; `h1` where the page\n * stands alone (inside the app shell). */\n headingAs?: AuthHeadingLevel;\n labels?: Partial<NotFoundLabels>;\n}\n\n/**\n * What an unknown address renders (the router's catch-all), signed out and signed in —\n * keksdose's `NotFoundPage` (app/not-found-page.tsx, feedback #129), which kastlan took\n * over on `AuthLayout` (docs/auth-harmonization.md §7).\n *\n * In place of the silent `<Navigate to=\"/\">` keksdose had: bouncing every typo, dead link\n * and fabricated URL to the start page is what Search Console reports as a soft 404, and\n * it hid broken links. An SPA cannot send a real 404 status — the web server answers\n * every path with index.html — so the page says it in words and calls\n * {@link useNoIndex}, which makes a crawler drop it (the server's `X-Robots-Tag` is the\n * authoritative half).\n *\n * It is the page's CONTENT, not a frame, so it sits in either: as `AuthLayout`'s child\n * for a visitor (`headingAs` default `h2`, under the layout's title), or bare inside the\n * app shell for someone signed in (`headingAs=\"h1\"`, and `appHref`). The large \"404\" is\n * decoration — the heading says it in words — and hidden from a screen reader.\n */\nexport function NotFoundPage({\n homeHref = \"/\",\n appHref,\n children,\n noIndex = true,\n headingAs: Heading = \"h2\",\n labels: labelsProp,\n className,\n ...rest\n}: NotFoundPageProps) {\n const labels = useKitLabels(\"notFound\", DEFAULT_NOT_FOUND_LABELS, labelsProp);\n useNoIndex(noIndex);\n return (\n <div {...rest} className={cn(\"flex flex-col items-center gap-2 py-4 text-center\", className)}>\n <p aria-hidden className=\"text-6xl font-bold leading-none tracking-tight text-[var(--text-placeholder)]\">\n 404\n </p>\n <Heading className=\"mt-2 text-xl font-semibold text-[var(--text-primary)]\">{labels.title}</Heading>\n <p className=\"max-w-prose text-sm text-[var(--text-secondary)]\">{labels.body}</p>\n {children}\n <div className=\"mt-4 flex flex-wrap justify-center gap-3\">\n <Button href={homeHref} variant=\"brand\">\n {labels.home}\n </Button>\n {appHref !== undefined && (\n <Button href={appHref} variant=\"secondary\">\n {labels.app}\n </Button>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";AA+EM,cAMA,YANA;AA9EN,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAgBhB,MAAM,2BAA2C;AAAA,EACtD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AACP;AAwCO,SAAS,aAAa;AAAA,EAC3B,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,WAAW,UAAU;AAAA,EACrB,QAAQ;AAAA,EACR;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,QAAM,SAAS,aAAa,YAAY,0BAA0B,UAAU;AAC5E,aAAW,OAAO;AAClB,SACE,qBAAC,SAAK,GAAG,MAAM,WAAW,GAAG,qDAAqD,SAAS,GACzF;AAAA,wBAAC,OAAE,eAAW,MAAC,WAAU,iFAAgF,iBAEzG;AAAA,IACA,oBAAC,WAAQ,WAAU,yDAAyD,iBAAO,OAAM;AAAA,IACzF,oBAAC,OAAE,WAAU,oDAAoD,iBAAO,MAAK;AAAA,IAC5E;AAAA,IACD,qBAAC,SAAI,WAAU,4CACb;AAAA,0BAAC,UAAO,MAAM,UAAU,SAAQ,SAC7B,iBAAO,MACV;AAAA,MACC,YAAY,UACX,oBAAC,UAAO,MAAM,SAAS,SAAQ,aAC5B,iBAAO,KACV;AAAA,OAEJ;AAAA,KACF;AAEJ;","names":[]}
@@ -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,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