@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,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { MonitorSmartphone } from "lucide-react";
|
|
5
|
+
import { useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { formatRelativeTime, toDate } from "../lib/format.js";
|
|
8
|
+
import { AlertBanner } from "../components/alert-banner.js";
|
|
9
|
+
import { Chip } from "../components/chip.js";
|
|
10
|
+
import { hasMessage } from "../components/choice-parts.js";
|
|
11
|
+
import { DangerConfirm } from "../components/danger-confirm.js";
|
|
12
|
+
import { Skeleton } from "../components/skeleton.js";
|
|
13
|
+
import { Button, Card } from "../components/ui.js";
|
|
14
|
+
import { CARD_DESCRIPTION_CLASS, CARD_TITLE_CLASS, settle, useMounted } from "./account-parts.js";
|
|
15
|
+
const DEFAULT_SESSIONS_LABELS = {
|
|
16
|
+
title: "Sessions",
|
|
17
|
+
description: "Signed in on a device you no longer use, or don\u2019t trust? Sign out everywhere.",
|
|
18
|
+
signOutEverywhere: "Sign out everywhere\u2026",
|
|
19
|
+
signOutEverywherePrompt: "This ends every session, including this one: you will be signed out on this device too, and sign in again from here.",
|
|
20
|
+
confirmSignOutEverywhere: "Sign out everywhere",
|
|
21
|
+
list: "Where you\u2019re signed in",
|
|
22
|
+
loading: "Loading sessions\u2026",
|
|
23
|
+
empty: "No sessions to show.",
|
|
24
|
+
current: "This device",
|
|
25
|
+
unknownDevice: "Unknown device",
|
|
26
|
+
lastActive: (when) => `Last active ${when}`,
|
|
27
|
+
ip: (address) => `IP ${address}`,
|
|
28
|
+
revoke: "Sign out",
|
|
29
|
+
revokeItem: (device) => `Sign out ${device}`,
|
|
30
|
+
failed: "That didn\u2019t work. Please try again."
|
|
31
|
+
};
|
|
32
|
+
function SessionsSetting({
|
|
33
|
+
onSignOutEverywhere,
|
|
34
|
+
sessions,
|
|
35
|
+
loading,
|
|
36
|
+
onRevoke,
|
|
37
|
+
describeError,
|
|
38
|
+
formatLastActive,
|
|
39
|
+
locale: localeProp,
|
|
40
|
+
labels: labelsProp,
|
|
41
|
+
className,
|
|
42
|
+
...rest
|
|
43
|
+
}) {
|
|
44
|
+
const labels = useKitLabels("sessions", DEFAULT_SESSIONS_LABELS, labelsProp);
|
|
45
|
+
const locale = useKitLocale(localeProp);
|
|
46
|
+
const [busyId, setBusyId] = useState(null);
|
|
47
|
+
const [failure, setFailure] = useState(null);
|
|
48
|
+
const mounted = useMounted();
|
|
49
|
+
const describe = (error, action) => {
|
|
50
|
+
const own = describeError?.(error, action);
|
|
51
|
+
return hasMessage(own) ? own : labels.failed;
|
|
52
|
+
};
|
|
53
|
+
const lastActive = (value) => {
|
|
54
|
+
const date = toDate(value);
|
|
55
|
+
if (!date) return null;
|
|
56
|
+
return formatLastActive ? formatLastActive(date) : formatRelativeTime(date, { locale, absoluteAfterDays: 7, absoluteStyle: "medium" });
|
|
57
|
+
};
|
|
58
|
+
const signOutEverywhere = () => {
|
|
59
|
+
setFailure(null);
|
|
60
|
+
return settle(onSignOutEverywhere).catch((error) => {
|
|
61
|
+
if (mounted.current) setFailure(describe(error, "sign-out-everywhere"));
|
|
62
|
+
throw error;
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const revoke = (id) => {
|
|
66
|
+
if (!onRevoke || busyId !== null) return;
|
|
67
|
+
setBusyId(id);
|
|
68
|
+
setFailure(null);
|
|
69
|
+
settle(() => onRevoke(id)).then(
|
|
70
|
+
() => {
|
|
71
|
+
if (mounted.current) setBusyId(null);
|
|
72
|
+
},
|
|
73
|
+
(error) => {
|
|
74
|
+
if (!mounted.current) return;
|
|
75
|
+
setBusyId(null);
|
|
76
|
+
setFailure(describe(error, "revoke"));
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
const showList = sessions !== void 0 || loading;
|
|
81
|
+
return /* @__PURE__ */ jsxs(Card, { ...rest, className: cn("p-4 space-y-3", className), children: [
|
|
82
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
83
|
+
/* @__PURE__ */ jsx("div", { className: CARD_TITLE_CLASS, children: labels.title }),
|
|
84
|
+
/* @__PURE__ */ jsx("div", { className: CARD_DESCRIPTION_CLASS, children: labels.description })
|
|
85
|
+
] }),
|
|
86
|
+
showList && (loading || sessions === void 0 ? /* @__PURE__ */ jsx(Skeleton, { lines: 2, label: labels.loading }) : sessions.length === 0 ? /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.empty }) : /* @__PURE__ */ jsx("ul", { "aria-label": labels.list, className: "divide-y divide-[var(--border)]", children: sessions.map((session) => {
|
|
87
|
+
const device = session.device?.trim() || labels.unknownDevice;
|
|
88
|
+
const when = lastActive(session.lastActiveAt);
|
|
89
|
+
const ip = session.ip?.trim();
|
|
90
|
+
return /* @__PURE__ */ jsxs(
|
|
91
|
+
"li",
|
|
92
|
+
{
|
|
93
|
+
"data-session-id": String(session.id),
|
|
94
|
+
"data-current": session.current || void 0,
|
|
95
|
+
className: "flex items-center gap-3 py-2",
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ jsx(MonitorSmartphone, { "aria-hidden": true, className: "size-4 shrink-0 text-[var(--text-muted)]" }),
|
|
98
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
99
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
100
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 break-words text-sm font-medium", children: device }),
|
|
101
|
+
session.current && /* @__PURE__ */ jsx(Chip, { size: "sm", tone: "brand", children: labels.current })
|
|
102
|
+
] }),
|
|
103
|
+
(when || ip) && /* @__PURE__ */ jsxs("div", { className: CARD_DESCRIPTION_CLASS, children: [
|
|
104
|
+
when && labels.lastActive(when),
|
|
105
|
+
when && ip && " \xB7 ",
|
|
106
|
+
ip && /* @__PURE__ */ jsx("span", { dir: "ltr", children: labels.ip(ip) })
|
|
107
|
+
] })
|
|
108
|
+
] }),
|
|
109
|
+
onRevoke && !session.current && /* @__PURE__ */ jsx(
|
|
110
|
+
Button,
|
|
111
|
+
{
|
|
112
|
+
type: "button",
|
|
113
|
+
size: "sm",
|
|
114
|
+
variant: "ghost",
|
|
115
|
+
commit: true,
|
|
116
|
+
pending: busyId === session.id,
|
|
117
|
+
disabled: busyId !== null && busyId !== session.id,
|
|
118
|
+
"aria-label": labels.revokeItem(device),
|
|
119
|
+
onClick: () => revoke(session.id),
|
|
120
|
+
children: labels.revoke
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
session.id
|
|
126
|
+
);
|
|
127
|
+
}) })),
|
|
128
|
+
/* @__PURE__ */ jsx(
|
|
129
|
+
DangerConfirm,
|
|
130
|
+
{
|
|
131
|
+
tone: "warning",
|
|
132
|
+
commit: true,
|
|
133
|
+
armLabel: labels.signOutEverywhere,
|
|
134
|
+
prompt: labels.signOutEverywherePrompt,
|
|
135
|
+
confirmLabel: labels.confirmSignOutEverywhere,
|
|
136
|
+
onConfirm: signOutEverywhere
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
hasMessage(failure) && /* @__PURE__ */ jsx(AlertBanner, { tone: "danger", size: "sm", role: "alert", children: failure })
|
|
140
|
+
] });
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
DEFAULT_SESSIONS_LABELS,
|
|
144
|
+
SessionsSetting
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=sessions-setting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/account/sessions-setting.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { MonitorSmartphone } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { formatRelativeTime, toDate } from \"../lib/format\";\nimport type { DateInput } from \"../lib/format\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Chip } from \"../components/chip\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport { DangerConfirm } from \"../components/danger-confirm\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { Button, Card } from \"../components/ui\";\nimport { CARD_DESCRIPTION_CLASS, CARD_TITLE_CLASS, settle, useMounted } from \"./account-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string {@link SessionsSetting} renders — the `sessions` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. The confirm's\n * Cancel is `dangerConfirm.cancel`. */\nexport interface SessionsLabels {\n /** The card's title. */\n title: string;\n /** The line under it: what \"sign out everywhere\" is for. */\n description: string;\n /** The button that asks first. */\n signOutEverywhere: string;\n /** The question it asks: every session ends, this one too. */\n signOutEverywherePrompt: string;\n /** The button that answers it. */\n confirmSignOutEverywhere: string;\n /** The device list's accessible name. */\n list: string;\n /** While the list loads. */\n loading: string;\n /** A list with no rows. */\n empty: string;\n /** The chip on the session this page runs in. */\n current: string;\n /** A session whose device the server could not name. */\n unknownDevice: string;\n /** Given the last activity, formatted (\"3 hours ago\", \"5 Oct 2026\"). */\n lastActive: (when: string) => string;\n /** Given the address the session was last seen from. */\n ip: (address: string) => string;\n /** A row's button, visible text. */\n revoke: string;\n /** The same button's accessible name, given the device — it starts with `revoke`,\n * the visible text, so voice control finds it by what it says. */\n revokeItem: (device: string) => string;\n /** A request failed. */\n failed: string;\n}\n\nexport const DEFAULT_SESSIONS_LABELS: SessionsLabels = {\n title: \"Sessions\",\n description: \"Signed in on a device you no longer use, or don’t trust? Sign out everywhere.\",\n signOutEverywhere: \"Sign out everywhere…\",\n signOutEverywherePrompt:\n \"This ends every session, including this one: you will be signed out on this device too, and sign in again from here.\",\n confirmSignOutEverywhere: \"Sign out everywhere\",\n list: \"Where you’re signed in\",\n loading: \"Loading sessions…\",\n empty: \"No sessions to show.\",\n current: \"This device\",\n unknownDevice: \"Unknown device\",\n lastActive: (when) => `Last active ${when}`,\n ip: (address) => `IP ${address}`,\n revoke: \"Sign out\",\n revokeItem: (device) => `Sign out ${device}`,\n failed: \"That didn’t work. Please try again.\",\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\n/** What a session's `id` may be: the app's own key type. */\nexport type SessionId = string | number;\n\n/** One stored session (kastlan's `GET /auth/sessions`). */\nexport interface SessionItem<Id extends SessionId = SessionId> {\n id: Id;\n /** The browser and system, as the server reads them (\"Firefox on Windows\"). Blank\n * reads as `labels.unknownDevice`. */\n device?: string | null;\n /** The address it was last seen from. */\n ip?: string | null;\n /** A `Date`, an ISO string or epoch ms. */\n lastActiveAt?: DateInput;\n /** The session this page runs in: marked, and offered no \"Sign out\" of its own — the\n * app's sign-out does that, and \"Sign out everywhere\" below. */\n current?: boolean;\n}\n\n/** Which request failed — {@link SessionsSettingProps.describeError}'s second argument. */\nexport type SessionsAction = \"sign-out-everywhere\" | \"revoke\";\n\nexport interface SessionsSettingProps<Id extends SessionId = SessionId>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /**\n * End every session (`POST /auth/logout`, auth §6.3) — this one included. Asked\n * first; resolve once the server answered, then sign this page out: the card says\n * that the device signs out too, and its own session is gone.\n */\n onSignOutEverywhere: () => Promise<unknown> | void;\n /**\n * The stored sessions, where the app keeps them (kastlan's `user_sessions`, §6.3).\n * Left out, the card is \"Sign out everywhere\" alone — keksdose and Kurvenschmiede keep\n * a cut-off (`sessions_invalid_before`), not rows. `undefined` with `loading` while the\n * first load runs.\n */\n sessions?: readonly SessionItem<Id>[];\n /** The list is loading. */\n loading?: boolean;\n /** End one other session (`DELETE /auth/sessions/{id}`). Left out, no row buttons.\n * The row is busy until it settles; refresh `sessions` then. */\n onRevoke?: (id: Id) => Promise<unknown> | void;\n /** The app's own words for a failure, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown, action: SessionsAction) => ReactNode | undefined;\n /** The \"Last active\" text. Default: how long ago, in the provider's locale, and the\n * date once it is more than a week back. */\n formatLastActive?: (date: Date) => string;\n /** Overrides the provider's locale for the default format. */\n locale?: string;\n labels?: Partial<SessionsLabels>;\n}\n\n/**\n * Where the account is signed in, and the way out of all of it\n * (docs/user-admin-harmonization.md §6.3, §2.6).\n *\n * **\"Sign out everywhere\", in every app.** It ends every session, THIS one included —\n * the server stamps a cut-off (`sessions_invalid_before`) that the page's own token is\n * older than — so the confirm says so before it is pressed, and the app signs out once it\n * resolves. A {@link DangerConfirm} in the warning tone: nothing is lost, but the person\n * has to sign in again on every device. keksdose kept its ordinary sign-out device-only\n * (its offline mirror is wiped on an explicit sign-out), which is why this is an action\n * of its own, not a mode of that one.\n *\n * **The device list, where sessions are stored** (kastlan): device, address, last\n * active, and \"This device\" on the current one, with \"Sign out\" on each other row — no\n * confirm, since a session ended is a sign-in away from coming back, not data lost.\n * Without `sessions` there is no list: the other apps keep a cut-off, not rows.\n *\n * Both requests are the app's; a failure is said under the card's action, in the app's\n * words if `describeError` has them.\n */\nexport function SessionsSetting<Id extends SessionId = SessionId>({\n onSignOutEverywhere,\n sessions,\n loading,\n onRevoke,\n describeError,\n formatLastActive,\n locale: localeProp,\n labels: labelsProp,\n className,\n ...rest\n}: SessionsSettingProps<Id>) {\n const labels = useKitLabels(\"sessions\", DEFAULT_SESSIONS_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const [busyId, setBusyId] = useState<Id | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n\n const describe = (error: unknown, action: SessionsAction): ReactNode => {\n const own = describeError?.(error, action);\n return hasMessage(own) ? own : labels.failed;\n };\n\n const lastActive = (value: DateInput): string | null => {\n const date = toDate(value);\n if (!date) return null;\n return formatLastActive\n ? formatLastActive(date)\n : formatRelativeTime(date, { locale, absoluteAfterDays: 7, absoluteStyle: \"medium\" });\n };\n\n const signOutEverywhere = () => {\n setFailure(null);\n // Rejected again after it is said, so the tile stays armed for a retry.\n return settle(onSignOutEverywhere).catch((error: unknown) => {\n if (mounted.current) setFailure(describe(error, \"sign-out-everywhere\"));\n throw error;\n });\n };\n\n const revoke = (id: Id) => {\n if (!onRevoke || busyId !== null) return;\n setBusyId(id);\n setFailure(null);\n settle(() => onRevoke(id)).then(\n () => {\n if (mounted.current) setBusyId(null);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusyId(null);\n setFailure(describe(error, \"revoke\"));\n },\n );\n };\n\n const showList = sessions !== undefined || loading;\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <div className={CARD_TITLE_CLASS}>{labels.title}</div>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.description}</div>\n </div>\n {showList &&\n (loading || sessions === undefined ? (\n <Skeleton lines={2} label={labels.loading} />\n ) : sessions.length === 0 ? (\n <p className={CARD_DESCRIPTION_CLASS}>{labels.empty}</p>\n ) : (\n <ul aria-label={labels.list} className=\"divide-y divide-[var(--border)]\">\n {sessions.map((session) => {\n const device = session.device?.trim() || labels.unknownDevice;\n const when = lastActive(session.lastActiveAt);\n const ip = session.ip?.trim();\n return (\n <li\n key={session.id}\n data-session-id={String(session.id)}\n data-current={session.current || undefined}\n className=\"flex items-center gap-3 py-2\"\n >\n <MonitorSmartphone aria-hidden className=\"size-4 shrink-0 text-[var(--text-muted)]\" />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n <span className=\"min-w-0 break-words text-sm font-medium\">{device}</span>\n {session.current && (\n <Chip size=\"sm\" tone=\"brand\">\n {labels.current}\n </Chip>\n )}\n </div>\n {(when || ip) && (\n <div className={CARD_DESCRIPTION_CLASS}>\n {when && labels.lastActive(when)}\n {when && ip && \" · \"}\n {/* An address reads left to right in any page direction. */}\n {ip && <span dir=\"ltr\">{labels.ip(ip)}</span>}\n </div>\n )}\n </div>\n {onRevoke && !session.current && (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit\n pending={busyId === session.id}\n disabled={busyId !== null && busyId !== session.id}\n aria-label={labels.revokeItem(device)}\n onClick={() => revoke(session.id)}\n >\n {labels.revoke}\n </Button>\n )}\n </li>\n );\n })}\n </ul>\n ))}\n <DangerConfirm\n tone=\"warning\"\n commit\n armLabel={labels.signOutEverywhere}\n prompt={labels.signOutEverywherePrompt}\n confirmLabel={labels.confirmSignOutEverywhere}\n onConfirm={signOutEverywhere}\n />\n {hasMessage(failure) && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure}\n </AlertBanner>\n )}\n </Card>\n );\n}\n"],"mappings":";AA+MM,SACE,KADF;AA/MN,SAAS,gBAAgB;AAEzB,SAAS,yBAAyB;AAElC,SAAS,cAAc,oBAAoB;AAC3C,SAAS,UAAU;AACnB,SAAS,oBAAoB,cAAc;AAE3C,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,QAAQ,YAAY;AAC7B,SA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,SAAI,WAAU,+CACb;AAAA,oCAAC,UAAK,WAAU,2CAA2C,kBAAO;AAAA,gBACjE,QAAQ,WACP,oBAAC,QAAK,MAAK,MAAK,MAAK,SAClB,iBAAO,SACV;AAAA,iBAEJ;AAAA,eACE,QAAQ,OACR,qBAAC,SAAI,WAAW,wBACb;AAAA,wBAAQ,OAAO,WAAW,IAAI;AAAA,gBAC9B,QAAQ,MAAM;AAAA,gBAEd,MAAM,oBAAC,UAAK,KAAI,OAAO,iBAAO,GAAG,EAAE,GAAE;AAAA,iBACxC;AAAA,eAEJ;AAAA,YACC,YAAY,CAAC,QAAQ,WACpB;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,MAAK;AAAA,gBACL,SAAQ;AAAA,gBACR,QAAM;AAAA,gBACN,SAAS,WAAW,QAAQ;AAAA,gBAC5B,UAAU,WAAW,QAAQ,WAAW,QAAQ;AAAA,gBAChD,cAAY,OAAO,WAAW,MAAM;AAAA,gBACpC,SAAS,MAAM,OAAO,QAAQ,EAAE;AAAA,gBAE/B,iBAAO;AAAA;AAAA,YACV;AAAA;AAAA;AAAA,QApCG,QAAQ;AAAA,MAsCf;AAAA,IAEJ,CAAC,GACH;AAAA,IAEJ;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,QAAM;AAAA,QACN,UAAU,OAAO;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,cAAc,OAAO;AAAA,QACrB,WAAW;AAAA;AAAA,IACb;AAAA,IACC,WAAW,OAAO,KACjB,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,mBACH;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -0,0 +1,91 @@
|
|
|
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-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,276 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Children, useContext, useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
5
|
+
import { AlertBanner } from "../components/alert-banner.js";
|
|
6
|
+
import { Checkbox } from "../components/checkbox.js";
|
|
7
|
+
import { DEFAULT_DANGER_CONFIRM_LABELS, TypedConfirmField, typedMatches } from "../components/danger-confirm.js";
|
|
8
|
+
import { DialogFrame } from "../components/dialog-frame.js";
|
|
9
|
+
import { ModalCloseContext } from "../components/modal.js";
|
|
10
|
+
import { Button } from "../components/ui.js";
|
|
11
|
+
import { authErrorCode } from "../auth/auth-errors.js";
|
|
12
|
+
import { hasMessage, usePersonLabel } from "./admin-parts.js";
|
|
13
|
+
const DEFAULT_ADMIN_ACTION_LABELS = {
|
|
14
|
+
confirm: "Confirm",
|
|
15
|
+
cancel: "Cancel",
|
|
16
|
+
close: "Close",
|
|
17
|
+
lastAdmin: "This is the last active administrator. Make someone else an administrator first.",
|
|
18
|
+
self: "You can\u2019t do this to your own account.",
|
|
19
|
+
confirmationMismatch: "The address doesn\u2019t match this account. Check which account you are on.",
|
|
20
|
+
otherCompanies: "This account also belongs to other companies, so only the platform operator can do this. You can remove it from this company instead.",
|
|
21
|
+
removeFromCompany: "Remove from company",
|
|
22
|
+
failed: "That didn\u2019t work. Please try again."
|
|
23
|
+
};
|
|
24
|
+
function isThenable(value) {
|
|
25
|
+
return typeof value === "object" && value !== null && typeof value.then === "function";
|
|
26
|
+
}
|
|
27
|
+
function refusalOf(error, present, describeError, labels) {
|
|
28
|
+
if (!present) return null;
|
|
29
|
+
const code = authErrorCode(error);
|
|
30
|
+
const own = describeError?.(error);
|
|
31
|
+
if (hasMessage(own)) return { text: own, code };
|
|
32
|
+
const text = code === "last_admin" ? labels.lastAdmin : code === "self_action" ? labels.self : code === "confirmation_mismatch" ? labels.confirmationMismatch : code === "other_companies" ? labels.otherCompanies : labels.failed;
|
|
33
|
+
return { text, code };
|
|
34
|
+
}
|
|
35
|
+
const FIELD = 'input:not([type="hidden"]):not(:disabled), select:not(:disabled), textarea:not(:disabled), [role="combobox"]';
|
|
36
|
+
function AdminActionConfirm({
|
|
37
|
+
level,
|
|
38
|
+
target,
|
|
39
|
+
confirmLabel,
|
|
40
|
+
title,
|
|
41
|
+
consequence,
|
|
42
|
+
acknowledgeLabel,
|
|
43
|
+
tone: toneProp,
|
|
44
|
+
onConfirm,
|
|
45
|
+
onClose,
|
|
46
|
+
onRemoveFromCompany,
|
|
47
|
+
describeError,
|
|
48
|
+
error: errorProp,
|
|
49
|
+
busy: busyProp,
|
|
50
|
+
children,
|
|
51
|
+
confirmDisabledReason,
|
|
52
|
+
open,
|
|
53
|
+
commit,
|
|
54
|
+
labels: labelsProp
|
|
55
|
+
}) {
|
|
56
|
+
const labels = useKitLabels("adminAction", DEFAULT_ADMIN_ACTION_LABELS, labelsProp);
|
|
57
|
+
const guardLabels = useKitLabels("dangerConfirm", DEFAULT_DANGER_CONFIRM_LABELS);
|
|
58
|
+
const nameOf = usePersonLabel();
|
|
59
|
+
const isOpen = open ?? true;
|
|
60
|
+
const [typed, setTyped] = useState("");
|
|
61
|
+
const [ticked, setTicked] = useState(false);
|
|
62
|
+
const [pending, setPending] = useState(false);
|
|
63
|
+
const [failure, setFailure] = useState(null);
|
|
64
|
+
const [done, setDone] = useState(false);
|
|
65
|
+
const confirmed = useRef(false);
|
|
66
|
+
const mounted = useRef(true);
|
|
67
|
+
const started = useRef(false);
|
|
68
|
+
const formId = useId();
|
|
69
|
+
const slotRef = useRef(null);
|
|
70
|
+
const guardRef = useRef(null);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
mounted.current = true;
|
|
73
|
+
return () => {
|
|
74
|
+
mounted.current = false;
|
|
75
|
+
};
|
|
76
|
+
}, []);
|
|
77
|
+
const [wasOpen, setWasOpen] = useState(isOpen);
|
|
78
|
+
if (wasOpen !== isOpen) {
|
|
79
|
+
setWasOpen(isOpen);
|
|
80
|
+
if (!isOpen) {
|
|
81
|
+
setTyped("");
|
|
82
|
+
setTicked(false);
|
|
83
|
+
setFailure(null);
|
|
84
|
+
setDone(false);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const busy = Boolean(busyProp) || pending;
|
|
88
|
+
const perform = (call) => {
|
|
89
|
+
let result;
|
|
90
|
+
try {
|
|
91
|
+
result = call();
|
|
92
|
+
} catch (caught) {
|
|
93
|
+
setFailure({ error: caught });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!isThenable(result)) return;
|
|
97
|
+
setFailure(null);
|
|
98
|
+
setPending(true);
|
|
99
|
+
result.then(
|
|
100
|
+
() => {
|
|
101
|
+
if (!mounted.current) return;
|
|
102
|
+
setPending(false);
|
|
103
|
+
confirmed.current = true;
|
|
104
|
+
setDone(true);
|
|
105
|
+
},
|
|
106
|
+
(caught) => {
|
|
107
|
+
if (!mounted.current) return;
|
|
108
|
+
setPending(false);
|
|
109
|
+
setFailure({ error: caught });
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (level !== "none") return;
|
|
115
|
+
if (!isOpen) {
|
|
116
|
+
started.current = false;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (started.current) return;
|
|
120
|
+
started.current = true;
|
|
121
|
+
confirmed.current = false;
|
|
122
|
+
let result;
|
|
123
|
+
try {
|
|
124
|
+
result = onConfirm({});
|
|
125
|
+
} catch (caught) {
|
|
126
|
+
result = Promise.reject(caught);
|
|
127
|
+
}
|
|
128
|
+
if (!isThenable(result)) return;
|
|
129
|
+
result.then(
|
|
130
|
+
() => {
|
|
131
|
+
if (mounted.current) onClose(true);
|
|
132
|
+
},
|
|
133
|
+
(caught) => {
|
|
134
|
+
if (mounted.current) setFailure({ error: caught });
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}, [level, isOpen, onConfirm, onClose]);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!isOpen || level === "none") return;
|
|
140
|
+
const field = slotRef.current?.querySelector(FIELD) ?? guardRef.current;
|
|
141
|
+
field?.focus();
|
|
142
|
+
}, [isOpen, level]);
|
|
143
|
+
const hasRefusal = failure !== null || errorProp !== void 0;
|
|
144
|
+
const refusal = refusalOf(failure ? failure.error : errorProp, hasRefusal, describeError, labels);
|
|
145
|
+
const offerRemoval = refusal?.code === "other_companies" && onRemoveFromCompany !== void 0;
|
|
146
|
+
const name = nameOf(target);
|
|
147
|
+
const identity = /* @__PURE__ */ jsx("span", { "data-private": true, children: name && name !== target.email ? `${name} \xB7 ${target.email}` : target.email });
|
|
148
|
+
const heading = title ?? confirmLabel ?? labels.confirm;
|
|
149
|
+
const refusalBanner = refusal && /* @__PURE__ */ jsx(
|
|
150
|
+
AlertBanner,
|
|
151
|
+
{
|
|
152
|
+
tone: "danger",
|
|
153
|
+
size: "sm",
|
|
154
|
+
action: offerRemoval ? /* @__PURE__ */ jsx(
|
|
155
|
+
Button,
|
|
156
|
+
{
|
|
157
|
+
type: "button",
|
|
158
|
+
size: "sm",
|
|
159
|
+
variant: "secondary",
|
|
160
|
+
disabled: busy,
|
|
161
|
+
onClick: () => perform(() => onRemoveFromCompany()),
|
|
162
|
+
children: labels.removeFromCompany
|
|
163
|
+
}
|
|
164
|
+
) : void 0,
|
|
165
|
+
children: refusal.text
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
if (level === "none") {
|
|
169
|
+
if (!isOpen || !refusal) return null;
|
|
170
|
+
return /* @__PURE__ */ jsx(
|
|
171
|
+
DialogFrame,
|
|
172
|
+
{
|
|
173
|
+
role: "alertdialog",
|
|
174
|
+
title: heading,
|
|
175
|
+
description: identity,
|
|
176
|
+
onClose: () => onClose(confirmed.current),
|
|
177
|
+
actions: (close) => /* @__PURE__ */ jsx(CloseOnDone, { done, children: /* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", disabled: busy, onClick: close, children: labels.close }) }),
|
|
178
|
+
children: refusalBanner
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
const tone = toneProp ?? (level === "type_email" ? "danger" : "warning");
|
|
183
|
+
const askTyped = level === "type_email";
|
|
184
|
+
const typedOk = !askTyped || typedMatches(typed, target.email, "caseless");
|
|
185
|
+
const tickOk = askTyped || ticked;
|
|
186
|
+
const guardReason = hasMessage(confirmDisabledReason) ? confirmDisabledReason : !tickOk ? guardLabels.needsAcknowledge : !typedOk ? typeof guardLabels.needsPhrase === "function" ? guardLabels.needsPhrase(target.email) : guardLabels.needsPhrase : void 0;
|
|
187
|
+
const submit = () => {
|
|
188
|
+
if (busy || guardReason !== void 0) return;
|
|
189
|
+
perform(
|
|
190
|
+
() => onConfirm(askTyped ? { confirmEmail: typed.trim(), acknowledged: true } : { acknowledged: true })
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
const lines = Array.isArray(consequence) ? consequence.map(
|
|
194
|
+
(item, index) => typeof item === "string" ? { key: item, text: item, severe: false } : { key: item.key ?? String(index), text: item.text, severe: Boolean(item.severe) }
|
|
195
|
+
) : null;
|
|
196
|
+
return /* @__PURE__ */ jsx(
|
|
197
|
+
DialogFrame,
|
|
198
|
+
{
|
|
199
|
+
open,
|
|
200
|
+
role: "alertdialog",
|
|
201
|
+
title: heading,
|
|
202
|
+
description: identity,
|
|
203
|
+
onClose: () => onClose(confirmed.current),
|
|
204
|
+
onKeyDown: (event) => {
|
|
205
|
+
if (busy && event.key === "Escape") event.preventDefault();
|
|
206
|
+
},
|
|
207
|
+
"aria-busy": busy || void 0,
|
|
208
|
+
actions: (close) => /* @__PURE__ */ jsxs(CloseOnDone, { done, children: [
|
|
209
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", disabled: busy, onClick: close, children: labels.cancel }),
|
|
210
|
+
/* @__PURE__ */ jsx(
|
|
211
|
+
Button,
|
|
212
|
+
{
|
|
213
|
+
type: "submit",
|
|
214
|
+
form: formId,
|
|
215
|
+
variant: tone === "danger" ? "danger" : "primary",
|
|
216
|
+
pending: busy,
|
|
217
|
+
commit,
|
|
218
|
+
disabledReason: busy ? void 0 : guardReason,
|
|
219
|
+
children: confirmLabel ?? labels.confirm
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
] }),
|
|
223
|
+
children: /* @__PURE__ */ jsxs(
|
|
224
|
+
"form",
|
|
225
|
+
{
|
|
226
|
+
id: formId,
|
|
227
|
+
noValidate: true,
|
|
228
|
+
className: "space-y-3",
|
|
229
|
+
onSubmit: (event) => {
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
submit();
|
|
232
|
+
},
|
|
233
|
+
children: [
|
|
234
|
+
lines ? /* @__PURE__ */ jsx("ul", { className: "list-disc space-y-1 ps-5 text-sm text-[var(--text-secondary)]", children: lines.map((line) => /* @__PURE__ */ jsx("li", { className: line.severe ? "text-[var(--danger)]" : void 0, children: line.text }, line.key)) }) : hasMessage(consequence) && /* @__PURE__ */ jsx("p", { className: "text-sm text-[var(--text-secondary)]", children: consequence }),
|
|
235
|
+
Children.toArray(children).some(hasMessage) && /* @__PURE__ */ jsx("div", { ref: slotRef, className: "space-y-3", children }),
|
|
236
|
+
askTyped ? /* @__PURE__ */ jsx(
|
|
237
|
+
TypedConfirmField,
|
|
238
|
+
{
|
|
239
|
+
ref: guardRef,
|
|
240
|
+
target: target.email,
|
|
241
|
+
match: "caseless",
|
|
242
|
+
value: typed,
|
|
243
|
+
onValueChange: setTyped,
|
|
244
|
+
busy,
|
|
245
|
+
"data-private": true
|
|
246
|
+
}
|
|
247
|
+
) : /* @__PURE__ */ jsx(
|
|
248
|
+
Checkbox,
|
|
249
|
+
{
|
|
250
|
+
ref: guardRef,
|
|
251
|
+
label: acknowledgeLabel ?? guardLabels.acknowledge,
|
|
252
|
+
checked: ticked,
|
|
253
|
+
onCheckedChange: (next) => {
|
|
254
|
+
if (!busy) setTicked(next);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
refusalBanner
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
function CloseOnDone({ done, children }) {
|
|
266
|
+
const close = useContext(ModalCloseContext);
|
|
267
|
+
useEffect(() => {
|
|
268
|
+
if (done) close?.();
|
|
269
|
+
}, [done, close]);
|
|
270
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
271
|
+
}
|
|
272
|
+
export {
|
|
273
|
+
AdminActionConfirm,
|
|
274
|
+
DEFAULT_ADMIN_ACTION_LABELS
|
|
275
|
+
};
|
|
276
|
+
//# sourceMappingURL=admin-action-confirm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/admin/admin-action-confirm.tsx"],"sourcesContent":["import { Children, useContext, useEffect, useId, useRef, useState } from \"react\";\nimport type { KeyboardEvent, ReactNode } from \"react\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Checkbox } from \"../components/checkbox\";\nimport { DEFAULT_DANGER_CONFIRM_LABELS, TypedConfirmField, typedMatches } from \"../components/danger-confirm\";\nimport type { DangerConsequence } from \"../components/danger-confirm\";\nimport { DialogFrame } from \"../components/dialog-frame\";\nimport { ModalCloseContext } from \"../components/modal\";\nimport { Button } from \"../components/ui\";\nimport { authErrorCode } from \"../auth/auth-errors\";\nimport type { KitErrorCode } from \"../auth/auth-errors\";\nimport { hasMessage, usePersonLabel } from \"./admin-parts\";\nimport type { AdminPerson, MaybePromise } from \"./admin-parts\";\n\n/**\n * The confirmation in front of an admin action, at the level the SERVER states\n * (docs/user-admin-harmonization.md §4.2):\n *\n * | level | what it asks | actions |\n * |---|---|---|\n * | `none` | nothing: it confirms at once and renders nothing | resend a mail, reactivate, the reviewer scope… |\n * | `acknowledge` | a tick under the consequence | force a password change, change a role |\n * | `type_email` | the target's address, typed | deactivate, erase now, transfer |\n *\n * keksdose decides the level per action and per account on the server\n * (`admin_user_actions_service`) and Kurvenschmiede asks for the typed address on its\n * two hard-to-undo actions; both drew the dialog by hand beside the kit's `DangerConfirm`\n * and `useConfirm`. The level is a PROP, never derived here: the server enforces it and\n * a hand-written request never sees this dialog, so a page that guessed its own level\n * could only disagree with the server. The comparison (caseless), the field and the tick\n * are `DangerConfirm`'s (`TypedConfirmField`, the `dangerConfirm` words), so the three\n * confirmations in the kit cannot disagree about what counts as the address.\n *\n * WHY TYPE THE TARGET'S ADDRESS and not the admin's password: the admin proved who they\n * are at the admin gate. What is unproven is which ROW they are on (keksdose's\n * `TYPE_EMAIL` rule, Kurvenschmiede's `TypedConfirm`).\n *\n * THE REFUSALS (§4.1, §9.6) are read by code — `authErrorCode`, which knows the account\n * codes beside the sign-in ones — and stay in the dialog, which stays open so the admin\n * can read them: `last_admin`, `self_action`, `confirmation_mismatch`, and kastlan's\n * `other_companies` — with \"Remove from company\" offered in its place when the app passes\n * `onRemoveFromCompany`. Anything else is `describeError`'s words, else \"That didn't work\".\n * At level `none` nothing is drawn while the action runs; a refusal opens a dialog of its\n * own to say it.\n *\n * It never sends a request: `onConfirm` does, with what the guards were answered with.\n */\n\n/** How much confirmation an action needs — the server's `confirmation_level(action)`. */\nexport type AdminConfirmLevel = \"none\" | \"acknowledge\" | \"type_email\";\n\n/** What {@link AdminActionConfirmProps.onConfirm} receives — the guards' answers, for\n * the request body (the server re-checks both). */\nexport interface AdminActionConfirmValues {\n /** `type_email`: the address as typed — trimmed, its case the admin's; the body's\n * `confirm_email`, which the server compares with the account's (server-kit's\n * `confirm_email_matches`). */\n confirmEmail?: string;\n /** `acknowledge` and `type_email`: the action was confirmed past a guard — the body's\n * `acknowledged`, which every admin action carries (server-kit 0.4). */\n acknowledged?: true;\n}\n\n/** The account the action is about. */\nexport type AdminActionTarget = AdminPerson & { email: string };\n\n/** The `adminAction` namespace. The tick, the typed field and their held-button reasons\n * are the `dangerConfirm` namespace's, shared with `DangerConfirm`. */\nexport interface AdminActionLabels {\n /** The confirm button when the action names none. */\n confirm: string;\n cancel: string;\n /** The refusal dialog's only button (level `none`). */\n close: string;\n /** `409 last_admin`. */\n lastAdmin: string;\n /** `409 self_action`: the admin's own account. */\n self: string;\n /** `confirmation_mismatch`: the typed address is not this account's — the page and\n * the server disagree about which row this is. */\n confirmationMismatch: string;\n /** kastlan's `409 other_companies` (§9.6). */\n otherCompanies: string;\n /** The alternative offered with it. */\n removeFromCompany: string;\n /** Any other failure, unless `describeError` says better. */\n failed: string;\n}\n\nexport const DEFAULT_ADMIN_ACTION_LABELS: AdminActionLabels = {\n confirm: \"Confirm\",\n cancel: \"Cancel\",\n close: \"Close\",\n lastAdmin: \"This is the last active administrator. Make someone else an administrator first.\",\n self: \"You can’t do this to your own account.\",\n confirmationMismatch: \"The address doesn’t match this account. Check which account you are on.\",\n otherCompanies:\n \"This account also belongs to other companies, so only the platform operator can do this. You can remove it from this company instead.\",\n removeFromCompany: \"Remove from company\",\n failed: \"That didn’t work. Please try again.\",\n};\n\nexport interface AdminActionConfirmProps {\n /** The level the server states for this action on this account (§4.2). */\n level: AdminConfirmLevel;\n /** Whom it is about: the address (typed at `type_email`) and the name parts. */\n target: AdminActionTarget;\n /** The confirm button — \"Deactivate\". Also the title when no `title` is given. */\n confirmLabel?: ReactNode;\n /** The dialog's heading — \"Deactivate Ada Example?\". Default `confirmLabel`. */\n title?: ReactNode;\n /**\n * What the action does to THIS account, said before it happens: a sentence, or lines\n * (`DangerConsequence`, a `severe` one in the danger colour). Derive them from the\n * row's facts rather than reciting the worst case (keksdose dev#488).\n */\n consequence?: ReactNode | readonly (string | DangerConsequence)[];\n /** The tick's words at `acknowledge`. Default `dangerConfirm.acknowledge` — \"I have\n * read what this does and want to continue.\" */\n acknowledgeLabel?: ReactNode;\n /** `danger` (default at `type_email`): a red confirm. `warning` (default at\n * `acknowledge`) and `neutral`: the primary confirm. */\n tone?: \"danger\" | \"warning\" | \"neutral\";\n /**\n * Runs the action. Return a promise and the dialog manages itself: busy until it\n * settles, closed (`onClose(true)`) when it resolves, open with the refusal when it\n * rejects. Return nothing and the app owns the rest — `busy`, `error`, closing it.\n */\n onConfirm: (values: AdminActionConfirmValues) => MaybePromise;\n /** The dialog has closed: `true` after the action (or the alternative) went through,\n * `false` for Cancel, Escape, the backdrop or Back. */\n onClose: (done: boolean) => void;\n /** kastlan: offered with an `other_companies` refusal — `DELETE …/membership`,\n * logged as `membership_remove` (§4.1). Promise handling as `onConfirm`. */\n onRemoveFromCompany?: () => MaybePromise;\n /** The app's words for a failure the kit has no code for. Asked first. */\n describeError?: (error: unknown) => ReactNode | undefined;\n /** A refusal the app caught itself, when `onConfirm` returns nothing. */\n error?: unknown;\n /** The action is running, for an app that tracks it itself. */\n busy?: boolean;\n /**\n * Fields of the action's own, above the guard — the transfer's recipient, kastlan's\n * roles (`RolesEditor`). Their values are the app's; hold the confirm with\n * `confirmDisabledReason` until they are complete.\n */\n children?: ReactNode;\n /** Why the confirm is held for a reason of the app's (\"Choose who receives it\").\n * Named before the guard's own, since the fields are above it. */\n confirmDisabledReason?: ReactNode;\n /** Kept-mounted mode, as on `DialogFrame`; left out, open while mounted. */\n open?: boolean;\n /** The confirm COMMITS: under a locked `WriteLockProvider` it is held with the lock's\n * reason. Off by default — an admin action is not a write to the open record. */\n commit?: boolean;\n labels?: Partial<AdminActionLabels>;\n}\n\n/** Whether a callback answered a promise. */\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return typeof value === \"object\" && value !== null && typeof (value as PromiseLike<unknown>).then === \"function\";\n}\n\n/** The refusal's words and code. */\nfunction refusalOf(\n error: unknown,\n present: boolean,\n describeError: AdminActionConfirmProps[\"describeError\"],\n labels: AdminActionLabels,\n): { text: ReactNode; code: KitErrorCode | undefined } | null {\n if (!present) return null;\n const code = authErrorCode(error);\n const own = describeError?.(error);\n if (hasMessage(own)) return { text: own, code };\n const text =\n code === \"last_admin\"\n ? labels.lastAdmin\n : code === \"self_action\"\n ? labels.self\n : code === \"confirmation_mismatch\"\n ? labels.confirmationMismatch\n : code === \"other_companies\"\n ? labels.otherCompanies\n : labels.failed;\n return { text, code };\n}\n\n/** The selector for the first field among the caller's `children` — what opening focuses. */\nconst FIELD = 'input:not([type=\"hidden\"]):not(:disabled), select:not(:disabled), textarea:not(:disabled), [role=\"combobox\"]';\n\nexport function AdminActionConfirm({\n level,\n target,\n confirmLabel,\n title,\n consequence,\n acknowledgeLabel,\n tone: toneProp,\n onConfirm,\n onClose,\n onRemoveFromCompany,\n describeError,\n error: errorProp,\n busy: busyProp,\n children,\n confirmDisabledReason,\n open,\n commit,\n labels: labelsProp,\n}: AdminActionConfirmProps) {\n const labels = useKitLabels(\"adminAction\", DEFAULT_ADMIN_ACTION_LABELS, labelsProp);\n const guardLabels = useKitLabels(\"dangerConfirm\", DEFAULT_DANGER_CONFIRM_LABELS);\n const nameOf = usePersonLabel();\n const isOpen = open ?? true;\n const [typed, setTyped] = useState(\"\");\n const [ticked, setTicked] = useState(false);\n const [pending, setPending] = useState(false);\n // The last rejection, boxed so a rejection with `undefined` still counts as one.\n const [failure, setFailure] = useState<{ error: unknown } | null>(null);\n // Resolved: the actions row lowers the panel, and `onClose` answers true.\n const [done, setDone] = useState(false);\n const confirmed = useRef(false);\n const mounted = useRef(true);\n const started = useRef(false);\n const formId = useId();\n const slotRef = useRef<HTMLDivElement>(null);\n const guardRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n // A close (kept-mounted) wipes the guards and the refusal: a reopened dialog starts\n // over. During render, like ReauthDialog's, so no frame shows the old answers.\n const [wasOpen, setWasOpen] = useState(isOpen);\n if (wasOpen !== isOpen) {\n setWasOpen(isOpen);\n if (!isOpen) {\n setTyped(\"\");\n setTicked(false);\n setFailure(null);\n setDone(false);\n }\n }\n\n const busy = Boolean(busyProp) || pending;\n\n /** Runs `call`, managing busy, the refusal and the close — or not, when it answers\n * no promise (the app owns it then). */\n const perform = (call: () => MaybePromise) => {\n let result: MaybePromise;\n try {\n result = call();\n } catch (caught) {\n setFailure({ error: caught });\n return;\n }\n if (!isThenable(result)) return;\n setFailure(null);\n setPending(true);\n result.then(\n () => {\n if (!mounted.current) return;\n setPending(false);\n confirmed.current = true;\n setDone(true);\n },\n (caught: unknown) => {\n if (!mounted.current) return;\n setPending(false);\n setFailure({ error: caught });\n },\n );\n };\n\n // Level `none`: confirmed the moment it opens, once per opening. Nothing is drawn\n // while it runs; the promise's answer comes back asynchronously.\n useEffect(() => {\n if (level !== \"none\") return;\n if (!isOpen) {\n started.current = false;\n return;\n }\n if (started.current) return;\n started.current = true;\n confirmed.current = false;\n let result: unknown;\n try {\n result = onConfirm({});\n } catch (caught) {\n result = Promise.reject(caught);\n }\n // No promise: the app owns the rest (it closes the part, or passes `error`).\n if (!isThenable(result)) return;\n result.then(\n () => {\n if (mounted.current) onClose(true);\n },\n (caught: unknown) => {\n if (mounted.current) setFailure({ error: caught });\n },\n );\n }, [level, isOpen, onConfirm, onClose]);\n\n // Focus the first thing the dialog waits for, after Modal's own effect has recorded\n // the trigger to return to (a parent's effects run after its children's).\n useEffect(() => {\n if (!isOpen || level === \"none\") return;\n const field = slotRef.current?.querySelector<HTMLElement>(FIELD) ?? guardRef.current;\n field?.focus();\n }, [isOpen, level]);\n\n const hasRefusal = failure !== null || errorProp !== undefined;\n const refusal = refusalOf(failure ? failure.error : errorProp, hasRefusal, describeError, labels);\n const offerRemoval = refusal?.code === \"other_companies\" && onRemoveFromCompany !== undefined;\n\n const name = nameOf(target);\n const identity = (\n <span data-private>{name && name !== target.email ? `${name} · ${target.email}` : target.email}</span>\n );\n const heading = title ?? confirmLabel ?? labels.confirm;\n\n const refusalBanner = refusal && (\n <AlertBanner\n tone=\"danger\"\n size=\"sm\"\n action={\n offerRemoval ? (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"secondary\"\n disabled={busy}\n onClick={() => perform(() => onRemoveFromCompany!())}\n >\n {labels.removeFromCompany}\n </Button>\n ) : undefined\n }\n >\n {refusal.text}\n </AlertBanner>\n );\n\n if (level === \"none\") {\n // Nothing to ask: only a refusal is worth a dialog.\n if (!isOpen || !refusal) return null;\n return (\n <DialogFrame\n role=\"alertdialog\"\n title={heading}\n description={identity}\n onClose={() => onClose(confirmed.current)}\n actions={(close) => (\n <CloseOnDone done={done}>\n <Button type=\"button\" variant=\"secondary\" disabled={busy} onClick={close}>\n {labels.close}\n </Button>\n </CloseOnDone>\n )}\n >\n {refusalBanner}\n </DialogFrame>\n );\n }\n\n const tone = toneProp ?? (level === \"type_email\" ? \"danger\" : \"warning\");\n const askTyped = level === \"type_email\";\n const typedOk = !askTyped || typedMatches(typed, target.email, \"caseless\");\n const tickOk = askTyped || ticked;\n const guardReason: ReactNode = hasMessage(confirmDisabledReason)\n ? confirmDisabledReason\n : !tickOk\n ? guardLabels.needsAcknowledge\n : !typedOk\n ? typeof guardLabels.needsPhrase === \"function\"\n ? guardLabels.needsPhrase(target.email)\n : guardLabels.needsPhrase\n : undefined;\n\n const submit = () => {\n if (busy || guardReason !== undefined) return;\n perform(() =>\n onConfirm(askTyped ? { confirmEmail: typed.trim(), acknowledged: true } : { acknowledged: true }),\n );\n };\n\n const lines = Array.isArray(consequence)\n ? (consequence as readonly (string | DangerConsequence)[]).map((item, index) =>\n typeof item === \"string\"\n ? { key: item, text: item as ReactNode, severe: false }\n : { key: item.key ?? String(index), text: item.text, severe: Boolean(item.severe) },\n )\n : null;\n\n return (\n <DialogFrame\n open={open}\n role=\"alertdialog\"\n title={heading}\n description={identity}\n onClose={() => onClose(confirmed.current)}\n // A request that has left cannot be called back by closing the dialog.\n onKeyDown={(event: KeyboardEvent<HTMLDivElement>) => {\n if (busy && event.key === \"Escape\") event.preventDefault();\n }}\n aria-busy={busy || undefined}\n actions={(close) => (\n <CloseOnDone done={done}>\n <Button type=\"button\" variant=\"ghost\" disabled={busy} onClick={close}>\n {labels.cancel}\n </Button>\n <Button\n type=\"submit\"\n form={formId}\n variant={tone === \"danger\" ? \"danger\" : \"primary\"}\n pending={busy}\n commit={commit}\n disabledReason={busy ? undefined : guardReason}\n >\n {confirmLabel ?? labels.confirm}\n </Button>\n </CloseOnDone>\n )}\n >\n <form\n id={formId}\n noValidate\n className=\"space-y-3\"\n onSubmit={(event) => {\n event.preventDefault();\n submit();\n }}\n >\n {lines ? (\n <ul className=\"list-disc space-y-1 ps-5 text-sm text-[var(--text-secondary)]\">\n {lines.map((line) => (\n <li key={line.key} className={line.severe ? \"text-[var(--danger)]\" : undefined}>\n {line.text}\n </li>\n ))}\n </ul>\n ) : (\n hasMessage(consequence as ReactNode) && (\n <p className=\"text-sm text-[var(--text-secondary)]\">{consequence as ReactNode}</p>\n )\n )}\n {Children.toArray(children).some(hasMessage) && (\n <div ref={slotRef} className=\"space-y-3\">\n {children}\n </div>\n )}\n {askTyped ? (\n <TypedConfirmField\n ref={guardRef}\n target={target.email}\n match=\"caseless\"\n value={typed}\n onValueChange={setTyped}\n busy={busy}\n data-private\n />\n ) : (\n <Checkbox\n ref={guardRef}\n label={acknowledgeLabel ?? guardLabels.acknowledge}\n checked={ticked}\n // Not `disabled` while busy: the box may hold the focus.\n onCheckedChange={(next) => {\n if (!busy) setTicked(next);\n }}\n />\n )}\n {refusalBanner}\n </form>\n </DialogFrame>\n );\n}\n\n/**\n * The actions row's wrapper: it renders INSIDE the Modal, where the panel's animated\n * close is in context, so a resolved action lowers the panel the way Cancel does and\n * Modal then calls `onClose` (ReauthDialog's pattern).\n */\nfunction CloseOnDone({ done, children }: { done: boolean; children: ReactNode }) {\n const close = useContext(ModalCloseContext);\n useEffect(() => {\n if (done) close?.();\n }, [done, close]);\n return <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