@stackone/malachite 2.94.1 → 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/Checkbox.js +41 -37
- package/dist/components/Checkbox.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 +8 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { FOCUS_RING as
|
|
3
|
-
const
|
|
1
|
+
import { jsx as a, jsxs as p, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import { FOCUS_RING as $ } from "./focusRing.js";
|
|
3
|
+
const k = {
|
|
4
|
+
default: "var(--malachite-accent-background, rgb(0, 175, 102))",
|
|
5
|
+
warning: "var(--malachite-warning-foreground, rgb(150, 88, 10))"
|
|
6
|
+
}, C = ({
|
|
4
7
|
checked: o,
|
|
5
|
-
indeterminate:
|
|
6
|
-
onChange:
|
|
7
|
-
disabled:
|
|
8
|
+
indeterminate: t = !1,
|
|
9
|
+
onChange: l,
|
|
10
|
+
disabled: e = !1,
|
|
8
11
|
size: r = 14,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"aria-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
tone: i = "default",
|
|
13
|
+
presentational: x = !1,
|
|
14
|
+
"aria-label": f,
|
|
15
|
+
"aria-labelledby": g,
|
|
16
|
+
className: d = "",
|
|
17
|
+
id: y
|
|
14
18
|
}) => {
|
|
15
|
-
const c = o && !
|
|
19
|
+
const c = o && !t, s = Math.max(3, Math.round(r * 0.36)), h = Math.round(r * 0.57), n = k[i], m = t || o || i !== "default" ? n : "var(--malachite-text-placeholder, rgb(187, 187, 187))", u = {
|
|
16
20
|
position: "relative",
|
|
17
21
|
flexShrink: 0,
|
|
18
22
|
display: "inline-flex",
|
|
@@ -21,16 +25,16 @@ const $ = ({
|
|
|
21
25
|
width: `${r}px`,
|
|
22
26
|
height: `${r}px`,
|
|
23
27
|
padding: 0,
|
|
24
|
-
borderRadius: `${
|
|
28
|
+
borderRadius: `${s}px`,
|
|
25
29
|
borderWidth: "1px",
|
|
26
30
|
borderStyle: "solid",
|
|
27
|
-
borderColor:
|
|
28
|
-
backgroundColor: c ?
|
|
31
|
+
borderColor: m,
|
|
32
|
+
backgroundColor: c ? n : "transparent",
|
|
29
33
|
color: "#fff",
|
|
30
|
-
opacity:
|
|
34
|
+
opacity: e ? 0.5 : 1,
|
|
31
35
|
transition: "background-color 150ms ease, border-color 150ms ease"
|
|
32
|
-
},
|
|
33
|
-
c && /* @__PURE__ */
|
|
36
|
+
}, b = /* @__PURE__ */ p(M, { children: [
|
|
37
|
+
c && /* @__PURE__ */ p(
|
|
34
38
|
"svg",
|
|
35
39
|
{
|
|
36
40
|
width: Math.round(r * 0.78),
|
|
@@ -38,42 +42,42 @@ const $ = ({
|
|
|
38
42
|
viewBox: "0 0 24 24",
|
|
39
43
|
"aria-hidden": "true",
|
|
40
44
|
children: [
|
|
41
|
-
/* @__PURE__ */
|
|
42
|
-
/* @__PURE__ */
|
|
45
|
+
/* @__PURE__ */ a("title", { children: "checked" }),
|
|
46
|
+
/* @__PURE__ */ a("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
|
|
43
47
|
]
|
|
44
48
|
}
|
|
45
49
|
),
|
|
46
|
-
|
|
50
|
+
t && /* @__PURE__ */ a(
|
|
47
51
|
"span",
|
|
48
52
|
{
|
|
49
53
|
style: {
|
|
50
|
-
width: `${
|
|
51
|
-
height: `${
|
|
52
|
-
borderRadius: `${Math.max(2, Math.round(
|
|
53
|
-
backgroundColor:
|
|
54
|
+
width: `${h}px`,
|
|
55
|
+
height: `${h}px`,
|
|
56
|
+
borderRadius: `${Math.max(2, Math.round(s * 0.6))}px`,
|
|
57
|
+
backgroundColor: n
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
)
|
|
57
61
|
] });
|
|
58
|
-
return
|
|
62
|
+
return x ? /* @__PURE__ */ a("span", { "aria-hidden": "true", className: d, style: u, children: b }) : /* @__PURE__ */ a(
|
|
59
63
|
"button",
|
|
60
64
|
{
|
|
61
65
|
type: "button",
|
|
62
66
|
role: "checkbox",
|
|
63
|
-
id:
|
|
64
|
-
"aria-checked":
|
|
65
|
-
"aria-label":
|
|
66
|
-
"aria-labelledby":
|
|
67
|
-
disabled:
|
|
68
|
-
onClick: () =>
|
|
69
|
-
className: `${
|
|
70
|
-
style: { ...
|
|
71
|
-
children:
|
|
67
|
+
id: y,
|
|
68
|
+
"aria-checked": t ? "mixed" : o,
|
|
69
|
+
"aria-label": f,
|
|
70
|
+
"aria-labelledby": g,
|
|
71
|
+
disabled: e,
|
|
72
|
+
onClick: () => l == null ? void 0 : l(t ? !0 : !o),
|
|
73
|
+
className: `${$} ${d}`,
|
|
74
|
+
style: { ...u, cursor: e ? "not-allowed" : "pointer" },
|
|
75
|
+
children: b
|
|
72
76
|
}
|
|
73
77
|
);
|
|
74
78
|
};
|
|
75
79
|
export {
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
C as Checkbox,
|
|
81
|
+
C as default
|
|
78
82
|
};
|
|
79
83
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sources":["../../src/components/Checkbox.tsx"],"sourcesContent":["import React from 'react';\nimport { FOCUS_RING } from './focusRing';\n\ninterface CheckboxProps {\n checked: boolean;\n /** Tri-state \"partial\" look — overrides the checked tick with a square. */\n indeterminate?: boolean;\n /** Optional when `presentational` — a presentational checkbox is a visual indicator only. */\n onChange?: (checked: boolean) => void;\n disabled?: boolean;\n size?: number;\n /**\n * Render a visual-only indicator (a non-interactive, non-focusable `<span>`,\n * `aria-hidden`) instead of an interactive checkbox. Use this inside a clickable\n * row/card whose wrapper is the real control, so there's a single tab stop.\n */\n presentational?: boolean;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n className?: string;\n id?: string;\n}\n\nconst Checkbox: React.FC<CheckboxProps> = ({\n checked,\n indeterminate = false,\n onChange,\n disabled = false,\n size = 14,\n presentational = false,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className = '',\n id,\n}) => {\n const isFilled = checked && !indeterminate;\n const radius = Math.max(3, Math.round(size * 0.36));\n const innerSize = Math.round(size * 0.57);\n\n // Indeterminate shares the checked border rather than a fainter one, so \"some selected\"\n // never reads weaker than \"nothing selected\"; the transparent fill separates the states.\n const borderColor =\n indeterminate || checked
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sources":["../../src/components/Checkbox.tsx"],"sourcesContent":["import React from 'react';\nimport { FOCUS_RING } from './focusRing';\n\ntype CheckboxTone = 'default' | 'warning';\n\ninterface CheckboxProps {\n checked: boolean;\n /** Tri-state \"partial\" look — overrides the checked tick with a square. */\n indeterminate?: boolean;\n /** Optional when `presentational` — a presentational checkbox is a visual indicator only. */\n onChange?: (checked: boolean) => void;\n disabled?: boolean;\n size?: number;\n /**\n * `warning` draws attention to this box in every state, unchecked included, for a choice\n * that needs a second look such as an unsaved change.\n */\n tone?: CheckboxTone;\n /**\n * Render a visual-only indicator (a non-interactive, non-focusable `<span>`,\n * `aria-hidden`) instead of an interactive checkbox. Use this inside a clickable\n * row/card whose wrapper is the real control, so there's a single tab stop.\n */\n presentational?: boolean;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n className?: string;\n id?: string;\n}\n\n// `warning` takes the foreground token: white on the warning background is under 3:1.\nconst TONE_COLOR: Record<CheckboxTone, string> = {\n default: 'var(--malachite-accent-background, rgb(0, 175, 102))',\n warning: 'var(--malachite-warning-foreground, rgb(150, 88, 10))',\n};\n\nconst Checkbox: React.FC<CheckboxProps> = ({\n checked,\n indeterminate = false,\n onChange,\n disabled = false,\n size = 14,\n tone = 'default',\n presentational = false,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className = '',\n id,\n}) => {\n const isFilled = checked && !indeterminate;\n const radius = Math.max(3, Math.round(size * 0.36));\n const innerSize = Math.round(size * 0.57);\n\n // Indeterminate shares the checked border rather than a fainter one, so \"some selected\"\n // never reads weaker than \"nothing selected\"; the transparent fill separates the states.\n const toneColor = TONE_COLOR[tone];\n const borderColor =\n indeterminate || checked || tone !== 'default'\n ? toneColor\n : 'var(--malachite-text-placeholder, rgb(187, 187, 187))';\n\n const boxStyle: React.CSSProperties = {\n position: 'relative',\n flexShrink: 0,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: `${size}px`,\n height: `${size}px`,\n padding: 0,\n borderRadius: `${radius}px`,\n borderWidth: '1px',\n borderStyle: 'solid',\n borderColor,\n backgroundColor: isFilled ? toneColor : 'transparent',\n color: '#fff',\n opacity: disabled ? 0.5 : 1,\n transition: 'background-color 150ms ease, border-color 150ms ease',\n };\n\n const glyph = (\n <>\n {isFilled && (\n <svg\n width={Math.round(size * 0.78)}\n height={Math.round(size * 0.78)}\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <title>checked</title>\n {/* Filled glyph — the library forces `svg path { fill: currentColor }` */}\n <path d=\"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z\" />\n </svg>\n )}\n {indeterminate && (\n <span\n style={{\n width: `${innerSize}px`,\n height: `${innerSize}px`,\n borderRadius: `${Math.max(2, Math.round(radius * 0.6))}px`,\n backgroundColor: toneColor,\n }}\n />\n )}\n </>\n );\n\n if (presentational) {\n return (\n <span aria-hidden=\"true\" className={className} style={boxStyle}>\n {glyph}\n </span>\n );\n }\n\n return (\n <button\n type=\"button\"\n role=\"checkbox\"\n id={id}\n aria-checked={indeterminate ? 'mixed' : checked}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n disabled={disabled}\n onClick={() => onChange?.(indeterminate ? true : !checked)}\n className={`${FOCUS_RING} ${className}`}\n style={{ ...boxStyle, cursor: disabled ? 'not-allowed' : 'pointer' }}\n >\n {glyph}\n </button>\n );\n};\n\nexport default Checkbox;\nexport { Checkbox };\nexport type { CheckboxProps, CheckboxTone };\n"],"names":["TONE_COLOR","Checkbox","checked","indeterminate","onChange","disabled","size","tone","presentational","ariaLabel","ariaLabelledBy","className","id","isFilled","radius","innerSize","toneColor","borderColor","boxStyle","glyph","jsxs","Fragment","jsx","FOCUS_RING"],"mappings":";;AA+BA,MAAMA,IAA2C;AAAA,EAC7C,SAAS;AAAA,EACT,SAAS;AACb,GAEMC,IAAoC,CAAC;AAAA,EACvC,SAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,MAAAC,IAAO;AAAA,EACP,MAAAC,IAAO;AAAA,EACP,gBAAAC,IAAiB;AAAA,EACjB,cAAcC;AAAA,EACd,mBAAmBC;AAAA,EACnB,WAAAC,IAAY;AAAA,EACZ,IAAAC;AACJ,MAAM;AACF,QAAMC,IAAWX,KAAW,CAACC,GACvBW,IAAS,KAAK,IAAI,GAAG,KAAK,MAAMR,IAAO,IAAI,CAAC,GAC5CS,IAAY,KAAK,MAAMT,IAAO,IAAI,GAIlCU,IAAYhB,EAAWO,CAAI,GAC3BU,IACFd,KAAiBD,KAAWK,MAAS,YAC/BS,IACA,yDAEJE,IAAgC;AAAA,I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AAgB,UAAUD;AAAA,MACxC,cAAYO;AAAA,MACZ,mBAAiBC;AAAA,MACjB,UAAAL;AAAA,MACA,SAAS,MAAMD,KAAA,gBAAAA,EAAWD,IAAgB,KAAO,CAACD;AAAA,MAClD,WAAW,GAAGqB,CAAU,IAAIZ,CAAS;AAAA,MACrC,OAAO,EAAE,GAAGO,GAAU,QAAQb,IAAW,gBAAgB,UAAA;AAAA,MAExD,UAAAc;AAAA,IAAA;AAAA,EAAA;AAGb;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import n from "react";
|
|
2
|
+
import { holdsFocus as r, isFocusLost as s, focusSection as p } from "./collapseFocus.js";
|
|
3
|
+
class l extends n.Component {
|
|
4
|
+
getSnapshotBeforeUpdate(o) {
|
|
5
|
+
const e = this.props.bodyRef.current, t = e == null ? void 0 : e.parentElement;
|
|
6
|
+
return !o.expanded || this.props.expanded || !e || !t ? null : r(e, e.getRootNode()) ? { body: e, section: t } : null;
|
|
7
|
+
}
|
|
8
|
+
componentDidUpdate(o, e, t) {
|
|
9
|
+
t && s(t) && p(this.props.toggleRef.current, t.section);
|
|
10
|
+
}
|
|
11
|
+
render() {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
l as default
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=CollapseFocusHandOff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollapseFocusHandOff.js","sources":["../../src/components/CollapseFocusHandOff.tsx"],"sourcesContent":["import React from 'react';\nimport { type FocusSnapshot, focusSection, holdsFocus, isFocusLost } from './collapseFocus';\n\ninterface CollapseFocusHandOffProps {\n expanded: boolean;\n bodyRef: React.RefObject<HTMLDivElement | null>;\n toggleRef: React.RefObject<HTMLButtonElement | null>;\n}\n\n/**\n * Hands focus out of a collapsing body to the toggle, or the section when it is disabled. A\n * class for `getSnapshotBeforeUpdate`: it sees focus before an instant body unmounts.\n */\nclass CollapseFocusHandOff extends React.Component<CollapseFocusHandOffProps> {\n getSnapshotBeforeUpdate(previous: CollapseFocusHandOffProps): FocusSnapshot | null {\n const body = this.props.bodyRef.current;\n const section = body?.parentElement;\n if (!previous.expanded || this.props.expanded || !body || !section) {\n return null;\n }\n return holdsFocus(body, body.getRootNode()) ? { body, section } : null;\n }\n\n componentDidUpdate(\n _previous: CollapseFocusHandOffProps,\n _state: unknown,\n snapshot: FocusSnapshot | null,\n ): void {\n // Only while focus is still lost: something else may have taken it in this commit.\n if (snapshot && isFocusLost(snapshot)) {\n focusSection(this.props.toggleRef.current, snapshot.section);\n }\n }\n\n render(): null {\n return null;\n }\n}\n\nexport default CollapseFocusHandOff;\n"],"names":["CollapseFocusHandOff","React","previous","body","section","holdsFocus","_previous","_state","snapshot","isFocusLost","focusSection"],"mappings":";;AAaA,MAAMA,UAA6BC,EAAM,UAAqC;AAAA,EAC1E,wBAAwBC,GAA2D;AAC/E,UAAMC,IAAO,KAAK,MAAM,QAAQ,SAC1BC,IAAUD,KAAA,gBAAAA,EAAM;AACtB,WAAI,CAACD,EAAS,YAAY,KAAK,MAAM,YAAY,CAACC,KAAQ,CAACC,IAChD,OAEJC,EAAWF,GAAMA,EAAK,YAAA,CAAa,IAAI,EAAE,MAAAA,GAAM,SAAAC,EAAA,IAAY;AAAA,EACtE;AAAA,EAEA,mBACIE,GACAC,GACAC,GACI;AAEJ,IAAIA,KAAYC,EAAYD,CAAQ,KAChCE,EAAa,KAAK,MAAM,UAAU,SAASF,EAAS,OAAO;AAAA,EAEnE;AAAA,EAEA,SAAe;AACX,WAAO;AAAA,EACX;AACJ;"}
|
|
@@ -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,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,SAAIC,IACO,EAAE,OAAAA,GAAO,MAAM,CAACA,EAAM,QAAQJ,GAAQI,EAAM,MAAM,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAAA,IAEhF,EAAE,MAAM,OAAOD,KAAU,WAAWA,IAAQ,QAAQH,CAAM,cAAA;AACrE,GAEMK,KAAgB,CAACC,GAAsBN,MACzCM,MAAY,WAAW,GAAGN,CAAM,yBAAyB,IAEvDO,KAAgB,CAClBP,GACAQ,GACAC,GACAC,MAC+D;AAC/D,QAAM,EAAE,SAAAJ,GAAS,SAAAK,GAAS,MAAAC,MAASC,GAAiB,GAAGL,CAAI,IAAIR,CAAM,EAAE,GAEjEc,IAAM,YAAY;AACpB,IAAId,KAAW,MAAMY,EAAKZ,CAAM,KAC5B,eAAe,MA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a;AAAA,MACb,MAAM,EAAE,MAAMuB,EAAK,MAAM,SAAST,EAAA;AAAA,MAClC,MACI,gBAAA9C;AAAA,QAACwE;AAAA,QAAA;AAAA,UACG,SAAArC;AAAA,UACA,MAAMF,KAAaV,GAAaY,CAAO;AAAA,QAAA;AAAA,MAAA;AAAA,MAI9C,UAAA;AAAA,QAAAC,IACG,gBAAApC;AAAA,UAACyE;AAAA,UAAA;AAAA,YACG,IAAInB;AAAA,YACJ,MAAMlB,EAAQ,QAAQmB,EAAK;AAAA,YAC3B,SAASnB,EAAQ;AAAA,YACjB,SAASgC;AAAA,UAAA;AAAA,QAAA,IAEb;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,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,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,SAAIC,IACO,EAAE,OAAAA,GAAO,MAAM,CAACA,EAAM,QAAQJ,GAAQI,EAAM,MAAM,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAAA,IAEhF,EAAE,MAAM,OAAOD,KAAU,WAAWA,IAAQ,QAAQH,CAAM,cAAA;AACrE,GAEMK,KAAgB,CAACC,GAAsBN,MACzCM,MAAY,WAAW,GAAGN,CAAM,yBAAyB,IAEvDO,KAAgB,CAClBP,GACAQ,GACAC,GACAC,MAC+D;AAC/D,QAAM,EAAE,SAAAJ,GAAS,SAAAK,GAAS,MAAAC,MAASC,GAAiB,GAAGL,CAAI,IAAIR,CAAM,EAAE,GAEjEc,IAAM,YAAY;AACpB,IAAId,KAAW,MAAMY,EAAKZ,CAAM,KAC5B,e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