@stackone/malachite 2.95.0 → 2.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 T } from "./Button.js";
3
+ import { Button as z } from "./Button.js";
4
4
  import oe from "./CalloutStrip.js";
5
- import ie from "./CustomIcons/CheckCircleFilled.js";
6
- import te from "./CustomIcons/CheckmarkIcon.js";
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 D } from "./Typography/index.js";
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 v = 12, h = (e) => e.replace(/\s+/g, " "), ue = (e, i) => {
19
- if (!(i === "" || e === "" || e === i) && h(e).toLowerCase() === h(i).toLowerCase())
20
- return h(e) === h(i) ? "The spacing has to match exactly." : "This is case-sensitive.";
21
- }, ye = "Could not copy. Enter the phrase manually.", xe = (e, i) => {
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, i, l.suffix].filter(Boolean).join(" ") } : { text: typeof e == "string" ? e : `Type ${i} to confirm` };
24
- }, Ce = (e, i) => e === "copied" ? `${i} copied to clipboard` : "", be = (e, i, l, c) => {
25
- const { outcome: m, canCopy: f, copy: a } = pe(`${i}|${e}`), s = async () => {
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
- }, N = ({ children: e }) => /* @__PURE__ */ o(D.Text, { size: "small", color: "primary", children: e }), ve = ({
29
+ }, T = ({ children: e }) => /* @__PURE__ */ o(G.Text, { size: "small", color: "primary", children: e }), ve = ({
30
30
  phrase: e,
31
- parts: i,
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: t,
40
- onCopy: I,
41
- nearMissMessage: y
39
+ canCopy: i,
40
+ onCopy: g,
41
+ nearMissMessage: x
42
42
  }) => {
43
- const u = d(), x = d(), C = d(), b = d(), r = [y, n === "failed" ? ye : void 0].filter(Boolean).join(" ") || void 0, g = i ? [u, i.suffix ? x : void 0].filter(Boolean).join(" ") : void 0;
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
- i ? /* @__PURE__ */ p("div", { className: "flex flex-wrap items-center gap-[6px] px-2 text-[13px]", children: [
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(N, { children: i.prefix }),
47
+ /* @__PURE__ */ o(T, { children: t.prefix }),
48
48
  " ",
49
- /* @__PURE__ */ o(D.CodeText, { variant: "inline", children: e })
49
+ /* @__PURE__ */ o(G.CodeText, { variant: "inline", children: e })
50
50
  ] }),
51
51
  /* @__PURE__ */ o(
52
- T,
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(te, { size: 13 }) : /* @__PURE__ */ o(le, { size: 13 }),
59
- onClick: I,
60
- disabled: !t
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
- i.suffix ? /* @__PURE__ */ o("span", { id: x, children: /* @__PURE__ */ o(N, { children: i.suffix }) }) : null
64
- ] }) : /* @__PURE__ */ o("label", { id: u, htmlFor: b, className: "px-2 text-[13px]", children: /* @__PURE__ */ o(N, { children: l }) }),
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: b,
68
+ id: v,
69
69
  name: "confirmation-phrase",
70
70
  size: "medium",
71
71
  value: m,
72
72
  onChange: f,
73
- "aria-labelledby": g,
73
+ "aria-labelledby": B,
74
74
  placeholder: c,
75
75
  requiredIndicator: "none",
76
- error: !!y,
77
- "aria-describedby": r ? C : void 0,
76
+ error: !!x,
77
+ "aria-describedby": r ? b : void 0,
78
78
  disabled: a
79
79
  }
80
80
  ),
