@stackone/malachite 2.95.0 → 2.95.1
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/dist/components/Accordion.js +112 -105
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/AppLogo.js +8 -7
- package/dist/components/AppLogo.js.map +1 -1
- package/dist/components/CollapseFocusHandOff.js +18 -0
- package/dist/components/CollapseFocusHandOff.js.map +1 -0
- package/dist/components/ConfirmationDialog.js +107 -95
- package/dist/components/ConfirmationDialog.js.map +1 -1
- package/dist/components/collapseFocus.js +22 -0
- package/dist/components/collapseFocus.js.map +1 -0
- package/dist/components/composeRefs.js +11 -11
- package/dist/components/composeRefs.js.map +1 -1
- package/dist/components/inert.js +6 -0
- package/dist/components/inert.js.map +1 -0
- package/dist/components/reactVersion.js +6 -0
- package/dist/components/reactVersion.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as p, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { useState as $, useId as d, Children as ee } from "react";
|
|
3
|
-
import { Button as
|
|
3
|
+
import { Button as z } from "./Button.js";
|
|
4
4
|
import oe from "./CalloutStrip.js";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import te from "./CustomIcons/CheckCircleFilled.js";
|
|
6
|
+
import ie from "./CustomIcons/CheckmarkIcon.js";
|
|
7
7
|
import le from "./CustomIcons/CopyIcon.js";
|
|
8
8
|
import re from "./CustomIcons/ErrorCircleFilled.js";
|
|
9
9
|
import se from "./CustomIcons/InfoCircleFilled.js";
|
|
@@ -11,24 +11,24 @@ import ae from "./CustomIcons/WarningCircleFilled.js";
|
|
|
11
11
|
import { FieldMessage as ne } from "./FieldMessage.js";
|
|
12
12
|
import { IconBadge as ce } from "./IconBadge.js";
|
|
13
13
|
import { Modal as de } from "./Modal.js";
|
|
14
|
-
import { Typography as
|
|
14
|
+
import { Typography as G } from "./Typography/index.js";
|
|
15
15
|
import { useClipboardCopy as pe } from "./useClipboardCopy.js";
|
|
16
16
|
import { CONFIRMATION_DIALOG_VARIANTS as me } from "./confirmationDialogVariants.js";
|
|
17
17
|
import fe from "./Input/Input.js";
|
|
18
|
-
const
|
|
19
|
-
if (!(
|
|
20
|
-
return
|
|
21
|
-
}, ye = "Could not copy. Enter the phrase manually.", xe = (e,
|
|
18
|
+
const h = 12, I = (e) => e.replace(/\s+/g, " "), ue = (e, t) => {
|
|
19
|
+
if (!(t === "" || e === "" || e === t) && I(e).toLowerCase() === I(t).toLowerCase())
|
|
20
|
+
return I(e) === I(t) ? "The spacing has to match exactly." : "This is case-sensitive.";
|
|
21
|
+
}, ye = "Could not copy. Enter the phrase manually.", xe = (e, t) => {
|
|
22
22
|
const l = typeof e == "object" && e !== null ? e : void 0;
|
|
23
|
-
return l ? { parts: l, text: [l.prefix,
|
|
24
|
-
}, Ce = (e,
|
|
25
|
-
const { outcome: m, canCopy: f, copy: a } = pe(`${
|
|
23
|
+
return l ? { parts: l, text: [l.prefix, t, l.suffix].filter(Boolean).join(" ") } : { text: typeof e == "string" ? e : `Type ${t} to confirm` };
|
|
24
|
+
}, Ce = (e, t) => e === "copied" ? `${t} copied to clipboard` : "", be = (e, t, l, c) => {
|
|
25
|
+
const { outcome: m, canCopy: f, copy: a } = pe(`${t}|${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
|
-
},
|
|
29
|
+
}, T = ({ children: e }) => /* @__PURE__ */ o(G.Text, { size: "small", color: "primary", children: e }), ve = ({
|
|
30
30
|
phrase: e,
|
|
31
|
-
parts:
|
|
31
|
+
parts: t,
|
|
32
32
|
plainLabel: l,
|
|
33
33
|
placeholder: c,
|
|
34
34
|
value: m,
|
|
@@ -36,59 +36,59 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), ue = (e, i) => {
|
|
|
36
36
|
disabled: a,
|
|
37
37
|
copyLabel: s,
|
|
38
38
|
copyOutcome: n,
|
|
39
|
-
canCopy:
|
|
40
|
-
onCopy:
|
|
41
|
-
nearMissMessage:
|
|
39
|
+
canCopy: i,
|
|
40
|
+
onCopy: g,
|
|
41
|
+
nearMissMessage: x
|
|
42
42
|
}) => {
|
|
43
|
-
const u = d(),
|
|
43
|
+
const u = d(), C = d(), b = d(), v = d(), r = [x, n === "failed" ? ye : void 0].filter(Boolean).join(" ") || void 0, B = t ? [u, t.suffix ? C : void 0].filter(Boolean).join(" ") : void 0;
|
|
44
44
|
return /* @__PURE__ */ p("div", { className: "flex flex-col gap-[6px]", children: [
|
|
45
|
-
|
|
45
|
+
t ? /* @__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
|
-
/* @__PURE__ */ o(
|
|
47
|
+
/* @__PURE__ */ o(T, { children: t.prefix }),
|
|
48
48
|
" ",
|
|
49
|
-
/* @__PURE__ */ o(
|
|
49
|
+
/* @__PURE__ */ o(G.CodeText, { variant: "inline", children: e })
|
|
50
50
|
] }),
|
|
51
51
|
/* @__PURE__ */ o(
|
|
52
|
-
|
|
52
|
+
z,
|
|
53
53
|
{
|
|
54
54
|
variant: "ghost",
|
|
55
55
|
size: "small",
|
|
56
56
|
iconOnly: !0,
|
|
57
57
|
"aria-label": `${s} ${e}`,
|
|
58
|
-
icon: n === "copied" ? /* @__PURE__ */ o(
|
|
59
|
-
onClick:
|
|
60
|
-
disabled: !
|
|
58
|
+
icon: n === "copied" ? /* @__PURE__ */ o(ie, { size: 13 }) : /* @__PURE__ */ o(le, { size: 13 }),
|
|
59
|
+
onClick: g,
|
|
60
|
+
disabled: !i
|
|
61
61
|
}
|
|
62
62
|
),
|
|
63
|
-
|
|
64
|
-
] }) : /* @__PURE__ */ o("label", { id: u, htmlFor:
|
|
63
|
+
t.suffix ? /* @__PURE__ */ o("span", { id: C, children: /* @__PURE__ */ o(T, { children: t.suffix }) }) : null
|
|
64
|
+
] }) : /* @__PURE__ */ o("label", { id: u, htmlFor: v, className: "px-2 text-[13px]", children: /* @__PURE__ */ o(T, { children: l }) }),
|
|
65
65
|
/* @__PURE__ */ o(
|
|
66
66
|
fe,
|
|
67
67
|
{
|
|
68
|
-
id:
|
|
68
|
+
id: v,
|
|
69
69
|
name: "confirmation-phrase",
|
|
70
70
|
size: "medium",
|
|
71
71
|
value: m,
|
|
72
72
|
onChange: f,
|
|
73
|
-
"aria-labelledby":
|
|
73
|
+
"aria-labelledby": B,
|
|
74
74
|
placeholder: c,
|
|
75
75
|
requiredIndicator: "none",
|
|
76
|
-
error: !!
|
|
77
|
-
"aria-describedby": r ?
|
|
76
|
+
error: !!x,
|
|
77
|
+
"aria-describedby": r ? b : void 0,
|
|
78
78
|
disabled: a
|
|
79
79
|
}
|
|
80
80
|
),
|
|
81
|
-
/* @__PURE__ */ o(ne, { id:
|
|
82
|
-
|
|
81
|
+
/* @__PURE__ */ o(ne, { id: b, message: r }),
|
|
82
|
+
t ? /* @__PURE__ */ o("span", { role: "status", className: "sr-only", children: Ce(n, e) }) : null
|
|
83
83
|
] });
|
|
84
84
|
}, he = {
|
|
85
|
-
default: /* @__PURE__ */ o(se, { size:
|
|
86
|
-
warning: /* @__PURE__ */ o(ae, { size:
|
|
87
|
-
destructive: /* @__PURE__ */ o(re, { size:
|
|
88
|
-
success: /* @__PURE__ */ o(
|
|
89
|
-
},
|
|
85
|
+
default: /* @__PURE__ */ o(se, { size: h }),
|
|
86
|
+
warning: /* @__PURE__ */ o(ae, { size: h }),
|
|
87
|
+
destructive: /* @__PURE__ */ o(re, { size: h }),
|
|
88
|
+
success: /* @__PURE__ */ o(te, { size: h })
|
|
89
|
+
}, Me = ({
|
|
90
90
|
open: e,
|
|
91
|
-
onClose:
|
|
91
|
+
onClose: t,
|
|
92
92
|
onConfirm: l,
|
|
93
93
|
title: c,
|
|
94
94
|
titleAdornment: m,
|
|
@@ -96,44 +96,44 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), ue = (e, i) => {
|
|
|
96
96
|
description: a,
|
|
97
97
|
variant: s = "default",
|
|
98
98
|
callout: n,
|
|
99
|
-
confirmPhrase:
|
|
100
|
-
confirmPhraseLabel:
|
|
101
|
-
confirmPhraseCopyLabel:
|
|
99
|
+
confirmPhrase: i,
|
|
100
|
+
confirmPhraseLabel: g,
|
|
101
|
+
confirmPhraseCopyLabel: x = "Copy",
|
|
102
102
|
onPhraseCopied: u,
|
|
103
|
-
confirmPhrasePlaceholder:
|
|
104
|
-
confirmLabel:
|
|
105
|
-
cancelLabel:
|
|
103
|
+
confirmPhrasePlaceholder: C,
|
|
104
|
+
confirmLabel: b = "Confirm",
|
|
105
|
+
cancelLabel: v = "Cancel",
|
|
106
106
|
loading: r = !1,
|
|
107
|
-
confirmDisabled:
|
|
108
|
-
tip:
|
|
109
|
-
size:
|
|
110
|
-
"aria-label":
|
|
111
|
-
"aria-labelledby":
|
|
112
|
-
children:
|
|
107
|
+
confirmDisabled: B = !1,
|
|
108
|
+
tip: R,
|
|
109
|
+
size: V = "medium",
|
|
110
|
+
"aria-label": q,
|
|
111
|
+
"aria-labelledby": Y,
|
|
112
|
+
children: L
|
|
113
113
|
}) => {
|
|
114
|
-
const [
|
|
115
|
-
(
|
|
116
|
-
const { parts:
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
const [A, S] = $(""), k = d(), w = d(), F = me[s], [j, H] = $({ open: e, confirmPhrase: i });
|
|
115
|
+
(j.open !== e || j.confirmPhrase !== i) && (H({ open: e, confirmPhrase: i }), e && S(""));
|
|
116
|
+
const { parts: W, text: E } = xe(
|
|
117
|
+
g,
|
|
118
|
+
i
|
|
119
119
|
), {
|
|
120
|
-
outcome:
|
|
121
|
-
canCopy:
|
|
122
|
-
copy:
|
|
123
|
-
} = be(
|
|
124
|
-
(
|
|
125
|
-
),
|
|
126
|
-
/* @__PURE__ */ o(
|
|
120
|
+
outcome: Z,
|
|
121
|
+
canCopy: J,
|
|
122
|
+
copy: K
|
|
123
|
+
} = be(i, e, r, u), O = A.trim(), N = (i == null ? void 0 : i.trim()) ?? "", _ = !i || (N === "" ? A === i : O === N), Q = ue(O, N), D = r || B || !_, U = ee.toArray(L).some(
|
|
124
|
+
(y) => typeof y != "string" || y.trim() !== ""
|
|
125
|
+
), M = !!a || U || !!i, 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: [
|
|
126
|
+
/* @__PURE__ */ o(z, { variant: "outline", size: "small", onClick: t, disabled: r, children: v }),
|
|
127
127
|
/* @__PURE__ */ o(
|
|
128
|
-
|
|
128
|
+
z,
|
|
129
129
|
{
|
|
130
|
-
variant:
|
|
130
|
+
variant: F.confirmVariant,
|
|
131
131
|
size: "small",
|
|
132
132
|
onClick: l,
|
|
133
|
-
disabled:
|
|
133
|
+
disabled: D,
|
|
134
134
|
loading: r,
|
|
135
|
-
tooltip: !r && !
|
|
136
|
-
children:
|
|
135
|
+
tooltip: !r && !_ ? E : void 0,
|
|
136
|
+
children: b
|
|
137
137
|
}
|
|
138
138
|
)
|
|
139
139
|
] });
|
|
@@ -141,20 +141,20 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), ue = (e, i) => {
|
|
|
141
141
|
de,
|
|
142
142
|
{
|
|
143
143
|
open: e,
|
|
144
|
-
onClose:
|
|
144
|
+
onClose: t,
|
|
145
145
|
title: c,
|
|
146
|
-
size:
|
|
146
|
+
size: V,
|
|
147
147
|
footer: P,
|
|
148
148
|
busy: r,
|
|
149
149
|
role: s === "destructive" ? "alertdialog" : "dialog",
|
|
150
|
-
"aria-label":
|
|
151
|
-
"aria-labelledby":
|
|
150
|
+
"aria-label": q,
|
|
151
|
+
"aria-labelledby": Y,
|
|
152
152
|
"aria-describedby": X,
|
|
153
|
-
closeOnOverlayClick: s !== "destructive" && !
|
|
153
|
+
closeOnOverlayClick: s !== "destructive" && !i,
|
|
154
154
|
headerDivider: !0,
|
|
155
155
|
titleAdornment: m,
|
|
156
156
|
bodyPadding: !1,
|
|
157
|
-
tray: { tone:
|
|
157
|
+
tray: { tone: F.tray, caption: R },
|
|
158
158
|
icon: /* @__PURE__ */ o(
|
|
159
159
|
ce,
|
|
160
160
|
{
|
|
@@ -167,12 +167,12 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), ue = (e, i) => {
|
|
|
167
167
|
oe,
|
|
168
168
|
{
|
|
169
169
|
id: w,
|
|
170
|
-
type: n.type ??
|
|
170
|
+
type: n.type ?? F.calloutType,
|
|
171
171
|
message: n.message,
|
|
172
|
-
divider:
|
|
172
|
+
divider: M
|
|
173
173
|
}
|
|
174
174
|
) : null,
|
|
175
|
-
|
|
175
|
+
M ? /* @__PURE__ */ p("div", { className: "flex flex-col gap-[12px] p-[28px]", children: [
|
|
176
176
|
a ? /* @__PURE__ */ o(
|
|
177
177
|
"div",
|
|
178
178
|
{
|
|
@@ -181,23 +181,35 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), ue = (e, i) => {
|
|
|
181
181
|
children: a
|
|
182
182
|
}
|
|
183
183
|
) : null,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
184
|
+
L,
|
|
185
|
+
i ? (
|
|
186
|
+
// Enter in a lone field submits its form; gated like the confirm button,
|
|
187
|
+
// and kept from a consumer's own form, which the portal would reach.
|
|
188
|
+
/* @__PURE__ */ o(
|
|
189
|
+
"form",
|
|
190
|
+
{
|
|
191
|
+
onSubmit: (y) => {
|
|
192
|
+
y.preventDefault(), y.stopPropagation(), D || l();
|
|
193
|
+
},
|
|
194
|
+
children: /* @__PURE__ */ o(
|
|
195
|
+
ve,
|
|
196
|
+
{
|
|
197
|
+
phrase: i,
|
|
198
|
+
parts: W,
|
|
199
|
+
plainLabel: E,
|
|
200
|
+
placeholder: C,
|
|
201
|
+
value: A,
|
|
202
|
+
onChange: S,
|
|
203
|
+
disabled: r,
|
|
204
|
+
copyLabel: x,
|
|
205
|
+
copyOutcome: Z,
|
|
206
|
+
canCopy: J,
|
|
207
|
+
onCopy: K,
|
|
208
|
+
nearMissMessage: Q
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
)
|
|
201
213
|
) : null
|
|
202
214
|
] }) : null
|
|
203
215
|
]
|
|
@@ -205,7 +217,7 @@ const v = 12, h = (e) => e.replace(/\s+/g, " "), ue = (e, i) => {
|
|
|
205
217
|
);
|
|
206
218
|
};
|
|
207
219
|
export {
|
|
208
|
-
|
|
209
|
-
|
|
220
|
+
Me as ConfirmationDialog,
|
|
221
|
+
Me as default
|
|
210
222
|
};
|
|
211
223
|
//# 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 /**\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,G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QACHA,IACG,gBAAAnD,EAAC,OAAA,EAAI,WAAU,qCACV,UAAA;AAAA,UAAAiB,IACG,gBAAAlC;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,IAAIqD;AAAA,cACJ,WAAU;AAAA,cAET,UAAAnB;AAAA,YAAA;AAAA,UAAA,IAEL;AAAA,UACHnC;AAAA,UACAsC,IACG,gBAAArC;AAAA,YAACE;AAAA,YAAA;AAAA,cACG,QAAQmC;AAAA,cACR,OAAOsB;AAAA,cACP,YAAYC;AAAA,cACZ,aAAanB;AAAA,cACb,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;"}
|
|
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 // Enter in a lone field submits its form; gated like the confirm button,\n // and kept from a consumer's own form, which the portal would reach.\n <form\n onSubmit={(event) => {\n event.preventDefault();\n event.stopPropagation();\n if (!confirmBlocked) {\n onConfirm();\n }\n }}\n >\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 </form>\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","event"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAMA,IAAmB,IAEnBC,IAAiB,CAACC,MAAkBA,EAAM,QAAQ,Q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;AAAA,QACHA,IACG,gBAAAnD,EAAC,OAAA,EAAI,WAAU,qCACV,UAAA;AAAA,UAAAiB,IACG,gBAAAlC;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,IAAIqD;AAAA,cACJ,WAAU;AAAA,cAET,UAAAnB;AAAA,YAAA;AAAA,UAAA,IAEL;AAAA,UACHnC;AAAA,UACAsC;AAAA;AAAA;AAAA,YAGG,gBAAArC;AAAA,cAAC;AAAA,cAAA;AAAA,gBACG,UAAU,CAAC0E,MAAU;AACjB,kBAAAA,EAAM,eAAA,GACNA,EAAM,gBAAA,GACDV,KACDlC,EAAA;AAAA,gBAER;AAAA,gBAEA,UAAA,gBAAA9B;AAAA,kBAACE;AAAA,kBAAA;AAAA,oBACG,QAAQmC;AAAA,oBACR,OAAOsB;AAAA,oBACP,YAAYC;AAAA,oBACZ,aAAanB;AAAA,oBACb,OAAOS;AAAA,oBACP,UAAUC;AAAA,oBACV,UAAUP;AAAA,oBACV,WAAWL;AAAA,oBACX,aAAAhC;AAAA,oBACA,SAASsD;AAAA,oBACT,QAAQC;AAAA,oBACR,iBAAArD;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACJ;AAAA,YAAA;AAAA,cAEJ;AAAA,QAAA,EAAA,CACR,IACA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGhB;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const u = (r, e) => {
|
|
2
|
+
if (r && !r.disabled) {
|
|
3
|
+
r.focus({ preventScroll: !0 });
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
if (!e)
|
|
7
|
+
return;
|
|
8
|
+
const t = e.getAttribute("tabindex"), n = () => t === null ? e.removeAttribute("tabindex") : e.setAttribute("tabindex", t);
|
|
9
|
+
e.setAttribute("tabindex", "-1"), e.focus({ preventScroll: !0 }), e.getRootNode().activeElement === e ? e.addEventListener("blur", n, { once: !0 }) : n();
|
|
10
|
+
}, o = (r, e) => {
|
|
11
|
+
const { activeElement: t } = e;
|
|
12
|
+
return !!t && r.contains(t);
|
|
13
|
+
}, s = ({ body: r, section: e }) => {
|
|
14
|
+
const t = e.ownerDocument;
|
|
15
|
+
return o(r, e.getRootNode()) || !t.activeElement || t.activeElement === t.body;
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
u as focusSection,
|
|
19
|
+
o as holdsFocus,
|
|
20
|
+
s as isFocusLost
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=collapseFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapseFocus.js","sources":["../../src/components/collapseFocus.ts"],"sourcesContent":["// Moving focus out of an Accordion body as it collapses; see `CollapseFocusHandOff`.\n\nexport const focusSection = (toggle: HTMLButtonElement | null, section: HTMLElement | null) => {\n if (toggle && !toggle.disabled) {\n toggle.focus({ preventScroll: true });\n return;\n }\n if (!section) {\n return;\n }\n // Focusable for this one stop, then back to whatever tabindex the consumer gave it.\n const previous = section.getAttribute('tabindex');\n const restore = () =>\n previous === null\n ? section.removeAttribute('tabindex')\n : section.setAttribute('tabindex', previous);\n section.setAttribute('tabindex', '-1');\n section.focus({ preventScroll: true });\n // Ignored inside an inert ancestor, where no blur would ever come to restore it.\n if ((section.getRootNode() as Document | ShadowRoot).activeElement === section) {\n section.addEventListener('blur', restore, { once: true });\n } else {\n restore();\n }\n};\n\n// Taken before the commit: an instant body is detached from its section by the update.\nexport interface FocusSnapshot {\n body: HTMLElement;\n section: HTMLElement;\n}\n\nexport const holdsFocus = (body: HTMLElement, root: Node) => {\n const { activeElement } = root as Document | ShadowRoot;\n return !!activeElement && body.contains(activeElement);\n};\n\n// Still inside a body that is inert or detached, or dropped to the page.\nexport const isFocusLost = ({ body, section }: FocusSnapshot) => {\n const page = section.ownerDocument;\n return (\n holdsFocus(body, section.getRootNode()) ||\n !page.activeElement ||\n page.activeElement === page.body\n );\n};\n"],"names":["focusSection","toggle","section","previous","restore","holdsFocus","body","root","activeElement","isFocusLost","page"],"mappings":"AAEO,MAAMA,IAAe,CAACC,GAAkCC,MAAgC;AAC3F,MAAID,KAAU,CAACA,EAAO,UAAU;AAC5B,IAAAA,EAAO,MAAM,EAAE,eAAe,GAAA,CAAM;AACpC;AAAA,EACJ;AACA,MAAI,CAACC;AACD;AAGJ,QAAMC,IAAWD,EAAQ,aAAa,UAAU,GAC1CE,IAAU,MACZD,MAAa,OACPD,EAAQ,gBAAgB,UAAU,IAClCA,EAAQ,aAAa,YAAYC,CAAQ;AACnD,EAAAD,EAAQ,aAAa,YAAY,IAAI,GACrCA,EAAQ,MAAM,EAAE,eAAe,GAAA,CAAM,GAEhCA,EAAQ,cAAwC,kBAAkBA,IACnEA,EAAQ,iBAAiB,QAAQE,GAAS,EAAE,MAAM,IAAM,IAExDA,EAAA;AAER,GAQaC,IAAa,CAACC,GAAmBC,MAAe;AACzD,QAAM,EAAE,eAAAC,MAAkBD;AAC1B,SAAO,CAAC,CAACC,KAAiBF,EAAK,SAASE,CAAa;AACzD,GAGaC,IAAc,CAAC,EAAE,MAAAH,GAAM,SAAAJ,QAA6B;AAC7D,QAAMQ,IAAOR,EAAQ;AACrB,SACIG,EAAWC,GAAMJ,EAAQ,YAAA,CAAa,KACtC,CAACQ,EAAK,iBACNA,EAAK,kBAAkBA,EAAK;AAEpC;"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
1
|
+
import { IS_REACT_19 as p } from "./reactVersion.js";
|
|
2
|
+
const u = (n, o) => {
|
|
3
3
|
if (typeof n == "function")
|
|
4
4
|
return n(o);
|
|
5
5
|
n && (n.current = o);
|
|
6
|
-
},
|
|
7
|
-
const t = n.map((c) =>
|
|
6
|
+
}, a = (...n) => (o) => {
|
|
7
|
+
const t = n.map((c) => u(c, o));
|
|
8
8
|
if (t.some((c) => typeof c == "function"))
|
|
9
9
|
return () => {
|
|
10
|
-
n.forEach((c,
|
|
11
|
-
const f = t[
|
|
10
|
+
n.forEach((c, e) => {
|
|
11
|
+
const f = t[e];
|
|
12
12
|
if (typeof f == "function") {
|
|
13
13
|
f();
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
u(c, null);
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
|
-
},
|
|
19
|
+
}, s = (n) => p ? n.props.ref : n.ref, i = (n, o) => (t) => {
|
|
20
20
|
n == null || n(t), t.defaultPrevented || o(t);
|
|
21
21
|
};
|
|
22
22
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
i as chainHandler,
|
|
24
|
+
a as composeRefs,
|
|
25
|
+
s as elementRef
|
|
26
26
|
};
|
|
27
27
|
//# sourceMappingURL=composeRefs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composeRefs.js","sources":["../../src/components/composeRefs.ts"],"sourcesContent":["import type React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"composeRefs.js","sources":["../../src/components/composeRefs.ts"],"sourcesContent":["import type React from 'react';\nimport { IS_REACT_19 } from './reactVersion';\n\ntype AnyRef<T> = React.Ref<T> | undefined;\n\nconst setRef = <T>(ref: AnyRef<T>, node: T | null): void | (() => void) => {\n if (typeof ref === 'function') {\n return ref(node);\n }\n if (ref) {\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n};\n\nexport const composeRefs =\n <T>(...refs: AnyRef<T>[]) =>\n (node: T | null): void | (() => void) => {\n const cleanups = refs.map((ref) => setRef(ref, node));\n if (!cleanups.some((cleanup) => typeof cleanup === 'function')) {\n return;\n }\n return () => {\n refs.forEach((ref, index) => {\n const cleanup = cleanups[index];\n if (typeof cleanup === 'function') {\n cleanup();\n return;\n }\n setRef(ref, null);\n });\n };\n };\n\nexport const elementRef = <T>(element: React.ReactElement): AnyRef<T> =>\n (IS_REACT_19\n ? (element.props as { ref?: React.Ref<T> }).ref\n : (element as unknown as { ref?: React.Ref<T> }).ref) as AnyRef<T>;\n\nexport const chainHandler =\n <E extends React.SyntheticEvent>(\n theirs: ((event: E) => void) | undefined,\n ours: (event: E) => void,\n ) =>\n (event: E): void => {\n theirs?.(event);\n if (!event.defaultPrevented) {\n ours(event);\n }\n };\n"],"names":["setRef","ref","node","composeRefs","refs","cleanups","cleanup","index","elementRef","element","IS_REACT_19","chainHandler","theirs","ours","event"],"mappings":";AAKA,MAAMA,IAAS,CAAIC,GAAgBC,MAAwC;AACvE,MAAI,OAAOD,KAAQ;AACf,WAAOA,EAAIC,CAAI;AAEnB,EAAID,MACCA,EAAyC,UAAUC;AAE5D,GAEaC,IACT,IAAOC,MACP,CAACF,MAAwC;AACrC,QAAMG,IAAWD,EAAK,IAAI,CAACH,MAAQD,EAAOC,GAAKC,CAAI,CAAC;AACpD,MAAKG,EAAS,KAAK,CAACC,MAAY,OAAOA,KAAY,UAAU;AAG7D,WAAO,MAAM;AACT,MAAAF,EAAK,QAAQ,CAACH,GAAKM,MAAU;AACzB,cAAMD,IAAUD,EAASE,CAAK;AAC9B,YAAI,OAAOD,KAAY,YAAY;AAC/B,UAAAA,EAAA;AACA;AAAA,QACJ;AACA,QAAAN,EAAOC,GAAK,IAAI;AAAA,MACpB,CAAC;AAAA,IACL;AACJ,GAESO,IAAa,CAAIC,MACzBC,IACMD,EAAQ,MAAiC,MACzCA,EAA8C,KAE5CE,IACT,CACIC,GACAC,MAEJ,CAACC,MAAmB;AAChB,EAAAF,KAAA,QAAAA,EAASE,IACJA,EAAM,oBACPD,EAAKC,CAAK;AAElB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inert.js","sources":["../../src/components/inert.ts"],"sourcesContent":["import type React from 'react';\nimport { IS_REACT_19 } from './reactVersion';\n\n// React 19 takes `inert` as a boolean; React 18 only passes a string through to the DOM.\nexport const inertWhen = (on: boolean) =>\n (on ? { inert: IS_REACT_19 ? true : '' } : {}) as React.HTMLAttributes<HTMLDivElement>;\n"],"names":["inertWhen","on","IS_REACT_19"],"mappings":";AAIO,MAAMA,IAAY,CAACC,MACrBA,IAAK,EAAE,OAAOC,IAAc,KAAO,OAAO,CAAA;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactVersion.js","sources":["../../src/components/reactVersion.ts"],"sourcesContent":["import { version } from 'react';\n\nexport const IS_REACT_19 = Number(version.split('.')[0]) >= 19;\n"],"names":["IS_REACT_19","version"],"mappings":";AAEO,MAAMA,IAAc,OAAOC,EAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -280,7 +280,7 @@ export declare interface AppLogoProps {
|
|
|
280
280
|
nameWeight?: FontWeight;
|
|
281
281
|
/** Rendered as a tag after the name, e.g. `v1.2.0` or `Legacy`. */
|
|
282
282
|
version?: string;
|
|
283
|
-
/** Truncates a long name with an ellipsis and reveals
|
|
283
|
+
/** Truncates a long name with an ellipsis, and reveals it on hover once it is cut off. */
|
|
284
284
|
truncate?: boolean;
|
|
285
285
|
className?: string;
|
|
286
286
|
}
|