@eifi1/ui-kit 0.30.0 → 0.31.1

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 (269) hide show
  1. package/README.md +42 -5
  2. package/dist/account/data-export-setting.js +3 -2
  3. package/dist/account/data-export-setting.js.map +1 -1
  4. package/dist/account/delete-account-setting.d.ts +5 -1
  5. package/dist/account/delete-account-setting.js +3 -2
  6. package/dist/account/delete-account-setting.js.map +1 -1
  7. package/dist/account/email-change-setting.js +4 -3
  8. package/dist/account/email-change-setting.js.map +1 -1
  9. package/dist/account/sessions-setting.js +3 -2
  10. package/dist/account/sessions-setting.js.map +1 -1
  11. package/dist/admin/admin-action-confirm.d.ts +5 -1
  12. package/dist/admin/admin-parts.d.ts +8 -1
  13. package/dist/admin/admin-parts.js +1 -1
  14. package/dist/admin/admin-parts.js.map +1 -1
  15. package/dist/admin/invitations-panel.d.ts +5 -1
  16. package/dist/admin/invitations-panel.js +3 -2
  17. package/dist/admin/invitations-panel.js.map +1 -1
  18. package/dist/admin/reviewer-scope-editor.d.ts +5 -1
  19. package/dist/admin/role-select.d.ts +5 -1
  20. package/dist/admin/transfer-ownership-dialog.d.ts +5 -1
  21. package/dist/admin/user-roster.d.ts +5 -1
  22. package/dist/auth/auth-errors.d.ts +24 -6
  23. package/dist/auth/auth-errors.js +7 -1
  24. package/dist/auth/auth-errors.js.map +1 -1
  25. package/dist/auth/register-form.d.ts +5 -1
  26. package/dist/auth/reset-password-form.d.ts +1 -1
  27. package/dist/auth/reset-password-form.js +2 -1
  28. package/dist/auth/reset-password-form.js.map +1 -1
  29. package/dist/auth/sign-in-form.d.ts +15 -1
  30. package/dist/auth/sign-in-form.js +12 -3
  31. package/dist/auth/sign-in-form.js.map +1 -1
  32. package/dist/auth/verify-email.d.ts +4 -0
  33. package/dist/auth/verify-email.js +3 -2
  34. package/dist/auth/verify-email.js.map +1 -1
  35. package/dist/chart.d.ts +5 -1
  36. package/dist/components/account-settings-labels.d.ts +12 -0
  37. package/dist/components/account-settings-labels.js +2 -1
  38. package/dist/components/account-settings-labels.js.map +1 -1
  39. package/dist/components/account-settings.d.ts +8 -2
  40. package/dist/components/account-settings.js +19 -11
  41. package/dist/components/account-settings.js.map +1 -1
  42. package/dist/components/amount-input.d.ts +5 -1
  43. package/dist/components/button-group.d.ts +5 -1
  44. package/dist/components/calculator.d.ts +5 -1
  45. package/dist/components/confirm-dialog.d.ts +5 -1
  46. package/dist/components/confirm-dialog.js +7 -1
  47. package/dist/components/confirm-dialog.js.map +1 -1
  48. package/dist/components/copy-button.d.ts +5 -1
  49. package/dist/components/danger-confirm.d.ts +5 -1
  50. package/dist/components/data-table.js +8 -1
  51. package/dist/components/data-table.js.map +1 -1
  52. package/dist/components/date-picker.js +9 -4
  53. package/dist/components/date-picker.js.map +1 -1
  54. package/dist/components/facing-pair.d.ts +5 -1
  55. package/dist/components/file-button.d.ts +5 -1
  56. package/dist/components/file-dropzone.d.ts +5 -1
  57. package/dist/components/form-actions.d.ts +5 -1
  58. package/dist/components/iban-input.d.ts +5 -1
  59. package/dist/components/language-select.d.ts +5 -1
  60. package/dist/components/legal-page.d.ts +5 -1
  61. package/dist/components/legal.d.ts +5 -1
  62. package/dist/components/money-field.d.ts +5 -1
  63. package/dist/components/number-field.d.ts +5 -1
  64. package/dist/components/number-input.d.ts +5 -1
  65. package/dist/components/numpad-sheet.d.ts +5 -1
  66. package/dist/components/passkeys-setting.js +2 -1
  67. package/dist/components/passkeys-setting.js.map +1 -1
  68. package/dist/components/phone-input.d.ts +5 -1
  69. package/dist/components/series-chart.d.ts +5 -1
  70. package/dist/components/settings-fields.d.ts +40 -3
  71. package/dist/components/settings-fields.js +20 -1
  72. package/dist/components/settings-fields.js.map +1 -1
  73. package/dist/components/share-card.d.ts +5 -1
  74. package/dist/components/text-link.d.ts +5 -1
  75. package/dist/components/time-input.d.ts +5 -1
  76. package/dist/components/ui.d.ts +5 -1
  77. package/dist/{delete-account-setting-CGVMckMw.d.ts → delete-account-setting-CpIhzxxZ.d.ts} +60 -23
  78. package/dist/demo/demo-banner.d.ts +51 -0
  79. package/dist/demo/demo-banner.js +97 -0
  80. package/dist/demo/demo-banner.js.map +1 -0
  81. package/dist/demo/demo-countdown.d.ts +58 -0
  82. package/dist/demo/demo-countdown.js +79 -0
  83. package/dist/demo/demo-countdown.js.map +1 -0
  84. package/dist/demo/demo-ended.d.ts +45 -0
  85. package/dist/demo/demo-ended.js +42 -0
  86. package/dist/demo/demo-ended.js.map +1 -0
  87. package/dist/demo/demo-labels.d.ts +53 -0
  88. package/dist/demo/demo-labels.js +29 -0
  89. package/dist/demo/demo-labels.js.map +1 -0
  90. package/dist/demo/demo-session.d.ts +30 -0
  91. package/dist/demo/demo-session.js +8 -0
  92. package/dist/demo/demo-session.js.map +1 -0
  93. package/dist/demo/demo-start.d.ts +54 -0
  94. package/dist/demo/demo-start.js +68 -0
  95. package/dist/demo/demo-start.js.map +1 -0
  96. package/dist/feedback/feedback-attachment.d.ts +5 -1
  97. package/dist/feedback/feedback-context.d.ts +5 -1
  98. package/dist/feedback/feedback-crash.d.ts +5 -1
  99. package/dist/feedback/feedback-dialog.d.ts +5 -1
  100. package/dist/feedback/feedback-inbox.d.ts +5 -1
  101. package/dist/feedback/feedback-inbox.js +12 -2
  102. package/dist/feedback/feedback-inbox.js.map +1 -1
  103. package/dist/feedback/feedback-labels.d.ts +5 -1
  104. package/dist/feedback/feedback-labels.js +1 -0
  105. package/dist/feedback/feedback-labels.js.map +1 -1
  106. package/dist/feedback/feedback-menu.d.ts +5 -1
  107. package/dist/feedback/feedback-record.d.ts +5 -1
  108. package/dist/feedback/feedback-record.js +2 -0
  109. package/dist/feedback/feedback-record.js.map +1 -1
  110. package/dist/feedback/feedback-row-detail.d.ts +5 -1
  111. package/dist/feedback/feedback-row-detail.js +7 -0
  112. package/dist/feedback/feedback-row-detail.js.map +1 -1
  113. package/dist/feedback/feedback-status-undo.d.ts +5 -1
  114. package/dist/feedback/feedback-submit.d.ts +5 -1
  115. package/dist/feedback/feedback-swipe.d.ts +6 -2
  116. package/dist/feedback/feedback-swipe.js.map +1 -1
  117. package/dist/feedback/feedback-table.d.ts +5 -1
  118. package/dist/feedback/feedback-thread.d.ts +5 -1
  119. package/dist/feedback.d.ts +5 -1
  120. package/dist/hooks/use-file-drop.d.ts +5 -1
  121. package/dist/i18n/defaults.d.ts +5 -1
  122. package/dist/i18n/defaults.js +6 -0
  123. package/dist/i18n/defaults.js.map +1 -1
  124. package/dist/i18n/german.d.ts +5 -1
  125. package/dist/i18n/german.js +85 -2
  126. package/dist/i18n/german.js.map +1 -1
  127. package/dist/i18n/kit-labels.d.ts +5 -1
  128. package/dist/i18n/kit-labels.js.map +1 -1
  129. package/dist/i18n/languages.d.ts +5 -1
  130. package/dist/i18n/locales/de-CH.d.ts +5 -1
  131. package/dist/i18n/locales/en.d.ts +5 -1
  132. package/dist/i18n/locales/es.d.ts +5 -1
  133. package/dist/i18n/locales/es.js +82 -2
  134. package/dist/i18n/locales/es.js.map +1 -1
  135. package/dist/i18n/locales/fr.d.ts +5 -1
  136. package/dist/i18n/locales/fr.js +83 -2
  137. package/dist/i18n/locales/fr.js.map +1 -1
  138. package/dist/i18n/locales/hu.d.ts +5 -1
  139. package/dist/i18n/locales/hu.js +83 -2
  140. package/dist/i18n/locales/hu.js.map +1 -1
  141. package/dist/i18n/locales/it.d.ts +5 -1
  142. package/dist/i18n/locales/it.js +82 -2
  143. package/dist/i18n/locales/it.js.map +1 -1
  144. package/dist/i18n/locales/zh.d.ts +5 -1
  145. package/dist/i18n/locales/zh.js +81 -2
  146. package/dist/i18n/locales/zh.js.map +1 -1
  147. package/dist/i18n/review.d.ts +5 -1
  148. package/dist/i18n/review.js +15 -1
  149. package/dist/i18n/review.js.map +1 -1
  150. package/dist/index.d.ts +25 -3
  151. package/dist/index.js +96 -0
  152. package/dist/index.js.map +1 -1
  153. package/dist/landing/access.d.ts +48 -0
  154. package/dist/landing/access.js +38 -0
  155. package/dist/landing/access.js.map +1 -0
  156. package/dist/landing/landing-actions.d.ts +140 -0
  157. package/dist/landing/landing-actions.js +39 -0
  158. package/dist/landing/landing-actions.js.map +1 -0
  159. package/dist/landing/landing-labels.d.ts +43 -0
  160. package/dist/landing/landing-labels.js +23 -0
  161. package/dist/landing/landing-labels.js.map +1 -0
  162. package/dist/landing/landing-sections.d.ts +218 -0
  163. package/dist/landing/landing-sections.js +167 -0
  164. package/dist/landing/landing-sections.js.map +1 -0
  165. package/dist/landing/page-seo.d.ts +99 -0
  166. package/dist/landing/page-seo.js +121 -0
  167. package/dist/landing/page-seo.js.map +1 -0
  168. package/dist/landing/public-header.d.ts +148 -0
  169. package/dist/landing/public-header.js +49 -0
  170. package/dist/landing/public-header.js.map +1 -0
  171. package/dist/landing/routing.d.ts +231 -0
  172. package/dist/landing/routing.js +84 -0
  173. package/dist/landing/routing.js.map +1 -0
  174. package/dist/rhf/fields.d.ts +5 -1
  175. package/dist/rhf/form.d.ts +5 -1
  176. package/dist/rhf.d.ts +5 -1
  177. package/dist/settings/settings-catalogue.d.ts +84 -0
  178. package/dist/settings/settings-catalogue.js +47 -0
  179. package/dist/settings/settings-catalogue.js.map +1 -0
  180. package/dist/settings/settings-context.d.ts +31 -0
  181. package/dist/settings/settings-context.js +11 -0
  182. package/dist/settings/settings-context.js.map +1 -0
  183. package/dist/settings/settings-heading.d.ts +50 -0
  184. package/dist/settings/settings-heading.js +27 -0
  185. package/dist/settings/settings-heading.js.map +1 -0
  186. package/dist/settings/settings-labels.d.ts +48 -0
  187. package/dist/settings/settings-labels.js +43 -0
  188. package/dist/settings/settings-labels.js.map +1 -0
  189. package/dist/settings/settings-layout.d.ts +77 -0
  190. package/dist/settings/settings-layout.js +242 -0
  191. package/dist/settings/settings-layout.js.map +1 -0
  192. package/dist/settings/settings-section.d.ts +133 -0
  193. package/dist/settings/settings-section.js +63 -0
  194. package/dist/settings/settings-section.js.map +1 -0
  195. package/dist/settings/use-account-language.d.ts +83 -0
  196. package/dist/settings/use-account-language.js +62 -0
  197. package/dist/settings/use-account-language.js.map +1 -0
  198. package/dist/settings/use-settings-focus.d.ts +34 -0
  199. package/dist/settings/use-settings-focus.js +77 -0
  200. package/dist/settings/use-settings-focus.js.map +1 -0
  201. package/dist/settings/use-settings-route.d.ts +118 -0
  202. package/dist/settings/use-settings-route.js +120 -0
  203. package/dist/settings/use-settings-route.js.map +1 -0
  204. package/dist/shell/app-shell.d.ts +11 -1
  205. package/dist/shell/app-shell.js +3 -2
  206. package/dist/shell/app-shell.js.map +1 -1
  207. package/dist/shell/top-bar-brand.d.ts +5 -1
  208. package/dist/shell.d.ts +15 -1
  209. package/dist/shell.js +56 -0
  210. package/dist/shell.js.map +1 -1
  211. package/dist/wizard/stepper-nav.d.ts +5 -1
  212. package/dist/wizard.d.ts +5 -1
  213. package/package.json +2 -1
  214. package/src/account/data-export-setting.tsx +3 -2
  215. package/src/account/delete-account-setting.tsx +3 -2
  216. package/src/account/email-change-setting.tsx +4 -7
  217. package/src/account/sessions-setting.tsx +3 -2
  218. package/src/admin/admin-parts.ts +9 -2
  219. package/src/admin/invitations-panel.tsx +11 -4
  220. package/src/auth/auth-errors.ts +36 -5
  221. package/src/auth/reset-password-form.tsx +6 -2
  222. package/src/auth/sign-in-form.tsx +34 -3
  223. package/src/auth/verify-email.tsx +14 -2
  224. package/src/components/account-settings-labels.ts +13 -0
  225. package/src/components/account-settings.tsx +33 -12
  226. package/src/components/confirm-dialog.tsx +20 -1
  227. package/src/components/data-table.tsx +8 -0
  228. package/src/components/date-picker.tsx +9 -4
  229. package/src/components/passkeys-setting.tsx +2 -1
  230. package/src/components/settings-fields.tsx +50 -1
  231. package/src/demo/demo-banner.tsx +159 -0
  232. package/src/demo/demo-countdown.ts +141 -0
  233. package/src/demo/demo-ended.tsx +89 -0
  234. package/src/demo/demo-labels.ts +78 -0
  235. package/src/demo/demo-session.ts +32 -0
  236. package/src/demo/demo-start.tsx +150 -0
  237. package/src/feedback/feedback-inbox.tsx +21 -8
  238. package/src/feedback/feedback-labels.ts +2 -1
  239. package/src/feedback/feedback-record.ts +10 -7
  240. package/src/feedback/feedback-row-detail.tsx +28 -4
  241. package/src/feedback/feedback-swipe.tsx +1 -1
  242. package/src/i18n/defaults.ts +6 -0
  243. package/src/i18n/german.ts +87 -0
  244. package/src/i18n/kit-labels.tsx +9 -0
  245. package/src/i18n/locales/es.ts +84 -0
  246. package/src/i18n/locales/fr.ts +85 -0
  247. package/src/i18n/locales/hu.ts +85 -0
  248. package/src/i18n/locales/it.ts +84 -0
  249. package/src/i18n/locales/zh.ts +82 -0
  250. package/src/i18n/review.ts +14 -0
  251. package/src/index.ts +98 -1
  252. package/src/landing/access.ts +97 -0
  253. package/src/landing/landing-actions.tsx +96 -0
  254. package/src/landing/landing-labels.ts +59 -0
  255. package/src/landing/landing-sections.tsx +337 -0
  256. package/src/landing/page-seo.ts +251 -0
  257. package/src/landing/public-header.tsx +120 -0
  258. package/src/landing/routing.tsx +226 -0
  259. package/src/settings/settings-catalogue.ts +132 -0
  260. package/src/settings/settings-context.ts +33 -0
  261. package/src/settings/settings-heading.tsx +65 -0
  262. package/src/settings/settings-labels.ts +87 -0
  263. package/src/settings/settings-layout.tsx +379 -0
  264. package/src/settings/settings-section.tsx +108 -0
  265. package/src/settings/use-account-language.ts +146 -0
  266. package/src/settings/use-settings-focus.ts +120 -0
  267. package/src/settings/use-settings-route.ts +258 -0
  268. package/src/shell/app-shell.tsx +10 -2
  269. package/src/shell.ts +51 -0