81
- /* @__PURE__ */ o(ne, { id: C, message: r }),
82
- i ? /* @__PURE__ */ o("span", { role: "status", className: "sr-only", children: Ce(n, e) }) : null
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: v }),
86
- warning: /* @__PURE__ */ o(ae, { size: v }),
87
- destructive: /* @__PURE__ */ o(re, { size: v }),
88
- success: /* @__PURE__ */ o(ie, { size: v })
89
- }, $e = ({
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: i,
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: t,
100
- confirmPhraseLabel: I,
101
- confirmPhraseCopyLabel: y = "Copy",
99
+ confirmPhrase: i,
100
+ confirmPhraseLabel: g,
101
+ confirmPhraseCopyLabel: x = "Copy",
102
102
  onPhraseCopied: u,
103
- confirmPhrasePlaceholder: x,
104
- confirmLabel: C = "Confirm",
105
- cancelLabel: b = "Cancel",
103
+ confirmPhrasePlaceholder: C,
104
+ confirmLabel: b = "Confirm",
105
+ cancelLabel: v = "Cancel",
106
106
  loading: r = !1,
107
- confirmDisabled: g = !1,
108
- tip: G,
109
- size: R = "medium",
110
- "aria-label": V,
111
- "aria-labelledby": q,
112
- children: z
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 [B, L] = $(""), k = d(), w = d(), A = me[s], [S, Y] = $({ open: e, confirmPhrase: t });
115
- (S.open !== e || S.confirmPhrase !== t) && (Y({ open: e, confirmPhrase: t }), e && L(""));
116
- const { parts: H, text: j } = xe(
117
- I,
118
- t
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: W,
121
- canCopy: Z,
122
- copy: J
123
- } = be(t, e, r, u), E = B.trim(), F = (t == null ? void 0 : t.trim()) ?? "", O = !t || (F === "" ? B === t : E === F), K = ue(E, F), Q = r || g || !O, U = ee.toArray(z).some(
124
- (M) => typeof M != "string" || M.trim() !== ""
125
- ), _ = !!a || U || !!t, X = [n ? w : null, a ? k : null].filter(Boolean).join(" ") || void 0, P = /* @__PURE__ */ p("div", { className: "flex w-full flex-wrap items-center justify-end gap-[8px]", children: [
126
- /* @__PURE__ */ o(T, { variant: "outline", size: "small", onClick: i, disabled: r, children: b }),
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
- T,
128
+ z,
129
129
  {
130
- variant: A.confirmVariant,
130
+ variant: F.confirmVariant,
131
131
  size: "small",
132
132
  onClick: l,
133
- disabled: Q,
133
+ disabled: D,
134
134
  loading: r,
135
- tooltip: !r && !O ? j : void 0,
136
- children: C
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: i,
144
+ onClose: t,
145
145
  title: c,
146
- size: R,
146
+ size: V,
147
147
  footer: P,
148
148
  busy: r,
149
149
  role: s === "destructive" ? "alertdialog" : "dialog",
150
- "aria-label": V,
151
- "aria-labelledby": q,
150
+ "aria-label": q,
151
+ "aria-labelledby": Y,
152
152
  "aria-describedby": X,
153
- closeOnOverlayClick: s !== "destructive" && !t,
153
+ closeOnOverlayClick: s !== "destructive" && !i,
154
154
  headerDivider: !0,
155
155
  titleAdornment: m,
156
156
  bodyPadding: !1,
157
- tray: { tone: A.tray, caption: G },
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 ?? A.calloutType,
170
+ type: n.type ?? F.calloutType,
171
171
  message: n.message,
172
- divider: _
172
+ divider: M
173
173
  }
174
174
  ) : null,
175
- _ ? /* @__PURE__ */ p("div", { className: "flex flex-col gap-[12px] p-[28px]", children: [
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
- z,
185
- t ? /* @__PURE__ */ o(
186
- ve,
187
- {
188
- phrase: t,
189
- parts: H,
190
- plainLabel: j,
191
- placeholder: x,
192
- value: B,
193
- onChange: L,
194
- disabled: r,
195
- copyLabel: y,
196
- copyOutcome: W,
197
- canCopy: Z,
198
- onCopy: J,
199
- nearMissMessage: K
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
- $e as ConfirmationDialog,
209
- $e as default
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","handleCopyP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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,eAAe,MAAMU,KAAA,gBAAAA,EAAWV,EAAO;AAAA,EAE/C;AAEA,SAAO,EAAE,SAAAM,GAAS,SAASK,KAAW,CAACF,GAAU,MAAM,MAAM,KAAKK,IAAI;AAC1E,GAEMC,IAAqD,CAAC,EAAE,UAAAC,QAC1D,gBAAAC,EAACC,EAAW,MAAX,EAAgB,MAAK,SAAQ,OAAM,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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;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,109 @@
1
+ import { jsx as a, jsxs as n } from "react/jsx-runtime";
2
+ import k from "./CustomIcons/CheckmarkIcon.js";
3
+ import p from "./Typography/Text.js";
4
+ import { isRenderableNode as b } from "./renderableNode.js";
5
+ const i = 24, x = 1, v = {
6
+ medium: { padding: { x: 28, y: 16 }, title: "medium", description: "small" },
7
+ small: { padding: { x: 20, y: 12 }, title: "small", description: "xsmall" }
8
+ }, S = {
9
+ complete: "Completed",
10
+ open: void 0,
11
+ locked: "Locked"
12
+ }, E = (t, r) => ({
13
+ insetInlineStart: t.x + i / 2 - 1,
14
+ top: t.y + i,
15
+ height: `calc(100% - ${i - (r ? x : 0)}px)`
16
+ }), c = "var(--malachite-card-border, rgb(232, 232, 232))", $ = "var(--malachite-accent-background, rgb(0, 175, 102))", N = `repeating-linear-gradient(to bottom, ${c} 0px, ${c} 4px, transparent 4px, transparent 8px)`, A = {
17
+ complete: "bg-[var(--malachite-accent-background,rgb(0,175,102))] text-white",
18
+ open: "border-[1.5px] border-solid border-[var(--malachite-accent-background,rgb(0,175,102))] bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-accent-foreground,rgb(2,122,66))]",
19
+ locked: "border-[1.5px] border-solid border-[var(--malachite-text-dimmed,rgb(153,153,153))] bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-text-dimmed,rgb(153,153,153))]"
20
+ }, I = (t, r) => t.key ?? `#${r}`, L = ({
21
+ steps: t,
22
+ size: r = "medium",
23
+ dividers: s = !1,
24
+ "aria-label": g,
25
+ "aria-labelledby": h,
26
+ className: u = ""
27
+ }) => {
28
+ const o = v[r], f = t.findIndex((e) => e.status === "open"), y = t.some((e) => b(e.action));
29
+ return (
30
+ // `role="list"`: Safari drops the list role from a list styled `list-none`.
31
+ /* @__PURE__ */ a(
32
+ "ol",
33
+ {
34
+ role: "list",
35
+ "aria-label": g,
36
+ "aria-labelledby": h,
37
+ className: `isolate m-0 list-none p-0 ${u}`,
38
+ children: t.map((e, l) => {
39
+ const d = e.status === "locked", m = S[e.status];
40
+ return /* @__PURE__ */ n(
41
+ "li",
42
+ {
43
+ "aria-current": l === f ? "step" : void 0,
44
+ style: {
45
+ padding: `${o.padding.y}px ${o.padding.x}px`,
46
+ borderBottom: s ? `${x}px solid ${c}` : void 0
47
+ },
48
+ className: "relative flex items-start gap-[12px]",
49
+ children: [
50
+ l < t.length - 1 && /* @__PURE__ */ a(
51
+ "span",
52
+ {
53
+ "aria-hidden": "true",
54
+ className: "absolute z-[1] w-[2px]",
55
+ style: {
56
+ ...E(o.padding, s),
57
+ background: e.status === "complete" ? $ : N
58
+ }
59
+ }
60
+ ),
61
+ /* @__PURE__ */ a(
62
+ "span",
63
+ {
64
+ "aria-hidden": "true",
65
+ className: `relative z-[2] box-border flex shrink-0 items-center justify-center rounded-full text-[length:var(--malachite-font-size-xsmall,11px)] [font-weight:600] ${A[e.status]}`,
66
+ style: { width: i, height: i },
67
+ children: e.status === "complete" ? /* @__PURE__ */ a(k, { size: 12 }) : l + 1
68
+ }
69
+ ),
70
+ /* @__PURE__ */ n("span", { className: "flex min-w-0 flex-1 flex-col gap-[2px] pt-[2px]", children: [
71
+ /* @__PURE__ */ n(
72
+ p,
73
+ {
74
+ size: o.title,
75
+ fontWeight: "semi-bold",
76
+ color: d ? "dimmed" : "primary",
77
+ children: [
78
+ e.title,
79
+ m && /* @__PURE__ */ n("span", { className: "sr-only", children: [
80
+ ", ",
81
+ m
82
+ ] })
83
+ ]
84
+ }
85
+ ),
86
+ b(e.description) && /* @__PURE__ */ a(
87
+ p,
88
+ {
89
+ size: o.description,
90
+ color: d ? "dimmed" : "secondary",
91
+ children: e.description
92
+ }
93
+ )
94
+ ] }),
95
+ y && /* @__PURE__ */ a("span", { className: "ml-[16px] flex min-w-[120px] items-center justify-end", children: e.action })
96
+ ]
97
+ },
98
+ I(e, l)
99
+ );
100
+ })
101
+ }
102
+ )
103
+ );
104
+ };
105
+ export {
106
+ L as StepList,
107
+ L as default
108
+ };
109
+ //# sourceMappingURL=StepList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepList.js","sources":["../../src/components/StepList.tsx"],"sourcesContent":["import type React from 'react';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport Text from './Typography/Text';\nimport { isRenderableNode } from './renderableNode';\n\nexport type StepListStatus = 'complete' | 'open' | 'locked';\n\nexport type StepListSize = 'medium' | 'small';\n\nexport interface StepListItem {\n /** Keys the row; falls back to its position, so pass one when steps come and go. */\n key?: string;\n title: React.ReactNode;\n description?: React.ReactNode;\n /**\n * `complete` fills the marker with a tick, `open` rings it in the accent, and `locked`\n * dims the marker and the text. The first `open` step is the current one.\n */\n status: StepListStatus;\n /**\n * Right of the text, e.g. the step's button. The state is already announced after the\n * title, so a label that repeats it, such as \"Completed\", wants `aria-hidden`.\n */\n action?: React.ReactNode;\n}\n\nexport interface StepListProps {\n steps: StepListItem[];\n /** `small` is the compact list for a sidebar: tighter rows and smaller text. */\n size?: StepListSize;\n /** Rules a line under each row, for a list that fills its container edge to edge. */\n dividers?: boolean;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /** On the list. Each connector runs to the next row's marker, so add no gap between rows. */\n className?: string;\n}\n\nconst MARKER_SIZE = 24;\nconst DIVIDER_WIDTH = 1;\n\nconst SIZES: Record<\n StepListSize,\n {\n padding: { x: number; y: number };\n title: 'medium' | 'small';\n description: 'small' | 'xsmall';\n }\n> = {\n medium: { padding: { x: 28, y: 16 }, title: 'medium', description: 'small' },\n small: { padding: { x: 20, y: 12 }, title: 'small', description: 'xsmall' },\n};\n\n// Read out after the title: the marker is hidden, and the dimmed text alone says nothing.\nconst STATUS_LABELS: Record<StepListStatus, string | undefined> = {\n complete: 'Completed',\n open: undefined,\n locked: 'Locked',\n};\n\n// From a marker's foot, through the next row's top padding and any rule, to its marker.\nconst connectorStyle = (\n padding: { x: number; y: number },\n divider: boolean,\n): React.CSSProperties => ({\n insetInlineStart: padding.x + MARKER_SIZE / 2 - 1,\n top: padding.y + MARKER_SIZE,\n height: `calc(100% - ${MARKER_SIZE - (divider ? DIVIDER_WIDTH : 0)}px)`,\n});\n\nconst BORDER = 'var(--malachite-card-border, rgb(232, 232, 232))';\nconst ACCENT = 'var(--malachite-accent-background, rgb(0, 175, 102))';\n\nconst DASHED = `repeating-linear-gradient(to bottom, ${BORDER} 0px, ${BORDER} 4px, transparent 4px, transparent 8px)`;\n\n// White on the accent fill in both themes, as Checkbox draws its tick.\nconst MARKER_CLASSES: Record<StepListStatus, string> = {\n complete: 'bg-[var(--malachite-accent-background,rgb(0,175,102))] text-white',\n open: 'border-[1.5px] border-solid border-[var(--malachite-accent-background,rgb(0,175,102))] bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-accent-foreground,rgb(2,122,66))]',\n locked: 'border-[1.5px] border-solid border-[var(--malachite-text-dimmed,rgb(153,153,153))] bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-text-dimmed,rgb(153,153,153))]',\n};\n\n// The position, not the title: two steps may share one. `#` keeps it off consumers' keys.\nconst keyOf = (step: StepListItem, index: number): string => step.key ?? `#${index}`;\n\n/**\n * A numbered, vertical list of setup steps: a marker per step joined by a line that turns\n * solid once a step is done, the step's title and description, and an optional action.\n */\nconst StepList: React.FC<StepListProps> = ({\n steps,\n size = 'medium',\n dividers = false,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className = '',\n}) => {\n const sizing = SIZES[size];\n const current = steps.findIndex((step) => step.status === 'open');\n // Every row keeps the column once any step has an action, so the text wraps alike.\n const hasActions = steps.some((step) => isRenderableNode(step.action));\n\n return (\n // `role=\"list\"`: Safari drops the list role from a list styled `list-none`.\n <ol\n role=\"list\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className={`isolate m-0 list-none p-0 ${className}`}\n >\n {steps.map((step, index) => {\n const locked = step.status === 'locked';\n const statusLabel = STATUS_LABELS[step.status];\n return (\n <li\n key={keyOf(step, index)}\n aria-current={index === current ? 'step' : undefined}\n style={{\n padding: `${sizing.padding.y}px ${sizing.padding.x}px`,\n borderBottom: dividers\n ? `${DIVIDER_WIDTH}px solid ${BORDER}`\n : undefined,\n }}\n className=\"relative flex items-start gap-[12px]\"\n >\n {index < steps.length - 1 && (\n <span\n aria-hidden=\"true\"\n className=\"absolute z-[1] w-[2px]\"\n style={{\n ...connectorStyle(sizing.padding, dividers),\n background: step.status === 'complete' ? ACCENT : DASHED,\n }}\n />\n )}\n <span\n aria-hidden=\"true\"\n className={`relative z-[2] box-border flex shrink-0 items-center justify-center rounded-full text-[length:var(--malachite-font-size-xsmall,11px)] [font-weight:600] ${MARKER_CLASSES[step.status]}`}\n style={{ width: MARKER_SIZE, height: MARKER_SIZE }}\n >\n {step.status === 'complete' ? <CheckmarkIcon size={12} /> : index + 1}\n </span>\n <span className=\"flex min-w-0 flex-1 flex-col gap-[2px] pt-[2px]\">\n <Text\n size={sizing.title}\n fontWeight=\"semi-bold\"\n color={locked ? 'dimmed' : 'primary'}\n >\n {step.title}\n {statusLabel && <span className=\"sr-only\">, {statusLabel}</span>}\n </Text>\n {isRenderableNode(step.description) && (\n <Text\n size={sizing.description}\n color={locked ? 'dimmed' : 'secondary'}\n >\n {step.description}\n </Text>\n )}\n </span>\n {hasActions && (\n <span className=\"ml-[16px] flex min-w-[120px] items-center justify-end\">\n {step.action}\n </span>\n )}\n </li>\n );\n })}\n </ol>\n );\n};\n\nexport default StepList;\nexport { StepList };\n"],"names":["MARKER_SIZE","DIVIDER_WIDTH","SIZES","STATUS_LABELS","connectorStyle","padding","divider","BORDER","ACCENT","DASHED","MARKER_CLASSES","keyOf","step","index","StepList","steps","size","dividers","ariaLabel","ariaLabelledBy","className","sizing","current","hasActions","isRenderableNode","jsx","locked","statusLabel","jsxs","CheckmarkIcon","Text"],"mappings":";;;;AAsCA,MAAMA,IAAc,IACdC,IAAgB,GAEhBC,IAOF;AAAA,EACA,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,GAAA,GAAM,OAAO,UAAU,aAAa,QAAA;AAAA,EACnE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,MAAM,OAAO,SAAS,aAAa,SAAA;AACrE,GAGMC,IAA4D;AAAA,EAC9D,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AACZ,GAGMC,IAAiB,C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;AAAA,YAAA;AAAA,YAhDCd,EAAMC,GAAMC,CAAK;AAAA,UAAA;AAAA,QAoDlC,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA;AAGb;"}
@@ -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;"}