@eifi1/ui-kit 0.30.0 → 0.31.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 +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/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/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/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/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-DCFS5Vof.d.ts} +52 -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 +84 -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 +81 -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 +82 -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 +82 -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 +81 -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 +80 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +5 -1
- package/dist/i18n/review.js +14 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +25 -3
- package/dist/index.js +95 -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 +138 -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 +218 -0
- package/dist/landing/routing.js +81 -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 +41 -0
- package/dist/settings/settings-labels.js +38 -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/invitations-panel.tsx +11 -4
- package/src/auth/auth-errors.ts +36 -5
- package/src/auth/sign-in-form.tsx +34 -3
- package/src/components/account-settings-labels.ts +13 -0
- package/src/components/account-settings.tsx +33 -12
- 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 +86 -0
- package/src/i18n/kit-labels.tsx +9 -0
- package/src/i18n/locales/es.ts +83 -0
- package/src/i18n/locales/fr.ts +84 -0
- package/src/i18n/locales/hu.ts +84 -0
- package/src/i18n/locales/it.ts +83 -0
- package/src/i18n/locales/zh.ts +81 -0
- package/src/i18n/review.ts +13 -0
- package/src/index.ts +92 -1
- package/src/landing/access.ts +97 -0
- package/src/landing/landing-actions.tsx +92 -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 +209 -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 +75 -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 +45 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { bt as AdminActionConfirm, bu as AdminActionConfirmProps, bv as AdminActionConfirmValues, bw as AdminActionLabels, bx as AdminActionTarget, by as AdminConfirmLevel, cf as DEFAULT_ADMIN_ACTION_LABELS } from '../delete-account-setting-
|
|
2
|
+
export { bt as AdminActionConfirm, bu as AdminActionConfirmProps, bv as AdminActionConfirmValues, bw as AdminActionLabels, bx as AdminActionTarget, by as AdminConfirmLevel, cf as DEFAULT_ADMIN_ACTION_LABELS } from '../delete-account-setting-DCFS5Vof.js';
|
|
3
3
|
import './admin-parts.js';
|
|
4
4
|
import '../components/tooltip.js';
|
|
5
5
|
import '../hooks/use-anchored-rect.js';
|
|
@@ -55,6 +55,8 @@ import '../components/image-grid.js';
|
|
|
55
55
|
import '../components/lightbox.js';
|
|
56
56
|
import '../components/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';
|
|
@@ -75,6 +77,8 @@ import '../lib/format.js';
|
|
|
75
77
|
import '../account/data-export-setting.js';
|
|
76
78
|
import '../components/account-chips.js';
|
|
77
79
|
import './admin-action-log.js';
|
|
80
|
+
import '../settings/settings-labels.js';
|
|
81
|
+
import '../demo/demo-labels.js';
|
|
78
82
|
import '../components/reauth-dialog.js';
|
|
79
83
|
import '../components/server-wake.js';
|
|
80
84
|
import '../lib/server-wake.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'react';
|
|
2
2
|
import '../lib/format.js';
|
|
3
|
-
export { cv as DEFAULT_INVITATIONS_LABELS, dE as InvitationDraft, dF as InvitationRow, dG as InvitationScope, dH as InvitationSentAnswer, dI as InvitationStatus, dJ as InvitationsLabels, dK as InvitationsPanel, dL as InvitationsPanelProps } from '../delete-account-setting-
|
|
3
|
+
export { cv as DEFAULT_INVITATIONS_LABELS, dE as InvitationDraft, dF as InvitationRow, dG as InvitationScope, dH as InvitationSentAnswer, dI as InvitationStatus, dJ as InvitationsLabels, dK as InvitationsPanel, dL as InvitationsPanelProps } from '../delete-account-setting-DCFS5Vof.js';
|
|
4
4
|
import '../components/account-chips.js';
|
|
5
5
|
import './admin-parts.js';
|
|
6
6
|
import '../components/tooltip.js';
|
|
@@ -57,6 +57,8 @@ import '../components/image-grid.js';
|
|
|
57
57
|
import '../components/lightbox.js';
|
|
58
58
|
import '../components/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';
|
|
@@ -75,6 +77,8 @@ import '../account/email-change-setting.js';
|
|
|
75
77
|
import '../account/sessions-setting.js';
|
|
76
78
|
import '../account/data-export-setting.js';
|
|
77
79
|
import './admin-action-log.js';
|
|
80
|
+
import '../settings/settings-labels.js';
|
|
81
|
+
import '../demo/demo-labels.js';
|
|
78
82
|
import '../components/reauth-dialog.js';
|
|
79
83
|
import '../components/server-wake.js';
|
|
80
84
|
import '../lib/server-wake.js';
|
|
@@ -64,6 +64,7 @@ function InvitationsPanel({
|
|
|
64
64
|
loading = false,
|
|
65
65
|
describeError,
|
|
66
66
|
intro,
|
|
67
|
+
listTitle,
|
|
67
68
|
className,
|
|
68
69
|
labels: labelsProp
|
|
69
70
|
}) {
|
|
@@ -216,13 +217,13 @@ function InvitationsPanel({
|
|
|
216
217
|
/* @__PURE__ */ jsx(CopyButton, { size: "xs", text: looseLink.link, label: labels.copyLink })
|
|
217
218
|
] }) }),
|
|
218
219
|
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
219
|
-
/* @__PURE__ */ jsx(SectionLabel, { as: "h4", children: labels.listTitle }),
|
|
220
|
+
listTitle !== null && /* @__PURE__ */ jsx(SectionLabel, { as: "h4", children: listTitle ?? labels.listTitle }),
|
|
220
221
|
loading && invitations.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-3", children: /* @__PURE__ */ jsx(Spinner, { label: labels.loading }) }) : invitations.length === 0 ? /* @__PURE__ */ jsx(Caption, { children: labels.empty }) : /* @__PURE__ */ jsx("ul", { "aria-label": labels.listTitle, className: "divide-y divide-[var(--border)]", children: invitations.map((invitation) => {
|
|
221
222
|
const key = String(invitation.id);
|
|
222
223
|
const link = invitation.link ?? links[key];
|
|
223
224
|
const open = invitation.status === "open";
|
|
224
225
|
const resendable = onResend && (open || invitation.status === "expired");
|
|
225
|
-
const revocable = onRevoke && open;
|
|
226
|
+
const revocable = onRevoke && (open || invitation.status === "expired");
|
|
226
227
|
const scopeText = scopeLabel(invitation.scope);
|
|
227
228
|
const by = typeof invitation.invited_by === "string" ? invitation.invited_by : nameOf(invitation.invited_by);
|
|
228
229
|
const facts = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/invitations-panel.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { FormEvent, ReactNode } from \"react\";\nimport { RefreshCw, Trash2, UserPlus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport type { DateInput } from \"../lib/format\";\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { KIT_LANGUAGES, resolveLanguage } from \"../i18n/languages\";\nimport type { KitLanguageCode } from \"../i18n/languages\";\nimport { RoleChip } from \"../components/account-chips\";\nimport type { RoleVocabulary } from \"../components/account-chips\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Chip } from \"../components/chip\";\nimport type { ChipTone } from \"../components/chip\";\nimport { CopyButton } from \"../components/copy-button\";\nimport { LanguageSelect } from \"../components/language-select\";\nimport { SectionLabel, Caption } from \"../components/text\";\nimport { Button, IconButton, Input, Select, Spinner } from \"../components/ui\";\nimport { useWriteLock } from \"../components/write-lock\";\nimport { hasMessage, settle, useDayText, usePersonLabel } from \"./admin-parts\";\nimport type { AdminPerson, MaybePromise } from \"./admin-parts\";\nimport { RoleSelect } from \"./role-select\";\n\n/**\n * Who is invited, and the form that invites (docs/user-admin-harmonization.md §5; auth\n * §4.4: a hashed one-time token, 14 days, an address with a role and a scope).\n *\n * Kurvenschmiede's `invitations-panel.tsx` with its parts made props: a form (the address,\n * a role from the app's vocabulary, an optional scope — a team, a company — the language\n * the invitation is written in, a note), then one row per invitation with its status, when\n * it was sent and until when it works, and resend / copy link / revoke.\n *\n * - **It assumes nothing about who invites.** Admins do, team managers into their team,\n * kastlan's company admins into their company — and in keksdose ANY budget owner, from\n * the budget's sharing (Marcel, 2026-10-07). So no word here says \"admin\"; the roles,\n * the scopes and the callbacks are the app's, and so is the frame around it.\n * - **The address is someone else's.** No `+app` tag is offered (auth §4.5): a tag is\n * the owner's own choice, made when they sign up.\n * - **The link is shown once.** The token is stored hashed, so the server can show a link\n * only in the answer that minted it — on creation and on resend, and only while mail\n * goes to the console (dev, a deploy without mail). The panel keeps such a link for as\n * long as it is mounted and offers to copy it on its row; reloading the page loses it,\n * and \"resend\" mints a new one. With the console backend the panel says so up front.\n * - **Revoked is optional.** An app that deletes the row instead (kastlan) never sends\n * `revoked`; the status chip simply never says it (§5).\n *\n * It never sends a request: `onInvite`, `onResend` and `onRevoke` do.\n */\n\nexport type InvitationStatus = \"open\" | \"accepted\" | \"expired\" | \"revoked\";\n\n/** One row of `GET /admin/invitations` (§5), in the wire's own field names. */\nexport interface InvitationRow<R extends string = string> {\n id: string | number;\n email: string;\n role?: R | null;\n /** The scope's value — a team's or a company's id, matched against `scopes`. */\n scope?: string | number | null;\n note?: string | null;\n /** The language it was written in. */\n locale?: string | null;\n /** Who sent it: a name, or the person. */\n invited_by?: string | AdminPerson | null;\n created_at: DateInput;\n expires_at?: DateInput;\n status: InvitationStatus;\n /** The one-time link, while mail goes to the console — in the answer that minted it. */\n link?: string | null;\n}\n\n/** What the form sends — `POST /admin/invitations {email, role, scope?, note?, locale}`. */\nexport interface InvitationDraft<R extends string = string> {\n email: string;\n /** Absent when the app offers no role choice (`roles` left out). */\n role?: R;\n scope?: string;\n note?: string;\n locale: KitLanguageCode;\n}\n\n/** What `onInvite` / `onResend` may answer, so the panel can keep a shown-once link. */\nexport interface InvitationSentAnswer {\n /** The invitation the answer is about — `onInvite` needs it for the link to find its\n * row; `onResend` knows it already. */\n id?: string | number;\n /** The one-time link, while mail goes to the console. */\n link?: string | null;\n /** `false`: the invitation exists but the mail failed — say so, resend it. */\n sent?: boolean;\n}\n\n/** A scope an invitation can carry. */\nexport interface InvitationScope {\n value: string;\n label: string;\n}\n\n/** The `invitations` namespace. */\nexport interface InvitationsLabels {\n /** The form's address field. */\n email: string;\n /** Under it while what was typed is not an address. */\n invalidEmail: string;\n role: string;\n /** The scope select's label — the app's word (\"Team\", \"Company\") goes over it. */\n scope: string;\n /** The scope select's empty choice. */\n scopeNone: string;\n /** The language select's label. */\n language: string;\n note: string;\n /** The form's button. */\n invite: string;\n /** Heading over the rows. */\n listTitle: string;\n empty: string;\n loading: string;\n /** The status chip, per status. */\n status: Record<InvitationStatus, string>;\n /** \"Sent 6 Oct 2026\". */\n sent: (date: string) => string;\n /** \"Expires 20 Oct 2026\" — on an open invitation. */\n expires: (date: string) => string;\n /** \"by Ada Example\". */\n invitedBy: (name: string) => string;\n /** The resend button — \"Send ben@example.com a new link\". */\n resend: (email: string) => string;\n /** The copy button. */\n copyLink: string;\n /** The revoke button — \"Revoke the invitation for ben@example.com\". */\n revoke: (email: string) => string;\n /** Over everything while mail goes to the console. */\n consoleHint: string;\n /** Beside a link the answer carried with no row to put it on. */\n linkReady: (email: string) => string;\n /** The answer said the mail was not sent. */\n notSent: (email: string) => string;\n /** A rejected callback, unless `describeError` says better. */\n failed: string;\n}\n\nexport const DEFAULT_INVITATIONS_LABELS: InvitationsLabels = {\n email: \"Email address\",\n invalidEmail: \"Enter a complete email address.\",\n role: \"Role\",\n scope: \"Scope\",\n scopeNone: \"None\",\n language: \"Language of the invitation\",\n note: \"Note\",\n invite: \"Invite\",\n listTitle: \"Invitations\",\n empty: \"Nobody has been invited yet.\",\n loading: \"Loading…\",\n status: { open: \"Open\", accepted: \"Accepted\", expired: \"Expired\", revoked: \"Revoked\" },\n sent: (date) => `Sent ${date}`,\n expires: (date) => `Expires ${date}`,\n invitedBy: (name) => `by ${name}`,\n resend: (email) => `Send ${email} a new link`,\n copyLink: \"Copy invitation link\",\n revoke: (email) => `Revoke the invitation for ${email}`,\n consoleHint:\n \"Mail isn’t sent on this server — it is written to the server log. Copy each invitation link from here and pass it on yourself: it is shown only once.\",\n linkReady: (email) => `The invitation link for ${email}, shown only this once:`,\n notSent: (email) => `${email} is invited, but the mail couldn’t be sent. Resend it.`,\n failed: \"That didn’t work. Please try again.\",\n};\n\n/** The tone of each status. */\nconst STATUS_TONES: Readonly<Record<InvitationStatus, ChipTone>> = {\n open: \"info\",\n accepted: \"success\",\n expired: \"warning\",\n revoked: \"neutral\",\n};\n\nexport interface InvitationsPanelProps<R extends string = string> {\n invitations: readonly InvitationRow<R>[];\n /** The app's roles. Left out: no role choice, and no role chip on a row. */\n roles?: RoleVocabulary<R>;\n /** The roles an invitation may carry — Kurvenschmiede's member or customer. Default:\n * the whole vocabulary. One role: no choice is drawn, and it is sent. */\n invitableRoles?: readonly R[];\n /** The role the form starts with. Default: the first invitable one. */\n defaultRole?: R;\n /** The scopes an invitation may carry — teams, companies. Left out: no scope field. */\n scopes?: readonly InvitationScope[];\n /** A scope must be chosen (no \"None\"). */\n scopeRequired?: boolean;\n /** The languages offered. Default: all seven of the kit's. */\n languages?: readonly KitLanguageCode[];\n /** The language the form starts with. Default: the page's, resolved to `languages`. */\n defaultLocale?: string;\n /** The server's `mail_backend`. `\"console\"` draws the hint. */\n mailBackend?: string | null;\n /** Creates one (resolve to clear the form; reject to keep it and say why). Left out:\n * no form — a list someone may look at but not add to. */\n onInvite?: (draft: InvitationDraft<R>) => MaybePromise<InvitationSentAnswer | void>;\n /** Mints a new link and mails it. Left out: no resend button. */\n onResend?: (invitation: InvitationRow<R>) => MaybePromise<InvitationSentAnswer | void>;\n /** Revokes an open invitation (level `none`, §4.2: re-inviting undoes it). Left out:\n * no revoke button. */\n onRevoke?: (invitation: InvitationRow<R>) => MaybePromise;\n /** The list is being fetched. */\n loading?: boolean;\n /** The app's words for a rejected callback. */\n describeError?: (error: unknown) => ReactNode | undefined;\n /** Over the form: who can be invited and what happens, in the app's words. */\n intro?: ReactNode;\n className?: string;\n labels?: Partial<InvitationsLabels>;\n}\n\n// Shape only — whether the address may be invited is the server's question.\nconst EMAIL_SHAPE = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nconst ALL_CODES: readonly KitLanguageCode[] = KIT_LANGUAGES.map((language) => language.code);\n\n/** A failed run, told apart from an answer of `undefined`. */\nconst FAILED = Symbol(\"failed\");\n\nexport function InvitationsPanel<R extends string = string>({\n invitations,\n roles,\n invitableRoles,\n defaultRole,\n scopes,\n scopeRequired = false,\n languages = ALL_CODES,\n defaultLocale,\n mailBackend,\n onInvite,\n onResend,\n onRevoke,\n loading = false,\n describeError,\n intro,\n className,\n labels: labelsProp,\n}: InvitationsPanelProps<R>) {\n const labels = useKitLabels(\"invitations\", DEFAULT_INVITATIONS_LABELS, labelsProp);\n const kitLocale = useKitLocale();\n const dayText = useDayText();\n const nameOf = usePersonLabel();\n const lock = useWriteLock();\n const offered: readonly R[] = invitableRoles ?? (roles ? (Object.keys(roles) as R[]) : []);\n const [email, setEmail] = useState(\"\");\n const [invalid, setInvalid] = useState(false);\n const [role, setRole] = useState<R | undefined>(defaultRole ?? offered[0]);\n const [scope, setScope] = useState(\"\");\n const [locale, setLocale] = useState<KitLanguageCode>(() =>\n resolveLanguage([defaultLocale, kitLocale], languages),\n );\n const [note, setNote] = useState(\"\");\n // One request at a time, for the whole panel; the key says which control spins.\n const [busy, setBusy] = useState<string | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const [notice, setNotice] = useState<ReactNode>(null);\n // Links the answers carried, by invitation — shown once, kept while mounted.\n const [links, setLinks] = useState<Record<string, string>>({});\n // A link whose answer named no invitation: shown above the list instead.\n const [looseLink, setLooseLink] = useState<{ email: string; link: string } | null>(null);\n\n const run = async <T,>(key: string, call: () => MaybePromise<T>): Promise<T | void | typeof FAILED> => {\n setBusy(key);\n setFailure(null);\n setNotice(null);\n try {\n return await settle(call);\n } catch (error) {\n const own = describeError?.(error);\n setFailure(hasMessage(own) ? own : labels.failed);\n return FAILED;\n } finally {\n setBusy(null);\n }\n };\n\n /** Keep what an answer carried: its link, and whether the mail went. */\n const took = (answer: InvitationSentAnswer | void, address: string, id?: string | number) => {\n if (!answer) return;\n const key = answer.id ?? id;\n if (answer.link) {\n if (key !== undefined) setLinks((known) => ({ ...known, [String(key)]: answer.link as string }));\n else setLooseLink({ email: address, link: answer.link });\n }\n if (answer.sent === false) setNotice(labels.notSent(address));\n };\n\n const address = email.trim();\n const choosesRole = roles !== undefined && offered.length > 1;\n const canInvite = onInvite !== undefined;\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n // Enter in a field is a commit too — the button's lock does not see it.\n if (!onInvite || busy || lock.locked || address === \"\") return;\n if (!EMAIL_SHAPE.test(address)) {\n setInvalid(true);\n return;\n }\n if (scopes && scopeRequired && scope === \"\") return;\n const draft: InvitationDraft<R> = {\n email: address,\n locale,\n ...(role !== undefined && roles !== undefined ? { role } : {}),\n ...(scope !== \"\" ? { scope } : {}),\n ...(note.trim() !== \"\" ? { note: note.trim() } : {}),\n };\n const answer = await run(\"invite\", () => onInvite(draft));\n if (answer === FAILED) return;\n took(answer, address);\n setEmail(\"\");\n setNote(\"\");\n };\n\n const scopeLabel = (value: InvitationRow[\"scope\"]) =>\n value === null || value === undefined || value === \"\"\n ? null\n : (scopes?.find((s) => s.value === String(value))?.label ?? String(value));\n\n return (\n <div className={cn(\"space-y-3\", className)}>\n {intro && <div className=\"text-sm text-[var(--text-secondary)]\">{intro}</div>}\n {mailBackend === \"console\" && (\n <AlertBanner tone=\"info\" size=\"sm\">\n {labels.consoleHint}\n </AlertBanner>\n )}\n\n {canInvite && (\n <form noValidate onSubmit={submit} className=\"@container space-y-2\">\n <div className=\"grid grid-cols-1 gap-2 @md:grid-cols-2\">\n <Input\n label={labels.email}\n type=\"email\"\n inputMode=\"email\"\n autoComplete=\"off\"\n autoCapitalize=\"none\"\n spellCheck={false}\n required\n value={email}\n error={invalid ? labels.invalidEmail : undefined}\n data-private\n onChange={(event) => {\n setInvalid(false);\n setEmail(event.target.value);\n }}\n />\n {choosesRole && (\n <RoleSelect<R>\n label={labels.role}\n value={role}\n roles={roles}\n offered={offered}\n onChange={setRole}\n />\n )}\n {scopes && scopes.length > 0 && (\n <Select\n label={labels.scope}\n value={scope}\n required={scopeRequired}\n onChange={(event) => setScope(event.target.value)}\n >\n <option value=\"\" disabled={scopeRequired}>\n {labels.scopeNone}\n </option>\n {scopes.map((s) => (\n <option key={s.value} value={s.value}>\n {s.label}\n </option>\n ))}\n </Select>\n )}\n {languages.length > 1 && (\n <LanguageSelect label={labels.language} codes={languages} value={locale} onChange={setLocale} />\n )}\n <Input\n label={labels.note}\n value={note}\n maxLength={255}\n onChange={(event) => setNote(event.target.value)}\n className=\"@md:col-span-2\"\n />\n </div>\n <div className=\"flex justify-end\">\n <Button\n type=\"submit\"\n variant=\"brand\"\n commit\n pending={busy === \"invite\"}\n disabled={busy !== null || address === \"\" || (scopeRequired && scopes !== undefined && scope === \"\")}\n >\n <UserPlus className=\"size-4\" aria-hidden />\n {labels.invite}\n </Button>\n </div>\n </form>\n )}\n\n {failure && (\n <AlertBanner tone=\"danger\" size=\"sm\">\n {failure}\n </AlertBanner>\n )}\n {notice && (\n <AlertBanner tone=\"warning\" size=\"sm\" onDismiss={() => setNotice(null)}>\n {notice}\n </AlertBanner>\n )}\n {looseLink && (\n <AlertBanner tone=\"info\" size=\"sm\" onDismiss={() => setLooseLink(null)}>\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n <span data-private>{labels.linkReady(looseLink.email)}</span>\n <code className=\"min-w-0 break-all text-xs\">{looseLink.link}</code>\n <CopyButton size=\"xs\" text={looseLink.link} label={labels.copyLink} />\n </div>\n </AlertBanner>\n )}\n\n <div className=\"space-y-2\">\n <SectionLabel as=\"h4\">{labels.listTitle}</SectionLabel>\n {loading && invitations.length === 0 ? (\n <div className=\"flex justify-center py-3\">\n <Spinner label={labels.loading} />\n </div>\n ) : invitations.length === 0 ? (\n <Caption>{labels.empty}</Caption>\n ) : (\n <ul aria-label={labels.listTitle} className=\"divide-y divide-[var(--border)]\">\n {invitations.map((invitation) => {\n const key = String(invitation.id);\n const link = invitation.link ?? links[key];\n const open = invitation.status === \"open\";\n const resendable = onResend && (open || invitation.status === \"expired\");\n const revocable = onRevoke && open;\n const scopeText = scopeLabel(invitation.scope);\n const by =\n typeof invitation.invited_by === \"string\" ? invitation.invited_by : nameOf(invitation.invited_by);\n const facts = [\n dayText(invitation.created_at) && labels.sent(dayText(invitation.created_at)),\n open && dayText(invitation.expires_at ?? null) && labels.expires(dayText(invitation.expires_at ?? null)),\n by && labels.invitedBy(by),\n ].filter(Boolean);\n return (\n <li key={key} data-status={invitation.status} className=\"py-2 first:pt-0 last:pb-0\">\n <div className=\"flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5\">\n <div className=\"min-w-0 flex-1 basis-48 space-y-1\">\n <div data-private className=\"truncate text-sm font-medium text-[var(--text-primary)]\">\n {invitation.email}\n </div>\n <div className=\"flex flex-wrap items-center gap-1\">\n <Chip size=\"xs\" shape=\"square\" caps tone={STATUS_TONES[invitation.status]}>\n {labels.status[invitation.status]}\n </Chip>\n {roles && invitation.role && <RoleChip<R> value={invitation.role} roles={roles} size=\"xs\" />}\n {scopeText && (\n <Chip size=\"xs\" shape=\"square\">\n {scopeText}\n </Chip>\n )}\n </div>\n {(facts.length > 0 || invitation.note) && (\n <div className=\"text-xs text-[var(--text-muted)]\">\n {facts.join(\" · \")}\n {invitation.note && (\n <>\n {facts.length > 0 && \" · \"}\n <span data-private>{invitation.note}</span>\n </>\n )}\n </div>\n )}\n </div>\n {(link || resendable || revocable) && (\n <div className=\"ms-auto flex shrink-0 items-center gap-1\">\n {link && open && <CopyButton size=\"xs\" tone=\"muted\" text={link} label={labels.copyLink} />}\n {resendable && (\n <IconButton\n size=\"xs\"\n commit\n label={labels.resend(invitation.email)}\n pending={busy === `resend:${key}`}\n disabled={busy !== null}\n onClick={async () => {\n const answer = await run(`resend:${key}`, () => onResend(invitation));\n if (answer !== FAILED) took(answer, invitation.email, invitation.id);\n }}\n >\n <RefreshCw />\n </IconButton>\n )}\n {revocable && (\n <IconButton\n size=\"xs\"\n tone=\"danger\"\n commit\n label={labels.revoke(invitation.email)}\n pending={busy === `revoke:${key}`}\n disabled={busy !== null}\n onClick={() => void run(`revoke:${key}`, () => onRevoke(invitation))}\n >\n <Trash2 />\n </IconButton>\n )}\n </div>\n )}\n </div>\n </li>\n );\n })}\n </ul>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";AAiUgB,SAgJY,UAhJZ,KAoCF,YApCE;AAjUhB,SAAS,gBAAgB;AAEzB,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,UAAU;AAEnB,SAAS,cAAc,oBAAoB;AAC3C,SAAS,eAAe,uBAAuB;AAE/C,SAAS,gBAAgB;AAEzB,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AAErB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,cAAc,eAAe;AACtC,SAAS,QAAQ,YAAY,OAAO,QAAQ,eAAe;AAC3D,SAAS,oBAAoB;AAC7B,SAAS,YAAY,QAAQ,YAAY,sBAAsB;AAE/D,SAAS,kBAAkB;AAwHpB,MAAM,6BAAgD;AAAA,EAC3D,OAAO;AAAA,EACP,cAAc;AAAA,EACd,MAAM;AAAA,EACN,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ,EAAE,MAAM,QAAQ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UAAU,GAAG,IAAI,MAAM,SAAS,UAAU,CAAC;AACpE,sBAAI,WAAW,OAAQ,MAAK,QAAQ,WAAW,OAAO,WAAW,EAAE;AAAA,gBACrE;AAAA,gBAEA,8BAAC,aAAU;AAAA;AAAA,YACb;AAAA,YAED,aACC;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,MAAK;AAAA,gBACL,QAAM;AAAA,gBACN,OAAO,OAAO,OAAO,WAAW,KAAK;AAAA,gBACrC,SAAS,SAAS,UAAU,GAAG;AAAA,gBAC/B,UAAU,SAAS;AAAA,gBACnB,SAAS,MAAM,KAAK,IAAI,UAAU,GAAG,IAAI,MAAM,SAAS,UAAU,CAAC;AAAA,gBAEnE,8BAAC,UAAO;AAAA;AAAA,YACV;AAAA,aAEJ;AAAA,WAEJ,KA9DO,GA+DT;AAAA,MAEJ,CAAC,GACH;AAAA,OAEJ;AAAA,KACF;AAEJ;","names":["address"]}
|
|
1
|
+
{"version":3,"sources":["../../src/admin/invitations-panel.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { FormEvent, ReactNode } from \"react\";\nimport { RefreshCw, Trash2, UserPlus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport type { DateInput } from \"../lib/format\";\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { KIT_LANGUAGES, resolveLanguage } from \"../i18n/languages\";\nimport type { KitLanguageCode } from \"../i18n/languages\";\nimport { RoleChip } from \"../components/account-chips\";\nimport type { RoleVocabulary } from \"../components/account-chips\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Chip } from \"../components/chip\";\nimport type { ChipTone } from \"../components/chip\";\nimport { CopyButton } from \"../components/copy-button\";\nimport { LanguageSelect } from \"../components/language-select\";\nimport { SectionLabel, Caption } from \"../components/text\";\nimport { Button, IconButton, Input, Select, Spinner } from \"../components/ui\";\nimport { useWriteLock } from \"../components/write-lock\";\nimport { hasMessage, settle, useDayText, usePersonLabel } from \"./admin-parts\";\nimport type { AdminPerson, MaybePromise } from \"./admin-parts\";\nimport { RoleSelect } from \"./role-select\";\n\n/**\n * Who is invited, and the form that invites (docs/user-admin-harmonization.md §5; auth\n * §4.4: a hashed one-time token, 14 days, an address with a role and a scope).\n *\n * Kurvenschmiede's `invitations-panel.tsx` with its parts made props: a form (the address,\n * a role from the app's vocabulary, an optional scope — a team, a company — the language\n * the invitation is written in, a note), then one row per invitation with its status, when\n * it was sent and until when it works, and resend / copy link / revoke.\n *\n * - **It assumes nothing about who invites.** Admins do, team managers into their team,\n * kastlan's company admins into their company — and in keksdose ANY budget owner, from\n * the budget's sharing (Marcel, 2026-10-07). So no word here says \"admin\"; the roles,\n * the scopes and the callbacks are the app's, and so is the frame around it.\n * - **The address is someone else's.** No `+app` tag is offered (auth §4.5): a tag is\n * the owner's own choice, made when they sign up.\n * - **The link is shown once.** The token is stored hashed, so the server can show a link\n * only in the answer that minted it — on creation and on resend, and only while mail\n * goes to the console (dev, a deploy without mail). The panel keeps such a link for as\n * long as it is mounted and offers to copy it on its row; reloading the page loses it,\n * and \"resend\" mints a new one. With the console backend the panel says so up front.\n * - **Revoked is optional.** An app that deletes the row instead (kastlan) never sends\n * `revoked`; the status chip simply never says it (§5).\n *\n * It never sends a request: `onInvite`, `onResend` and `onRevoke` do.\n */\n\nexport type InvitationStatus = \"open\" | \"accepted\" | \"expired\" | \"revoked\";\n\n/** One row of `GET /admin/invitations` (§5), in the wire's own field names. */\nexport interface InvitationRow<R extends string = string> {\n id: string | number;\n email: string;\n role?: R | null;\n /** The scope's value — a team's or a company's id, matched against `scopes`. */\n scope?: string | number | null;\n note?: string | null;\n /** The language it was written in. */\n locale?: string | null;\n /** Who sent it: a name, or the person. */\n invited_by?: string | AdminPerson | null;\n created_at: DateInput;\n expires_at?: DateInput;\n status: InvitationStatus;\n /** The one-time link, while mail goes to the console — in the answer that minted it. */\n link?: string | null;\n}\n\n/** What the form sends — `POST /admin/invitations {email, role, scope?, note?, locale}`. */\nexport interface InvitationDraft<R extends string = string> {\n email: string;\n /** Absent when the app offers no role choice (`roles` left out). */\n role?: R;\n scope?: string;\n note?: string;\n locale: KitLanguageCode;\n}\n\n/** What `onInvite` / `onResend` may answer, so the panel can keep a shown-once link. */\nexport interface InvitationSentAnswer {\n /** The invitation the answer is about — `onInvite` needs it for the link to find its\n * row; `onResend` knows it already. */\n id?: string | number;\n /** The one-time link, while mail goes to the console. */\n link?: string | null;\n /** `false`: the invitation exists but the mail failed — say so, resend it. */\n sent?: boolean;\n}\n\n/** A scope an invitation can carry. */\nexport interface InvitationScope {\n value: string;\n label: string;\n}\n\n/** The `invitations` namespace. */\nexport interface InvitationsLabels {\n /** The form's address field. */\n email: string;\n /** Under it while what was typed is not an address. */\n invalidEmail: string;\n role: string;\n /** The scope select's label — the app's word (\"Team\", \"Company\") goes over it. */\n scope: string;\n /** The scope select's empty choice. */\n scopeNone: string;\n /** The language select's label. */\n language: string;\n note: string;\n /** The form's button. */\n invite: string;\n /** Heading over the rows. */\n listTitle: string;\n empty: string;\n loading: string;\n /** The status chip, per status. */\n status: Record<InvitationStatus, string>;\n /** \"Sent 6 Oct 2026\". */\n sent: (date: string) => string;\n /** \"Expires 20 Oct 2026\" — on an open invitation. */\n expires: (date: string) => string;\n /** \"by Ada Example\". */\n invitedBy: (name: string) => string;\n /** The resend button — \"Send ben@example.com a new link\". */\n resend: (email: string) => string;\n /** The copy button. */\n copyLink: string;\n /** The revoke button — \"Revoke the invitation for ben@example.com\". */\n revoke: (email: string) => string;\n /** Over everything while mail goes to the console. */\n consoleHint: string;\n /** Beside a link the answer carried with no row to put it on. */\n linkReady: (email: string) => string;\n /** The answer said the mail was not sent. */\n notSent: (email: string) => string;\n /** A rejected callback, unless `describeError` says better. */\n failed: string;\n}\n\nexport const DEFAULT_INVITATIONS_LABELS: InvitationsLabels = {\n email: \"Email address\",\n invalidEmail: \"Enter a complete email address.\",\n role: \"Role\",\n scope: \"Scope\",\n scopeNone: \"None\",\n language: \"Language of the invitation\",\n note: \"Note\",\n invite: \"Invite\",\n listTitle: \"Invitations\",\n empty: \"Nobody has been invited yet.\",\n loading: \"Loading…\",\n status: { open: \"Open\", accepted: \"Accepted\", expired: \"Expired\", revoked: \"Revoked\" },\n sent: (date) => `Sent ${date}`,\n expires: (date) => `Expires ${date}`,\n invitedBy: (name) => `by ${name}`,\n resend: (email) => `Send ${email} a new link`,\n copyLink: \"Copy invitation link\",\n revoke: (email) => `Revoke the invitation for ${email}`,\n consoleHint:\n \"Mail isn’t sent on this server — it is written to the server log. Copy each invitation link from here and pass it on yourself: it is shown only once.\",\n linkReady: (email) => `The invitation link for ${email}, shown only this once:`,\n notSent: (email) => `${email} is invited, but the mail couldn’t be sent. Resend it.`,\n failed: \"That didn’t work. Please try again.\",\n};\n\n/** The tone of each status. */\nconst STATUS_TONES: Readonly<Record<InvitationStatus, ChipTone>> = {\n open: \"info\",\n accepted: \"success\",\n expired: \"warning\",\n revoked: \"neutral\",\n};\n\nexport interface InvitationsPanelProps<R extends string = string> {\n invitations: readonly InvitationRow<R>[];\n /** The app's roles. Left out: no role choice, and no role chip on a row. */\n roles?: RoleVocabulary<R>;\n /** The roles an invitation may carry — Kurvenschmiede's member or customer. Default:\n * the whole vocabulary. One role: no choice is drawn, and it is sent. */\n invitableRoles?: readonly R[];\n /** The role the form starts with. Default: the first invitable one. */\n defaultRole?: R;\n /** The scopes an invitation may carry — teams, companies. Left out: no scope field. */\n scopes?: readonly InvitationScope[];\n /** A scope must be chosen (no \"None\"). */\n scopeRequired?: boolean;\n /** The languages offered. Default: all seven of the kit's. */\n languages?: readonly KitLanguageCode[];\n /** The language the form starts with. Default: the page's, resolved to `languages`. */\n defaultLocale?: string;\n /** The server's `mail_backend`. `\"console\"` draws the hint. */\n mailBackend?: string | null;\n /** Creates one (resolve to clear the form; reject to keep it and say why). Left out:\n * no form — a list someone may look at but not add to. */\n onInvite?: (draft: InvitationDraft<R>) => MaybePromise<InvitationSentAnswer | void>;\n /** Mints a new link and mails it. Left out: no resend button. */\n onResend?: (invitation: InvitationRow<R>) => MaybePromise<InvitationSentAnswer | void>;\n /** Revokes an open or an expired invitation (level `none`, §4.2: re-inviting undoes\n * it). An expired row can be resent, and since 0.31 also removed: in an app that\n * keeps the rows it would otherwise stay listed for good (Kurvenschmiede's 0.30\n * adoption). Left out: no revoke button. */\n onRevoke?: (invitation: InvitationRow<R>) => MaybePromise;\n /** The list is being fetched. */\n loading?: boolean;\n /** The app's words for a rejected callback. */\n describeError?: (error: unknown) => ReactNode | undefined;\n /** Over the form: who can be invited and what happens, in the app's words. */\n intro?: ReactNode;\n /** The list's visible heading. Default: the `listTitle` label. `null` leaves it out,\n * for a page whose card is already headed \"Invitations\" (Kurvenschmiede's 0.30\n * adoption); the list keeps the label as its accessible name either way. */\n listTitle?: ReactNode | null;\n className?: string;\n labels?: Partial<InvitationsLabels>;\n}\n\n// Shape only — whether the address may be invited is the server's question.\nconst EMAIL_SHAPE = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nconst ALL_CODES: readonly KitLanguageCode[] = KIT_LANGUAGES.map((language) => language.code);\n\n/** A failed run, told apart from an answer of `undefined`. */\nconst FAILED = Symbol(\"failed\");\n\nexport function InvitationsPanel<R extends string = string>({\n invitations,\n roles,\n invitableRoles,\n defaultRole,\n scopes,\n scopeRequired = false,\n languages = ALL_CODES,\n defaultLocale,\n mailBackend,\n onInvite,\n onResend,\n onRevoke,\n loading = false,\n describeError,\n intro,\n listTitle,\n className,\n labels: labelsProp,\n}: InvitationsPanelProps<R>) {\n const labels = useKitLabels(\"invitations\", DEFAULT_INVITATIONS_LABELS, labelsProp);\n const kitLocale = useKitLocale();\n const dayText = useDayText();\n const nameOf = usePersonLabel();\n const lock = useWriteLock();\n const offered: readonly R[] = invitableRoles ?? (roles ? (Object.keys(roles) as R[]) : []);\n const [email, setEmail] = useState(\"\");\n const [invalid, setInvalid] = useState(false);\n const [role, setRole] = useState<R | undefined>(defaultRole ?? offered[0]);\n const [scope, setScope] = useState(\"\");\n const [locale, setLocale] = useState<KitLanguageCode>(() =>\n resolveLanguage([defaultLocale, kitLocale], languages),\n );\n const [note, setNote] = useState(\"\");\n // One request at a time, for the whole panel; the key says which control spins.\n const [busy, setBusy] = useState<string | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const [notice, setNotice] = useState<ReactNode>(null);\n // Links the answers carried, by invitation — shown once, kept while mounted.\n const [links, setLinks] = useState<Record<string, string>>({});\n // A link whose answer named no invitation: shown above the list instead.\n const [looseLink, setLooseLink] = useState<{ email: string; link: string } | null>(null);\n\n const run = async <T,>(key: string, call: () => MaybePromise<T>): Promise<T | void | typeof FAILED> => {\n setBusy(key);\n setFailure(null);\n setNotice(null);\n try {\n return await settle(call);\n } catch (error) {\n const own = describeError?.(error);\n setFailure(hasMessage(own) ? own : labels.failed);\n return FAILED;\n } finally {\n setBusy(null);\n }\n };\n\n /** Keep what an answer carried: its link, and whether the mail went. */\n const took = (answer: InvitationSentAnswer | void, address: string, id?: string | number) => {\n if (!answer) return;\n const key = answer.id ?? id;\n if (answer.link) {\n if (key !== undefined) setLinks((known) => ({ ...known, [String(key)]: answer.link as string }));\n else setLooseLink({ email: address, link: answer.link });\n }\n if (answer.sent === false) setNotice(labels.notSent(address));\n };\n\n const address = email.trim();\n const choosesRole = roles !== undefined && offered.length > 1;\n const canInvite = onInvite !== undefined;\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n // Enter in a field is a commit too — the button's lock does not see it.\n if (!onInvite || busy || lock.locked || address === \"\") return;\n if (!EMAIL_SHAPE.test(address)) {\n setInvalid(true);\n return;\n }\n if (scopes && scopeRequired && scope === \"\") return;\n const draft: InvitationDraft<R> = {\n email: address,\n locale,\n ...(role !== undefined && roles !== undefined ? { role } : {}),\n ...(scope !== \"\" ? { scope } : {}),\n ...(note.trim() !== \"\" ? { note: note.trim() } : {}),\n };\n const answer = await run(\"invite\", () => onInvite(draft));\n if (answer === FAILED) return;\n took(answer, address);\n setEmail(\"\");\n setNote(\"\");\n };\n\n const scopeLabel = (value: InvitationRow[\"scope\"]) =>\n value === null || value === undefined || value === \"\"\n ? null\n : (scopes?.find((s) => s.value === String(value))?.label ?? String(value));\n\n return (\n <div className={cn(\"space-y-3\", className)}>\n {intro && <div className=\"text-sm text-[var(--text-secondary)]\">{intro}</div>}\n {mailBackend === \"console\" && (\n <AlertBanner tone=\"info\" size=\"sm\">\n {labels.consoleHint}\n </AlertBanner>\n )}\n\n {canInvite && (\n <form noValidate onSubmit={submit} className=\"@container space-y-2\">\n <div className=\"grid grid-cols-1 gap-2 @md:grid-cols-2\">\n <Input\n label={labels.email}\n type=\"email\"\n inputMode=\"email\"\n autoComplete=\"off\"\n autoCapitalize=\"none\"\n spellCheck={false}\n required\n value={email}\n error={invalid ? labels.invalidEmail : undefined}\n data-private\n onChange={(event) => {\n setInvalid(false);\n setEmail(event.target.value);\n }}\n />\n {choosesRole && (\n <RoleSelect<R>\n label={labels.role}\n value={role}\n roles={roles}\n offered={offered}\n onChange={setRole}\n />\n )}\n {scopes && scopes.length > 0 && (\n <Select\n label={labels.scope}\n value={scope}\n required={scopeRequired}\n onChange={(event) => setScope(event.target.value)}\n >\n <option value=\"\" disabled={scopeRequired}>\n {labels.scopeNone}\n </option>\n {scopes.map((s) => (\n <option key={s.value} value={s.value}>\n {s.label}\n </option>\n ))}\n </Select>\n )}\n {languages.length > 1 && (\n <LanguageSelect label={labels.language} codes={languages} value={locale} onChange={setLocale} />\n )}\n <Input\n label={labels.note}\n value={note}\n maxLength={255}\n onChange={(event) => setNote(event.target.value)}\n className=\"@md:col-span-2\"\n />\n </div>\n <div className=\"flex justify-end\">\n <Button\n type=\"submit\"\n variant=\"brand\"\n commit\n pending={busy === \"invite\"}\n disabled={busy !== null || address === \"\" || (scopeRequired && scopes !== undefined && scope === \"\")}\n >\n <UserPlus className=\"size-4\" aria-hidden />\n {labels.invite}\n </Button>\n </div>\n </form>\n )}\n\n {failure && (\n <AlertBanner tone=\"danger\" size=\"sm\">\n {failure}\n </AlertBanner>\n )}\n {notice && (\n <AlertBanner tone=\"warning\" size=\"sm\" onDismiss={() => setNotice(null)}>\n {notice}\n </AlertBanner>\n )}\n {looseLink && (\n <AlertBanner tone=\"info\" size=\"sm\" onDismiss={() => setLooseLink(null)}>\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n <span data-private>{labels.linkReady(looseLink.email)}</span>\n <code className=\"min-w-0 break-all text-xs\">{looseLink.link}</code>\n <CopyButton size=\"xs\" text={looseLink.link} label={labels.copyLink} />\n </div>\n </AlertBanner>\n )}\n\n <div className=\"space-y-2\">\n {listTitle !== null && <SectionLabel as=\"h4\">{listTitle ?? labels.listTitle}</SectionLabel>}\n {loading && invitations.length === 0 ? (\n <div className=\"flex justify-center py-3\">\n <Spinner label={labels.loading} />\n </div>\n ) : invitations.length === 0 ? (\n <Caption>{labels.empty}</Caption>\n ) : (\n <ul aria-label={labels.listTitle} className=\"divide-y divide-[var(--border)]\">\n {invitations.map((invitation) => {\n const key = String(invitation.id);\n const link = invitation.link ?? links[key];\n const open = invitation.status === \"open\";\n const resendable = onResend && (open || invitation.status === \"expired\");\n const revocable = onRevoke && (open || invitation.status === \"expired\");\n const scopeText = scopeLabel(invitation.scope);\n const by =\n typeof invitation.invited_by === \"string\" ? invitation.invited_by : nameOf(invitation.invited_by);\n const facts = [\n dayText(invitation.created_at) && labels.sent(dayText(invitation.created_at)),\n open && dayText(invitation.expires_at ?? null) && labels.expires(dayText(invitation.expires_at ?? null)),\n by && labels.invitedBy(by),\n ].filter(Boolean);\n return (\n <li key={key} data-status={invitation.status} className=\"py-2 first:pt-0 last:pb-0\">\n <div className=\"flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5\">\n <div className=\"min-w-0 flex-1 basis-48 space-y-1\">\n <div data-private className=\"truncate text-sm font-medium text-[var(--text-primary)]\">\n {invitation.email}\n </div>\n <div className=\"flex flex-wrap items-center gap-1\">\n <Chip size=\"xs\" shape=\"square\" caps tone={STATUS_TONES[invitation.status]}>\n {labels.status[invitation.status]}\n </Chip>\n {roles && invitation.role && <RoleChip<R> value={invitation.role} roles={roles} size=\"xs\" />}\n {scopeText && (\n <Chip size=\"xs\" shape=\"square\">\n {scopeText}\n </Chip>\n )}\n </div>\n {(facts.length > 0 || invitation.note) && (\n <div className=\"text-xs text-[var(--text-muted)]\">\n {facts.join(\" · \")}\n {invitation.note && (\n <>\n {facts.length > 0 && \" · \"}\n <span data-private>{invitation.note}</span>\n </>\n )}\n </div>\n )}\n </div>\n {(link || resendable || revocable) && (\n <div className=\"ms-auto flex shrink-0 items-center gap-1\">\n {link && open && <CopyButton size=\"xs\" tone=\"muted\" text={link} label={labels.copyLink} />}\n {resendable && (\n <IconButton\n size=\"xs\"\n commit\n label={labels.resend(invitation.email)}\n pending={busy === `resend:${key}`}\n disabled={busy !== null}\n onClick={async () => {\n const answer = await run(`resend:${key}`, () => onResend(invitation));\n if (answer !== FAILED) took(answer, invitation.email, invitation.id);\n }}\n >\n <RefreshCw />\n </IconButton>\n )}\n {revocable && (\n <IconButton\n size=\"xs\"\n tone=\"danger\"\n commit\n label={labels.revoke(invitation.email)}\n pending={busy === `revoke:${key}`}\n disabled={busy !== null}\n onClick={() => void run(`revoke:${key}`, () => onRevoke(invitation))}\n >\n <Trash2 />\n </IconButton>\n )}\n </div>\n )}\n </div>\n </li>\n );\n })}\n </ul>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";AAwUgB,SAgJY,UAhJZ,KAoCF,YApCE;AAxUhB,SAAS,gBAAgB;AAEzB,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,UAAU;AAEnB,SAAS,cAAc,oBAAoB;AAC3C,SAAS,eAAe,uBAAuB;AAE/C,SAAS,gBAAgB;AAEzB,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AAErB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,cAAc,eAAe;AACtC,SAAS,QAAQ,YAAY,OAAO,QAAQ,eAA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aAEJ;AAAA,WACE,QAAQ,cAAc,cACtB,qBAAC,SAAI,WAAU,4CACZ;AAAA,oBAAQ,QAAQ,oBAAC,cAAW,MAAK,MAAK,MAAK,SAAQ,MAAM,MAAM,OAAO,OAAO,UAAU;AAAA,YACvF,cACC;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,QAAM;AAAA,gBACN,OAAO,OAAO,OAAO,WAAW,KAAK;AAAA,gBACrC,SAAS,SAAS,UAAU,GAAG;AAAA,gBAC/B,UAAU,SAAS;AAAA,gBACnB,SAAS,YAAY;AACnB,wBAAM,SAAS,MAAM,IAAI,UAAU,GAAG,IAAI,MAAM,SAAS,UAAU,CAAC;AACpE,sBAAI,WAAW,OAAQ,MAAK,QAAQ,WAAW,OAAO,WAAW,EAAE;AAAA,gBACrE;AAAA,gBAEA,8BAAC,aAAU;AAAA;AAAA,YACb;AAAA,YAED,aACC;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,MAAK;AAAA,gBACL,QAAM;AAAA,gBACN,OAAO,OAAO,OAAO,WAAW,KAAK;AAAA,gBACrC,SAAS,SAAS,UAAU,GAAG;AAAA,gBAC/B,UAAU,SAAS;AAAA,gBACnB,SAAS,MAAM,KAAK,IAAI,UAAU,GAAG,IAAI,MAAM,SAAS,UAAU,CAAC;AAAA,gBAEnE,8BAAC,UAAO;AAAA;AAAA,YACV;AAAA,aAEJ;AAAA,WAEJ,KA9DO,GA+DT;AAAA,MAEJ,CAAC,GACH;AAAA,OAEJ;AAAA,KACF;AAEJ;","names":["address"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { cC as DEFAULT_REVIEWER_SCOPE_LABELS, en as ReviewerScope, eo as ReviewerScopeArea, ep as ReviewerScopeEditor, eq as ReviewerScopeEditorProps, er as ReviewerScopeLabels, es as ReviewerScopeLanguage } from '../delete-account-setting-
|
|
2
|
+
export { cC as DEFAULT_REVIEWER_SCOPE_LABELS, en as ReviewerScope, eo as ReviewerScopeArea, ep as ReviewerScopeEditor, eq as ReviewerScopeEditorProps, er as ReviewerScopeLabels, es as ReviewerScopeLanguage } from '../delete-account-setting-DCFS5Vof.js';
|
|
3
3
|
import './admin-parts.js';
|
|
4
4
|
import '../components/tooltip.js';
|
|
5
5
|
import '../hooks/use-anchored-rect.js';
|
|
@@ -55,6 +55,8 @@ import '../components/image-grid.js';
|
|
|
55
55
|
import '../components/lightbox.js';
|
|
56
56
|
import '../components/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';
|
|
@@ -75,6 +77,8 @@ import '../lib/format.js';
|
|
|
75
77
|
import '../account/data-export-setting.js';
|
|
76
78
|
import '../components/account-chips.js';
|
|
77
79
|
import './admin-action-log.js';
|
|
80
|
+
import '../settings/settings-labels.js';
|
|
81
|
+
import '../demo/demo-labels.js';
|
|
78
82
|
import '../components/reauth-dialog.js';
|
|
79
83
|
import '../components/server-wake.js';
|
|
80
84
|
import '../lib/server-wake.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'react';
|
|
2
2
|
import '../components/account-chips.js';
|
|
3
|
-
export { cD as DEFAULT_ROLE_SELECT_LABELS, eu as RoleLock, ev as RoleLockCode, ew as RoleSelect, ex as RoleSelectLabels, ey as RoleSelectProps, ez as RolesEditor, eA as RolesEditorProps } from '../delete-account-setting-
|
|
3
|
+
export { cD as DEFAULT_ROLE_SELECT_LABELS, eu as RoleLock, ev as RoleLockCode, ew as RoleSelect, ex as RoleSelectLabels, ey as RoleSelectProps, ez as RolesEditor, eA as RolesEditorProps } from '../delete-account-setting-DCFS5Vof.js';
|
|
4
4
|
import 'lucide-react';
|
|
5
5
|
import '../lib/format.js';
|
|
6
6
|
import '../components/chip.js';
|
|
@@ -56,6 +56,8 @@ import '../components/image-grid.js';
|
|
|
56
56
|
import '../components/lightbox.js';
|
|
57
57
|
import '../components/write-lock.js';
|
|
58
58
|
import '../auth/sign-in-form.js';
|
|
59
|
+
import '../landing/access.js';
|
|
60
|
+
import '../landing/landing-labels.js';
|
|
59
61
|
import '../shell/topbar-controls.js';
|
|
60
62
|
import '../theme/palette-presets.js';
|
|
61
63
|
import '../theme/chart-palette.js';
|
|
@@ -75,6 +77,8 @@ import '../account/sessions-setting.js';
|
|
|
75
77
|
import '../account/data-export-setting.js';
|
|
76
78
|
import './admin-parts.js';
|
|
77
79
|
import './admin-action-log.js';
|
|
80
|
+
import '../settings/settings-labels.js';
|
|
81
|
+
import '../demo/demo-labels.js';
|
|
78
82
|
import '../components/reauth-dialog.js';
|
|
79
83
|
import '../components/server-wake.js';
|
|
80
84
|
import '../lib/server-wake.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { cI as DEFAULT_TRANSFER_OWNERSHIP_LABELS, e_ as TransferCandidate, e$ as TransferOwnershipDialog, f0 as TransferOwnershipDialogProps, f1 as TransferOwnershipLabels, f2 as TransferUnavailable, f3 as TransferValues } from '../delete-account-setting-
|
|
2
|
+
export { cI as DEFAULT_TRANSFER_OWNERSHIP_LABELS, e_ as TransferCandidate, e$ as TransferOwnershipDialog, f0 as TransferOwnershipDialogProps, f1 as TransferOwnershipLabels, f2 as TransferUnavailable, f3 as TransferValues } from '../delete-account-setting-DCFS5Vof.js';
|
|
3
3
|
import './admin-parts.js';
|
|
4
4
|
import '../components/tooltip.js';
|
|
5
5
|
import '../hooks/use-anchored-rect.js';
|
|
@@ -55,6 +55,8 @@ import '../components/image-grid.js';
|
|
|
55
55
|
import '../components/lightbox.js';
|
|
56
56
|
import '../components/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';
|
|
@@ -75,6 +77,8 @@ import '../lib/format.js';
|
|
|
75
77
|
import '../account/data-export-setting.js';
|
|
76
78
|
import '../components/account-chips.js';
|
|
77
79
|
import './admin-action-log.js';
|
|
80
|
+
import '../settings/settings-labels.js';
|
|
81
|
+
import '../demo/demo-labels.js';
|
|
78
82
|
import '../components/reauth-dialog.js';
|
|
79
83
|
import '../components/server-wake.js';
|
|
80
84
|
import '../lib/server-wake.js';
|
|
@@ -6,7 +6,7 @@ import '../components/account-chips.js';
|
|
|
6
6
|
import '../components/chip.js';
|
|
7
7
|
import '../data-table-labels-DUELeXpa.js';
|
|
8
8
|
import '../components/data-table-sort.js';
|
|
9
|
-
export { bz as AdminUserStateFields, cJ as DEFAULT_USER_ROSTER_LABELS, et as RoleEditing, eB as RosterState, f8 as USER_ROSTER_SORT_KEYS, ff as UserIdentityCell, fg as UserIdentityCellProps, fh as UserRosterColumnsOptions, fi as UserRosterLabels, fj as UserRosterRow, fk as UserRosterSortKey, fl as UserRowAction, fm as UserRowActionList, fn as UserRowActions, fo as UserRowActionsProps, fp as adminUserStates, fO as useUserRosterColumns, fP as userRosterColumns, fQ as userRosterSort } from '../delete-account-setting-
|
|
9
|
+
export { bz as AdminUserStateFields, cJ as DEFAULT_USER_ROSTER_LABELS, et as RoleEditing, eB as RosterState, f8 as USER_ROSTER_SORT_KEYS, ff as UserIdentityCell, fg as UserIdentityCellProps, fh as UserRosterColumnsOptions, fi as UserRosterLabels, fj as UserRosterRow, fk as UserRosterSortKey, fl as UserRowAction, fm as UserRowActionList, fn as UserRowActions, fo as UserRowActionsProps, fp as adminUserStates, fO as useUserRosterColumns, fP as userRosterColumns, fQ as userRosterSort } from '../delete-account-setting-DCFS5Vof.js';
|
|
10
10
|
import '../components/swipeable-row.js';
|
|
11
11
|
import '../components/tooltip.js';
|
|
12
12
|
import '../hooks/use-anchored-rect.js';
|
|
@@ -56,6 +56,8 @@ import '../components/image-grid.js';
|
|
|
56
56
|
import '../components/lightbox.js';
|
|
57
57
|
import '../components/write-lock.js';
|
|
58
58
|
import '../auth/sign-in-form.js';
|
|
59
|
+
import '../landing/access.js';
|
|
60
|
+
import '../landing/landing-labels.js';
|
|
59
61
|
import '../shell/topbar-controls.js';
|
|
60
62
|
import '../theme/palette-presets.js';
|
|
61
63
|
import '../theme/chart-palette.js';
|
|
@@ -75,6 +77,8 @@ import '../account/sessions-setting.js';
|
|
|
75
77
|
import '../account/data-export-setting.js';
|
|
76
78
|
import './admin-parts.js';
|
|
77
79
|
import './admin-action-log.js';
|
|
80
|
+
import '../settings/settings-labels.js';
|
|
81
|
+
import '../demo/demo-labels.js';
|
|
78
82
|
import '../components/reauth-dialog.js';
|
|
79
83
|
import '../components/server-wake.js';
|
|
80
84
|
import '../lib/server-wake.js';
|
|
@@ -48,11 +48,28 @@ type AuthErrorCode = "invalid_credentials" | "registration_closed" | "email_take
|
|
|
48
48
|
* is a `409`.
|
|
49
49
|
*/
|
|
50
50
|
type AccountErrorCode = "last_admin" | "self_action" | "other_companies" | "household_has_members" | "confirmation_required" | "confirmation_mismatch" | "password_incorrect";
|
|
51
|
-
/** Every code the kit reads: the sign-in refusals and the account ones (0.30.0). */
|
|
52
|
-
type KitErrorCode = AuthErrorCode | AccountErrorCode;
|
|
53
51
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
52
|
+
* 0.31.0: the demo's coded refusals (docs/landing-demo-harmonization.md §6.2) —
|
|
53
|
+
* server-kit 0.5's `DemoErrorCode`, value for value, answered as `{detail, code}` like
|
|
54
|
+
* the others and read by the same {@link authErrorCode}.
|
|
55
|
+
*
|
|
56
|
+
* - `demo_disabled` — `404`: the demo switch is off (it is "not there", not forbidden).
|
|
57
|
+
* - `demo_rate_limited` — `429` with `Retry-After`: the per-IP window of demo starts.
|
|
58
|
+
* - `demo_capacity` — `429`, no `Retry-After`: the cap of live demo users.
|
|
59
|
+
* - `demo_not_ready` — `503`: the demo data has not been seeded yet.
|
|
60
|
+
* - `demo_read_only` — `403`, model R: any write by a demo user. The app's write lock
|
|
61
|
+
* already explains it, so it shows no toast (§5.4).
|
|
62
|
+
* - `demo_refused` — `403`, both models: an action a demo never may — a way in or out,
|
|
63
|
+
* mail, uploads, the account export (§6.4).
|
|
64
|
+
*/
|
|
65
|
+
type DemoErrorCode = "demo_disabled" | "demo_rate_limited" | "demo_capacity" | "demo_not_ready" | "demo_read_only" | "demo_refused";
|
|
66
|
+
/** Every code the kit reads: the sign-in refusals, the account ones (0.30.0) and the
|
|
67
|
+
* demo's (0.31.0). */
|
|
68
|
+
type KitErrorCode = AuthErrorCode | AccountErrorCode | DemoErrorCode;
|
|
69
|
+
/**
|
|
70
|
+
* The code an error carries — an {@link AuthErrorCode}, since 0.30.0 an
|
|
71
|
+
* {@link AccountErrorCode}, since 0.31.0 a {@link DemoErrorCode} — or `undefined` when it
|
|
72
|
+
* carries none.
|
|
56
73
|
*
|
|
57
74
|
* Reads the parsed response body wherever the apps' HTTP clients put it, without
|
|
58
75
|
* depending on any of them:
|
|
@@ -81,7 +98,8 @@ declare function authErrorCode(err: unknown): KitErrorCode | undefined;
|
|
|
81
98
|
* The kit's `SignInForm` and `RegisterForm` call it on what their callbacks reject
|
|
82
99
|
* with, so an app's `onSubmit` can simply let its client's error through. See
|
|
83
100
|
* {@link authErrorCode} for the shapes it reads. Since 0.30.0 it knows the account codes
|
|
84
|
-
* too: `isAuthError(err, "last_admin")
|
|
101
|
+
* too: `isAuthError(err, "last_admin")`; since 0.31.0 the demo's:
|
|
102
|
+
* `isAuthError(err, "demo_read_only")`.
|
|
85
103
|
*/
|
|
86
104
|
declare function isAuthError(err: unknown, code?: KitErrorCode): boolean;
|
|
87
105
|
/**
|
|
@@ -136,4 +154,4 @@ declare function englishRateLimited(seconds?: number): string;
|
|
|
136
154
|
/** "30 s", "2 min" — a wait in English, rounded up. @internal */
|
|
137
155
|
declare function englishWait(seconds: number): string;
|
|
138
156
|
|
|
139
|
-
export { type AccountErrorCode, type AuthErrorCode, type KitErrorCode, authErrorCode, englishRateLimited, englishWait, isAuthError, isRateLimited, retryAfterSeconds };
|
|
157
|
+
export { type AccountErrorCode, type AuthErrorCode, type DemoErrorCode, type KitErrorCode, authErrorCode, englishRateLimited, englishWait, isAuthError, isRateLimited, retryAfterSeconds };
|
package/dist/auth/auth-errors.js
CHANGED
|
@@ -14,7 +14,13 @@ const CODES = /* @__PURE__ */ new Set([
|
|
|
14
14
|
"household_has_members",
|
|
15
15
|
"confirmation_required",
|
|
16
16
|
"confirmation_mismatch",
|
|
17
|
-
"password_incorrect"
|
|
17
|
+
"password_incorrect",
|
|
18
|
+
"demo_disabled",
|
|
19
|
+
"demo_rate_limited",
|
|
20
|
+
"demo_capacity",
|
|
21
|
+
"demo_not_ready",
|
|
22
|
+
"demo_read_only",
|
|
23
|
+
"demo_refused"
|
|
18
24
|
]);
|
|
19
25
|
const isBag = (value) => typeof value === "object" && value !== null;
|
|
20
26
|
function known(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/auth-errors.ts"],"sourcesContent":["/**\n * The coded refusals of sign-in and sign-up (docs/auth-harmonization.md §5.2): every\n * refusal the auth routes answer carries a machine-readable `code`, and the pages\n * recognise the CODE, never the server's sentence.\n *\n * Today each app's pages print the server's `detail` string (keksdose's\n * `extractApiErrorMessage`), which is English on every locale and, on a credential\n * check, would be an account-enumeration oracle if it ever said more than one thing.\n * keksdose already keys one refusal on a code (`features/budgets/plan-limit.ts`,\n * `402 {detail, code: \"plan_budget_limit\"}`); §5.2 makes that the rule for auth. Each\n * app switches its server and its pages together (§9).\n *\n * - `invalid_credentials` — unknown address, wrong password AND deactivated account:\n * one answer, in the same time (§2.10). `401`.\n * - `registration_closed` — the sign-up gate refused the address. `403`.\n * - `email_taken` — an account with this address exists. `409`.\n * - `invitation_invalid`, `invitation_expired` — the `invite` token of a sign-up or an\n * accept (§4.4).\n * - `token_invalid` — a one-time token (reset, verification, a sign-in challenge) is\n * unknown, spent or expired.\n * - `account_inactive` — **no server answers it.** §2.10 decided that a deactivated\n * account gets `invalid_credentials`, because a separate answer after a correct\n * password would confirm a leaked one. It stays in the union only for a future server\n * step that is past the password (an admin view, a signed-in refresh) and may say so.\n */\nexport type AuthErrorCode =\n | \"invalid_credentials\"\n | \"registration_closed\"\n | \"email_taken\"\n | \"invitation_invalid\"\n | \"invitation_expired\"\n | \"token_invalid\"\n /** 0.29.1: a link that WAS valid and ran out (verification, reset) — keksdose's step-3\n * refusals tell it from `token_invalid`, so a page can say \"expired, ask for a new one\". */\n | \"token_expired\"\n | \"account_inactive\";\n\n/**\n * 0.30.0: the coded refusals of user administration and the account's own settings\n * (docs/user-admin-harmonization.md §4, §6) — server-kit 0.4.0's `AccountErrorCode`,\n * value for value. The same family of answer as the sign-in codes (`{detail, code}`,\n * plus `companies` on kastlan's `last_admin`), read by the same {@link authErrorCode}.\n *\n * - `last_admin` — the action would leave no active admin: deactivating, demoting or\n * deleting the last one (in kastlan, of a company; the answer names the `companies`).\n * - `self_action` — an admin acting on their own account where that is never allowed.\n * - `other_companies` — kastlan: the account belongs to other companies too, so a\n * company admin may not deactivate it; \"Remove from company\" instead (§9.6).\n * - `household_has_members` — keksdose's guard on a deletion request (§6.4).\n * - `confirmation_required`, `confirmation_mismatch` — the action's confirmation level\n * asked for a typed address (or a tick), and the request carried none, or another\n * address (§4.2).\n * - `password_incorrect` — the CURRENT password is wrong on a signed-in route (the email\n * change, the deletion request). `400`, not `401`: an app's client reads a 401 as an\n * ended session and signs the user out, the wrong answer to a typo. Every other one\n * is a `409`.\n */\nexport type AccountErrorCode =\n | \"last_admin\"\n | \"self_action\"\n | \"other_companies\"\n | \"household_has_members\"\n | \"confirmation_required\"\n | \"confirmation_mismatch\"\n | \"password_incorrect\";\n\n/** Every code the kit reads: the sign-in refusals and the account ones (0.30.0). */\nexport type KitErrorCode = AuthErrorCode | AccountErrorCode;\n\nconst CODES: ReadonlySet<string> = new Set<KitErrorCode>([\n \"invalid_credentials\",\n \"registration_closed\",\n \"email_taken\",\n \"invitation_invalid\",\n \"invitation_expired\",\n \"token_invalid\",\n \"token_expired\",\n \"account_inactive\",\n \"last_admin\",\n \"self_action\",\n \"other_companies\",\n \"household_has_members\",\n \"confirmation_required\",\n \"confirmation_mismatch\",\n \"password_incorrect\",\n]);\n\ntype Bag = Record<string, unknown>;\n\nconst isBag = (value: unknown): value is Bag => typeof value === \"object\" && value !== null;\n\n/** A known code, or undefined. */\nfunction known(value: unknown): KitErrorCode | undefined {\n return typeof value === \"string\" && CODES.has(value) ? (value as KitErrorCode) : undefined;\n}\n\n/** `{code}` on a parsed body, or FastAPI's `{detail: {code}}` — what an\n * `HTTPException(detail={\"code\": …})` serialises to. */\nfunction codeOfBody(body: unknown): KitErrorCode | undefined {\n if (!isBag(body)) return undefined;\n return known(body.code) ?? (isBag(body.detail) ? known(body.detail.code) : undefined);\n}\n\n/**\n * The code an error carries — an {@link AuthErrorCode}, or since 0.30.0 an\n * {@link AccountErrorCode} — or `undefined` when it carries none.\n *\n * Reads the parsed response body wherever the apps' HTTP clients put it, without\n * depending on any of them:\n *\n * 1. `err.response.data` — axios (keksdose's, kastlan's and Kurvenschmiede's clients;\n * keksdose's `isPlanBudgetLimitRefusal` reads the same path);\n * 2. `err.data` — ofetch's `FetchError`, and most `fetch` wrappers that parse the body;\n * 3. `err.body` — the generated OpenAPI clients' `ApiError`;\n * 4. `err` itself — a body thrown as it came (`throw await res.json()`).\n *\n * In each, `code` or FastAPI's nested `detail.code`. Last, `err.code` — but only when\n * it is one of the codes above: axios writes its OWN codes there (`ERR_NETWORK`,\n * `ECONNABORTED`, `ERR_BAD_REQUEST`), and so does Node, so an unknown value is never\n * read as a refusal. The HTTP status is not checked: the code is the contract, and the\n * status differs per refusal (401, 403, 409, 410).\n */\nexport function authErrorCode(err: unknown): KitErrorCode | undefined {\n if (!isBag(err)) return undefined;\n const response = err.response;\n return (\n (isBag(response) ? codeOfBody(response.data) : undefined) ??\n codeOfBody(err.data) ??\n codeOfBody(err.body) ??\n codeOfBody(err)\n );\n}\n\n/**\n * Whether `err` is a coded auth refusal — any of them, or the one named:\n *\n * ```ts\n * try { await api.register(values) }\n * catch (err) { if (isAuthError(err, \"email_taken\")) … }\n * ```\n *\n * The kit's `SignInForm` and `RegisterForm` call it on what their callbacks reject\n * with, so an app's `onSubmit` can simply let its client's error through. See\n * {@link authErrorCode} for the shapes it reads. Since 0.30.0 it knows the account codes\n * too: `isAuthError(err, \"last_admin\")`.\n */\nexport function isAuthError(err: unknown, code?: KitErrorCode): boolean {\n const found = authErrorCode(err);\n return found !== undefined && (code === undefined || found === code);\n}\n\n/** An HTTP status as a number, or undefined. */\nfunction statusOf(value: unknown): number | undefined {\n return typeof value === \"number\" && Number.isInteger(value) ? value : undefined;\n}\n\n/**\n * Whether `err` is a throttled request — HTTP `429 Too Many Requests` (0.30.0, from the\n * apps' 0.29 adoption: every app answered a throttled sign-in, sign-up or reset through\n * its own `describeError`, with three wordings of one sentence).\n *\n * A throttle carries no `code` in the contract — the STATUS is the answer, set by the\n * apps' limiters (server-kit's `AuthLimiters`, keksdose's per-IP limit) — so this reads\n * the status, wherever the apps' HTTP clients put it, without depending on any of them:\n *\n * 1. `err.response.status` — axios (all three apps' clients);\n * 2. `err.status` — ofetch's `FetchError`, the generated OpenAPI clients' `ApiError`, and\n * a `Response` thrown as it came;\n * 3. `err.statusCode` — ofetch's alias, and Node-style errors.\n *\n * There is no `rate_limited` code: keksdose answers its 429s uncoded, with a\n * `Retry-After` header, and the status is the one signal every limiter gives.\n *\n * The kit's `SignInForm`, `RegisterForm`, `ForgotPasswordForm` and `ResetPasswordForm`\n * call it AFTER the app's `describeError` — an app with words of its own keeps them —\n * and before their generic failure, so \"Too many attempts. Try again in 30 s.\" (with\n * {@link retryAfterSeconds}) or \"… Wait a moment and try again.\" needs no app code.\n */\nexport function isRateLimited(err: unknown): boolean {\n if (!isBag(err)) return false;\n const response = err.response;\n const status =\n (isBag(response) ? statusOf(response.status) : undefined) ?? statusOf(err.status) ?? statusOf(err.statusCode);\n return status === 429;\n}\n\n/** A header's value from a `Headers` (fetch, ofetch's `response`), axios' `AxiosHeaders`\n * or a plain record — whose keys may come in any case. */\nfunction headerOf(headers: unknown, name: string): unknown {\n if (!isBag(headers)) return undefined;\n if (typeof headers.get === \"function\") {\n try {\n const value: unknown = (headers.get as (key: string) => unknown).call(headers, name);\n if (value !== undefined && value !== null) return value;\n } catch {\n // A `get` that is not a header lookup; the record below is.\n }\n }\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === name) return value;\n }\n return undefined;\n}\n\n/** `Retry-After` as seconds from `now`: delta-seconds (\"30\"), or an HTTP date\n * (\"Wed, 07 Oct 2026 10:00:00 GMT\") counted from now, never below 0 (RFC 9110 §10.2.3). */\nfunction parseRetryAfter(value: unknown, now: number): number | undefined {\n const raw = Array.isArray(value) ? (value as unknown[])[0] : value;\n if (typeof raw === \"number\") return Number.isFinite(raw) && raw >= 0 ? Math.ceil(raw) : undefined;\n if (typeof raw !== \"string\") return undefined;\n const text = raw.trim();\n if (/^\\d+$/.test(text)) return Number(text);\n // An HTTP date names its day and month (\"Wed, 07 Oct 2026 …\"). Without a letter it is\n // a malformed number (\"-5\", \"1.5\"), which `Date.parse` would happily read as a year.\n if (!/[a-z]/i.test(text)) return undefined;\n const at = Date.parse(text);\n if (Number.isNaN(at)) return undefined;\n return Math.max(0, Math.ceil((at - now) / 1000));\n}\n\n/**\n * How long a throttled request asks to wait, in whole seconds — its `Retry-After`\n * header (0.30.0, keksdose: its 429s carry no code, only the header) — or `undefined`\n * when there is none, or none that parses.\n *\n * Read where the apps' clients keep the response headers, without depending on any of\n * them: `err.response.headers` (axios' `AxiosHeaders` or a plain record; ofetch's\n * `FetchError.response`, a fetch `Headers`), then `err.headers` (a `Response` thrown as\n * it came). The value is delta-seconds, or an HTTP date turned into seconds from `now`\n * (default: the present moment) — never below 0.\n *\n * The forms hand it to their `rateLimited` label when {@link isRateLimited} is true:\n * \"Too many attempts. Try again in 30 s.\" — and, without one, \"… Wait a moment and try\n * again.\" A browser only exposes `Retry-After` to a cross-origin page when the server\n * lists it in `Access-Control-Expose-Headers`.\n */\nexport function retryAfterSeconds(err: unknown, now: number | Date = Date.now()): number | undefined {\n if (!isBag(err)) return undefined;\n const at = typeof now === \"number\" ? now : now.getTime();\n const response = err.response;\n const value =\n (isBag(response) ? headerOf(response.headers, \"retry-after\") : undefined) ?? headerOf(err.headers, \"retry-after\");\n return value === undefined ? undefined : parseRetryAfter(value, at);\n}\n\n/**\n * The English of every `rateLimited` label (0.30.0): \"Too many attempts. Try again in\n * 30 s.\" with a wait under a minute, in whole minutes from one minute up (keksdose's\n * reset throttle answers in hours, and \"3600 s\" is a number nobody reads), and \"Wait a\n * moment and try again.\" without one — or with a `0`.\n *\n * @internal The namespaces' English; not part of the barrel.\n */\nexport function englishRateLimited(seconds?: number): string {\n if (!seconds || seconds <= 0) return \"Too many attempts. Wait a moment and try again.\";\n return `Too many attempts. Try again in ${englishWait(seconds)}.`;\n}\n\n/** \"30 s\", \"2 min\" — a wait in English, rounded up. @internal */\nexport function englishWait(seconds: number): string {\n return seconds < 60 ? `${Math.ceil(seconds)} s` : `${Math.ceil(seconds / 60)} min`;\n}\n"],"mappings":";AAqEA,MAAM,QAA6B,oBAAI,IAAkB;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAID,MAAM,QAAQ,CAAC,UAAiC,OAAO,UAAU,YAAY,UAAU;AAGvF,SAAS,MAAM,OAA0C;AACvD,SAAO,OAAO,UAAU,YAAY,MAAM,IAAI,KAAK,IAAK,QAAyB;AACnF;AAIA,SAAS,WAAW,MAAyC;AAC3D,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,QAAQ,KAAK,IAAK,MAAoB,CAAC,IAAI;AAC7D,MAAI,OAAO,QAAQ,SAAU,QAAO,OAAO,SAAS,GAAG,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG,IAAI;AACxF,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,QAAM,OAAO,IAAI,KAAK;AACtB,MAAI,QAAQ,KAAK,IAAI,EAAG,QAAO,OAAO,IAAI;AAG1C,MAAI,CAAC,SAAS,KAAK,IAAI,EAAG,QAAO;AACjC,QAAM,KAAK,KAAK,MAAM,IAAI;AAC1B,MAAI,OAAO,MAAM,EAAE,EAAG,QAAO;AAC7B,SAAO,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,OAAO,GAAI,CAAC;AACjD;AAkBO,SAAS,kBAAkB,KAAc,MAAqB,KAAK,IAAI,GAAuB;AACnG,MAAI,CAAC,MAAM,GAAG,EAAG,QAAO;AACxB,QAAM,KAAK,OAAO,QAAQ,WAAW,MAAM,IAAI,QAAQ;AACvD,QAAM,WAAW,IAAI;AACrB,QAAM,SACH,MAAM,QAAQ,IAAI,SAAS,SAAS,SAAS,aAAa,IAAI,WAAc,SAAS,IAAI,SAAS,aAAa;AAClH,SAAO,UAAU,SAAY,SAAY,gBAAgB,OAAO,EAAE;AACpE;AAUO,SAAS,mBAAmB,SAA0B;AAC3D,MAAI,CAAC,WAAW,WAAW,EAAG,QAAO;AACrC,SAAO,mCAAmC,YAAY,OAAO,CAAC;AAChE;AAGO,SAAS,YAAY,SAAyB;AACnD,SAAO,UAAU,KAAK,GAAG,KAAK,KAAK,OAAO,CAAC,OAAO,GAAG,KAAK,KAAK,UAAU,EAAE,CAAC;AAC9E;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/auth/auth-errors.ts"],"sourcesContent":["/**\n * The coded refusals of sign-in and sign-up (docs/auth-harmonization.md §5.2): every\n * refusal the auth routes answer carries a machine-readable `code`, and the pages\n * recognise the CODE, never the server's sentence.\n *\n * Today each app's pages print the server's `detail` string (keksdose's\n * `extractApiErrorMessage`), which is English on every locale and, on a credential\n * check, would be an account-enumeration oracle if it ever said more than one thing.\n * keksdose already keys one refusal on a code (`features/budgets/plan-limit.ts`,\n * `402 {detail, code: \"plan_budget_limit\"}`); §5.2 makes that the rule for auth. Each\n * app switches its server and its pages together (§9).\n *\n * - `invalid_credentials` — unknown address, wrong password AND deactivated account:\n * one answer, in the same time (§2.10). `401`.\n * - `registration_closed` — the sign-up gate refused the address. `403`.\n * - `email_taken` — an account with this address exists. `409`.\n * - `invitation_invalid`, `invitation_expired` — the `invite` token of a sign-up or an\n * accept (§4.4).\n * - `token_invalid` — a one-time token (reset, verification, a sign-in challenge) is\n * unknown, spent or expired.\n * - `account_inactive` — **no server answers it.** §2.10 decided that a deactivated\n * account gets `invalid_credentials`, because a separate answer after a correct\n * password would confirm a leaked one. It stays in the union only for a future server\n * step that is past the password (an admin view, a signed-in refresh) and may say so.\n */\nexport type AuthErrorCode =\n | \"invalid_credentials\"\n | \"registration_closed\"\n | \"email_taken\"\n | \"invitation_invalid\"\n | \"invitation_expired\"\n | \"token_invalid\"\n /** 0.29.1: a link that WAS valid and ran out (verification, reset) — keksdose's step-3\n * refusals tell it from `token_invalid`, so a page can say \"expired, ask for a new one\". */\n | \"token_expired\"\n | \"account_inactive\";\n\n/**\n * 0.30.0: the coded refusals of user administration and the account's own settings\n * (docs/user-admin-harmonization.md §4, §6) — server-kit 0.4.0's `AccountErrorCode`,\n * value for value. The same family of answer as the sign-in codes (`{detail, code}`,\n * plus `companies` on kastlan's `last_admin`), read by the same {@link authErrorCode}.\n *\n * - `last_admin` — the action would leave no active admin: deactivating, demoting or\n * deleting the last one (in kastlan, of a company; the answer names the `companies`).\n * - `self_action` — an admin acting on their own account where that is never allowed.\n * - `other_companies` — kastlan: the account belongs to other companies too, so a\n * company admin may not deactivate it; \"Remove from company\" instead (§9.6).\n * - `household_has_members` — keksdose's guard on a deletion request (§6.4).\n * - `confirmation_required`, `confirmation_mismatch` — the action's confirmation level\n * asked for a typed address (or a tick), and the request carried none, or another\n * address (§4.2).\n * - `password_incorrect` — the CURRENT password is wrong on a signed-in route (the email\n * change, the deletion request). `400`, not `401`: an app's client reads a 401 as an\n * ended session and signs the user out, the wrong answer to a typo. Every other one\n * is a `409`.\n */\nexport type AccountErrorCode =\n | \"last_admin\"\n | \"self_action\"\n | \"other_companies\"\n | \"household_has_members\"\n | \"confirmation_required\"\n | \"confirmation_mismatch\"\n | \"password_incorrect\";\n\n/**\n * 0.31.0: the demo's coded refusals (docs/landing-demo-harmonization.md §6.2) —\n * server-kit 0.5's `DemoErrorCode`, value for value, answered as `{detail, code}` like\n * the others and read by the same {@link authErrorCode}.\n *\n * - `demo_disabled` — `404`: the demo switch is off (it is \"not there\", not forbidden).\n * - `demo_rate_limited` — `429` with `Retry-After`: the per-IP window of demo starts.\n * - `demo_capacity` — `429`, no `Retry-After`: the cap of live demo users.\n * - `demo_not_ready` — `503`: the demo data has not been seeded yet.\n * - `demo_read_only` — `403`, model R: any write by a demo user. The app's write lock\n * already explains it, so it shows no toast (§5.4).\n * - `demo_refused` — `403`, both models: an action a demo never may — a way in or out,\n * mail, uploads, the account export (§6.4).\n */\nexport type DemoErrorCode =\n | \"demo_disabled\"\n | \"demo_rate_limited\"\n | \"demo_capacity\"\n | \"demo_not_ready\"\n | \"demo_read_only\"\n | \"demo_refused\";\n\n/** Every code the kit reads: the sign-in refusals, the account ones (0.30.0) and the\n * demo's (0.31.0). */\nexport type KitErrorCode = AuthErrorCode | AccountErrorCode | DemoErrorCode;\n\nconst CODES: ReadonlySet<string> = new Set<KitErrorCode>([\n \"invalid_credentials\",\n \"registration_closed\",\n \"email_taken\",\n \"invitation_invalid\",\n \"invitation_expired\",\n \"token_invalid\",\n \"token_expired\",\n \"account_inactive\",\n \"last_admin\",\n \"self_action\",\n \"other_companies\",\n \"household_has_members\",\n \"confirmation_required\",\n \"confirmation_mismatch\",\n \"password_incorrect\",\n \"demo_disabled\",\n \"demo_rate_limited\",\n \"demo_capacity\",\n \"demo_not_ready\",\n \"demo_read_only\",\n \"demo_refused\",\n]);\n\ntype Bag = Record<string, unknown>;\n\nconst isBag = (value: unknown): value is Bag => typeof value === \"object\" && value !== null;\n\n/** A known code, or undefined. */\nfunction known(value: unknown): KitErrorCode | undefined {\n return typeof value === \"string\" && CODES.has(value) ? (value as KitErrorCode) : undefined;\n}\n\n/** `{code}` on a parsed body, or FastAPI's `{detail: {code}}` — what an\n * `HTTPException(detail={\"code\": …})` serialises to. */\nfunction codeOfBody(body: unknown): KitErrorCode | undefined {\n if (!isBag(body)) return undefined;\n return known(body.code) ?? (isBag(body.detail) ? known(body.detail.code) : undefined);\n}\n\n/**\n * The code an error carries — an {@link AuthErrorCode}, since 0.30.0 an\n * {@link AccountErrorCode}, since 0.31.0 a {@link DemoErrorCode} — or `undefined` when it\n * carries none.\n *\n * Reads the parsed response body wherever the apps' HTTP clients put it, without\n * depending on any of them:\n *\n * 1. `err.response.data` — axios (keksdose's, kastlan's and Kurvenschmiede's clients;\n * keksdose's `isPlanBudgetLimitRefusal` reads the same path);\n * 2. `err.data` — ofetch's `FetchError`, and most `fetch` wrappers that parse the body;\n * 3. `err.body` — the generated OpenAPI clients' `ApiError`;\n * 4. `err` itself — a body thrown as it came (`throw await res.json()`).\n *\n * In each, `code` or FastAPI's nested `detail.code`. Last, `err.code` — but only when\n * it is one of the codes above: axios writes its OWN codes there (`ERR_NETWORK`,\n * `ECONNABORTED`, `ERR_BAD_REQUEST`), and so does Node, so an unknown value is never\n * read as a refusal. The HTTP status is not checked: the code is the contract, and the\n * status differs per refusal (401, 403, 409, 410).\n */\nexport function authErrorCode(err: unknown): KitErrorCode | undefined {\n if (!isBag(err)) return undefined;\n const response = err.response;\n return (\n (isBag(response) ? codeOfBody(response.data) : undefined) ??\n codeOfBody(err.data) ??\n codeOfBody(err.body) ??\n codeOfBody(err)\n );\n}\n\n/**\n * Whether `err` is a coded auth refusal — any of them, or the one named:\n *\n * ```ts\n * try { await api.register(values) }\n * catch (err) { if (isAuthError(err, \"email_taken\")) … }\n * ```\n *\n * The kit's `SignInForm` and `RegisterForm` call it on what their callbacks reject\n * with, so an app's `onSubmit` can simply let its client's error through. See\n * {@link authErrorCode} for the shapes it reads. Since 0.30.0 it knows the account codes\n * too: `isAuthError(err, \"last_admin\")`; since 0.31.0 the demo's:\n * `isAuthError(err, \"demo_read_only\")`.\n */\nexport function isAuthError(err: unknown, code?: KitErrorCode): boolean {\n const found = authErrorCode(err);\n return found !== undefined && (code === undefined || found === code);\n}\n\n/** An HTTP status as a number, or undefined. */\nfunction statusOf(value: unknown): number | undefined {\n return typeof value === \"number\" && Number.isInteger(value) ? value : undefined;\n}\n\n/**\n * Whether `err` is a throttled request — HTTP `429 Too Many Requests` (0.30.0, from the\n * apps' 0.29 adoption: every app answered a throttled sign-in, sign-up or reset through\n * its own `describeError`, with three wordings of one sentence).\n *\n * A throttle carries no `code` in the contract — the STATUS is the answer, set by the\n * apps' limiters (server-kit's `AuthLimiters`, keksdose's per-IP limit) — so this reads\n * the status, wherever the apps' HTTP clients put it, without depending on any of them:\n *\n * 1. `err.response.status` — axios (all three apps' clients);\n * 2. `err.status` — ofetch's `FetchError`, the generated OpenAPI clients' `ApiError`, and\n * a `Response` thrown as it came;\n * 3. `err.statusCode` — ofetch's alias, and Node-style errors.\n *\n * There is no `rate_limited` code: keksdose answers its 429s uncoded, with a\n * `Retry-After` header, and the status is the one signal every limiter gives.\n *\n * The kit's `SignInForm`, `RegisterForm`, `ForgotPasswordForm` and `ResetPasswordForm`\n * call it AFTER the app's `describeError` — an app with words of its own keeps them —\n * and before their generic failure, so \"Too many attempts. Try again in 30 s.\" (with\n * {@link retryAfterSeconds}) or \"… Wait a moment and try again.\" needs no app code.\n */\nexport function isRateLimited(err: unknown): boolean {\n if (!isBag(err)) return false;\n const response = err.response;\n const status =\n (isBag(response) ? statusOf(response.status) : undefined) ?? statusOf(err.status) ?? statusOf(err.statusCode);\n return status === 429;\n}\n\n/** A header's value from a `Headers` (fetch, ofetch's `response`), axios' `AxiosHeaders`\n * or a plain record — whose keys may come in any case. */\nfunction headerOf(headers: unknown, name: string): unknown {\n if (!isBag(headers)) return undefined;\n if (typeof headers.get === \"function\") {\n try {\n const value: unknown = (headers.get as (key: string) => unknown).call(headers, name);\n if (value !== undefined && value !== null) return value;\n } catch {\n // A `get` that is not a header lookup; the record below is.\n }\n }\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === name) return value;\n }\n return undefined;\n}\n\n/** `Retry-After` as seconds from `now`: delta-seconds (\"30\"), or an HTTP date\n * (\"Wed, 07 Oct 2026 10:00:00 GMT\") counted from now, never below 0 (RFC 9110 §10.2.3). */\nfunction parseRetryAfter(value: unknown, now: number): number | undefined {\n const raw = Array.isArray(value) ? (value as unknown[])[0] : value;\n if (typeof raw === \"number\") return Number.isFinite(raw) && raw >= 0 ? Math.ceil(raw) : undefined;\n if (typeof raw !== \"string\") return undefined;\n const text = raw.trim();\n if (/^\\d+$/.test(text)) return Number(text);\n // An HTTP date names its day and month (\"Wed, 07 Oct 2026 …\"). Without a letter it is\n // a malformed number (\"-5\", \"1.5\"), which `Date.parse` would happily read as a year.\n if (!/[a-z]/i.test(text)) return undefined;\n const at = Date.parse(text);\n if (Number.isNaN(at)) return undefined;\n return Math.max(0, Math.ceil((at - now) / 1000));\n}\n\n/**\n * How long a throttled request asks to wait, in whole seconds — its `Retry-After`\n * header (0.30.0, keksdose: its 429s carry no code, only the header) — or `undefined`\n * when there is none, or none that parses.\n *\n * Read where the apps' clients keep the response headers, without depending on any of\n * them: `err.response.headers` (axios' `AxiosHeaders` or a plain record; ofetch's\n * `FetchError.response`, a fetch `Headers`), then `err.headers` (a `Response` thrown as\n * it came). The value is delta-seconds, or an HTTP date turned into seconds from `now`\n * (default: the present moment) — never below 0.\n *\n * The forms hand it to their `rateLimited` label when {@link isRateLimited} is true:\n * \"Too many attempts. Try again in 30 s.\" — and, without one, \"… Wait a moment and try\n * again.\" A browser only exposes `Retry-After` to a cross-origin page when the server\n * lists it in `Access-Control-Expose-Headers`.\n */\nexport function retryAfterSeconds(err: unknown, now: number | Date = Date.now()): number | undefined {\n if (!isBag(err)) return undefined;\n const at = typeof now === \"number\" ? now : now.getTime();\n const response = err.response;\n const value =\n (isBag(response) ? headerOf(response.headers, \"retry-after\") : undefined) ?? headerOf(err.headers, \"retry-after\");\n return value === undefined ? undefined : parseRetryAfter(value, at);\n}\n\n/**\n * The English of every `rateLimited` label (0.30.0): \"Too many attempts. Try again in\n * 30 s.\" with a wait under a minute, in whole minutes from one minute up (keksdose's\n * reset throttle answers in hours, and \"3600 s\" is a number nobody reads), and \"Wait a\n * moment and try again.\" without one — or with a `0`.\n *\n * @internal The namespaces' English; not part of the barrel.\n */\nexport function englishRateLimited(seconds?: number): string {\n if (!seconds || seconds <= 0) return \"Too many attempts. Wait a moment and try again.\";\n return `Too many attempts. Try again in ${englishWait(seconds)}.`;\n}\n\n/** \"30 s\", \"2 min\" — a wait in English, rounded up. @internal */\nexport function englishWait(seconds: number): string {\n return seconds < 60 ? `${Math.ceil(seconds)} s` : `${Math.ceil(seconds / 60)} min`;\n}\n"],"mappings":";AA4FA,MAAM,QAA6B,oBAAI,IAAkB;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAID,MAAM,QAAQ,CAAC,UAAiC,OAAO,UAAU,YAAY,UAAU;AAGvF,SAAS,MAAM,OAA0C;AACvD,SAAO,OAAO,UAAU,YAAY,MAAM,IAAI,KAAK,IAAK,QAAyB;AACnF;AAIA,SAAS,WAAW,MAAyC;AAC3D,MAAI,CAAC,MAAM,IAAI,EAAG,QAAO;AACzB,SAAO,MA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AI,OAAO,QAAQ,SAAU,QAAO,OAAO,SAAS,GAAG,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG,IAAI;AACxF,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,QAAM,OAAO,IAAI,KAAK;AACtB,MAAI,QAAQ,KAAK,IAAI,EAAG,QAAO,OAAO,IAAI;AAG1C,MAAI,CAAC,SAAS,KAAK,IAAI,EAAG,QAAO;AACjC,QAAM,KAAK,KAAK,MAAM,IAAI;AAC1B,MAAI,OAAO,MAAM,EAAE,EAAG,QAAO;AAC7B,SAAO,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,OAAO,GAAI,CAAC;AACjD;AAkBO,SAAS,kBAAkB,KAAc,MAAqB,KAAK,IAAI,GAAuB;AACnG,MAAI,CAAC,MAAM,GAAG,EAAG,QAAO;AACxB,QAAM,KAAK,OAAO,QAAQ,WAAW,MAAM,IAAI,QAAQ;AACvD,QAAM,WAAW,IAAI;AACrB,QAAM,SACH,MAAM,QAAQ,IAAI,SAAS,SAAS,SAAS,aAAa,IAAI,WAAc,SAAS,IAAI,SAAS,aAAa;AAClH,SAAO,UAAU,SAAY,SAAY,gBAAgB,OAAO,EAAE;AACpE;AAUO,SAAS,mBAAmB,SAA0B;AAC3D,MAAI,CAAC,WAAW,WAAW,EAAG,QAAO;AACrC,SAAO,mCAAmC,YAAY,OAAO,CAAC;AAChE;AAGO,SAAS,YAAY,SAAyB;AACnD,SAAO,UAAU,KAAK,GAAG,KAAK,KAAK,OAAO,CAAC,OAAO,GAAG,KAAK,KAAK,UAAU,EAAE,CAAC;AAC9E;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { cB as DEFAULT_REGISTER_LABELS, ei as RegisterForm, ej as RegisterFormProps, ek as RegisterLabels, el as RegisterValues } from '../delete-account-setting-
|
|
2
|
+
export { cB as DEFAULT_REGISTER_LABELS, ei as RegisterForm, ej as RegisterFormProps, ek as RegisterLabels, el as RegisterValues } from '../delete-account-setting-DCFS5Vof.js';
|
|
3
3
|
import '../components/tooltip.js';
|
|
4
4
|
import '../hooks/use-anchored-rect.js';
|
|
5
5
|
import '../lib/clipping.js';
|
|
@@ -54,6 +54,8 @@ import '../components/image-grid.js';
|
|
|
54
54
|
import '../components/lightbox.js';
|
|
55
55
|
import '../components/write-lock.js';
|
|
56
56
|
import './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 '../components/account-chips.js';
|
|
76
78
|
import '../admin/admin-parts.js';
|
|
77
79
|
import '../admin/admin-action-log.js';
|
|
80
|
+
import '../settings/settings-labels.js';
|
|
81
|
+
import '../demo/demo-labels.js';
|
|
78
82
|
import '../components/reauth-dialog.js';
|
|
79
83
|
import '../components/server-wake.js';
|
|
80
84
|
import '../lib/server-wake.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
import { AccessChoice } from '../landing/access.js';
|
|
4
|
+
import '../landing/landing-labels.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* What a sign-in call answers, in the kit's words — docs/auth-harmonization.md §5.1,
|
|
@@ -142,6 +144,9 @@ interface SignInLabels {
|
|
|
142
144
|
* wait its `Retry-After` asks for, in seconds ({@link retryAfterSeconds}), or
|
|
143
145
|
* `undefined` (or `0`) without one. */
|
|
144
146
|
rateLimited?: (seconds?: number) => string;
|
|
147
|
+
/** 0.31.0: the link after `noAccount` for an invitation-only app (`access` of kind
|
|
148
|
+
* `request`) — a mail to support, in place of `register`. */
|
|
149
|
+
requestAccess?: string;
|
|
145
150
|
}
|
|
146
151
|
/** `Required`: every key, the 0.30 ones included, has its English here. */
|
|
147
152
|
declare const DEFAULT_SIGN_IN_LABELS: Required<SignInLabels>;
|
|
@@ -185,6 +190,15 @@ interface SignInFormProps extends Omit<ComponentPropsWithoutRef<"div">, "onSubmi
|
|
|
185
190
|
forgotHref?: string;
|
|
186
191
|
/** "No account yet? Create account" goes here — `/register`. Left out, no line. */
|
|
187
192
|
registerHref?: string;
|
|
193
|
+
/**
|
|
194
|
+
* 0.31.0 (docs/landing-demo-harmonization.md §4.2): how a visitor gets an account —
|
|
195
|
+
* the same value the landing's `PublicHeader` and `Hero` take. `{kind: "request",
|
|
196
|
+
* email}` turns the line into "No account yet? Request access", a mail to support with
|
|
197
|
+
* the subject and body of `accessAction` (every app is invitation-only); `{kind:
|
|
198
|
+
* "register", href}` keeps "Create account", to `href`. Wins over `registerHref`; left
|
|
199
|
+
* out, `registerHref` works as before.
|
|
200
|
+
*/
|
|
201
|
+
access?: AccessChoice;
|
|
188
202
|
/** The email field's start value — the reset page ends on "Sign in" with the address
|
|
189
203
|
* filled in (§6.3). */
|
|
190
204
|
defaultEmail?: string;
|
|
@@ -290,6 +304,6 @@ interface SignInFormProps extends Omit<ComponentPropsWithoutRef<"div">, "onSubmi
|
|
|
290
304
|
* The password is dropped from state once the credentials are answered; "Back to sign in"
|
|
291
305
|
* returns to an empty password field.
|
|
292
306
|
*/
|
|
293
|
-
declare function SignInForm({ onSubmit, onCode, onSetPassword, onPasskey, passkeyAutofill, forgotHref, registerHref, defaultEmail, emailTag, deactivatedContact, codeLength, recoveryCode, credentialsContent, twoFactorContent, passwordChangeContent, describeError, onStepChange, headingAs: Heading, labels: labelsProp, className, ...rest }: SignInFormProps): react.JSX.Element;
|
|
307
|
+
declare function SignInForm({ onSubmit, onCode, onSetPassword, onPasskey, passkeyAutofill, forgotHref, registerHref, access, defaultEmail, emailTag, deactivatedContact, codeLength, recoveryCode, credentialsContent, twoFactorContent, passwordChangeContent, describeError, onStepChange, headingAs: Heading, labels: labelsProp, className, ...rest }: SignInFormProps): react.JSX.Element;
|
|
294
308
|
|
|
295
309
|
export { DEFAULT_SIGN_IN_LABELS, type SignInAction, type SignInAnswer, type SignInCodeValues, type SignInCredentials, SignInForm, type SignInFormProps, type SignInLabels, type SignInNewPasswordValues, type SignInStep };
|
|
@@ -10,6 +10,8 @@ import { CurrentPasswordInput } from "../components/danger-confirm.js";
|
|
|
10
10
|
import { OneTimeCodeInput } from "../components/one-time-code-input.js";
|
|
11
11
|
import { TextLink } from "../components/text-link.js";
|
|
12
12
|
import { Button, Input } from "../components/ui.js";
|
|
13
|
+
import { accessAction } from "../landing/access.js";
|
|
14
|
+
import { useLandingLabels } from "../landing/landing-labels.js";
|
|
13
15
|
import { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from "./auth-errors.js";
|
|
14
16
|
import { taggedEmail } from "./email-tag.js";
|
|
15
17
|
import { newPasswordProblem } from "./form-rules.js";
|
|
@@ -47,7 +49,8 @@ const DEFAULT_SIGN_IN_LABELS = {
|
|
|
47
49
|
recoveryIntro: "Enter one of the backup codes you saved when you turned on two-factor authentication.",
|
|
48
50
|
recoveryCodeHint: (length) => `${length} letters and digits. Dashes and spaces don\u2019t matter.`,
|
|
49
51
|
recoveryCodeInvalid: "This backup code is not valid, or it has been used already.",
|
|
50
|
-
rateLimited: englishRateLimited
|
|
52
|
+
rateLimited: englishRateLimited,
|
|
53
|
+
requestAccess: "Request access"
|
|
51
54
|
};
|
|
52
55
|
function withContact(template, contact) {
|
|
53
56
|
const node = typeof contact === "string" && contact.includes("@") ? /* @__PURE__ */ jsx(TextLink, { href: `mailto:${contact}`, tone: "secondary", children: contact }, "contact") : /* @__PURE__ */ jsx("span", { children: contact }, "contact");
|
|
@@ -68,6 +71,7 @@ function SignInForm({
|
|
|
68
71
|
passkeyAutofill,
|
|
69
72
|
forgotHref,
|
|
70
73
|
registerHref,
|
|
74
|
+
access,
|
|
71
75
|
defaultEmail = "",
|
|
72
76
|
emailTag,
|
|
73
77
|
deactivatedContact,
|
|
@@ -84,6 +88,11 @@ function SignInForm({
|
|
|
84
88
|
...rest
|
|
85
89
|
}) {
|
|
86
90
|
const labels = useKitLabels("signIn", DEFAULT_SIGN_IN_LABELS, labelsProp);
|
|
91
|
+
const landing = useLandingLabels();
|
|
92
|
+
const accountLink = access === void 0 ? registerHref === void 0 ? null : { href: registerHref, label: labels.register } : access.kind === "register" ? { href: access.href, label: labels.register } : {
|
|
93
|
+
href: accessAction(access, landing).href,
|
|
94
|
+
label: labels.requestAccess ?? DEFAULT_SIGN_IN_LABELS.requestAccess
|
|
95
|
+
};
|
|
87
96
|
const [step, setStep] = useState("credentials");
|
|
88
97
|
const [email, setEmail] = useState(defaultEmail);
|
|
89
98
|
const [password, setPassword] = useState("");
|
|
@@ -409,10 +418,10 @@ function SignInForm({
|
|
|
409
418
|
)
|
|
410
419
|
] }),
|
|
411
420
|
forgotHref !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-center text-sm", children: /* @__PURE__ */ jsx(TextLink, { href: forgotHref, tone: "secondary", children: labels.forgotPassword }) }),
|
|
412
|
-
|
|
421
|
+
accountLink !== null && /* @__PURE__ */ jsxs("p", { className: "text-center text-sm text-[var(--text-secondary)]", children: [
|
|
413
422
|
labels.noAccount,
|
|
414
423
|
" ",
|
|
415
|
-
/* @__PURE__ */ jsx(TextLink, { href:
|
|
424
|
+
/* @__PURE__ */ jsx(TextLink, { href: accountLink.href, tone: "primary", children: accountLink.label })
|
|
416
425
|
] })
|
|
417
426
|
] });
|
|
418
427
|
}
|