package/README.md CHANGED
@@ -382,16 +382,16 @@ 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
- **1577 names from 231 modules** — 724 values and 853 types. _Italic_ is a type-only export.
385
+ **1690 names from 253 modules** — 779 values and 911 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` | 1577 |
392
+ | `@eifi1/ui-kit` | 1690 |
393
393
  | `@eifi1/ui-kit/chart` | 104 |
394
- | `@eifi1/ui-kit/shell` | 24 |
394
+ | `@eifi1/ui-kit/shell` | 72 |
395
395
  | `@eifi1/ui-kit/data-table` | 51 |
396
396
  | `@eifi1/ui-kit/wizard` | 25 |
397
397
  | `@eifi1/ui-kit/tour` | 7 |
@@ -513,7 +513,7 @@ re-slicing of it, never a second API.
513
513
  | `components/multi-select` | `MultiSelect`, _`MultiSelectOption`_, _`MultiSelectProps`_ |
514
514
  | `components/tooltip` | `placeTooltip`, `Tooltip`, _`TooltipPlacement`_, _`TooltipProps`_, _`TooltipSide`_, _`TooltipSize`_, _`TooltipTap`_, _`TooltipViewport`_ |
515
515
  | `components/user-avatar` | `avatarInitials`, `UserAvatar`, _`UserAvatarBadge`_, _`UserAvatarProps`_ |
516
- | `components/settings-fields` | `LanguageSetting`, `ThemeSetting`, _`LanguageSettingProps`_, _`ThemeSettingProps`_ |
516
+ | `components/settings-fields` | `LanguageSetting`, `ThemeSetting`, _`LanguageSettingProps`_, _`ThemeSettingProps`_, _`ThemeSettingToggleProps`_ |
517
517
  | `components/field-sync` | `DEFAULT_FIELD_SYNC_LABELS`, `FIELD_SYNC_FRAME`, `FIELD_SYNC_SAVED_MS`, `FieldSyncIndicator`, `FieldSyncRow`, `resolveFieldSyncLabels`, `useFieldSync`, _`FieldSyncIndicatorProps`_, _`FieldSyncLabels`_, _`FieldSyncRowProps`_, _`FieldSyncState`_, _`UseFieldSyncOptions`_, _`UseFieldSyncReturn`_ |
518
518
  | `components/month-picker` | `DEFAULT_MONTH_PICKER_LABELS`, `MonthPicker`, _`MonthPickerLabels`_, _`MonthPickerProps`_ |
519
519
  | `components/checkbox` | `Checkbox`, _`CheckboxProps`_ |
@@ -652,7 +652,7 @@ re-slicing of it, never a second API.
652
652
  | `auth/sign-in-form` | `DEFAULT_SIGN_IN_LABELS`, `SignInForm`, _`SignInAction`_, _`SignInAnswer`_, _`SignInCodeValues`_, _`SignInCredentials`_, _`SignInFormProps`_, _`SignInLabels`_, _`SignInNewPasswordValues`_, _`SignInStep`_ |
653
653
  | `auth/complete-name-dialog` | `CompleteNameDialog`, `DEFAULT_COMPLETE_NAME_LABELS`, _`CompleteNameDialogProps`_, _`CompleteNameLabels`_, _`CompleteNameValues`_ |
654
654
  | `auth/email-tag` | `taggedEmail` |
655
- | `auth/auth-errors` | `authErrorCode`, `isAuthError`, `isRateLimited`, `retryAfterSeconds`, _`AccountErrorCode`_, _`AuthErrorCode`_, _`KitErrorCode`_ |
655
+ | `auth/auth-errors` | `authErrorCode`, `isAuthError`, `isRateLimited`, `retryAfterSeconds`, _`AccountErrorCode`_, _`AuthErrorCode`_, _`DemoErrorCode`_, _`KitErrorCode`_ |
656
656
  | `auth/forgot-password-form` | `DEFAULT_FORGOT_PASSWORD_LABELS`, `ForgotPasswordForm`, _`ForgotPasswordFormProps`_, _`ForgotPasswordLabels`_ |
657
657
  | `auth/reset-password-form` | `DEFAULT_RESET_PASSWORD_LABELS`, `ResetPasswordForm`, _`ResetPasswordCheck`_, _`ResetPasswordFormProps`_, _`ResetPasswordLabels`_, _`ResetPasswordResult`_, _`ResetPasswordValues`_ |
658
658
  | `auth/verify-email` | `DEFAULT_VERIFY_EMAIL_LABELS`, `EmailVerificationBanner`, `VerifyEmailStatus`, _`EmailVerificationBannerProps`_, _`VerifyEmailFailure`_, _`VerifyEmailLabels`_, _`VerifyEmailStatusProps`_ |
@@ -700,6 +700,43 @@ re-slicing of it, never a second API.
700
700
  | `search/search-index` | `createSearchIndex`, `matchEntries`, `normalizeSearchText`, `SEARCH_TIER_POINTS`, _`SearchEntry`_, _`SearchHit`_, _`SearchIndex`_, _`SearchIndexOptions`_, _`SearchMatchField`_ |
701
701
  | `search/global-search` | `DEFAULT_GLOBAL_SEARCH_LABELS`, `GlobalSearch`, _`GlobalSearchLabels`_, _`GlobalSearchProps`_, _`GlobalSearchSource`_, _`GlobalSearchSourceGroup`_, _`GlobalSearchSuggestion`_, _`GlobalSearchTriggerProps`_ |
702
702
 
703
+ ### settings
704
+
705
+ | Module | Exports |
706
+ |---|---|
707
+ | `settings/settings-layout` | `SETTINGS_SEARCH_THRESHOLD`, `SettingsLayout`, _`SettingsLayoutProps`_, _`SettingsLayoutWidth`_ |
708
+ | `settings/use-settings-route` | `resolveSettingsLocation`, `SETTINGS_FROM_LIST_STATE`, `settingsFromListState`, `useSettingsRoute`, _`SettingsLayoutMode`_, _`SettingsLocation`_, _`SettingsLocationResult`_, _`SettingsLocationRules`_, _`SettingsRoute`_, _`UseSettingsRouteOptions`_ |
709
+ | `settings/use-settings-focus` | `SETTINGS_FOCUS_MS`, `SETTINGS_FOCUS_RING`, `useSettingsFocus` |
710
+ | `settings/settings-section` | `SettingsSection`, _`SettingsSectionProps`_ |
711
+ | `settings/settings-context` | `useSettingsLayout`, _`SettingsLayoutContextValue`_ |
712
+ | `settings/settings-heading` | `SettingsHeadingLevel`, `useSettingsHeadingLevel`, _`SettingsHeadingLevelProps`_, _`SettingsHeadingTag`_ |
713
+ | `settings/settings-catalogue` | `settingsHref`, `settingsSearchEntries`, `visibleSettingsEntries`, `visibleSettingsGroups`, _`SettingsEntry`_, _`SettingsGroup`_, _`SettingsSearchEntriesOptions`_ |
714
+ | `settings/settings-labels` | `DEFAULT_SETTINGS_LABELS`, `useSettingsLabels`, _`SettingsCoreGroup`_, _`SettingsGroupLabels`_, _`SettingsLabels`_ |
715
+ | `settings/use-account-language` | `matchOfferedLanguage`, `resolveAccountLanguage`, `useAccountLanguage`, _`AccountLanguage`_, _`AccountLanguageSource`_, _`ResolveAccountLanguageInput`_, _`ResolvedAccountLanguage`_, _`UseAccountLanguageOptions`_ |
716
+
717
+ ### landing
718
+
719
+ | Module | Exports |
720
+ |---|---|
721
+ | `landing/landing-labels` | `DEFAULT_LANDING_LABELS`, `useLandingLabels`, _`LandingLabels`_ |
722
+ | `landing/access` | `accessAction`, `useAccessAction`, _`AccessChoice`_, _`AccessLabels`_, _`AccessLink`_ |
723
+ | `landing/landing-actions` | `LandingActions`, _`LandingActionsProps`_, _`LandingSession`_ |
724
+ | `landing/landing-sections` | `CtaBand`, `FeatureRow`, `FeatureRows`, `Hero`, `PublicFooter`, `TrustStrip`, _`CtaBandProps`_, _`FeatureRowProps`_, _`FeatureRowsProps`_, _`HeroProps`_, _`PublicFooterProps`_, _`TrustItem`_, _`TrustStripProps`_ |
725
+ | `landing/page-seo` | `metaContent`, `seoCopyProblems`, `usePageSeo`, _`SeoCopy`_, _`SeoCopyLimits`_, _`SeoCopyProblem`_, _`SeoCopyProblemCode`_ |
726
+ | `landing/routing` | `clearLastVisitedPage`, `DEFAULT_LAST_VISITED_EXCLUDES`, `NEXT_PARAM`, `readLastVisitedPage`, `RedirectIfAuthed`, `RootEntry`, `safeNextPath`, `useLastVisitedPage`, _`LastVisitedPageOptions`_, _`PathPattern`_, _`RedirectIfAuthedProps`_, _`RootEntryProps`_, _`RoutingSession`_ |
727
+ | `landing/public-header` | `PublicHeader`, _`PublicHeaderBrand`_, _`PublicHeaderProps`_ |
728
+
729
+ ### demo
730
+
731
+ | Module | Exports |
732
+ |---|---|
733
+ | `demo/demo-labels` | `DEFAULT_DEMO_LABELS`, `useDemoLabels`, _`DemoLabels`_ |
734
+ | `demo/demo-session` | `isDemoSession`, _`DemoModel`_, _`DemoSessionUser`_ |
735
+ | `demo/demo-countdown` | `DEMO_MINUTES_ONLY`, `DEMO_WARNING_MINUTES`, `demoCountdown`, `useDemoCountdown`, _`DemoCountdown`_, _`DemoCountdownOptions`_, _`DemoExpiry`_ |
736
+ | `demo/demo-start` | `DemoStart`, _`DemoStartProps`_ |
737
+ | `demo/demo-banner` | `DemoBanner`, _`DemoBannerProps`_ |
738
+ | `demo/demo-ended` | `DemoEnded`, _`DemoEndedProps`_ |
739
+
703
740
  <!-- END GENERATED: exports -->
704
741
 
705
742
  ## Forms / refs
@@ -9,7 +9,8 @@ import { hasMessage } from "../components/choice-parts.js";
9
9
  import { TextLink } from "../components/text-link.js";
10
10
  import { Button, Card } from "../components/ui.js";
11
11
  import { englishWait, isRateLimited, retryAfterSeconds } from "../auth/auth-errors.js";
12
- import { CARD_DESCRIPTION_CLASS, CARD_TITLE_CLASS, settle, useMounted } from "./account-parts.js";
12
+ import { CARD_DESCRIPTION_CLASS, settle, useMounted } from "./account-parts.js";
13
+ import { SettingsCardTitle } from "../settings/settings-heading.js";
13
14
  const DEFAULT_DATA_EXPORT_LABELS = {
14
15
  title: "Export your data",
15
16
  description: "Download a copy of your account\u2019s data as a JSON file.",
@@ -88,7 +89,7 @@ function DataExportSetting({
88
89
  };
89
90
  return /* @__PURE__ */ jsxs(Card, { ...rest, className: cn("p-4 space-y-3", className), children: [
90
91
  /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
91
- /* @__PURE__ */ jsx("div", { className: CARD_TITLE_CLASS, children: labels.title }),
92
+ /* @__PURE__ */ jsx(SettingsCardTitle, { children: labels.title }),
92
93
  /* @__PURE__ */ jsx("div", { className: CARD_DESCRIPTION_CLASS, children: labels.description }),
93
94
  hasMessage(description) && /* @__PURE__ */ jsx("div", { className: CARD_DESCRIPTION_CLASS, children: description })
94
95
  ] }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/account/data-export-setting.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { Download } from \"lucide-react\";\n\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport { TextLink } from \"../components/text-link\";\nimport { Button, Card } from \"../components/ui\";\nimport { englishWait, isRateLimited, retryAfterSeconds } from \"../auth/auth-errors\";\nimport { CARD_DESCRIPTION_CLASS, CARD_TITLE_CLASS, settle, useMounted } from \"./account-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string {@link DataExportSetting} renders — the `dataExport` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. */\nexport interface DataExportLabels {\n /** The card's title. */\n title: string;\n /** What the download is. The app's own sentence (`description`) follows it. */\n description: string;\n /** The button. */\n download: string;\n /** Said once the file was handed to the browser. */\n started: string;\n /** The link under it that saves the same file again, for a browser that held the\n * download back. */\n saveAgain: string;\n /** The export was throttled — HTTP 429 (§6.5: once a minute) — given its\n * `Retry-After` wait in seconds, or `undefined` without one. */\n rateLimited: (seconds?: number) => string;\n /** Any other failure. */\n failed: string;\n}\n\nexport const DEFAULT_DATA_EXPORT_LABELS: DataExportLabels = {\n title: \"Export your data\",\n description: \"Download a copy of your account’s data as a JSON file.\",\n download: \"Download my data\",\n started: \"Your download has started.\",\n saveAgain: \"Didn’t start? Save the file\",\n rateLimited: (seconds) =>\n seconds && seconds > 0\n ? `You exported your data a moment ago. Try again in ${englishWait(seconds)}.`\n : \"You exported your data a moment ago. Please try again in a minute.\",\n failed: \"The export failed. Please try again.\",\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\n/**\n * What {@link DataExportSettingProps.onExport} resolves with: the file itself — a `Blob`\n * (axios' `responseType: \"blob\"`, `await res.blob()`) — or a URL the browser fetches\n * itself (a signed link), with the file name to save it under.\n */\nexport type DataExportFile = Blob | { url: string; filename?: string };\n\nexport interface DataExportSettingProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /**\n * Fetch the export (`GET /auth/me/export`, §6.5). Resolve with the file — the card\n * saves it under `filename` — or reject with the client's error: a 429 (the export is\n * throttled to once a minute) says `rateLimited`, anything else (a demo account's 403)\n * goes through `describeError`, else `failed`.\n */\n onExport: () => Promise<DataExportFile>;\n /**\n * The app's sentence under the kit's — what the export holds and what it doesn't.\n * kastlan's: \"Your account; your company's records are your company's, ask them.\"\n */\n description?: ReactNode;\n /** The name the file is saved under. Default `account-export-YYYY-MM-DD.json` (the\n * local day); a `{ url, filename }` answer's own name wins. */\n filename?: string;\n /** The app's own words for a failure, or `undefined` for the kit's. Asked first. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: Partial<DataExportLabels>;\n}\n\ninterface Saved {\n href: string;\n filename: string;\n /** An object URL of ours, revoked when it is replaced or the card goes. */\n owned: boolean;\n}\n\n/** `account-export-2026-10-07.json`, the local day — the one a person looks for. */\nfunction defaultFilename(now = new Date()): string {\n const pad = (n: number) => String(n).padStart(2, \"0\");\n return `account-export-${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}.json`;\n}\n\n/** A `{ url }` answer, as opposed to a Blob or anything else. */\nfunction isUrlAnswer(value: unknown): value is { url: string; filename?: string } {\n return typeof value === \"object\" && value !== null && typeof (value as { url?: unknown }).url === \"string\";\n}\n\n/** Hand `href` to the browser as a download named `filename`: a link with `download`,\n * clicked once and taken out again — the one way a page saves a file without a new\n * tab that would show the JSON instead. */\nfunction startDownload(href: string, filename: string) {\n const link = document.createElement(\"a\");\n link.href = href;\n link.download = filename;\n link.rel = \"noopener\";\n link.hidden = true;\n document.body.appendChild(link);\n link.click();\n link.remove();\n}\n\n/**\n * The account's data as a download (docs/user-admin-harmonization.md §6.5, §2.2): what it\n * is, the app's sentence on what it holds, and one button.\n *\n * **The kit saves the file.** `onExport` fetches it — the request is the app's, with its\n * auth (auth §8) — and resolves with a `Blob` or a `{ url }`; the card hands it to the\n * browser through a link with a `download` name, so it lands as `account-export-….json`\n * rather than opening as a page of JSON. A `Blob` becomes an object URL, revoked when\n * the next export replaces it or the card unmounts.\n *\n * The click comes after an `await`, which some browsers count as no longer the\n * person's: \"Didn't start? Save the file\" stays under the confirmation, a real link to\n * the same file that the person clicks themselves.\n *\n * **The throttle** (once a minute, §6.5) is a 429, said as such; the app's\n * `describeError` comes first (keksdose's demo account answers 403).\n */\nexport function DataExportSetting({\n onExport,\n description,\n filename,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: DataExportSettingProps) {\n const labels = useKitLabels(\"dataExport\", DEFAULT_DATA_EXPORT_LABELS, labelsProp);\n const [busy, setBusy] = useState(false);\n const [saved, setSaved] = useState<Saved | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n\n // Our object URL lives as long as the \"Save the file\" link that points at it.\n useEffect(() => {\n if (!saved?.owned) return;\n const href = saved.href;\n return () => URL.revokeObjectURL(href);\n }, [saved]);\n\n const run = () => {\n if (busy) return;\n setBusy(true);\n setFailure(null);\n // The last file's link goes (and its object URL with it): it would sit beside this\n // export's answer as if it were it.\n setSaved(null);\n settle(onExport).then(\n (answer) => {\n if (!mounted.current) return;\n setBusy(false);\n let next: Saved;\n if (answer instanceof Blob) {\n next = { href: URL.createObjectURL(answer), filename: filename ?? defaultFilename(), owned: true };\n } else if (isUrlAnswer(answer)) {\n next = { href: answer.url, filename: answer.filename ?? filename ?? defaultFilename(), owned: false };\n } else {\n // Nothing to save: an app that resolved with its response object, say.\n setFailure(labels.failed);\n return;\n }\n setSaved(next);\n startDownload(next.href, next.filename);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusy(false);\n const own = describeError?.(error);\n setFailure(\n hasMessage(own) ? own : isRateLimited(error) ? labels.rateLimited(retryAfterSeconds(error)) : labels.failed,\n );\n },\n );\n };\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div className=\"space-y-1\">\n <div className={CARD_TITLE_CLASS}>{labels.title}</div>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.description}</div>\n {hasMessage(description) && <div className={CARD_DESCRIPTION_CLASS}>{description}</div>}\n </div>\n <div className=\"flex flex-wrap items-center gap-x-3 gap-y-2\">\n <Button type=\"button\" variant=\"secondary\" pending={busy} onClick={run}>\n <Download aria-hidden className=\"size-4\" />\n {labels.download}\n </Button>\n {/* Always in the tree, so the confirmation that appears in it is announced; in\n the button's row, so an empty one takes no line of its own. */}\n <span role=\"status\" className=\"text-xs text-[var(--text-secondary)]\">\n {saved && (\n <>\n {labels.started}{\" \"}\n <TextLink href={saved.href} download={saved.filename} reloadDocument tone=\"secondary\">\n {labels.saveAgain}\n </TextLink>\n </>\n )}\n </span>\n </div>\n {hasMessage(failure) && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure}\n </AlertBanner>\n )}\n </Card>\n );\n}\n"],"mappings":";AA2LM,SAcM,UAbJ,KADF;AA3LN,SAAS,WAAW,gBAAgB;AAEpC,SAAS,gBAAgB;AAEzB,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,QAAQ,YAAY;AAC7B,SAAS,aAAa,eAAe,yBAAyB;AAC9D,SAAS,wBAAwB,kBAAkB,QAAQ,kBAAkB;AAyBtE,MAAM,6BAA+C;AAAA,EAC1D,OAAO;AAAA,EACP,aAAa;AAAA,EACb,UAAU;AAAA,EACV,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa,CAAC,YACZ,WAAW,UAAU,IACjB,qDAAqD,YAAY,OAAO,CAAC,MACzE;AAAA,EACN,QAAQ;AACV;AAwCA,SAAS,gBAAgB,MAAM,oBAAI,KAAK,GAAW;AACjD,QAAM,MAAM,CAAC,MAAc,OAAO,CAAC,EAAE,SAAS,GAAG,GAAG;AACpD,SAAO,kBAAkB,IAAI,YAAY,CAAC,IAAI,IAAI,IAAI,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,QAAQ,CAAC,CAAC;AAC7F;AAGA,SAAS,YAAY,OAA6D;AAChF,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAQ,MAA4B,QAAQ;AACpG;AAKA,SAAS,cAAc,MAAc,UAAkB;AACrD,QAAM,OAAO,SAAS,cAAc,GAAG;AACvC,OAAK,OAAO;AACZ,OAAK,WAAW;AAChB,OAAK,MAAM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AAM,MAAM,gBAAgB,KAAK;AACjC;AAAA,UACE,WAAW,GAAG,IAAI,MAAM,cAAc,KAAK,IAAI,OAAO,YAAY,kBAAkB,KAAK,CAAC,IAAI,OAAO;AAAA,QACvG;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SACE,qBAAC,QAAM,GAAG,MAAM,WAAW,GAAG,iBAAiB,SAAS,GACtD;AAAA,yBAAC,SAAI,WAAU,aACb;AAAA,0BAAC,SAAI,WAAW,kBAAmB,iBAAO,OAAM;AAAA,MAChD,oBAAC,SAAI,WAAW,wBAAyB,iBAAO,aAAY;AAAA,MAC3D,WAAW,WAAW,KAAK,oBAAC,SAAI,WAAW,wBAAyB,uBAAY;AAAA,OACnF;AAAA,IACA,qBAAC,SAAI,WAAU,+CACb;AAAA,2BAAC,UAAO,MAAK,UAAS,SAAQ,aAAY,SAAS,MAAM,SAAS,KAChE;AAAA,4BAAC,YAAS,eAAW,MAAC,WAAU,UAAS;AAAA,QACxC,OAAO;AAAA,SACV;AAAA,MAGA,oBAAC,UAAK,MAAK,UAAS,WAAU,wCAC3B,mBACC,iCACG;AAAA,eAAO;AAAA,QAAS;AAAA,QACjB,oBAAC,YAAS,MAAM,MAAM,MAAM,UAAU,MAAM,UAAU,gBAAc,MAAC,MAAK,aACvE,iBAAO,WACV;AAAA,SACF,GAEJ;AAAA,OACF;AAAA,IACC,WAAW,OAAO,KACjB,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,mBACH;AAAA,KAEJ;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/account/data-export-setting.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { Download } from \"lucide-react\";\n\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport { TextLink } from \"../components/text-link\";\nimport { Button, Card } from \"../components/ui\";\nimport { englishWait, isRateLimited, retryAfterSeconds } from \"../auth/auth-errors\";\nimport { CARD_DESCRIPTION_CLASS, settle, useMounted } from \"./account-parts\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string {@link DataExportSetting} renders — the `dataExport` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. */\nexport interface DataExportLabels {\n /** The card's title. */\n title: string;\n /** What the download is. The app's own sentence (`description`) follows it. */\n description: string;\n /** The button. */\n download: string;\n /** Said once the file was handed to the browser. */\n started: string;\n /** The link under it that saves the same file again, for a browser that held the\n * download back. */\n saveAgain: string;\n /** The export was throttled — HTTP 429 (§6.5: once a minute) — given its\n * `Retry-After` wait in seconds, or `undefined` without one. */\n rateLimited: (seconds?: number) => string;\n /** Any other failure. */\n failed: string;\n}\n\nexport const DEFAULT_DATA_EXPORT_LABELS: DataExportLabels = {\n title: \"Export your data\",\n description: \"Download a copy of your account’s data as a JSON file.\",\n download: \"Download my data\",\n started: \"Your download has started.\",\n saveAgain: \"Didn’t start? Save the file\",\n rateLimited: (seconds) =>\n seconds && seconds > 0\n ? `You exported your data a moment ago. Try again in ${englishWait(seconds)}.`\n : \"You exported your data a moment ago. Please try again in a minute.\",\n failed: \"The export failed. Please try again.\",\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\n/**\n * What {@link DataExportSettingProps.onExport} resolves with: the file itself — a `Blob`\n * (axios' `responseType: \"blob\"`, `await res.blob()`) — or a URL the browser fetches\n * itself (a signed link), with the file name to save it under.\n */\nexport type DataExportFile = Blob | { url: string; filename?: string };\n\nexport interface DataExportSettingProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /**\n * Fetch the export (`GET /auth/me/export`, §6.5). Resolve with the file — the card\n * saves it under `filename` — or reject with the client's error: a 429 (the export is\n * throttled to once a minute) says `rateLimited`, anything else (a demo account's 403)\n * goes through `describeError`, else `failed`.\n */\n onExport: () => Promise<DataExportFile>;\n /**\n * The app's sentence under the kit's — what the export holds and what it doesn't.\n * kastlan's: \"Your account; your company's records are your company's, ask them.\"\n */\n description?: ReactNode;\n /** The name the file is saved under. Default `account-export-YYYY-MM-DD.json` (the\n * local day); a `{ url, filename }` answer's own name wins. */\n filename?: string;\n /** The app's own words for a failure, or `undefined` for the kit's. Asked first. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: Partial<DataExportLabels>;\n}\n\ninterface Saved {\n href: string;\n filename: string;\n /** An object URL of ours, revoked when it is replaced or the card goes. */\n owned: boolean;\n}\n\n/** `account-export-2026-10-07.json`, the local day — the one a person looks for. */\nfunction defaultFilename(now = new Date()): string {\n const pad = (n: number) => String(n).padStart(2, \"0\");\n return `account-export-${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}.json`;\n}\n\n/** A `{ url }` answer, as opposed to a Blob or anything else. */\nfunction isUrlAnswer(value: unknown): value is { url: string; filename?: string } {\n return typeof value === \"object\" && value !== null && typeof (value as { url?: unknown }).url === \"string\";\n}\n\n/** Hand `href` to the browser as a download named `filename`: a link with `download`,\n * clicked once and taken out again — the one way a page saves a file without a new\n * tab that would show the JSON instead. */\nfunction startDownload(href: string, filename: string) {\n const link = document.createElement(\"a\");\n link.href = href;\n link.download = filename;\n link.rel = \"noopener\";\n link.hidden = true;\n document.body.appendChild(link);\n link.click();\n link.remove();\n}\n\n/**\n * The account's data as a download (docs/user-admin-harmonization.md §6.5, §2.2): what it\n * is, the app's sentence on what it holds, and one button.\n *\n * **The kit saves the file.** `onExport` fetches it — the request is the app's, with its\n * auth (auth §8) — and resolves with a `Blob` or a `{ url }`; the card hands it to the\n * browser through a link with a `download` name, so it lands as `account-export-….json`\n * rather than opening as a page of JSON. A `Blob` becomes an object URL, revoked when\n * the next export replaces it or the card unmounts.\n *\n * The click comes after an `await`, which some browsers count as no longer the\n * person's: \"Didn't start? Save the file\" stays under the confirmation, a real link to\n * the same file that the person clicks themselves.\n *\n * **The throttle** (once a minute, §6.5) is a 429, said as such; the app's\n * `describeError` comes first (keksdose's demo account answers 403).\n */\nexport function DataExportSetting({\n onExport,\n description,\n filename,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: DataExportSettingProps) {\n const labels = useKitLabels(\"dataExport\", DEFAULT_DATA_EXPORT_LABELS, labelsProp);\n const [busy, setBusy] = useState(false);\n const [saved, setSaved] = useState<Saved | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n\n // Our object URL lives as long as the \"Save the file\" link that points at it.\n useEffect(() => {\n if (!saved?.owned) return;\n const href = saved.href;\n return () => URL.revokeObjectURL(href);\n }, [saved]);\n\n const run = () => {\n if (busy) return;\n setBusy(true);\n setFailure(null);\n // The last file's link goes (and its object URL with it): it would sit beside this\n // export's answer as if it were it.\n setSaved(null);\n settle(onExport).then(\n (answer) => {\n if (!mounted.current) return;\n setBusy(false);\n let next: Saved;\n if (answer instanceof Blob) {\n next = { href: URL.createObjectURL(answer), filename: filename ?? defaultFilename(), owned: true };\n } else if (isUrlAnswer(answer)) {\n next = { href: answer.url, filename: answer.filename ?? filename ?? defaultFilename(), owned: false };\n } else {\n // Nothing to save: an app that resolved with its response object, say.\n setFailure(labels.failed);\n return;\n }\n setSaved(next);\n startDownload(next.href, next.filename);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusy(false);\n const own = describeError?.(error);\n setFailure(\n hasMessage(own) ? own : isRateLimited(error) ? labels.rateLimited(retryAfterSeconds(error)) : labels.failed,\n );\n },\n );\n };\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div className=\"space-y-1\">\n <SettingsCardTitle>{labels.title}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.description}</div>\n {hasMessage(description) && <div className={CARD_DESCRIPTION_CLASS}>{description}</div>}\n </div>\n <div className=\"flex flex-wrap items-center gap-x-3 gap-y-2\">\n <Button type=\"button\" variant=\"secondary\" pending={busy} onClick={run}>\n <Download aria-hidden className=\"size-4\" />\n {labels.download}\n </Button>\n {/* Always in the tree, so the confirmation that appears in it is announced; in\n the button's row, so an empty one takes no line of its own. */}\n <span role=\"status\" className=\"text-xs text-[var(--text-secondary)]\">\n {saved && (\n <>\n {labels.started}{\" \"}\n <TextLink href={saved.href} download={saved.filename} reloadDocument tone=\"secondary\">\n {labels.saveAgain}\n </TextLink>\n </>\n )}\n </span>\n </div>\n {hasMessage(failure) && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure}\n </AlertBanner>\n )}\n </Card>\n );\n}\n"],"mappings":";AA4LM,SAcM,UAbJ,KADF;AA5LN,SAAS,WAAW,gBAAgB;AAEpC,SAAS,gBAAgB;AAEzB,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,QAAQ,YAAY;AAC7B,SAAS,aAAa,eAAe,yBAAyB;AAC9D,SAAS,wBAAwB,QAAQ,kBAAkB;AAC3D,SAAS,yBAAyB;AAyB3B,MAAM,6BAA+C;AAAA,EAC1D,OAAO;AAAA,EACP,aAAa;AAAA,EACb,UAAU;AAAA,EACV,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa,CAAC,YACZ,WAAW,UAAU,IACjB,qDAAqD,YAAY,OAAO,CAAC,MACzE;AAAA,EACN,QAAQ;AACV;AAwCA,SAAS,gBAAgB,MAAM,oBAAI,KAAK,GAAW;AACjD,QAAM,MAAM,CAAC,MAAc,OAAO,CAAC,EAAE,SAAS,GAAG,GAAG;AACpD,SAAO,kBAAkB,IAAI,YAAY,CAAC,IAAI,IAAI,IAAI,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,QAAQ,CAAC,CAAC;AAC7F;AAGA,SAAS,YAAY,OAA6D;AAChF,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAQ,MAA4B,QAAQ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,sBAAc,KAAK,MAAM,KAAK,QAAQ;AAAA,MACxC;AAAA,MACA,CAAC,UAAmB;AAClB,YAAI,CAAC,QAAQ,QAAS;AACtB,gBAAQ,KAAK;AACb,cAAM,MAAM,gBAAgB,KAAK;AACjC;AAAA,UACE,WAAW,GAAG,IAAI,MAAM,cAAc,KAAK,IAAI,OAAO,YAAY,kBAAkB,KAAK,CAAC,IAAI,OAAO;AAAA,QACvG;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SACE,qBAAC,QAAM,GAAG,MAAM,WAAW,GAAG,iBAAiB,SAAS,GACtD;AAAA,yBAAC,SAAI,WAAU,aACb;AAAA,0BAAC,qBAAmB,iBAAO,OAAM;AAAA,MACjC,oBAAC,SAAI,WAAW,wBAAyB,iBAAO,aAAY;AAAA,MAC3D,WAAW,WAAW,KAAK,oBAAC,SAAI,WAAW,wBAAyB,uBAAY;AAAA,OACnF;AAAA,IACA,qBAAC,SAAI,WAAU,+CACb;AAAA,2BAAC,UAAO,MAAK,UAAS,SAAQ,aAAY,SAAS,MAAM,SAAS,KAChE;AAAA,4BAAC,YAAS,eAAW,MAAC,WAAU,UAAS;AAAA,QACxC,OAAO;AAAA,SACV;AAAA,MAGA,oBAAC,UAAK,MAAK,UAAS,WAAU,wCAC3B,mBACC,iCACG;AAAA,eAAO;AAAA,QAAS;AAAA,QACjB,oBAAC,YAAS,MAAM,MAAM,MAAM,UAAU,MAAM,UAAU,gBAAc,MAAC,MAAK,aACvE,iBAAO,WACV;AAAA,SACF,GAEJ;AAAA,OACF;AAAA,IACC,WAAW,OAAO,KACjB,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,mBACH;AAAA,KAEJ;AAEJ;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import 'react';
