@eifi1/ui-kit 0.28.1 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -4
- package/dist/account/account-parts.d.ts +21 -0
- package/dist/account/account-parts.js +40 -0
- package/dist/account/account-parts.js.map +1 -0
- package/dist/account/data-export-setting.d.ts +73 -0
- package/dist/account/data-export-setting.js +113 -0
- package/dist/account/data-export-setting.js.map +1 -0
- package/dist/account/delete-account-setting.d.ts +91 -0
- package/dist/account/delete-account-setting.js +199 -0
- package/dist/account/delete-account-setting.js.map +1 -0
- package/dist/account/email-change-setting.d.ts +136 -0
- package/dist/account/email-change-setting.js +277 -0
- package/dist/account/email-change-setting.js.map +1 -0
- package/dist/account/sessions-setting.d.ts +110 -0
- package/dist/account/sessions-setting.js +146 -0
- package/dist/account/sessions-setting.js.map +1 -0
- package/dist/admin/admin-action-confirm.d.ts +91 -0
- package/dist/admin/admin-action-confirm.js +276 -0
- package/dist/admin/admin-action-confirm.js.map +1 -0
- package/dist/admin/admin-action-log.d.ts +105 -0
- package/dist/admin/admin-action-log.js +153 -0
- package/dist/admin/admin-action-log.js.map +1 -0
- package/dist/admin/admin-parts.d.ts +40 -0
- package/dist/admin/admin-parts.js +45 -0
- package/dist/admin/admin-parts.js.map +1 -0
- package/dist/admin/invitations-panel.d.ts +91 -0
- package/dist/admin/invitations-panel.js +289 -0
- package/dist/admin/invitations-panel.js.map +1 -0
- package/dist/admin/reviewer-scope-editor.d.ts +91 -0
- package/dist/admin/reviewer-scope-editor.js +134 -0
- package/dist/admin/reviewer-scope-editor.js.map +1 -0
- package/dist/admin/role-select.d.ts +91 -0
- package/dist/admin/role-select.js +128 -0
- package/dist/admin/role-select.js.map +1 -0
- package/dist/admin/transfer-ownership-dialog.d.ts +91 -0
- package/dist/admin/transfer-ownership-dialog.js +83 -0
- package/dist/admin/transfer-ownership-dialog.js.map +1 -0
- package/dist/admin/user-roster.d.ts +91 -0
- package/dist/admin/user-roster.js +285 -0
- package/dist/admin/user-roster.js.map +1 -0
- package/dist/auth/accept-invitation.d.ts +90 -0
- package/dist/auth/accept-invitation.js +117 -0
- package/dist/auth/accept-invitation.js.map +1 -0
- package/dist/auth/auth-errors.d.ts +139 -0
- package/dist/auth/auth-errors.js +92 -0
- package/dist/auth/auth-errors.js.map +1 -0
- package/dist/auth/complete-name-dialog.d.ts +71 -0
- package/dist/auth/complete-name-dialog.js +168 -0
- package/dist/auth/complete-name-dialog.js.map +1 -0
- package/dist/auth/email-tag.d.ts +60 -0
- package/dist/auth/email-tag.js +23 -0
- package/dist/auth/email-tag.js.map +1 -0
- package/dist/auth/forgot-password-form.d.ts +86 -0
- package/dist/auth/forgot-password-form.js +123 -0
- package/dist/auth/forgot-password-form.js.map +1 -0
- package/dist/auth/form-rules.d.ts +27 -0
- package/dist/auth/form-rules.js +23 -0
- package/dist/auth/form-rules.js.map +1 -0
- package/dist/auth/new-password-fields.d.ts +38 -0
- package/dist/auth/new-password-fields.js +54 -0
- package/dist/auth/new-password-fields.js.map +1 -0
- package/dist/auth/not-found-page.d.ts +57 -0
- package/dist/auth/not-found-page.js +40 -0
- package/dist/auth/not-found-page.js.map +1 -0
- package/dist/auth/register-form.d.ts +91 -0
- package/dist/auth/register-form.js +270 -0
- package/dist/auth/register-form.js.map +1 -0
- package/dist/auth/reset-password-form.d.ts +131 -0
- package/dist/auth/reset-password-form.js +167 -0
- package/dist/auth/reset-password-form.js.map +1 -0
- package/dist/auth/sign-in-form.d.ts +295 -0
- package/dist/auth/sign-in-form.js +426 -0
- package/dist/auth/sign-in-form.js.map +1 -0
- package/dist/auth/status-parts.d.ts +78 -0
- package/dist/auth/status-parts.js +83 -0
- package/dist/auth/status-parts.js.map +1 -0
- package/dist/auth/verify-email.d.ts +126 -0
- package/dist/auth/verify-email.js +243 -0
- package/dist/auth/verify-email.js.map +1 -0
- package/dist/chart.d.ts +25 -5
- package/dist/components/account-chips.d.ts +47 -7
- package/dist/components/account-chips.js +19 -3
- package/dist/components/account-chips.js.map +1 -1
- package/dist/components/account-settings-labels.d.ts +12 -1
- package/dist/components/account-settings-labels.js +4 -1
- package/dist/components/account-settings-labels.js.map +1 -1
- package/dist/components/account-settings.d.ts +61 -6
- package/dist/components/account-settings.js +115 -15
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +26 -5
- package/dist/components/button-group.d.ts +26 -5
- package/dist/components/calculator.d.ts +26 -5
- package/dist/components/confirm-dialog.d.ts +26 -5
- package/dist/components/copy-button.d.ts +23 -2
- package/dist/components/danger-confirm.d.ts +26 -5
- package/dist/components/facing-pair.d.ts +26 -5
- package/dist/components/file-button.d.ts +26 -5
- package/dist/components/file-dropzone.d.ts +26 -5
- package/dist/components/form-actions.d.ts +26 -5
- package/dist/components/iban-input.d.ts +26 -5
- package/dist/components/language-select.d.ts +26 -12
- package/dist/components/legal-page.d.ts +26 -5
- package/dist/components/legal.d.ts +26 -5
- package/dist/components/money-field.d.ts +26 -5
- package/dist/components/number-field.d.ts +26 -5
- package/dist/components/number-input.d.ts +26 -5
- package/dist/components/numpad-sheet.d.ts +26 -5
- package/dist/components/phone-input.d.ts +26 -5
- package/dist/components/series-chart.d.ts +26 -5
- package/dist/components/settings-fields.d.ts +25 -7
- package/dist/components/share-card.d.ts +25 -4
- package/dist/components/text-link.d.ts +26 -5
- package/dist/components/time-input.d.ts +26 -5
- package/dist/components/ui.d.ts +23 -2
- package/dist/components/user-avatar.d.ts +16 -2
- package/dist/components/user-avatar.js +7 -3
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/{kit-labels-Du0uHBq4.d.ts → delete-account-setting-CGVMckMw.d.ts} +6654 -5302
- package/dist/feedback/feedback-attachment.d.ts +26 -5
- package/dist/feedback/feedback-context.d.ts +26 -5
- package/dist/feedback/feedback-crash.d.ts +26 -5
- package/dist/feedback/feedback-dialog.d.ts +26 -5
- package/dist/feedback/feedback-inbox.d.ts +26 -5
- package/dist/feedback/feedback-labels.d.ts +26 -5
- package/dist/feedback/feedback-menu.d.ts +26 -5
- package/dist/feedback/feedback-record.d.ts +26 -5
- package/dist/feedback/feedback-row-detail.d.ts +26 -5
- package/dist/feedback/feedback-status-undo.d.ts +26 -5
- package/dist/feedback/feedback-submit.d.ts +26 -5
- package/dist/feedback/feedback-swipe.d.ts +26 -5
- package/dist/feedback/feedback-table.d.ts +23 -2
- package/dist/feedback/feedback-thread.d.ts +26 -5
- package/dist/feedback.d.ts +26 -5
- package/dist/hooks/use-anchored-panel.d.ts +6 -2
- package/dist/hooks/use-anchored-panel.js +2 -1
- package/dist/hooks/use-anchored-panel.js.map +1 -1
- package/dist/hooks/use-file-drop.d.ts +26 -5
- package/dist/i18n/defaults.d.ts +26 -5
- package/dist/i18n/defaults.js +40 -0
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +26 -5
- package/dist/i18n/german.js +343 -2
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +23 -2
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +21 -204
- package/dist/i18n/locales/de-CH.d.ts +26 -5
- package/dist/i18n/locales/en.d.ts +26 -5
- package/dist/i18n/locales/es.d.ts +26 -5
- package/dist/i18n/locales/es.js +337 -3
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +26 -5
- package/dist/i18n/locales/fr.js +344 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +26 -5
- package/dist/i18n/locales/hu.js +337 -3
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +26 -5
- package/dist/i18n/locales/it.js +342 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +26 -5
- package/dist/i18n/locales/zh.js +333 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +26 -5
- package/dist/i18n/review.js +45 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +19 -3
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/person-name.d.ts +69 -0
- package/dist/lib/person-name.js +65 -0
- package/dist/lib/person-name.js.map +1 -0
- package/dist/rhf/fields.d.ts +26 -5
- package/dist/rhf/form.d.ts +26 -5
- package/dist/rhf.d.ts +26 -5
- package/dist/shell/app-shell.d.ts +26 -5
- package/dist/shell/company-switcher.d.ts +59 -0
- package/dist/shell/company-switcher.js +85 -0
- package/dist/shell/company-switcher.js.map +1 -0
- package/dist/shell/top-bar-brand.d.ts +26 -5
- package/dist/shell/topbar-action-menu.d.ts +1 -0
- package/dist/shell.d.ts +20 -5
- package/dist/wizard/stepper-nav.d.ts +26 -5
- package/dist/wizard.d.ts +26 -5
- package/package.json +1 -1
- package/src/account/account-parts.ts +67 -0
- package/src/account/data-export-setting.tsx +218 -0
- package/src/account/delete-account-setting.tsx +362 -0
- package/src/account/email-change-setting.tsx +457 -0
- package/src/account/sessions-setting.tsx +283 -0
- package/src/admin/admin-action-confirm.tsx +495 -0
- package/src/admin/admin-action-log.tsx +297 -0
- package/src/admin/admin-parts.ts +82 -0
- package/src/admin/invitations-panel.tsx +516 -0
- package/src/admin/reviewer-scope-editor.tsx +234 -0
- package/src/admin/role-select.tsx +286 -0
- package/src/admin/transfer-ownership-dialog.tsx +172 -0
- package/src/admin/user-roster.tsx +573 -0
- package/src/auth/accept-invitation.tsx +227 -0
- package/src/auth/auth-errors.ts +262 -0
- package/src/auth/complete-name-dialog.tsx +253 -0
- package/src/auth/email-tag.ts +75 -0
- package/src/auth/forgot-password-form.tsx +229 -0
- package/src/auth/form-rules.ts +40 -0
- package/src/auth/new-password-fields.tsx +85 -0
- package/src/auth/not-found-page.tsx +98 -0
- package/src/auth/register-form.tsx +477 -0
- package/src/auth/reset-password-form.tsx +351 -0
- package/src/auth/sign-in-form.tsx +859 -0
- package/src/auth/status-parts.tsx +138 -0
- package/src/auth/verify-email.tsx +409 -0
- package/src/components/account-chips.tsx +64 -7
- package/src/components/account-settings-labels.ts +15 -1
- package/src/components/account-settings.tsx +199 -23
- package/src/components/user-avatar.tsx +22 -4
- package/src/hooks/use-anchored-panel.ts +14 -3
- package/src/i18n/defaults.ts +40 -0
- package/src/i18n/german.ts +379 -0
- package/src/i18n/kit-labels.tsx +60 -0
- package/src/i18n/locales/es.ts +371 -1
- package/src/i18n/locales/fr.ts +379 -0
- package/src/i18n/locales/hu.ts +366 -1
- package/src/i18n/locales/it.ts +373 -0
- package/src/i18n/locales/zh.ts +343 -0
- package/src/i18n/review.ts +44 -0
- package/src/index.ts +146 -0
- package/src/lib/person-name.ts +157 -0
- package/src/shell/company-switcher.tsx +140 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
const FORM_HEADING_CLASS = "text-base font-semibold text-[var(--text-primary)]";
|
|
6
|
+
const STATUS_HEADING_CLASS = "text-center text-base font-semibold text-[var(--text-primary)]";
|
|
7
|
+
const INTRO_CLASS = "text-sm text-[var(--text-secondary)]";
|
|
8
|
+
const OUTCOME_CLASS = "border-0 bg-transparent px-0 py-3";
|
|
9
|
+
function withQuery(href, key, value) {
|
|
10
|
+
const hash = href.indexOf("#");
|
|
11
|
+
const base = hash === -1 ? href : href.slice(0, hash);
|
|
12
|
+
const fragment = hash === -1 ? "" : href.slice(hash);
|
|
13
|
+
const separator = base.includes("?") ? base.endsWith("?") || base.endsWith("&") ? "" : "&" : "?";
|
|
14
|
+
return `${base}${separator}${encodeURIComponent(key)}=${encodeURIComponent(value)}${fragment}`;
|
|
15
|
+
}
|
|
16
|
+
function useOncePerKey(key, start, settle) {
|
|
17
|
+
const latest = useRef({ start, settle });
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
latest.current = { start, settle };
|
|
20
|
+
});
|
|
21
|
+
const current = useRef(null);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (key === null) {
|
|
24
|
+
current.current = null;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (current.current === key) return;
|
|
28
|
+
current.current = key;
|
|
29
|
+
const report = (result) => {
|
|
30
|
+
if (current.current === key) latest.current.settle(key, result);
|
|
31
|
+
};
|
|
32
|
+
let started;
|
|
33
|
+
try {
|
|
34
|
+
started = latest.current.start(key);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
report({ ok: false, error });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
Promise.resolve(started).then(
|
|
40
|
+
(value) => report({ ok: true, value }),
|
|
41
|
+
(error) => report({ ok: false, error })
|
|
42
|
+
);
|
|
43
|
+
}, [key]);
|
|
44
|
+
}
|
|
45
|
+
function isThenable(value) {
|
|
46
|
+
return typeof value?.then === "function";
|
|
47
|
+
}
|
|
48
|
+
function useFocusWhen(active, ref) {
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (active) ref.current?.focus();
|
|
51
|
+
}, [active, ref]);
|
|
52
|
+
}
|
|
53
|
+
function OutcomeMessage({
|
|
54
|
+
icon,
|
|
55
|
+
children,
|
|
56
|
+
focusRef,
|
|
57
|
+
className
|
|
58
|
+
}) {
|
|
59
|
+
return /* @__PURE__ */ jsxs(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
ref: focusRef,
|
|
63
|
+
tabIndex: -1,
|
|
64
|
+
className: cn("flex flex-col items-center gap-2 py-2 text-center outline-none", className),
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "[&_svg]:size-10", children: icon }),
|
|
67
|
+
children
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
FORM_HEADING_CLASS,
|
|
74
|
+
INTRO_CLASS,
|
|
75
|
+
OUTCOME_CLASS,
|
|
76
|
+
OutcomeMessage,
|
|
77
|
+
STATUS_HEADING_CLASS,
|
|
78
|
+
isThenable,
|
|
79
|
+
useFocusWhen,
|
|
80
|
+
useOncePerKey,
|
|
81
|
+
withQuery
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=status-parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/auth/status-parts.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\n\n/**\n * The pieces the signed-out status pages share — {@link ForgotPasswordForm},\n * {@link ResetPasswordForm}, {@link VerifyEmailStatus}, {@link AcceptInvitation} and\n * {@link NotFoundPage} (docs/auth-harmonization.md §7).\n *\n * @internal Not part of the barrel; the pages are.\n */\n\n/** A heading level a page part may take. Default `h2`, under the page's `h1`\n * (`AuthLayout`'s `title`, the app's name), as on `SignInForm`'s steps; deeper for a\n * page embedded in another (a preview, the docs). */\nexport type AuthHeadingLevel = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n\n/** The form pages' heading: start-aligned, the size of `SignInForm`'s step headings. */\nexport const FORM_HEADING_CLASS = \"text-base font-semibold text-[var(--text-primary)]\";\n/** The status pages' heading: centred over the centred outcome below it. */\nexport const STATUS_HEADING_CLASS = \"text-center text-base font-semibold text-[var(--text-primary)]\";\nexport const INTRO_CLASS = \"text-sm text-[var(--text-secondary)]\";\n\n/**\n * kastlan's outcome block (verify-email-page, reset-password-page): the kit's\n * `EmptyState` without its dashed box, because it already sits in `AuthLayout`'s card —\n * a box in a box. The icon and the title carry the tone.\n */\nexport const OUTCOME_CLASS = \"border-0 bg-transparent px-0 py-3\";\n\n/** `href` with `key=value` added to its query, before any `#fragment`: the reset page's\n * \"Sign in\" carries the address (`/login?email=ada%40example.com`). */\nexport function withQuery(href: string, key: string, value: string): string {\n const hash = href.indexOf(\"#\");\n const base = hash === -1 ? href : href.slice(0, hash);\n const fragment = hash === -1 ? \"\" : href.slice(hash);\n const separator = base.includes(\"?\") ? (base.endsWith(\"?\") || base.endsWith(\"&\") ? \"\" : \"&\") : \"?\";\n return `${base}${separator}${encodeURIComponent(key)}=${encodeURIComponent(value)}${fragment}`;\n}\n\n/** What a callback's promise came to. */\nexport type Settled<T> = { ok: true; value: T } | { ok: false; error: unknown };\n\n/**\n * Run `start(key)` ONCE per key, and hand what it settles to into `settle` — unless the\n * key moved on in the meantime, when the stale answer is dropped.\n *\n * keksdose's verify-email and join pages fire their request from an effect behind a\n * `useRef` guard, and say why: the token is single-use, and StrictMode's\n * mount → unmount → remount would send it twice and turn a success into \"invalid\" on\n * the second answer. The guard is the same here; there is deliberately no \"unmounted\"\n * flag set in the cleanup, because StrictMode's simulated unmount would set it and the\n * remount would never clear the guard — the page would hang on its spinner (the bug\n * keksdose hit on /join with a react-query observer). A state update after a real\n * unmount is a no-op in React 18 and later.\n *\n * `key === null` runs nothing (no token, not signed in yet) and forgets the last key, so\n * the same token runs again once it is back.\n */\nexport function useOncePerKey<T>(\n key: string | null,\n start: (key: string) => T | Promise<T>,\n settle: (key: string, result: Settled<T>) => void,\n): void {\n const latest = useRef({ start, settle });\n useEffect(() => {\n latest.current = { start, settle };\n });\n const current = useRef<string | null>(null);\n useEffect(() => {\n if (key === null) {\n current.current = null;\n return;\n }\n if (current.current === key) return;\n current.current = key;\n const report = (result: Settled<T>) => {\n if (current.current === key) latest.current.settle(key, result);\n };\n let started: T | Promise<T>;\n try {\n started = latest.current.start(key);\n } catch (error) {\n report({ ok: false, error });\n return;\n }\n Promise.resolve(started).then(\n (value) => report({ ok: true, value }),\n (error: unknown) => report({ ok: false, error }),\n );\n }, [key]);\n}\n\n/** Whether a callback's return is a promise to wait for. A callback that returns\n * nothing is done when it returns. */\nexport function isThenable(value: unknown): value is PromiseLike<unknown> {\n return typeof (value as PromiseLike<unknown> | null)?.then === \"function\";\n}\n\n/**\n * Move focus to `ref` when `active` turns true — the outcome a person's own submit led\n * to (\"If an account exists … the link is on its way\", \"Your password has been\n * changed\"). The submit button they pressed is gone with the form, which drops focus to\n * `<body>`; a screen reader then hears nothing at all. Focusing the message (a\n * `tabIndex={-1}` box) reads it out and leaves the next Tab where the page continues.\n */\nexport function useFocusWhen(active: boolean, ref: { current: HTMLElement | null }): void {\n useEffect(() => {\n if (active) ref.current?.focus();\n }, [active, ref]);\n}\n\n/** The box {@link useFocusWhen} focuses: centred, no focus ring of its own (it is not a\n * control; the ring would read as one). */\nexport function OutcomeMessage({\n icon,\n children,\n focusRef,\n className,\n}: {\n icon: ReactNode;\n children: ReactNode;\n focusRef?: { current: HTMLDivElement | null };\n className?: string;\n}) {\n return (\n <div\n ref={focusRef}\n tabIndex={-1}\n className={cn(\"flex flex-col items-center gap-2 py-2 text-center outline-none\", className)}\n >\n <span aria-hidden className=\"[&_svg]:size-10\">\n {icon}\n </span>\n {children}\n </div>\n );\n}\n"],"mappings":";AA8HI,SAKE,KALF;AA9HJ,SAAS,WAAW,cAAc;AAElC,SAAS,UAAU;AAgBZ,MAAM,qBAAqB;AAE3B,MAAM,uBAAuB;AAC7B,MAAM,cAAc;AAOpB,MAAM,gBAAgB;AAItB,SAAS,UAAU,MAAc,KAAa,OAAuB;AAC1E,QAAM,OAAO,KAAK,QAAQ,GAAG;AAC7B,QAAM,OAAO,SAAS,KAAK,OAAO,KAAK,MAAM,GAAG,IAAI;AACpD,QAAM,WAAW,SAAS,KAAK,KAAK,KAAK,MAAM,IAAI;AACnD,QAAM,YAAY,KAAK,SAAS,GAAG,IAAK,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,GAAG,IAAI,KAAK,MAAO;AAC/F,SAAO,GAAG,IAAI,GAAG,SAAS,GAAG,mBAAmB,GAAG,CAAC,IAAI,mBAAmB,KAAK,CAAC,GAAG,QAAQ;AAC9F;AAqBO,SAAS,cACd,KACA,OACA,QACM;AACN,QAAM,SAAS,OAAO,EAAE,OAAO,OAAO,CAAC;AACvC,YAAU,MAAM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sWithoutRef } from 'react';
|
|
3
|
+
import { AuthHeadingLevel } from './status-parts.js';
|
|
4
|
+
|
|
5
|
+
/** Every string the verification page and banner render — the `verifyEmail` namespace.
|
|
6
|
+
* keksdose's words (`verify_email.*`, and its server's "has expired"). */
|
|
7
|
+
interface VerifyEmailLabels {
|
|
8
|
+
/** The page's heading. */
|
|
9
|
+
title: string;
|
|
10
|
+
/** While the link is redeemed. */
|
|
11
|
+
verifying: string;
|
|
12
|
+
verified: string;
|
|
13
|
+
/** The way on from the page — into the app, or to sign-in. */
|
|
14
|
+
continue: string;
|
|
15
|
+
invalid: string;
|
|
16
|
+
expired: string;
|
|
17
|
+
/** The page was opened without a `token`. */
|
|
18
|
+
noToken: string;
|
|
19
|
+
/** Under `invalid`: why a link stops working. */
|
|
20
|
+
invalidHint: string;
|
|
21
|
+
/** Under a dead link, signed out: where a new one comes from. */
|
|
22
|
+
requestInApp: string;
|
|
23
|
+
/** Under a dead link, signed in, beside "Send again". */
|
|
24
|
+
requestHere: string;
|
|
25
|
+
/** The resend button, on the page and in the banner. */
|
|
26
|
+
resend: string;
|
|
27
|
+
/** The resend button while a just-sent mail cools down, given the seconds left. */
|
|
28
|
+
resendIn: (seconds: number) => string;
|
|
29
|
+
/** Said (and shown) after a resend went out. */
|
|
30
|
+
resent: string;
|
|
31
|
+
/** Said (and shown) after a resend failed. */
|
|
32
|
+
resendError: string;
|
|
33
|
+
/** The banner's message. */
|
|
34
|
+
banner: string;
|
|
35
|
+
/** The banner's ×: it defers, it does not close anything. */
|
|
36
|
+
dismiss: string;
|
|
37
|
+
}
|
|
38
|
+
declare const DEFAULT_VERIFY_EMAIL_LABELS: VerifyEmailLabels;
|
|
39
|
+
/** What became of a confirmation link that did not verify. */
|
|
40
|
+
type VerifyEmailFailure = "invalid" | "expired";
|
|
41
|
+
interface VerifyEmailStatusProps extends Omit<ComponentPropsWithoutRef<"div">, "children" | "title"> {
|
|
42
|
+
/** The link's token — the app's `?token=`. Empty: the link was cut short, and the
|
|
43
|
+
* page says so without asking anyone. */
|
|
44
|
+
token: string;
|
|
45
|
+
/**
|
|
46
|
+
* Redeem it — `POST /auth/verify-email {token}`, once per token, on mount. A POST and
|
|
47
|
+
* not the link's own GET (§10.10): a mail scanner that opens every link must not
|
|
48
|
+
* confirm an address nobody read. Resolve when it verified (an address that already
|
|
49
|
+
* was counts: keksdose's redeem is idempotent); reject with the client's error.
|
|
50
|
+
*/
|
|
51
|
+
onVerify: (token: string) => Promise<unknown>;
|
|
52
|
+
/** Which dead end a rejection is. Default: `invalid` for everything — §5.2's servers
|
|
53
|
+
* answer one `token_invalid`; an app whose server tells expiry apart maps it here. */
|
|
54
|
+
classifyError?: (error: unknown) => VerifyEmailFailure;
|
|
55
|
+
/** 0.29.1: the words for a refused resend — the server's own sentence (a throttle's
|
|
56
|
+
* "try again in N minutes"), else the kit's `resendError`. */
|
|
57
|
+
describeError?: (error: unknown) => string | undefined;
|
|
58
|
+
/** Someone is signed in on this device: "Continue" goes into the app, and a dead link
|
|
59
|
+
* offers "Send again" (with `onResend`). */
|
|
60
|
+
signedIn?: boolean;
|
|
61
|
+
/** Send a new confirmation mail (`POST /auth/verify-email/resend`) — offered on a dead
|
|
62
|
+
* link while signed in. */
|
|
63
|
+
onResend?: () => Promise<unknown> | void;
|
|
64
|
+
/** Seconds "Send again" waits after a mail went out. Default 60; `0` never waits. */
|
|
65
|
+
cooldown?: number;
|
|
66
|
+
/** Where "Continue" goes. Default `/` signed in, `/login` signed out. */
|
|
67
|
+
continueHref?: string;
|
|
68
|
+
/** App content under "confirmed" — keksdose's "Others can now share a budget with you
|
|
69
|
+
* directly." */
|
|
70
|
+
verifiedContent?: ReactNode;
|
|
71
|
+
/** The heading. Default `labels.title`; `null` draws none, for a page that puts it in
|
|
72
|
+
* `AuthLayout`'s `title` instead. */
|
|
73
|
+
title?: ReactNode;
|
|
74
|
+
/** The heading's level. Default `h2`, under the page's `h1`. */
|
|
75
|
+
headingAs?: AuthHeadingLevel;
|
|
76
|
+
labels?: Partial<VerifyEmailLabels>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Redeem an email-confirmation link (`/verify-email?token=…`, docs/auth-harmonization.md
|
|
80
|
+
* §7) — keksdose's `VerifyEmailPage` (features/auth/verify-email-page.tsx), with
|
|
81
|
+
* kastlan's outcome blocks and its separate "expired".
|
|
82
|
+
*
|
|
83
|
+
* Opened from an inbox, often in a browser with no session, so the token is the only
|
|
84
|
+
* credential and the page renders signed-out. It redeems once per token on mount
|
|
85
|
+
* (StrictMode's double effect included — the token is single-use) and shows one of:
|
|
86
|
+
* confirmed; not valid; expired; or the link had no token at all. Verification gates
|
|
87
|
+
* nothing (§2.8), so every outcome ends on "Continue". Signed in, a dead link also
|
|
88
|
+
* offers "Send again", which waits `cooldown` seconds after a mail went out.
|
|
89
|
+
*
|
|
90
|
+
* The outcome replaces the spinner, which says nothing to a screen reader on its own,
|
|
91
|
+
* so it is also announced.
|
|
92
|
+
*/
|
|
93
|
+
declare function VerifyEmailStatus({ token, onVerify, classifyError, describeError, signedIn, onResend, cooldown, continueHref, verifiedContent, title, headingAs: Heading, labels: labelsProp, className, ...rest }: VerifyEmailStatusProps): react.JSX.Element;
|
|
94
|
+
interface EmailVerificationBannerProps {
|
|
95
|
+
/** Send a new confirmation mail (`POST /auth/verify-email/resend`). Resolve when it
|
|
96
|
+
* went out; reject and the banner says it could not. */
|
|
97
|
+
onResend: () => Promise<unknown> | void;
|
|
98
|
+
/** 0.29.1: the words for a refused resend — the server's own sentence, else the kit's. */
|
|
99
|
+
describeError?: (error: unknown) => string | undefined;
|
|
100
|
+
/** Seconds "Send again" waits after a mail went out. Default 60; `0` never waits. */
|
|
101
|
+
cooldown?: number;
|
|
102
|
+
/** The ×, "Not now". The banner does not hide itself: the app stops rendering it —
|
|
103
|
+
* keksdose for the rest of the session. Left out, no ×. */
|
|
104
|
+
onDismiss?: () => void;
|
|
105
|
+
/** `strip` (default): keksdose's band across the top of the shell. `box`: kastlan's
|
|
106
|
+
* callout inside the page. */
|
|
107
|
+
variant?: "strip" | "box";
|
|
108
|
+
/** The app's sentence after the kit's — keksdose's "Until you do, nobody can share a
|
|
109
|
+
* budget with you directly." */
|
|
110
|
+
children?: ReactNode;
|
|
111
|
+
className?: string;
|
|
112
|
+
labels?: Partial<VerifyEmailLabels>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The nudge for a signed-in account whose address is not confirmed — keksdose's
|
|
116
|
+
* `VerifyEmailBanner` (features/auth/verify-email-banner.tsx), kastlan's copy of it.
|
|
117
|
+
*
|
|
118
|
+
* A prompt, not a wall: verification gates nothing (§2.8). The app renders it while
|
|
119
|
+
* `/auth/me` says `email_verified: false`, and stops when the user dismisses it or the
|
|
120
|
+
* page above confirms the address. "Send again" waits `cooldown` seconds after a mail
|
|
121
|
+
* went out (the button says how long), and its outcome is written into the banner and
|
|
122
|
+
* read out — no toast needed.
|
|
123
|
+
*/
|
|
124
|
+
declare function EmailVerificationBanner({ onResend, describeError, cooldown, onDismiss, variant, children, className, labels: labelsProp, }: EmailVerificationBannerProps): react.JSX.Element;
|
|
125
|
+
|
|
126
|
+
export { DEFAULT_VERIFY_EMAIL_LABELS, EmailVerificationBanner, type EmailVerificationBannerProps, type VerifyEmailFailure, type VerifyEmailLabels, VerifyEmailStatus, type VerifyEmailStatusProps };
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { CheckCircle2, MailWarning, TimerOff, XCircle } from "lucide-react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
7
|
+
import { useAnnounce } from "../hooks/use-announce.js";
|
|
8
|
+
import { AlertBanner } from "../components/alert-banner.js";
|
|
9
|
+
import { LoadingState } from "../components/loading-state.js";
|
|
10
|
+
import { Button, EmptyState } from "../components/ui.js";
|
|
11
|
+
import { OUTCOME_CLASS, STATUS_HEADING_CLASS, isThenable, useOncePerKey } from "./status-parts.js";
|
|
12
|
+
import { authErrorCode } from "./auth-errors.js";
|
|
13
|
+
const DEFAULT_VERIFY_EMAIL_LABELS = {
|
|
14
|
+
title: "Confirm your email address",
|
|
15
|
+
verifying: "Confirming\u2026",
|
|
16
|
+
verified: "Your email address is confirmed.",
|
|
17
|
+
continue: "Continue",
|
|
18
|
+
invalid: "This confirmation link is not valid",
|
|
19
|
+
expired: "This confirmation link has expired",
|
|
20
|
+
noToken: "This link is missing its confirmation token.",
|
|
21
|
+
invalidHint: "The link may have expired or already been used.",
|
|
22
|
+
requestInApp: "You can request a new one from inside the app.",
|
|
23
|
+
requestHere: "You can request a new one here.",
|
|
24
|
+
resend: "Send again",
|
|
25
|
+
resendIn: (seconds) => `Send again in ${seconds} s`,
|
|
26
|
+
resent: "Confirmation email sent",
|
|
27
|
+
resendError: "Could not send the confirmation email",
|
|
28
|
+
banner: "Please confirm your email address.",
|
|
29
|
+
dismiss: "Not now"
|
|
30
|
+
};
|
|
31
|
+
const DEFAULT_COOLDOWN = 60;
|
|
32
|
+
function useResend(onResend, cooldown) {
|
|
33
|
+
const [phase, setPhase] = useState("idle");
|
|
34
|
+
const [error, setError] = useState(void 0);
|
|
35
|
+
const [remaining, setRemaining] = useState(0);
|
|
36
|
+
const counting = remaining > 0;
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!counting) return;
|
|
39
|
+
const id = setInterval(() => setRemaining((r) => Math.max(0, r - 1)), 1e3);
|
|
40
|
+
return () => clearInterval(id);
|
|
41
|
+
}, [counting]);
|
|
42
|
+
const sent = () => {
|
|
43
|
+
setPhase("sent");
|
|
44
|
+
setRemaining(Math.max(0, Math.round(cooldown)));
|
|
45
|
+
};
|
|
46
|
+
const send = () => {
|
|
47
|
+
if (!onResend || phase === "sending" || counting) return;
|
|
48
|
+
let result;
|
|
49
|
+
try {
|
|
50
|
+
result = onResend();
|
|
51
|
+
} catch (e) {
|
|
52
|
+
setError(e);
|
|
53
|
+
setPhase("failed");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!isThenable(result)) {
|
|
57
|
+
sent();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
setPhase("sending");
|
|
61
|
+
result.then(sent, (e) => {
|
|
62
|
+
setError(e);
|
|
63
|
+
setPhase("failed");
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
return { phase, remaining, send, error };
|
|
67
|
+
}
|
|
68
|
+
function ResendButton({
|
|
69
|
+
state,
|
|
70
|
+
labels,
|
|
71
|
+
variant
|
|
72
|
+
}) {
|
|
73
|
+
return /* @__PURE__ */ jsx(
|
|
74
|
+
Button,
|
|
75
|
+
{
|
|
76
|
+
type: "button",
|
|
77
|
+
variant,
|
|
78
|
+
size: variant === "secondary" ? "sm" : void 0,
|
|
79
|
+
onClick: state.send,
|
|
80
|
+
pending: state.phase === "sending",
|
|
81
|
+
disabledReason: state.remaining > 0 ? labels.resent : void 0,
|
|
82
|
+
children: state.remaining > 0 ? labels.resendIn(state.remaining) : labels.resend
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
function ResendStatus({
|
|
87
|
+
phase,
|
|
88
|
+
error,
|
|
89
|
+
describeError,
|
|
90
|
+
labels,
|
|
91
|
+
className
|
|
92
|
+
}) {
|
|
93
|
+
const failed = phase === "failed" ? describeError?.(error) ?? labels.resendError : "";
|
|
94
|
+
return /* @__PURE__ */ jsx(
|
|
95
|
+
"span",
|
|
96
|
+
{
|
|
97
|
+
role: "status",
|
|
98
|
+
className: cn(phase === "failed" ? "text-[var(--danger)]" : "text-[var(--success)]", className),
|
|
99
|
+
children: phase === "sent" ? labels.resent : failed
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
function defaultVerifyFailure(error) {
|
|
104
|
+
return authErrorCode(error) === "token_expired" ? "expired" : "invalid";
|
|
105
|
+
}
|
|
106
|
+
function VerifyEmailStatus({
|
|
107
|
+
token,
|
|
108
|
+
onVerify,
|
|
109
|
+
classifyError,
|
|
110
|
+
describeError,
|
|
111
|
+
signedIn = false,
|
|
112
|
+
onResend,
|
|
113
|
+
cooldown = DEFAULT_COOLDOWN,
|
|
114
|
+
continueHref,
|
|
115
|
+
verifiedContent,
|
|
116
|
+
title,
|
|
117
|
+
headingAs: Heading = "h2",
|
|
118
|
+
labels: labelsProp,
|
|
119
|
+
className,
|
|
120
|
+
...rest
|
|
121
|
+
}) {
|
|
122
|
+
const labels = useKitLabels("verifyEmail", DEFAULT_VERIFY_EMAIL_LABELS, labelsProp);
|
|
123
|
+
const [settled, setSettled] = useState(null);
|
|
124
|
+
const outcome = token === "" ? "invalid" : settled?.token === token ? settled.outcome : "verifying";
|
|
125
|
+
const { announce, regionProps } = useAnnounce();
|
|
126
|
+
const resend = useResend(onResend, cooldown);
|
|
127
|
+
useOncePerKey(token === "" ? null : token, onVerify, (key, result) => {
|
|
128
|
+
const next = result.ok ? "verified" : (classifyError ?? defaultVerifyFailure)(result.error);
|
|
129
|
+
setSettled({ token: key, outcome: next });
|
|
130
|
+
announce(labels[next]);
|
|
131
|
+
});
|
|
132
|
+
const href = continueHref ?? (signedIn ? "/" : "/login");
|
|
133
|
+
const continueButton = /* @__PURE__ */ jsx(Button, { href, replace: true, variant: outcome === "verified" ? "brand" : "secondary", children: labels.continue });
|
|
134
|
+
const canResend = signedIn && onResend !== void 0;
|
|
135
|
+
let body;
|
|
136
|
+
if (outcome === "verifying") {
|
|
137
|
+
body = /* @__PURE__ */ jsx(LoadingState, { size: "sm", label: labels.verifying });
|
|
138
|
+
} else if (outcome === "verified") {
|
|
139
|
+
body = /* @__PURE__ */ jsx(
|
|
140
|
+
EmptyState,
|
|
141
|
+
{
|
|
142
|
+
tone: "success",
|
|
143
|
+
icon: /* @__PURE__ */ jsx(CheckCircle2, {}),
|
|
144
|
+
title: labels.verified,
|
|
145
|
+
hint: verifiedContent,
|
|
146
|
+
action: continueButton,
|
|
147
|
+
className: OUTCOME_CLASS
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
} else {
|
|
151
|
+
const hint = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
152
|
+
outcome === "invalid" && token !== "" ? `${labels.invalidHint} ` : "",
|
|
153
|
+
canResend ? labels.requestHere : labels.requestInApp
|
|
154
|
+
] });
|
|
155
|
+
body = /* @__PURE__ */ jsx(
|
|
156
|
+
EmptyState,
|
|
157
|
+
{
|
|
158
|
+
tone: "danger",
|
|
159
|
+
icon: outcome === "expired" ? /* @__PURE__ */ jsx(TimerOff, {}) : /* @__PURE__ */ jsx(XCircle, {}),
|
|
160
|
+
title: token === "" ? labels.noToken : labels[outcome],
|
|
161
|
+
hint,
|
|
162
|
+
action: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
163
|
+
canResend && /* @__PURE__ */ jsx(ResendButton, { state: resend, labels, variant: "brand" }),
|
|
164
|
+
continueButton
|
|
165
|
+
] }),
|
|
166
|
+
className: OUTCOME_CLASS
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
return /* @__PURE__ */ jsxs(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
...rest,
|
|
174
|
+
"data-state": outcome,
|
|
175
|
+
"aria-busy": outcome === "verifying" || void 0,
|
|
176
|
+
className: cn("space-y-3", className),
|
|
177
|
+
children: [
|
|
178
|
+
title === null ? null : /* @__PURE__ */ jsx(Heading, { className: STATUS_HEADING_CLASS, children: title ?? labels.title }),
|
|
179
|
+
body,
|
|
180
|
+
canResend && /* @__PURE__ */ jsx(
|
|
181
|
+
ResendStatus,
|
|
182
|
+
{
|
|
183
|
+
phase: resend.phase,
|
|
184
|
+
error: resend.error,
|
|
185
|
+
describeError,
|
|
186
|
+
labels,
|
|
187
|
+
className: "block text-center text-xs"
|
|
188
|
+
}
|
|
189
|
+
),
|
|
190
|
+
/* @__PURE__ */ jsx("div", { ...regionProps })
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
function EmailVerificationBanner({
|
|
196
|
+
onResend,
|
|
197
|
+
describeError,
|
|
198
|
+
cooldown = DEFAULT_COOLDOWN,
|
|
199
|
+
onDismiss,
|
|
200
|
+
variant = "strip",
|
|
201
|
+
children,
|
|
202
|
+
className,
|
|
203
|
+
labels: labelsProp
|
|
204
|
+
}) {
|
|
205
|
+
const labels = useKitLabels("verifyEmail", DEFAULT_VERIFY_EMAIL_LABELS, labelsProp);
|
|
206
|
+
const resend = useResend(onResend, cooldown);
|
|
207
|
+
return /* @__PURE__ */ jsxs(
|
|
208
|
+
AlertBanner,
|
|
209
|
+
{
|
|
210
|
+
tone: "warning",
|
|
211
|
+
variant,
|
|
212
|
+
icon: /* @__PURE__ */ jsx(MailWarning, {}),
|
|
213
|
+
action: /* @__PURE__ */ jsx(ResendButton, { state: resend, labels, variant: "secondary" }),
|
|
214
|
+
onDismiss,
|
|
215
|
+
dismissLabel: onDismiss ? labels.dismiss : void 0,
|
|
216
|
+
className,
|
|
217
|
+
children: [
|
|
218
|
+
labels.banner,
|
|
219
|
+
children != null && children !== false && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
220
|
+
" ",
|
|
221
|
+
children
|
|
222
|
+
] }),
|
|
223
|
+
" ",
|
|
224
|
+
/* @__PURE__ */ jsx(
|
|
225
|
+
ResendStatus,
|
|
226
|
+
{
|
|
227
|
+
phase: resend.phase,
|
|
228
|
+
error: resend.error,
|
|
229
|
+
describeError,
|
|
230
|
+
labels,
|
|
231
|
+
className: "font-medium"
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
export {
|
|
239
|
+
DEFAULT_VERIFY_EMAIL_LABELS,
|
|
240
|
+
EmailVerificationBanner,
|
|
241
|
+
VerifyEmailStatus
|
|
242
|
+
};
|
|
243
|
+
//# sourceMappingURL=verify-email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/auth/verify-email.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { CheckCircle2, MailWarning, TimerOff, XCircle } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { LoadingState } from \"../components/loading-state\";\nimport { Button, EmptyState } from \"../components/ui\";\nimport { OUTCOME_CLASS, STATUS_HEADING_CLASS, isThenable, useOncePerKey } from \"./status-parts\";\nimport { authErrorCode } from \"./auth-errors\";\nimport type { AuthHeadingLevel } from \"./status-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the verification page and banner render — the `verifyEmail` namespace.\n * keksdose's words (`verify_email.*`, and its server's \"has expired\"). */\nexport interface VerifyEmailLabels {\n /** The page's heading. */\n title: string;\n /** While the link is redeemed. */\n verifying: string;\n verified: string;\n /** The way on from the page — into the app, or to sign-in. */\n continue: string;\n invalid: string;\n expired: string;\n /** The page was opened without a `token`. */\n noToken: string;\n /** Under `invalid`: why a link stops working. */\n invalidHint: string;\n /** Under a dead link, signed out: where a new one comes from. */\n requestInApp: string;\n /** Under a dead link, signed in, beside \"Send again\". */\n requestHere: string;\n /** The resend button, on the page and in the banner. */\n resend: string;\n /** The resend button while a just-sent mail cools down, given the seconds left. */\n resendIn: (seconds: number) => string;\n /** Said (and shown) after a resend went out. */\n resent: string;\n /** Said (and shown) after a resend failed. */\n resendError: string;\n /** The banner's message. */\n banner: string;\n /** The banner's ×: it defers, it does not close anything. */\n dismiss: string;\n}\n\nexport const DEFAULT_VERIFY_EMAIL_LABELS: VerifyEmailLabels = {\n title: \"Confirm your email address\",\n verifying: \"Confirming…\",\n verified: \"Your email address is confirmed.\",\n continue: \"Continue\",\n invalid: \"This confirmation link is not valid\",\n expired: \"This confirmation link has expired\",\n noToken: \"This link is missing its confirmation token.\",\n invalidHint: \"The link may have expired or already been used.\",\n requestInApp: \"You can request a new one from inside the app.\",\n requestHere: \"You can request a new one here.\",\n resend: \"Send again\",\n resendIn: (seconds) => `Send again in ${seconds} s`,\n resent: \"Confirmation email sent\",\n resendError: \"Could not send the confirmation email\",\n banner: \"Please confirm your email address.\",\n dismiss: \"Not now\",\n};\n\n/** A minute: long enough that an impatient second click does not mail twice, short\n * enough that a mail lost to a spam filter can be re-sent without leaving the page. The\n * server's own limit is the real one (kastlan: 3 an hour per address). */\nconst DEFAULT_COOLDOWN = 60;\n\n/* ── Resend ──────────────────────────────────────────────────────────────── */\n\ntype ResendPhase = \"idle\" | \"sending\" | \"sent\" | \"failed\";\n\n/**\n * \"Send again\" with its own memory: busy while the request runs, then — after a mail\n * went out — held for `cooldown` seconds with the countdown on the button, so a second\n * click cannot mail twice and a throttled server is not asked to refuse. A failure frees\n * it at once. The outcome is a polite live region that is always rendered (a region that\n * mounts with its message is often not read), and visible.\n */\nfunction useResend(onResend: (() => Promise<unknown> | void) | undefined, cooldown: number) {\n const [phase, setPhase] = useState<ResendPhase>(\"idle\");\n // The refusal itself, for `describeError` (0.29.1): the server's own sentence — keksdose's\n // per-address throttle, \"try again in N minutes\" — beats a fixed \"could not send\".\n const [error, setError] = useState<unknown>(undefined);\n const [remaining, setRemaining] = useState(0);\n const counting = remaining > 0;\n useEffect(() => {\n if (!counting) return;\n const id = setInterval(() => setRemaining((r) => Math.max(0, r - 1)), 1000);\n return () => clearInterval(id);\n }, [counting]);\n\n const sent = () => {\n setPhase(\"sent\");\n setRemaining(Math.max(0, Math.round(cooldown)));\n };\n const send = () => {\n if (!onResend || phase === \"sending\" || counting) return;\n let result: unknown;\n try {\n result = onResend();\n } catch (e) {\n setError(e);\n setPhase(\"failed\");\n return;\n }\n if (!isThenable(result)) {\n sent();\n return;\n }\n setPhase(\"sending\");\n result.then(sent, (e: unknown) => {\n setError(e);\n setPhase(\"failed\");\n });\n };\n return { phase, remaining, send, error };\n}\n\nfunction ResendButton({\n state,\n labels,\n variant,\n}: {\n state: ReturnType<typeof useResend>;\n labels: VerifyEmailLabels;\n variant: \"secondary\" | \"brand\";\n}) {\n return (\n <Button\n type=\"button\"\n variant={variant}\n size={variant === \"secondary\" ? \"sm\" : undefined}\n onClick={state.send}\n pending={state.phase === \"sending\"}\n // `disabledReason`, not `disabled`: the button just pressed has the focus, and a\n // native `disabled` would drop it to <body>. The reason is what just happened.\n disabledReason={state.remaining > 0 ? labels.resent : undefined}\n >\n {state.remaining > 0 ? labels.resendIn(state.remaining) : labels.resend}\n </Button>\n );\n}\n\nfunction ResendStatus({\n phase,\n error,\n describeError,\n labels,\n className,\n}: {\n phase: ResendPhase;\n error?: unknown;\n describeError?: (error: unknown) => string | undefined;\n labels: VerifyEmailLabels;\n className?: string;\n}) {\n const failed = phase === \"failed\" ? (describeError?.(error) ?? labels.resendError) : \"\";\n return (\n <span\n role=\"status\"\n className={cn(phase === \"failed\" ? \"text-[var(--danger)]\" : \"text-[var(--success)]\", className)}\n >\n {phase === \"sent\" ? labels.resent : failed}\n </span>\n );\n}\n\n/* ── The page ────────────────────────────────────────────────────────────── */\n\n/** What became of a confirmation link that did not verify. */\nexport type VerifyEmailFailure = \"invalid\" | \"expired\";\n\n/** The default when the app gives no `classifyError`: the coded refusal decides. */\nfunction defaultVerifyFailure(error: unknown): VerifyEmailFailure {\n return authErrorCode(error) === \"token_expired\" ? \"expired\" : \"invalid\";\n}\n\nexport interface VerifyEmailStatusProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"title\"> {\n /** The link's token — the app's `?token=`. Empty: the link was cut short, and the\n * page says so without asking anyone. */\n token: string;\n /**\n * Redeem it — `POST /auth/verify-email {token}`, once per token, on mount. A POST and\n * not the link's own GET (§10.10): a mail scanner that opens every link must not\n * confirm an address nobody read. Resolve when it verified (an address that already\n * was counts: keksdose's redeem is idempotent); reject with the client's error.\n */\n onVerify: (token: string) => Promise<unknown>;\n /** Which dead end a rejection is. Default: `invalid` for everything — §5.2's servers\n * answer one `token_invalid`; an app whose server tells expiry apart maps it here. */\n classifyError?: (error: unknown) => VerifyEmailFailure;\n /** 0.29.1: the words for a refused resend — the server's own sentence (a throttle's\n * \"try again in N minutes\"), else the kit's `resendError`. */\n describeError?: (error: unknown) => string | undefined;\n /** Someone is signed in on this device: \"Continue\" goes into the app, and a dead link\n * offers \"Send again\" (with `onResend`). */\n signedIn?: boolean;\n /** Send a new confirmation mail (`POST /auth/verify-email/resend`) — offered on a dead\n * link while signed in. */\n onResend?: () => Promise<unknown> | void;\n /** Seconds \"Send again\" waits after a mail went out. Default 60; `0` never waits. */\n cooldown?: number;\n /** Where \"Continue\" goes. Default `/` signed in, `/login` signed out. */\n continueHref?: string;\n /** App content under \"confirmed\" — keksdose's \"Others can now share a budget with you\n * directly.\" */\n verifiedContent?: ReactNode;\n /** The heading. Default `labels.title`; `null` draws none, for a page that puts it in\n * `AuthLayout`'s `title` instead. */\n title?: ReactNode;\n /** The heading's level. Default `h2`, under the page's `h1`. */\n headingAs?: AuthHeadingLevel;\n labels?: Partial<VerifyEmailLabels>;\n}\n\ntype VerifyOutcome = \"verified\" | VerifyEmailFailure;\n\n/**\n * Redeem an email-confirmation link (`/verify-email?token=…`, docs/auth-harmonization.md\n * §7) — keksdose's `VerifyEmailPage` (features/auth/verify-email-page.tsx), with\n * kastlan's outcome blocks and its separate \"expired\".\n *\n * Opened from an inbox, often in a browser with no session, so the token is the only\n * credential and the page renders signed-out. It redeems once per token on mount\n * (StrictMode's double effect included — the token is single-use) and shows one of:\n * confirmed; not valid; expired; or the link had no token at all. Verification gates\n * nothing (§2.8), so every outcome ends on \"Continue\". Signed in, a dead link also\n * offers \"Send again\", which waits `cooldown` seconds after a mail went out.\n *\n * The outcome replaces the spinner, which says nothing to a screen reader on its own,\n * so it is also announced.\n */\nexport function VerifyEmailStatus({\n token,\n onVerify,\n classifyError,\n describeError,\n signedIn = false,\n onResend,\n cooldown = DEFAULT_COOLDOWN,\n continueHref,\n verifiedContent,\n title,\n headingAs: Heading = \"h2\",\n labels: labelsProp,\n className,\n ...rest\n}: VerifyEmailStatusProps) {\n const labels = useKitLabels(\"verifyEmail\", DEFAULT_VERIFY_EMAIL_LABELS, labelsProp);\n const [settled, setSettled] = useState<{ token: string; outcome: VerifyOutcome } | null>(null);\n const outcome: VerifyOutcome | \"verifying\" =\n token === \"\" ? \"invalid\" : settled?.token === token ? settled.outcome : \"verifying\";\n const { announce, regionProps } = useAnnounce();\n const resend = useResend(onResend, cooldown);\n\n useOncePerKey(token === \"\" ? null : token, onVerify, (key, result) => {\n // Without a classifier, the coded refusal decides (0.29.1): `token_expired` is\n // \"expired\", anything else \"invalid\".\n const next: VerifyOutcome = result.ok\n ? \"verified\"\n : (classifyError ?? defaultVerifyFailure)(result.error);\n setSettled({ token: key, outcome: next });\n announce(labels[next]);\n });\n\n const href = continueHref ?? (signedIn ? \"/\" : \"/login\");\n // `replace`: the token is spent, so Back must not land on this page again (keksdose F1).\n const continueButton = (\n <Button href={href} replace variant={outcome === \"verified\" ? \"brand\" : \"secondary\"}>\n {labels.continue}\n </Button>\n );\n const canResend = signedIn && onResend !== undefined;\n\n let body: ReactNode;\n if (outcome === \"verifying\") {\n body = <LoadingState size=\"sm\" label={labels.verifying} />;\n } else if (outcome === \"verified\") {\n body = (\n <EmptyState\n tone=\"success\"\n icon={<CheckCircle2 />}\n title={labels.verified}\n hint={verifiedContent}\n action={continueButton}\n className={OUTCOME_CLASS}\n />\n );\n } else {\n const hint = (\n <>\n {outcome === \"invalid\" && token !== \"\" ? `${labels.invalidHint} ` : \"\"}\n {canResend ? labels.requestHere : labels.requestInApp}\n </>\n );\n body = (\n <EmptyState\n tone=\"danger\"\n icon={outcome === \"expired\" ? <TimerOff /> : <XCircle />}\n title={token === \"\" ? labels.noToken : labels[outcome]}\n hint={hint}\n action={\n <>\n {canResend && <ResendButton state={resend} labels={labels} variant=\"brand\" />}\n {continueButton}\n </>\n }\n className={OUTCOME_CLASS}\n />\n );\n }\n\n return (\n <div\n {...rest}\n data-state={outcome}\n aria-busy={outcome === \"verifying\" || undefined}\n className={cn(\"space-y-3\", className)}\n >\n {title === null ? null : <Heading className={STATUS_HEADING_CLASS}>{title ?? labels.title}</Heading>}\n {body}\n {canResend && (\n <ResendStatus\n phase={resend.phase}\n error={resend.error}\n describeError={describeError}\n labels={labels}\n className=\"block text-center text-xs\"\n />\n )}\n {/* Rendered from the start, so the outcome is read when it arrives. */}\n <div {...regionProps} />\n </div>\n );\n}\n\n/* ── The banner ──────────────────────────────────────────────────────────── */\n\nexport interface EmailVerificationBannerProps {\n /** Send a new confirmation mail (`POST /auth/verify-email/resend`). Resolve when it\n * went out; reject and the banner says it could not. */\n onResend: () => Promise<unknown> | void;\n /** 0.29.1: the words for a refused resend — the server's own sentence, else the kit's. */\n describeError?: (error: unknown) => string | undefined;\n /** Seconds \"Send again\" waits after a mail went out. Default 60; `0` never waits. */\n cooldown?: number;\n /** The ×, \"Not now\". The banner does not hide itself: the app stops rendering it —\n * keksdose for the rest of the session. Left out, no ×. */\n onDismiss?: () => void;\n /** `strip` (default): keksdose's band across the top of the shell. `box`: kastlan's\n * callout inside the page. */\n variant?: \"strip\" | \"box\";\n /** The app's sentence after the kit's — keksdose's \"Until you do, nobody can share a\n * budget with you directly.\" */\n children?: ReactNode;\n className?: string;\n labels?: Partial<VerifyEmailLabels>;\n}\n\n/**\n * The nudge for a signed-in account whose address is not confirmed — keksdose's\n * `VerifyEmailBanner` (features/auth/verify-email-banner.tsx), kastlan's copy of it.\n *\n * A prompt, not a wall: verification gates nothing (§2.8). The app renders it while\n * `/auth/me` says `email_verified: false`, and stops when the user dismisses it or the\n * page above confirms the address. \"Send again\" waits `cooldown` seconds after a mail\n * went out (the button says how long), and its outcome is written into the banner and\n * read out — no toast needed.\n */\nexport function EmailVerificationBanner({\n onResend,\n describeError,\n cooldown = DEFAULT_COOLDOWN,\n onDismiss,\n variant = \"strip\",\n children,\n className,\n labels: labelsProp,\n}: EmailVerificationBannerProps) {\n const labels = useKitLabels(\"verifyEmail\", DEFAULT_VERIFY_EMAIL_LABELS, labelsProp);\n const resend = useResend(onResend, cooldown);\n return (\n <AlertBanner\n tone=\"warning\"\n variant={variant}\n icon={<MailWarning />}\n action={<ResendButton state={resend} labels={labels} variant=\"secondary\" />}\n onDismiss={onDismiss}\n dismissLabel={onDismiss ? labels.dismiss : undefined}\n className={className}\n >\n {labels.banner}\n {children != null && children !== false && <> {children}</>}{\" \"}\n <ResendStatus\n phase={resend.phase}\n error={resend.error}\n describeError={describeError}\n labels={labels}\n className=\"font-medium\"\n />\n </AlertBanner>\n );\n}\n"],"mappings":";AAsII,SAkKE,UAlKF,KAkKE,YAlKF;AAtIJ,SAAS,WAAW,gBAAgB;AAEpC,SAAS,cAAc,aAAa,UAAU,eAAe;AAC7D,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,kBAAkB;AACnC,SAAS,eAAe,sBAAsB,YAAY,qBAAqB;AAC/E,SAAS,qBAAqB;AAuCvB,MAAM,8BAAiD;AAAA,EAC5D,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,aAAa;AAAA,EACb,cAAc;AAAA,EACd,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,UAAU,CAAC,YAAY,iBAAiB,OAAO;AAAA,EAC/C,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,SAAS;AACX;AAKA,MAAM,mBAAmB;AAazB,SAAS,UAAU,UAAuD,UAAkB;AAC1F,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAsB,MA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tC;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,QAAQ;AACV,GAAiC;AAC/B,QAAM,SAAS,aAAa,eAAe,6BAA6B,UAAU;AAClF,QAAM,SAAS,UAAU,UAAU,QAAQ;AAC3C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL;AAAA,MACA,MAAM,oBAAC,eAAY;AAAA,MACnB,QAAQ,oBAAC,gBAAa,OAAO,QAAQ,QAAgB,SAAQ,aAAY;AAAA,MACzE;AAAA,MACA,cAAc,YAAY,OAAO,UAAU;AAAA,MAC3C;AAAA,MAEC;AAAA,eAAO;AAAA,QACP,YAAY,QAAQ,aAAa,SAAS,iCAAE;AAAA;AAAA,UAAE;AAAA,WAAS;AAAA,QAAK;AAAA,QAC7D;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,OAAO;AAAA,YACd,OAAO,OAAO;AAAA,YACd;AAAA,YACA;AAAA,YACA,WAAU;AAAA;AAAA,QACZ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
package/dist/chart.d.ts
CHANGED
|
@@ -13,7 +13,10 @@ export { TimeTickUnit } from './components/series-chart-ticks.js';
|
|
|
13
13
|
import 'recharts';
|
|
14
14
|
import 'react';
|
|
15
15
|
import './lib/direction.js';
|
|
16
|
-
import './
|
|
16
|
+
import './delete-account-setting-CGVMckMw.js';
|
|
17
|
+
import './components/tooltip.js';
|
|
18
|
+
import './hooks/use-anchored-rect.js';
|
|
19
|
+
import './lib/clipping.js';
|
|
17
20
|
import './data-table-labels-DUELeXpa.js';
|
|
18
21
|
import './components/data-table-sort.js';
|
|
19
22
|
import './components/swipeable-row.js';
|
|
@@ -23,9 +26,6 @@ import './components/popover.js';
|
|
|
23
26
|
import './components/chip.js';
|
|
24
27
|
import 'lucide-react';
|
|
25
28
|
import './components/field-sync.js';
|
|
26
|
-
import './components/tooltip.js';
|
|
27
|
-
import './hooks/use-anchored-rect.js';
|
|
28
|
-
import './lib/clipping.js';
|
|
29
29
|
import './wizard/types.js';
|
|
30
30
|
import './tour/tour.js';
|
|
31
31
|
import './search/command-palette.js';
|
|
@@ -45,6 +45,7 @@ import './components/modal.js';
|
|
|
45
45
|
import './hooks/use-search-param-state.js';
|
|
46
46
|
import './components/measured-grid.js';
|
|
47
47
|
import './components/user-avatar.js';
|
|
48
|
+
import './lib/person-name.js';
|
|
48
49
|
import './components/status-dot.js';
|
|
49
50
|
import './components/progress-bar.js';
|
|
50
51
|
import './components/signed-amount.js';
|
|
@@ -64,8 +65,27 @@ import './components/authed-image.js';
|
|
|
64
65
|
import './components/image-grid.js';
|
|
65
66
|
import './components/lightbox.js';
|
|
66
67
|
import './components/write-lock.js';
|
|
67
|
-
import './
|
|
68
|
+
import './auth/sign-in-form.js';
|
|
69
|
+
import './shell/topbar-controls.js';
|
|
70
|
+
import './theme/palette-presets.js';
|
|
71
|
+
import './theme/theme-store.js';
|
|
72
|
+
import 'zustand/middleware';
|
|
73
|
+
import 'zustand';
|
|
74
|
+
import './auth/complete-name-dialog.js';
|
|
75
|
+
import './auth/forgot-password-form.js';
|
|
76
|
+
import './auth/status-parts.js';
|
|
77
|
+
import './auth/reset-password-form.js';
|
|
78
|
+
import './auth/verify-email.js';
|
|
79
|
+
import './auth/not-found-page.js';
|
|
80
|
+
import './auth/accept-invitation.js';
|
|
81
|
+
import './shell/company-switcher.js';
|
|
82
|
+
import './account/email-change-setting.js';
|
|
83
|
+
import './account/sessions-setting.js';
|
|
68
84
|
import './lib/format.js';
|
|
85
|
+
import './account/data-export-setting.js';
|
|
86
|
+
import './components/account-chips.js';
|
|
87
|
+
import './admin/admin-parts.js';
|
|
88
|
+
import './admin/admin-action-log.js';
|
|
69
89
|
import './components/reauth-dialog.js';
|
|
70
90
|
import './components/server-wake.js';
|
|
71
91
|
import './lib/server-wake.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ReactElement, ReactNode } from 'react';
|
|
3
3
|
import { LucideIcon } from 'lucide-react';
|
|
4
4
|
import { DateInput, FormatDateStyle, FormatRelativeTimeOptions } from '../lib/format.js';
|
|
5
5
|
import { ChipTone, ChipSize, ChipVariant, ChipShape } from './chip.js';
|
|
@@ -78,18 +78,58 @@ declare function RoleChip<R extends string = string>({ value: role, roles, size,
|
|
|
78
78
|
* - `registered` — an allowlist row whose address has an account now (Kurvenschmiede).
|
|
79
79
|
* - `unverified` — the email address is not confirmed (keksdose).
|
|
80
80
|
* - `passwordChange` — must set a new password at the next sign-in (keksdose).
|
|
81
|
+
* - `deletion` — 0.30.0: the user asked for the account to be deleted
|
|
82
|
+
* (docs/user-admin-harmonization.md §2.1, §6.4). It is deactivated at once and erased
|
|
83
|
+
* on a date (`after_days`: keksdose, Kurvenschmiede) or by an operator (kastlan). The
|
|
84
|
+
* chip says the date when there is one ({@link AccountStateChipProps.date}), and
|
|
85
|
+
* "Deletion requested" when there is none. It stands IN PLACE of `inactive`: an
|
|
86
|
+
* account marked for deletion is always deactivated, and two chips would say it twice.
|
|
81
87
|
*
|
|
82
88
|
* An account can be several at once (inactive AND unverified): render one chip per
|
|
83
89
|
* state, as keksdose's state column does.
|
|
84
90
|
*/
|
|
85
|
-
type AccountState = "active" | "inactive" | "invited" | "registered" | "unverified" | "passwordChange";
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
*
|
|
91
|
+
type AccountState = "active" | "inactive" | "invited" | "registered" | "unverified" | "passwordChange" | "deletion";
|
|
92
|
+
/**
|
|
93
|
+
* The `accountState` namespace. One word per state, plus the two forms of `deletion`.
|
|
94
|
+
*
|
|
95
|
+
* The 0.30 keys are OPTIONAL, like every key added to a namespace an app annotates
|
|
96
|
+
* (`const L: AccountStateLabels = {…}`): a new required key would be a compile error in
|
|
97
|
+
* each app on its next update. Left out, they fall back to the provider's, then English.
|
|
98
|
+
*/
|
|
99
|
+
interface AccountStateLabels extends Record<Exclude<AccountState, "deletion">, string> {
|
|
100
|
+
/** 0.30.0: an account marked for deletion with no date — kastlan's `operator` mode,
|
|
101
|
+
* where an operator erases it (§6.4). "Deletion requested". */
|
|
102
|
+
deletion?: string;
|
|
103
|
+
/** 0.30.0: an account that will be erased on `date`, already formatted in the
|
|
104
|
+
* reader's locale — the `after_days` mode. "Deletion on 6 Nov 2026". */
|
|
105
|
+
deletionOn?: (date: string) => string;
|
|
106
|
+
}
|
|
107
|
+
declare const DEFAULT_ACCOUNT_STATE_LABELS: {
|
|
108
|
+
active: string;
|
|
109
|
+
inactive: string;
|
|
110
|
+
invited: string;
|
|
111
|
+
registered: string;
|
|
112
|
+
unverified: string;
|
|
113
|
+
passwordChange: string;
|
|
114
|
+
deletion: string;
|
|
115
|
+
deletionOn: (date: string) => string;
|
|
116
|
+
};
|
|
117
|
+
/** The default tone of each state: green for the normal case, red for switched off
|
|
118
|
+
* (and for going, `deletion`), amber for something the user still has to do, blue for
|
|
119
|
+
* an open invitation. */
|
|
90
120
|
declare const ACCOUNT_STATE_TONES: Readonly<Record<AccountState, ChipTone>>;
|
|
91
121
|
interface AccountStateChipProps extends AccountChipLook {
|
|
92
122
|
state: AccountState;
|
|
123
|
+
/**
|
|
124
|
+
* 0.30.0, `state="deletion"` only: the day the account will be erased — the row's
|
|
125
|
+
* `deletion_scheduled_at` (§3.2, §6.4). Formatted as a date in the reader's locale
|
|
126
|
+
* ("Deletion on 6 Nov 2026"), through the provider's `formatDate` when the app set
|
|
127
|
+
* one, as {@link DateMark} does. Missing or `null` — an operator erases it, so there
|
|
128
|
+
* is no date — the chip says "Deletion requested". Ignored for every other state.
|
|
129
|
+
*/
|
|
130
|
+
date?: DateInput;
|
|
131
|
+
/** Over the provider's locale, for the `deletion` date. */
|
|
132
|
+
locale?: string;
|
|
93
133
|
/** Over {@link ACCOUNT_STATE_TONES} — Kurvenschmiede draws `inactive` neutral. */
|
|
94
134
|
tone?: ChipTone;
|
|
95
135
|
/** Over the label, for an app whose word for the state is its own ("Deactivated"). */
|
|
@@ -101,7 +141,7 @@ interface AccountStateChipProps extends AccountChipLook {
|
|
|
101
141
|
* An account's state as a chip, in the kit's words and tones. Carries `data-state`
|
|
102
142
|
* with the key.
|
|
103
143
|
*/
|
|
104
|
-
declare function AccountStateChip({ state, tone, children, labels: labelsProp, size, variant, shape, caps, className, ...rest }: AccountStateChipProps): react.JSX.Element;
|
|
144
|
+
declare function AccountStateChip({ state, date, locale: localeProp, tone, children, labels: labelsProp, size, variant, shape, caps, className, ...rest }: AccountStateChipProps): react.JSX.Element;
|
|
105
145
|
interface DateMarkProps {
|
|
106
146
|
value: DateInput;
|
|
107
147
|
/**
|