@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
package/README.md CHANGED
@@ -382,14 +382,14 @@ columns, strings and permissions (see the note at the top of `src/feedback/feedb
382
382
 
383
383
  <!-- BEGIN GENERATED: exports — node scripts/gen-export-inventory.mjs -->
384
384
 
385
- **1414 names from 206 modules** — 665 values and 749 types. _Italic_ is a type-only export.
385
+ **1478 names from 219 modules** — 692 values and 786 types. _Italic_ is a type-only export.
386
386
 
387
387
  Generated from `dist/index.d.ts` by `node scripts/gen-export-inventory.mjs`; the count
388
388
  is pinned by `src/__tests__/public-surface.test.ts`. Do not edit between the markers.
389
389
 
390
390
  | Entry point | Names |
391
391
  |---|---|
392
- | `@eifi1/ui-kit` | 1414 |
392
+ | `@eifi1/ui-kit` | 1478 |
393
393
  | `@eifi1/ui-kit/chart` | 104 |
394
394
  | `@eifi1/ui-kit/shell` | 24 |
395
395
  | `@eifi1/ui-kit/data-table` | 51 |
@@ -416,6 +416,7 @@ re-slicing of it, never a second API.
416
416
  | `lib/qr-encode` | `encodeQr`, _`QrEncodeOptions`_, _`QrErrorCorrection`_, _`QrMatrix`_ |
417
417
  | `lib/server-wake` | `attachServerWake`, `createServerWake`, `serverWake`, `watchReadsAnd`, `wrapFetch`, _`AxiosLikeInstance`_, _`ServerWakeAxiosConfig`_, _`ServerWakeFilter`_, _`ServerWakeOptions`_, _`ServerWakeRequest`_, _`ServerWakeStage`_, _`ServerWakeWatcher`_ |
418
418
  | `lib/translation-review` | `DEFAULT_TRANSLATION_REVIEW_FILTER`, `DEFAULT_TRANSLATION_REVIEW_SWIPE`, `dropReviews`, `filterTranslationRows`, `flattenStrings`, `fromApiReview`, `groupTranslationRows`, `keyInArea`, `keyInAreas`, `keyNamespace`, `mergeReviews`, `placeholderMismatch`, `placeholderTokens`, `REVIEW_STATUSES`, `reviewAreaOf`, `reviewStatus`, `reviewUndo`, `reviewWrite`, `summariseRows`, `toApiWrite`, `TRANSLATION_REVIEW_SWIPE_ACTIONS`, `translationCorrections`, `translationReviewSwipePlan`, `translationRows`, `unreviewedRows`, _`ApiTranslationReview`_, _`ApiTranslationReviewWrite`_, _`ReviewStatus`_, _`TranslationCorrection`_, _`TranslationReview`_, _`TranslationReviewFilter`_, _`TranslationReviewKey`_, _`TranslationReviewSwipeAction`_, _`TranslationReviewSwipeBinding`_, _`TranslationReviewUndo`_, _`TranslationReviewWrite`_, _`TranslationRow`_, _`TranslationRowGroup`_, _`TranslationRowsInput`_, _`TranslationSummary`_, _`TranslationVerdict`_ |
419
+ | `lib/person-name` | `formatPersonName`, `personInitials`, _`PersonName`_ |
419
420
  | `lib/countries` | `COUNTRY_CODES`, `countryName` |
420
421
  | `lib/iban` | `compactIban`, `formatIban`, `IBAN_LENGTHS`, `ibanCheckDigits`, `ibanProblem`, `isQrIban`, `isValidIban`, _`IbanKind`_, _`IbanProblem`_ |
421
422
  | `lib/isin` | `formatIsin`, `isinCheckDigit`, `isValidIsin` |
@@ -462,9 +463,9 @@ re-slicing of it, never a second API.
462
463
  | Module | Exports |
463
464
  |---|---|
464
465
  | `i18n/kit-labels` | `DEFAULT_APP_SHELL_LABELS`, `DEFAULT_CALCULATOR_LABELS`, `DEFAULT_COMBOBOX_LABELS`, `DEFAULT_COMMON_LABELS`, `DEFAULT_CURRENCY_LABELS`, `DEFAULT_DATE_PICKER_LABELS`, `DEFAULT_FILE_LABELS`, `DEFAULT_MULTI_SELECT_LABELS`, `DEFAULT_PICKER_SHEET_LABELS`, `DEFAULT_SWIPEABLE_ROW_LABELS`, `DEFAULT_TOP_BAR_LABELS`, `formatFileSize`, `missingKitLabels`, `UiKitProvider`, `useKitChartTooltipPlacement`, `useKitDateFormatter`, `useKitFileLabels`, `useKitLabelOverrides`, `useKitLabels`, `useKitLink`, `useKitLocale`, `useKitWeekStart`, _`AppShellLabels`_, _`CalculatorLabels`_, _`ChartTooltipPlacement`_, _`ComboboxLabels`_, _`CommonLabels`_, _`CurrencyLabels`_, _`DatePickerLabels`_, _`FileLabels`_, _`KitDateFormatContext`_, _`KitDateFormatter`_, _`KitLinkComponent`_, _`KitLinkProps`_, _`LabelOverride`_, _`MultiSelectLabels`_, _`PickerSheetLabels`_, _`SwipeableRowLabels`_, _`TopBarLabels`_, _`UiKitLabelOverrides`_, _`UiKitLabels`_, _`UiKitProviderProps`_ |
466
+ | `i18n/languages` | `formatLocaleOf`, `KIT_LANGUAGES`, `languageOptions`, `loadUiKitLabels`, `peekUiKitLabels`, `resolveLanguage`, `useUiKitLabels`, _`KitLanguage`_, _`KitLanguageCode`_ |
465
467
  | `i18n/defaults` | `DEFAULT_UI_KIT_LABELS` |
466
468
  | `i18n/review` | `kitLabelStrings`, _`KitLabelStringsOptions`_ |
467
- | `i18n/languages` | `formatLocaleOf`, `KIT_LANGUAGES`, `languageOptions`, `loadUiKitLabels`, `peekUiKitLabels`, `resolveLanguage`, `useUiKitLabels`, _`KitLanguage`_, _`KitLanguageCode`_ |
468
469
  | `i18n/plurals` | `withAllPlurals` |
469
470
 
470
471
  ### components
@@ -478,7 +479,7 @@ re-slicing of it, never a second API.
478
479
  | `components/file-button` | `DEFAULT_FILE_PICKER_LABELS`, `FileButton`, `matchesAccept`, `useFilePicker`, _`FileButtonProps`_, _`FilePickerLabels`_, _`FileRejection`_, _`FileRejectionReason`_, _`FileScreenOptions`_, _`UseFilePickerOptions`_, _`UseFilePickerReturn`_ |
479
480
  | `components/form-actions` | `DEFAULT_FORM_ACTIONS_LABELS`, `FormActions`, _`FormActionsAlign`_, _`FormActionsDestructive`_, _`FormActionsLabels`_, _`FormActionsPlacement`_, _`FormActionsProps`_, _`FormActionsStickyWithin`_, _`FormActionsSubmitProps`_, _`FormActionsSubmitShortcut`_, _`ResponsiveFormActionsPlacement`_ |
480
481
  | `components/iban-input` | `DEFAULT_IBAN_INPUT_LABELS`, `IbanInput`, _`IbanInputLabels`_, _`IbanInputProps`_ |
481
- | `components/legal` | `DEFAULT_LEGAL_LABELS`, `LegalFooter`, `LegalLayout`, `LegalLinks`, `LegalSection`, _`LegalFooterProps`_, _`LegalFramedSectionLabels`_, _`LegalLabels`_, _`LegalLayoutProps`_, _`LegalLink`_, _`LegalLinksProps`_, _`LegalOperator`_, _`LegalOperatorSectionLabels`_, _`LegalOperatorText`_, _`LegalPageKey`_, _`LegalSectionProps`_, _`LegalTextSectionLabels`_ |
482
+ | `components/legal` | `DEFAULT_LEGAL_LABELS`, `LEGAL_HREFS`, `LegalFooter`, `LegalLayout`, `LegalLinks`, `legalOperatorText`, `LegalSection`, `useLegalLabels`, _`LegalFooterProps`_, _`LegalFramedSectionLabels`_, _`LegalLabels`_, _`LegalLayoutProps`_, _`LegalLink`_, _`LegalLinksProps`_, _`LegalOperator`_, _`LegalOperatorSectionLabels`_, _`LegalOperatorText`_, _`LegalPageKey`_, _`LegalSectionProps`_, _`LegalTextSectionLabels`_ |
482
483
  | `components/phone-input` | `DEFAULT_PHONE_INPUT_LABELS`, `PhoneInput`, _`PhoneInputLabels`_, _`PhoneInputProps`_ |
483
484
  | `components/share-card` | `DEFAULT_SHARE_CARD_LABELS`, `ShareCard`, `ShareDialog`, `SharePanel`, _`ShareAddRequest`_, _`ShareCandidate`_, _`ShareCardLabels`_, _`ShareCardProps`_, _`ShareDialogProps`_, _`ShareGrantee`_, _`SharePanelProps`_, _`SharePendingGrant`_, _`ShareRole`_ |
484
485
  | `components/field` | `Field`, _`FieldControlProps`_, _`FieldLabelVisibility`_, _`FieldProps`_, _`FieldRenderMeta`_ |
@@ -621,6 +622,22 @@ re-slicing of it, never a second API.
621
622
  | `feedback/feedback-submit` | `useFeedbackSubmit`, _`FeedbackCreatePayload`_, _`FeedbackSubmit`_, _`UseFeedbackSubmitOptions`_ |
622
623
  | `feedback/feedback-crash` | `createCrashReporter`, _`CrashFiling`_, _`CrashReportCreate`_, _`CrashReporter`_, _`CrashReporterOptions`_, _`CrashReportResponse`_ |
623
624
 
625
+ ### auth
626
+
627
+ | Module | Exports |
628
+ |---|---|
629
+ | `auth/register-form` | `DEFAULT_REGISTER_LABELS`, `RegisterForm`, _`RegisterFormProps`_, _`RegisterLabels`_, _`RegisterValues`_ |
630
+ | `auth/sign-in-form` | `DEFAULT_SIGN_IN_LABELS`, `SignInForm`, _`SignInAction`_, _`SignInAnswer`_, _`SignInCodeValues`_, _`SignInCredentials`_, _`SignInFormProps`_, _`SignInLabels`_, _`SignInNewPasswordValues`_, _`SignInStep`_ |
631
+ | `auth/complete-name-dialog` | `CompleteNameDialog`, `DEFAULT_COMPLETE_NAME_LABELS`, _`CompleteNameDialogProps`_, _`CompleteNameLabels`_, _`CompleteNameValues`_ |
632
+ | `auth/email-tag` | `taggedEmail` |
633
+ | `auth/auth-errors` | `authErrorCode`, `isAuthError`, _`AuthErrorCode`_ |
634
+ | `auth/forgot-password-form` | `DEFAULT_FORGOT_PASSWORD_LABELS`, `ForgotPasswordForm`, _`ForgotPasswordFormProps`_, _`ForgotPasswordLabels`_ |
635
+ | `auth/reset-password-form` | `DEFAULT_RESET_PASSWORD_LABELS`, `ResetPasswordForm`, _`ResetPasswordCheck`_, _`ResetPasswordFormProps`_, _`ResetPasswordLabels`_, _`ResetPasswordResult`_, _`ResetPasswordValues`_ |
636
+ | `auth/verify-email` | `DEFAULT_VERIFY_EMAIL_LABELS`, `EmailVerificationBanner`, `VerifyEmailStatus`, _`EmailVerificationBannerProps`_, _`VerifyEmailFailure`_, _`VerifyEmailLabels`_, _`VerifyEmailStatusProps`_ |
637
+ | `auth/not-found-page` | `DEFAULT_NOT_FOUND_LABELS`, `NotFoundPage`, _`NotFoundLabels`_, _`NotFoundPageProps`_ |
638
+ | `auth/accept-invitation` | `AcceptInvitation`, `DEFAULT_ACCEPT_INVITATION_LABELS`, _`AcceptInvitationFailure`_, _`AcceptInvitationLabels`_, _`AcceptInvitationProps`_, _`AcceptInvitationResult`_ |
639
+ | `auth/status-parts` | _`AuthHeadingLevel`_ |
640
+
624
641
  ### shell
625
642
 
626
643
  | Module | Exports |
@@ -633,6 +650,7 @@ re-slicing of it, never a second API.
633
650
  | `shell/topbar-action-menu` | `TopBarActionMenu`, _`TopBarMenuEntry`_, _`TopBarMenuHeader`_ |
634
651
  | `shell/top-bar-brand` | `TopBarBrand`, _`TopBarBrandProps`_ |
635
652
  | `shell/auth-layout` | `AuthLayout`, _`AuthLayoutProps`_ |
653
+ | `shell/company-switcher` | `CompanySwitcher`, `DEFAULT_COMPANY_SWITCHER_LABELS`, _`CompanySwitcherCompany`_, _`CompanySwitcherLabels`_, _`CompanySwitcherProps`_ |
636
654
 
637
655
  ### wizard
638
656
 
@@ -0,0 +1,90 @@
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 `acceptInvitation` namespace. keksdose's words
6
+ * where its `/join` page has them (`budget_share.join*`). */
7
+ interface AcceptInvitationLabels {
8
+ /** The heading. */
9
+ title: string;
10
+ /** While the invitation is accepted. */
11
+ accepting: string;
12
+ /** Accepted, when the app did not say into what. */
13
+ accepted: string;
14
+ /** Accepted, given what it attached the account to — a company, a team, a budget. */
15
+ joined: (name: string) => string;
16
+ /** Into the app, from every outcome but "sign in first". */
17
+ continue: string;
18
+ /** The token is unknown, spent, or for another address. */
19
+ invalid: string;
20
+ expired: string;
21
+ /** The page was opened without a `token`. */
22
+ noToken: string;
23
+ /** Under `invalid` and `expired`: an invitation is re-sent as a new one (§4.4). */
24
+ askAgain: string;
25
+ /** Nobody is signed in: an existing account accepts after sign-in (§4.4). */
26
+ signInFirst: string;
27
+ /** Under it. */
28
+ signInHint: string;
29
+ signIn: string;
30
+ /** Beside "Sign in", with `registerHref`. */
31
+ register: string;
32
+ }
33
+ declare const DEFAULT_ACCEPT_INVITATION_LABELS: AcceptInvitationLabels;
34
+ /** What `onAccept` may resolve with. */
35
+ interface AcceptInvitationResult {
36
+ /** What the invitation attached the account to, by name — "Example Property Ltd",
37
+ * "Team North", a budget. Said in the confirmation. */
38
+ name?: string;
39
+ }
40
+ /** What became of an invitation that was not accepted. `signIn`: the server wants a
41
+ * session first (a `401`), which `signedIn` did not know about. */
42
+ type AcceptInvitationFailure = "invalid" | "expired" | "signIn";
43
+ interface AcceptInvitationProps extends Omit<ComponentPropsWithoutRef<"div">, "children" | "title"> {
44
+ /** The invitation's token — the app's `?invite=` / `?token=`. Empty: the link was cut
45
+ * short, and the page says so without asking anyone. */
46
+ token: string;
47
+ /** Someone is signed in on this device. Until then the page asks for a sign-in and
48
+ * sends nothing: accepting attaches the invitation to the SIGNED-IN account. */
49
+ signedIn: boolean;
50
+ /**
51
+ * Accept it — `POST /auth/invitations/accept {token}`, once per token, as soon as
52
+ * someone is signed in. Resolve (with what it attached the account to, if the app
53
+ * knows); reject with the client's error.
54
+ */
55
+ onAccept: (token: string) => Promise<AcceptInvitationResult | void | undefined>;
56
+ /** Which dead end a rejection is. Default: `invitation_expired` is `expired`,
57
+ * anything else `invalid` (§5.2's codes). Map a `401` to `signIn` here. */
58
+ classifyError?: (error: unknown) => AcceptInvitationFailure;
59
+ /** "Continue" — into the app. Default `/`. */
60
+ continueHref?: string;
61
+ /** "Sign in" — the app's `/login`, with a way back here (`?next=…`). Default
62
+ * `/login`. */
63
+ signInHref?: string;
64
+ /** "Create account" beside "Sign in", for an invitation that may lead to a new
65
+ * account — the app's `/register?invite=…`. Left out, none. */
66
+ registerHref?: string;
67
+ /** The heading. Default `labels.title`; `null` draws none, for a page that puts it in
68
+ * `AuthLayout`'s `title` instead. */
69
+ title?: ReactNode;
70
+ /** The heading's level. Default `h2`, under the page's `h1`. */
71
+ headingAs?: AuthHeadingLevel;
72
+ labels?: Partial<AcceptInvitationLabels>;
73
+ }
74
+ /**
75
+ * Accept an invitation with an EXISTING account (docs/auth-harmonization.md §4.4): the
76
+ * link leads here, the person signs in if they are not, and the app attaches the
77
+ * invitation — a kastlan user joining a second company, a Kurvenschmiede member a team,
78
+ * a keksdose user a shared budget. A new address never needs this page: its link opens
79
+ * the sign-up form, which spends the invitation itself.
80
+ *
81
+ * keksdose's `JoinSharePage` (features/budgets/join-page.tsx) is the model: it accepts
82
+ * on load, once (the token is single-use, and StrictMode's double effect would send it
83
+ * twice), and shows the outcome where its spinner was. The outcomes: accepted, with the
84
+ * way into the app; not valid; expired (both say to ask for a new invitation, since
85
+ * "resend" mints a new token); or "sign in first", with nothing sent. "Continue" REPLACES
86
+ * this page in the history: the token is spent, so Back must not land here again.
87
+ */
88
+ declare function AcceptInvitation({ token, signedIn, onAccept, classifyError, continueHref, signInHref, registerHref, title, headingAs: Heading, labels: labelsProp, className, ...rest }: AcceptInvitationProps): react.JSX.Element;
89
+
90
+ export { AcceptInvitation, type AcceptInvitationFailure, type AcceptInvitationLabels, type AcceptInvitationProps, type AcceptInvitationResult, DEFAULT_ACCEPT_INVITATION_LABELS };
@@ -0,0 +1,117 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { CheckCircle2, LogIn, TimerOff, XCircle } from "lucide-react";
5
+ import { cn } from "../lib/cn.js";
6
+ import { useKitLabels } from "../i18n/kit-labels.js";
7
+ import { useAnnounce } from "../hooks/use-announce.js";
8
+ import { LoadingState } from "../components/loading-state.js";
9
+ import { Button, EmptyState } from "../components/ui.js";
10
+ import { authErrorCode } from "./auth-errors.js";
11
+ import { OUTCOME_CLASS, STATUS_HEADING_CLASS, useOncePerKey } from "./status-parts.js";
12
+ const DEFAULT_ACCEPT_INVITATION_LABELS = {
13
+ title: "Accept invitation",
14
+ accepting: "Joining\u2026",
15
+ accepted: "Invitation accepted.",
16
+ joined: (name) => `You\u2019ve joined ${name}.`,
17
+ continue: "Continue",
18
+ invalid: "Could not join with this link",
19
+ expired: "This invitation has expired",
20
+ noToken: "This link is missing its invite token.",
21
+ askAgain: "Ask the person who invited you to send a new invitation.",
22
+ signInFirst: "Sign in to accept this invitation",
23
+ signInHint: "Use the account the invitation was sent to.",
24
+ signIn: "Sign in",
25
+ register: "Create account"
26
+ };
27
+ function AcceptInvitation({
28
+ token,
29
+ signedIn,
30
+ onAccept,
31
+ classifyError,
32
+ continueHref = "/",
33
+ signInHref = "/login",
34
+ registerHref,
35
+ title,
36
+ headingAs: Heading = "h2",
37
+ labels: labelsProp,
38
+ className,
39
+ ...rest
40
+ }) {
41
+ const labels = useKitLabels("acceptInvitation", DEFAULT_ACCEPT_INVITATION_LABELS, labelsProp);
42
+ const [settled, setSettled] = useState(null);
43
+ const { announce, regionProps } = useAnnounce();
44
+ useOncePerKey(token !== "" && signedIn ? token : null, onAccept, (key, result) => {
45
+ if (result.ok) {
46
+ const name = result.value?.name?.trim() || void 0;
47
+ setSettled({ token: key, outcome: "accepted", name });
48
+ announce(name ? labels.joined(name) : labels.accepted);
49
+ return;
50
+ }
51
+ const failure = classifyError?.(result.error) ?? (authErrorCode(result.error) === "invitation_expired" ? "expired" : "invalid");
52
+ setSettled({ token: key, outcome: failure });
53
+ announce(failure === "signIn" ? labels.signInFirst : labels[failure]);
54
+ });
55
+ const outcome = token === "" ? "invalid" : settled?.token === token ? settled.outcome : signedIn ? "accepting" : "signIn";
56
+ const continueButton = (variant) => /* @__PURE__ */ jsx(Button, { href: continueHref, replace: true, variant, children: labels.continue });
57
+ let body;
58
+ if (outcome === "accepting") {
59
+ body = /* @__PURE__ */ jsx(LoadingState, { size: "sm", label: labels.accepting });
60
+ } else if (outcome === "accepted") {
61
+ body = /* @__PURE__ */ jsx(
62
+ EmptyState,
63
+ {
64
+ tone: "success",
65
+ icon: /* @__PURE__ */ jsx(CheckCircle2, {}),
66
+ title: settled?.name ? labels.joined(settled.name) : labels.accepted,
67
+ action: continueButton("brand"),
68
+ className: OUTCOME_CLASS
69
+ }
70
+ );
71
+ } else if (outcome === "signIn") {
72
+ body = /* @__PURE__ */ jsx(
73
+ EmptyState,
74
+ {
75
+ icon: /* @__PURE__ */ jsx(LogIn, {}),
76
+ title: labels.signInFirst,
77
+ hint: labels.signInHint,
78
+ action: /* @__PURE__ */ jsxs(Fragment, { children: [
79
+ /* @__PURE__ */ jsx(Button, { href: signInHref, variant: "brand", children: labels.signIn }),
80
+ registerHref !== void 0 && /* @__PURE__ */ jsx(Button, { href: registerHref, variant: "secondary", children: labels.register })
81
+ ] }),
82
+ className: OUTCOME_CLASS
83
+ }
84
+ );
85
+ } else {
86
+ body = /* @__PURE__ */ jsx(
87
+ EmptyState,
88
+ {
89
+ tone: "danger",
90
+ icon: outcome === "expired" ? /* @__PURE__ */ jsx(TimerOff, {}) : /* @__PURE__ */ jsx(XCircle, {}),
91
+ title: token === "" ? labels.noToken : labels[outcome],
92
+ hint: labels.askAgain,
93
+ action: signedIn ? continueButton("secondary") : void 0,
94
+ className: OUTCOME_CLASS
95
+ }
96
+ );
97
+ }
98
+ return /* @__PURE__ */ jsxs(
99
+ "div",
100
+ {
101
+ ...rest,
102
+ "data-state": outcome,
103
+ "aria-busy": outcome === "accepting" || void 0,
104
+ className: cn("space-y-3", className),
105
+ children: [
106
+ title === null ? null : /* @__PURE__ */ jsx(Heading, { className: STATUS_HEADING_CLASS, children: title ?? labels.title }),
107
+ body,
108
+ /* @__PURE__ */ jsx("div", { ...regionProps })
109
+ ]
110
+ }
111
+ );
112
+ }
113
+ export {
114
+ AcceptInvitation,
115
+ DEFAULT_ACCEPT_INVITATION_LABELS
116
+ };
117
+ //# sourceMappingURL=accept-invitation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/auth/accept-invitation.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { CheckCircle2, LogIn, TimerOff, XCircle } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { LoadingState } from \"../components/loading-state\";\nimport { Button, EmptyState } from \"../components/ui\";\nimport { authErrorCode } from \"./auth-errors\";\nimport { OUTCOME_CLASS, STATUS_HEADING_CLASS, useOncePerKey } from \"./status-parts\";\nimport type { AuthHeadingLevel } from \"./status-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the page renders — the `acceptInvitation` namespace. keksdose's words\n * where its `/join` page has them (`budget_share.join*`). */\nexport interface AcceptInvitationLabels {\n /** The heading. */\n title: string;\n /** While the invitation is accepted. */\n accepting: string;\n /** Accepted, when the app did not say into what. */\n accepted: string;\n /** Accepted, given what it attached the account to — a company, a team, a budget. */\n joined: (name: string) => string;\n /** Into the app, from every outcome but \"sign in first\". */\n continue: string;\n /** The token is unknown, spent, or for another address. */\n invalid: string;\n expired: string;\n /** The page was opened without a `token`. */\n noToken: string;\n /** Under `invalid` and `expired`: an invitation is re-sent as a new one (§4.4). */\n askAgain: string;\n /** Nobody is signed in: an existing account accepts after sign-in (§4.4). */\n signInFirst: string;\n /** Under it. */\n signInHint: string;\n signIn: string;\n /** Beside \"Sign in\", with `registerHref`. */\n register: string;\n}\n\nexport const DEFAULT_ACCEPT_INVITATION_LABELS: AcceptInvitationLabels = {\n title: \"Accept invitation\",\n accepting: \"Joining…\",\n accepted: \"Invitation accepted.\",\n joined: (name) => `You’ve joined ${name}.`,\n continue: \"Continue\",\n invalid: \"Could not join with this link\",\n expired: \"This invitation has expired\",\n noToken: \"This link is missing its invite token.\",\n askAgain: \"Ask the person who invited you to send a new invitation.\",\n signInFirst: \"Sign in to accept this invitation\",\n signInHint: \"Use the account the invitation was sent to.\",\n signIn: \"Sign in\",\n register: \"Create account\",\n};\n\n/* ── Types ───────────────────────────────────────────────────────────────── */\n\n/** What `onAccept` may resolve with. */\nexport interface AcceptInvitationResult {\n /** What the invitation attached the account to, by name — \"Example Property Ltd\",\n * \"Team North\", a budget. Said in the confirmation. */\n name?: string;\n}\n\n/** What became of an invitation that was not accepted. `signIn`: the server wants a\n * session first (a `401`), which `signedIn` did not know about. */\nexport type AcceptInvitationFailure = \"invalid\" | \"expired\" | \"signIn\";\n\ntype Outcome = \"accepted\" | AcceptInvitationFailure;\n\nexport interface AcceptInvitationProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"title\"> {\n /** The invitation's token — the app's `?invite=` / `?token=`. Empty: the link was cut\n * short, and the page says so without asking anyone. */\n token: string;\n /** Someone is signed in on this device. Until then the page asks for a sign-in and\n * sends nothing: accepting attaches the invitation to the SIGNED-IN account. */\n signedIn: boolean;\n /**\n * Accept it — `POST /auth/invitations/accept {token}`, once per token, as soon as\n * someone is signed in. Resolve (with what it attached the account to, if the app\n * knows); reject with the client's error.\n */\n onAccept: (token: string) => Promise<AcceptInvitationResult | void | undefined>;\n /** Which dead end a rejection is. Default: `invitation_expired` is `expired`,\n * anything else `invalid` (§5.2's codes). Map a `401` to `signIn` here. */\n classifyError?: (error: unknown) => AcceptInvitationFailure;\n /** \"Continue\" — into the app. Default `/`. */\n continueHref?: string;\n /** \"Sign in\" — the app's `/login`, with a way back here (`?next=…`). Default\n * `/login`. */\n signInHref?: string;\n /** \"Create account\" beside \"Sign in\", for an invitation that may lead to a new\n * account — the app's `/register?invite=…`. Left out, none. */\n registerHref?: string;\n /** The heading. Default `labels.title`; `null` draws none, for a page that puts it in\n * `AuthLayout`'s `title` instead. */\n title?: ReactNode;\n /** The heading's level. Default `h2`, under the page's `h1`. */\n headingAs?: AuthHeadingLevel;\n labels?: Partial<AcceptInvitationLabels>;\n}\n\n/**\n * Accept an invitation with an EXISTING account (docs/auth-harmonization.md §4.4): the\n * link leads here, the person signs in if they are not, and the app attaches the\n * invitation — a kastlan user joining a second company, a Kurvenschmiede member a team,\n * a keksdose user a shared budget. A new address never needs this page: its link opens\n * the sign-up form, which spends the invitation itself.\n *\n * keksdose's `JoinSharePage` (features/budgets/join-page.tsx) is the model: it accepts\n * on load, once (the token is single-use, and StrictMode's double effect would send it\n * twice), and shows the outcome where its spinner was. The outcomes: accepted, with the\n * way into the app; not valid; expired (both say to ask for a new invitation, since\n * \"resend\" mints a new token); or \"sign in first\", with nothing sent. \"Continue\" REPLACES\n * this page in the history: the token is spent, so Back must not land here again.\n */\nexport function AcceptInvitation({\n token,\n signedIn,\n onAccept,\n classifyError,\n continueHref = \"/\",\n signInHref = \"/login\",\n registerHref,\n title,\n headingAs: Heading = \"h2\",\n labels: labelsProp,\n className,\n ...rest\n}: AcceptInvitationProps) {\n const labels = useKitLabels(\"acceptInvitation\", DEFAULT_ACCEPT_INVITATION_LABELS, labelsProp);\n const [settled, setSettled] = useState<{ token: string; outcome: Outcome; name?: string } | null>(null);\n const { announce, regionProps } = useAnnounce();\n\n useOncePerKey(token !== \"\" && signedIn ? token : null, onAccept, (key, result) => {\n if (result.ok) {\n const name = result.value?.name?.trim() || undefined;\n setSettled({ token: key, outcome: \"accepted\", name });\n announce(name ? labels.joined(name) : labels.accepted);\n return;\n }\n const failure: AcceptInvitationFailure =\n classifyError?.(result.error) ?? (authErrorCode(result.error) === \"invitation_expired\" ? \"expired\" : \"invalid\");\n setSettled({ token: key, outcome: failure });\n announce(failure === \"signIn\" ? labels.signInFirst : labels[failure]);\n });\n\n const outcome: Outcome | \"accepting\" =\n token === \"\"\n ? \"invalid\"\n : settled?.token === token\n ? settled.outcome\n : signedIn\n ? \"accepting\"\n : \"signIn\";\n\n const continueButton = (variant: \"brand\" | \"secondary\") => (\n <Button href={continueHref} replace variant={variant}>\n {labels.continue}\n </Button>\n );\n\n let body: ReactNode;\n if (outcome === \"accepting\") {\n body = <LoadingState size=\"sm\" label={labels.accepting} />;\n } else if (outcome === \"accepted\") {\n body = (\n <EmptyState\n tone=\"success\"\n icon={<CheckCircle2 />}\n title={settled?.name ? labels.joined(settled.name) : labels.accepted}\n action={continueButton(\"brand\")}\n className={OUTCOME_CLASS}\n />\n );\n } else if (outcome === \"signIn\") {\n body = (\n <EmptyState\n icon={<LogIn />}\n title={labels.signInFirst}\n hint={labels.signInHint}\n action={\n <>\n <Button href={signInHref} variant=\"brand\">\n {labels.signIn}\n </Button>\n {registerHref !== undefined && (\n <Button href={registerHref} variant=\"secondary\">\n {labels.register}\n </Button>\n )}\n </>\n }\n className={OUTCOME_CLASS}\n />\n );\n } else {\n body = (\n <EmptyState\n tone=\"danger\"\n icon={outcome === \"expired\" ? <TimerOff /> : <XCircle />}\n title={token === \"\" ? labels.noToken : labels[outcome]}\n hint={labels.askAgain}\n action={signedIn ? continueButton(\"secondary\") : undefined}\n className={OUTCOME_CLASS}\n />\n );\n }\n\n return (\n <div\n {...rest}\n data-state={outcome}\n aria-busy={outcome === \"accepting\" || undefined}\n className={cn(\"space-y-3\", className)}\n >\n {title === null ? null : <Heading className={STATUS_HEADING_CLASS}>{title ?? labels.title}</Heading>}\n {body}\n {/* Rendered from the start, so the outcome is read when it arrives. */}\n <div {...regionProps} />\n </div>\n );\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The coded refusals of sign-in and sign-up (docs/auth-harmonization.md §5.2): every
3
+ * refusal the auth routes answer carries a machine-readable `code`, and the pages
4
+ * recognise the CODE, never the server's sentence.
5
+ *
6
+ * Today each app's pages print the server's `detail` string (keksdose's
7
+ * `extractApiErrorMessage`), which is English on every locale and, on a credential
8
+ * check, would be an account-enumeration oracle if it ever said more than one thing.
9
+ * keksdose already keys one refusal on a code (`features/budgets/plan-limit.ts`,
10
+ * `402 {detail, code: "plan_budget_limit"}`); §5.2 makes that the rule for auth. Each
11
+ * app switches its server and its pages together (§9).
12
+ *
13
+ * - `invalid_credentials` — unknown address, wrong password AND deactivated account:
14
+ * one answer, in the same time (§2.10). `401`.
15
+ * - `registration_closed` — the sign-up gate refused the address. `403`.
16
+ * - `email_taken` — an account with this address exists. `409`.
17
+ * - `invitation_invalid`, `invitation_expired` — the `invite` token of a sign-up or an
18
+ * accept (§4.4).
19
+ * - `token_invalid` — a one-time token (reset, verification, a sign-in challenge) is
20
+ * unknown, spent or expired.
21
+ * - `account_inactive` — **no server answers it.** §2.10 decided that a deactivated
22
+ * account gets `invalid_credentials`, because a separate answer after a correct
23
+ * password would confirm a leaked one. It stays in the union only for a future server
24
+ * step that is past the password (an admin view, a signed-in refresh) and may say so.
25
+ */
26
+ type AuthErrorCode = "invalid_credentials" | "registration_closed" | "email_taken" | "invitation_invalid" | "invitation_expired" | "token_invalid" | "account_inactive";
27
+ /**
28
+ * The {@link AuthErrorCode} an error carries, or `undefined` when it carries none.
29
+ *
30
+ * Reads the parsed response body wherever the apps' HTTP clients put it, without
31
+ * depending on any of them:
32
+ *
33
+ * 1. `err.response.data` — axios (keksdose's, kastlan's and Kurvenschmiede's clients;
34
+ * keksdose's `isPlanBudgetLimitRefusal` reads the same path);
35
+ * 2. `err.data` — ofetch's `FetchError`, and most `fetch` wrappers that parse the body;
36
+ * 3. `err.body` — the generated OpenAPI clients' `ApiError`;
37
+ * 4. `err` itself — a body thrown as it came (`throw await res.json()`).
38
+ *
39
+ * In each, `code` or FastAPI's nested `detail.code`. Last, `err.code` — but only when
40
+ * it is one of the codes above: axios writes its OWN codes there (`ERR_NETWORK`,
41
+ * `ECONNABORTED`, `ERR_BAD_REQUEST`), and so does Node, so an unknown value is never
42
+ * read as a refusal. The HTTP status is not checked: the code is the contract, and the
43
+ * status differs per refusal (401, 403, 409, 410).
44
+ */
45
+ declare function authErrorCode(err: unknown): AuthErrorCode | undefined;
46
+ /**
47
+ * Whether `err` is a coded auth refusal — any of them, or the one named:
48
+ *
49
+ * ```ts
50
+ * try { await api.register(values) }
51
+ * catch (err) { if (isAuthError(err, "email_taken")) … }
52
+ * ```
53
+ *
54
+ * The kit's `SignInForm` and `RegisterForm` call it on what their callbacks reject
55
+ * with, so an app's `onSubmit` can simply let its client's error through. See
56
+ * {@link authErrorCode} for the shapes it reads.
57
+ */
58
+ declare function isAuthError(err: unknown, code?: AuthErrorCode): boolean;
59
+
60
+ export { type AuthErrorCode, authErrorCode, isAuthError };
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ const CODES = /* @__PURE__ */ new Set([
3
+ "invalid_credentials",
4
+ "registration_closed",
5
+ "email_taken",
6
+ "invitation_invalid",
7
+ "invitation_expired",
8
+ "token_invalid",
9
+ "account_inactive"
10
+ ]);
11
+ const isBag = (value) => typeof value === "object" && value !== null;
12
+ function known(value) {
13
+ return typeof value === "string" && CODES.has(value) ? value : void 0;
14
+ }
15
+ function codeOfBody(body) {
16
+ if (!isBag(body)) return void 0;
17
+ return known(body.code) ?? (isBag(body.detail) ? known(body.detail.code) : void 0);
18
+ }
19
+ function authErrorCode(err) {
20
+ if (!isBag(err)) return void 0;
21
+ const response = err.response;
22
+ return (isBag(response) ? codeOfBody(response.data) : void 0) ?? codeOfBody(err.data) ?? codeOfBody(err.body) ?? codeOfBody(err);
23
+ }
24
+ function isAuthError(err, code) {
25
+ const found = authErrorCode(err);
26
+ return found !== void 0 && (code === void 0 || found === code);
27
+ }
28
+ export {
29
+ authErrorCode,
30
+ isAuthError
31
+ };
32
+ //# sourceMappingURL=auth-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/auth/auth-errors.ts"],"sourcesContent":["/**\n * The coded refusals of sign-in and sign-up (docs/auth-harmonization.md §5.2): every\n * refusal the auth routes answer carries a machine-readable `code`, and the pages\n * recognise the CODE, never the server's sentence.\n *\n * Today each app's pages print the server's `detail` string (keksdose's\n * `extractApiErrorMessage`), which is English on every locale and, on a credential\n * check, would be an account-enumeration oracle if it ever said more than one thing.\n * keksdose already keys one refusal on a code (`features/budgets/plan-limit.ts`,\n * `402 {detail, code: \"plan_budget_limit\"}`); §5.2 makes that the rule for auth. Each\n * app switches its server and its pages together (§9).\n *\n * - `invalid_credentials` — unknown address, wrong password AND deactivated account:\n * one answer, in the same time (§2.10). `401`.\n * - `registration_closed` — the sign-up gate refused the address. `403`.\n * - `email_taken` — an account with this address exists. `409`.\n * - `invitation_invalid`, `invitation_expired` — the `invite` token of a sign-up or an\n * accept (§4.4).\n * - `token_invalid` — a one-time token (reset, verification, a sign-in challenge) is\n * unknown, spent or expired.\n * - `account_inactive` — **no server answers it.** §2.10 decided that a deactivated\n * account gets `invalid_credentials`, because a separate answer after a correct\n * password would confirm a leaked one. It stays in the union only for a future server\n * step that is past the password (an admin view, a signed-in refresh) and may say so.\n */\nexport type AuthErrorCode =\n | \"invalid_credentials\"\n | \"registration_closed\"\n | \"email_taken\"\n | \"invitation_invalid\"\n | \"invitation_expired\"\n | \"token_invalid\"\n | \"account_inactive\";\n\nconst CODES: ReadonlySet<string> = new Set<AuthErrorCode>([\n \"invalid_credentials\",\n \"registration_closed\",\n \"email_taken\",\n \"invitation_invalid\",\n \"invitation_expired\",\n \"token_invalid\",\n \"account_inactive\",\n]);\n\ntype Bag = Record<string, unknown>;\n\nconst isBag = (value: unknown): value is Bag => typeof value === \"object\" && value !== null;\n\n/** A known code, or undefined. */\nfunction known(value: unknown): AuthErrorCode | undefined {\n return typeof value === \"string\" && CODES.has(value) ? (value as AuthErrorCode) : undefined;\n}\n\n/** `{code}` on a parsed body, or FastAPI's `{detail: {code}}` — what an\n * `HTTPException(detail={\"code\": …})` serialises to. */\nfunction codeOfBody(body: unknown): AuthErrorCode | undefined {\n if (!isBag(body)) return undefined;\n return known(body.code) ?? (isBag(body.detail) ? known(body.detail.code) : undefined);\n}\n\n/**\n * The {@link AuthErrorCode} an error carries, or `undefined` when it carries none.\n *\n * Reads the parsed response body wherever the apps' HTTP clients put it, without\n * depending on any of them:\n *\n * 1. `err.response.data` — axios (keksdose's, kastlan's and Kurvenschmiede's clients;\n * keksdose's `isPlanBudgetLimitRefusal` reads the same path);\n * 2. `err.data` — ofetch's `FetchError`, and most `fetch` wrappers that parse the body;\n * 3. `err.body` — the generated OpenAPI clients' `ApiError`;\n * 4. `err` itself — a body thrown as it came (`throw await res.json()`).\n *\n * In each, `code` or FastAPI's nested `detail.code`. Last, `err.code` — but only when\n * it is one of the codes above: axios writes its OWN codes there (`ERR_NETWORK`,\n * `ECONNABORTED`, `ERR_BAD_REQUEST`), and so does Node, so an unknown value is never\n * read as a refusal. The HTTP status is not checked: the code is the contract, and the\n * status differs per refusal (401, 403, 409, 410).\n */\nexport function authErrorCode(err: unknown): AuthErrorCode | undefined {\n if (!isBag(err)) return undefined;\n const response = err.response;\n return (\n (isBag(response) ? codeOfBody(response.data) : undefined) ??\n codeOfBody(err.data) ??\n codeOfBody(err.body) ??\n codeOfBody(err)\n );\n}\n\n/**\n * Whether `err` is a coded auth refusal — any of them, or the one named:\n *\n * ```ts\n * try { await api.register(values) }\n * catch (err) { if (isAuthError(err, \"email_taken\")) … }\n * ```\n *\n * The kit's `SignInForm` and `RegisterForm` call it on what their callbacks reject\n * with, so an app's `onSubmit` can simply let its client's error through. See\n * {@link authErrorCode} for the shapes it reads.\n */\nexport function isAuthError(err: unknown, code?: AuthErrorCode): boolean {\n const found = authErrorCode(err);\n return found !== undefined && (code === undefined || found === code);\n}\n"],"mappings":";AAkCA,MAAM,QAA6B,oBAAI,IAAmB;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAID,MAAM,QAAQ,CAAC,UAAiC,OAAO,UAAU,YAAY,UAAU;AAGvF,SAAS,MAAM,OAA2C;AACxD,SAAO,OAAO,UAAU,YAAY,MAAM,IAAI,KAAK,IAAK,QAA0B;AACpF;AAIA,SAAS,WAAW,MAA0C;AAC5D,MAAI,CAAC,MAAM,IAAI,EAAG,QAAO;AACzB,SAAO,MAAM,KAAK,IAAI,MAAM,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,OAAO,IAAI,IAAI;AAC7E;AAoBO,SAAS,cAAc,KAAyC;AACrE,MAAI,CAAC,MAAM,GAAG,EAAG,QAAO;AACxB,QAAM,WAAW,IAAI;AACrB,UACG,MAAM,QAAQ,IAAI,WAAW,SAAS,IAAI,IAAI,WAC/C,WAAW,IAAI,IAAI,KACnB,WAAW,IAAI,IAAI,KACnB,WAAW,GAAG;AAElB;AAcO,SAAS,YAAY,KAAc,MAA+B;AACvE,QAAM,QAAQ,cAAc,GAAG;AAC/B,SAAO,UAAU,WAAc,SAAS,UAAa,UAAU;AACjE;","names":[]}
@@ -0,0 +1,71 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ /** What `CompleteNameDialog` hands `onSave`: both names, trimmed, 1–120 characters —
5
+ * `PATCH /auth/me {first_name, last_name}` (§6.1). */
6
+ interface CompleteNameValues {
7
+ firstName: string;
8
+ lastName: string;
9
+ }
10
+ /**
11
+ * Every string the dialog renders — the `completeName` namespace of `<UiKitProvider
12
+ * labels>`, overridable per instance through `labels`.
13
+ */
14
+ interface CompleteNameLabels {
15
+ title: string;
16
+ description: string;
17
+ firstName: string;
18
+ lastName: string;
19
+ save: string;
20
+ /** Dismisses the dialog until the next sign-in. */
21
+ later: string;
22
+ /** Under the fields when `onSave` rejected and the app passed no `error`. */
23
+ failed: string;
24
+ }
25
+ declare const DEFAULT_COMPLETE_NAME_LABELS: CompleteNameLabels;
26
+ interface CompleteNameDialogProps {
27
+ /** What the account holds now — after the migration, the old display name (§3.3). */
28
+ firstName?: string;
29
+ /** Usually empty: that is why the dialog is up. */
30
+ lastName?: string;
31
+ /**
32
+ * Save the names (`PATCH /auth/me`). Resolve and the dialog closes (`onClose(true)`);
33
+ * reject and it stays open with the names kept and `error` — or "Your name could not
34
+ * be saved" — under them.
35
+ */
36
+ onSave: (values: CompleteNameValues) => Promise<unknown>;
37
+ /**
38
+ * The dialog has closed: `true` after a resolved `onSave`, `false` for "Later", Escape,
39
+ * the backdrop and Back. `false` only DEFERS it: the app shows it again after the
40
+ * next sign-in while `/auth/me` still answers `name_incomplete: true`.
41
+ */
42
+ onClose: (saved: boolean) => void;
43
+ /** The app's words for the last failed save, instead of `labels.failed`. Hidden again
44
+ * once a name is edited. */
45
+ error?: ReactNode;
46
+ /** Kept-mounted mode, as on `Modal`: left out, the dialog is open while mounted. */
47
+ open?: boolean;
48
+ labels?: Partial<CompleteNameLabels>;
49
+ }
50
+ /**
51
+ * "Complete your name" — asked once after sign-in of a user whose name was migrated
52
+ * (docs/auth-harmonization.md §3.3). keksdose's and Kurvenschmiede's accounts had one
53
+ * `display_name`; it moved whole into `first_name`, `last_name` stayed empty, and
54
+ * nothing was split by guesswork (§2.4). The app shows this while `/auth/me` answers
55
+ * `name_incomplete: true` — never for a demo user.
56
+ *
57
+ * Both names prefilled with what is there; "Save" waits until both have 1–120
58
+ * characters after trimming. **"Later" only defers it**: nothing else waits on a
59
+ * complete name, no page is blocked, and the app asks again at the next sign-in.
60
+ *
61
+ * The promise handling is `ReauthDialog`'s: busy while `onSave` runs (the fields
62
+ * read-only, "Later" disabled, Escape held — a request that has left cannot be called
63
+ * back by closing the dialog), closed on resolve, kept open on reject. Save is a
64
+ * `commit` control, so a `WriteLockProvider` above it locks it with its reason.
65
+ *
66
+ * Focus starts in the first EMPTY field — the last name, as a rule — because filling it
67
+ * in is the whole of what the dialog is for.
68
+ */
69
+ declare function CompleteNameDialog({ firstName: initialFirst, lastName: initialLast, onSave, onClose, error, open, labels: labelsProp, }: CompleteNameDialogProps): react.JSX.Element;
70
+
71
+ export { CompleteNameDialog, type CompleteNameDialogProps, type CompleteNameLabels, type CompleteNameValues, DEFAULT_COMPLETE_NAME_LABELS };