2
- export { cq as DEFAULT_DELETE_ACCOUNT_LABELS, cQ as DeleteAccountConsequence, cR as DeleteAccountLabels, cS as DeleteAccountSetting, cT as DeleteAccountSettingProps, cU as DeleteAccountValues, cV as DeletionMode } from '../delete-account-setting-CGVMckMw.js';
2
+ export { cq as DEFAULT_DELETE_ACCOUNT_LABELS, cQ as DeleteAccountConsequence, cR as DeleteAccountLabels, cS as DeleteAccountSetting, cT as DeleteAccountSettingProps, cU as DeleteAccountValues, cV as DeletionMode } from '../delete-account-setting-CpIhzxxZ.js';
3
3
  import '../components/tooltip.js';
4
4
  import '../hooks/use-anchored-rect.js';
5
5
  import '../lib/clipping.js';
@@ -54,6 +54,8 @@ import '../components/image-grid.js';
54
54
  import '../components/lightbox.js';
55
55
  import '../components/write-lock.js';
56
56
  import '../auth/sign-in-form.js';
57
+ import '../landing/access.js';
58
+ import '../landing/landing-labels.js';
57
59
  import '../shell/topbar-controls.js';
58
60
  import '../theme/palette-presets.js';
59
61
  import '../theme/chart-palette.js';
@@ -75,6 +77,8 @@ import './data-export-setting.js';
75
77
  import '../components/account-chips.js';
76
78
  import '../admin/admin-parts.js';
77
79
  import '../admin/admin-action-log.js';
80
+ import '../settings/settings-labels.js';
81
+ import '../demo/demo-labels.js';
78
82
  import '../components/reauth-dialog.js';
79
83
  import '../components/server-wake.js';
80
84
  import '../lib/server-wake.js';
