@eifi1/ui-kit 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -4
- package/dist/account/account-parts.d.ts +21 -0
- package/dist/account/account-parts.js +40 -0
- package/dist/account/account-parts.js.map +1 -0
- package/dist/account/data-export-setting.d.ts +73 -0
- package/dist/account/data-export-setting.js +113 -0
- package/dist/account/data-export-setting.js.map +1 -0
- package/dist/account/delete-account-setting.d.ts +91 -0
- package/dist/account/delete-account-setting.js +199 -0
- package/dist/account/delete-account-setting.js.map +1 -0
- package/dist/account/email-change-setting.d.ts +136 -0
- package/dist/account/email-change-setting.js +277 -0
- package/dist/account/email-change-setting.js.map +1 -0
- package/dist/account/sessions-setting.d.ts +110 -0
- package/dist/account/sessions-setting.js +146 -0
- package/dist/account/sessions-setting.js.map +1 -0
- package/dist/admin/admin-action-confirm.d.ts +91 -0
- package/dist/admin/admin-action-confirm.js +276 -0
- package/dist/admin/admin-action-confirm.js.map +1 -0
- package/dist/admin/admin-action-log.d.ts +105 -0
- package/dist/admin/admin-action-log.js +153 -0
- package/dist/admin/admin-action-log.js.map +1 -0
- package/dist/admin/admin-parts.d.ts +40 -0
- package/dist/admin/admin-parts.js +45 -0
- package/dist/admin/admin-parts.js.map +1 -0
- package/dist/admin/invitations-panel.d.ts +91 -0
- package/dist/admin/invitations-panel.js +289 -0
- package/dist/admin/invitations-panel.js.map +1 -0
- package/dist/admin/reviewer-scope-editor.d.ts +91 -0
- package/dist/admin/reviewer-scope-editor.js +134 -0
- package/dist/admin/reviewer-scope-editor.js.map +1 -0
- package/dist/admin/role-select.d.ts +91 -0
- package/dist/admin/role-select.js +128 -0
- package/dist/admin/role-select.js.map +1 -0
- package/dist/admin/transfer-ownership-dialog.d.ts +91 -0
- package/dist/admin/transfer-ownership-dialog.js +83 -0
- package/dist/admin/transfer-ownership-dialog.js.map +1 -0
- package/dist/admin/user-roster.d.ts +91 -0
- package/dist/admin/user-roster.js +285 -0
- package/dist/admin/user-roster.js.map +1 -0
- package/dist/auth/auth-errors.d.ts +85 -6
- package/dist/auth/auth-errors.js +62 -2
- package/dist/auth/auth-errors.js.map +1 -1
- package/dist/auth/forgot-password-form.d.ts +10 -3
- package/dist/auth/forgot-password-form.js +6 -3
- package/dist/auth/forgot-password-form.js.map +1 -1
- package/dist/auth/register-form.d.ts +17 -12
- package/dist/auth/register-form.js +6 -4
- package/dist/auth/register-form.js.map +1 -1
- package/dist/auth/reset-password-form.d.ts +10 -3
- package/dist/auth/reset-password-form.js +6 -3
- package/dist/auth/reset-password-form.js.map +1 -1
- package/dist/auth/sign-in-form.d.ts +61 -9
- package/dist/auth/sign-in-form.js +94 -13
- package/dist/auth/sign-in-form.js.map +1 -1
- package/dist/auth/verify-email.d.ts +7 -2
- package/dist/auth/verify-email.js +44 -8
- package/dist/auth/verify-email.js.map +1 -1
- package/dist/chart.d.ts +16 -11
- package/dist/components/account-chips.d.ts +47 -7
- package/dist/components/account-chips.js +19 -3
- package/dist/components/account-chips.js.map +1 -1
- package/dist/components/account-settings-labels.d.ts +12 -1
- package/dist/components/account-settings-labels.js +4 -1
- package/dist/components/account-settings-labels.js.map +1 -1
- package/dist/components/account-settings.d.ts +61 -6
- package/dist/components/account-settings.js +115 -15
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +17 -12
- package/dist/components/button-group.d.ts +17 -12
- package/dist/components/calculator.d.ts +17 -12
- package/dist/components/confirm-dialog.d.ts +17 -12
- package/dist/components/copy-button.d.ts +14 -9
- package/dist/components/danger-confirm.d.ts +17 -12
- package/dist/components/facing-pair.d.ts +17 -12
- package/dist/components/file-button.d.ts +17 -12
- package/dist/components/file-dropzone.d.ts +17 -12
- package/dist/components/form-actions.d.ts +17 -12
- package/dist/components/iban-input.d.ts +17 -12
- package/dist/components/language-select.d.ts +17 -12
- package/dist/components/legal-page.d.ts +17 -12
- package/dist/components/legal.d.ts +17 -12
- package/dist/components/money-field.d.ts +17 -12
- package/dist/components/number-field.d.ts +17 -12
- package/dist/components/number-input.d.ts +17 -12
- package/dist/components/numpad-sheet.d.ts +17 -12
- package/dist/components/phone-input.d.ts +17 -12
- package/dist/components/series-chart.d.ts +17 -12
- package/dist/components/settings-fields.d.ts +16 -11
- package/dist/components/share-card.d.ts +16 -11
- package/dist/components/text-link.d.ts +17 -12
- package/dist/components/time-input.d.ts +17 -12
- package/dist/components/ui.d.ts +13 -8
- package/dist/{register-form-V1OeNlMr.d.ts → delete-account-setting-CGVMckMw.d.ts} +6616 -5645
- package/dist/feedback/feedback-attachment.d.ts +17 -12
- package/dist/feedback/feedback-context.d.ts +17 -12
- package/dist/feedback/feedback-crash.d.ts +17 -12
- package/dist/feedback/feedback-dialog.d.ts +17 -12
- package/dist/feedback/feedback-inbox.d.ts +17 -12
- package/dist/feedback/feedback-labels.d.ts +17 -12
- package/dist/feedback/feedback-menu.d.ts +17 -12
- package/dist/feedback/feedback-record.d.ts +17 -12
- package/dist/feedback/feedback-row-detail.d.ts +17 -12
- package/dist/feedback/feedback-status-undo.d.ts +17 -12
- package/dist/feedback/feedback-submit.d.ts +17 -12
- package/dist/feedback/feedback-swipe.d.ts +17 -12
- package/dist/feedback/feedback-table.d.ts +14 -9
- package/dist/feedback/feedback-thread.d.ts +17 -12
- package/dist/feedback.d.ts +17 -12
- package/dist/hooks/use-anchored-panel.d.ts +6 -2
- package/dist/hooks/use-anchored-panel.js +2 -1
- package/dist/hooks/use-anchored-panel.js.map +1 -1
- package/dist/hooks/use-file-drop.d.ts +17 -12
- package/dist/i18n/defaults.d.ts +17 -12
- package/dist/i18n/defaults.js +22 -0
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +17 -12
- package/dist/i18n/german.js +215 -11
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +10 -5
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +11 -6
- package/dist/i18n/locales/de-CH.d.ts +17 -12
- package/dist/i18n/locales/en.d.ts +17 -12
- package/dist/i18n/locales/es.d.ts +17 -12
- package/dist/i18n/locales/es.js +207 -9
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +17 -12
- package/dist/i18n/locales/fr.js +209 -6
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +17 -12
- package/dist/i18n/locales/hu.js +207 -11
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +17 -12
- package/dist/i18n/locales/it.js +209 -6
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +17 -12
- package/dist/i18n/locales/zh.js +200 -6
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +17 -12
- package/dist/i18n/review.js +37 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -1
- package/dist/rhf/fields.d.ts +17 -12
- package/dist/rhf/form.d.ts +17 -12
- package/dist/rhf.d.ts +17 -12
- package/dist/shell/app-shell.d.ts +17 -12
- package/dist/shell/top-bar-brand.d.ts +17 -12
- package/dist/shell.d.ts +11 -6
- package/dist/wizard/stepper-nav.d.ts +17 -12
- package/dist/wizard.d.ts +17 -12
- package/package.json +1 -1
- package/src/account/account-parts.ts +67 -0
- package/src/account/data-export-setting.tsx +218 -0
- package/src/account/delete-account-setting.tsx +362 -0
- package/src/account/email-change-setting.tsx +457 -0
- package/src/account/sessions-setting.tsx +283 -0
- package/src/admin/admin-action-confirm.tsx +495 -0
- package/src/admin/admin-action-log.tsx +297 -0
- package/src/admin/admin-parts.ts +82 -0
- package/src/admin/invitations-panel.tsx +516 -0
- package/src/admin/reviewer-scope-editor.tsx +234 -0
- package/src/admin/role-select.tsx +286 -0
- package/src/admin/transfer-ownership-dialog.tsx +172 -0
- package/src/admin/user-roster.tsx +573 -0
- package/src/auth/auth-errors.ts +165 -8
- package/src/auth/forgot-password-form.tsx +21 -5
- package/src/auth/register-form.tsx +24 -6
- package/src/auth/reset-password-form.tsx +19 -5
- package/src/auth/sign-in-form.tsx +207 -35
- package/src/auth/verify-email.tsx +59 -8
- package/src/components/account-chips.tsx +64 -7
- package/src/components/account-settings-labels.ts +15 -1
- package/src/components/account-settings.tsx +199 -23
- package/src/hooks/use-anchored-panel.ts +14 -3
- package/src/i18n/defaults.ts +22 -0
- package/src/i18n/german.ts +241 -5
- package/src/i18n/kit-labels.tsx +33 -0
- package/src/i18n/locales/es.ts +230 -3
- package/src/i18n/locales/fr.ts +232 -0
- package/src/i18n/locales/hu.ts +224 -5
- package/src/i18n/locales/it.ts +230 -0
- package/src/i18n/locales/zh.ts +205 -0
- package/src/i18n/review.ts +36 -0
- package/src/index.ts +93 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { RefreshCw, Trash2, UserPlus } from "lucide-react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
|
|
7
|
+
import { KIT_LANGUAGES, resolveLanguage } from "../i18n/languages.js";
|
|
8
|
+
import { RoleChip } from "../components/account-chips.js";
|
|
9
|
+
import { AlertBanner } from "../components/alert-banner.js";
|
|
10
|
+
import { Chip } from "../components/chip.js";
|
|
11
|
+
import { CopyButton } from "../components/copy-button.js";
|
|
12
|
+
import { LanguageSelect } from "../components/language-select.js";
|
|
13
|
+
import { SectionLabel, Caption } from "../components/text.js";
|
|
14
|
+
import { Button, IconButton, Input, Select, Spinner } from "../components/ui.js";
|
|
15
|
+
import { useWriteLock } from "../components/write-lock.js";
|
|
16
|
+
import { hasMessage, settle, useDayText, usePersonLabel } from "./admin-parts.js";
|
|
17
|
+
import { RoleSelect } from "./role-select.js";
|
|
18
|
+
const DEFAULT_INVITATIONS_LABELS = {
|
|
19
|
+
email: "Email address",
|
|
20
|
+
invalidEmail: "Enter a complete email address.",
|
|
21
|
+
role: "Role",
|
|
22
|
+
scope: "Scope",
|
|
23
|
+
scopeNone: "None",
|
|
24
|
+
language: "Language of the invitation",
|
|
25
|
+
note: "Note",
|
|
26
|
+
invite: "Invite",
|
|
27
|
+
listTitle: "Invitations",
|
|
28
|
+
empty: "Nobody has been invited yet.",
|
|
29
|
+
loading: "Loading\u2026",
|
|
30
|
+
status: { open: "Open", accepted: "Accepted", expired: "Expired", revoked: "Revoked" },
|
|
31
|
+
sent: (date) => `Sent ${date}`,
|
|
32
|
+
expires: (date) => `Expires ${date}`,
|
|
33
|
+
invitedBy: (name) => `by ${name}`,
|
|
34
|
+
resend: (email) => `Send ${email} a new link`,
|
|
35
|
+
copyLink: "Copy invitation link",
|
|
36
|
+
revoke: (email) => `Revoke the invitation for ${email}`,
|
|
37
|
+
consoleHint: "Mail isn\u2019t sent on this server \u2014 it is written to the server log. Copy each invitation link from here and pass it on yourself: it is shown only once.",
|
|
38
|
+
linkReady: (email) => `The invitation link for ${email}, shown only this once:`,
|
|
39
|
+
notSent: (email) => `${email} is invited, but the mail couldn\u2019t be sent. Resend it.`,
|
|
40
|
+
failed: "That didn\u2019t work. Please try again."
|
|
41
|
+
};
|
|
42
|
+
const STATUS_TONES = {
|
|
43
|
+
open: "info",
|
|
44
|
+
accepted: "success",
|
|
45
|
+
expired: "warning",
|
|
46
|
+
revoked: "neutral"
|
|
47
|
+
};
|
|
48
|
+
const EMAIL_SHAPE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
49
|
+
const ALL_CODES = KIT_LANGUAGES.map((language) => language.code);
|
|
50
|
+
const FAILED = /* @__PURE__ */ Symbol("failed");
|
|
51
|
+
function InvitationsPanel({
|
|
52
|
+
invitations,
|
|
53
|
+
roles,
|
|
54
|
+
invitableRoles,
|
|
55
|
+
defaultRole,
|
|
56
|
+
scopes,
|
|
57
|
+
scopeRequired = false,
|
|
58
|
+
languages = ALL_CODES,
|
|
59
|
+
defaultLocale,
|
|
60
|
+
mailBackend,
|
|
61
|
+
onInvite,
|
|
62
|
+
onResend,
|
|
63
|
+
onRevoke,
|
|
64
|
+
loading = false,
|
|
65
|
+
describeError,
|
|
66
|
+
intro,
|
|
67
|
+
className,
|
|
68
|
+
labels: labelsProp
|
|
69
|
+
}) {
|
|
70
|
+
const labels = useKitLabels("invitations", DEFAULT_INVITATIONS_LABELS, labelsProp);
|
|
71
|
+
const kitLocale = useKitLocale();
|
|
72
|
+
const dayText = useDayText();
|
|
73
|
+
const nameOf = usePersonLabel();
|
|
74
|
+
const lock = useWriteLock();
|
|
75
|
+
const offered = invitableRoles ?? (roles ? Object.keys(roles) : []);
|
|
76
|
+
const [email, setEmail] = useState("");
|
|
77
|
+
const [invalid, setInvalid] = useState(false);
|
|
78
|
+
const [role, setRole] = useState(defaultRole ?? offered[0]);
|
|
79
|
+
const [scope, setScope] = useState("");
|
|
80
|
+
const [locale, setLocale] = useState(
|
|
81
|
+
() => resolveLanguage([defaultLocale, kitLocale], languages)
|
|
82
|
+
);
|
|
83
|
+
const [note, setNote] = useState("");
|
|
84
|
+
const [busy, setBusy] = useState(null);
|
|
85
|
+
const [failure, setFailure] = useState(null);
|
|
86
|
+
const [notice, setNotice] = useState(null);
|
|
87
|
+
const [links, setLinks] = useState({});
|
|
88
|
+
const [looseLink, setLooseLink] = useState(null);
|
|
89
|
+
const run = async (key, call) => {
|
|
90
|
+
setBusy(key);
|
|
91
|
+
setFailure(null);
|
|
92
|
+
setNotice(null);
|
|
93
|
+
try {
|
|
94
|
+
return await settle(call);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
const own = describeError?.(error);
|
|
97
|
+
setFailure(hasMessage(own) ? own : labels.failed);
|
|
98
|
+
return FAILED;
|
|
99
|
+
} finally {
|
|
100
|
+
setBusy(null);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const took = (answer, address2, id) => {
|
|
104
|
+
if (!answer) return;
|
|
105
|
+
const key = answer.id ?? id;
|
|
106
|
+
if (answer.link) {
|
|
107
|
+
if (key !== void 0) setLinks((known) => ({ ...known, [String(key)]: answer.link }));
|
|
108
|
+
else setLooseLink({ email: address2, link: answer.link });
|
|
109
|
+
}
|
|
110
|
+
if (answer.sent === false) setNotice(labels.notSent(address2));
|
|
111
|
+
};
|
|
112
|
+
const address = email.trim();
|
|
113
|
+
const choosesRole = roles !== void 0 && offered.length > 1;
|
|
114
|
+
const canInvite = onInvite !== void 0;
|
|
115
|
+
const submit = async (event) => {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
if (!onInvite || busy || lock.locked || address === "") return;
|
|
118
|
+
if (!EMAIL_SHAPE.test(address)) {
|
|
119
|
+
setInvalid(true);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (scopes && scopeRequired && scope === "") return;
|
|
123
|
+
const draft = {
|
|
124
|
+
email: address,
|
|
125
|
+
locale,
|
|
126
|
+
...role !== void 0 && roles !== void 0 ? { role } : {},
|
|
127
|
+
...scope !== "" ? { scope } : {},
|
|
128
|
+
...note.trim() !== "" ? { note: note.trim() } : {}
|
|
129
|
+
};
|
|
130
|
+
const answer = await run("invite", () => onInvite(draft));
|
|
131
|
+
if (answer === FAILED) return;
|
|
132
|
+
took(answer, address);
|
|
133
|
+
setEmail("");
|
|
134
|
+
setNote("");
|
|
135
|
+
};
|
|
136
|
+
const scopeLabel = (value) => value === null || value === void 0 || value === "" ? null : scopes?.find((s) => s.value === String(value))?.label ?? String(value);
|
|
137
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-3", className), children: [
|
|
138
|
+
intro && /* @__PURE__ */ jsx("div", { className: "text-sm text-[var(--text-secondary)]", children: intro }),
|
|
139
|
+
mailBackend === "console" && /* @__PURE__ */ jsx(AlertBanner, { tone: "info", size: "sm", children: labels.consoleHint }),
|
|
140
|
+
canInvite && /* @__PURE__ */ jsxs("form", { noValidate: true, onSubmit: submit, className: "@container space-y-2", children: [
|
|
141
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2 @md:grid-cols-2", children: [
|
|
142
|
+
/* @__PURE__ */ jsx(
|
|
143
|
+
Input,
|
|
144
|
+
{
|
|
145
|
+
label: labels.email,
|
|
146
|
+
type: "email",
|
|
147
|
+
inputMode: "email",
|
|
148
|
+
autoComplete: "off",
|
|
149
|
+
autoCapitalize: "none",
|
|
150
|
+
spellCheck: false,
|
|
151
|
+
required: true,
|
|
152
|
+
value: email,
|
|
153
|
+
error: invalid ? labels.invalidEmail : void 0,
|
|
154
|
+
"data-private": true,
|
|
155
|
+
onChange: (event) => {
|
|
156
|
+
setInvalid(false);
|
|
157
|
+
setEmail(event.target.value);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
choosesRole && /* @__PURE__ */ jsx(
|
|
162
|
+
RoleSelect,
|
|
163
|
+
{
|
|
164
|
+
label: labels.role,
|
|
165
|
+
value: role,
|
|
166
|
+
roles,
|
|
167
|
+
offered,
|
|
168
|
+
onChange: setRole
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
scopes && scopes.length > 0 && /* @__PURE__ */ jsxs(
|
|
172
|
+
Select,
|
|
173
|
+
{
|
|
174
|
+
label: labels.scope,
|
|
175
|
+
value: scope,
|
|
176
|
+
required: scopeRequired,
|
|
177
|
+
onChange: (event) => setScope(event.target.value),
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsx("option", { value: "", disabled: scopeRequired, children: labels.scopeNone }),
|
|
180
|
+
scopes.map((s) => /* @__PURE__ */ jsx("option", { value: s.value, children: s.label }, s.value))
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
languages.length > 1 && /* @__PURE__ */ jsx(LanguageSelect, { label: labels.language, codes: languages, value: locale, onChange: setLocale }),
|
|
185
|
+
/* @__PURE__ */ jsx(
|
|
186
|
+
Input,
|
|
187
|
+
{
|
|
188
|
+
label: labels.note,
|
|
189
|
+
value: note,
|
|
190
|
+
maxLength: 255,
|
|
191
|
+
onChange: (event) => setNote(event.target.value),
|
|
192
|
+
className: "@md:col-span-2"
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxs(
|
|
197
|
+
Button,
|
|
198
|
+
{
|
|
199
|
+
type: "submit",
|
|
200
|
+
variant: "brand",
|
|
201
|
+
commit: true,
|
|
202
|
+
pending: busy === "invite",
|
|
203
|
+
disabled: busy !== null || address === "" || scopeRequired && scopes !== void 0 && scope === "",
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ jsx(UserPlus, { className: "size-4", "aria-hidden": true }),
|
|
206
|
+
labels.invite
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
) })
|
|
210
|
+
] }),
|
|
211
|
+
failure && /* @__PURE__ */ jsx(AlertBanner, { tone: "danger", size: "sm", children: failure }),
|
|
212
|
+
notice && /* @__PURE__ */ jsx(AlertBanner, { tone: "warning", size: "sm", onDismiss: () => setNotice(null), children: notice }),
|
|
213
|
+
looseLink && /* @__PURE__ */ jsx(AlertBanner, { tone: "info", size: "sm", onDismiss: () => setLooseLink(null), children: /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [
|
|
214
|
+
/* @__PURE__ */ jsx("span", { "data-private": true, children: labels.linkReady(looseLink.email) }),
|
|
215
|
+
/* @__PURE__ */ jsx("code", { className: "min-w-0 break-all text-xs", children: looseLink.link }),
|
|
216
|
+
/* @__PURE__ */ jsx(CopyButton, { size: "xs", text: looseLink.link, label: labels.copyLink })
|
|
217
|
+
] }) }),
|
|
218
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
219
|
+
/* @__PURE__ */ jsx(SectionLabel, { as: "h4", children: labels.listTitle }),
|
|
220
|
+
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
|
+
const key = String(invitation.id);
|
|
222
|
+
const link = invitation.link ?? links[key];
|
|
223
|
+
const open = invitation.status === "open";
|
|
224
|
+
const resendable = onResend && (open || invitation.status === "expired");
|
|
225
|
+
const revocable = onRevoke && open;
|
|
226
|
+
const scopeText = scopeLabel(invitation.scope);
|
|
227
|
+
const by = typeof invitation.invited_by === "string" ? invitation.invited_by : nameOf(invitation.invited_by);
|
|
228
|
+
const facts = [
|
|
229
|
+
dayText(invitation.created_at) && labels.sent(dayText(invitation.created_at)),
|
|
230
|
+
open && dayText(invitation.expires_at ?? null) && labels.expires(dayText(invitation.expires_at ?? null)),
|
|
231
|
+
by && labels.invitedBy(by)
|
|
232
|
+
].filter(Boolean);
|
|
233
|
+
return /* @__PURE__ */ jsx("li", { "data-status": invitation.status, className: "py-2 first:pt-0 last:pb-0", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5", children: [
|
|
234
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 basis-48 space-y-1", children: [
|
|
235
|
+
/* @__PURE__ */ jsx("div", { "data-private": true, className: "truncate text-sm font-medium text-[var(--text-primary)]", children: invitation.email }),
|
|
236
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
237
|
+
/* @__PURE__ */ jsx(Chip, { size: "xs", shape: "square", caps: true, tone: STATUS_TONES[invitation.status], children: labels.status[invitation.status] }),
|
|
238
|
+
roles && invitation.role && /* @__PURE__ */ jsx(RoleChip, { value: invitation.role, roles, size: "xs" }),
|
|
239
|
+
scopeText && /* @__PURE__ */ jsx(Chip, { size: "xs", shape: "square", children: scopeText })
|
|
240
|
+
] }),
|
|
241
|
+
(facts.length > 0 || invitation.note) && /* @__PURE__ */ jsxs("div", { className: "text-xs text-[var(--text-muted)]", children: [
|
|
242
|
+
facts.join(" \xB7 "),
|
|
243
|
+
invitation.note && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
244
|
+
facts.length > 0 && " \xB7 ",
|
|
245
|
+
/* @__PURE__ */ jsx("span", { "data-private": true, children: invitation.note })
|
|
246
|
+
] })
|
|
247
|
+
] })
|
|
248
|
+
] }),
|
|
249
|
+
(link || resendable || revocable) && /* @__PURE__ */ jsxs("div", { className: "ms-auto flex shrink-0 items-center gap-1", children: [
|
|
250
|
+
link && open && /* @__PURE__ */ jsx(CopyButton, { size: "xs", tone: "muted", text: link, label: labels.copyLink }),
|
|
251
|
+
resendable && /* @__PURE__ */ jsx(
|
|
252
|
+
IconButton,
|
|
253
|
+
{
|
|
254
|
+
size: "xs",
|
|
255
|
+
commit: true,
|
|
256
|
+
label: labels.resend(invitation.email),
|
|
257
|
+
pending: busy === `resend:${key}`,
|
|
258
|
+
disabled: busy !== null,
|
|
259
|
+
onClick: async () => {
|
|
260
|
+
const answer = await run(`resend:${key}`, () => onResend(invitation));
|
|
261
|
+
if (answer !== FAILED) took(answer, invitation.email, invitation.id);
|
|
262
|
+
},
|
|
263
|
+
children: /* @__PURE__ */ jsx(RefreshCw, {})
|
|
264
|
+
}
|
|
265
|
+
),
|
|
266
|
+
revocable && /* @__PURE__ */ jsx(
|
|
267
|
+
IconButton,
|
|
268
|
+
{
|
|
269
|
+
size: "xs",
|
|
270
|
+
tone: "danger",
|
|
271
|
+
commit: true,
|
|
272
|
+
label: labels.revoke(invitation.email),
|
|
273
|
+
pending: busy === `revoke:${key}`,
|
|
274
|
+
disabled: busy !== null,
|
|
275
|
+
onClick: () => void run(`revoke:${key}`, () => onRevoke(invitation)),
|
|
276
|
+
children: /* @__PURE__ */ jsx(Trash2, {})
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
] })
|
|
280
|
+
] }) }, key);
|
|
281
|
+
}) })
|
|
282
|
+
] })
|
|
283
|
+
] });
|
|
284
|
+
}
|
|
285
|
+
export {
|
|
286
|
+
DEFAULT_INVITATIONS_LABELS,
|
|
287
|
+
InvitationsPanel
|
|
288
|
+
};
|
|
289
|
+
//# sourceMappingURL=invitations-panel.js.map
|
|
@@ -0,0 +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,UAAU,YAAY,SAAS,WAAW,SAAS,UAAU;AAAA,EACrF,MAAM,CAAC,SAAS,QAAQ,IAAI;AAAA,EAC5B,SAAS,CAAC,SAAS,WAAW,IAAI;AAAA,EAClC,WAAW,CAAC,SAAS,MAAM,IAAI;AAAA,EAC/B,QAAQ,CAAC,UAAU,QAAQ,KAAK;AAAA,EAChC,UAAU;AAAA,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A,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"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
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-CGVMckMw.js';
|
|
3
|
+
import './admin-parts.js';
|
|
4
|
+
import '../components/tooltip.js';
|
|
5
|
+
import '../hooks/use-anchored-rect.js';
|
|
6
|
+
import '../lib/clipping.js';
|
|
7
|
+
import '../data-table-labels-DUELeXpa.js';
|
|
8
|
+
import '../components/data-table-sort.js';
|
|
9
|
+
import '../components/swipeable-row.js';
|
|
10
|
+
import '../components/mini-calendar.js';
|
|
11
|
+
import '../components/calendar-heatmap.js';
|
|
12
|
+
import '../components/popover.js';
|
|
13
|
+
import '../components/chip.js';
|
|
14
|
+
import 'lucide-react';
|
|
15
|
+
import '../components/field-sync.js';
|
|
16
|
+
import '../wizard/types.js';
|
|
17
|
+
import '../tour/tour.js';
|
|
18
|
+
import '../search/command-palette.js';
|
|
19
|
+
import '../search/global-search.js';
|
|
20
|
+
import '../search/search-index.js';
|
|
21
|
+
import '../components/month-picker.js';
|
|
22
|
+
import '../components/page-contents.js';
|
|
23
|
+
import '../components/series-chart-labels.js';
|
|
24
|
+
import '../components/pie-chart-labels.js';
|
|
25
|
+
import '../components/sparkline.js';
|
|
26
|
+
import '../components/stat-tile.js';
|
|
27
|
+
import '../components/signature-pad.js';
|
|
28
|
+
import '../components/password-strength.js';
|
|
29
|
+
import '../components/swatch-picker.js';
|
|
30
|
+
import '../components/tile-radio.js';
|
|
31
|
+
import '../components/icon-picker.js';
|
|
32
|
+
import '../components/dialog-frame.js';
|
|
33
|
+
import '../components/modal.js';
|
|
34
|
+
import '../hooks/use-search-param-state.js';
|
|
35
|
+
import '../components/measured-grid.js';
|
|
36
|
+
import '../components/user-avatar.js';
|
|
37
|
+
import '../lib/person-name.js';
|
|
38
|
+
import '../components/status-dot.js';
|
|
39
|
+
import '../components/progress-bar.js';
|
|
40
|
+
import '../components/signed-amount.js';
|
|
41
|
+
import '../shell/topbar-action-menu.js';
|
|
42
|
+
import '../components/menu-item.js';
|
|
43
|
+
import '../components/floating-panel.js';
|
|
44
|
+
import '../hooks/use-authed-src.js';
|
|
45
|
+
import '../components/account-settings-labels.js';
|
|
46
|
+
import '../components/bulk-action-bar.js';
|
|
47
|
+
import '../components/list.js';
|
|
48
|
+
import '../components/breadcrumbs.js';
|
|
49
|
+
import '../components/toast.js';
|
|
50
|
+
import '../components/description-list.js';
|
|
51
|
+
import '../components/line-items.js';
|
|
52
|
+
import '../components/error-boundary.js';
|
|
53
|
+
import '../components/authed-image.js';
|
|
54
|
+
import '../components/image-grid.js';
|
|
55
|
+
import '../components/lightbox.js';
|
|
56
|
+
import '../components/write-lock.js';
|
|
57
|
+
import '../auth/sign-in-form.js';
|
|
58
|
+
import '../shell/topbar-controls.js';
|
|
59
|
+
import '../theme/palette-presets.js';
|
|
60
|
+
import '../theme/chart-palette.js';
|
|
61
|
+
import '../theme/theme-store.js';
|
|
62
|
+
import 'zustand/middleware';
|
|
63
|
+
import 'zustand';
|
|
64
|
+
import '../auth/complete-name-dialog.js';
|
|
65
|
+
import '../auth/forgot-password-form.js';
|
|
66
|
+
import '../auth/status-parts.js';
|
|
67
|
+
import '../auth/reset-password-form.js';
|
|
68
|
+
import '../auth/verify-email.js';
|
|
69
|
+
import '../auth/not-found-page.js';
|
|
70
|
+
import '../auth/accept-invitation.js';
|
|
71
|
+
import '../shell/company-switcher.js';
|
|
72
|
+
import '../account/email-change-setting.js';
|
|
73
|
+
import '../account/sessions-setting.js';
|
|
74
|
+
import '../lib/format.js';
|
|
75
|
+
import '../account/data-export-setting.js';
|
|
76
|
+
import '../components/account-chips.js';
|
|
77
|
+
import './admin-action-log.js';
|
|
78
|
+
import '../components/reauth-dialog.js';
|
|
79
|
+
import '../components/server-wake.js';
|
|
80
|
+
import '../lib/server-wake.js';
|
|
81
|
+
import '../components/translation-review-labels.js';
|
|
82
|
+
import '../lib/translation-review.js';
|
|
83
|
+
import '../components/country-select.js';
|
|
84
|
+
import '../components/inline-edit-field.js';
|
|
85
|
+
import '../lib/iban.js';
|
|
86
|
+
import '../lib/phone.js';
|
|
87
|
+
import '../components/sign-chip.js';
|
|
88
|
+
import '../components/column-mapper.js';
|
|
89
|
+
import '../lib/column-mapping.js';
|
|
90
|
+
import '../lib/table-text.js';
|
|
91
|
+
import '../components/field-parts.js';
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
5
|
+
import { KIT_LANGUAGES } from "../i18n/languages.js";
|
|
6
|
+
import { AlertBanner } from "../components/alert-banner.js";
|
|
7
|
+
import { CheckboxGroup } from "../components/checkbox-group.js";
|
|
8
|
+
import { FormActions } from "../components/form-actions.js";
|
|
9
|
+
import { Caption } from "../components/text.js";
|
|
10
|
+
import { hasMessage } from "./admin-parts.js";
|
|
11
|
+
const DEFAULT_REVIEWER_SCOPE_LABELS = {
|
|
12
|
+
languages: "Languages",
|
|
13
|
+
hint: "Tick the languages this person reviews.",
|
|
14
|
+
none: "No language: saving takes the reviewer role away.",
|
|
15
|
+
areas: "Limit to",
|
|
16
|
+
legalOnly: "Only the legal pages",
|
|
17
|
+
legalOnlyHint: "Imprint, Privacy Policy and Terms \u2014 for a lawyer rather than a native speaker.",
|
|
18
|
+
failed: "The reviewer scope couldn\u2019t be saved. Please try again."
|
|
19
|
+
};
|
|
20
|
+
function languageOptions(languages) {
|
|
21
|
+
const rows = languages ?? KIT_LANGUAGES.map((language) => language.code);
|
|
22
|
+
return rows.map((row) => {
|
|
23
|
+
if (typeof row !== "string") return { value: row.value, label: row.label };
|
|
24
|
+
const language = KIT_LANGUAGES.find((entry) => entry.code === row);
|
|
25
|
+
return {
|
|
26
|
+
value: row,
|
|
27
|
+
// Each name in its own language, marked so a screen reader says it so.
|
|
28
|
+
label: language ? /* @__PURE__ */ jsx("span", { lang: language.formatLocale, children: language.nativeName }) : row
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function sameSet(a, b) {
|
|
33
|
+
if (a.length !== b.length) return false;
|
|
34
|
+
const seen = new Set(a);
|
|
35
|
+
return b.every((x) => seen.has(x));
|
|
36
|
+
}
|
|
37
|
+
function ReviewerScopeEditor({
|
|
38
|
+
value,
|
|
39
|
+
onSave,
|
|
40
|
+
onCancel,
|
|
41
|
+
languages,
|
|
42
|
+
areas: areasProp,
|
|
43
|
+
disabledReason,
|
|
44
|
+
describeError,
|
|
45
|
+
intro,
|
|
46
|
+
columns = 2,
|
|
47
|
+
commit,
|
|
48
|
+
labels: labelsProp
|
|
49
|
+
}) {
|
|
50
|
+
const labels = useKitLabels("reviewerScope", DEFAULT_REVIEWER_SCOPE_LABELS, labelsProp);
|
|
51
|
+
const areaOptions = areasProp ?? [{ value: "legal", label: labels.legalOnly, hint: labels.legalOnlyHint }];
|
|
52
|
+
const savedLocales = [...value.locales ?? []];
|
|
53
|
+
const savedAreas = [...value.areas ?? []];
|
|
54
|
+
const [locales, setLocales] = useState(savedLocales);
|
|
55
|
+
const [areas, setAreas] = useState(savedAreas);
|
|
56
|
+
const [pending, setPending] = useState(false);
|
|
57
|
+
const [failure, setFailure] = useState(null);
|
|
58
|
+
const locked = hasMessage(disabledReason);
|
|
59
|
+
const nextAreas = locales.length === 0 ? [] : areas;
|
|
60
|
+
const dirty = !sameSet(locales, savedLocales) || !sameSet(nextAreas, locales.length === 0 ? [] : savedAreas);
|
|
61
|
+
const save = () => {
|
|
62
|
+
if (pending || locked || !dirty) return;
|
|
63
|
+
const scope = {
|
|
64
|
+
locales,
|
|
65
|
+
areas: locales.length > 0 && areas.length > 0 ? areas : null
|
|
66
|
+
};
|
|
67
|
+
setFailure(null);
|
|
68
|
+
let result;
|
|
69
|
+
try {
|
|
70
|
+
result = onSave(scope);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
setFailure(describeError?.(error) ?? labels.failed);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!result || typeof result.then !== "function") return;
|
|
76
|
+
setPending(true);
|
|
77
|
+
result.then(
|
|
78
|
+
() => setPending(false),
|
|
79
|
+
(error) => {
|
|
80
|
+
setPending(false);
|
|
81
|
+
const own = describeError?.(error);
|
|
82
|
+
setFailure(hasMessage(own) ? own : labels.failed);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
87
|
+
intro && /* @__PURE__ */ jsx("div", { className: "text-sm text-[var(--text-secondary)]", children: intro }),
|
|
88
|
+
/* @__PURE__ */ jsx(
|
|
89
|
+
CheckboxGroup,
|
|
90
|
+
{
|
|
91
|
+
legend: labels.languages,
|
|
92
|
+
options: languageOptions(languages),
|
|
93
|
+
value: locales,
|
|
94
|
+
onChange: (next) => {
|
|
95
|
+
setFailure(null);
|
|
96
|
+
setLocales(next);
|
|
97
|
+
},
|
|
98
|
+
columns,
|
|
99
|
+
hint: locked ? void 0 : locales.length === 0 ? labels.none : labels.hint,
|
|
100
|
+
disabledReason
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
areaOptions.length > 0 && /* @__PURE__ */ jsx(
|
|
104
|
+
CheckboxGroup,
|
|
105
|
+
{
|
|
106
|
+
legend: labels.areas,
|
|
107
|
+
options: areaOptions.map((area) => ({ value: area.value, label: area.label, hint: area.hint })),
|
|
108
|
+
value: nextAreas,
|
|
109
|
+
onChange: (next) => {
|
|
110
|
+
setFailure(null);
|
|
111
|
+
setAreas(next);
|
|
112
|
+
},
|
|
113
|
+
disabled: locales.length === 0,
|
|
114
|
+
disabledReason
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
failure && /* @__PURE__ */ jsx(AlertBanner, { tone: "danger", size: "sm", children: failure }),
|
|
118
|
+
locked ? /* @__PURE__ */ jsx(Caption, { children: disabledReason }) : /* @__PURE__ */ jsx(
|
|
119
|
+
FormActions,
|
|
120
|
+
{
|
|
121
|
+
onSubmit: save,
|
|
122
|
+
onCancel,
|
|
123
|
+
pending,
|
|
124
|
+
submitDisabled: !dirty,
|
|
125
|
+
commit
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
] });
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
DEFAULT_REVIEWER_SCOPE_LABELS,
|
|
132
|
+
ReviewerScopeEditor
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=reviewer-scope-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/admin/reviewer-scope-editor.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { KIT_LANGUAGES } from \"../i18n/languages\";\nimport type { KitLanguageCode } from \"../i18n/languages\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { CheckboxGroup } from \"../components/checkbox-group\";\nimport type { CheckboxGroupOption } from \"../components/checkbox-group\";\nimport { FormActions } from \"../components/form-actions\";\nimport { Caption } from \"../components/text\";\nimport { hasMessage } from \"./admin-parts\";\nimport type { MaybePromise } from \"./admin-parts\";\n\n/**\n * Who may review which translations: the REVIEWER role and its scope, in one editor\n * (docs/user-admin-harmonization.md §4.1 `PUT /admin/users/{id}/reviewer {locales, areas}`,\n * §7). It replaces three: keksdose's `user-reviewer-role.tsx` (a checkbox per language,\n * saved on each click), Kurvenschmiede's `reviewer-dialog.tsx` (a `CheckboxGroup` in a\n * dialog with Save) and kastlan's platform column.\n *\n * - **Languages** are the scope. Ticking none takes the role away — that is how both\n * apps remove a reviewer — and the editor says so under the boxes.\n * - **Areas** narrow it: \"Only the legal pages\" (Imprint, Privacy Policy, Terms) for a\n * lawyer, who reads law, not French. An area only means something beside at least one\n * language, so the areas wait for one. Saved as `areas: null` when none is ticked —\n * server-kit's \"every area\" — never `[]`, which would be \"no area at all\".\n *\n * A draft with Save, not a save per click: keksdose saved every tick, and two quick ticks\n * could land as a set nobody chose; one Save sends the whole scope, in the languages'\n * order (CheckboxGroup's), so the answer equals the request and the row does not\n * reshuffle on refetch. The server keeps its rules (an admin reviews everything already,\n * a customer is not given the role): `disabledReason` says them here.\n */\n\n/** A reviewer's scope — the request body of `PUT …/reviewer`. */\nexport interface ReviewerScope {\n /** Language codes, in the editor's order. Empty: not a reviewer. */\n locales: string[];\n /** The areas the scope is narrowed to; `null` = every area (server-kit's rule). */\n areas: string[] | null;\n}\n\n/** One area the scope can be narrowed to. */\nexport interface ReviewerScopeArea {\n value: string;\n label: ReactNode;\n hint?: ReactNode;\n}\n\n/** One language the editor offers, when the app's list is not the kit's codes. */\nexport interface ReviewerScopeLanguage {\n value: string;\n label: ReactNode;\n}\n\n/** The `reviewerScope` namespace. */\nexport interface ReviewerScopeLabels {\n /** The language group's legend. */\n languages: string;\n /** Under the languages. */\n hint: string;\n /** Under the languages while none is ticked. */\n none: string;\n /** The area group's legend. */\n areas: string;\n /** The default area, `legal`. */\n legalOnly: string;\n legalOnlyHint: string;\n /** A rejected save, unless `describeError` says better. */\n failed: string;\n}\n\nexport const DEFAULT_REVIEWER_SCOPE_LABELS: ReviewerScopeLabels = {\n languages: \"Languages\",\n hint: \"Tick the languages this person reviews.\",\n none: \"No language: saving takes the reviewer role away.\",\n areas: \"Limit to\",\n legalOnly: \"Only the legal pages\",\n legalOnlyHint: \"Imprint, Privacy Policy and Terms — for a lawyer rather than a native speaker.\",\n failed: \"The reviewer scope couldn’t be saved. Please try again.\",\n};\n\nexport interface ReviewerScopeEditorProps {\n /** The scope the server has — the draft starts from it. Key the editor by the\n * account (`key={user.id}`) so another account starts a fresh draft. */\n value: { locales?: readonly string[] | null; areas?: readonly string[] | null };\n /** Sends the scope. A promise keeps the editor busy, and a rejection keeps the draft\n * and shows why. */\n onSave: (scope: ReviewerScope) => MaybePromise;\n /** A Cancel beside Save — a dialog's way out. */\n onCancel?: () => void;\n /**\n * The languages offered: kit codes (named by the kit's registry, each in its own\n * language — \"Deutsch\", \"Français\") or the app's own `{ value, label }` rows. Default:\n * all seven of the kit's.\n */\n languages?: readonly KitLanguageCode[] | readonly ReviewerScopeLanguage[];\n /** The areas the scope can be narrowed to. Default: `legal` alone. `[]` for none. */\n areas?: readonly ReviewerScopeArea[];\n /** Why the scope cannot be changed for this account (\"Administrators review every\n * language already\"). Every box says it; there is no Save. */\n disabledReason?: ReactNode;\n /** The app's words for a failed save. */\n describeError?: (error: unknown) => ReactNode | undefined;\n /** Over the languages: what the role is, in the app's words. */\n intro?: ReactNode;\n /** Columns for the languages from `sm` up. Default 2 (Kurvenschmiede's dialog). */\n columns?: 1 | 2 | 3 | 4;\n /** Save COMMITS: under a locked `WriteLockProvider` it is held with the lock's reason. */\n commit?: boolean;\n labels?: Partial<ReviewerScopeLabels>;\n}\n\nfunction languageOptions(languages: ReviewerScopeEditorProps[\"languages\"]): CheckboxGroupOption[] {\n const rows = languages ?? KIT_LANGUAGES.map((language) => language.code);\n return rows.map((row) => {\n if (typeof row !== \"string\") return { value: row.value, label: row.label };\n const language = KIT_LANGUAGES.find((entry) => entry.code === row);\n return {\n value: row,\n // Each name in its own language, marked so a screen reader says it so.\n label: language ? <span lang={language.formatLocale}>{language.nativeName}</span> : row,\n };\n });\n}\n\n/** The same set, regardless of order. */\nfunction sameSet(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n const seen = new Set(a);\n return b.every((x) => seen.has(x));\n}\n\nexport function ReviewerScopeEditor({\n value,\n onSave,\n onCancel,\n languages,\n areas: areasProp,\n disabledReason,\n describeError,\n intro,\n columns = 2,\n commit,\n labels: labelsProp,\n}: ReviewerScopeEditorProps) {\n const labels = useKitLabels(\"reviewerScope\", DEFAULT_REVIEWER_SCOPE_LABELS, labelsProp);\n const areaOptions: readonly ReviewerScopeArea[] =\n areasProp ?? [{ value: \"legal\", label: labels.legalOnly, hint: labels.legalOnlyHint }];\n const savedLocales = [...(value.locales ?? [])];\n const savedAreas = [...(value.areas ?? [])];\n const [locales, setLocales] = useState<string[]>(savedLocales);\n const [areas, setAreas] = useState<string[]>(savedAreas);\n const [pending, setPending] = useState(false);\n const [failure, setFailure] = useState<ReactNode>(null);\n const locked = hasMessage(disabledReason);\n\n const nextAreas = locales.length === 0 ? [] : areas;\n const dirty = !sameSet(locales, savedLocales) || !sameSet(nextAreas, locales.length === 0 ? [] : savedAreas);\n\n const save = () => {\n if (pending || locked || !dirty) return;\n const scope: ReviewerScope = {\n locales,\n areas: locales.length > 0 && areas.length > 0 ? areas : null,\n };\n setFailure(null);\n let result: MaybePromise;\n try {\n result = onSave(scope);\n } catch (error) {\n setFailure(describeError?.(error) ?? labels.failed);\n return;\n }\n if (!result || typeof result.then !== \"function\") return;\n setPending(true);\n result.then(\n () => setPending(false),\n (error: unknown) => {\n setPending(false);\n const own = describeError?.(error);\n setFailure(hasMessage(own) ? own : labels.failed);\n },\n );\n };\n\n return (\n <div className=\"space-y-3\">\n {intro && <div className=\"text-sm text-[var(--text-secondary)]\">{intro}</div>}\n <CheckboxGroup\n legend={labels.languages}\n options={languageOptions(languages)}\n value={locales}\n onChange={(next) => {\n setFailure(null);\n setLocales(next);\n }}\n columns={columns}\n hint={locked ? undefined : locales.length === 0 ? labels.none : labels.hint}\n disabledReason={disabledReason}\n />\n {areaOptions.length > 0 && (\n <CheckboxGroup\n legend={labels.areas}\n options={areaOptions.map((area) => ({ value: area.value, label: area.label, hint: area.hint }))}\n value={nextAreas}\n onChange={(next) => {\n setFailure(null);\n setAreas(next);\n }}\n // An area narrows a language scope; with no language there is none to narrow.\n disabled={locales.length === 0}\n disabledReason={disabledReason}\n />\n )}\n {failure && (\n <AlertBanner tone=\"danger\" size=\"sm\">\n {failure}\n </AlertBanner>\n )}\n {locked ? (\n <Caption>{disabledReason}</Caption>\n ) : (\n <FormActions\n onSubmit={save}\n onCancel={onCancel}\n pending={pending}\n submitDisabled={!dirty}\n commit={commit}\n />\n )}\n </div>\n );\n}\n"],"mappings":";AAyHwB,cAkEpB,YAlEoB;AAzHxB,SAAS,gBAAgB;AAEzB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAE9B,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAE9B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AA8DpB,MAAM,gCAAqD;AAAA,EAChE,WAAW;AAAA,EACX,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,WAAW;AAAA,EACX,eAAe;AAAA,EACf,QAAQ;AACV;AAiCA,SAAS,gBAAgB,WAAyE;AAChG,QAAM,OAAO,aAAa,cAAc,IAAI,CAAC,aAAa,SAAS,IAAI;AACvE,SAAO,KAAK,IAAI,CAAC,QAAQ;AACvB,QAAI,OAAO,QAAQ,SAAU,QAAO,EAAE,OAAO,IAAI,OAAO,OAAO,IAAI,MAAM;AACzE,UAAM,WAAW,cAAc,KAAK,CAAC,UAAU,MAAM,SAAS,GAAG;AACjE,WAAO;AAAA,MACL,OAAO;AAAA;AAAA,MAEP,OAAO,WAAW,oBAAC,UAAK,MAAM,SAAS,cAAe,mBAAS,YAAW,IAAU;AAAA,IACtF;AAAA,EACF,CAAC;AACH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