@stackone/malachite 2.89.1 → 2.91.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/COMPONENTS.md +4 -3
- package/dist/components/CodeBlock.js +112 -107
- package/dist/components/CodeBlock.js.map +1 -1
- package/dist/components/ConfirmationDialog.js +72 -71
- package/dist/components/ConfirmationDialog.js.map +1 -1
- package/dist/components/FormActions.js +40 -0
- package/dist/components/FormActions.js.map +1 -0
- package/dist/components/SidePanel.js +124 -104
- package/dist/components/SidePanel.js.map +1 -1
- package/dist/components/Tabs.js +55 -28
- package/dist/components/Tabs.js.map +1 -1
- package/dist/index.d.ts +57 -0
- package/dist/index.js +368 -366
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { jsxs as p, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as $, useId as d, Children as ee } from "react";
|
|
3
3
|
import { Button as T } from "./Button.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { FieldMessage as
|
|
12
|
-
import { IconBadge as
|
|
13
|
-
import { Modal as
|
|
14
|
-
import { Typography as
|
|
15
|
-
import { useClipboardCopy as
|
|
16
|
-
import { CONFIRMATION_DIALOG_VARIANTS as
|
|
17
|
-
import
|
|
18
|
-
const v = 12, h = (e) => e.replace(/\s+/g, " "),
|
|
4
|
+
import oe from "./CalloutStrip.js";
|
|
5
|
+
import ie from "./CustomIcons/CheckCircleFilled.js";
|
|
6
|
+
import te from "./CustomIcons/CheckmarkIcon.js";
|
|
7
|
+
import le from "./CustomIcons/CopyIcon.js";
|
|
8
|
+
import re from "./CustomIcons/ErrorCircleFilled.js";
|
|
9
|
+
import se from "./CustomIcons/InfoCircleFilled.js";
|
|
10
|
+
import ae from "./CustomIcons/WarningCircleFilled.js";
|
|
11
|
+
import { FieldMessage as ne } from "./FieldMessage.js";
|
|
12
|
+
import { IconBadge as ce } from "./IconBadge.js";
|
|
13
|
+
import { Modal as de } from "./Modal.js";
|
|
14
|
+
import { Typography as D } from "./Typography/index.js";
|
|
15
|
+
import { useClipboardCopy as pe } from "./useClipboardCopy.js";
|
|
16
|
+
import { CONFIRMATION_DIALOG_VARIANTS as me } from "./confirmationDialogVariants.js";
|
|
17
|
+
import fe from "./Input/Input.js";
|
|
18
|
+
const v = 12, h = (e) => e.replace(/\s+/g, " "), ue = (e, i) => {
|
|
19
19
|
if (!(i === "" || e === "" || e === i) && h(e).toLowerCase() === h(i).toLowerCase())
|
|
20
20
|
return h(e) === h(i) ? "The spacing has to match exactly." : "This is case-sensitive.";
|
|
21
|
-
},
|
|
21
|
+
}, ye = "Could not copy. Enter the phrase manually.", xe = (e, i) => {
|
|
22
22
|
const l = typeof e == "object" && e !== null ? e : void 0;
|
|
23
23
|
return l ? { parts: l, text: [l.prefix, i, l.suffix].filter(Boolean).join(" ") } : { text: typeof e == "string" ? e : `Type ${i} to confirm` };
|
|
24
|
-
},
|
|
25
|
-
const { outcome: m, canCopy: f, copy: a } =
|
|
24
|
+
}, Ce = (e, i) => e === "copied" ? `${i} copied to clipboard` : "", be = (e, i, l, c) => {
|
|
25
|
+
const { outcome: m, canCopy: f, copy: a } = pe(`${i}|${e}`), s = async () => {
|
|
26
26
|
e && await a(e) && queueMicrotask(() => c == null ? void 0 : c(e));
|
|
27
27
|
};
|
|
28
28
|
return { outcome: m, canCopy: f && !l, copy: () => void s() };
|
|
29
|
-
}, N = ({ children: e }) => /* @__PURE__ */ o(
|
|
29
|
+
}, N = ({ children: e }) => /* @__PURE__ */ o(D.Text, { size: "small", color: "primary", children: e }), ve = ({
|
|
30
30
|
phrase: e,
|
|
31
31
|
parts: i,
|
|
32
32
|
plainLabel: l,
|
|
@@ -40,13 +40,13 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), fe = (e, i) => {
|
|
|
40
40
|
onCopy: I,
|
|
41
41
|
nearMissMessage: y
|
|
42
42
|
}) => {
|
|
43
|
-
const u = d(), x = d(), C = d(), b = d(), r = [y, n === "failed" ?
|
|
43
|
+
const u = d(), x = d(), C = d(), b = d(), r = [y, n === "failed" ? ye : void 0].filter(Boolean).join(" ") || void 0, g = i ? [u, i.suffix ? x : void 0].filter(Boolean).join(" ") : void 0;
|
|
44
44
|
return /* @__PURE__ */ p("div", { className: "flex flex-col gap-[6px]", children: [
|
|
45
45
|
i ? /* @__PURE__ */ p("div", { className: "flex flex-wrap items-center gap-[6px] px-2 text-[13px]", children: [
|
|
46
46
|
/* @__PURE__ */ p("span", { id: u, children: [
|
|
47
47
|
/* @__PURE__ */ o(N, { children: i.prefix }),
|
|
48
48
|
" ",
|
|
49
|
-
/* @__PURE__ */ o(
|
|
49
|
+
/* @__PURE__ */ o(D.CodeText, { variant: "inline", children: e })
|
|
50
50
|
] }),
|
|
51
51
|
/* @__PURE__ */ o(
|
|
52
52
|
T,
|
|
@@ -55,7 +55,7 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), fe = (e, i) => {
|
|
|
55
55
|
size: "small",
|
|
56
56
|
iconOnly: !0,
|
|
57
57
|
"aria-label": `${s} ${e}`,
|
|
58
|
-
icon: n === "copied" ? /* @__PURE__ */ o(
|
|
58
|
+
icon: n === "copied" ? /* @__PURE__ */ o(te, { size: 13 }) : /* @__PURE__ */ o(le, { size: 13 }),
|
|
59
59
|
onClick: I,
|
|
60
60
|
disabled: !t
|
|
61
61
|
}
|
|
@@ -63,7 +63,7 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), fe = (e, i) => {
|
|
|
63
63
|
i.suffix ? /* @__PURE__ */ o("span", { id: x, children: /* @__PURE__ */ o(N, { children: i.suffix }) }) : null
|
|
64
64
|
] }) : /* @__PURE__ */ o("label", { id: u, htmlFor: b, className: "px-2 text-[13px]", children: /* @__PURE__ */ o(N, { children: l }) }),
|
|
65
65
|
/* @__PURE__ */ o(
|
|
66
|
-
|
|
66
|
+
fe,
|
|
67
67
|
{
|
|
68
68
|
id: b,
|
|
69
69
|
name: "confirmation-phrase",
|
|
@@ -78,15 +78,15 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), fe = (e, i) => {
|
|
|
78
78
|
disabled: a
|
|
79
79
|
}
|
|
80
80
|
),
|
|
81
|
-
/* @__PURE__ */ o(
|
|
82
|
-
i ? /* @__PURE__ */ o("span", { role: "status", className: "sr-only", children:
|
|
81
|
+
/* @__PURE__ */ o(ne, { id: C, message: r }),
|
|
82
|
+
i ? /* @__PURE__ */ o("span", { role: "status", className: "sr-only", children: Ce(n, e) }) : null
|
|
83
83
|
] });
|
|
84
|
-
},
|
|
85
|
-
default: /* @__PURE__ */ o(
|
|
86
|
-
warning: /* @__PURE__ */ o(
|
|
87
|
-
destructive: /* @__PURE__ */ o(
|
|
88
|
-
success: /* @__PURE__ */ o(
|
|
89
|
-
},
|
|
84
|
+
}, he = {
|
|
85
|
+
default: /* @__PURE__ */ o(se, { size: v }),
|
|
86
|
+
warning: /* @__PURE__ */ o(ae, { size: v }),
|
|
87
|
+
destructive: /* @__PURE__ */ o(re, { size: v }),
|
|
88
|
+
success: /* @__PURE__ */ o(ie, { size: v })
|
|
89
|
+
}, $e = ({
|
|
90
90
|
open: e,
|
|
91
91
|
onClose: i,
|
|
92
92
|
onConfirm: l,
|
|
@@ -104,69 +104,70 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), fe = (e, i) => {
|
|
|
104
104
|
confirmLabel: C = "Confirm",
|
|
105
105
|
cancelLabel: b = "Cancel",
|
|
106
106
|
loading: r = !1,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
"aria-
|
|
107
|
+
confirmDisabled: g = !1,
|
|
108
|
+
tip: G,
|
|
109
|
+
size: R = "medium",
|
|
110
|
+
"aria-label": V,
|
|
111
|
+
"aria-labelledby": q,
|
|
111
112
|
children: z
|
|
112
113
|
}) => {
|
|
113
|
-
const [
|
|
114
|
-
(
|
|
115
|
-
const { parts:
|
|
114
|
+
const [B, L] = $(""), k = d(), w = d(), A = me[s], [S, Y] = $({ open: e, confirmPhrase: t });
|
|
115
|
+
(S.open !== e || S.confirmPhrase !== t) && (Y({ open: e, confirmPhrase: t }), e && L(""));
|
|
116
|
+
const { parts: H, text: j } = xe(
|
|
116
117
|
I,
|
|
117
118
|
t
|
|
118
119
|
), {
|
|
119
|
-
outcome:
|
|
120
|
-
canCopy:
|
|
121
|
-
copy:
|
|
122
|
-
} =
|
|
123
|
-
(
|
|
124
|
-
), _ = !!a ||
|
|
120
|
+
outcome: W,
|
|
121
|
+
canCopy: Z,
|
|
122
|
+
copy: J
|
|
123
|
+
} = be(t, e, r, u), E = B.trim(), F = (t == null ? void 0 : t.trim()) ?? "", O = !t || (F === "" ? B === t : E === F), K = ue(E, F), Q = r || g || !O, U = ee.toArray(z).some(
|
|
124
|
+
(M) => typeof M != "string" || M.trim() !== ""
|
|
125
|
+
), _ = !!a || U || !!t, X = [n ? w : null, a ? k : null].filter(Boolean).join(" ") || void 0, P = /* @__PURE__ */ p("div", { className: "flex w-full flex-wrap items-center justify-end gap-[8px]", children: [
|
|
125
126
|
/* @__PURE__ */ o(T, { variant: "outline", size: "small", onClick: i, disabled: r, children: b }),
|
|
126
127
|
/* @__PURE__ */ o(
|
|
127
128
|
T,
|
|
128
129
|
{
|
|
129
|
-
variant:
|
|
130
|
+
variant: A.confirmVariant,
|
|
130
131
|
size: "small",
|
|
131
132
|
onClick: l,
|
|
132
|
-
disabled:
|
|
133
|
+
disabled: Q,
|
|
133
134
|
loading: r,
|
|
134
|
-
tooltip: !r && !O ?
|
|
135
|
+
tooltip: !r && !O ? j : void 0,
|
|
135
136
|
children: C
|
|
136
137
|
}
|
|
137
138
|
)
|
|
138
139
|
] });
|
|
139
140
|
return /* @__PURE__ */ p(
|
|
140
|
-
|
|
141
|
+
de,
|
|
141
142
|
{
|
|
142
143
|
open: e,
|
|
143
144
|
onClose: i,
|
|
144
145
|
title: c,
|
|
145
|
-
size:
|
|
146
|
-
footer:
|
|
146
|
+
size: R,
|
|
147
|
+
footer: P,
|
|
147
148
|
busy: r,
|
|
148
149
|
role: s === "destructive" ? "alertdialog" : "dialog",
|
|
149
|
-
"aria-label":
|
|
150
|
-
"aria-labelledby":
|
|
151
|
-
"aria-describedby":
|
|
150
|
+
"aria-label": V,
|
|
151
|
+
"aria-labelledby": q,
|
|
152
|
+
"aria-describedby": X,
|
|
152
153
|
closeOnOverlayClick: s !== "destructive" && !t,
|
|
153
154
|
headerDivider: !0,
|
|
154
155
|
titleAdornment: m,
|
|
155
156
|
bodyPadding: !1,
|
|
156
|
-
tray: { tone:
|
|
157
|
+
tray: { tone: A.tray, caption: G },
|
|
157
158
|
icon: /* @__PURE__ */ o(
|
|
158
|
-
|
|
159
|
+
ce,
|
|
159
160
|
{
|
|
160
161
|
variant: s,
|
|
161
|
-
icon: f ??
|
|
162
|
+
icon: f ?? he[s]
|
|
162
163
|
}
|
|
163
164
|
),
|
|
164
165
|
children: [
|
|
165
166
|
n ? /* @__PURE__ */ o(
|
|
166
|
-
|
|
167
|
+
oe,
|
|
167
168
|
{
|
|
168
|
-
id:
|
|
169
|
-
type: n.type ??
|
|
169
|
+
id: w,
|
|
170
|
+
type: n.type ?? A.calloutType,
|
|
170
171
|
message: n.message,
|
|
171
172
|
divider: _
|
|
172
173
|
}
|
|
@@ -175,27 +176,27 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), fe = (e, i) => {
|
|
|
175
176
|
a ? /* @__PURE__ */ o(
|
|
176
177
|
"div",
|
|
177
178
|
{
|
|
178
|
-
id:
|
|
179
|
+
id: k,
|
|
179
180
|
className: "text-[13px] leading-[1.6] text-[var(--malachite-text-secondary)]",
|
|
180
181
|
children: a
|
|
181
182
|
}
|
|
182
183
|
) : null,
|
|
183
184
|
z,
|
|
184
185
|
t ? /* @__PURE__ */ o(
|
|
185
|
-
|
|
186
|
+
ve,
|
|
186
187
|
{
|
|
187
188
|
phrase: t,
|
|
188
|
-
parts:
|
|
189
|
-
plainLabel:
|
|
189
|
+
parts: H,
|
|
190
|
+
plainLabel: j,
|
|
190
191
|
placeholder: x,
|
|
191
|
-
value:
|
|
192
|
+
value: B,
|
|
192
193
|
onChange: L,
|
|
193
194
|
disabled: r,
|
|
194
195
|
copyLabel: y,
|
|
195
|
-
copyOutcome:
|
|
196
|
-
canCopy:
|
|
197
|
-
onCopy:
|
|
198
|
-
nearMissMessage:
|
|
196
|
+
copyOutcome: W,
|
|
197
|
+
canCopy: Z,
|
|
198
|
+
onCopy: J,
|
|
199
|
+
nearMissMessage: K
|
|
199
200
|
}
|
|
200
201
|
) : null
|
|
201
202
|
] }) : null
|
|
@@ -204,7 +205,7 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), fe = (e, i) => {
|
|
|
204
205
|
);
|
|
205
206
|
};
|
|
206
207
|
export {
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
$e as ConfirmationDialog,
|
|
209
|
+
$e as default
|
|
209
210
|
};
|
|
210
211
|
//# sourceMappingURL=ConfirmationDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmationDialog.js","sources":["../../src/components/ConfirmationDialog.tsx"],"sourcesContent":["import type React from 'react';\nimport { Children, useId, useState } from 'react';\nimport type { AlertType } from './Alert';\nimport Button from './Button';\nimport CalloutStrip from './CalloutStrip';\nimport CheckCircleFilled from './CustomIcons/CheckCircleFilled';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport CopyIcon from './CustomIcons/CopyIcon';\nimport ErrorCircleFilled from './CustomIcons/ErrorCircleFilled';\nimport InfoCircleFilled from './CustomIcons/InfoCircleFilled';\nimport WarningCircleFilled from './CustomIcons/WarningCircleFilled';\nimport FieldMessage from './FieldMessage';\nimport IconBadge from './IconBadge';\nimport { Input } from './Input';\nimport Modal, { type ModalSize } from './Modal';\nimport Typography from './Typography';\nimport { type CopyOutcome, useClipboardCopy } from './useClipboardCopy';\nimport {\n CONFIRMATION_DIALOG_VARIANTS,\n type ConfirmationDialogVariant,\n} from './confirmationDialogVariants';\n\n/** Kept beside the component: an icon is a node, not a value the variant table can hold. */\nconst BADGE_GLYPH_SIZE = 12;\n\nconst collapseSpaces = (value: string) => value.replace(/\\s+/g, ' ');\n\nconst nearMissAgainst = (typed: string, phrase: string): string | undefined => {\n if (phrase === '' || typed === '' || typed === phrase) {\n return undefined;\n }\n if (collapseSpaces(typed).toLowerCase() !== collapseSpaces(phrase).toLowerCase()) {\n return undefined;\n }\n return collapseSpaces(typed) === collapseSpaces(phrase)\n ? 'The spacing has to match exactly.'\n : 'This is case-sensitive.';\n};\n\ntype PhraseLabel = string | { prefix: string; suffix?: string };\n\nconst COPY_FAILED_MESSAGE = 'Could not copy. Enter the phrase manually.';\n\nconst resolvePhraseLabel = (\n label: PhraseLabel | undefined,\n phrase?: string,\n): { parts?: { prefix: string; suffix?: string }; text: string } => {\n const parts = typeof label === 'object' && label !== null ? label : undefined;\n if (parts) {\n return { parts, text: [parts.prefix, phrase, parts.suffix].filter(Boolean).join(' ') };\n }\n return { text: typeof label === 'string' ? label : `Type ${phrase} to confirm` };\n};\n\nconst copyStatusFor = (outcome: CopyOutcome, phrase: string): string =>\n outcome === 'copied' ? `${phrase} copied to clipboard` : '';\n\nconst usePhraseCopy = (\n phrase: string | undefined,\n open: boolean,\n disabled: boolean,\n onCopied?: (phrase: string) => void,\n): { outcome: CopyOutcome; canCopy: boolean; copy: () => void } => {\n const { outcome, canCopy, copy } = useClipboardCopy(`${open}|${phrase}`);\n\n const run = async () => {\n if (phrase && (await copy(phrase))) {\n queueMicrotask(() => onCopied?.(phrase));\n }\n };\n\n return { outcome, canCopy: canCopy && !disabled, copy: () => void run() };\n};\n\nconst LabelText: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <Typography.Text size=\"small\" color=\"primary\">\n {children}\n </Typography.Text>\n);\n\ninterface PhraseFieldProps {\n phrase: string;\n parts?: { prefix: string; suffix?: string };\n plainLabel: string;\n placeholder?: string;\n value: string;\n onChange: (value: string) => void;\n disabled: boolean;\n copyLabel: string;\n copyOutcome: CopyOutcome;\n canCopy: boolean;\n onCopy: () => void;\n nearMissMessage?: string;\n}\n\nconst PhraseField: React.FC<PhraseFieldProps> = ({\n phrase,\n parts,\n plainLabel,\n placeholder,\n value,\n onChange,\n disabled,\n copyLabel,\n copyOutcome,\n canCopy,\n onCopy,\n nearMissMessage,\n}) => {\n const beforeId = useId();\n const afterId = useId();\n const messageId = useId();\n const inputId = useId();\n const message =\n [nearMissMessage, copyOutcome === 'failed' ? COPY_FAILED_MESSAGE : undefined]\n .filter(Boolean)\n .join(' ') || undefined;\n const labelledBy = parts\n ? [beforeId, parts.suffix ? afterId : undefined].filter(Boolean).join(' ')\n : undefined;\n\n return (\n <div className=\"flex flex-col gap-[6px]\">\n {parts ? (\n <div className=\"flex flex-wrap items-center gap-[6px] px-2 text-[13px]\">\n <span id={beforeId}>\n <LabelText>{parts.prefix}</LabelText>{' '}\n <Typography.CodeText variant=\"inline\">\n {phrase}\n </Typography.CodeText>\n </span>\n <Button\n variant=\"ghost\"\n size=\"small\"\n iconOnly\n aria-label={`${copyLabel} ${phrase}`}\n icon={\n copyOutcome === 'copied' ? (\n <CheckmarkIcon size={13} />\n ) : (\n <CopyIcon size={13} />\n )\n }\n onClick={onCopy}\n disabled={!canCopy}\n />\n {parts.suffix ? (\n <span id={afterId}>\n <LabelText>{parts.suffix}</LabelText>\n </span>\n ) : null}\n </div>\n ) : (\n <label id={beforeId} htmlFor={inputId} className=\"px-2 text-[13px]\">\n <LabelText>{plainLabel}</LabelText>\n </label>\n )}\n <Input\n id={inputId}\n name=\"confirmation-phrase\"\n size=\"medium\"\n value={value}\n onChange={onChange}\n aria-labelledby={labelledBy}\n placeholder={placeholder}\n requiredIndicator=\"none\"\n error={!!nearMissMessage}\n aria-describedby={message ? messageId : undefined}\n disabled={disabled}\n />\n <FieldMessage id={messageId} message={message} />\n {parts ? (\n <span role=\"status\" className=\"sr-only\">\n {copyStatusFor(copyOutcome, phrase)}\n </span>\n ) : null}\n </div>\n );\n};\n\nconst VARIANT_ICON: Record<ConfirmationDialogVariant, React.ReactNode> = {\n default: <InfoCircleFilled size={BADGE_GLYPH_SIZE} />,\n warning: <WarningCircleFilled size={BADGE_GLYPH_SIZE} />,\n destructive: <ErrorCircleFilled size={BADGE_GLYPH_SIZE} />,\n success: <CheckCircleFilled size={BADGE_GLYPH_SIZE} />,\n};\n\nexport interface ConfirmationDialogProps {\n open: boolean;\n /** Dismiss handler — cancel, close button, ESC or scrim. `loading` suppresses every\n * route except ESC, which always reaches this so a keyboard user is never stranded. */\n onClose: () => void;\n /** Runs when the confirm action is taken. Closing is left to the consumer. */\n onConfirm: () => void;\n title: React.ReactNode;\n titleAdornment?: React.ReactNode;\n badgeIcon?: React.ReactNode;\n /** The sentence saying what is about to happen. */\n description?: React.ReactNode;\n variant?: ConfirmationDialogVariant;\n /** Coloured callout below the body. Defaults to the variant's own type. */\n callout?: { type?: AlertType; message: string };\n /**\n * Requires this phrase, ends trimmed, to be typed before the confirm action enables — for a\n * consequence severe enough that a single click should not be able to cause it.\n */\n confirmPhrase?: string;\n /** Label above the type-to-confirm field. `{ prefix, suffix }` makes the phrase copyable. */\n confirmPhraseLabel?: PhraseLabel;\n /** Names the copy control, e.g. `Copy profile name`. Default: `Copy`. */\n confirmPhraseCopyLabel?: string;\n /** Runs after the phrase reaches the clipboard, with what was copied. */\n onPhraseCopied?: (phrase: string) => void;\n confirmPhrasePlaceholder?: string;\n confirmLabel?: string;\n cancelLabel?: string;\n /**\n * Disables the actions, spins the confirm button and suppresses the pointer dismissal\n * routes — but never ESC, which always reaches `onClose`.\n */\n loading?: boolean;\n tip?: { label?: string; message: string };\n size?: ModalSize;\n /** Accessible dialog name; required when `title` isn't a plain string. */\n 'aria-label'?: string;\n /** ID of a visible element naming the dialog (alternative to `aria-label`). */\n 'aria-labelledby'?: string;\n /** Extra body content between the description and the callout, e.g. an entity chip. */\n children?: React.ReactNode;\n}\n\nconst ConfirmationDialog: React.FC<ConfirmationDialogProps> = ({\n open,\n onClose,\n onConfirm,\n title,\n titleAdornment,\n badgeIcon,\n description,\n variant = 'default',\n callout,\n confirmPhrase,\n confirmPhraseLabel,\n confirmPhraseCopyLabel = 'Copy',\n onPhraseCopied,\n confirmPhrasePlaceholder,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n loading = false,\n tip,\n size = 'medium',\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n children,\n}) => {\n const [typedPhrase, setTypedPhrase] = useState('');\n const descriptionId = useId();\n const calloutId = useId();\n const base = CONFIRMATION_DIALOG_VARIANTS[variant];\n\n // On open, not close: the dialog outlives `open` by its exit transition, so resetting on\n // close empties the field in front of the user. Adjusted during render rather than from an\n // effect, or a reopen paints the previous answer once with confirm already enabled.\n const [answeredFor, setAnsweredFor] = useState({ open, confirmPhrase });\n if (answeredFor.open !== open || answeredFor.confirmPhrase !== confirmPhrase) {\n setAnsweredFor({ open, confirmPhrase });\n if (open) {\n setTypedPhrase('');\n }\n }\n\n const { parts: phraseParts, text: phraseLabel } = resolvePhraseLabel(\n confirmPhraseLabel,\n confirmPhrase,\n );\n const {\n outcome: copyOutcome,\n canCopy: canCopyPhrase,\n copy: handleCopyPhrase,\n } = usePhraseCopy(confirmPhrase, open, loading, onPhraseCopied);\n // Both sides trimmed, as copied and saved names pick up padding that never renders. A\n // whitespace-only phrase is matched as given, so an empty field cannot confirm it.\n const typed = typedPhrase.trim();\n const phrase = confirmPhrase?.trim() ?? '';\n const phraseSatisfied =\n !confirmPhrase || (phrase === '' ? typedPhrase === confirmPhrase : typed === phrase);\n const nearMissMessage = nearMissAgainst(typed, phrase);\n const confirmDisabled = loading || !phraseSatisfied;\n const hasChildren = Children.toArray(children).some(\n (child) => typeof child !== 'string' || child.trim() !== '',\n );\n const hasBody = Boolean(description) || hasChildren || Boolean(confirmPhrase);\n // The callout is often the whole consequence, so it is announced along with the description.\n const describedBy =\n [callout ? calloutId : null, description ? descriptionId : null]\n .filter(Boolean)\n .join(' ') || undefined;\n\n const footer = (\n <div className=\"flex w-full flex-wrap items-center justify-end gap-[8px]\">\n <Button variant=\"outline\" size=\"small\" onClick={onClose} disabled={loading}>\n {cancelLabel}\n </Button>\n <Button\n variant={base.confirmVariant}\n size=\"small\"\n onClick={onConfirm}\n disabled={confirmDisabled}\n loading={loading}\n // A disabled control emits no hover, so the tooltip explains the gate from the\n // wrapper Button renders for exactly this case.\n tooltip={!loading && !phraseSatisfied ? phraseLabel : undefined}\n >\n {confirmLabel}\n </Button>\n </div>\n );\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title={title}\n size={size}\n footer={footer}\n busy={loading}\n // A consequential choice is an alertdialog: it asks assistive tech to announce the\n // body, which is where the consequence is written.\n role={variant === 'destructive' ? 'alertdialog' : 'dialog'}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={describedBy}\n // A choice this deliberate should not be undone by a stray click, and a scrim\n // click must not discard a phrase the customer has already typed.\n closeOnOverlayClick={variant !== 'destructive' && !confirmPhrase}\n headerDivider\n titleAdornment={titleAdornment}\n bodyPadding={false}\n tray={{ tone: base.tray, caption: tip }}\n icon={\n <IconBadge\n variant={variant}\n icon={badgeIcon ?? VARIANT_ICON[variant]}\n />\n }\n >\n {callout ? (\n <CalloutStrip\n id={calloutId}\n type={callout.type ?? base.calloutType}\n message={callout.message}\n divider={hasBody}\n />\n ) : null}\n {hasBody ? (\n <div className=\"flex flex-col gap-[12px] p-[28px]\">\n {description ? (\n <div\n id={descriptionId}\n className=\"text-[13px] leading-[1.6] text-[var(--malachite-text-secondary)]\"\n >\n {description}\n </div>\n ) : null}\n {children}\n {confirmPhrase ? (\n <PhraseField\n phrase={confirmPhrase}\n parts={phraseParts}\n plainLabel={phraseLabel}\n placeholder={confirmPhrasePlaceholder}\n value={typedPhrase}\n onChange={setTypedPhrase}\n disabled={loading}\n copyLabel={confirmPhraseCopyLabel}\n copyOutcome={copyOutcome}\n canCopy={canCopyPhrase}\n onCopy={handleCopyPhrase}\n nearMissMessage={nearMissMessage}\n />\n ) : null}\n </div>\n ) : null}\n </Modal>\n );\n};\n\nexport default ConfirmationDialog;\nexport { ConfirmationDialog };\nexport type { ConfirmationDialogVariant };\n"],"names":["BADGE_GLYPH_SIZE","collapseSpaces","value","nearMissAgainst","typed","phrase","COPY_FAILED_MESSAGE","resolvePhraseLabel","label","parts","copyStatusFor","outcome","usePhraseCopy","open","disabled","onCopied","canCopy","copy","useClipboardCopy","run","LabelText","children","jsx","Typography","PhraseField","plainLabel","placeholder","onChange","copyLabel","copyOutcome","onCopy","nearMissMessage","beforeId","useId","afterId","messageId","inputId","message","labelledBy","jsxs","Button","CheckmarkIcon","CopyIcon","Input","FieldMessage","VARIANT_ICON","InfoCircleFilled","WarningCircleFilled","ErrorCircleFilled","CheckCircleFilled","ConfirmationDialog","onClose","onConfirm","title","titleAdornment","badgeIcon","description","variant","callout","confirmPhrase","confirmPhraseLabel","confirmPhraseCopyLabel","onPhraseCopied","confirmPhrasePlaceholder","confirmLabel","cancelLabel","loading","tip","size","ariaLabel","ariaLabelledBy","typedPhrase","setTypedPhrase","useState","descriptionId","calloutId","base","CONFIRMATION_DIALOG_VARIANTS","answeredFor","setAnsweredFor","phraseParts","phraseLabel","canCopyPhrase","handleCopyPhrase","phraseSatisfied","confirmDisabled","hasChildren","Children","child","hasBody","describedBy","footer","Modal","IconBadge","CalloutStrip"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAMA,IAAmB,IAEnBC,IAAiB,CAACC,MAAkBA,EAAM,QAAQ,QAAQ,GAAG,GAE7DC,KAAkB,CAACC,GAAeC,MAAuC;AAC3E,MAAI,EAAAA,MAAW,MAAMD,MAAU,MAAMA,MAAUC,MAG3CJ,EAAeG,CAAK,EAAE,YAAA,MAAkBH,EAAeI,CAAM,EAAE;AAGnE,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,UACHnC;AAAA,UACAsC,IACG,gBAAArC;AAAA,YAACE;AAAA,YAAA;AAAA,cACG,QAAQmC;AAAA,cACR,OAAOqB;AAAA,cACP,YAAYC;AAAA,cACZ,aAAalB;AAAA,cACb,OAAOQ;AAAA,cACP,UAAUC;AAAA,cACV,UAAUN;AAAA,cACV,WAAWL;AAAA,cACX,aAAAhC;AAAA,cACA,SAASqD;AAAA,cACT,QAAQC;AAAA,cACR,iBAAApD;AAAA,YAAA;AAAA,UAAA,IAEJ;AAAA,QAAA,EAAA,CACR,IACA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGhB;"}
|
|
1
|
+
{"version":3,"file":"ConfirmationDialog.js","sources":["../../src/components/ConfirmationDialog.tsx"],"sourcesContent":["import type React from 'react';\nimport { Children, useId, useState } from 'react';\nimport type { AlertType } from './Alert';\nimport Button from './Button';\nimport CalloutStrip from './CalloutStrip';\nimport CheckCircleFilled from './CustomIcons/CheckCircleFilled';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport CopyIcon from './CustomIcons/CopyIcon';\nimport ErrorCircleFilled from './CustomIcons/ErrorCircleFilled';\nimport InfoCircleFilled from './CustomIcons/InfoCircleFilled';\nimport WarningCircleFilled from './CustomIcons/WarningCircleFilled';\nimport FieldMessage from './FieldMessage';\nimport IconBadge from './IconBadge';\nimport { Input } from './Input';\nimport Modal, { type ModalSize } from './Modal';\nimport Typography from './Typography';\nimport { type CopyOutcome, useClipboardCopy } from './useClipboardCopy';\nimport {\n CONFIRMATION_DIALOG_VARIANTS,\n type ConfirmationDialogVariant,\n} from './confirmationDialogVariants';\n\n/** Kept beside the component: an icon is a node, not a value the variant table can hold. */\nconst BADGE_GLYPH_SIZE = 12;\n\nconst collapseSpaces = (value: string) => value.replace(/\\s+/g, ' ');\n\nconst nearMissAgainst = (typed: string, phrase: string): string | undefined => {\n if (phrase === '' || typed === '' || typed === phrase) {\n return undefined;\n }\n if (collapseSpaces(typed).toLowerCase() !== collapseSpaces(phrase).toLowerCase()) {\n return undefined;\n }\n return collapseSpaces(typed) === collapseSpaces(phrase)\n ? 'The spacing has to match exactly.'\n : 'This is case-sensitive.';\n};\n\ntype PhraseLabel = string | { prefix: string; suffix?: string };\n\nconst COPY_FAILED_MESSAGE = 'Could not copy. Enter the phrase manually.';\n\nconst resolvePhraseLabel = (\n label: PhraseLabel | undefined,\n phrase?: string,\n): { parts?: { prefix: string; suffix?: string }; text: string } => {\n const parts = typeof label === 'object' && label !== null ? label : undefined;\n if (parts) {\n return { parts, text: [parts.prefix, phrase, parts.suffix].filter(Boolean).join(' ') };\n }\n return { text: typeof label === 'string' ? label : `Type ${phrase} to confirm` };\n};\n\nconst copyStatusFor = (outcome: CopyOutcome, phrase: string): string =>\n outcome === 'copied' ? `${phrase} copied to clipboard` : '';\n\nconst usePhraseCopy = (\n phrase: string | undefined,\n open: boolean,\n disabled: boolean,\n onCopied?: (phrase: string) => void,\n): { outcome: CopyOutcome; canCopy: boolean; copy: () => void } => {\n const { outcome, canCopy, copy } = useClipboardCopy(`${open}|${phrase}`);\n\n const run = async () => {\n if (phrase && (await copy(phrase))) {\n queueMicrotask(() => onCopied?.(phrase));\n }\n };\n\n return { outcome, canCopy: canCopy && !disabled, copy: () => void run() };\n};\n\nconst LabelText: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <Typography.Text size=\"small\" color=\"primary\">\n {children}\n </Typography.Text>\n);\n\ninterface PhraseFieldProps {\n phrase: string;\n parts?: { prefix: string; suffix?: string };\n plainLabel: string;\n placeholder?: string;\n value: string;\n onChange: (value: string) => void;\n disabled: boolean;\n copyLabel: string;\n copyOutcome: CopyOutcome;\n canCopy: boolean;\n onCopy: () => void;\n nearMissMessage?: string;\n}\n\nconst PhraseField: React.FC<PhraseFieldProps> = ({\n phrase,\n parts,\n plainLabel,\n placeholder,\n value,\n onChange,\n disabled,\n copyLabel,\n copyOutcome,\n canCopy,\n onCopy,\n nearMissMessage,\n}) => {\n const beforeId = useId();\n const afterId = useId();\n const messageId = useId();\n const inputId = useId();\n const message =\n [nearMissMessage, copyOutcome === 'failed' ? COPY_FAILED_MESSAGE : undefined]\n .filter(Boolean)\n .join(' ') || undefined;\n const labelledBy = parts\n ? [beforeId, parts.suffix ? afterId : undefined].filter(Boolean).join(' ')\n : undefined;\n\n return (\n <div className=\"flex flex-col gap-[6px]\">\n {parts ? (\n <div className=\"flex flex-wrap items-center gap-[6px] px-2 text-[13px]\">\n <span id={beforeId}>\n <LabelText>{parts.prefix}</LabelText>{' '}\n <Typography.CodeText variant=\"inline\">\n {phrase}\n </Typography.CodeText>\n </span>\n <Button\n variant=\"ghost\"\n size=\"small\"\n iconOnly\n aria-label={`${copyLabel} ${phrase}`}\n icon={\n copyOutcome === 'copied' ? (\n <CheckmarkIcon size={13} />\n ) : (\n <CopyIcon size={13} />\n )\n }\n onClick={onCopy}\n disabled={!canCopy}\n />\n {parts.suffix ? (\n <span id={afterId}>\n <LabelText>{parts.suffix}</LabelText>\n </span>\n ) : null}\n </div>\n ) : (\n <label id={beforeId} htmlFor={inputId} className=\"px-2 text-[13px]\">\n <LabelText>{plainLabel}</LabelText>\n </label>\n )}\n <Input\n id={inputId}\n name=\"confirmation-phrase\"\n size=\"medium\"\n value={value}\n onChange={onChange}\n aria-labelledby={labelledBy}\n placeholder={placeholder}\n requiredIndicator=\"none\"\n error={!!nearMissMessage}\n aria-describedby={message ? messageId : undefined}\n disabled={disabled}\n />\n <FieldMessage id={messageId} message={message} />\n {parts ? (\n <span role=\"status\" className=\"sr-only\">\n {copyStatusFor(copyOutcome, phrase)}\n </span>\n ) : null}\n </div>\n );\n};\n\nconst VARIANT_ICON: Record<ConfirmationDialogVariant, React.ReactNode> = {\n default: <InfoCircleFilled size={BADGE_GLYPH_SIZE} />,\n warning: <WarningCircleFilled size={BADGE_GLYPH_SIZE} />,\n destructive: <ErrorCircleFilled size={BADGE_GLYPH_SIZE} />,\n success: <CheckCircleFilled size={BADGE_GLYPH_SIZE} />,\n};\n\nexport interface ConfirmationDialogProps {\n open: boolean;\n /** Dismiss handler — cancel, close button, ESC or scrim. `loading` suppresses every\n * route except ESC, which always reaches this so a keyboard user is never stranded. */\n onClose: () => void;\n /** Runs when the confirm action is taken. Closing is left to the consumer. */\n onConfirm: () => void;\n title: React.ReactNode;\n titleAdornment?: React.ReactNode;\n badgeIcon?: React.ReactNode;\n /** The sentence saying what is about to happen. */\n description?: React.ReactNode;\n variant?: ConfirmationDialogVariant;\n /** Coloured callout below the body. Defaults to the variant's own type. */\n callout?: { type?: AlertType; message: string };\n /**\n * Requires this phrase, ends trimmed, to be typed before the confirm action enables — for a\n * consequence severe enough that a single click should not be able to cause it.\n */\n confirmPhrase?: string;\n /** Label above the type-to-confirm field. `{ prefix, suffix }` makes the phrase copyable. */\n confirmPhraseLabel?: PhraseLabel;\n /** Names the copy control, e.g. `Copy profile name`. Default: `Copy`. */\n confirmPhraseCopyLabel?: string;\n /** Runs after the phrase reaches the clipboard, with what was copied. */\n onPhraseCopied?: (phrase: string) => void;\n confirmPhrasePlaceholder?: string;\n confirmLabel?: string;\n cancelLabel?: string;\n /**\n * Disables the actions, spins the confirm button and suppresses the pointer dismissal\n * routes — but never ESC, which always reaches `onClose`.\n */\n loading?: boolean;\n /**\n * Holds the confirm action back while the consequence is not yet known, say while a check\n * the callout reports on is still running. Cancel and every dismissal route stay live. The\n * held button has no tooltip, so pair it with a callout that says why.\n */\n confirmDisabled?: boolean;\n tip?: { label?: string; message: string };\n size?: ModalSize;\n /** Accessible dialog name; required when `title` isn't a plain string. */\n 'aria-label'?: string;\n /** ID of a visible element naming the dialog (alternative to `aria-label`). */\n 'aria-labelledby'?: string;\n /** Extra body content between the description and the callout, e.g. an entity chip. */\n children?: React.ReactNode;\n}\n\nconst ConfirmationDialog: React.FC<ConfirmationDialogProps> = ({\n open,\n onClose,\n onConfirm,\n title,\n titleAdornment,\n badgeIcon,\n description,\n variant = 'default',\n callout,\n confirmPhrase,\n confirmPhraseLabel,\n confirmPhraseCopyLabel = 'Copy',\n onPhraseCopied,\n confirmPhrasePlaceholder,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n loading = false,\n confirmDisabled = false,\n tip,\n size = 'medium',\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n children,\n}) => {\n const [typedPhrase, setTypedPhrase] = useState('');\n const descriptionId = useId();\n const calloutId = useId();\n const base = CONFIRMATION_DIALOG_VARIANTS[variant];\n\n // On open, not close: the dialog outlives `open` by its exit transition, so resetting on\n // close empties the field in front of the user. Adjusted during render rather than from an\n // effect, or a reopen paints the previous answer once with confirm already enabled.\n const [answeredFor, setAnsweredFor] = useState({ open, confirmPhrase });\n if (answeredFor.open !== open || answeredFor.confirmPhrase !== confirmPhrase) {\n setAnsweredFor({ open, confirmPhrase });\n if (open) {\n setTypedPhrase('');\n }\n }\n\n const { parts: phraseParts, text: phraseLabel } = resolvePhraseLabel(\n confirmPhraseLabel,\n confirmPhrase,\n );\n const {\n outcome: copyOutcome,\n canCopy: canCopyPhrase,\n copy: handleCopyPhrase,\n } = usePhraseCopy(confirmPhrase, open, loading, onPhraseCopied);\n // Both sides trimmed, as copied and saved names pick up padding that never renders. A\n // whitespace-only phrase is matched as given, so an empty field cannot confirm it.\n const typed = typedPhrase.trim();\n const phrase = confirmPhrase?.trim() ?? '';\n const phraseSatisfied =\n !confirmPhrase || (phrase === '' ? typedPhrase === confirmPhrase : typed === phrase);\n const nearMissMessage = nearMissAgainst(typed, phrase);\n const confirmBlocked = loading || confirmDisabled || !phraseSatisfied;\n const hasChildren = Children.toArray(children).some(\n (child) => typeof child !== 'string' || child.trim() !== '',\n );\n const hasBody = Boolean(description) || hasChildren || Boolean(confirmPhrase);\n // The callout is often the whole consequence, so it is announced along with the description.\n const describedBy =\n [callout ? calloutId : null, description ? descriptionId : null]\n .filter(Boolean)\n .join(' ') || undefined;\n\n const footer = (\n <div className=\"flex w-full flex-wrap items-center justify-end gap-[8px]\">\n <Button variant=\"outline\" size=\"small\" onClick={onClose} disabled={loading}>\n {cancelLabel}\n </Button>\n <Button\n variant={base.confirmVariant}\n size=\"small\"\n onClick={onConfirm}\n disabled={confirmBlocked}\n loading={loading}\n // A disabled control emits no hover, so the tooltip explains the gate from the\n // wrapper Button renders for exactly this case.\n tooltip={!loading && !phraseSatisfied ? phraseLabel : undefined}\n >\n {confirmLabel}\n </Button>\n </div>\n );\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title={title}\n size={size}\n footer={footer}\n busy={loading}\n // A consequential choice is an alertdialog: it asks assistive tech to announce the\n // body, which is where the consequence is written.\n role={variant === 'destructive' ? 'alertdialog' : 'dialog'}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={describedBy}\n // A choice this deliberate should not be undone by a stray click, and a scrim\n // click must not discard a phrase the customer has already typed.\n closeOnOverlayClick={variant !== 'destructive' && !confirmPhrase}\n headerDivider\n titleAdornment={titleAdornment}\n bodyPadding={false}\n tray={{ tone: base.tray, caption: tip }}\n icon={\n <IconBadge\n variant={variant}\n icon={badgeIcon ?? VARIANT_ICON[variant]}\n />\n }\n >\n {callout ? (\n <CalloutStrip\n id={calloutId}\n type={callout.type ?? base.calloutType}\n message={callout.message}\n divider={hasBody}\n />\n ) : null}\n {hasBody ? (\n <div className=\"flex flex-col gap-[12px] p-[28px]\">\n {description ? (\n <div\n id={descriptionId}\n className=\"text-[13px] leading-[1.6] text-[var(--malachite-text-secondary)]\"\n >\n {description}\n </div>\n ) : null}\n {children}\n {confirmPhrase ? (\n <PhraseField\n phrase={confirmPhrase}\n parts={phraseParts}\n plainLabel={phraseLabel}\n placeholder={confirmPhrasePlaceholder}\n value={typedPhrase}\n onChange={setTypedPhrase}\n disabled={loading}\n copyLabel={confirmPhraseCopyLabel}\n copyOutcome={copyOutcome}\n canCopy={canCopyPhrase}\n onCopy={handleCopyPhrase}\n nearMissMessage={nearMissMessage}\n />\n ) : null}\n </div>\n ) : null}\n </Modal>\n );\n};\n\nexport default ConfirmationDialog;\nexport { ConfirmationDialog };\nexport type { ConfirmationDialogVariant };\n"],"names":["BADGE_GLYPH_SIZE","collapseSpaces","value","nearMissAgainst","typed","phrase","COPY_FAILED_MESSAGE","resolvePhraseLabel","label","parts","copyStatusFor","outcome","usePhraseCopy","open","disabled","onCopied","canCopy","copy","useClipboardCopy","run","LabelText","children","jsx","Typography","PhraseField","plainLabel","placeholder","onChange","copyLabel","copyOutcome","onCopy","nearMissMessage","beforeId","useId","afterId","messageId","inputId","message","labelledBy","jsxs","Button","CheckmarkIcon","CopyIcon","Input","FieldMessage","VARIANT_ICON","InfoCircleFilled","WarningCircleFilled","ErrorCircleFilled","CheckCircleFilled","ConfirmationDialog","onClose","onConfirm","title","titleAdornment","badgeIcon","description","variant","callout","confirmPhrase","confirmPhraseLabel","confirmPhraseCopyLabel","onPhraseCopied","confirmPhrasePlaceholder","confirmLabel","cancelLabel","loading","confirmDisabled","tip","size","ariaLabel","ariaLabelledBy","typedPhrase","setTypedPhrase","useState","descriptionId","calloutId","base","CONFIRMATION_DIALOG_VARIANTS","answeredFor","setAnsweredFor","phraseParts","phraseLabel","canCopyPhrase","handleCopyPhrase","phraseSatisfied","confirmBlocked","hasChildren","Children","child","hasBody","describedBy","footer","Modal","IconBadge","CalloutStrip"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAMA,IAAmB,IAEnBC,IAAiB,CAACC,MAAkBA,EAAM,QAAQ,QAAQ,GAAG,GAE7DC,KAAkB,CAACC,GAAeC,MAAuC;AAC3E,MAAI,EAAAA,MAAW,MAAMD,MAAU,MAAMA,MAAUC,MAG3CJ,EAAeG,CAAK,EAAE,YAAA,MAAkBH,EAAeI,CAAM,EAAE;AAGnE,WAAOJ,EAAeG,CAAK,MAAMH,EAAeI,CAAM,IAChD,sCACA;AACV,GAIMC,KAAsB,8CAEtBC,KAAqB,CACvBC,GACAH,MACgE;AAChE,QAAMI,IAAQ,OAAOD,KAAU,YAAYA,MAAU,OAAOA,IAAQ;AACpE,S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ACb,OAAOS;AAAA,cACP,UAAUC;AAAA,cACV,UAAUP;AAAA,cACV,WAAWL;AAAA,cACX,aAAAhC;AAAA,cACA,SAASsD;AAAA,cACT,QAAQC;AAAA,cACR,iBAAArD;AAAA,YAAA;AAAA,UAAA,IAEJ;AAAA,QAAA,EAAA,CACR,IACA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGhB;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsxs as d, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { Button as e } from "./Button.js";
|
|
3
|
+
const b = ({
|
|
4
|
+
primary: t,
|
|
5
|
+
secondary: l,
|
|
6
|
+
size: i = "medium",
|
|
7
|
+
className: n = ""
|
|
8
|
+
}) => /* @__PURE__ */ d("div", { className: `flex items-center justify-end gap-[8px] ${n}`, children: [
|
|
9
|
+
l ? /* @__PURE__ */ o(
|
|
10
|
+
e,
|
|
11
|
+
{
|
|
12
|
+
variant: "outline",
|
|
13
|
+
size: i,
|
|
14
|
+
type: "button",
|
|
15
|
+
disabled: l.disabled,
|
|
16
|
+
loading: l.loading,
|
|
17
|
+
tooltip: l.tooltip,
|
|
18
|
+
onClick: l.onClick,
|
|
19
|
+
children: l.label
|
|
20
|
+
}
|
|
21
|
+
) : null,
|
|
22
|
+
t ? /* @__PURE__ */ o(
|
|
23
|
+
e,
|
|
24
|
+
{
|
|
25
|
+
variant: t.tone === "destructive" ? "destructive" : "filled",
|
|
26
|
+
size: i,
|
|
27
|
+
type: t.type ?? "button",
|
|
28
|
+
disabled: t.disabled,
|
|
29
|
+
loading: t.loading,
|
|
30
|
+
tooltip: t.tooltip,
|
|
31
|
+
onClick: t.onClick,
|
|
32
|
+
children: t.label
|
|
33
|
+
}
|
|
34
|
+
) : null
|
|
35
|
+
] });
|
|
36
|
+
export {
|
|
37
|
+
b as FormActions,
|
|
38
|
+
b as default
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=FormActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormActions.js","sources":["../../src/components/FormActions.tsx"],"sourcesContent":["import React from 'react';\nimport { Button } from './Button';\n\nexport interface FormAction {\n label: string;\n onClick?: () => void;\n disabled?: boolean;\n loading?: boolean;\n tooltip?: string;\n}\n\nexport interface FormPrimaryAction extends FormAction {\n /** `destructive` for an action that deletes or revokes. */\n tone?: 'default' | 'destructive';\n /**\n * `submit` makes it the form's submit button, so Enter in a field presses it. Leave `onClick`\n * off then and handle the form's `onSubmit` (a `SidePanel`'s, say), or a click runs both.\n */\n type?: 'button' | 'submit';\n}\n\nexport interface FormActionsProps {\n /** The filled action, last in the row. */\n primary?: FormPrimaryAction;\n /** The outline action before it, usually Cancel. */\n secondary?: FormAction;\n size?: 'small' | 'medium';\n className?: string;\n}\n\n/** A form's Cancel and primary pair, end-aligned: a side panel's footer, or under a settings section. */\nconst FormActions: React.FC<FormActionsProps> = ({\n primary,\n secondary,\n size = 'medium',\n className = '',\n}) => (\n <div className={`flex items-center justify-end gap-[8px] ${className}`}>\n {secondary ? (\n <Button\n variant=\"outline\"\n size={size}\n type=\"button\"\n disabled={secondary.disabled}\n loading={secondary.loading}\n tooltip={secondary.tooltip}\n onClick={secondary.onClick}\n >\n {secondary.label}\n </Button>\n ) : null}\n {primary ? (\n <Button\n variant={primary.tone === 'destructive' ? 'destructive' : 'filled'}\n size={size}\n type={primary.type ?? 'button'}\n disabled={primary.disabled}\n loading={primary.loading}\n tooltip={primary.tooltip}\n onClick={primary.onClick}\n >\n {primary.label}\n </Button>\n ) : null}\n </div>\n);\n\nexport default FormActions;\nexport { FormActions };\n"],"names":["FormActions","primary","secondary","size","className","jsxs","jsx","Button"],"mappings":";;AA+BA,MAAMA,IAA0C,CAAC;AAAA,EAC7C,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,WAAAC,IAAY;AAChB,MACI,gBAAAC,EAAC,OAAA,EAAI,WAAW,2CAA2CD,CAAS,IAC/D,UAAA;AAAA,EAAAF,IACG,gBAAAI;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,SAAQ;AAAA,MACR,MAAAJ;AAAA,MACA,MAAK;AAAA,MACL,UAAUD,EAAU;AAAA,MACpB,SAASA,EAAU;AAAA,MACnB,SAASA,EAAU;AAAA,MACnB,SAASA,EAAU;AAAA,MAElB,UAAAA,EAAU;AAAA,IAAA;AAAA,EAAA,IAEf;AAAA,EACHD,IACG,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,SAASN,EAAQ,SAAS,gBAAgB,gBAAgB;AAAA,MAC1D,MAAAE;AAAA,MACA,MAAMF,EAAQ,QAAQ;AAAA,MACtB,UAAUA,EAAQ;AAAA,MAClB,SAASA,EAAQ;AAAA,MACjB,SAASA,EAAQ;AAAA,MACjB,SAASA,EAAQ;AAAA,MAEhB,UAAAA,EAAQ;AAAA,IAAA;AAAA,EAAA,IAEb;AAAA,EAAA,CACR;"}
|