@@ -16,7 +16,8 @@ import {
16
16
  import { Card } from "../components/ui.js";
17
17
  import { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from "../auth/auth-errors.js";
18
18
  import { useFocusWhen } from "../auth/status-parts.js";
19
- import { CARD_DESCRIPTION_CLASS, CARD_TITLE_CLASS, refusalCompanies, settle, useMounted } from "./account-parts.js";
19
+ import { CARD_DESCRIPTION_CLASS, refusalCompanies, settle, useMounted } from "./account-parts.js";
20
+ import { SettingsCardTitle } from "../settings/settings-heading.js";
20
21
  const DEFAULT_DELETE_ACCOUNT_LABELS = {
21
22
  title: "Delete account",
22
23
  afterDays: (days) => days === 1 ? "Your account is deactivated at once and erased for good 1 day later." : `Your account is deactivated at once and erased for good ${days} days later.`,
@@ -135,7 +136,7 @@ function DeleteAccountSetting({
135
136
  className: cn("p-4 space-y-3", className),
136
137
  children: [
137
138
  /* @__PURE__ */ jsxs("div", { children: [
138
- /* @__PURE__ */ jsx("div", { className: CARD_TITLE_CLASS, children: labels.title }),
139
+ /* @__PURE__ */ jsx(SettingsCardTitle, { children: labels.title }),
139
140
  /* @__PURE__ */ jsx("div", { className: CARD_DESCRIPTION_CLASS, children: modeSentence })
140
141
  ] }),
141
142
  done ? /* @__PURE__ */ jsxs("div", { ref: doneRef, tabIndex: -1, role: "status", className: "flex items-start gap-2 text-sm outline-none", children: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/account/delete-account-setting.tsx"],"sourcesContent":["import { isValidElement, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { UserX } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport {\n CurrentPasswordInput,\n DangerConfirm,\n DEFAULT_DANGER_CONFIRM_LABELS,\n TypedConfirmField,\n typedMatches,\n} from \"../components/danger-confirm\";\nimport type { DangerConsequence } from \"../components/danger-confirm\";\nimport { Card } from \"../components/ui\";\nimport { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from \"../auth/auth-errors\";\nimport { useFocusWhen } from \"../auth/status-parts\";\nimport { CARD_DESCRIPTION_CLASS, CARD_TITLE_CLASS, refusalCompanies, settle, useMounted } from \"./account-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/**\n * Every string {@link DeleteAccountSetting} renders — the `deleteAccount` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. The confirm's\n * Cancel, \"Password\" and \"Type … to confirm\" are `dangerConfirm`'s.\n */\nexport interface DeleteAccountLabels {\n /** The card's title. */\n title: string;\n /** Mode `after_days`, given the days: what happens and when. */\n afterDays: (days: number) => string;\n /** Mode `operator`: what happens, and who erases it. */\n operator: string;\n /** The button that opens the confirm. */\n arm: string;\n /** The confirm's warning, over the consequences. */\n prompt: string;\n /** The line in the consequences when `handOverCount` is given (Kurvenschmiede, §2.7),\n * given the count. */\n handOver: (count: number) => string;\n /** The button that sends it. */\n confirm: string;\n /** Said once the request is accepted — the app signs out next. */\n done: string;\n /** `password_incorrect` (server-kit's `400` for a wrong current password), under the\n * password field. */\n wrongPassword: string;\n /** `confirmation_mismatch` — the server did not take the typed address as the\n * account's — under the address field. */\n confirmationMismatch: string;\n /** `last_admin` — the account is the last active admin. */\n lastAdmin: string;\n /** `last_admin` naming the companies (kastlan checks per company), given them as one\n * list in the reader's language (\"Example AG and Sample GmbH\"). */\n lastAdminOf: (companies: string) => string;\n /** `household_has_members` — keksdose's guard (§6.4). */\n householdHasMembers: string;\n /** A request was throttled — HTTP 429 — given its `Retry-After` wait in seconds, or\n * `undefined` without one. */\n rateLimited: (seconds?: number) => string;\n /** Any other failure. */\n failed: string;\n}\n\nexport const DEFAULT_DELETE_ACCOUNT_LABELS: DeleteAccountLabels = {\n title: \"Delete account\",\n afterDays: (days) =>\n days === 1\n ? \"Your account is deactivated at once and erased for good 1 day later.\"\n : `Your account is deactivated at once and erased for good ${days} days later.`,\n operator: \"Your account is deactivated at once, and an operator will erase it for good.\",\n arm: \"Delete account…\",\n prompt: \"You will be signed out on every device, and your account can no longer be used.\",\n handOver: (count) =>\n count === 1\n ? \"1 item others can see will pass to an administrator.\"\n : `${count} items others can see will pass to an administrator.`,\n confirm: \"Delete my account\",\n done: \"Your account is deactivated. You are being signed out.\",\n wrongPassword: \"The password is incorrect.\",\n confirmationMismatch: \"This is not your account’s address.\",\n lastAdmin: \"You are the last administrator. Make someone else an administrator first.\",\n lastAdminOf: (companies) =>\n `You are the last administrator of ${companies}. Make someone else an administrator there first.`,\n householdHasMembers:\n \"Your household has other members, so the account can’t be deleted here. Please write to the operator.\",\n rateLimited: englishRateLimited,\n failed: \"Your account could not be deleted. Please try again.\",\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\n/** What happens after the deactivation (§2.1, §6.4) — the app's setting. */\nexport type DeletionMode = \"after_days\" | \"operator\";\n\n/** What {@link DeleteAccountSettingProps.onRequest} gets: the `POST /auth/me/deletion`\n * body. */\nexport interface DeleteAccountValues {\n /** As typed. */\n password: string;\n /** The address as TYPED, trimmed — the server re-checks it against the account\n * (server-kit's `confirm_email_matches`), as keksdose's admin actions do. */\n confirmEmail: string;\n}\n\n/** One line of the consequences: a node of the app's, or a {@link DangerConsequence}\n * for a key of its own and the `severe` mark. */\nexport type DeleteAccountConsequence = ReactNode | DangerConsequence;\n\nexport interface DeleteAccountSettingProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** The account's address — the text to type. */\n email: string;\n /** `\"after_days\"` (keksdose, Kurvenschmiede: erased by a scheduled job) or\n * `\"operator\"` (kastlan: company data is involved, an operator erases it). */\n mode: DeletionMode;\n /** With `after_days`: how many. Default 30 (§2.1). */\n days?: number;\n /**\n * What goes, in the app's words (§6.4: \"the app's own list\") — derived from the\n * account's own facts where it can be: keksdose's \"Budget X will be deleted; its 2\n * guests are told\", rather than the worst case for everybody.\n */\n consequences?: readonly DeleteAccountConsequence[];\n /** Kurvenschmiede (§2.7): how many owned items others can see — they pass to the\n * first active admin at erasure. A line of its own in the consequences; 0 or left\n * out, none. */\n handOverCount?: number;\n /**\n * The confirm was answered: send `POST /auth/me/deletion {password, confirm_email}`.\n * Resolve once it is accepted — the card says \"You are being signed out\" — and then\n * sign the user out: the server ended every session with the deactivation. Reject\n * with the client's error: `password_incorrect` under the password,\n * `confirmation_mismatch` under the address, `last_admin` (with kastlan's\n * `companies`) and `household_has_members` above the buttons, a 429 as\n * `rateLimited`, anything else (a demo account's 403, an app's own code) through\n * `describeError`, else `failed`. The confirm stays open with what was typed, for a\n * retry.\n */\n onRequest: (values: DeleteAccountValues) => Promise<unknown> | void;\n /** The app's own words for a failure, or `undefined` for the kit's. Asked first, for\n * every failure — kastlan's `last_admin` names the companies. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: Partial<DeleteAccountLabels>;\n}\n\n/** Whether an item is a `{ text }` line rather than a node — a React element is an\n * object too, and so would a `{ text }` lookalike be, so the element test comes first. */\nfunction isConsequence(item: DeleteAccountConsequence): item is DangerConsequence {\n return typeof item === \"object\" && item !== null && !isValidElement(item) && \"text\" in item;\n}\n\n/**\n * Deleting one's own account (docs/user-admin-harmonization.md §6.4, §2.1): what it does,\n * the password, the typed address — then the app signs out.\n *\n * **Two stages, said before the button.** The request DEACTIVATES the account at once\n * (no sign-in, every session ended, marked for deletion); the erasure follows per the\n * app's `mode` — \"erased for good 30 days later\" (`after_days`, a scheduled job) or \"an\n * operator will erase it\" (`operator`, kastlan, where company records are involved).\n * The sentence is under the title, so it is read before anything is pressed.\n *\n * **The confirm is a {@link DangerConfirm}** with the two guards of every \"type the\n * address\" rule in the apps: the address typed (compared caseless, as in all of them)\n * and the password. They are the tile's own {@link TypedConfirmField} and\n * {@link CurrentPasswordInput}, drawn in its fields slot and held by\n * `confirmDisabledReason` with the tile's own sentences, rather than its built-in\n * `phrase` / `requirePassword` — those have no error of their own, and a wrong password\n * belongs under the password. Its consequences are the app's list, plus\n * Kurvenschmiede's hand-over line (`handOverCount`, §2.7: shared work goes to an\n * administrator, never a refusal). The typed address goes to `onRequest` as typed, so\n * the server re-checks it (`confirm_email_matches`).\n *\n * **Refusals** (§6.4) are read by code ({@link authErrorCode}): `password_incorrect` (a\n * `400`, so an app's 401 handling never signs the person out over a typo) under the\n * password, `confirmation_mismatch` under the address, `last_admin` — naming kastlan's\n * companies when the answer lists them — and keksdose's `household_has_members` guard\n * above the buttons; a 429; and the rest in the app's words. The confirm stays open with\n * what was typed, for a retry; Cancel wipes it.\n *\n * **After success** the card says the account is deactivated and the person is being\n * signed out — the app's to do, since the kit sends nothing (auth §8).\n */\nexport function DeleteAccountSetting({\n email,\n mode,\n days = 30,\n consequences,\n handOverCount,\n onRequest,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: DeleteAccountSettingProps) {\n const labels = useKitLabels(\"deleteAccount\", DEFAULT_DELETE_ACCOUNT_LABELS, labelsProp);\n // The guards speak the tile's words, so \"Type “…” to confirm\" and \"Enter your password\n // to confirm\" are translated once, in `dangerConfirm`.\n const guardLabels = useKitLabels(\"dangerConfirm\", DEFAULT_DANGER_CONFIRM_LABELS);\n const locale = useKitLocale();\n const [typed, setTyped] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n const [busy, setBusy] = useState(false);\n const [fieldError, setFieldError] = useState<\"email\" | \"password\" | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const [done, setDone] = useState(false);\n const mounted = useMounted();\n const typedRef = useRef<HTMLInputElement>(null);\n const passwordRef = useRef<HTMLInputElement>(null);\n const doneRef = useRef<HTMLDivElement>(null);\n // The tile went with the press; the answer takes the focus, so it is read out.\n useFocusWhen(done, doneRef);\n\n const modeSentence = mode === \"operator\" ? labels.operator : labels.afterDays(days);\n\n const lines: (string | DangerConsequence)[] = (consequences ?? [])\n // `{cond && \"…\"}` lines that came out empty are no lines.\n .filter((item) => item !== null && item !== undefined && item !== false && item !== \"\")\n .map((item, index) => (isConsequence(item) ? item : { key: `app-${index}`, text: item }));\n if (handOverCount !== undefined && handOverCount > 0) {\n lines.push({ key: \"hand-over\", text: labels.handOver(handOverCount) });\n }\n\n // The first guard still open, in the order the fields are drawn — DangerConfirm's rule.\n const held = !typedMatches(typed, email, \"caseless\")\n ? typeof guardLabels.needsPhrase === \"function\"\n ? guardLabels.needsPhrase(email)\n : guardLabels.needsPhrase\n : password === \"\"\n ? guardLabels.needsPassword\n : undefined;\n\n const present = (error: unknown) => {\n const own = describeError?.(error);\n if (hasMessage(own)) {\n setFailure(own);\n return;\n }\n if (isRateLimited(error)) {\n setFailure(labels.rateLimited(retryAfterSeconds(error)));\n return;\n }\n const code = authErrorCode(error);\n // `invalid_credentials` too, for a server that answered a wrong password so before\n // server-kit 0.4.0 named `password_incorrect`.\n if (code === \"password_incorrect\" || code === \"invalid_credentials\") {\n setFieldError(\"password\");\n passwordRef.current?.focus();\n return;\n }\n if (code === \"confirmation_mismatch\" || code === \"confirmation_required\") {\n setFieldError(\"email\");\n typedRef.current?.focus();\n return;\n }\n if (code === \"last_admin\") {\n const companies = refusalCompanies(error);\n setFailure(\n companies\n ? labels.lastAdminOf(new Intl.ListFormat(locale, { type: \"conjunction\" }).format(companies))\n : labels.lastAdmin,\n );\n return;\n }\n setFailure(code === \"household_has_members\" ? labels.householdHasMembers : labels.failed);\n };\n\n const confirm = () => {\n setFailure(null);\n setFieldError(null);\n setBusy(true);\n const values: DeleteAccountValues = { password, confirmEmail: typed.trim() };\n return settle(() => onRequest(values)).then(\n () => {\n if (!mounted.current) return;\n setBusy(false);\n setDone(true);\n },\n (error: unknown) => {\n if (mounted.current) {\n setBusy(false);\n present(error);\n }\n // Rejected again, so DangerConfirm stays armed with what was typed.\n throw error;\n },\n );\n };\n\n // A disarmed tile holds no password — DangerConfirm's own rule, for the fields it\n // does not own here.\n const disarmed = (armed: boolean) => {\n if (armed) return;\n setTyped(\"\");\n setPassword(\"\");\n setFieldError(null);\n setFailure(null);\n };\n\n return (\n <Card\n {...rest}\n data-state={done ? \"done\" : \"form\"}\n tone=\"danger\"\n className={cn(\"p-4 space-y-3\", className)}\n >\n <div>\n <div className={CARD_TITLE_CLASS}>{labels.title}</div>\n <div className={CARD_DESCRIPTION_CLASS}>{modeSentence}</div>\n </div>\n {done ? (\n <div ref={doneRef} tabIndex={-1} role=\"status\" className=\"flex items-start gap-2 text-sm outline-none\">\n <UserX aria-hidden className=\"mt-0.5 size-4 shrink-0 text-[var(--text-muted)]\" />\n <span>{labels.done}</span>\n </div>\n ) : (\n <>\n <DangerConfirm\n commit\n armLabel={labels.arm}\n prompt={labels.prompt}\n consequences={lines}\n confirmLabel={labels.confirm}\n confirmDisabledReason={held}\n busy={busy}\n onArmedChange={disarmed}\n onConfirm={confirm}\n >\n <TypedConfirmField\n ref={typedRef}\n target={email}\n match=\"caseless\"\n value={typed}\n onValueChange={(next) => {\n setTyped(next);\n if (fieldError === \"email\") setFieldError(null);\n }}\n error={fieldError === \"email\" ? labels.confirmationMismatch : undefined}\n busy={busy}\n />\n <CurrentPasswordInput\n ref={passwordRef}\n value={password}\n onValueChange={(next) => {\n setPassword(next);\n if (fieldError === \"password\") setFieldError(null);\n }}\n error={fieldError === \"password\" ? labels.wrongPassword : undefined}\n busy={busy}\n />\n </DangerConfirm>\n {hasMessage(failure) && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure}\n </AlertBanner>\n )}\n </>\n )}\n </Card>\n );\n}\n"],"mappings":";AAmTM,SAUE,UATA,KADF;AAnTN,SAAS,gBAAgB,QAAQ,gBAAgB;AAEjD,SAAS,aAAa;AAEtB,SAAS,cAAc,oBAAoB;AAC3C,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,YAAY;AACrB,SAAS,eAAe,oBAAoB,eAAe,yBAAyB;AACpF,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB,kBAAkB,kBAAkB,QAAQ,kBAAkB;AA+CxF,MAAM,gCAAqD;AAAA,EAChE,OAAO;AAAA,EACP,WAAW,CAAC,SACV,SAAS,IACL,yEACA,2DAA2D,IAAI;AAAA,EACrE,UAAU;AAAA,EACV,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,UAAU,CAAC,UACT,UAAU,IACN,yDACA,GAAG,KAAK;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AAAA,EACN,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,WAAW;AAAA,EACX,aAAa,CAAC,cACZ,qCAAqC,SAAS;AAAA,EAChD,qBACE;AAAA,EACF,aAAa;AAAA,EACb,QAAQ;AACV;AA2DA,SAAS,cAAc,MAA2D;AAChF,SAAO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Ac,IAAI;AAAA,oBACnD;AAAA,oBACA,OAAO,eAAe,aAAa,OAAO,gBAAgB;AAAA,oBAC1D;AAAA;AAAA,gBACF;AAAA;AAAA;AAAA,UACF;AAAA,UACC,WAAW,OAAO,KACjB,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,mBACH;AAAA,WAEJ;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/account/delete-account-setting.tsx"],"sourcesContent":["import { isValidElement, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { UserX } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport {\n CurrentPasswordInput,\n DangerConfirm,\n DEFAULT_DANGER_CONFIRM_LABELS,\n TypedConfirmField,\n typedMatches,\n} from \"../components/danger-confirm\";\nimport type { DangerConsequence } from \"../components/danger-confirm\";\nimport { Card } from \"../components/ui\";\nimport { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from \"../auth/auth-errors\";\nimport { useFocusWhen } from \"../auth/status-parts\";\nimport { CARD_DESCRIPTION_CLASS, refusalCompanies, settle, useMounted } from \"./account-parts\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/**\n * Every string {@link DeleteAccountSetting} renders — the `deleteAccount` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. The confirm's\n * Cancel, \"Password\" and \"Type … to confirm\" are `dangerConfirm`'s.\n */\nexport interface DeleteAccountLabels {\n /** The card's title. */\n title: string;\n /** Mode `after_days`, given the days: what happens and when. */\n afterDays: (days: number) => string;\n /** Mode `operator`: what happens, and who erases it. */\n operator: string;\n /** The button that opens the confirm. */\n arm: string;\n /** The confirm's warning, over the consequences. */\n prompt: string;\n /** The line in the consequences when `handOverCount` is given (Kurvenschmiede, §2.7),\n * given the count. */\n handOver: (count: number) => string;\n /** The button that sends it. */\n confirm: string;\n /** Said once the request is accepted — the app signs out next. */\n done: string;\n /** `password_incorrect` (server-kit's `400` for a wrong current password), under the\n * password field. */\n wrongPassword: string;\n /** `confirmation_mismatch` — the server did not take the typed address as the\n * account's — under the address field. */\n confirmationMismatch: string;\n /** `last_admin` — the account is the last active admin. */\n lastAdmin: string;\n /** `last_admin` naming the companies (kastlan checks per company), given them as one\n * list in the reader's language (\"Example AG and Sample GmbH\"). */\n lastAdminOf: (companies: string) => string;\n /** `household_has_members` — keksdose's guard (§6.4). */\n householdHasMembers: string;\n /** A request was throttled — HTTP 429 — given its `Retry-After` wait in seconds, or\n * `undefined` without one. */\n rateLimited: (seconds?: number) => string;\n /** Any other failure. */\n failed: string;\n}\n\nexport const DEFAULT_DELETE_ACCOUNT_LABELS: DeleteAccountLabels = {\n title: \"Delete account\",\n afterDays: (days) =>\n days === 1\n ? \"Your account is deactivated at once and erased for good 1 day later.\"\n : `Your account is deactivated at once and erased for good ${days} days later.`,\n operator: \"Your account is deactivated at once, and an operator will erase it for good.\",\n arm: \"Delete account…\",\n prompt: \"You will be signed out on every device, and your account can no longer be used.\",\n handOver: (count) =>\n count === 1\n ? \"1 item others can see will pass to an administrator.\"\n : `${count} items others can see will pass to an administrator.`,\n confirm: \"Delete my account\",\n done: \"Your account is deactivated. You are being signed out.\",\n wrongPassword: \"The password is incorrect.\",\n confirmationMismatch: \"This is not your account’s address.\",\n lastAdmin: \"You are the last administrator. Make someone else an administrator first.\",\n lastAdminOf: (companies) =>\n `You are the last administrator of ${companies}. Make someone else an administrator there first.`,\n householdHasMembers:\n \"Your household has other members, so the account can’t be deleted here. Please write to the operator.\",\n rateLimited: englishRateLimited,\n failed: \"Your account could not be deleted. Please try again.\",\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\n/** What happens after the deactivation (§2.1, §6.4) — the app's setting. */\nexport type DeletionMode = \"after_days\" | \"operator\";\n\n/** What {@link DeleteAccountSettingProps.onRequest} gets: the `POST /auth/me/deletion`\n * body. */\nexport interface DeleteAccountValues {\n /** As typed. */\n password: string;\n /** The address as TYPED, trimmed — the server re-checks it against the account\n * (server-kit's `confirm_email_matches`), as keksdose's admin actions do. */\n confirmEmail: string;\n}\n\n/** One line of the consequences: a node of the app's, or a {@link DangerConsequence}\n * for a key of its own and the `severe` mark. */\nexport type DeleteAccountConsequence = ReactNode | DangerConsequence;\n\nexport interface DeleteAccountSettingProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** The account's address — the text to type. */\n email: string;\n /** `\"after_days\"` (keksdose, Kurvenschmiede: erased by a scheduled job) or\n * `\"operator\"` (kastlan: company data is involved, an operator erases it). */\n mode: DeletionMode;\n /** With `after_days`: how many. Default 30 (§2.1). */\n days?: number;\n /**\n * What goes, in the app's words (§6.4: \"the app's own list\") — derived from the\n * account's own facts where it can be: keksdose's \"Budget X will be deleted; its 2\n * guests are told\", rather than the worst case for everybody.\n */\n consequences?: readonly DeleteAccountConsequence[];\n /** Kurvenschmiede (§2.7): how many owned items others can see — they pass to the\n * first active admin at erasure. A line of its own in the consequences; 0 or left\n * out, none. */\n handOverCount?: number;\n /**\n * The confirm was answered: send `POST /auth/me/deletion {password, confirm_email}`.\n * Resolve once it is accepted — the card says \"You are being signed out\" — and then\n * sign the user out: the server ended every session with the deactivation. Reject\n * with the client's error: `password_incorrect` under the password,\n * `confirmation_mismatch` under the address, `last_admin` (with kastlan's\n * `companies`) and `household_has_members` above the buttons, a 429 as\n * `rateLimited`, anything else (a demo account's 403, an app's own code) through\n * `describeError`, else `failed`. The confirm stays open with what was typed, for a\n * retry.\n */\n onRequest: (values: DeleteAccountValues) => Promise<unknown> | void;\n /** The app's own words for a failure, or `undefined` for the kit's. Asked first, for\n * every failure — kastlan's `last_admin` names the companies. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: Partial<DeleteAccountLabels>;\n}\n\n/** Whether an item is a `{ text }` line rather than a node — a React element is an\n * object too, and so would a `{ text }` lookalike be, so the element test comes first. */\nfunction isConsequence(item: DeleteAccountConsequence): item is DangerConsequence {\n return typeof item === \"object\" && item !== null && !isValidElement(item) && \"text\" in item;\n}\n\n/**\n * Deleting one's own account (docs/user-admin-harmonization.md §6.4, §2.1): what it does,\n * the password, the typed address — then the app signs out.\n *\n * **Two stages, said before the button.** The request DEACTIVATES the account at once\n * (no sign-in, every session ended, marked for deletion); the erasure follows per the\n * app's `mode` — \"erased for good 30 days later\" (`after_days`, a scheduled job) or \"an\n * operator will erase it\" (`operator`, kastlan, where company records are involved).\n * The sentence is under the title, so it is read before anything is pressed.\n *\n * **The confirm is a {@link DangerConfirm}** with the two guards of every \"type the\n * address\" rule in the apps: the address typed (compared caseless, as in all of them)\n * and the password. They are the tile's own {@link TypedConfirmField} and\n * {@link CurrentPasswordInput}, drawn in its fields slot and held by\n * `confirmDisabledReason` with the tile's own sentences, rather than its built-in\n * `phrase` / `requirePassword` — those have no error of their own, and a wrong password\n * belongs under the password. Its consequences are the app's list, plus\n * Kurvenschmiede's hand-over line (`handOverCount`, §2.7: shared work goes to an\n * administrator, never a refusal). The typed address goes to `onRequest` as typed, so\n * the server re-checks it (`confirm_email_matches`).\n *\n * **Refusals** (§6.4) are read by code ({@link authErrorCode}): `password_incorrect` (a\n * `400`, so an app's 401 handling never signs the person out over a typo) under the\n * password, `confirmation_mismatch` under the address, `last_admin` — naming kastlan's\n * companies when the answer lists them — and keksdose's `household_has_members` guard\n * above the buttons; a 429; and the rest in the app's words. The confirm stays open with\n * what was typed, for a retry; Cancel wipes it.\n *\n * **After success** the card says the account is deactivated and the person is being\n * signed out — the app's to do, since the kit sends nothing (auth §8).\n */\nexport function DeleteAccountSetting({\n email,\n mode,\n days = 30,\n consequences,\n handOverCount,\n onRequest,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: DeleteAccountSettingProps) {\n const labels = useKitLabels(\"deleteAccount\", DEFAULT_DELETE_ACCOUNT_LABELS, labelsProp);\n // The guards speak the tile's words, so \"Type “…” to confirm\" and \"Enter your password\n // to confirm\" are translated once, in `dangerConfirm`.\n const guardLabels = useKitLabels(\"dangerConfirm\", DEFAULT_DANGER_CONFIRM_LABELS);\n const locale = useKitLocale();\n const [typed, setTyped] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n const [busy, setBusy] = useState(false);\n const [fieldError, setFieldError] = useState<\"email\" | \"password\" | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const [done, setDone] = useState(false);\n const mounted = useMounted();\n const typedRef = useRef<HTMLInputElement>(null);\n const passwordRef = useRef<HTMLInputElement>(null);\n const doneRef = useRef<HTMLDivElement>(null);\n // The tile went with the press; the answer takes the focus, so it is read out.\n useFocusWhen(done, doneRef);\n\n const modeSentence = mode === \"operator\" ? labels.operator : labels.afterDays(days);\n\n const lines: (string | DangerConsequence)[] = (consequences ?? [])\n // `{cond && \"…\"}` lines that came out empty are no lines.\n .filter((item) => item !== null && item !== undefined && item !== false && item !== \"\")\n .map((item, index) => (isConsequence(item) ? item : { key: `app-${index}`, text: item }));\n if (handOverCount !== undefined && handOverCount > 0) {\n lines.push({ key: \"hand-over\", text: labels.handOver(handOverCount) });\n }\n\n // The first guard still open, in the order the fields are drawn — DangerConfirm's rule.\n const held = !typedMatches(typed, email, \"caseless\")\n ? typeof guardLabels.needsPhrase === \"function\"\n ? guardLabels.needsPhrase(email)\n : guardLabels.needsPhrase\n : password === \"\"\n ? guardLabels.needsPassword\n : undefined;\n\n const present = (error: unknown) => {\n const own = describeError?.(error);\n if (hasMessage(own)) {\n setFailure(own);\n return;\n }\n if (isRateLimited(error)) {\n setFailure(labels.rateLimited(retryAfterSeconds(error)));\n return;\n }\n const code = authErrorCode(error);\n // `invalid_credentials` too, for a server that answered a wrong password so before\n // server-kit 0.4.0 named `password_incorrect`.\n if (code === \"password_incorrect\" || code === \"invalid_credentials\") {\n setFieldError(\"password\");\n passwordRef.current?.focus();\n return;\n }\n if (code === \"confirmation_mismatch\" || code === \"confirmation_required\") {\n setFieldError(\"email\");\n typedRef.current?.focus();\n return;\n }\n if (code === \"last_admin\") {\n const companies = refusalCompanies(error);\n setFailure(\n companies\n ? labels.lastAdminOf(new Intl.ListFormat(locale, { type: \"conjunction\" }).format(companies))\n : labels.lastAdmin,\n );\n return;\n }\n setFailure(code === \"household_has_members\" ? labels.householdHasMembers : labels.failed);\n };\n\n const confirm = () => {\n setFailure(null);\n setFieldError(null);\n setBusy(true);\n const values: DeleteAccountValues = { password, confirmEmail: typed.trim() };\n return settle(() => onRequest(values)).then(\n () => {\n if (!mounted.current) return;\n setBusy(false);\n setDone(true);\n },\n (error: unknown) => {\n if (mounted.current) {\n setBusy(false);\n present(error);\n }\n // Rejected again, so DangerConfirm stays armed with what was typed.\n throw error;\n },\n );\n };\n\n // A disarmed tile holds no password — DangerConfirm's own rule, for the fields it\n // does not own here.\n const disarmed = (armed: boolean) => {\n if (armed) return;\n setTyped(\"\");\n setPassword(\"\");\n setFieldError(null);\n setFailure(null);\n };\n\n return (\n <Card\n {...rest}\n data-state={done ? \"done\" : \"form\"}\n tone=\"danger\"\n className={cn(\"p-4 space-y-3\", className)}\n >\n <div>\n <SettingsCardTitle>{labels.title}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{modeSentence}</div>\n </div>\n {done ? (\n <div ref={doneRef} tabIndex={-1} role=\"status\" className=\"flex items-start gap-2 text-sm outline-none\">\n <UserX aria-hidden className=\"mt-0.5 size-4 shrink-0 text-[var(--text-muted)]\" />\n <span>{labels.done}</span>\n </div>\n ) : (\n <>\n <DangerConfirm\n commit\n armLabel={labels.arm}\n prompt={labels.prompt}\n consequences={lines}\n confirmLabel={labels.confirm}\n confirmDisabledReason={held}\n busy={busy}\n onArmedChange={disarmed}\n onConfirm={confirm}\n >\n <TypedConfirmField\n ref={typedRef}\n target={email}\n match=\"caseless\"\n value={typed}\n onValueChange={(next) => {\n setTyped(next);\n if (fieldError === \"email\") setFieldError(null);\n }}\n error={fieldError === \"email\" ? labels.confirmationMismatch : undefined}\n busy={busy}\n />\n <CurrentPasswordInput\n ref={passwordRef}\n value={password}\n onValueChange={(next) => {\n setPassword(next);\n if (fieldError === \"password\") setFieldError(null);\n }}\n error={fieldError === \"password\" ? labels.wrongPassword : undefined}\n busy={busy}\n />\n </DangerConfirm>\n {hasMessage(failure) && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure}\n </AlertBanner>\n )}\n </>\n )}\n </Card>\n );\n}\n"],"mappings":";AAoTM,SAUE,UATA,KADF;AApTN,SAAS,gBAAgB,QAAQ,gBAAgB;AAEjD,SAAS,aAAa;AAEtB,SAAS,cAAc,oBAAoB;AAC3C,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,YAAY;AACrB,SAAS,eAAe,oBAAoB,eAAe,yBAAyB;AACpF,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB,kBAAkB,QAAQ,kBAAkB;AAC7E,SAAS,yBAAyB;AA+C3B,MAAM,gCAAqD;AAAA,EAChE,OAAO;AAAA,EACP,WAAW,CAAC,SACV,SAAS,IACL,yEACA,2DAA2D,IAAI;AAAA,EACrE,UAAU;AAAA,EACV,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,UAAU,CAAC,UACT,UAAU,IACN,yDACA,GAAG,KAAK;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AAAA,EACN,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,WAAW;AAAA,EACX,aAAa,CAAC,cACZ,qCAAqC,SAAS;AAAA,EAChD,qBACE;AAAA,EACF,aAAa;AAAA,EACb,QAAQ;AACV;AA2DA,SAAS,cAAc,MAA2D;AAChF,SAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,eAAe,I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,gBAAgB;AAAA,oBAC1D;AAAA;AAAA,gBACF;AAAA;AAAA;AAAA,UACF;AAAA,UACC,WAAW,OAAO,KACjB,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,mBACH;AAAA,WAEJ;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
@@ -10,7 +10,8 @@ import { CurrentPasswordInput } from "../components/danger-confirm.js";
10
10
  import { Button, Card, Input } from "../components/ui.js";
11
11
  import { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from "../auth/auth-errors.js";
12
12
  import { emailParts, taggedEmail } from "../auth/email-tag.js";
13
- import { CARD_DESCRIPTION_CLASS, CARD_TITLE_CLASS, settle, useMounted } from "./account-parts.js";
13
+ import { CARD_DESCRIPTION_CLASS, settle, useMounted } from "./account-parts.js";
14
+ import { SettingsCardTitle } from "../settings/settings-heading.js";
14
15
  const DEFAULT_EMAIL_CHANGE_LABELS = {
15
16
  title: "Email address",
16
17
  current: "Current address",
@@ -107,7 +108,7 @@ function EmailChangeSetting({
107
108
  };
108
109
  return /* @__PURE__ */ jsxs(Card, { ...rest, "data-state": "pending", className: cn("p-4 space-y-3", className), children: [
109
110
  /* @__PURE__ */ jsxs("div", { children: [
110
- /* @__PURE__ */ jsx("div", { id: titleId, className: CARD_TITLE_CLASS, children: labels.title }),
111
+ /* @__PURE__ */ jsx(SettingsCardTitle, { id: titleId, children: labels.title }),
111
112
  /* @__PURE__ */ jsx("div", { className: cn(CARD_DESCRIPTION_CLASS, "break-all"), children: common.fieldValue(labels.current, currentEmail) })
112
113
  ] }),
113
114
  /* @__PURE__ */ jsxs("div", { ref: pendingRef, tabIndex: -1, className: "flex gap-2 outline-none", children: [
@@ -202,7 +203,7 @@ function EmailChangeSetting({
202
203
  };
203
204
  return /* @__PURE__ */ jsxs(Card, { ...rest, "data-state": confirmed ? "confirmed" : "form", className: cn("p-4 space-y-3", className), children: [
204
205
  /* @__PURE__ */ jsxs("div", { children: [
205
- /* @__PURE__ */ jsx("div", { id: titleId, className: CARD_TITLE_CLASS, children: labels.title }),
206
+ /* @__PURE__ */ jsx(SettingsCardTitle, { id: titleId, children: labels.title }),
206
207
  /* @__PURE__ */ jsx("div", { className: cn(CARD_DESCRIPTION_CLASS, "break-all"), children: common.fieldValue(labels.current, currentEmail) })
207
208
  ] }),
208
209
  confirmed && /* @__PURE__ */ jsxs(AlertBanner, { tone: "success", size: "sm", children: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/account/email-change-setting.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, FormEvent, ReactNode } from \"react\";\nimport { MailCheck } from \"lucide-react\";\n\nimport { DEFAULT_COMMON_LABELS, useKitLabels } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport { CurrentPasswordInput } from \"../components/danger-confirm\";\nimport { Button, Card, Input } from \"../components/ui\";\nimport { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from \"../auth/auth-errors\";\nimport { emailParts, taggedEmail } from \"../auth/email-tag\";\nimport { CARD_DESCRIPTION_CLASS, CARD_TITLE_CLASS, settle, useMounted } from \"./account-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string {@link EmailChangeSetting} renders — the `emailChange` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. */\nexport interface EmailChangeLabels {\n /** The card's title. */\n title: string;\n /** Names the address the account has now: \"Current address: ada@example.com\". */\n current: string;\n /** The new address's field. */\n newEmail: string;\n /** The password field. */\n password: string;\n /** Under the password field: why it is asked again. */\n passwordHint: string;\n /** The address-tag button (auth §4.5), given the exact address it would use. */\n emailTagUse: (address: string) => string;\n /** The line after the address-tag button. */\n emailTagHint: string;\n /** The submit button. */\n submit: string;\n /** Under the new address while it is the current one. */\n sameAsCurrent: string;\n /** `email_taken`, under the new address. */\n emailTaken: string;\n /** `password_incorrect`, under the password. */\n wrongPassword: string;\n /** The pending state, given the new address the link went to. */\n pending: (newEmail: string) => string;\n /** Under it, given the current address — which still signs in until the link is\n * confirmed. */\n pendingHint: (currentEmail: string) => string;\n /** Mails the link again. */\n resend: string;\n /** Said once it went. */\n resent: string;\n /** Drops the change; the current address stays. */\n cancel: string;\n /** The done state (`confirmed`), given the address the account has now. */\n confirmed: (email: string) => string;\n /** Under it (`passkeyNote`): a passkey's label in the authenticator keeps the old\n * address (§6.2). */\n passkeyNote: string;\n /** A request was throttled — HTTP 429 — given its `Retry-After` wait in seconds, or\n * `undefined` without one. */\n rateLimited: (seconds?: number) => string;\n /** Any other failure, of any of the three requests. */\n failed: string;\n}\n\nexport const DEFAULT_EMAIL_CHANGE_LABELS: EmailChangeLabels = {\n title: \"Email address\",\n current: \"Current address\",\n newEmail: \"New email address\",\n password: \"Current password\",\n passwordHint: \"Your address is how you sign in, so changing it takes your password.\",\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 submit: \"Change email address\",\n sameAsCurrent: \"This is already your address.\",\n emailTaken: \"An account with this email address already exists.\",\n wrongPassword: \"The password is incorrect.\",\n pending: (newEmail) => `Confirm the link we sent to ${newEmail}.`,\n pendingHint: (currentEmail) =>\n `Until you do, you keep signing in with ${currentEmail}. Check your spam folder too.`,\n resend: \"Send the link again\",\n resent: \"We sent the link again.\",\n cancel: \"Cancel the change\",\n confirmed: (email) => `Your email address is now ${email}.`,\n passkeyNote: \"Your passkeys keep working. Your device may still list them under your old address.\",\n rateLimited: englishRateLimited,\n failed: \"That didn’t work. Please try again.\",\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\n/** What {@link EmailChangeSettingProps.onRequest} gets: the `POST /auth/me/email` body. */\nexport interface EmailChangeValues {\n /** Trimmed. A `+tag` stays (auth §4.5); lower-casing is the server's. */\n newEmail: string;\n /** As typed. */\n password: string;\n}\n\n/** Which request failed — {@link EmailChangeSettingProps.describeError}'s second\n * argument. */\nexport type EmailChangeAction = \"request\" | \"resend\" | \"cancel\";\n\nexport interface EmailChangeSettingProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"onSubmit\"> {\n /** The account's address now. */\n currentEmail: string;\n /**\n * The address a change waits on, from the app's server state — so a reload, or\n * another tab, shows the pending state. `null`: none, whatever the card did. Left out\n * (`undefined`), the card keeps its own: pending from a resolved `onRequest` until a\n * resolved `onCancel`.\n */\n pendingEmail?: string | null;\n /**\n * The form was submitted: send `POST /auth/me/email {new_email, password}` (§6.2).\n * Resolve once the link is mailed — refresh `pendingEmail` first if the app passes\n * it — and the card shows \"Confirm the link we sent to …\". Reject with the client's\n * error: `email_taken` shows under the new address, `password_incorrect` (server-kit's\n * `400` for a wrong current password; an older `invalid_credentials` too) under the\n * password, a 429 as `rateLimited`, anything else as `failed` unless `describeError`\n * has the app's words.\n */\n onRequest: (values: EmailChangeValues) => Promise<unknown> | void;\n /** Mail the link again. Left out, no button. */\n onResend?: () => Promise<unknown> | void;\n /** Drop the pending change. Left out, no button. */\n onCancel?: () => Promise<unknown> | void;\n /**\n * The change was just confirmed — the app's confirm route (`POST /auth/me/email/confirm`)\n * came back here. Says \"Your email address is now …\" over the form, with\n * `passkeyNote`.\n */\n confirmed?: boolean;\n /** With `confirmed`: say that a passkey's label keeps the old address (§6.2). Default\n * `true`; `false` for an account without passkeys. */\n passkeyNote?: boolean;\n /**\n * The app's address tag (`\"kastlan\"`, auth §4.5): once the new address is plausible a\n * button under it offers the tagged form — the rule of `RegisterForm`, since this is\n * the person's own address. Never applied on its own. Left out, no offer.\n */\n emailTag?: string;\n /** The app's own words for a failure, or `undefined` for the kit's. Asked first, for\n * every failure (a demo account's 403, the device offline). */\n describeError?: (error: unknown, action: EmailChangeAction) => ReactNode | undefined;\n labels?: Partial<EmailChangeLabels>;\n}\n\ninterface Failure {\n action: EmailChangeAction;\n message: ReactNode;\n}\n\n/**\n * Changing the account's email address (docs/user-admin-harmonization.md §6.2, §2.5):\n * the current address, the new one, the password — then a pending state until the new\n * address confirms its link.\n *\n * **The new address must confirm before it takes effect.** The server mails a one-time\n * link to the NEW address (and a notice to the old one); until it is opened, the account\n * keeps the old address and signs in with it. So the card's answer to a request is not\n * \"changed\" but \"Confirm the link we sent to …\", with \"Send the link again\" and \"Cancel\n * the change\". The state is the server's: pass `pendingEmail` and a reload shows it too.\n *\n * **The password is asked again** because the address is the identity: whoever holds the\n * session must not move the account to a mailbox of their own. It is a\n * {@link CurrentPasswordInput}, so a password manager fills it and offers no new one.\n *\n * **The `+tag` offer** (`emailTag`) is RegisterForm's: the address is the person's own,\n * so `you+kastlan@…` is offered under the field, applied only on a click.\n *\n * **It never sends a request** (auth §8): `onRequest`, `onResend` and `onCancel` are the\n * app's, and their refusals are read by code — `email_taken` and `password_incorrect`\n * under their fields, which take the focus; a 429 as \"Too many attempts\". A wrong\n * password is a `400 password_incorrect`, never a 401: an app's client reads a 401 on a\n * signed-in route as an ended session, and would sign the person out for a typo.\n *\n * **Done** (`confirmed`): \"Your email address is now …\" and, unless `passkeyNote` is\n * off, that a passkey keeps its old label in the device's list — the authenticator\n * stored the name it was given, and only a new passkey carries the new one.\n */\nexport function EmailChangeSetting({\n currentEmail,\n pendingEmail,\n onRequest,\n onResend,\n onCancel,\n confirmed,\n passkeyNote = true,\n emailTag,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: EmailChangeSettingProps) {\n const labels = useKitLabels(\"emailChange\", DEFAULT_EMAIL_CHANGE_LABELS, labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const [newEmail, setNewEmail] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n const [ownPending, setOwnPending] = useState<string | null>(null);\n const [busy, setBusy] = useState<EmailChangeAction | null>(null);\n const [failure, setFailure] = useState<Failure | null>(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 [wrongPassword, setWrongPassword] = useState(false);\n const [resent, setResent] = useState(false);\n const mounted = useMounted();\n const titleId = useId();\n const tagHintId = useId();\n const emailRef = useRef<HTMLInputElement>(null);\n const passwordRef = useRef<HTMLInputElement>(null);\n const pendingRef = useRef<HTMLDivElement>(null);\n\n const pending = pendingEmail !== undefined ? pendingEmail : ownPending;\n const isPending = pending !== null && pending !== \"\";\n\n // The state swapped under the button that was pressed (the form for the pending\n // message, or back): the focus goes to what came in, never down to <body>. Only after\n // the person's own request — a pending state that arrives with the page takes nothing.\n const focusNext = useRef<\"pending\" | \"form\" | null>(null);\n useEffect(() => {\n const target = focusNext.current;\n if (target === \"pending\" && isPending) {\n focusNext.current = null;\n pendingRef.current?.focus();\n } else if (target === \"form\" && !isPending) {\n focusNext.current = null;\n emailRef.current?.focus();\n }\n }, [isPending]);\n\n const messageFor = (error: unknown, action: EmailChangeAction): ReactNode => {\n const own = describeError?.(error, action);\n if (hasMessage(own)) return own;\n return isRateLimited(error) ? labels.rateLimited(retryAfterSeconds(error)) : labels.failed;\n };\n\n /* ── The pending state ── */\n if (isPending) {\n const run = (action: \"resend\" | \"cancel\", call: () => unknown) => {\n if (busy) return;\n setBusy(action);\n setFailure(null);\n setResent(false);\n settle(call).then(\n () => {\n if (!mounted.current) return;\n setBusy(null);\n if (action === \"resend\") {\n setResent(true);\n return;\n }\n focusNext.current = \"form\";\n setOwnPending(null);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusy(null);\n setFailure({ action, message: messageFor(error, action) });\n },\n );\n };\n return (\n <Card {...rest} data-state=\"pending\" className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <div id={titleId} className={CARD_TITLE_CLASS}>\n {labels.title}\n </div>\n <div className={cn(CARD_DESCRIPTION_CLASS, \"break-all\")}>{common.fieldValue(labels.current, currentEmail)}</div>\n </div>\n {/* Focusable, not a control: the request's answer is read out when it takes the\n focus from the submit that went with the form. */}\n <div ref={pendingRef} tabIndex={-1} className=\"flex gap-2 outline-none\">\n <MailCheck aria-hidden className=\"mt-0.5 size-4 shrink-0 text-[var(--success)]\" />\n <div className=\"min-w-0 space-y-1\">\n <p className=\"break-words text-sm\">{labels.pending(pending)}</p>\n <p className={CARD_DESCRIPTION_CLASS}>{labels.pendingHint(currentEmail)}</p>\n </div>\n </div>\n {(onResend || onCancel) && (\n <div className=\"flex flex-wrap items-center gap-2\">\n {onResend && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n commit\n pending={busy === \"resend\"}\n disabled={busy === \"cancel\"}\n onClick={() => run(\"resend\", onResend)}\n >\n {labels.resend}\n </Button>\n )}\n {onCancel && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n commit\n pending={busy === \"cancel\"}\n disabled={busy === \"resend\"}\n onClick={() => run(\"cancel\", onCancel)}\n >\n {labels.cancel}\n </Button>\n )}\n {/* Always in the tree, so the \"sent again\" that appears in it is announced\n (VerifyEmailStatus's resend line). */}\n <span role=\"status\" className=\"text-xs text-[var(--success)]\">\n {resent ? labels.resent : null}\n </span>\n </div>\n )}\n {failure && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure.message}\n </AlertBanner>\n )}\n </Card>\n );\n }\n\n /* ── The form ── */\n const typed = newEmail.trim();\n const same = typed !== \"\" && typed.toLowerCase() === currentEmail.trim().toLowerCase();\n const working = busy !== null;\n const canSubmit = emailParts(newEmail) !== null && !same && password !== \"\";\n const suggestion = emailTag ? taggedEmail(newEmail, emailTag) : null;\n const emailError = same ? labels.sameAsCurrent : taken !== null && taken === typed ? labels.emailTaken : undefined;\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n if (!canSubmit || working) return;\n const values: EmailChangeValues = { newEmail: typed, password };\n setBusy(\"request\");\n setFailure(null);\n setTaken(null);\n setWrongPassword(false);\n settle(() => onRequest(values)).then(\n () => {\n if (!mounted.current) return;\n setBusy(null);\n // The password has done its work; nothing of the form stays in state.\n setNewEmail(\"\");\n setPassword(\"\");\n setResent(false);\n focusNext.current = \"pending\";\n setOwnPending(values.newEmail);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusy(null);\n const own = describeError?.(error, \"request\");\n if (hasMessage(own)) {\n setFailure({ action: \"request\", message: own });\n return;\n }\n if (isRateLimited(error)) {\n setFailure({ action: \"request\", message: labels.rateLimited(retryAfterSeconds(error)) });\n return;\n }\n const code = authErrorCode(error);\n if (code === \"email_taken\") {\n setTaken(values.newEmail);\n emailRef.current?.focus();\n return;\n }\n // `invalid_credentials` too, for a server that answered a wrong password so\n // before server-kit 0.4.0 named `password_incorrect`.\n if (code === \"password_incorrect\" || code === \"invalid_credentials\") {\n setWrongPassword(true);\n passwordRef.current?.focus();\n return;\n }\n setFailure({ action: \"request\", message: labels.failed });\n },\n );\n };\n\n return (\n <Card {...rest} data-state={confirmed ? \"confirmed\" : \"form\"} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <div id={titleId} className={CARD_TITLE_CLASS}>\n {labels.title}\n </div>\n <div className={cn(CARD_DESCRIPTION_CLASS, \"break-all\")}>{common.fieldValue(labels.current, currentEmail)}</div>\n </div>\n {confirmed && (\n <AlertBanner tone=\"success\" size=\"sm\">\n <span className=\"block\">{labels.confirmed(currentEmail)}</span>\n {passkeyNote && <span className=\"mt-1 block\">{labels.passkeyNote}</span>}\n </AlertBanner>\n )}\n <form className=\"space-y-3\" aria-labelledby={titleId} onSubmit={submit} noValidate>\n <div>\n <Input\n ref={emailRef}\n type=\"email\"\n name=\"email\"\n autoComplete=\"email\"\n label={labels.newEmail}\n value={newEmail}\n onChange={(e) => {\n setNewEmail(e.target.value);\n if (failure) setFailure(null);\n }}\n readOnly={working}\n error={emailError}\n required\n />\n {/* RegisterForm's offer (auth §4.5): one click, the exact address on the\n button, reversible by typing. */}\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={() => setNewEmail(suggestion)}\n >\n {labels.emailTagUse(suggestion)}\n </Button>{\" \"}\n <span id={tagHintId}>{labels.emailTagHint}</span>\n </p>\n )}\n </div>\n <CurrentPasswordInput\n ref={passwordRef}\n name=\"password\"\n label={labels.password}\n value={password}\n onValueChange={(next) => {\n setPassword(next);\n setWrongPassword(false);\n if (failure) setFailure(null);\n }}\n hint={labels.passwordHint}\n error={wrongPassword ? labels.wrongPassword : undefined}\n busy={working}\n required\n />\n {failure && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure.message}\n </AlertBanner>\n )}\n <Button type=\"submit\" commit disabled={!working && !canSubmit} pending={working}>\n {labels.submit}\n </Button>\n </form>\n </Card>\n );\n}\n"],"mappings":";AAwQQ,SACE,KADF;AAxQR,SAAS,WAAW,OAAO,QAAQ,gBAAgB;AAEnD,SAAS,iBAAiB;AAE1B,SAAS,uBAAuB,oBAAoB;AACpD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AACrC,SAAS,QAAQ,MAAM,aAAa;AACpC,SAAS,eAAe,oBAAoB,eAAe,yBAAyB;AACpF,SAAS,YAAY,mBAAmB;AACxC,SAAS,wBAAwB,kBAAkB,QAAQ,kBAAkB;AAoDtE,MAAM,8BAAiD;AAAA,EAC5D,OAAO;AAAA,EACP,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,aAAa,CAAC,YAAY,OAAO,OAAO;AAAA,EACxC,cACE;AAAA,EACF,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,SAAS,CAAC,aAAa,+BAA+B,QAAQ;AAAA,EAC9D,aAAa,CAAC,iBACZ,0CAA0C,YAAY;AAAA,EACxD,QAAQ;AAAA,EACR,QAAQ;AAA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AgB;AAAA,UAC9C,MAAM;AAAA,UACN,UAAQ;AAAA;AAAA,MACV;AAAA,MACC,WACC,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,kBAAQ,SACX;AAAA,MAEF,oBAAC,UAAO,MAAK,UAAS,QAAM,MAAC,UAAU,CAAC,WAAW,CAAC,WAAW,SAAS,SACrE,iBAAO,QACV;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/account/email-change-setting.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, FormEvent, ReactNode } from \"react\";\nimport { MailCheck } from \"lucide-react\";\n\nimport { DEFAULT_COMMON_LABELS, useKitLabels } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport { CurrentPasswordInput } from \"../components/danger-confirm\";\nimport { Button, Card, Input } from \"../components/ui\";\nimport { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from \"../auth/auth-errors\";\nimport { emailParts, taggedEmail } from \"../auth/email-tag\";\nimport { CARD_DESCRIPTION_CLASS, settle, useMounted } from \"./account-parts\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string {@link EmailChangeSetting} renders — the `emailChange` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. */\nexport interface EmailChangeLabels {\n /** The card's title. */\n title: string;\n /** Names the address the account has now: \"Current address: ada@example.com\". */\n current: string;\n /** The new address's field. */\n newEmail: string;\n /** The password field. */\n password: string;\n /** Under the password field: why it is asked again. */\n passwordHint: string;\n /** The address-tag button (auth §4.5), given the exact address it would use. */\n emailTagUse: (address: string) => string;\n /** The line after the address-tag button. */\n emailTagHint: string;\n /** The submit button. */\n submit: string;\n /** Under the new address while it is the current one. */\n sameAsCurrent: string;\n /** `email_taken`, under the new address. */\n emailTaken: string;\n /** `password_incorrect`, under the password. */\n wrongPassword: string;\n /** The pending state, given the new address the link went to. */\n pending: (newEmail: string) => string;\n /** Under it, given the current address — which still signs in until the link is\n * confirmed. */\n pendingHint: (currentEmail: string) => string;\n /** Mails the link again. */\n resend: string;\n /** Said once it went. */\n resent: string;\n /** Drops the change; the current address stays. */\n cancel: string;\n /** The done state (`confirmed`), given the address the account has now. */\n confirmed: (email: string) => string;\n /** Under it (`passkeyNote`): a passkey's label in the authenticator keeps the old\n * address (§6.2). */\n passkeyNote: string;\n /** A request was throttled — HTTP 429 — given its `Retry-After` wait in seconds, or\n * `undefined` without one. */\n rateLimited: (seconds?: number) => string;\n /** Any other failure, of any of the three requests. */\n failed: string;\n}\n\nexport const DEFAULT_EMAIL_CHANGE_LABELS: EmailChangeLabels = {\n title: \"Email address\",\n current: \"Current address\",\n newEmail: \"New email address\",\n password: \"Current password\",\n passwordHint: \"Your address is how you sign in, so changing it takes your password.\",\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 submit: \"Change email address\",\n sameAsCurrent: \"This is already your address.\",\n emailTaken: \"An account with this email address already exists.\",\n wrongPassword: \"The password is incorrect.\",\n pending: (newEmail) => `Confirm the link we sent to ${newEmail}.`,\n pendingHint: (currentEmail) =>\n `Until you do, you keep signing in with ${currentEmail}. Check your spam folder too.`,\n resend: \"Send the link again\",\n resent: \"We sent the link again.\",\n cancel: \"Cancel the change\",\n confirmed: (email) => `Your email address is now ${email}.`,\n passkeyNote: \"Your passkeys keep working. Your device may still list them under your old address.\",\n rateLimited: englishRateLimited,\n failed: \"That didn’t work. Please try again.\",\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\n/** What {@link EmailChangeSettingProps.onRequest} gets: the `POST /auth/me/email` body. */\nexport interface EmailChangeValues {\n /** Trimmed. A `+tag` stays (auth §4.5); lower-casing is the server's. */\n newEmail: string;\n /** As typed. */\n password: string;\n}\n\n/** Which request failed — {@link EmailChangeSettingProps.describeError}'s second\n * argument. */\nexport type EmailChangeAction = \"request\" | \"resend\" | \"cancel\";\n\nexport interface EmailChangeSettingProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"onSubmit\"> {\n /** The account's address now. */\n currentEmail: string;\n /**\n * The address a change waits on, from the app's server state — so a reload, or\n * another tab, shows the pending state. `null`: none, whatever the card did. Left out\n * (`undefined`), the card keeps its own: pending from a resolved `onRequest` until a\n * resolved `onCancel`.\n */\n pendingEmail?: string | null;\n /**\n * The form was submitted: send `POST /auth/me/email {new_email, password}` (§6.2).\n * Resolve once the link is mailed — refresh `pendingEmail` first if the app passes\n * it — and the card shows \"Confirm the link we sent to …\". Reject with the client's\n * error: `email_taken` shows under the new address, `password_incorrect` (server-kit's\n * `400` for a wrong current password; an older `invalid_credentials` too) under the\n * password, a 429 as `rateLimited`, anything else as `failed` unless `describeError`\n * has the app's words.\n */\n onRequest: (values: EmailChangeValues) => Promise<unknown> | void;\n /** Mail the link again. Left out, no button. */\n onResend?: () => Promise<unknown> | void;\n /** Drop the pending change. Left out, no button. */\n onCancel?: () => Promise<unknown> | void;\n /**\n * The change was just confirmed — the app's confirm route (`POST /auth/me/email/confirm`)\n * came back here. Says \"Your email address is now …\" over the form, with\n * `passkeyNote`.\n */\n confirmed?: boolean;\n /** With `confirmed`: say that a passkey's label keeps the old address (§6.2). Default\n * `true`; `false` for an account without passkeys. */\n passkeyNote?: boolean;\n /**\n * The app's address tag (`\"kastlan\"`, auth §4.5): once the new address is plausible a\n * button under it offers the tagged form — the rule of `RegisterForm`, since this is\n * the person's own address. Never applied on its own. Left out, no offer.\n */\n emailTag?: string;\n /** The app's own words for a failure, or `undefined` for the kit's. Asked first, for\n * every failure (a demo account's 403, the device offline). */\n describeError?: (error: unknown, action: EmailChangeAction) => ReactNode | undefined;\n labels?: Partial<EmailChangeLabels>;\n}\n\ninterface Failure {\n action: EmailChangeAction;\n message: ReactNode;\n}\n\n/**\n * Changing the account's email address (docs/user-admin-harmonization.md §6.2, §2.5):\n * the current address, the new one, the password — then a pending state until the new\n * address confirms its link.\n *\n * **The new address must confirm before it takes effect.** The server mails a one-time\n * link to the NEW address (and a notice to the old one); until it is opened, the account\n * keeps the old address and signs in with it. So the card's answer to a request is not\n * \"changed\" but \"Confirm the link we sent to …\", with \"Send the link again\" and \"Cancel\n * the change\". The state is the server's: pass `pendingEmail` and a reload shows it too.\n *\n * **The password is asked again** because the address is the identity: whoever holds the\n * session must not move the account to a mailbox of their own. It is a\n * {@link CurrentPasswordInput}, so a password manager fills it and offers no new one.\n *\n * **The `+tag` offer** (`emailTag`) is RegisterForm's: the address is the person's own,\n * so `you+kastlan@…` is offered under the field, applied only on a click.\n *\n * **It never sends a request** (auth §8): `onRequest`, `onResend` and `onCancel` are the\n * app's, and their refusals are read by code — `email_taken` and `password_incorrect`\n * under their fields, which take the focus; a 429 as \"Too many attempts\". A wrong\n * password is a `400 password_incorrect`, never a 401: an app's client reads a 401 on a\n * signed-in route as an ended session, and would sign the person out for a typo.\n *\n * **Done** (`confirmed`): \"Your email address is now …\" and, unless `passkeyNote` is\n * off, that a passkey keeps its old label in the device's list — the authenticator\n * stored the name it was given, and only a new passkey carries the new one.\n */\nexport function EmailChangeSetting({\n currentEmail,\n pendingEmail,\n onRequest,\n onResend,\n onCancel,\n confirmed,\n passkeyNote = true,\n emailTag,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: EmailChangeSettingProps) {\n const labels = useKitLabels(\"emailChange\", DEFAULT_EMAIL_CHANGE_LABELS, labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const [newEmail, setNewEmail] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n const [ownPending, setOwnPending] = useState<string | null>(null);\n const [busy, setBusy] = useState<EmailChangeAction | null>(null);\n const [failure, setFailure] = useState<Failure | null>(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 [wrongPassword, setWrongPassword] = useState(false);\n const [resent, setResent] = useState(false);\n const mounted = useMounted();\n const titleId = useId();\n const tagHintId = useId();\n const emailRef = useRef<HTMLInputElement>(null);\n const passwordRef = useRef<HTMLInputElement>(null);\n const pendingRef = useRef<HTMLDivElement>(null);\n\n const pending = pendingEmail !== undefined ? pendingEmail : ownPending;\n const isPending = pending !== null && pending !== \"\";\n\n // The state swapped under the button that was pressed (the form for the pending\n // message, or back): the focus goes to what came in, never down to <body>. Only after\n // the person's own request — a pending state that arrives with the page takes nothing.\n const focusNext = useRef<\"pending\" | \"form\" | null>(null);\n useEffect(() => {\n const target = focusNext.current;\n if (target === \"pending\" && isPending) {\n focusNext.current = null;\n pendingRef.current?.focus();\n } else if (target === \"form\" && !isPending) {\n focusNext.current = null;\n emailRef.current?.focus();\n }\n }, [isPending]);\n\n const messageFor = (error: unknown, action: EmailChangeAction): ReactNode => {\n const own = describeError?.(error, action);\n if (hasMessage(own)) return own;\n return isRateLimited(error) ? labels.rateLimited(retryAfterSeconds(error)) : labels.failed;\n };\n\n /* ── The pending state ── */\n if (isPending) {\n const run = (action: \"resend\" | \"cancel\", call: () => unknown) => {\n if (busy) return;\n setBusy(action);\n setFailure(null);\n setResent(false);\n settle(call).then(\n () => {\n if (!mounted.current) return;\n setBusy(null);\n if (action === \"resend\") {\n setResent(true);\n return;\n }\n focusNext.current = \"form\";\n setOwnPending(null);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusy(null);\n setFailure({ action, message: messageFor(error, action) });\n },\n );\n };\n return (\n <Card {...rest} data-state=\"pending\" className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle id={titleId}>{labels.title}</SettingsCardTitle>\n <div className={cn(CARD_DESCRIPTION_CLASS, \"break-all\")}>{common.fieldValue(labels.current, currentEmail)}</div>\n </div>\n {/* Focusable, not a control: the request's answer is read out when it takes the\n focus from the submit that went with the form. */}\n <div ref={pendingRef} tabIndex={-1} className=\"flex gap-2 outline-none\">\n <MailCheck aria-hidden className=\"mt-0.5 size-4 shrink-0 text-[var(--success)]\" />\n <div className=\"min-w-0 space-y-1\">\n <p className=\"break-words text-sm\">{labels.pending(pending)}</p>\n <p className={CARD_DESCRIPTION_CLASS}>{labels.pendingHint(currentEmail)}</p>\n </div>\n </div>\n {(onResend || onCancel) && (\n <div className=\"flex flex-wrap items-center gap-2\">\n {onResend && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n commit\n pending={busy === \"resend\"}\n disabled={busy === \"cancel\"}\n onClick={() => run(\"resend\", onResend)}\n >\n {labels.resend}\n </Button>\n )}\n {onCancel && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n commit\n pending={busy === \"cancel\"}\n disabled={busy === \"resend\"}\n onClick={() => run(\"cancel\", onCancel)}\n >\n {labels.cancel}\n </Button>\n )}\n {/* Always in the tree, so the \"sent again\" that appears in it is announced\n (VerifyEmailStatus's resend line). */}\n <span role=\"status\" className=\"text-xs text-[var(--success)]\">\n {resent ? labels.resent : null}\n </span>\n </div>\n )}\n {failure && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure.message}\n </AlertBanner>\n )}\n </Card>\n );\n }\n\n /* ── The form ── */\n const typed = newEmail.trim();\n const same = typed !== \"\" && typed.toLowerCase() === currentEmail.trim().toLowerCase();\n const working = busy !== null;\n const canSubmit = emailParts(newEmail) !== null && !same && password !== \"\";\n const suggestion = emailTag ? taggedEmail(newEmail, emailTag) : null;\n const emailError = same ? labels.sameAsCurrent : taken !== null && taken === typed ? labels.emailTaken : undefined;\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n if (!canSubmit || working) return;\n const values: EmailChangeValues = { newEmail: typed, password };\n setBusy(\"request\");\n setFailure(null);\n setTaken(null);\n setWrongPassword(false);\n settle(() => onRequest(values)).then(\n () => {\n if (!mounted.current) return;\n setBusy(null);\n // The password has done its work; nothing of the form stays in state.\n setNewEmail(\"\");\n setPassword(\"\");\n setResent(false);\n focusNext.current = \"pending\";\n setOwnPending(values.newEmail);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusy(null);\n const own = describeError?.(error, \"request\");\n if (hasMessage(own)) {\n setFailure({ action: \"request\", message: own });\n return;\n }\n if (isRateLimited(error)) {\n setFailure({ action: \"request\", message: labels.rateLimited(retryAfterSeconds(error)) });\n return;\n }\n const code = authErrorCode(error);\n if (code === \"email_taken\") {\n setTaken(values.newEmail);\n emailRef.current?.focus();\n return;\n }\n // `invalid_credentials` too, for a server that answered a wrong password so\n // before server-kit 0.4.0 named `password_incorrect`.\n if (code === \"password_incorrect\" || code === \"invalid_credentials\") {\n setWrongPassword(true);\n passwordRef.current?.focus();\n return;\n }\n setFailure({ action: \"request\", message: labels.failed });\n },\n );\n };\n\n return (\n <Card {...rest} data-state={confirmed ? \"confirmed\" : \"form\"} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle id={titleId}>{labels.title}</SettingsCardTitle>\n <div className={cn(CARD_DESCRIPTION_CLASS, \"break-all\")}>{common.fieldValue(labels.current, currentEmail)}</div>\n </div>\n {confirmed && (\n <AlertBanner tone=\"success\" size=\"sm\">\n <span className=\"block\">{labels.confirmed(currentEmail)}</span>\n {passkeyNote && <span className=\"mt-1 block\">{labels.passkeyNote}</span>}\n </AlertBanner>\n )}\n <form className=\"space-y-3\" aria-labelledby={titleId} onSubmit={submit} noValidate>\n <div>\n <Input\n ref={emailRef}\n type=\"email\"\n name=\"email\"\n autoComplete=\"email\"\n label={labels.newEmail}\n value={newEmail}\n onChange={(e) => {\n setNewEmail(e.target.value);\n if (failure) setFailure(null);\n }}\n readOnly={working}\n error={emailError}\n required\n />\n {/* RegisterForm's offer (auth §4.5): one click, the exact address on the\n button, reversible by typing. */}\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={() => setNewEmail(suggestion)}\n >\n {labels.emailTagUse(suggestion)}\n </Button>{\" \"}\n <span id={tagHintId}>{labels.emailTagHint}</span>\n </p>\n )}\n </div>\n <CurrentPasswordInput\n ref={passwordRef}\n name=\"password\"\n label={labels.password}\n value={password}\n onValueChange={(next) => {\n setPassword(next);\n setWrongPassword(false);\n if (failure) setFailure(null);\n }}\n hint={labels.passwordHint}\n error={wrongPassword ? labels.wrongPassword : undefined}\n busy={working}\n required\n />\n {failure && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure.message}\n </AlertBanner>\n )}\n <Button type=\"submit\" commit disabled={!working && !canSubmit} pending={working}>\n {labels.submit}\n </Button>\n </form>\n </Card>\n );\n}\n"],"mappings":";AAyQQ,SACE,KADF;AAzQR,SAAS,WAAW,OAAO,QAAQ,gBAAgB;AAEnD,SAAS,iBAAiB;AAE1B,SAAS,uBAAuB,oBAAoB;AACpD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AACrC,SAAS,QAAQ,MAAM,aAAa;AACpC,SAAS,eAAe,oBAAoB,eAAe,yBAAyB;AACpF,SAAS,YAAY,mBAAmB;AACxC,SAAS,wBAAwB,QAAQ,kBAAkB;AAC3D,SAAS,yBAAyB;AAoD3B,MAAM,8BAAiD;AAAA,EAC5D,OAAO;AAAA,EACP,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,aAAa,CAAC,YAAY,OAAO,OAAO;AAAA,EACxC,cACE;AAAA,EACF,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,SAAS,CAAC,aAAa,+BAA+B,QAAQ;AAAA,EAC9D,aAAa,CAAC,iBACZ,0CAA0C,YAAY;AAAA,EACxD,QAAQ;AAAA,E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B;AAAA,UAC9C,MAAM;AAAA,UACN,UAAQ;AAAA;AAAA,MACV;AAAA,MACC,WACC,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,kBAAQ,SACX;AAAA,MAEF,oBAAC,UAAO,MAAK,UAAS,QAAM,MAAC,UAAU,CAAC,WAAW,CAAC,WAAW,SAAS,SACrE,iBAAO,QACV;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
@@ -11,7 +11,8 @@ import { hasMessage } from "../components/choice-parts.js";
11
11
  import { DangerConfirm } from "../components/danger-confirm.js";
12
12
  import { Skeleton } from "../components/skeleton.js";
13
13
  import { Button, Card } from "../components/ui.js";
14
- import { CARD_DESCRIPTION_CLASS, CARD_TITLE_CLASS, settle, useMounted } from "./account-parts.js";
14
+ import { CARD_DESCRIPTION_CLASS, settle, useMounted } from "./account-parts.js";
15
+ import { SettingsCardTitle } from "../settings/settings-heading.js";
15
16
  const DEFAULT_SESSIONS_LABELS = {
16
17
  title: "Sessions",
17
18
  description: "Signed in on a device you no longer use, or don\u2019t trust? Sign out everywhere.",
@@ -80,7 +81,7 @@ function SessionsSetting({
80
81
  const showList = sessions !== void 0 || loading;
81
82
  return /* @__PURE__ */ jsxs(Card, { ...rest, className: cn("p-4 space-y-3", className), children: [
82
83
  /* @__PURE__ */ jsxs("div", { children: [
83
- /* @__PURE__ */ jsx("div", { className: CARD_TITLE_CLASS, children: labels.title }),
84
+ /* @__PURE__ */ jsx(SettingsCardTitle, { children: labels.title }),
84
85
  /* @__PURE__ */ jsx("div", { className: CARD_DESCRIPTION_CLASS, children: labels.description })
85
86
  ] }),
86
87
  showList && (loading || sessions === void 0 ? /* @__PURE__ */ jsx(Skeleton, { lines: 2, label: labels.loading }) : sessions.length === 0 ? /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.empty }) : /* @__PURE__ */ jsx("ul", { "aria-label": labels.list, className: "divide-y divide-[var(--border)]", children: sessions.map((session) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/account/sessions-setting.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { MonitorSmartphone } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { formatRelativeTime, toDate } from \"../lib/format\";\nimport type { DateInput } from \"../lib/format\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Chip } from \"../components/chip\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport { DangerConfirm } from \"../components/danger-confirm\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { Button, Card } from \"../components/ui\";\nimport { CARD_DESCRIPTION_CLASS, CARD_TITLE_CLASS, settle, useMounted } from \"./account-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string {@link SessionsSetting} renders — the `sessions` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. The confirm's\n * Cancel is `dangerConfirm.cancel`. */\nexport interface SessionsLabels {\n /** The card's title. */\n title: string;\n /** The line under it: what \"sign out everywhere\" is for. */\n description: string;\n /** The button that asks first. */\n signOutEverywhere: string;\n /** The question it asks: every session ends, this one too. */\n signOutEverywherePrompt: string;\n /** The button that answers it. */\n confirmSignOutEverywhere: string;\n /** The device list's accessible name. */\n list: string;\n /** While the list loads. */\n loading: string;\n /** A list with no rows. */\n empty: string;\n /** The chip on the session this page runs in. */\n current: string;\n /** A session whose device the server could not name. */\n unknownDevice: string;\n /** Given the last activity, formatted (\"3 hours ago\", \"5 Oct 2026\"). */\n lastActive: (when: string) => string;\n /** Given the address the session was last seen from. */\n ip: (address: string) => string;\n /** A row's button, visible text. */\n revoke: string;\n /** The same button's accessible name, given the device — it starts with `revoke`,\n * the visible text, so voice control finds it by what it says. */\n revokeItem: (device: string) => string;\n /** A request failed. */\n failed: string;\n}\n\nexport const DEFAULT_SESSIONS_LABELS: SessionsLabels = {\n title: \"Sessions\",\n description: \"Signed in on a device you no longer use, or don’t trust? Sign out everywhere.\",\n signOutEverywhere: \"Sign out everywhere…\",\n signOutEverywherePrompt:\n \"This ends every session, including this one: you will be signed out on this device too, and sign in again from here.\",\n confirmSignOutEverywhere: \"Sign out everywhere\",\n list: \"Where you’re signed in\",\n loading: \"Loading sessions…\",\n empty: \"No sessions to show.\",\n current: \"This device\",\n unknownDevice: \"Unknown device\",\n lastActive: (when) => `Last active ${when}`,\n ip: (address) => `IP ${address}`,\n revoke: \"Sign out\",\n revokeItem: (device) => `Sign out ${device}`,\n failed: \"That didn’t work. Please try again.\",\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\n/** What a session's `id` may be: the app's own key type. */\nexport type SessionId = string | number;\n\n/** One stored session (kastlan's `GET /auth/sessions`). */\nexport interface SessionItem<Id extends SessionId = SessionId> {\n id: Id;\n /** The browser and system, as the server reads them (\"Firefox on Windows\"). Blank\n * reads as `labels.unknownDevice`. */\n device?: string | null;\n /** The address it was last seen from. */\n ip?: string | null;\n /** A `Date`, an ISO string or epoch ms. */\n lastActiveAt?: DateInput;\n /** The session this page runs in: marked, and offered no \"Sign out\" of its own — the\n * app's sign-out does that, and \"Sign out everywhere\" below. */\n current?: boolean;\n}\n\n/** Which request failed — {@link SessionsSettingProps.describeError}'s second argument. */\nexport type SessionsAction = \"sign-out-everywhere\" | \"revoke\";\n\nexport interface SessionsSettingProps<Id extends SessionId = SessionId>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /**\n * End every session (`POST /auth/logout`, auth §6.3) — this one included. Asked\n * first; resolve once the server answered, then sign this page out: the card says\n * that the device signs out too, and its own session is gone.\n */\n onSignOutEverywhere: () => Promise<unknown> | void;\n /**\n * The stored sessions, where the app keeps them (kastlan's `user_sessions`, §6.3).\n * Left out, the card is \"Sign out everywhere\" alone — keksdose and Kurvenschmiede keep\n * a cut-off (`sessions_invalid_before`), not rows. `undefined` with `loading` while the\n * first load runs.\n */\n sessions?: readonly SessionItem<Id>[];\n /** The list is loading. */\n loading?: boolean;\n /** End one other session (`DELETE /auth/sessions/{id}`). Left out, no row buttons.\n * The row is busy until it settles; refresh `sessions` then. */\n onRevoke?: (id: Id) => Promise<unknown> | void;\n /** The app's own words for a failure, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown, action: SessionsAction) => ReactNode | undefined;\n /** The \"Last active\" text. Default: how long ago, in the provider's locale, and the\n * date once it is more than a week back. */\n formatLastActive?: (date: Date) => string;\n /** Overrides the provider's locale for the default format. */\n locale?: string;\n labels?: Partial<SessionsLabels>;\n}\n\n/**\n * Where the account is signed in, and the way out of all of it\n * (docs/user-admin-harmonization.md §6.3, §2.6).\n *\n * **\"Sign out everywhere\", in every app.** It ends every session, THIS one included —\n * the server stamps a cut-off (`sessions_invalid_before`) that the page's own token is\n * older than — so the confirm says so before it is pressed, and the app signs out once it\n * resolves. A {@link DangerConfirm} in the warning tone: nothing is lost, but the person\n * has to sign in again on every device. keksdose kept its ordinary sign-out device-only\n * (its offline mirror is wiped on an explicit sign-out), which is why this is an action\n * of its own, not a mode of that one.\n *\n * **The device list, where sessions are stored** (kastlan): device, address, last\n * active, and \"This device\" on the current one, with \"Sign out\" on each other row — no\n * confirm, since a session ended is a sign-in away from coming back, not data lost.\n * Without `sessions` there is no list: the other apps keep a cut-off, not rows.\n *\n * Both requests are the app's; a failure is said under the card's action, in the app's\n * words if `describeError` has them.\n */\nexport function SessionsSetting<Id extends SessionId = SessionId>({\n onSignOutEverywhere,\n sessions,\n loading,\n onRevoke,\n describeError,\n formatLastActive,\n locale: localeProp,\n labels: labelsProp,\n className,\n ...rest\n}: SessionsSettingProps<Id>) {\n const labels = useKitLabels(\"sessions\", DEFAULT_SESSIONS_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const [busyId, setBusyId] = useState<Id | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n\n const describe = (error: unknown, action: SessionsAction): ReactNode => {\n const own = describeError?.(error, action);\n return hasMessage(own) ? own : labels.failed;\n };\n\n const lastActive = (value: DateInput): string | null => {\n const date = toDate(value);\n if (!date) return null;\n return formatLastActive\n ? formatLastActive(date)\n : formatRelativeTime(date, { locale, absoluteAfterDays: 7, absoluteStyle: \"medium\" });\n };\n\n const signOutEverywhere = () => {\n setFailure(null);\n // Rejected again after it is said, so the tile stays armed for a retry.\n return settle(onSignOutEverywhere).catch((error: unknown) => {\n if (mounted.current) setFailure(describe(error, \"sign-out-everywhere\"));\n throw error;\n });\n };\n\n const revoke = (id: Id) => {\n if (!onRevoke || busyId !== null) return;\n setBusyId(id);\n setFailure(null);\n settle(() => onRevoke(id)).then(\n () => {\n if (mounted.current) setBusyId(null);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusyId(null);\n setFailure(describe(error, \"revoke\"));\n },\n );\n };\n\n const showList = sessions !== undefined || loading;\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <div className={CARD_TITLE_CLASS}>{labels.title}</div>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.description}</div>\n </div>\n {showList &&\n (loading || sessions === undefined ? (\n <Skeleton lines={2} label={labels.loading} />\n ) : sessions.length === 0 ? (\n <p className={CARD_DESCRIPTION_CLASS}>{labels.empty}</p>\n ) : (\n <ul aria-label={labels.list} className=\"divide-y divide-[var(--border)]\">\n {sessions.map((session) => {\n const device = session.device?.trim() || labels.unknownDevice;\n const when = lastActive(session.lastActiveAt);\n const ip = session.ip?.trim();\n return (\n <li\n key={session.id}\n data-session-id={String(session.id)}\n data-current={session.current || undefined}\n className=\"flex items-center gap-3 py-2\"\n >\n <MonitorSmartphone aria-hidden className=\"size-4 shrink-0 text-[var(--text-muted)]\" />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n <span className=\"min-w-0 break-words text-sm font-medium\">{device}</span>\n {session.current && (\n <Chip size=\"sm\" tone=\"brand\">\n {labels.current}\n </Chip>\n )}\n </div>\n {(when || ip) && (\n <div className={CARD_DESCRIPTION_CLASS}>\n {when && labels.lastActive(when)}\n {when && ip && \" · \"}\n {/* An address reads left to right in any page direction. */}\n {ip && <span dir=\"ltr\">{labels.ip(ip)}</span>}\n </div>\n )}\n </div>\n {onRevoke && !session.current && (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit\n pending={busyId === session.id}\n disabled={busyId !== null && busyId !== session.id}\n aria-label={labels.revokeItem(device)}\n onClick={() => revoke(session.id)}\n >\n {labels.revoke}\n </Button>\n )}\n </li>\n );\n })}\n </ul>\n ))}\n <DangerConfirm\n tone=\"warning\"\n commit\n armLabel={labels.signOutEverywhere}\n prompt={labels.signOutEverywherePrompt}\n confirmLabel={labels.confirmSignOutEverywhere}\n onConfirm={signOutEverywhere}\n />\n {hasMessage(failure) && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure}\n </AlertBanner>\n )}\n </Card>\n );\n}\n"],"mappings":";AA+MM,SACE,KADF;AA/MN,SAAS,gBAAgB;AAEzB,SAAS,yBAAyB;AAElC,SAAS,cAAc,oBAAoB;AAC3C,SAAS,UAAU;AACnB,SAAS,oBAAoB,cAAc;AAE3C,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,QAAQ,YAAY;AAC7B,SAAS,wBAAwB,kBAAkB,QAAQ,kBAAkB;AAyCtE,MAAM,0BAA0C;AAAA,EACrD,OAAO;AAAA,EACP,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,yBACE;AAAA,EACF,0BAA0B;AAAA,EAC1B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AAAA,EACf,YAAY,CAAC,SAAS,eAAe,IAAI;AAAA,EACzC,IAAI,CAAC,YAAY,MAAM,OAAO;AAAA,EAC9B,QAAQ;A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AAA,eAEJ;AAAA,YACC,YAAY,CAAC,QAAQ,WACpB;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,MAAK;AAAA,gBACL,SAAQ;AAAA,gBACR,QAAM;AAAA,gBACN,SAAS,WAAW,QAAQ;AAAA,gBAC5B,UAAU,WAAW,QAAQ,WAAW,QAAQ;AAAA,gBAChD,cAAY,OAAO,WAAW,MAAM;AAAA,gBACpC,SAAS,MAAM,OAAO,QAAQ,EAAE;AAAA,gBAE/B,iBAAO;AAAA;AAAA,YACV;AAAA;AAAA;AAAA,QApCG,QAAQ;AAAA,MAsCf;AAAA,IAEJ,CAAC,GACH;AAAA,IAEJ;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,QAAM;AAAA,QACN,UAAU,OAAO;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,cAAc,OAAO;AAAA,QACrB,WAAW;AAAA;AAAA,IACb;AAAA,IACC,WAAW,OAAO,KACjB,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,mBACH;AAAA,KAEJ;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/account/sessions-setting.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { MonitorSmartphone } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { formatRelativeTime, toDate } from \"../lib/format\";\nimport type { DateInput } from \"../lib/format\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Chip } from \"../components/chip\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport { DangerConfirm } from \"../components/danger-confirm\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { Button, Card } from \"../components/ui\";\nimport { CARD_DESCRIPTION_CLASS, settle, useMounted } from \"./account-parts\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string {@link SessionsSetting} renders — the `sessions` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. The confirm's\n * Cancel is `dangerConfirm.cancel`. */\nexport interface SessionsLabels {\n /** The card's title. */\n title: string;\n /** The line under it: what \"sign out everywhere\" is for. */\n description: string;\n /** The button that asks first. */\n signOutEverywhere: string;\n /** The question it asks: every session ends, this one too. */\n signOutEverywherePrompt: string;\n /** The button that answers it. */\n confirmSignOutEverywhere: string;\n /** The device list's accessible name. */\n list: string;\n /** While the list loads. */\n loading: string;\n /** A list with no rows. */\n empty: string;\n /** The chip on the session this page runs in. */\n current: string;\n /** A session whose device the server could not name. */\n unknownDevice: string;\n /** Given the last activity, formatted (\"3 hours ago\", \"5 Oct 2026\"). */\n lastActive: (when: string) => string;\n /** Given the address the session was last seen from. */\n ip: (address: string) => string;\n /** A row's button, visible text. */\n revoke: string;\n /** The same button's accessible name, given the device — it starts with `revoke`,\n * the visible text, so voice control finds it by what it says. */\n revokeItem: (device: string) => string;\n /** A request failed. */\n failed: string;\n}\n\nexport const DEFAULT_SESSIONS_LABELS: SessionsLabels = {\n title: \"Sessions\",\n description: \"Signed in on a device you no longer use, or don’t trust? Sign out everywhere.\",\n signOutEverywhere: \"Sign out everywhere…\",\n signOutEverywherePrompt:\n \"This ends every session, including this one: you will be signed out on this device too, and sign in again from here.\",\n confirmSignOutEverywhere: \"Sign out everywhere\",\n list: \"Where you’re signed in\",\n loading: \"Loading sessions…\",\n empty: \"No sessions to show.\",\n current: \"This device\",\n unknownDevice: \"Unknown device\",\n lastActive: (when) => `Last active ${when}`,\n ip: (address) => `IP ${address}`,\n revoke: \"Sign out\",\n revokeItem: (device) => `Sign out ${device}`,\n failed: \"That didn’t work. Please try again.\",\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\n/** What a session's `id` may be: the app's own key type. */\nexport type SessionId = string | number;\n\n/** One stored session (kastlan's `GET /auth/sessions`). */\nexport interface SessionItem<Id extends SessionId = SessionId> {\n id: Id;\n /** The browser and system, as the server reads them (\"Firefox on Windows\"). Blank\n * reads as `labels.unknownDevice`. */\n device?: string | null;\n /** The address it was last seen from. */\n ip?: string | null;\n /** A `Date`, an ISO string or epoch ms. */\n lastActiveAt?: DateInput;\n /** The session this page runs in: marked, and offered no \"Sign out\" of its own — the\n * app's sign-out does that, and \"Sign out everywhere\" below. */\n current?: boolean;\n}\n\n/** Which request failed — {@link SessionsSettingProps.describeError}'s second argument. */\nexport type SessionsAction = \"sign-out-everywhere\" | \"revoke\";\n\nexport interface SessionsSettingProps<Id extends SessionId = SessionId>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /**\n * End every session (`POST /auth/logout`, auth §6.3) — this one included. Asked\n * first; resolve once the server answered, then sign this page out: the card says\n * that the device signs out too, and its own session is gone.\n */\n onSignOutEverywhere: () => Promise<unknown> | void;\n /**\n * The stored sessions, where the app keeps them (kastlan's `user_sessions`, §6.3).\n * Left out, the card is \"Sign out everywhere\" alone — keksdose and Kurvenschmiede keep\n * a cut-off (`sessions_invalid_before`), not rows. `undefined` with `loading` while the\n * first load runs.\n */\n sessions?: readonly SessionItem<Id>[];\n /** The list is loading. */\n loading?: boolean;\n /** End one other session (`DELETE /auth/sessions/{id}`). Left out, no row buttons.\n * The row is busy until it settles; refresh `sessions` then. */\n onRevoke?: (id: Id) => Promise<unknown> | void;\n /** The app's own words for a failure, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown, action: SessionsAction) => ReactNode | undefined;\n /** The \"Last active\" text. Default: how long ago, in the provider's locale, and the\n * date once it is more than a week back. */\n formatLastActive?: (date: Date) => string;\n /** Overrides the provider's locale for the default format. */\n locale?: string;\n labels?: Partial<SessionsLabels>;\n}\n\n/**\n * Where the account is signed in, and the way out of all of it\n * (docs/user-admin-harmonization.md §6.3, §2.6).\n *\n * **\"Sign out everywhere\", in every app.** It ends every session, THIS one included —\n * the server stamps a cut-off (`sessions_invalid_before`) that the page's own token is\n * older than — so the confirm says so before it is pressed, and the app signs out once it\n * resolves. A {@link DangerConfirm} in the warning tone: nothing is lost, but the person\n * has to sign in again on every device. keksdose kept its ordinary sign-out device-only\n * (its offline mirror is wiped on an explicit sign-out), which is why this is an action\n * of its own, not a mode of that one.\n *\n * **The device list, where sessions are stored** (kastlan): device, address, last\n * active, and \"This device\" on the current one, with \"Sign out\" on each other row — no\n * confirm, since a session ended is a sign-in away from coming back, not data lost.\n * Without `sessions` there is no list: the other apps keep a cut-off, not rows.\n *\n * Both requests are the app's; a failure is said under the card's action, in the app's\n * words if `describeError` has them.\n */\nexport function SessionsSetting<Id extends SessionId = SessionId>({\n onSignOutEverywhere,\n sessions,\n loading,\n onRevoke,\n describeError,\n formatLastActive,\n locale: localeProp,\n labels: labelsProp,\n className,\n ...rest\n}: SessionsSettingProps<Id>) {\n const labels = useKitLabels(\"sessions\", DEFAULT_SESSIONS_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const [busyId, setBusyId] = useState<Id | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n\n const describe = (error: unknown, action: SessionsAction): ReactNode => {\n const own = describeError?.(error, action);\n return hasMessage(own) ? own : labels.failed;\n };\n\n const lastActive = (value: DateInput): string | null => {\n const date = toDate(value);\n if (!date) return null;\n return formatLastActive\n ? formatLastActive(date)\n : formatRelativeTime(date, { locale, absoluteAfterDays: 7, absoluteStyle: \"medium\" });\n };\n\n const signOutEverywhere = () => {\n setFailure(null);\n // Rejected again after it is said, so the tile stays armed for a retry.\n return settle(onSignOutEverywhere).catch((error: unknown) => {\n if (mounted.current) setFailure(describe(error, \"sign-out-everywhere\"));\n throw error;\n });\n };\n\n const revoke = (id: Id) => {\n if (!onRevoke || busyId !== null) return;\n setBusyId(id);\n setFailure(null);\n settle(() => onRevoke(id)).then(\n () => {\n if (mounted.current) setBusyId(null);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusyId(null);\n setFailure(describe(error, \"revoke\"));\n },\n );\n };\n\n const showList = sessions !== undefined || loading;\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.title}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.description}</div>\n </div>\n {showList &&\n (loading || sessions === undefined ? (\n <Skeleton lines={2} label={labels.loading} />\n ) : sessions.length === 0 ? (\n <p className={CARD_DESCRIPTION_CLASS}>{labels.empty}</p>\n ) : (\n <ul aria-label={labels.list} className=\"divide-y divide-[var(--border)]\">\n {sessions.map((session) => {\n const device = session.device?.trim() || labels.unknownDevice;\n const when = lastActive(session.lastActiveAt);\n const ip = session.ip?.trim();\n return (\n <li\n key={session.id}\n data-session-id={String(session.id)}\n data-current={session.current || undefined}\n className=\"flex items-center gap-3 py-2\"\n >\n <MonitorSmartphone aria-hidden className=\"size-4 shrink-0 text-[var(--text-muted)]\" />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n <span className=\"min-w-0 break-words text-sm font-medium\">{device}</span>\n {session.current && (\n <Chip size=\"sm\" tone=\"brand\">\n {labels.current}\n </Chip>\n )}\n </div>\n {(when || ip) && (\n <div className={CARD_DESCRIPTION_CLASS}>\n {when && labels.lastActive(when)}\n {when && ip && \" · \"}\n {/* An address reads left to right in any page direction. */}\n {ip && <span dir=\"ltr\">{labels.ip(ip)}</span>}\n </div>\n )}\n </div>\n {onRevoke && !session.current && (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit\n pending={busyId === session.id}\n disabled={busyId !== null && busyId !== session.id}\n aria-label={labels.revokeItem(device)}\n onClick={() => revoke(session.id)}\n >\n {labels.revoke}\n </Button>\n )}\n </li>\n );\n })}\n </ul>\n ))}\n <DangerConfirm\n tone=\"warning\"\n commit\n armLabel={labels.signOutEverywhere}\n prompt={labels.signOutEverywherePrompt}\n confirmLabel={labels.confirmSignOutEverywhere}\n onConfirm={signOutEverywhere}\n />\n {hasMessage(failure) &&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