@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.
- package/README.md +42 -5
- package/dist/account/data-export-setting.js +3 -2
- package/dist/account/data-export-setting.js.map +1 -1
- package/dist/account/delete-account-setting.d.ts +5 -1
- package/dist/account/delete-account-setting.js +3 -2
- package/dist/account/delete-account-setting.js.map +1 -1
- package/dist/account/email-change-setting.js +4 -3
- package/dist/account/email-change-setting.js.map +1 -1
- package/dist/account/sessions-setting.js +3 -2
- package/dist/account/sessions-setting.js.map +1 -1
- package/dist/admin/admin-action-confirm.d.ts +5 -1
- package/dist/admin/admin-parts.d.ts +8 -1
- package/dist/admin/admin-parts.js +1 -1
- package/dist/admin/admin-parts.js.map +1 -1
- package/dist/admin/invitations-panel.d.ts +5 -1
- package/dist/admin/invitations-panel.js +3 -2
- package/dist/admin/invitations-panel.js.map +1 -1
- package/dist/admin/reviewer-scope-editor.d.ts +5 -1
- package/dist/admin/role-select.d.ts +5 -1
- package/dist/admin/transfer-ownership-dialog.d.ts +5 -1
- package/dist/admin/user-roster.d.ts +5 -1
- package/dist/auth/auth-errors.d.ts +24 -6
- package/dist/auth/auth-errors.js +7 -1
- package/dist/auth/auth-errors.js.map +1 -1
- package/dist/auth/register-form.d.ts +5 -1
- package/dist/auth/reset-password-form.d.ts +1 -1
- package/dist/auth/reset-password-form.js +2 -1
- package/dist/auth/reset-password-form.js.map +1 -1
- package/dist/auth/sign-in-form.d.ts +15 -1
- package/dist/auth/sign-in-form.js +12 -3
- package/dist/auth/sign-in-form.js.map +1 -1
- package/dist/auth/verify-email.d.ts +4 -0
- package/dist/auth/verify-email.js +3 -2
- package/dist/auth/verify-email.js.map +1 -1
- package/dist/chart.d.ts +5 -1
- package/dist/components/account-settings-labels.d.ts +12 -0
- package/dist/components/account-settings-labels.js +2 -1
- package/dist/components/account-settings-labels.js.map +1 -1
- package/dist/components/account-settings.d.ts +8 -2
- package/dist/components/account-settings.js +19 -11
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +5 -1
- package/dist/components/button-group.d.ts +5 -1
- package/dist/components/calculator.d.ts +5 -1
- package/dist/components/confirm-dialog.d.ts +5 -1
- package/dist/components/confirm-dialog.js +7 -1
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/copy-button.d.ts +5 -1
- package/dist/components/danger-confirm.d.ts +5 -1
- package/dist/components/data-table.js +8 -1
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.js +9 -4
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/facing-pair.d.ts +5 -1
- package/dist/components/file-button.d.ts +5 -1
- package/dist/components/file-dropzone.d.ts +5 -1
- package/dist/components/form-actions.d.ts +5 -1
- package/dist/components/iban-input.d.ts +5 -1
- package/dist/components/language-select.d.ts +5 -1
- package/dist/components/legal-page.d.ts +5 -1
- package/dist/components/legal.d.ts +5 -1
- package/dist/components/money-field.d.ts +5 -1
- package/dist/components/number-field.d.ts +5 -1
- package/dist/components/number-input.d.ts +5 -1
- package/dist/components/numpad-sheet.d.ts +5 -1
- package/dist/components/passkeys-setting.js +2 -1
- package/dist/components/passkeys-setting.js.map +1 -1
- package/dist/components/phone-input.d.ts +5 -1
- package/dist/components/series-chart.d.ts +5 -1
- package/dist/components/settings-fields.d.ts +40 -3
- package/dist/components/settings-fields.js +20 -1
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/share-card.d.ts +5 -1
- package/dist/components/text-link.d.ts +5 -1
- package/dist/components/time-input.d.ts +5 -1
- package/dist/components/ui.d.ts +5 -1
- package/dist/{delete-account-setting-CGVMckMw.d.ts → delete-account-setting-CpIhzxxZ.d.ts} +60 -23
- package/dist/demo/demo-banner.d.ts +51 -0
- package/dist/demo/demo-banner.js +97 -0
- package/dist/demo/demo-banner.js.map +1 -0
- package/dist/demo/demo-countdown.d.ts +58 -0
- package/dist/demo/demo-countdown.js +79 -0
- package/dist/demo/demo-countdown.js.map +1 -0
- package/dist/demo/demo-ended.d.ts +45 -0
- package/dist/demo/demo-ended.js +42 -0
- package/dist/demo/demo-ended.js.map +1 -0
- package/dist/demo/demo-labels.d.ts +53 -0
- package/dist/demo/demo-labels.js +29 -0
- package/dist/demo/demo-labels.js.map +1 -0
- package/dist/demo/demo-session.d.ts +30 -0
- package/dist/demo/demo-session.js +8 -0
- package/dist/demo/demo-session.js.map +1 -0
- package/dist/demo/demo-start.d.ts +54 -0
- package/dist/demo/demo-start.js +68 -0
- package/dist/demo/demo-start.js.map +1 -0
- package/dist/feedback/feedback-attachment.d.ts +5 -1
- package/dist/feedback/feedback-context.d.ts +5 -1
- package/dist/feedback/feedback-crash.d.ts +5 -1
- package/dist/feedback/feedback-dialog.d.ts +5 -1
- package/dist/feedback/feedback-inbox.d.ts +5 -1
- package/dist/feedback/feedback-inbox.js +12 -2
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-labels.d.ts +5 -1
- package/dist/feedback/feedback-labels.js +1 -0
- package/dist/feedback/feedback-labels.js.map +1 -1
- package/dist/feedback/feedback-menu.d.ts +5 -1
- package/dist/feedback/feedback-record.d.ts +5 -1
- package/dist/feedback/feedback-record.js +2 -0
- package/dist/feedback/feedback-record.js.map +1 -1
- package/dist/feedback/feedback-row-detail.d.ts +5 -1
- package/dist/feedback/feedback-row-detail.js +7 -0
- package/dist/feedback/feedback-row-detail.js.map +1 -1
- package/dist/feedback/feedback-status-undo.d.ts +5 -1
- package/dist/feedback/feedback-submit.d.ts +5 -1
- package/dist/feedback/feedback-swipe.d.ts +6 -2
- package/dist/feedback/feedback-swipe.js.map +1 -1
- package/dist/feedback/feedback-table.d.ts +5 -1
- package/dist/feedback/feedback-thread.d.ts +5 -1
- package/dist/feedback.d.ts +5 -1
- package/dist/hooks/use-file-drop.d.ts +5 -1
- package/dist/i18n/defaults.d.ts +5 -1
- package/dist/i18n/defaults.js +6 -0
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +5 -1
- package/dist/i18n/german.js +85 -2
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +5 -1
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +5 -1
- package/dist/i18n/locales/de-CH.d.ts +5 -1
- package/dist/i18n/locales/en.d.ts +5 -1
- package/dist/i18n/locales/es.d.ts +5 -1
- package/dist/i18n/locales/es.js +82 -2
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +5 -1
- package/dist/i18n/locales/fr.js +83 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +5 -1
- package/dist/i18n/locales/hu.js +83 -2
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +5 -1
- package/dist/i18n/locales/it.js +82 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +5 -1
- package/dist/i18n/locales/zh.js +81 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +5 -1
- package/dist/i18n/review.js +15 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +25 -3
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -1
- package/dist/landing/access.d.ts +48 -0
- package/dist/landing/access.js +38 -0
- package/dist/landing/access.js.map +1 -0
- package/dist/landing/landing-actions.d.ts +140 -0
- package/dist/landing/landing-actions.js +39 -0
- package/dist/landing/landing-actions.js.map +1 -0
- package/dist/landing/landing-labels.d.ts +43 -0
- package/dist/landing/landing-labels.js +23 -0
- package/dist/landing/landing-labels.js.map +1 -0
- package/dist/landing/landing-sections.d.ts +218 -0
- package/dist/landing/landing-sections.js +167 -0
- package/dist/landing/landing-sections.js.map +1 -0
- package/dist/landing/page-seo.d.ts +99 -0
- package/dist/landing/page-seo.js +121 -0
- package/dist/landing/page-seo.js.map +1 -0
- package/dist/landing/public-header.d.ts +148 -0
- package/dist/landing/public-header.js +49 -0
- package/dist/landing/public-header.js.map +1 -0
- package/dist/landing/routing.d.ts +231 -0
- package/dist/landing/routing.js +84 -0
- package/dist/landing/routing.js.map +1 -0
- package/dist/rhf/fields.d.ts +5 -1
- package/dist/rhf/form.d.ts +5 -1
- package/dist/rhf.d.ts +5 -1
- package/dist/settings/settings-catalogue.d.ts +84 -0
- package/dist/settings/settings-catalogue.js +47 -0
- package/dist/settings/settings-catalogue.js.map +1 -0
- package/dist/settings/settings-context.d.ts +31 -0
- package/dist/settings/settings-context.js +11 -0
- package/dist/settings/settings-context.js.map +1 -0
- package/dist/settings/settings-heading.d.ts +50 -0
- package/dist/settings/settings-heading.js +27 -0
- package/dist/settings/settings-heading.js.map +1 -0
- package/dist/settings/settings-labels.d.ts +48 -0
- package/dist/settings/settings-labels.js +43 -0
- package/dist/settings/settings-labels.js.map +1 -0
- package/dist/settings/settings-layout.d.ts +77 -0
- package/dist/settings/settings-layout.js +242 -0
- package/dist/settings/settings-layout.js.map +1 -0
- package/dist/settings/settings-section.d.ts +133 -0
- package/dist/settings/settings-section.js +63 -0
- package/dist/settings/settings-section.js.map +1 -0
- package/dist/settings/use-account-language.d.ts +83 -0
- package/dist/settings/use-account-language.js +62 -0
- package/dist/settings/use-account-language.js.map +1 -0
- package/dist/settings/use-settings-focus.d.ts +34 -0
- package/dist/settings/use-settings-focus.js +77 -0
- package/dist/settings/use-settings-focus.js.map +1 -0
- package/dist/settings/use-settings-route.d.ts +118 -0
- package/dist/settings/use-settings-route.js +120 -0
- package/dist/settings/use-settings-route.js.map +1 -0
- package/dist/shell/app-shell.d.ts +11 -1
- package/dist/shell/app-shell.js +3 -2
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/top-bar-brand.d.ts +5 -1
- package/dist/shell.d.ts +15 -1
- package/dist/shell.js +56 -0
- package/dist/shell.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +5 -1
- package/dist/wizard.d.ts +5 -1
- package/package.json +2 -1
- package/src/account/data-export-setting.tsx +3 -2
- package/src/account/delete-account-setting.tsx +3 -2
- package/src/account/email-change-setting.tsx +4 -7
- package/src/account/sessions-setting.tsx +3 -2
- package/src/admin/admin-parts.ts +9 -2
- package/src/admin/invitations-panel.tsx +11 -4
- package/src/auth/auth-errors.ts +36 -5
- package/src/auth/reset-password-form.tsx +6 -2
- package/src/auth/sign-in-form.tsx +34 -3
- package/src/auth/verify-email.tsx +14 -2
- package/src/components/account-settings-labels.ts +13 -0
- package/src/components/account-settings.tsx +33 -12
- package/src/components/confirm-dialog.tsx +20 -1
- package/src/components/data-table.tsx +8 -0
- package/src/components/date-picker.tsx +9 -4
- package/src/components/passkeys-setting.tsx +2 -1
- package/src/components/settings-fields.tsx +50 -1
- package/src/demo/demo-banner.tsx +159 -0
- package/src/demo/demo-countdown.ts +141 -0
- package/src/demo/demo-ended.tsx +89 -0
- package/src/demo/demo-labels.ts +78 -0
- package/src/demo/demo-session.ts +32 -0
- package/src/demo/demo-start.tsx +150 -0
- package/src/feedback/feedback-inbox.tsx +21 -8
- package/src/feedback/feedback-labels.ts +2 -1
- package/src/feedback/feedback-record.ts +10 -7
- package/src/feedback/feedback-row-detail.tsx +28 -4
- package/src/feedback/feedback-swipe.tsx +1 -1
- package/src/i18n/defaults.ts +6 -0
- package/src/i18n/german.ts +87 -0
- package/src/i18n/kit-labels.tsx +9 -0
- package/src/i18n/locales/es.ts +84 -0
- package/src/i18n/locales/fr.ts +85 -0
- package/src/i18n/locales/hu.ts +85 -0
- package/src/i18n/locales/it.ts +84 -0
- package/src/i18n/locales/zh.ts +82 -0
- package/src/i18n/review.ts +14 -0
- package/src/index.ts +98 -1
- package/src/landing/access.ts +97 -0
- package/src/landing/landing-actions.tsx +96 -0
- package/src/landing/landing-labels.ts +59 -0
- package/src/landing/landing-sections.tsx +337 -0
- package/src/landing/page-seo.ts +251 -0
- package/src/landing/public-header.tsx +120 -0
- package/src/landing/routing.tsx +226 -0
- package/src/settings/settings-catalogue.ts +132 -0
- package/src/settings/settings-context.ts +33 -0
- package/src/settings/settings-heading.tsx +65 -0
- package/src/settings/settings-labels.ts +87 -0
- package/src/settings/settings-layout.tsx +379 -0
- package/src/settings/settings-section.tsx +108 -0
- package/src/settings/use-account-language.ts +146 -0
- package/src/settings/use-settings-focus.ts +120 -0
- package/src/settings/use-settings-route.ts +258 -0
- package/src/shell/app-shell.tsx +10 -2
- package/src/shell.ts +51 -0
package/dist/chart.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { TimeTickUnit } from './components/series-chart-ticks.js';
|
|
|
13
13
|
import 'recharts';
|
|
14
14
|
import 'react';
|
|
15
15
|
import './lib/direction.js';
|
|
16
|
-
import './delete-account-setting-
|
|
16
|
+
import './delete-account-setting-CpIhzxxZ.js';
|
|
17
17
|
import './components/tooltip.js';
|
|
18
18
|
import './hooks/use-anchored-rect.js';
|
|
19
19
|
import './lib/clipping.js';
|
|
@@ -66,6 +66,8 @@ import './components/image-grid.js';
|
|
|
66
66
|
import './components/lightbox.js';
|
|
67
67
|
import './components/write-lock.js';
|
|
68
68
|
import './auth/sign-in-form.js';
|
|
69
|
+
import './landing/access.js';
|
|
70
|
+
import './landing/landing-labels.js';
|
|
69
71
|
import './shell/topbar-controls.js';
|
|
70
72
|
import './theme/palette-presets.js';
|
|
71
73
|
import './theme/theme-store.js';
|
|
@@ -86,6 +88,8 @@ import './account/data-export-setting.js';
|
|
|
86
88
|
import './components/account-chips.js';
|
|
87
89
|
import './admin/admin-parts.js';
|
|
88
90
|
import './admin/admin-action-log.js';
|
|
91
|
+
import './settings/settings-labels.js';
|
|
92
|
+
import './demo/demo-labels.js';
|
|
89
93
|
import './components/reauth-dialog.js';
|
|
90
94
|
import './components/server-wake.js';
|
|
91
95
|
import './lib/server-wake.js';
|
|
@@ -40,6 +40,12 @@ interface PasswordSettingLabels {
|
|
|
40
40
|
mismatch: string;
|
|
41
41
|
}
|
|
42
42
|
interface TwoFactorSettingLabels {
|
|
43
|
+
/**
|
|
44
|
+
* Before 0.31 the card's one line, "<status>: On". Since 0.31 the setting's name is the
|
|
45
|
+
* card's {@link title} and the state stands beside it, so this is read only where no
|
|
46
|
+
* `title` is given at the same level — an app that translated `status` keeps its word
|
|
47
|
+
* as the title.
|
|
48
|
+
*/
|
|
43
49
|
status: string;
|
|
44
50
|
enabledText: string;
|
|
45
51
|
disabledText: string;
|
|
@@ -64,6 +70,12 @@ interface TwoFactorSettingLabels {
|
|
|
64
70
|
secretHint?: string;
|
|
65
71
|
/** The copy button beside that key. */
|
|
66
72
|
copySecret?: string;
|
|
73
|
+
/**
|
|
74
|
+
* 0.31.0 (docs/settings-harmonization.md §3.7): the card's title, a heading inside a
|
|
75
|
+
* `SettingsLayout`. OPTIONAL for the reason `qrAlt` is. Unset, the same source's
|
|
76
|
+
* `status` stands in for it, then English.
|
|
77
|
+
*/
|
|
78
|
+
title?: string;
|
|
67
79
|
}
|
|
68
80
|
interface PasskeysSettingLabels {
|
|
69
81
|
title: string;
|
|
@@ -36,7 +36,8 @@ const DEFAULT_ACCOUNT_SETTINGS_LABELS = {
|
|
|
36
36
|
// Unchanged from the fallback it had before the namespace (i18n-labels.test pins it).
|
|
37
37
|
qrAlt: "QR code",
|
|
38
38
|
secretHint: "Can\u2019t scan it? Enter this key in the app instead:",
|
|
39
|
-
copySecret: "Copy key"
|
|
39
|
+
copySecret: "Copy key",
|
|
40
|
+
title: "Two-factor authentication"
|
|
40
41
|
},
|
|
41
42
|
passkeys: {
|
|
42
43
|
title: "Passkeys",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/account-settings-labels.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useKitLabelOverrides } from \"../i18n/kit-labels\";\n\n/**\n * The `accountSettings` namespace of `<UiKitProvider labels>`: one record per section —\n * `profile`, `password`, `twoFactor`, `passkeys` — each merged key by key, so an app\n * can translate `accountSettings.twoFactor.scanHint` alone.\n *\n * Before 0.12.0 every section took a REQUIRED `labels` prop and had no English of its\n * own, so each app spelled out 30-odd keys at the call site and still hard-coded some\n * (kastlan's profile page passed `email: \"Email\"` in English to a German page). The\n * prop stays, now partial, and wins over the provider as everywhere else in the kit.\n *\n * Its own module, beside the components rather than in them, so `PasskeysSetting`\n * (its own file) and the older three read one tree without importing each other.\n */\n\nexport interface ProfileSettingLabels {\n title: string;\n email: string;\n role: string;\n memberSince: string;\n /** The single name field — the card without `firstName` / `lastName`. */\n displayName: string;\n save: string;\n /**\n * 0.30.0 (docs/user-admin-harmonization.md §6.1): the two fields that replace\n * `displayName` once the card is given `firstName` / `lastName`. OPTIONAL, like\n * `TwoFactorSettingLabels.qrAlt` and for its reason — this interface is annotated at\n * call sites — and filled from the provider's `accountSettings.profile`, then English.\n */\n firstName?: string;\n lastName?: string;\n /** Why Save is held while a name is blank: both are required (§3.1). */\n nameRequired?: string;\n}\n\nexport interface PasswordSettingLabels {\n title: string;\n current: string;\n next: string;\n confirm: string;\n submit: string;\n tooShort: string;\n mismatch: string;\n}\n\nexport interface TwoFactorSettingLabels {\n status: string;\n enabledText: string;\n disabledText: string;\n enable: string;\n scanHint: string;\n codeLabel: string;\n verify: string;\n disableSection: string;\n password: string;\n disable: string;\n /**\n * Alt text for the setup QR code, which shipped as a hardcoded `alt=\"QR\"`.\n *\n * OPTIONAL, like the two keys below, and not because it matters less: this interface\n * is annotated at consumer call sites (`const LABELS: TwoFactorSettingLabels = {…}`),\n * so a new REQUIRED key is a compile error in every app on the next `npm update` —\n * the additive-API rule in the README. Each falls back to the provider's\n * `accountSettings.twoFactor`, then English.\n */\n qrAlt?: string;\n /** The line over the manual-entry key, for a phone that cannot scan its own screen. */\n secretHint?: string;\n /** The copy button beside that key. */\n copySecret?: string;\n}\n\nexport interface PasskeysSettingLabels {\n title: string;\n /** The line under the title saying what a passkey is for — `mode=\"instead\"` (the\n * default): the passkey stands in for the password. */\n description: string;\n /**\n * The same line for `mode=\"alongside\"` (0.18.0): the password keeps working and the\n * passkey is a second way in. OPTIONAL for the reason `TwoFactorSettingLabels.qrAlt`\n * is — this interface is annotated at call sites — and filled from the provider's\n * `accountSettings.passkeys`, then English.\n */\n descriptionAlongside?: string;\n empty: string;\n loading: string;\n /** Accessible name of the list. */\n list: string;\n nameLabel: string;\n namePlaceholder: string;\n add: string;\n /** The add button while the app's WebAuthn ceremony runs — the OS prompt is open. */\n adding: string;\n rename: string;\n /** The row's rename button, named for its passkey — it starts with `rename`, the\n * visible text, so voice control finds it by what it says. */\n renameItem: (name: string) => string;\n /** Accessible name of the inline rename field. */\n renameField: (name: string) => string;\n save: string;\n cancel: string;\n delete: string;\n /** The row's delete button, named for its passkey (see `renameItem`). */\n deleteItem: (name: string) => string;\n /** The inline question a delete asks first. */\n deleteConfirm: (name: string) => string;\n /** The destructive button that answers it. */\n confirmDelete: string;\n /** `date` arrives formatted in the provider's locale. */\n created: (date: string) => string;\n lastUsed: (date: string) => string;\n neverUsed: string;\n}\n\nexport interface AccountSettingsLabels {\n profile: Required<ProfileSettingLabels>;\n password: PasswordSettingLabels;\n // `Required` here, optional on the section interfaces: the namespace is what a full\n // catalogue (`@eifi1/ui-kit/i18n/<code>`, `missingKitLabels`) is written against, so\n // it must name the late keys; the section interfaces are annotated at call sites.\n twoFactor: Required<TwoFactorSettingLabels>;\n passkeys: Required<PasskeysSettingLabels>;\n}\n\nexport const DEFAULT_ACCOUNT_SETTINGS_LABELS: AccountSettingsLabels = {\n profile: {\n title: \"Profile\",\n email: \"Email\",\n role: \"Role\",\n memberSince: \"Member since\",\n displayName: \"Display name\",\n save: \"Save\",\n firstName: \"First name\",\n lastName: \"Last name\",\n nameRequired: \"Enter both a first and a last name.\",\n },\n password: {\n title: \"Change password\",\n current: \"Current password\",\n next: \"New password\",\n confirm: \"Confirm new password\",\n submit: \"Change password\",\n tooShort: \"The new password is too short.\",\n mismatch: \"The passwords don’t match.\",\n },\n twoFactor: {\n status: \"Two-factor authentication\",\n enabledText: \"On\",\n disabledText: \"Off\",\n enable: \"Set up two-factor authentication\",\n scanHint: \"Scan this code with your authenticator app, then enter the code it shows.\",\n codeLabel: \"Verification code\",\n verify: \"Verify and turn on\",\n disableSection: \"Turn off two-factor authentication\",\n password: \"Current password\",\n disable: \"Turn off\",\n // Unchanged from the fallback it had before the namespace (i18n-labels.test pins it).\n qrAlt: \"QR code\",\n secretHint: \"Can’t scan it? Enter this key in the app instead:\",\n copySecret: \"Copy key\",\n },\n passkeys: {\n title: \"Passkeys\",\n description: \"Sign in with your fingerprint, face or device PIN instead of a password.\",\n // Kurvenschmiede overrode `description` because \"instead of\" is false where the\n // password stays; this is the sentence for those apps, picked by `mode`.\n descriptionAlongside: \"Sign in with your fingerprint, face or device PIN. Your password keeps working too.\",\n empty: \"No passkeys yet\",\n loading: \"Loading passkeys…\",\n list: \"Your passkeys\",\n nameLabel: \"Name (optional)\",\n namePlaceholder: \"e.g. Laptop, Phone\",\n add: \"Add passkey\",\n adding: \"Waiting for your device…\",\n rename: \"Rename\",\n renameItem: (name) => `Rename ${name}`,\n renameField: (name) => `New name for ${name}`,\n save: \"Save\",\n cancel: \"Cancel\",\n delete: \"Delete\",\n deleteItem: (name) => `Delete ${name}`,\n deleteConfirm: (name) => `Delete “${name}”? It can no longer be used to sign in.`,\n confirmDelete: \"Delete passkey\",\n created: (date) => `Added ${date}`,\n lastUsed: (date) => `Last used ${date}`,\n neverUsed: \"Never used\",\n },\n};\n\n/**\n * One section of the namespace, resolved: English, then the provider's\n * `accountSettings.<section>`, then the component's own `labels` prop. An `undefined`\n * in either source is skipped, so a prop object built from optional values cannot\n * blank out a default.\n */\nexport function useAccountSettingsLabels<K extends keyof AccountSettingsLabels>(\n section: K,\n prop?: Partial<AccountSettingsLabels[K]>,\n): AccountSettingsLabels[K] {\n const fromProvider = useKitLabelOverrides(\"accountSettings\")?.[section] as\n | Partial<AccountSettingsLabels[K]>\n | undefined;\n return useMemo(\n () => ({\n ...DEFAULT_ACCOUNT_SETTINGS_LABELS[section],\n ...definedOnly(fromProvider),\n ...definedOnly(prop),\n }),\n [section, fromProvider, prop],\n );\n}\n\nfunction definedOnly<T extends object>(value: T | undefined): Partial<T> {\n if (!value) return {};\n return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined)) as Partial<T>;\n}\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,4BAA4B;AA6H9B,MAAM,kCAAyD;AAAA,EACpE,SAAS;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,MAAM;AAAA,IACN,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,EAChB;AAAA,EACA,UAAU;AAAA,IACR,OAAO;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AAAA,EACA,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,SAAS;AAAA;AAAA,IAET,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,YAAY;AAAA,EACd;AAAA,EACA,UAAU;AAAA,IACR,OAAO;AAAA,IACP,aAAa;AAAA;AAAA;AAAA,IAGb,sBAAsB;AAAA,IACtB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,YAAY,CAAC,SAAS,UAAU,IAAI;AAAA,IACpC,aAAa,CAAC,SAAS,gBAAgB,IAAI;AAAA,IAC3C,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,YAAY,CAAC,SAAS,UAAU,IAAI;AAAA,IACpC,eAAe,CAAC,SAAS,gBAAW,IAAI;AAAA,IACxC,eAAe;AAAA,IACf,SAAS,CAAC,SAAS,SAAS,IAAI;AAAA,IAChC,UAAU,CAAC,SAAS,aAAa,IAAI;AAAA,IACrC,WAAW;AAAA,EACb;AACF;AAQO,SAAS,yBACd,SACA,MAC0B;AAC1B,QAAM,eAAe,qBAAqB,iBAAiB,IAAI,OAAO;AAGtE,SAAO;AAAA,IACL,OAAO;AAAA,MACL,GAAG,gCAAgC,OAAO;AAAA,MAC1C,GAAG,YAAY,YAAY;AAAA,MAC3B,GAAG,YAAY,IAAI;AAAA,IACrB;AAAA,IACA,CAAC,SAAS,cAAc,IAAI;AAAA,EAC9B;AACF;AAEA,SAAS,YAA8B,OAAkC;AACvE,MAAI,CAAC,MAAO,QAAO,CAAC;AACpB,SAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS,CAAC;AACpF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/account-settings-labels.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useKitLabelOverrides } from \"../i18n/kit-labels\";\n\n/**\n * The `accountSettings` namespace of `<UiKitProvider labels>`: one record per section —\n * `profile`, `password`, `twoFactor`, `passkeys` — each merged key by key, so an app\n * can translate `accountSettings.twoFactor.scanHint` alone.\n *\n * Before 0.12.0 every section took a REQUIRED `labels` prop and had no English of its\n * own, so each app spelled out 30-odd keys at the call site and still hard-coded some\n * (kastlan's profile page passed `email: \"Email\"` in English to a German page). The\n * prop stays, now partial, and wins over the provider as everywhere else in the kit.\n *\n * Its own module, beside the components rather than in them, so `PasskeysSetting`\n * (its own file) and the older three read one tree without importing each other.\n */\n\nexport interface ProfileSettingLabels {\n title: string;\n email: string;\n role: string;\n memberSince: string;\n /** The single name field — the card without `firstName` / `lastName`. */\n displayName: string;\n save: string;\n /**\n * 0.30.0 (docs/user-admin-harmonization.md §6.1): the two fields that replace\n * `displayName` once the card is given `firstName` / `lastName`. OPTIONAL, like\n * `TwoFactorSettingLabels.qrAlt` and for its reason — this interface is annotated at\n * call sites — and filled from the provider's `accountSettings.profile`, then English.\n */\n firstName?: string;\n lastName?: string;\n /** Why Save is held while a name is blank: both are required (§3.1). */\n nameRequired?: string;\n}\n\nexport interface PasswordSettingLabels {\n title: string;\n current: string;\n next: string;\n confirm: string;\n submit: string;\n tooShort: string;\n mismatch: string;\n}\n\nexport interface TwoFactorSettingLabels {\n /**\n * Before 0.31 the card's one line, \"<status>: On\". Since 0.31 the setting's name is the\n * card's {@link title} and the state stands beside it, so this is read only where no\n * `title` is given at the same level — an app that translated `status` keeps its word\n * as the title.\n */\n status: string;\n enabledText: string;\n disabledText: string;\n enable: string;\n scanHint: string;\n codeLabel: string;\n verify: string;\n disableSection: string;\n password: string;\n disable: string;\n /**\n * Alt text for the setup QR code, which shipped as a hardcoded `alt=\"QR\"`.\n *\n * OPTIONAL, like the two keys below, and not because it matters less: this interface\n * is annotated at consumer call sites (`const LABELS: TwoFactorSettingLabels = {…}`),\n * so a new REQUIRED key is a compile error in every app on the next `npm update` —\n * the additive-API rule in the README. Each falls back to the provider's\n * `accountSettings.twoFactor`, then English.\n */\n qrAlt?: string;\n /** The line over the manual-entry key, for a phone that cannot scan its own screen. */\n secretHint?: string;\n /** The copy button beside that key. */\n copySecret?: string;\n /**\n * 0.31.0 (docs/settings-harmonization.md §3.7): the card's title, a heading inside a\n * `SettingsLayout`. OPTIONAL for the reason `qrAlt` is. Unset, the same source's\n * `status` stands in for it, then English.\n */\n title?: string;\n}\n\nexport interface PasskeysSettingLabels {\n title: string;\n /** The line under the title saying what a passkey is for — `mode=\"instead\"` (the\n * default): the passkey stands in for the password. */\n description: string;\n /**\n * The same line for `mode=\"alongside\"` (0.18.0): the password keeps working and the\n * passkey is a second way in. OPTIONAL for the reason `TwoFactorSettingLabels.qrAlt`\n * is — this interface is annotated at call sites — and filled from the provider's\n * `accountSettings.passkeys`, then English.\n */\n descriptionAlongside?: string;\n empty: string;\n loading: string;\n /** Accessible name of the list. */\n list: string;\n nameLabel: string;\n namePlaceholder: string;\n add: string;\n /** The add button while the app's WebAuthn ceremony runs — the OS prompt is open. */\n adding: string;\n rename: string;\n /** The row's rename button, named for its passkey — it starts with `rename`, the\n * visible text, so voice control finds it by what it says. */\n renameItem: (name: string) => string;\n /** Accessible name of the inline rename field. */\n renameField: (name: string) => string;\n save: string;\n cancel: string;\n delete: string;\n /** The row's delete button, named for its passkey (see `renameItem`). */\n deleteItem: (name: string) => string;\n /** The inline question a delete asks first. */\n deleteConfirm: (name: string) => string;\n /** The destructive button that answers it. */\n confirmDelete: string;\n /** `date` arrives formatted in the provider's locale. */\n created: (date: string) => string;\n lastUsed: (date: string) => string;\n neverUsed: string;\n}\n\nexport interface AccountSettingsLabels {\n profile: Required<ProfileSettingLabels>;\n password: PasswordSettingLabels;\n // `Required` here, optional on the section interfaces: the namespace is what a full\n // catalogue (`@eifi1/ui-kit/i18n/<code>`, `missingKitLabels`) is written against, so\n // it must name the late keys; the section interfaces are annotated at call sites.\n twoFactor: Required<TwoFactorSettingLabels>;\n passkeys: Required<PasskeysSettingLabels>;\n}\n\nexport const DEFAULT_ACCOUNT_SETTINGS_LABELS: AccountSettingsLabels = {\n profile: {\n title: \"Profile\",\n email: \"Email\",\n role: \"Role\",\n memberSince: \"Member since\",\n displayName: \"Display name\",\n save: \"Save\",\n firstName: \"First name\",\n lastName: \"Last name\",\n nameRequired: \"Enter both a first and a last name.\",\n },\n password: {\n title: \"Change password\",\n current: \"Current password\",\n next: \"New password\",\n confirm: \"Confirm new password\",\n submit: \"Change password\",\n tooShort: \"The new password is too short.\",\n mismatch: \"The passwords don’t match.\",\n },\n twoFactor: {\n status: \"Two-factor authentication\",\n enabledText: \"On\",\n disabledText: \"Off\",\n enable: \"Set up two-factor authentication\",\n scanHint: \"Scan this code with your authenticator app, then enter the code it shows.\",\n codeLabel: \"Verification code\",\n verify: \"Verify and turn on\",\n disableSection: \"Turn off two-factor authentication\",\n password: \"Current password\",\n disable: \"Turn off\",\n // Unchanged from the fallback it had before the namespace (i18n-labels.test pins it).\n qrAlt: \"QR code\",\n secretHint: \"Can’t scan it? Enter this key in the app instead:\",\n copySecret: \"Copy key\",\n title: \"Two-factor authentication\",\n },\n passkeys: {\n title: \"Passkeys\",\n description: \"Sign in with your fingerprint, face or device PIN instead of a password.\",\n // Kurvenschmiede overrode `description` because \"instead of\" is false where the\n // password stays; this is the sentence for those apps, picked by `mode`.\n descriptionAlongside: \"Sign in with your fingerprint, face or device PIN. Your password keeps working too.\",\n empty: \"No passkeys yet\",\n loading: \"Loading passkeys…\",\n list: \"Your passkeys\",\n nameLabel: \"Name (optional)\",\n namePlaceholder: \"e.g. Laptop, Phone\",\n add: \"Add passkey\",\n adding: \"Waiting for your device…\",\n rename: \"Rename\",\n renameItem: (name) => `Rename ${name}`,\n renameField: (name) => `New name for ${name}`,\n save: \"Save\",\n cancel: \"Cancel\",\n delete: \"Delete\",\n deleteItem: (name) => `Delete ${name}`,\n deleteConfirm: (name) => `Delete “${name}”? It can no longer be used to sign in.`,\n confirmDelete: \"Delete passkey\",\n created: (date) => `Added ${date}`,\n lastUsed: (date) => `Last used ${date}`,\n neverUsed: \"Never used\",\n },\n};\n\n/**\n * One section of the namespace, resolved: English, then the provider's\n * `accountSettings.<section>`, then the component's own `labels` prop. An `undefined`\n * in either source is skipped, so a prop object built from optional values cannot\n * blank out a default.\n */\nexport function useAccountSettingsLabels<K extends keyof AccountSettingsLabels>(\n section: K,\n prop?: Partial<AccountSettingsLabels[K]>,\n): AccountSettingsLabels[K] {\n const fromProvider = useKitLabelOverrides(\"accountSettings\")?.[section] as\n | Partial<AccountSettingsLabels[K]>\n | undefined;\n return useMemo(\n () => ({\n ...DEFAULT_ACCOUNT_SETTINGS_LABELS[section],\n ...definedOnly(fromProvider),\n ...definedOnly(prop),\n }),\n [section, fromProvider, prop],\n );\n}\n\nfunction definedOnly<T extends object>(value: T | undefined): Partial<T> {\n if (!value) return {};\n return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined)) as Partial<T>;\n}\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,4BAA4B;AAyI9B,MAAM,kCAAyD;AAAA,EACpE,SAAS;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,MAAM;AAAA,IACN,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,EAChB;AAAA,EACA,UAAU;AAAA,IACR,OAAO;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AAAA,EACA,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,SAAS;AAAA;AAAA,IAET,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,OAAO;AAAA,EACT;AAAA,EACA,UAAU;AAAA,IACR,OAAO;AAAA,IACP,aAAa;AAAA;AAAA;AAAA,IAGb,sBAAsB;AAAA,IACtB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,YAAY,CAAC,SAAS,UAAU,IAAI;AAAA,IACpC,aAAa,CAAC,SAAS,gBAAgB,IAAI;AAAA,IAC3C,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,YAAY,CAAC,SAAS,UAAU,IAAI;AAAA,IACpC,eAAe,CAAC,SAAS,gBAAW,IAAI;AAAA,IACxC,eAAe;AAAA,IACf,SAAS,CAAC,SAAS,SAAS,IAAI;AAAA,IAChC,UAAU,CAAC,SAAS,aAAa,IAAI;AAAA,IACrC,WAAW;AAAA,EACb;AACF;AAQO,SAAS,yBACd,SACA,MAC0B;AAC1B,QAAM,eAAe,qBAAqB,iBAAiB,IAAI,OAAO;AAGtE,SAAO;AAAA,IACL,OAAO;AAAA,MACL,GAAG,gCAAgC,OAAO;AAAA,MAC1C,GAAG,YAAY,YAAY;AAAA,MAC3B,GAAG,YAAY,IAAI;AAAA,IACrB;AAAA,IACA,CAAC,SAAS,cAAc,IAAI;AAAA,EAC9B;AACF;AAEA,SAAS,YAA8B,OAAkC;AACvE,MAAI,CAAC,MAAO,QAAO,CAAC;AACpB,SAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS,CAAC;AACpF;","names":[]}
|
|
@@ -29,6 +29,8 @@ interface ProfileSettingCommonProps {
|
|
|
29
29
|
saving?: boolean;
|
|
30
30
|
/** Prop > `<UiKitProvider labels={{ accountSettings: { profile } }}>` > English. */
|
|
31
31
|
labels?: Partial<ProfileSettingLabels>;
|
|
32
|
+
/** The card's DOM id — a settings catalogue `anchor`, so `?focus=` can ring it (0.31). */
|
|
33
|
+
id?: string;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* The single display name, as before 0.30.0 — controlled through `value` / `onChange`,
|
|
@@ -87,7 +89,7 @@ declare function ProfileSetting(props: ProfileSettingProps): react.JSX.Element;
|
|
|
87
89
|
* (the card's own prop, which the submit enforces as well).
|
|
88
90
|
*/
|
|
89
91
|
type PasswordSettingStrength = Pick<PasswordStrengthMeterProps, "score" | "showRequirements" | "labels">;
|
|
90
|
-
declare function PasswordSetting({ onSubmit, pending, minLength, strength, maxBytes, labels: labelsProp, }: {
|
|
92
|
+
declare function PasswordSetting({ onSubmit, pending, minLength, strength, maxBytes, labels: labelsProp, id, }: {
|
|
91
93
|
/** Called with the validated (current, new) pair; return a promise to auto-clear on success. */
|
|
92
94
|
onSubmit: (currentPassword: string, newPassword: string) => void | Promise<unknown>;
|
|
93
95
|
pending?: boolean;
|
|
@@ -117,6 +119,8 @@ declare function PasswordSetting({ onSubmit, pending, minLength, strength, maxBy
|
|
|
117
119
|
maxBytes?: number;
|
|
118
120
|
/** Prop > `<UiKitProvider labels={{ accountSettings: { password } }}>` > English. */
|
|
119
121
|
labels?: Partial<PasswordSettingLabels>;
|
|
122
|
+
/** The card's DOM id — a settings catalogue `anchor`, so `?focus=` can ring it (0.31). */
|
|
123
|
+
id?: string;
|
|
120
124
|
}): react.JSX.Element;
|
|
121
125
|
/**
|
|
122
126
|
* What the app's setup call returned.
|
|
@@ -134,7 +138,7 @@ type TwoFactorSetupData = {
|
|
|
134
138
|
otpauthUri: string;
|
|
135
139
|
secret?: string;
|
|
136
140
|
};
|
|
137
|
-
declare function TwoFactorSetting({ enabled, setup, onStartSetup, onEnable, onDisable, busy, renderQr, labels: labelsProp, }: {
|
|
141
|
+
declare function TwoFactorSetting({ enabled, setup, onStartSetup, onEnable, onDisable, busy, renderQr, labels: labelsProp, id, }: {
|
|
138
142
|
enabled: boolean;
|
|
139
143
|
/** What the app's setup call returned; null before setup starts. */
|
|
140
144
|
setup: TwoFactorSetupData | null;
|
|
@@ -147,6 +151,8 @@ declare function TwoFactorSetting({ enabled, setup, onStartSetup, onEnable, onDi
|
|
|
147
151
|
renderQr?: (otpauthUri: string) => ReactNode;
|
|
148
152
|
/** Prop > `<UiKitProvider labels={{ accountSettings: { twoFactor } }}>` > English. */
|
|
149
153
|
labels?: Partial<TwoFactorSettingLabels>;
|
|
154
|
+
/** The card's DOM id — a settings catalogue `anchor`, so `?focus=` can ring it (0.31). */
|
|
155
|
+
id?: string;
|
|
150
156
|
}): react.JSX.Element;
|
|
151
157
|
|
|
152
158
|
export { PasswordSetting, PasswordSettingLabels, type PasswordSettingStrength, type ProfileNameValues, ProfileSetting, type ProfileSettingDisplayNameProps, ProfileSettingLabels, type ProfileSettingNamesProps, type ProfileSettingProps, TwoFactorSetting, TwoFactorSettingLabels, type TwoFactorSetupData };
|
|
@@ -13,14 +13,16 @@ import {
|
|
|
13
13
|
passwordByteLength,
|
|
14
14
|
PasswordStrengthMeter
|
|
15
15
|
} from "./password-strength.js";
|
|
16
|
-
import {
|
|
16
|
+
import { useKitLabelOverrides, useKitLabels } from "../i18n/kit-labels.js";
|
|
17
|
+
import { Chip } from "./chip.js";
|
|
17
18
|
import { useAccountSettingsLabels } from "./account-settings-labels.js";
|
|
19
|
+
import { SettingsCardTitle } from "../settings/settings-heading.js";
|
|
18
20
|
import { DEFAULT_ACCOUNT_SETTINGS_LABELS } from "./account-settings-labels.js";
|
|
19
21
|
function ProfileSetting(props) {
|
|
20
|
-
const { name, email, role, memberSince, labels: labelsProp } = props;
|
|
22
|
+
const { name, email, role, memberSince, labels: labelsProp, id } = props;
|
|
21
23
|
const labels = useAccountSettingsLabels("profile", labelsProp);
|
|
22
24
|
const names = props.firstName !== void 0 || props.lastName !== void 0;
|
|
23
|
-
return /* @__PURE__ */ jsxs(Card, { className: "p-4 space-y-3", children: [
|
|
25
|
+
return /* @__PURE__ */ jsxs(Card, { id, className: "p-4 space-y-3", children: [
|
|
24
26
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
25
27
|
/* @__PURE__ */ jsx(
|
|
26
28
|
UserAvatar,
|
|
@@ -32,7 +34,7 @@ function ProfileSetting(props) {
|
|
|
32
34
|
}
|
|
33
35
|
),
|
|
34
36
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
35
|
-
/* @__PURE__ */ jsx(
|
|
37
|
+
/* @__PURE__ */ jsx(SettingsCardTitle, { children: labels.title }),
|
|
36
38
|
/* @__PURE__ */ jsxs("div", { className: "truncate font-mono text-xs text-[var(--text-muted)]", children: [
|
|
37
39
|
/* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
|
|
38
40
|
labels.email,
|
|
@@ -167,7 +169,8 @@ function PasswordSetting({
|
|
|
167
169
|
minLength = 8,
|
|
168
170
|
strength,
|
|
169
171
|
maxBytes,
|
|
170
|
-
labels: labelsProp
|
|
172
|
+
labels: labelsProp,
|
|
173
|
+
id
|
|
171
174
|
}) {
|
|
172
175
|
const labels = useAccountSettingsLabels("password", labelsProp);
|
|
173
176
|
const strengthOptions = typeof strength === "object" ? strength : void 0;
|
|
@@ -199,8 +202,8 @@ function PasswordSetting({
|
|
|
199
202
|
}
|
|
200
203
|
};
|
|
201
204
|
const nextField = /* @__PURE__ */ jsx(Input, { type: "password", autoComplete: "new-password", label: labels.next, value: next, onChange: (e) => setNext(e.target.value) });
|
|
202
|
-
return /* @__PURE__ */ jsxs(Card, { className: "p-4 space-y-3", children: [
|
|
203
|
-
/* @__PURE__ */ jsx(
|
|
205
|
+
return /* @__PURE__ */ jsxs(Card, { id, className: "p-4 space-y-3", children: [
|
|
206
|
+
/* @__PURE__ */ jsx(SettingsCardTitle, { children: labels.title }),
|
|
204
207
|
/* @__PURE__ */ jsx(Input, { type: "password", autoComplete: "current-password", label: labels.current, value: current, onChange: (e) => setCurrent(e.target.value) }),
|
|
205
208
|
strength ? (
|
|
206
209
|
// One box for the field and its meter, so the card's `space-y-3` spaces the pair
|
|
@@ -245,15 +248,20 @@ function TwoFactorSetting({
|
|
|
245
248
|
onDisable,
|
|
246
249
|
busy,
|
|
247
250
|
renderQr,
|
|
248
|
-
labels: labelsProp
|
|
251
|
+
labels: labelsProp,
|
|
252
|
+
id
|
|
249
253
|
}) {
|
|
250
254
|
const labels = useAccountSettingsLabels("twoFactor", labelsProp);
|
|
255
|
+
const overrides = useKitLabelOverrides("accountSettings")?.twoFactor;
|
|
256
|
+
const title = labelsProp?.title ?? overrides?.title ?? labelsProp?.status ?? overrides?.status ?? labels.title;
|
|
251
257
|
const [code, setCode] = useState("");
|
|
252
258
|
const [password, setPassword] = useState("");
|
|
253
|
-
const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
|
|
254
259
|
const secret = setup ? setup.secret ?? ("otpauthUri" in setup ? otpauthSecret(setup.otpauthUri) : null) : null;
|
|
255
|
-
return /* @__PURE__ */ jsxs(Card, { className: "p-4 space-y-3", children: [
|
|
256
|
-
/* @__PURE__ */
|
|
260
|
+
return /* @__PURE__ */ jsxs(Card, { id, className: "p-4 space-y-3", children: [
|
|
261
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [
|
|
262
|
+
/* @__PURE__ */ jsx(SettingsCardTitle, { children: title }),
|
|
263
|
+
/* @__PURE__ */ jsx(Chip, { size: "sm", tone: enabled ? "success" : "neutral", children: enabled ? labels.enabledText : labels.disabledText })
|
|
264
|
+
] }),
|
|
257
265
|
!enabled && !setup && /* @__PURE__ */ jsx(Button, { onClick: onStartSetup, disabled: busy, children: labels.enable }),
|
|
258
266
|
setup && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
259
267
|
/* @__PURE__ */ jsx("div", { className: "text-xs text-[var(--text-secondary)]", children: labels.scanHint }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/account-settings.tsx"],"sourcesContent":["import { useId, useState } from \"react\";\nimport type { FormEvent, KeyboardEvent, ReactNode } from \"react\";\nimport { Button, Card, Input } from \"./ui\";\nimport { UserAvatar } from \"./user-avatar\";\nimport { CopyButton } from \"./copy-button\";\nimport { QrCode } from \"./qr-code\";\nimport { OneTimeCodeInput } from \"./one-time-code-input\";\nimport { usePromisePending } from \"./danger-confirm\";\nimport { personNameOk, PERSON_NAME_MAX_LENGTH } from \"../auth/form-rules\";\nimport {\n DEFAULT_PASSWORD_STRENGTH_LABELS,\n passwordByteLength,\n PasswordStrengthMeter,\n} from \"./password-strength\";\nimport type { PasswordStrengthMeterProps } from \"./password-strength\";\nimport { DEFAULT_COMMON_LABELS, useKitLabels } from \"../i18n/kit-labels\";\nimport { useAccountSettingsLabels } from \"./account-settings-labels\";\nimport type {\n PasswordSettingLabels,\n ProfileSettingLabels,\n TwoFactorSettingLabels,\n} from \"./account-settings-labels\";\n\n// The label types moved beside the namespace's defaults (0.12.0); re-exported here so\n// every existing `import type { ProfileSettingLabels }` keeps resolving.\nexport type {\n AccountSettingsLabels,\n PasskeysSettingLabels,\n PasswordSettingLabels,\n ProfileSettingLabels,\n TwoFactorSettingLabels,\n} from \"./account-settings-labels\";\nexport { DEFAULT_ACCOUNT_SETTINGS_LABELS } from \"./account-settings-labels\";\n\n/**\n * App-agnostic account-settings SECTIONS (feedback #333). The presentation lives\n * in @hb/ui; each app injects its own auth-API handlers + translated labels and\n * arranges these next to its own app-specific cards (appearance, budgets, …).\n * Every section is a self-contained <Card> owning its transient form state.\n *\n * Every `labels` prop is optional since 0.12.0: the strings come from the provider's\n * `accountSettings` namespace, then English (see account-settings-labels.ts).\n */\n\n/** What {@link ProfileSetting} hands `onSave` in its two-field form (0.30.0): both\n * trimmed, 1–120 characters each — the `PATCH /auth/me` body's `first_name` /\n * `last_name` (docs/user-admin-harmonization.md §6.1). */\nexport interface ProfileNameValues {\n firstName: string;\n lastName: string;\n}\n\n/** What both forms of {@link ProfileSetting} take. */\ninterface ProfileSettingCommonProps {\n name?: string | null;\n email?: string | null;\n role?: ReactNode;\n memberSince?: ReactNode;\n saving?: boolean;\n /** Prop > `<UiKitProvider labels={{ accountSettings: { profile } }}>` > English. */\n labels?: Partial<ProfileSettingLabels>;\n}\n\n/**\n * The single display name, as before 0.30.0 — controlled through `value` / `onChange`,\n * saved by `onSave()`. Kept unchanged for an app that has not moved to first and last\n * name yet.\n */\nexport interface ProfileSettingDisplayNameProps extends ProfileSettingCommonProps {\n value: string;\n onChange: (value: string) => void;\n onSave: () => void;\n firstName?: undefined;\n lastName?: undefined;\n}\n\n/**\n * First and last name (0.30.0, docs/user-admin-harmonization.md §6.1): the saved\n * values in, the edited ones out through `onSave`. The card keeps the drafts itself.\n */\nexport interface ProfileSettingNamesProps extends ProfileSettingCommonProps {\n /** The saved given name — `first_name`. `null` reads as empty. */\n firstName: string | null;\n /** The saved family name — `last_name`. `null` (a migrated account, §3.3) reads as\n * empty, and Save then waits for one. */\n lastName: string | null;\n /**\n * Save the two names (`PATCH /auth/me`, which also clears `name_incomplete`). Return\n * a promise and Save is busy until it settles. Refresh `firstName` / `lastName` from\n * the answer: the card compares its drafts with them, so Save turns off once the new\n * names come back. A rejection keeps what was typed — the app says why (a toast), as\n * for `PasswordSetting`.\n */\n onSave: (values: ProfileNameValues) => void | Promise<unknown>;\n value?: undefined;\n onChange?: undefined;\n}\n\nexport type ProfileSettingProps = ProfileSettingDisplayNameProps | ProfileSettingNamesProps;\n\n/**\n * The profile section: avatar, address, role, member since, and the name.\n *\n * **Two forms.** Given `firstName` / `lastName` (0.30.0, §6.1) it edits first and last\n * name in two fields, side by side where the card is wide enough — the order and the\n * 1–120-character rule of `RegisterForm` (auth §3.1), so the name a person signed up\n * with is edited the way it was typed. Without them it is the single `displayName`\n * field it always was, `value` / `onChange` / `onSave()` unchanged, for an app that has\n * not moved yet (kastlan split the one name at its first space on save; Kurvenschmiede\n * built its own card instead).\n *\n * The two-field form owns its drafts, starting from the saved names and following them\n * when they change; Save waits for a change, holds — saying why — while a name is\n * blank, and is a `commit` (a {@link WriteLockProvider} locks it, keksdose's demo).\n */\nexport function ProfileSetting(props: ProfileSettingProps) {\n const { name, email, role, memberSince, labels: labelsProp } = props;\n const labels = useAccountSettingsLabels(\"profile\", labelsProp);\n const names = props.firstName !== undefined || props.lastName !== undefined;\n return (\n <Card className=\"p-4 space-y-3\">\n <div className=\"flex items-center gap-3\">\n <UserAvatar\n name={name}\n email={email}\n person={names ? { first: props.firstName, last: props.lastName } : undefined}\n size=\"lg\"\n />\n <div className=\"min-w-0\">\n <div className=\"text-sm font-medium\">{labels.title}</div>\n <div className=\"truncate font-mono text-xs text-[var(--text-muted)]\">\n {/* `email` was a required key that nothing rendered; it names the address\n for a screen reader, which otherwise hears a bare string under a title. */}\n <span className=\"sr-only\">{labels.email}: </span>\n {email ?? \"—\"}\n </div>\n </div>\n </div>\n <div className=\"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-sm\">\n <span className=\"text-[var(--text-muted)]\">{labels.role}</span>\n <span>{role ?? \"—\"}</span>\n <span className=\"text-[var(--text-muted)]\">{labels.memberSince}</span>\n <span>{memberSince ?? \"—\"}</span>\n </div>\n {names ? (\n <PersonNameFields\n firstName={props.firstName ?? \"\"}\n lastName={props.lastName ?? \"\"}\n onSave={(props as ProfileSettingNamesProps).onSave}\n saving={props.saving}\n labels={labels}\n />\n ) : (\n <DisplayNameField\n name={name}\n value={(props as ProfileSettingDisplayNameProps).value}\n onChange={(props as ProfileSettingDisplayNameProps).onChange}\n onSave={(props as ProfileSettingDisplayNameProps).onSave}\n saving={props.saving}\n labels={labels}\n />\n )}\n </Card>\n );\n}\n\n/** The single-name form — exactly the 0.29 card's field and button. */\nfunction DisplayNameField({\n name,\n value,\n onChange,\n onSave,\n saving,\n labels,\n}: {\n name?: string | null;\n value: string;\n onChange: (value: string) => void;\n onSave: () => void;\n saving?: boolean;\n labels: Required<ProfileSettingLabels>;\n}) {\n const dirty = value.trim().length > 0 && value.trim() !== (name ?? \"\");\n // Generated, not the literal \"display-name\" it was: two of these on one page (an\n // admin editing someone else's profile beside their own) shared an id, and the\n // second label pointed at the first field.\n const inputId = useId();\n return (\n <>\n <Input\n id={inputId}\n label={labels.displayName}\n value={value}\n onChange={(e) => onChange(e.target.value)}\n maxLength={120}\n />\n <Button onClick={onSave} disabled={!dirty || saving}>\n {labels.save}\n </Button>\n </>\n );\n}\n\n/** The first-and-last form (0.30.0, §6.1). */\nfunction PersonNameFields({\n firstName,\n lastName,\n onSave,\n saving,\n labels,\n}: {\n firstName: string;\n lastName: string;\n onSave: (values: ProfileNameValues) => void | Promise<unknown>;\n saving?: boolean;\n labels: Required<ProfileSettingLabels>;\n}) {\n const [first, setFirst] = useState(firstName);\n const [last, setLast] = useState(lastName);\n // The saved names moved (the save came back, another tab renamed): the drafts follow\n // them. During render, as DangerConfirm resets its fields, so no frame shows the old\n // draft beside the new name.\n const [saved, setSaved] = useState({ firstName, lastName });\n if (saved.firstName !== firstName || saved.lastName !== lastName) {\n setSaved({ firstName, lastName });\n setFirst(firstName);\n setLast(lastName);\n }\n const { pending, run } = usePromisePending();\n const busy = Boolean(saving) || pending;\n const valid = personNameOk(first) && personNameOk(last);\n const dirty = first.trim() !== firstName.trim() || last.trim() !== lastName.trim();\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n if (!valid || !dirty || busy) return;\n // A rejection keeps the drafts; the app reports it, as PasswordSetting's does.\n run(onSave({ firstName: first.trim(), lastName: last.trim() }), () => {});\n };\n\n return (\n <form className=\"@container space-y-3\" onSubmit={submit} noValidate>\n {/* The order and the rule of RegisterForm's two fields (auth §3.1). */}\n <div className=\"grid gap-3 @xs:grid-cols-2\">\n <Input\n name=\"given-name\"\n autoComplete=\"given-name\"\n label={labels.firstName}\n value={first}\n onChange={(e) => setFirst(e.target.value)}\n maxLength={PERSON_NAME_MAX_LENGTH}\n readOnly={busy}\n required\n />\n <Input\n name=\"family-name\"\n autoComplete=\"family-name\"\n label={labels.lastName}\n value={last}\n onChange={(e) => setLast(e.target.value)}\n maxLength={PERSON_NAME_MAX_LENGTH}\n readOnly={busy}\n required\n />\n </div>\n <Button\n type=\"submit\"\n commit\n pending={busy}\n // A blank name is a reason the person can act on; an unchanged one is not —\n // there is nothing to save, and the button is simply off.\n disabled={valid && !dirty}\n disabledReason={valid ? undefined : labels.nameRequired}\n >\n {labels.save}\n </Button>\n </form>\n );\n}\n\n/**\n * What {@link PasswordSetting}'s `strength` takes besides `true`: the meter's own options,\n * minus the ones the card owns — `value` (the new password), `minLength` (the card's, so\n * the checklist's length rule and the submit's check are one number) and `maxBytes`\n * (the card's own prop, which the submit enforces as well).\n */\nexport type PasswordSettingStrength = Pick<PasswordStrengthMeterProps, \"score\" | \"showRequirements\" | \"labels\">;\n\nexport function PasswordSetting({\n onSubmit,\n pending,\n minLength = 8,\n strength,\n maxBytes,\n labels: labelsProp,\n}: {\n /** Called with the validated (current, new) pair; return a promise to auto-clear on success. */\n onSubmit: (currentPassword: string, newPassword: string) => void | Promise<unknown>;\n pending?: boolean;\n /** The shortest new password the card submits, in characters as a person counts them\n * (an emoji is one). Keep it in step with the server's own minimum. Default 8. */\n minLength?: number;\n /**\n * Show the {@link PasswordStrengthMeter} under the new-password field (0.22.0,\n * kastlan's input audit): the bar, the level in words and the checklist, with the\n * length rule drawn from `minLength`. `true` for the meter as it comes; an object for\n * its `score` (zxcvbn's, say), `showRequirements` or `labels`.\n *\n * Off by default, so a card that never asked for it does not grow one. The meter is\n * advisory, as everywhere in the kit: it blocks nothing — the card's own checks do\n * (`minLength`, the confirmation, `maxBytes`).\n */\n strength?: boolean | PasswordSettingStrength;\n /**\n * A byte ceiling on the new password — bcrypt reads at most 72 BYTES and ignores the\n * rest, which is kastlan's case: `maxBytes={72}`. A new password over it is refused\n * on submit with the meter's own \"too long\" sentence (the `passwordStrength`\n * namespace's `tooLong`), and the meter, when shown, warns while it is typed.\n *\n * Unset by default, and leave it unset for a secret with no ceiling: an invented one\n * talks people out of the long passphrase they chose.\n */\n maxBytes?: number;\n /** Prop > `<UiKitProvider labels={{ accountSettings: { password } }}>` > English. */\n labels?: Partial<PasswordSettingLabels>;\n}) {\n const labels = useAccountSettingsLabels(\"password\", labelsProp);\n const strengthOptions = typeof strength === \"object\" ? strength : undefined;\n // Only for `tooLong`: the sentence the meter shows is the one the refusal says.\n const strengthLabels = useKitLabels(\"passwordStrength\", DEFAULT_PASSWORD_STRENGTH_LABELS, strengthOptions?.labels);\n const [current, setCurrent] = useState(\"\");\n const [next, setNext] = useState(\"\");\n const [confirm, setConfirm] = useState(\"\");\n const [error, setError] = useState<string | null>(null);\n\n const submit = async () => {\n // Code points, not UTF-16 units — the count the meter's checklist and a server's\n // `len()` use. `next.length` counted an emoji as two, so four of them passed a\n // minimum of eight that the meter beside the field said they missed.\n if ([...next].length < minLength) {\n setError(labels.tooShort);\n return;\n }\n if (maxBytes !== undefined && passwordByteLength(next) > maxBytes) {\n setError(strengthLabels.tooLong(maxBytes));\n return;\n }\n if (next !== confirm) {\n setError(labels.mismatch);\n return;\n }\n setError(null);\n try {\n await onSubmit(current, next);\n setCurrent(\"\");\n setNext(\"\");\n setConfirm(\"\");\n } catch {\n // The app surfaces the failure (e.g. a toast); keep the fields for a retry.\n }\n };\n\n const nextField = (\n <Input type=\"password\" autoComplete=\"new-password\" label={labels.next} value={next} onChange={(e) => setNext(e.target.value)} />\n );\n\n return (\n <Card className=\"p-4 space-y-3\">\n <div className=\"text-sm font-medium\">{labels.title}</div>\n <Input type=\"password\" autoComplete=\"current-password\" label={labels.current} value={current} onChange={(e) => setCurrent(e.target.value)} />\n {strength ? (\n // One box for the field and its meter, so the card's `space-y-3` spaces the pair\n // from its neighbours and the meter keeps its own small gap under the field.\n <div>\n {nextField}\n <PasswordStrengthMeter\n value={next}\n minLength={minLength}\n maxBytes={maxBytes}\n score={strengthOptions?.score}\n showRequirements={strengthOptions?.showRequirements}\n labels={strengthOptions?.labels}\n />\n </div>\n ) : (\n nextField\n )}\n <Input type=\"password\" autoComplete=\"new-password\" label={labels.confirm} value={confirm} onChange={(e) => setConfirm(e.target.value)} />\n {error && <p className=\"text-xs text-[var(--danger)]\">{error}</p>}\n <Button onClick={() => void submit()} disabled={!current || !next || !confirm || pending}>\n {labels.submit}\n </Button>\n </Card>\n );\n}\n\n/**\n * What the app's setup call returned.\n *\n * `otpauthUri` (0.12.0) is what an authenticator backend actually hands out; the kit\n * draws the QR code itself ({@link QrCode}) and reads the manual-entry key out of the\n * URI's `secret` parameter when `secret` is not given. The `qrSvg` shape — a\n * base64-encoded SVG image — is what the section took before, which made every app\n * render a QR library to a static string and base64 it only for the kit to draw it back.\n */\nexport type TwoFactorSetupData =\n | { qrSvg: string; secret: string }\n | { otpauthUri: string; secret?: string };\n\n/** The `secret` parameter of an `otpauth://` URI, or null. */\nfunction otpauthSecret(uri: string): string | null {\n const match = /[?&]secret=([^&#]*)/i.exec(uri);\n if (!match) return null;\n try {\n return decodeURIComponent(match[1]) || null;\n } catch {\n return match[1] || null;\n }\n}\n\n/** \"JBSW Y3DP EHPK 3PXP\": the key in groups of four, which is how an authenticator's\n * manual-entry screen shows it and how a person copies it by eye. */\nfunction groupSecret(secret: string): string {\n return secret.replace(/\\s+/g, \"\").replace(/(.{4})(?=.)/g, \"$1 \");\n}\n\nexport function TwoFactorSetting({\n enabled,\n setup,\n onStartSetup,\n onEnable,\n onDisable,\n busy,\n renderQr,\n labels: labelsProp,\n}: {\n enabled: boolean;\n /** What the app's setup call returned; null before setup starts. */\n setup: TwoFactorSetupData | null;\n onStartSetup: () => void;\n onEnable: (code: string) => void;\n onDisable: (password: string, code: string) => void;\n busy?: boolean;\n /** Draw the code yourself (a branded QR, a library you already ship). Given the\n * `otpauthUri`; the kit's own {@link QrCode} otherwise. Unused with `qrSvg`. */\n renderQr?: (otpauthUri: string) => ReactNode;\n /** Prop > `<UiKitProvider labels={{ accountSettings: { twoFactor } }}>` > English. */\n labels?: Partial<TwoFactorSettingLabels>;\n}) {\n const labels = useAccountSettingsLabels(\"twoFactor\", labelsProp);\n const [code, setCode] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n // Both code fields are a OneTimeCodeInput (0.22.0) — the field this card wrote by hand\n // twice — and keep what they did:\n // - `readOnlyUntilFocus`: browsers autofill a one-time-code field with the saved\n // username (the disable form has a current-password field right above it), and a\n // read-only field is never autofilled. The guard drops on focus, and the field\n // keeps the look of an editable one meanwhile (FIELD_WRITABLE_LOOK) — see the prop.\n // - `length={8}`: the `maxLength={8}` they had, so an authenticator issuing eight\n // digits still fits. What changed is that they now take digits only: \"123 456\"\n // pasted from an authenticator that groups its digits used to reach `onEnable`\n // with the space in it.\n // - one `code` state for both, as before.\n // Only for the \"Status: Enabled\" composition — the punctuation between a field's\n // name and its value is the language's (see `CommonLabels.fieldValue`).\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const secret = setup\n ? (setup.secret ?? (\"otpauthUri\" in setup ? otpauthSecret(setup.otpauthUri) : null))\n : null;\n\n return (\n <Card className=\"p-4 space-y-3\">\n <div className=\"text-sm\">\n {common.fieldValue(labels.status, enabled ? labels.enabledText : labels.disabledText)}\n </div>\n\n {!enabled && !setup && (\n <Button onClick={onStartSetup} disabled={busy}>\n {labels.enable}\n </Button>\n )}\n\n {setup && (\n <div className=\"space-y-2\">\n <div className=\"text-xs text-[var(--text-secondary)]\">{labels.scanHint}</div>\n {/* `bg-white`, NOT `--bg-surface`, and it must stay that way: a QR code is\n read by a camera looking for maximum contrast between the modules and\n their quiet zone. On the dark theme a surface-coloured backing makes it\n slow to acquire, and on a warm light preset it lowers the contrast ratio\n the spec is written against. This is the one place in the kit where a\n literal colour is the correct answer. `data-private`: the code IS the\n second factor, and demo mode blurs it like any other secret. */}\n {\"otpauthUri\" in setup ? (\n // No backing of its own: QrCode draws its quiet zone white inside the SVG.\n <div data-private className=\"inline-block overflow-hidden rounded-md\">\n {renderQr ? (\n renderQr(setup.otpauthUri)\n ) : (\n <QrCode value={setup.otpauthUri} label={labels.qrAlt} className=\"size-48\" />\n )}\n </div>\n ) : (\n <div data-private className=\"inline-block rounded-md bg-white p-2\">\n <img\n alt={labels.qrAlt}\n src={`data:image/svg+xml;base64,${setup.qrSvg}`}\n className=\"h-48 w-48\"\n />\n </div>\n )}\n {secret && (\n <div className=\"space-y-1\">\n <div className=\"text-xs text-[var(--text-secondary)]\">{labels.secretHint}</div>\n <div className=\"flex items-center gap-1\">\n {/* `dir=\"ltr\"`: a base32 key is Latin letters and digits in a fixed\n order, and in an RTL page the groups would otherwise be laid out\n right to left. */}\n <code data-private dir=\"ltr\" className=\"break-all font-mono text-xs select-all\">\n {groupSecret(secret)}\n </code>\n <CopyButton text={secret} label={labels.copySecret} size=\"xs\" tone=\"muted\" />\n </div>\n </div>\n )}\n <OneTimeCodeInput\n readOnlyUntilFocus\n length={8}\n label={labels.codeLabel}\n value={code}\n onChange={setCode}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\" && code && !busy) {\n e.preventDefault();\n onEnable(code);\n }\n }}\n />\n <Button onClick={() => onEnable(code)} disabled={!code || busy}>\n {labels.verify}\n </Button>\n </div>\n )}\n\n {enabled && (\n <div className=\"space-y-3 border-t border-[var(--border)] pt-3\">\n <div className=\"text-sm font-medium\">{labels.disableSection}</div>\n <Input type=\"password\" autoComplete=\"current-password\" label={labels.password} value={password} onChange={(e) => setPassword(e.target.value)} />\n <OneTimeCodeInput\n readOnlyUntilFocus\n length={8}\n label={labels.codeLabel}\n value={code}\n onChange={setCode}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\" && password && code && !busy) {\n e.preventDefault();\n onDisable(password, code);\n }\n }}\n />\n <Button variant=\"danger\" onClick={() => onDisable(password, code)} disabled={!password || !code || busy}>\n {labels.disable}\n </Button>\n </div>\n )}\n </Card>\n );\n}\n"],"mappings":";AA0HQ,SAkEJ,UAlEI,KAWI,YAXJ;AA1HR,SAAS,OAAO,gBAAgB;AAEhC,SAAS,QAAQ,MAAM,aAAa;AACpC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,cAAc,8BAA8B;AACrD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,uBAAuB,oBAAoB;AACpD,SAAS,gCAAgC;AAgBzC,SAAS,uCAAuC;AAmFzC,SAAS,eAAe,OAA4B;AACzD,QAAM,EAAE,MAAM,OAAO,MAAM,aAAa,QAAQ,WAAW,IAAI;AAC/D,QAAM,SAAS,yBAAyB,WAAW,UAAU;AAC7D,QAAM,QAAQ,MAAM,cAAc,UAAa,MAAM,aAAa;AAClE,SACE,qBAAC,QAAK,WAAU,iBACd;AAAA,yBAA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A,YAC1B;AAAA,UACF;AAAA;AAAA,MACF;AAAA,MACA,oBAAC,UAAO,SAAQ,UAAS,SAAS,MAAM,UAAU,UAAU,IAAI,GAAG,UAAU,CAAC,YAAY,CAAC,QAAQ,MAChG,iBAAO,SACV;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/account-settings.tsx"],"sourcesContent":["import { useId, useState } from \"react\";\nimport type { FormEvent, KeyboardEvent, ReactNode } from \"react\";\nimport { Button, Card, Input } from \"./ui\";\nimport { UserAvatar } from \"./user-avatar\";\nimport { CopyButton } from \"./copy-button\";\nimport { QrCode } from \"./qr-code\";\nimport { OneTimeCodeInput } from \"./one-time-code-input\";\nimport { usePromisePending } from \"./danger-confirm\";\nimport { personNameOk, PERSON_NAME_MAX_LENGTH } from \"../auth/form-rules\";\nimport {\n DEFAULT_PASSWORD_STRENGTH_LABELS,\n passwordByteLength,\n PasswordStrengthMeter,\n} from \"./password-strength\";\nimport type { PasswordStrengthMeterProps } from \"./password-strength\";\nimport { useKitLabelOverrides, useKitLabels } from \"../i18n/kit-labels\";\nimport { Chip } from \"./chip\";\nimport { useAccountSettingsLabels } from \"./account-settings-labels\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport type {\n PasswordSettingLabels,\n ProfileSettingLabels,\n TwoFactorSettingLabels,\n} from \"./account-settings-labels\";\n\n// The label types moved beside the namespace's defaults (0.12.0); re-exported here so\n// every existing `import type { ProfileSettingLabels }` keeps resolving.\nexport type {\n AccountSettingsLabels,\n PasskeysSettingLabels,\n PasswordSettingLabels,\n ProfileSettingLabels,\n TwoFactorSettingLabels,\n} from \"./account-settings-labels\";\nexport { DEFAULT_ACCOUNT_SETTINGS_LABELS } from \"./account-settings-labels\";\n\n/**\n * App-agnostic account-settings SECTIONS (feedback #333). The presentation lives\n * in @hb/ui; each app injects its own auth-API handlers + translated labels and\n * arranges these next to its own app-specific cards (appearance, budgets, …).\n * Every section is a self-contained <Card> owning its transient form state.\n *\n * Every `labels` prop is optional since 0.12.0: the strings come from the provider's\n * `accountSettings` namespace, then English (see account-settings-labels.ts).\n */\n\n/** What {@link ProfileSetting} hands `onSave` in its two-field form (0.30.0): both\n * trimmed, 1–120 characters each — the `PATCH /auth/me` body's `first_name` /\n * `last_name` (docs/user-admin-harmonization.md §6.1). */\nexport interface ProfileNameValues {\n firstName: string;\n lastName: string;\n}\n\n/** What both forms of {@link ProfileSetting} take. */\ninterface ProfileSettingCommonProps {\n name?: string | null;\n email?: string | null;\n role?: ReactNode;\n memberSince?: ReactNode;\n saving?: boolean;\n /** Prop > `<UiKitProvider labels={{ accountSettings: { profile } }}>` > English. */\n labels?: Partial<ProfileSettingLabels>;\n /** The card's DOM id — a settings catalogue `anchor`, so `?focus=` can ring it (0.31). */\n id?: string;\n}\n\n/**\n * The single display name, as before 0.30.0 — controlled through `value` / `onChange`,\n * saved by `onSave()`. Kept unchanged for an app that has not moved to first and last\n * name yet.\n */\nexport interface ProfileSettingDisplayNameProps extends ProfileSettingCommonProps {\n value: string;\n onChange: (value: string) => void;\n onSave: () => void;\n firstName?: undefined;\n lastName?: undefined;\n}\n\n/**\n * First and last name (0.30.0, docs/user-admin-harmonization.md §6.1): the saved\n * values in, the edited ones out through `onSave`. The card keeps the drafts itself.\n */\nexport interface ProfileSettingNamesProps extends ProfileSettingCommonProps {\n /** The saved given name — `first_name`. `null` reads as empty. */\n firstName: string | null;\n /** The saved family name — `last_name`. `null` (a migrated account, §3.3) reads as\n * empty, and Save then waits for one. */\n lastName: string | null;\n /**\n * Save the two names (`PATCH /auth/me`, which also clears `name_incomplete`). Return\n * a promise and Save is busy until it settles. Refresh `firstName` / `lastName` from\n * the answer: the card compares its drafts with them, so Save turns off once the new\n * names come back. A rejection keeps what was typed — the app says why (a toast), as\n * for `PasswordSetting`.\n */\n onSave: (values: ProfileNameValues) => void | Promise<unknown>;\n value?: undefined;\n onChange?: undefined;\n}\n\nexport type ProfileSettingProps = ProfileSettingDisplayNameProps | ProfileSettingNamesProps;\n\n/**\n * The profile section: avatar, address, role, member since, and the name.\n *\n * **Two forms.** Given `firstName` / `lastName` (0.30.0, §6.1) it edits first and last\n * name in two fields, side by side where the card is wide enough — the order and the\n * 1–120-character rule of `RegisterForm` (auth §3.1), so the name a person signed up\n * with is edited the way it was typed. Without them it is the single `displayName`\n * field it always was, `value` / `onChange` / `onSave()` unchanged, for an app that has\n * not moved yet (kastlan split the one name at its first space on save; Kurvenschmiede\n * built its own card instead).\n *\n * The two-field form owns its drafts, starting from the saved names and following them\n * when they change; Save waits for a change, holds — saying why — while a name is\n * blank, and is a `commit` (a {@link WriteLockProvider} locks it, keksdose's demo).\n */\nexport function ProfileSetting(props: ProfileSettingProps) {\n const { name, email, role, memberSince, labels: labelsProp, id } = props;\n const labels = useAccountSettingsLabels(\"profile\", labelsProp);\n const names = props.firstName !== undefined || props.lastName !== undefined;\n return (\n <Card id={id} className=\"p-4 space-y-3\">\n <div className=\"flex items-center gap-3\">\n <UserAvatar\n name={name}\n email={email}\n person={names ? { first: props.firstName, last: props.lastName } : undefined}\n size=\"lg\"\n />\n <div className=\"min-w-0\">\n {/* A heading inside a SettingsLayout (0.31, docs/settings-harmonization.md\n §3.7), the plain div it always was outside one. */}\n <SettingsCardTitle>{labels.title}</SettingsCardTitle>\n <div className=\"truncate font-mono text-xs text-[var(--text-muted)]\">\n {/* `email` was a required key that nothing rendered; it names the address\n for a screen reader, which otherwise hears a bare string under a title. */}\n <span className=\"sr-only\">{labels.email}: </span>\n {email ?? \"—\"}\n </div>\n </div>\n </div>\n <div className=\"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-sm\">\n <span className=\"text-[var(--text-muted)]\">{labels.role}</span>\n <span>{role ?? \"—\"}</span>\n <span className=\"text-[var(--text-muted)]\">{labels.memberSince}</span>\n <span>{memberSince ?? \"—\"}</span>\n </div>\n {names ? (\n <PersonNameFields\n firstName={props.firstName ?? \"\"}\n lastName={props.lastName ?? \"\"}\n onSave={(props as ProfileSettingNamesProps).onSave}\n saving={props.saving}\n labels={labels}\n />\n ) : (\n <DisplayNameField\n name={name}\n value={(props as ProfileSettingDisplayNameProps).value}\n onChange={(props as ProfileSettingDisplayNameProps).onChange}\n onSave={(props as ProfileSettingDisplayNameProps).onSave}\n saving={props.saving}\n labels={labels}\n />\n )}\n </Card>\n );\n}\n\n/** The single-name form — exactly the 0.29 card's field and button. */\nfunction DisplayNameField({\n name,\n value,\n onChange,\n onSave,\n saving,\n labels,\n}: {\n name?: string | null;\n value: string;\n onChange: (value: string) => void;\n onSave: () => void;\n saving?: boolean;\n labels: Required<ProfileSettingLabels>;\n}) {\n const dirty = value.trim().length > 0 && value.trim() !== (name ?? \"\");\n // Generated, not the literal \"display-name\" it was: two of these on one page (an\n // admin editing someone else's profile beside their own) shared an id, and the\n // second label pointed at the first field.\n const inputId = useId();\n return (\n <>\n <Input\n id={inputId}\n label={labels.displayName}\n value={value}\n onChange={(e) => onChange(e.target.value)}\n maxLength={120}\n />\n <Button onClick={onSave} disabled={!dirty || saving}>\n {labels.save}\n </Button>\n </>\n );\n}\n\n/** The first-and-last form (0.30.0, §6.1). */\nfunction PersonNameFields({\n firstName,\n lastName,\n onSave,\n saving,\n labels,\n}: {\n firstName: string;\n lastName: string;\n onSave: (values: ProfileNameValues) => void | Promise<unknown>;\n saving?: boolean;\n labels: Required<ProfileSettingLabels>;\n}) {\n const [first, setFirst] = useState(firstName);\n const [last, setLast] = useState(lastName);\n // The saved names moved (the save came back, another tab renamed): the drafts follow\n // them. During render, as DangerConfirm resets its fields, so no frame shows the old\n // draft beside the new name.\n const [saved, setSaved] = useState({ firstName, lastName });\n if (saved.firstName !== firstName || saved.lastName !== lastName) {\n setSaved({ firstName, lastName });\n setFirst(firstName);\n setLast(lastName);\n }\n const { pending, run } = usePromisePending();\n const busy = Boolean(saving) || pending;\n const valid = personNameOk(first) && personNameOk(last);\n const dirty = first.trim() !== firstName.trim() || last.trim() !== lastName.trim();\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n if (!valid || !dirty || busy) return;\n // A rejection keeps the drafts; the app reports it, as PasswordSetting's does.\n run(onSave({ firstName: first.trim(), lastName: last.trim() }), () => {});\n };\n\n return (\n <form className=\"@container space-y-3\" onSubmit={submit} noValidate>\n {/* The order and the rule of RegisterForm's two fields (auth §3.1). */}\n <div className=\"grid gap-3 @xs:grid-cols-2\">\n <Input\n name=\"given-name\"\n autoComplete=\"given-name\"\n label={labels.firstName}\n value={first}\n onChange={(e) => setFirst(e.target.value)}\n maxLength={PERSON_NAME_MAX_LENGTH}\n readOnly={busy}\n required\n />\n <Input\n name=\"family-name\"\n autoComplete=\"family-name\"\n label={labels.lastName}\n value={last}\n onChange={(e) => setLast(e.target.value)}\n maxLength={PERSON_NAME_MAX_LENGTH}\n readOnly={busy}\n required\n />\n </div>\n <Button\n type=\"submit\"\n commit\n pending={busy}\n // A blank name is a reason the person can act on; an unchanged one is not —\n // there is nothing to save, and the button is simply off.\n disabled={valid && !dirty}\n disabledReason={valid ? undefined : labels.nameRequired}\n >\n {labels.save}\n </Button>\n </form>\n );\n}\n\n/**\n * What {@link PasswordSetting}'s `strength` takes besides `true`: the meter's own options,\n * minus the ones the card owns — `value` (the new password), `minLength` (the card's, so\n * the checklist's length rule and the submit's check are one number) and `maxBytes`\n * (the card's own prop, which the submit enforces as well).\n */\nexport type PasswordSettingStrength = Pick<PasswordStrengthMeterProps, \"score\" | \"showRequirements\" | \"labels\">;\n\nexport function PasswordSetting({\n onSubmit,\n pending,\n minLength = 8,\n strength,\n maxBytes,\n labels: labelsProp,\n id,\n}: {\n /** Called with the validated (current, new) pair; return a promise to auto-clear on success. */\n onSubmit: (currentPassword: string, newPassword: string) => void | Promise<unknown>;\n pending?: boolean;\n /** The shortest new password the card submits, in characters as a person counts them\n * (an emoji is one). Keep it in step with the server's own minimum. Default 8. */\n minLength?: number;\n /**\n * Show the {@link PasswordStrengthMeter} under the new-password field (0.22.0,\n * kastlan's input audit): the bar, the level in words and the checklist, with the\n * length rule drawn from `minLength`. `true` for the meter as it comes; an object for\n * its `score` (zxcvbn's, say), `showRequirements` or `labels`.\n *\n * Off by default, so a card that never asked for it does not grow one. The meter is\n * advisory, as everywhere in the kit: it blocks nothing — the card's own checks do\n * (`minLength`, the confirmation, `maxBytes`).\n */\n strength?: boolean | PasswordSettingStrength;\n /**\n * A byte ceiling on the new password — bcrypt reads at most 72 BYTES and ignores the\n * rest, which is kastlan's case: `maxBytes={72}`. A new password over it is refused\n * on submit with the meter's own \"too long\" sentence (the `passwordStrength`\n * namespace's `tooLong`), and the meter, when shown, warns while it is typed.\n *\n * Unset by default, and leave it unset for a secret with no ceiling: an invented one\n * talks people out of the long passphrase they chose.\n */\n maxBytes?: number;\n /** Prop > `<UiKitProvider labels={{ accountSettings: { password } }}>` > English. */\n labels?: Partial<PasswordSettingLabels>;\n /** The card's DOM id — a settings catalogue `anchor`, so `?focus=` can ring it (0.31). */\n id?: string;\n}) {\n const labels = useAccountSettingsLabels(\"password\", labelsProp);\n const strengthOptions = typeof strength === \"object\" ? strength : undefined;\n // Only for `tooLong`: the sentence the meter shows is the one the refusal says.\n const strengthLabels = useKitLabels(\"passwordStrength\", DEFAULT_PASSWORD_STRENGTH_LABELS, strengthOptions?.labels);\n const [current, setCurrent] = useState(\"\");\n const [next, setNext] = useState(\"\");\n const [confirm, setConfirm] = useState(\"\");\n const [error, setError] = useState<string | null>(null);\n\n const submit = async () => {\n // Code points, not UTF-16 units — the count the meter's checklist and a server's\n // `len()` use. `next.length` counted an emoji as two, so four of them passed a\n // minimum of eight that the meter beside the field said they missed.\n if ([...next].length < minLength) {\n setError(labels.tooShort);\n return;\n }\n if (maxBytes !== undefined && passwordByteLength(next) > maxBytes) {\n setError(strengthLabels.tooLong(maxBytes));\n return;\n }\n if (next !== confirm) {\n setError(labels.mismatch);\n return;\n }\n setError(null);\n try {\n await onSubmit(current, next);\n setCurrent(\"\");\n setNext(\"\");\n setConfirm(\"\");\n } catch {\n // The app surfaces the failure (e.g. a toast); keep the fields for a retry.\n }\n };\n\n const nextField = (\n <Input type=\"password\" autoComplete=\"new-password\" label={labels.next} value={next} onChange={(e) => setNext(e.target.value)} />\n );\n\n return (\n <Card id={id} className=\"p-4 space-y-3\">\n <SettingsCardTitle>{labels.title}</SettingsCardTitle>\n <Input type=\"password\" autoComplete=\"current-password\" label={labels.current} value={current} onChange={(e) => setCurrent(e.target.value)} />\n {strength ? (\n // One box for the field and its meter, so the card's `space-y-3` spaces the pair\n // from its neighbours and the meter keeps its own small gap under the field.\n <div>\n {nextField}\n <PasswordStrengthMeter\n value={next}\n minLength={minLength}\n maxBytes={maxBytes}\n score={strengthOptions?.score}\n showRequirements={strengthOptions?.showRequirements}\n labels={strengthOptions?.labels}\n />\n </div>\n ) : (\n nextField\n )}\n <Input type=\"password\" autoComplete=\"new-password\" label={labels.confirm} value={confirm} onChange={(e) => setConfirm(e.target.value)} />\n {error && <p className=\"text-xs text-[var(--danger)]\">{error}</p>}\n <Button onClick={() => void submit()} disabled={!current || !next || !confirm || pending}>\n {labels.submit}\n </Button>\n </Card>\n );\n}\n\n/**\n * What the app's setup call returned.\n *\n * `otpauthUri` (0.12.0) is what an authenticator backend actually hands out; the kit\n * draws the QR code itself ({@link QrCode}) and reads the manual-entry key out of the\n * URI's `secret` parameter when `secret` is not given. The `qrSvg` shape — a\n * base64-encoded SVG image — is what the section took before, which made every app\n * render a QR library to a static string and base64 it only for the kit to draw it back.\n */\nexport type TwoFactorSetupData =\n | { qrSvg: string; secret: string }\n | { otpauthUri: string; secret?: string };\n\n/** The `secret` parameter of an `otpauth://` URI, or null. */\nfunction otpauthSecret(uri: string): string | null {\n const match = /[?&]secret=([^&#]*)/i.exec(uri);\n if (!match) return null;\n try {\n return decodeURIComponent(match[1]) || null;\n } catch {\n return match[1] || null;\n }\n}\n\n/** \"JBSW Y3DP EHPK 3PXP\": the key in groups of four, which is how an authenticator's\n * manual-entry screen shows it and how a person copies it by eye. */\nfunction groupSecret(secret: string): string {\n return secret.replace(/\\s+/g, \"\").replace(/(.{4})(?=.)/g, \"$1 \");\n}\n\nexport function TwoFactorSetting({\n enabled,\n setup,\n onStartSetup,\n onEnable,\n onDisable,\n busy,\n renderQr,\n labels: labelsProp,\n id,\n}: {\n enabled: boolean;\n /** What the app's setup call returned; null before setup starts. */\n setup: TwoFactorSetupData | null;\n onStartSetup: () => void;\n onEnable: (code: string) => void;\n onDisable: (password: string, code: string) => void;\n busy?: boolean;\n /** Draw the code yourself (a branded QR, a library you already ship). Given the\n * `otpauthUri`; the kit's own {@link QrCode} otherwise. Unused with `qrSvg`. */\n renderQr?: (otpauthUri: string) => ReactNode;\n /** Prop > `<UiKitProvider labels={{ accountSettings: { twoFactor } }}>` > English. */\n labels?: Partial<TwoFactorSettingLabels>;\n /** The card's DOM id — a settings catalogue `anchor`, so `?focus=` can ring it (0.31). */\n id?: string;\n}) {\n const labels = useAccountSettingsLabels(\"twoFactor\", labelsProp);\n // The title (0.31, docs/settings-harmonization.md §3.7) is new, and an app that\n // translated this card before it named the setting in `status` — \"2FA\",\n // \"Zwei-Faktor-Authentifizierung\". Each source's `title` first, then its `status`, so\n // that app keeps its own word instead of meeting the English title.\n const overrides = useKitLabelOverrides(\"accountSettings\")?.twoFactor;\n const title = labelsProp?.title ?? overrides?.title ?? labelsProp?.status ?? overrides?.status ?? labels.title;\n const [code, setCode] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n // Both code fields are a OneTimeCodeInput (0.22.0) — the field this card wrote by hand\n // twice — and keep what they did:\n // - `readOnlyUntilFocus`: browsers autofill a one-time-code field with the saved\n // username (the disable form has a current-password field right above it), and a\n // read-only field is never autofilled. The guard drops on focus, and the field\n // keeps the look of an editable one meanwhile (FIELD_WRITABLE_LOOK) — see the prop.\n // - `length={8}`: the `maxLength={8}` they had, so an authenticator issuing eight\n // digits still fits. What changed is that they now take digits only: \"123 456\"\n // pasted from an authenticator that groups its digits used to reach `onEnable`\n // with the space in it.\n // - one `code` state for both, as before.\n const secret = setup\n ? (setup.secret ?? (\"otpauthUri\" in setup ? otpauthSecret(setup.otpauthUri) : null))\n : null;\n\n return (\n <Card id={id} className=\"p-4 space-y-3\">\n {/* The card had only \"Two-factor authentication: Off\". A settings page outlines its\n cards by their titles (§3.7), so the setting's name is the title now, and the\n state stands beside it as a chip instead of repeating the name. */}\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <SettingsCardTitle>{title}</SettingsCardTitle>\n <Chip size=\"sm\" tone={enabled ? \"success\" : \"neutral\"}>\n {enabled ? labels.enabledText : labels.disabledText}\n </Chip>\n </div>\n\n {!enabled && !setup && (\n <Button onClick={onStartSetup} disabled={busy}>\n {labels.enable}\n </Button>\n )}\n\n {setup && (\n <div className=\"space-y-2\">\n <div className=\"text-xs text-[var(--text-secondary)]\">{labels.scanHint}</div>\n {/* `bg-white`, NOT `--bg-surface`, and it must stay that way: a QR code is\n read by a camera looking for maximum contrast between the modules and\n their quiet zone. On the dark theme a surface-coloured backing makes it\n slow to acquire, and on a warm light preset it lowers the contrast ratio\n the spec is written against. This is the one place in the kit where a\n literal colour is the correct answer. `data-private`: the code IS the\n second factor, and demo mode blurs it like any other secret. */}\n {\"otpauthUri\" in setup ? (\n // No backing of its own: QrCode draws its quiet zone white inside the SVG.\n <div data-private className=\"inline-block overflow-hidden rounded-md\">\n {renderQr ? (\n renderQr(setup.otpauthUri)\n ) : (\n <QrCode value={setup.otpauthUri} label={labels.qrAlt} className=\"size-48\" />\n )}\n </div>\n ) : (\n <div data-private className=\"inline-block rounded-md bg-white p-2\">\n <img\n alt={labels.qrAlt}\n src={`data:image/svg+xml;base64,${setup.qrSvg}`}\n className=\"h-48 w-48\"\n />\n </div>\n )}\n {secret && (\n <div className=\"space-y-1\">\n <div className=\"text-xs text-[var(--text-secondary)]\">{labels.secretHint}</div>\n <div className=\"flex items-center gap-1\">\n {/* `dir=\"ltr\"`: a base32 key is Latin letters and digits in a fixed\n order, and in an RTL page the groups would otherwise be laid out\n right to left. */}\n <code data-private dir=\"ltr\" className=\"break-all font-mono text-xs select-all\">\n {groupSecret(secret)}\n </code>\n <CopyButton text={secret} label={labels.copySecret} size=\"xs\" tone=\"muted\" />\n </div>\n </div>\n )}\n <OneTimeCodeInput\n readOnlyUntilFocus\n length={8}\n label={labels.codeLabel}\n value={code}\n onChange={setCode}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\" && code && !busy) {\n e.preventDefault();\n onEnable(code);\n }\n }}\n />\n <Button onClick={() => onEnable(code)} disabled={!code || busy}>\n {labels.verify}\n </Button>\n </div>\n )}\n\n {enabled && (\n <div className=\"space-y-3 border-t border-[var(--border)] pt-3\">\n <div className=\"text-sm font-medium\">{labels.disableSection}</div>\n <Input type=\"password\" autoComplete=\"current-password\" label={labels.password} value={password} onChange={(e) => setPassword(e.target.value)} />\n <OneTimeCodeInput\n readOnlyUntilFocus\n length={8}\n label={labels.codeLabel}\n value={code}\n onChange={setCode}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\" && password && code && !busy) {\n e.preventDefault();\n onDisable(password, code);\n }\n }}\n />\n <Button variant=\"danger\" onClick={() => onDisable(password, code)} disabled={!password || !code || busy}>\n {labels.disable}\n </Button>\n </div>\n )}\n </Card>\n );\n}\n"],"mappings":";AA8HQ,SAoEJ,UApEI,KAaI,YAbJ;AA9HR,SAAS,OAAO,gBAAgB;AAEhC,SAAS,QAAQ,MAAM,aAAa;AACpC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,cAAc,8BAA8B;AACrD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,sBAAsB,oBAAoB;AACnD,SAAS,YAAY;AACrB,SAAS,gCAAgC;AACzC,SAAS,yBAAyB;AAgBlC,SAAS,uCAAuC;AAqFzC,SAAS,eAAe,OAA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AAC,SAAM,MAAK,YAAW,cAAa,oBAAmB,OAAO,OAAO,UAAU,OAAO,UAAU,UAAU,CAAC,MAAM,YAAY,EAAE,OAAO,KAAK,GAAG;AAAA,MAC9I;AAAA,QAAC;AAAA;AAAA,UACC,oBAAkB;AAAA,UAClB,QAAQ;AAAA,UACR,OAAO,OAAO;AAAA,UACd,OAAO;AAAA,UACP,UAAU;AAAA,UACV,WAAW,CAAC,MAAuC;AACjD,gBAAI,EAAE,QAAQ,WAAW,YAAY,QAAQ,CAAC,MAAM;AAClD,gBAAE,eAAe;AACjB,wBAAU,UAAU,IAAI;AAAA,YAC1B;AAAA,UACF;AAAA;AAAA,MACF;AAAA,MACA,oBAAC,UAAO,SAAQ,UAAS,SAAS,MAAM,UAAU,UAAU,IAAI,GAAG,UAAU,CAAC,YAAY,CAAC,QAAQ,MAChG,iBAAO,SACV;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { CalculatorButtonLabels } from './calculator.js';
|
|
4
4
|
import { NumberPadSheetLabels } from './numpad-sheet.js';
|
|
5
|
-
import '../delete-account-setting-
|
|
5
|
+
import '../delete-account-setting-CpIhzxxZ.js';
|
|
6
6
|
import './tooltip.js';
|
|
7
7
|
import '../hooks/use-anchored-rect.js';
|
|
8
8
|
import '../lib/clipping.js';
|
|
@@ -57,6 +57,8 @@ import './image-grid.js';
|
|
|
57
57
|
import './lightbox.js';
|
|
58
58
|
import './write-lock.js';
|
|
59
59
|
import '../auth/sign-in-form.js';
|
|
60
|
+
import '../landing/access.js';
|
|
61
|
+
import '../landing/landing-labels.js';
|
|
60
62
|
import '../shell/topbar-controls.js';
|
|
61
63
|
import '../theme/palette-presets.js';
|
|
62
64
|
import '../theme/chart-palette.js';
|
|
@@ -78,6 +80,8 @@ import '../account/data-export-setting.js';
|
|
|
78
80
|
import './account-chips.js';
|
|
79
81
|
import '../admin/admin-parts.js';
|
|
80
82
|
import '../admin/admin-action-log.js';
|
|
83
|
+
import '../settings/settings-labels.js';
|
|
84
|
+
import '../demo/demo-labels.js';
|
|
81
85
|
import './reauth-dialog.js';
|
|
82
86
|
import './server-wake.js';
|
|
83
87
|
import '../lib/server-wake.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentPropsWithoutRef, ReactNode, Ref, MouseEvent, ReactElement } from 'react';
|
|
3
|
-
import { bH as ButtonVariant, bF as ButtonSize } from '../delete-account-setting-
|
|
3
|
+
import { bH as ButtonVariant, bF as ButtonSize } from '../delete-account-setting-CpIhzxxZ.js';
|
|
4
4
|
import './tooltip.js';
|
|
5
5
|
import '../hooks/use-anchored-rect.js';
|
|
6
6
|
import '../lib/clipping.js';
|
|
@@ -55,6 +55,8 @@ import './image-grid.js';
|
|
|
55
55
|
import './lightbox.js';
|
|
56
56
|
import './write-lock.js';
|
|
57
57
|
import '../auth/sign-in-form.js';
|
|
58
|
+
import '../landing/access.js';
|
|
59
|
+
import '../landing/landing-labels.js';
|
|
58
60
|
import '../shell/topbar-controls.js';
|
|
59
61
|
import '../theme/palette-presets.js';
|
|
60
62
|
import '../theme/chart-palette.js';
|
|
@@ -76,6 +78,8 @@ import '../account/data-export-setting.js';
|
|
|
76
78
|
import './account-chips.js';
|
|
77
79
|
import '../admin/admin-parts.js';
|
|
78
80
|
import '../admin/admin-action-log.js';
|
|
81
|
+
import '../settings/settings-labels.js';
|
|
82
|
+
import '../demo/demo-labels.js';
|
|
79
83
|
import './reauth-dialog.js';
|
|
80
84
|
import './server-wake.js';
|
|
81
85
|
import '../lib/server-wake.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { bI as CalculatorLabels } from '../delete-account-setting-
|
|
2
|
+
import { bI as CalculatorLabels } from '../delete-account-setting-CpIhzxxZ.js';
|
|
3
3
|
import './tooltip.js';
|
|
4
4
|
import '../hooks/use-anchored-rect.js';
|
|
5
5
|
import '../lib/clipping.js';
|
|
@@ -54,6 +54,8 @@ import './image-grid.js';
|
|
|
54
54
|
import './lightbox.js';
|
|
55
55
|
import './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 '../account/data-export-setting.js';
|
|
|
75
77
|
import './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 './reauth-dialog.js';
|
|
79
83
|
import './server-wake.js';
|
|
80
84
|
import '../lib/server-wake.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { c2 as ConfirmDialogLabels, c3 as ConfirmFn, c4 as ConfirmOptions, c5 as ConfirmProvider, c6 as ConfirmProviderProps, c7 as ConfirmTone, cl as DEFAULT_CONFIRM_DIALOG_LABELS, fC as useConfirm } from '../delete-account-setting-
|
|
2
|
+
export { c2 as ConfirmDialogLabels, c3 as ConfirmFn, c4 as ConfirmOptions, c5 as ConfirmProvider, c6 as ConfirmProviderProps, c7 as ConfirmTone, cl as DEFAULT_CONFIRM_DIALOG_LABELS, fC as useConfirm } from '../delete-account-setting-CpIhzxxZ.js';
|
|
3
3
|
import './tooltip.js';
|
|
4
4
|
import '../hooks/use-anchored-rect.js';
|
|
5
5
|
import '../lib/clipping.js';
|
|
@@ -54,6 +54,8 @@ import './image-grid.js';
|
|
|
54
54
|
import './lightbox.js';
|
|
55
55
|
import './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 '../account/data-export-setting.js';
|
|
|
75
77
|
import './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 './reauth-dialog.js';
|
|
79
83
|
import './server-wake.js';
|
|
80
84
|
import '../lib/server-wake.js';
|
|
@@ -5,6 +5,7 @@ import { useKitLabels } from "../i18n/kit-labels.js";
|
|
|
5
5
|
import { TypedConfirmField, typedMatches } from "./danger-confirm.js";
|
|
6
6
|
import { DialogFrame } from "./dialog-frame.js";
|
|
7
7
|
import { Button } from "./ui.js";
|
|
8
|
+
import { useWriteLock } from "./write-lock.js";
|
|
8
9
|
const DEFAULT_CONFIRM_DIALOG_LABELS = {
|
|
9
10
|
confirm: "Confirm",
|
|
10
11
|
cancel: "Cancel",
|
|
@@ -16,7 +17,11 @@ function useConfirm() {
|
|
|
16
17
|
if (!confirm) {
|
|
17
18
|
throw new Error("useConfirm() must be called below a <ConfirmProvider>.");
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
const lock = useWriteLock();
|
|
21
|
+
return useCallback(
|
|
22
|
+
(options) => confirm(options.commit && lock.locked ? { ...options, lockReason: lock.reason } : options),
|
|
23
|
+
[confirm, lock.locked, lock.reason]
|
|
24
|
+
);
|
|
20
25
|
}
|
|
21
26
|
function ConfirmProvider({ children }) {
|
|
22
27
|
const [queue, setQueue] = useState([]);
|
|
@@ -85,6 +90,7 @@ function ConfirmDialogView({
|
|
|
85
90
|
type: "button",
|
|
86
91
|
variant: tone === "danger" ? "danger" : "primary",
|
|
87
92
|
disabled: !matches,
|
|
93
|
+
disabledReason: request.lockReason,
|
|
88
94
|
onClick: () => {
|
|
89
95
|
accepted.current = true;
|
|
90
96
|
close();
|