@stackone/malachite 2.128.0 → 2.130.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.
@@ -0,0 +1,79 @@
1
+ import { jsx as a, jsxs as s, Fragment as b } from "react/jsx-runtime";
2
+ import h from "react";
3
+ import { Progress as u } from "./Progress.js";
4
+ import { VisuallyHidden as g } from "./VisuallyHidden.js";
5
+ import { paintOnChild as x } from "./asChild.js";
6
+ import { FOCUS_RING_INSET as f } from "./focusRing.js";
7
+ import { useSidebarCollapsed as v } from "./sidebarContext.js";
8
+ const p = "box-border flex w-full flex-col gap-2 rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-accent-border,rgba(0,175,102,0.2))] bg-[var(--malachite-accent-background-glass,rgba(0,175,102,0.08))] px-3 py-[10px] text-left no-underline transition-colors duration-200", N = `${p} cursor-pointer hover:border-[var(--malachite-control-border-hover,rgba(0,175,102,0.4))] ${f}`, _ = "[box-shadow:inset_0_0_0_1.5px_var(--malachite-accent-foreground,rgb(2,122,66))]", c = 5, d = { backgroundColor: "var(--malachite-card-background, rgb(255, 255, 255))" }, C = (r, e) => Math.min(Math.max(r, 0), e), m = ({
9
+ title: r,
10
+ value: e,
11
+ max: o,
12
+ caption: l,
13
+ busy: i = !1,
14
+ linked: t,
15
+ "aria-valuetext": n = `${e} of ${o}`
16
+ }) => /* @__PURE__ */ s(b, { children: [
17
+ /* @__PURE__ */ s("span", { className: "flex min-w-0 items-baseline gap-[6px]", children: [
18
+ /* @__PURE__ */ a("span", { className: "min-w-0 truncate text-[13px] leading-4 font-medium text-[var(--malachite-text-primary,rgb(10,10,10))]", children: r }),
19
+ !i && /* @__PURE__ */ s(
20
+ "span",
21
+ {
22
+ "aria-hidden": !0,
23
+ className: "ml-auto shrink-0 font-mono text-[11px] leading-4 text-[var(--malachite-accent-foreground,rgb(2,122,66))]",
24
+ children: [
25
+ e,
26
+ "/",
27
+ o
28
+ ]
29
+ }
30
+ ),
31
+ t && /* @__PURE__ */ a(g, { children: `, ${n},` })
32
+ ] }),
33
+ /* @__PURE__ */ a("span", { className: "block min-w-0 truncate text-[11.5px] leading-[15px] text-[var(--malachite-text-secondary,rgb(123,123,123))]", children: l }),
34
+ i ? /* @__PURE__ */ a(
35
+ "span",
36
+ {
37
+ className: "block rounded-[3px]",
38
+ style: { ...d, height: `${c}px` }
39
+ }
40
+ ) : /* @__PURE__ */ a("span", { "aria-hidden": t || void 0, className: "block", children: /* @__PURE__ */ a(
41
+ u,
42
+ {
43
+ height: c,
44
+ max: o,
45
+ segments: [{ value: e, variant: "accent" }],
46
+ "aria-label": r,
47
+ "aria-valuetext": n,
48
+ style: d
49
+ }
50
+ ) })
51
+ ] }), k = ({ link: r, current: e = !1, value: o, max: l, ...i }) => {
52
+ const t = { ...i, value: C(o, l), max: l };
53
+ if (r && !t.busy) {
54
+ const n = x(
55
+ r,
56
+ `${N} ${e ? _ : ""}`,
57
+ void 0,
58
+ /* @__PURE__ */ a(m, { ...t, linked: !0 })
59
+ );
60
+ return e ? h.cloneElement(n, {
61
+ "aria-current": "page"
62
+ }) : n;
63
+ }
64
+ return /* @__PURE__ */ a(
65
+ "div",
66
+ {
67
+ role: "group",
68
+ "aria-label": t.title,
69
+ "aria-busy": t.busy || void 0,
70
+ className: p,
71
+ children: /* @__PURE__ */ a(m, { ...t, linked: !1 })
72
+ }
73
+ );
74
+ }, A = (r) => v() ? null : /* @__PURE__ */ a("div", { className: "shrink-0 px-4 pb-4", children: /* @__PURE__ */ a(k, { ...r }) });
75
+ export {
76
+ A as SidebarProgress,
77
+ A as default
78
+ };
79
+ //# sourceMappingURL=SidebarProgress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidebarProgress.js","sources":["../../src/components/SidebarProgress.tsx"],"sourcesContent":["import React from 'react';\nimport Progress from './Progress';\nimport VisuallyHidden from './VisuallyHidden';\nimport { paintOnChild } from './asChild';\nimport { FOCUS_RING_INSET } from './focusRing';\nimport { useSidebarCollapsed } from './sidebarContext';\n\ninterface SidebarProgressBaseProps {\n title: string;\n /** Steps done, out of `max`. */\n value: number;\n max: number;\n caption: React.ReactNode;\n busy?: boolean;\n /** Spoken in the link's name when `link` is set. Defaults to \"`value` of `max`\". */\n 'aria-valuetext'?: string;\n}\n\ninterface SidebarProgressLinkProps {\n /** An empty link element, such as `<a href>` or a router `Link`, that the whole card becomes. */\n link: React.ReactElement;\n /** The page `link` opens is the one on screen. */\n current?: boolean;\n}\n\n/** `current` only exists alongside `link`: there is nothing else to mark. */\nexport type SidebarProgressProps = SidebarProgressBaseProps &\n (SidebarProgressLinkProps | { link?: undefined; current?: never });\n\nconst CARD = `box-border flex w-full flex-col gap-2 rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-accent-border,rgba(0,175,102,0.2))] bg-[var(--malachite-accent-background-glass,rgba(0,175,102,0.08))] px-3 py-[10px] text-left no-underline transition-colors duration-200`;\nconst LINK = `${CARD} cursor-pointer hover:border-[var(--malachite-control-border-hover,rgba(0,175,102,0.4))] ${FOCUS_RING_INSET}`;\n// Inset, like the focus ring, so neither is clipped by the scrolling body the card sits in.\nconst CURRENT = '[box-shadow:inset_0_0_0_1.5px_var(--malachite-accent-foreground,rgb(2,122,66))]';\nconst BAR_HEIGHT_PX = 5;\nconst TRACK = { backgroundColor: 'var(--malachite-card-background, rgb(255, 255, 255))' };\n\nconst clamp = (value: number, max: number): number => Math.min(Math.max(value, 0), max);\n\ntype CardContentProps = Omit<SidebarProgressProps, 'link' | 'current'> & { linked: boolean };\n\n// Browsers differ on whether a progressbar's value reaches its link's name, so a link speaks it as text.\nconst CardContent: React.FC<CardContentProps> = ({\n title,\n value,\n max,\n caption,\n busy = false,\n linked,\n 'aria-valuetext': ariaValueText = `${value} of ${max}`,\n}) => (\n <>\n <span className=\"flex min-w-0 items-baseline gap-[6px]\">\n <span className=\"min-w-0 truncate text-[13px] leading-4 font-medium text-[var(--malachite-text-primary,rgb(10,10,10))]\">\n {title}\n </span>\n {!busy && (\n <span\n aria-hidden\n className=\"ml-auto shrink-0 font-mono text-[11px] leading-4 text-[var(--malachite-accent-foreground,rgb(2,122,66))]\"\n >\n {value}/{max}\n </span>\n )}\n {linked && <VisuallyHidden>{`, ${ariaValueText},`}</VisuallyHidden>}\n </span>\n <span className=\"block min-w-0 truncate text-[11.5px] leading-[15px] text-[var(--malachite-text-secondary,rgb(123,123,123))]\">\n {caption}\n </span>\n {busy ? (\n <span\n className=\"block rounded-[3px]\"\n style={{ ...TRACK, height: `${BAR_HEIGHT_PX}px` }}\n />\n ) : (\n <span aria-hidden={linked || undefined} className=\"block\">\n <Progress\n height={BAR_HEIGHT_PX}\n max={max}\n segments={[{ value, variant: 'accent' }]}\n aria-label={title}\n aria-valuetext={ariaValueText}\n style={TRACK}\n />\n </span>\n )}\n </>\n);\n\nconst Card: React.FC<SidebarProgressProps> = ({ link, current = false, value, max, ...rest }) => {\n const content = { ...rest, value: clamp(value, max), max };\n if (link && !content.busy) {\n const card = paintOnChild(\n link,\n `${LINK} ${current ? CURRENT : ''}`,\n undefined,\n <CardContent {...content} linked />,\n );\n return current\n ? React.cloneElement(card, {\n 'aria-current': 'page',\n } as React.HTMLAttributes<HTMLElement>)\n : card;\n }\n return (\n <div\n role=\"group\"\n aria-label={content.title}\n aria-busy={content.busy || undefined}\n className={CARD}\n >\n <CardContent {...content} linked={false} />\n </div>\n );\n};\n\n/** A checklist's progress at the sidebar's gutter, as one link to the checklist; hidden while collapsed. */\nconst SidebarProgress: React.FC<SidebarProgressProps> = (props) => {\n const collapsed = useSidebarCollapsed();\n if (collapsed) {\n return null;\n }\n return (\n <div className=\"shrink-0 px-4 pb-4\">\n <Card {...props} />\n </div>\n );\n};\n\nexport { SidebarProgress };\nexport default SidebarProgress;\n"],"names":["CARD","LINK","FOCUS_RING_INSET","CURRENT","BAR_HEIGHT_PX","TRACK","clamp","value","max","CardContent","title","caption","busy","linked","ariaValueText","jsxs","Fragment","jsx","VisuallyHidden","Progress","Card","link","current","rest","content","card","paintOnChild","React","SidebarProgress","props","useSidebarCollapsed"],"mappings":";;;;;;;AA6BA,MAAMA,IAAO,2SACPC,IAAO,GAAGD,CAAI,4FAA4FE,CAAgB,IAE1HC,IAAU,mFACVC,IAAgB,GAChBC,IAAQ,EAAE,iBAAiB,uDAAA,GAE3BC,IAAQ,CAACC,GAAeC,MAAwB,KAAK,IAAI,KAAK,IAAID,GAAO,CAAC,GAAGC,CAAG,GAKhFC,IAA0C,CAAC;AAAA,EAC7C,OAAAC;AAAA,EACA,OAAAH;AAAA,EACA,KAAAC;AAAA,EACA,SAAAG;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAC;AAAA,EACA,kBAAkBC,IAAgB,GAAGP,CAAK,OAAOC,CAAG;AACxD,MACI,gBAAAO,EAAAC,GAAA,EACI,UAAA;AAAA,EAAA,gBAAAD,EAAC,QAAA,EAAK,WAAU,yCACZ,UAAA;AAAA,IAAA,gBAAAE,EAAC,QAAA,EAAK,WAAU,yGACX,UAAAP,GACL;AAAA,IACC,CAACE,KACE,gBAAAG;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,eAAW;AAAA,QACX,WAAU;AAAA,QAET,UAAA;AAAA,UAAAR;AAAA,UAAM;AAAA,UAAEC;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAGhBK,KAAU,gBAAAI,EAACC,GAAA,EAAgB,UAAA,KAAKJ,CAAa,IAAA,CAAI;AAAA,EAAA,GACtD;AAAA,EACA,gBAAAG,EAAC,QAAA,EAAK,WAAU,+GACX,UAAAN,GACL;AAAA,EACCC,IACG,gBAAAK;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,OAAO,EAAE,GAAGZ,GAAO,QAAQ,GAAGD,CAAa,KAAA;AAAA,IAAK;AAAA,EAAA,IAGpD,gBAAAa,EAAC,QAAA,EAAK,eAAaJ,KAAU,QAAW,WAAU,SAC9C,UAAA,gBAAAI;AAAA,IAACE;AAAA,IAAA;AAAA,MACG,QAAQf;AAAA,MACR,KAAAI;AAAA,MACA,UAAU,CAAC,EAAE,OAAAD,GAAO,SAAS,UAAU;AAAA,MACvC,cAAYG;AAAA,MACZ,kBAAgBI;AAAA,MAChB,OAAOT;AAAA,IAAA;AAAA,EAAA,EACX,CACJ;AAAA,GAER,GAGEe,IAAuC,CAAC,EAAE,MAAAC,GAAM,SAAAC,IAAU,IAAO,OAAAf,GAAO,KAAAC,GAAK,GAAGe,QAAW;AAC7F,QAAMC,IAAU,EAAE,GAAGD,GAAM,OAAOjB,EAAMC,GAAOC,CAAG,GAAG,KAAAA,EAAA;AACrD,MAAIa,KAAQ,CAACG,EAAQ,MAAM;AACvB,UAAMC,IAAOC;AAAA,MACTL;AAAA,MACA,GAAGpB,CAAI,IAAIqB,IAAUnB,IAAU,EAAE;AAAA,MACjC;AAAA,MACA,gBAAAc,EAACR,GAAA,EAAa,GAAGe,GAAS,QAAM,GAAA,CAAC;AAAA,IAAA;AAErC,WAAOF,IACDK,EAAM,aAAaF,GAAM;AAAA,MACrB,gBAAgB;AAAA,IAAA,CACkB,IACtCA;AAAA,EACV;AACA,SACI,gBAAAR;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,MAAK;AAAA,MACL,cAAYO,EAAQ;AAAA,MACpB,aAAWA,EAAQ,QAAQ;AAAA,MAC3B,WAAWxB;AAAA,MAEX,UAAA,gBAAAiB,EAACR,GAAA,EAAa,GAAGe,GAAS,QAAQ,GAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAGrD,GAGMI,IAAkD,CAACC,MACnCC,EAAA,IAEP,OAGP,gBAAAb,EAAC,SAAI,WAAU,sBACX,4BAACG,GAAA,EAAM,GAAGS,GAAO,EAAA,CACrB;"}
@@ -1,115 +1,196 @@
1
- import { jsx as t, jsxs as o } from "react/jsx-runtime";
2
- import N from "./CustomIcons/CheckmarkIcon.js";
3
- import c from "./Typography/Text.js";
4
- import { isRenderableNode as s } from "./renderableNode.js";
5
- const i = 24, g = 1, E = {
6
- medium: { padding: { x: 28, y: 16 }, title: "medium", description: "small" },
7
- small: { padding: { x: 20, y: 12 }, title: "small", description: "xsmall" }
8
- }, $ = {
1
+ import { jsxs as s, Fragment as F, jsx as a } from "react/jsx-runtime";
2
+ import O, { useRef as E } from "react";
3
+ import D from "./CustomIcons/CheckmarkIcon.js";
4
+ import f from "./Typography/Text.js";
5
+ import { isFocusDropped as j, focusSection as B, holdsFocus as U } from "./collapseFocus.js";
6
+ import { isRenderableNode as b } from "./renderableNode.js";
7
+ const i = 24, I = 1, G = {
8
+ medium: { padding: { x: 28, y: 16 }, title: "medium", description: "small", childrenGap: 10 },
9
+ small: { padding: { x: 20, y: 12 }, title: "small", description: "xsmall", childrenGap: 6 }
10
+ }, H = {
9
11
  complete: "Completed",
10
12
  open: void 0,
11
13
  locked: "Locked"
12
- }, z = (a, r) => ({
13
- insetInlineStart: a.x + i / 2 - 1,
14
- top: a.y + i,
15
- height: `calc(100% - ${i - (r ? g : 0)}px)`
16
- }), d = "var(--malachite-card-border, rgb(232, 232, 232))", A = "var(--malachite-accent-background, rgb(0, 175, 102))", I = `repeating-linear-gradient(to bottom, ${d} 0px, ${d} 4px, transparent 4px, transparent 8px)`, R = {
14
+ }, W = (t, r) => ({
15
+ insetInlineStart: t.x + i / 2 - 1,
16
+ top: t.y + i,
17
+ height: `calc(100% - ${i - (r ? I : 0)}px)`
18
+ }), z = "var(--malachite-card-border, rgb(232, 232, 232))", T = "var(--malachite-accent-background, rgb(0, 175, 102))", K = "var(--malachite-accent-foreground, rgb(2, 122, 66))", g = "var(--malachite-text-secondary, rgb(123, 123, 123))", Z = "var(--malachite-text-dimmed, rgb(161, 161, 161))", A = 0.4, P = (t) => `repeating-linear-gradient(to bottom, ${t} 0px, ${t} 4px, transparent 4px, transparent 8px)`, V = {
17
19
  complete: "bg-[var(--malachite-accent-background,rgb(0,175,102))] text-white",
18
20
  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
21
  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
- }, w = (a, r) => a.key ?? `#${r}`, j = ({
21
- steps: a,
22
+ }, Y = ({
23
+ status: t,
24
+ color: r,
25
+ opacity: o
26
+ }) => /* @__PURE__ */ s(
27
+ "span",
28
+ {
29
+ "aria-hidden": "true",
30
+ className: "relative z-[2] box-border flex shrink-0 items-center justify-center rounded-full border-[1.5px] border-solid bg-[var(--malachite-card-background,rgb(255,255,255))]",
31
+ style: { width: i, height: i, borderColor: r, color: r, opacity: o },
32
+ children: [
33
+ t === "complete" && /* @__PURE__ */ a(D, { size: 12 }),
34
+ t === "open" && /* @__PURE__ */ a("span", { className: "size-[10px] rounded-[3px]", style: { background: r } })
35
+ ]
36
+ }
37
+ ), q = (t, r) => r ? T : t === "locked" ? Z : g, J = (t) => Array.from(t.children).find(
38
+ (r) => r instanceof HTMLElement && U(r, t.getRootNode())
39
+ );
40
+ class Q extends O.Component {
41
+ getSnapshotBeforeUpdate() {
42
+ const r = this.props.listRef.current, o = r ? J(r) : void 0;
43
+ return o ? { row: o, wasCurrent: o === this.props.currentRef.current } : null;
44
+ }
45
+ componentDidUpdate(r, o, l) {
46
+ if (!l || !j(l.row.ownerDocument))
47
+ return;
48
+ const { row: u, wasCurrent: x } = l, h = this.props.currentRef.current, n = [...x ? [h, u] : [u, h], this.props.listRef.current].find(
49
+ (d) => d == null ? void 0 : d.isConnected
50
+ );
51
+ B(null, n ?? null, { preventScroll: !1 });
52
+ }
53
+ render() {
54
+ return null;
55
+ }
56
+ }
57
+ const X = (t, r) => t.key ?? `#${r}`, ce = ({
58
+ steps: t,
22
59
  size: r = "medium",
23
- dividers: m = !1,
24
- completeLabel: p,
25
- "aria-label": u,
26
- "aria-labelledby": f,
27
- className: k = ""
60
+ variant: o = "numbered",
61
+ dividers: l = !1,
62
+ completeLabel: u,
63
+ "aria-label": x,
64
+ "aria-labelledby": h,
65
+ className: v = ""
28
66
  }) => {
29
- const l = E[r], y = a.findIndex((e) => e.status === "open"), b = (e) => !!p && e.status === "complete" && !s(e.action), v = /* @__PURE__ */ o("span", { "aria-hidden": "true", className: "flex items-center gap-[6px]", children: [
30
- /* @__PURE__ */ t("span", { className: "size-[8px] shrink-0 rounded-full bg-[var(--malachite-text-success,rgb(2,122,66))]" }),
31
- /* @__PURE__ */ t(c, { size: "small", fontWeight: "semi-bold", color: "success", children: p })
32
- ] }), S = a.some(
33
- (e) => s(e.action) || b(e)
67
+ const n = G[r], d = E(null), k = E(null), R = t.findIndex((e) => e.status === "open"), c = o === "focused", N = c && R !== -1, _ = c ? g : z, $ = c ? g : T, C = (e) => !!u && e.status === "complete" && !b(e.action), L = /* @__PURE__ */ s("span", { "aria-hidden": "true", className: "flex items-center gap-[6px]", children: [
68
+ /* @__PURE__ */ a("span", { className: "size-[8px] shrink-0 rounded-full bg-[var(--malachite-text-success,rgb(2,122,66))]" }),
69
+ /* @__PURE__ */ a(f, { size: "small", fontWeight: "semi-bold", color: "success", children: u })
70
+ ] }), M = t.some(
71
+ (e) => b(e.action) || C(e)
34
72
  );
35
- return (
36
- // `role="list"`: Safari drops the list role from a list styled `list-none`.
37
- /* @__PURE__ */ t(
73
+ return /* @__PURE__ */ s(F, { children: [
74
+ /* @__PURE__ */ a(
38
75
  "ol",
39
76
  {
77
+ ref: d,
40
78
  role: "list",
41
- "aria-label": u,
42
- "aria-labelledby": f,
43
- className: `isolate m-0 list-none p-0 ${k}`,
44
- children: a.map((e, n) => {
45
- const x = e.status === "locked", h = $[e.status];
46
- return /* @__PURE__ */ o(
79
+ "aria-label": x,
80
+ "aria-labelledby": h,
81
+ className: `isolate m-0 list-none p-0 ${v}`,
82
+ children: t.map((e, p) => {
83
+ const m = p === R, S = !c && e.status === "locked", w = H[e.status], y = c && (N && !m || e.status === "locked") ? A : void 0;
84
+ return /* @__PURE__ */ s(
47
85
  "li",
48
86
  {
49
- "aria-current": n === y ? "step" : void 0,
87
+ ref: m ? k : void 0,
88
+ "aria-current": m ? "step" : void 0,
50
89
  style: {
51
- padding: `${l.padding.y}px ${l.padding.x}px`,
52
- borderBottom: m ? `${g}px solid ${d}` : void 0
90
+ padding: `${n.padding.y}px ${n.padding.x}px`,
91
+ borderBottom: l ? `${I}px solid ${z}` : void 0
53
92
  },
54
93
  className: "relative flex items-start gap-[12px]",
55
94
  children: [
56
- n < a.length - 1 && /* @__PURE__ */ t(
95
+ p < t.length - 1 && /* @__PURE__ */ a(
57
96
  "span",
58
97
  {
59
98
  "aria-hidden": "true",
60
99
  className: "absolute z-[1] w-[2px]",
61
100
  style: {
62
- ...z(l.padding, m),
63
- background: e.status === "complete" ? A : I
101
+ ...W(n.padding, l),
102
+ background: e.status === "complete" ? $ : P(_),
103
+ opacity: N ? A : void 0
64
104
  }
65
105
  }
66
106
  ),
67
- /* @__PURE__ */ t(
107
+ c ? /* @__PURE__ */ a(
108
+ Y,
109
+ {
110
+ status: e.status,
111
+ color: q(e.status, m),
112
+ opacity: y
113
+ }
114
+ ) : /* @__PURE__ */ a(
68
115
  "span",
69
116
  {
70
117
  "aria-hidden": "true",
71
- 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] ${R[e.status]}`,
118
+ 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] ${V[e.status]}`,
72
119
  style: { width: i, height: i },
73
- children: e.status === "complete" ? /* @__PURE__ */ t(N, { size: 12 }) : n + 1
120
+ children: e.status === "complete" ? /* @__PURE__ */ a(D, { size: 12 }) : p + 1
74
121
  }
75
122
  ),
76
- /* @__PURE__ */ o("span", { className: "flex min-w-0 flex-1 flex-col gap-[2px] pt-[2px]", children: [
77
- /* @__PURE__ */ o(
78
- c,
79
- {
80
- size: l.title,
81
- fontWeight: "semi-bold",
82
- color: x ? "dimmed" : "primary",
83
- children: [
84
- e.title,
85
- h && /* @__PURE__ */ o("span", { className: "sr-only", children: [
86
- ", ",
87
- h
88
- ] })
89
- ]
90
- }
91
- ),
92
- s(e.description) && /* @__PURE__ */ t(
93
- c,
94
- {
95
- size: l.description,
96
- color: x ? "dimmed" : "secondary",
97
- children: e.description
98
- }
99
- )
100
- ] }),
101
- S && /* @__PURE__ */ t("span", { className: "ml-[16px] flex min-w-[120px] items-center justify-end", children: b(e) ? v : e.action })
123
+ /* @__PURE__ */ s(
124
+ "div",
125
+ {
126
+ className: "flex min-w-0 flex-1 flex-col gap-[2px] pt-[2px]",
127
+ style: { opacity: y },
128
+ children: [
129
+ c && /* @__PURE__ */ a(
130
+ "div",
131
+ {
132
+ "aria-hidden": "true",
133
+ style: { color: m ? K : g },
134
+ children: /* @__PURE__ */ s(f, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", children: [
135
+ "Step ",
136
+ p + 1
137
+ ] })
138
+ }
139
+ ),
140
+ /* @__PURE__ */ s(
141
+ f,
142
+ {
143
+ size: n.title,
144
+ fontWeight: "semi-bold",
145
+ color: S ? "dimmed" : "primary",
146
+ children: [
147
+ e.title,
148
+ w && /* @__PURE__ */ s("span", { className: "sr-only", children: [
149
+ ", ",
150
+ w
151
+ ] })
152
+ ]
153
+ }
154
+ ),
155
+ b(e.description) && /* @__PURE__ */ a(
156
+ f,
157
+ {
158
+ size: n.description,
159
+ color: S ? "dimmed" : "secondary",
160
+ children: e.description
161
+ }
162
+ ),
163
+ m && b(e.children) && /* @__PURE__ */ a(
164
+ "div",
165
+ {
166
+ className: "min-w-0",
167
+ style: { marginTop: n.childrenGap },
168
+ children: e.children
169
+ }
170
+ )
171
+ ]
172
+ }
173
+ ),
174
+ M && /* @__PURE__ */ a(
175
+ "span",
176
+ {
177
+ className: "ml-[16px] flex min-w-[120px] items-center justify-end",
178
+ style: { opacity: y },
179
+ children: C(e) ? L : e.action
180
+ }
181
+ )
102
182
  ]
103
183
  },
104
- w(e, n)
184
+ X(e, p)
105
185
  );
106
186
  })
107
187
  }
108
- )
109
- );
188
+ ),
189
+ /* @__PURE__ */ a(Q, { listRef: d, currentRef: k })
190
+ ] });
110
191
  };
111
192
  export {
112
- j as StepList,
113
- j as default
193
+ ce as StepList,
194
+ ce as default
114
195
  };
115
196
  //# sourceMappingURL=StepList.js.map
@@ -1 +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 /** Right of the text, e.g. the step's button. See `completeLabel` for a complete step. */\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 /**\n * Shown, with a dot, in the action column of a complete step that has no `action`, e.g.\n * \"Completed\". Hidden from assistive tech, which already hears the state after the title.\n */\n completeLabel?: string;\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 completeLabel,\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 const showsCompleteLabel = (step: StepListItem) =>\n Boolean(completeLabel) && step.status === 'complete' && !isRenderableNode(step.action);\n const completeMark = (\n <span aria-hidden=\"true\" className=\"flex items-center gap-[6px]\">\n {/* Success, as its text: the label reports a status, not a choice. */}\n <span className=\"size-[8px] shrink-0 rounded-full bg-[var(--malachite-text-success,rgb(2,122,66))]\" />\n <Text size=\"small\" fontWeight=\"semi-bold\" color=\"success\">\n {completeLabel}\n </Text>\n </span>\n );\n // Every row keeps the column once any step has an action or a complete label, so the text\n // wraps alike.\n const hasActions = steps.some(\n (step) => isRenderableNode(step.action) || showsCompleteLabel(step),\n );\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 {showsCompleteLabel(step) ? completeMark : 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","completeLabel","ariaLabel","ariaLabelledBy","className","sizing","current","showsCompleteLabel","isRenderableNode","completeMark","jsxs","jsx","Text","hasActions","locked","statusLabel","CheckmarkIcon"],"mappings":";;;;AAwCA,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,CACnBC,GACAC,OACuB;AAAA,EACvB,kBAAkBD,EAAQ,IAAIL,IAAc,IAAI;AAAA,EAChD,KAAKK,EAAQ,IAAIL;AAAA,EACjB,QAAQ,eAAeA,KAAeM,IAAUL,IAAgB,EAAE;AACtE,IAEMM,IAAS,oDACTC,IAAS,wDAETC,IAAS,wCAAwCF,CAAM,SAASA,CAAM,2CAGtEG,IAAiD;AAAA,EACnD,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AACZ,GAGMC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kB,KACG,gBAAAF,EAAC,QAAA,EAAK,WAAU,yDACX,YAAmBhB,CAAI,IAAIc,IAAed,EAAK,OAAA,CACpD;AAAA,cAAA;AAAA,YAAA;AAAA,YAhDCD,EAAMC,GAAMC,CAAK;AAAA,UAAA;AAAA,QAoDlC,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA;AAGb;"}
1
+ {"version":3,"file":"StepList.js","sources":["../../src/components/StepList.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport Text from './Typography/Text';\nimport { focusSection, holdsFocus, isFocusDropped } from './collapseFocus';\nimport { isRenderableNode } from './renderableNode';\n\nexport type StepListStatus = 'complete' | 'open' | 'locked';\n\nexport type StepListSize = 'medium' | 'small';\n\nexport type StepListVariant = 'numbered' | 'focused';\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 /** Right of the text, e.g. the step's button. See `completeLabel` for a complete step. */\n action?: React.ReactNode;\n /** Under the description, shown only while this is the current step. */\n children?: 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 /**\n * `focused` marks each step with a ring around a square and a \"Step N\" label, in the accent\n * on the current step only, and fades every other step, any locked one, and the lines.\n */\n variant?: StepListVariant;\n /** Rules a line under each row, for a list that fills its container edge to edge. */\n dividers?: boolean;\n /**\n * Shown, with a dot, in the action column of a complete step that has no `action`, e.g.\n * \"Completed\". Hidden from assistive tech, which already hears the state after the title.\n */\n completeLabel?: string;\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 childrenGap: number;\n }\n> = {\n medium: { padding: { x: 28, y: 16 }, title: 'medium', description: 'small', childrenGap: 10 },\n small: { padding: { x: 20, y: 12 }, title: 'small', description: 'xsmall', childrenGap: 6 },\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 ACCENT_FOREGROUND = 'var(--malachite-accent-foreground, rgb(2, 122, 66))';\nconst NEUTRAL = 'var(--malachite-text-secondary, rgb(123, 123, 123))';\nconst DIMMED = 'var(--malachite-text-dimmed, rgb(161, 161, 161))';\nconst FADED_OPACITY = 0.4;\n\nconst dashed = (color: string) =>\n `repeating-linear-gradient(to bottom, ${color} 0px, ${color} 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// A locked step keeps an empty ring, so it reads apart from an open step waiting its turn.\nconst FocusedMarker: React.FC<{ status: StepListStatus; color: string; opacity?: number }> = ({\n status,\n color,\n opacity,\n}) => (\n <span\n aria-hidden=\"true\"\n className=\"relative z-[2] box-border flex shrink-0 items-center justify-center rounded-full border-[1.5px] border-solid bg-[var(--malachite-card-background,rgb(255,255,255))]\"\n style={{ width: MARKER_SIZE, height: MARKER_SIZE, borderColor: color, color, opacity }}\n >\n {status === 'complete' && <CheckmarkIcon size={12} />}\n {status === 'open' && (\n <span className=\"size-[10px] rounded-[3px]\" style={{ background: color }} />\n )}\n </span>\n);\n\nconst focusedMarkerColor = (status: StepListStatus, isCurrent: boolean): string => {\n if (isCurrent) {\n return ACCENT;\n }\n return status === 'locked' ? DIMMED : NEUTRAL;\n};\n\ninterface StepFocusHandOffProps {\n listRef: React.RefObject<HTMLOListElement | null>;\n currentRef: React.RefObject<HTMLLIElement | null>;\n}\n\ninterface RowSnapshot {\n row: HTMLElement;\n wasCurrent: boolean;\n}\n\nconst rowHolding = (list: HTMLOListElement): HTMLElement | undefined =>\n Array.from(list.children).find(\n (row): row is HTMLElement =>\n row instanceof HTMLElement && holdsFocus(row, list.getRootNode()),\n );\n\n/** A class for `getSnapshotBeforeUpdate`, which sees focus before the update drops it. */\nclass StepFocusHandOff extends React.Component<StepFocusHandOffProps> {\n getSnapshotBeforeUpdate(): RowSnapshot | null {\n const list = this.props.listRef.current;\n const row = list ? rowHolding(list) : undefined;\n return row ? { row, wasCurrent: row === this.props.currentRef.current } : null;\n }\n\n componentDidUpdate(\n _previous: StepFocusHandOffProps,\n _state: unknown,\n snapshot: RowSnapshot | null,\n ): void {\n if (!snapshot || !isFocusDropped(snapshot.row.ownerDocument)) {\n return;\n }\n const { row, wasCurrent } = snapshot;\n const current = this.props.currentRef.current;\n // Leaving the current step moves on to the next; any other row keeps the reader in it.\n const nearest = wasCurrent ? [current, row] : [row, current];\n const target = [...nearest, this.props.listRef.current].find(\n (element) => element?.isConnected,\n );\n focusSection(null, target ?? null, { preventScroll: false });\n }\n\n render(): null {\n return null;\n }\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 variant = 'numbered',\n dividers = false,\n completeLabel,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className = '',\n}) => {\n const sizing = SIZES[size];\n const listRef = useRef<HTMLOListElement>(null);\n const currentRef = useRef<HTMLLIElement>(null);\n const current = steps.findIndex((step) => step.status === 'open');\n const focused = variant === 'focused';\n const fadesOthers = focused && current !== -1;\n const lineColor = focused ? NEUTRAL : BORDER;\n const solidLine = focused ? NEUTRAL : ACCENT;\n const showsCompleteLabel = (step: StepListItem) =>\n Boolean(completeLabel) && step.status === 'complete' && !isRenderableNode(step.action);\n const completeMark = (\n <span aria-hidden=\"true\" className=\"flex items-center gap-[6px]\">\n {/* Success, as its text: the label reports a status, not a choice. */}\n <span className=\"size-[8px] shrink-0 rounded-full bg-[var(--malachite-text-success,rgb(2,122,66))]\" />\n <Text size=\"small\" fontWeight=\"semi-bold\" color=\"success\">\n {completeLabel}\n </Text>\n </span>\n );\n // Every row keeps the column once any step has an action or a complete label, so the text\n // wraps alike.\n const hasActions = steps.some(\n (step) => isRenderableNode(step.action) || showsCompleteLabel(step),\n );\n\n return (\n <>\n {/* `role=\"list\"`: Safari drops the list role from a list styled `list-none`. */}\n <ol\n ref={listRef}\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 isCurrent = index === current;\n const locked = !focused && step.status === 'locked';\n const statusLabel = STATUS_LABELS[step.status];\n const faded =\n focused && ((fadesOthers && !isCurrent) || step.status === 'locked');\n const fade = faded ? FADED_OPACITY : undefined;\n return (\n <li\n key={keyOf(step, index)}\n ref={isCurrent ? currentRef : undefined}\n aria-current={isCurrent ? '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:\n step.status === 'complete'\n ? solidLine\n : dashed(lineColor),\n opacity: fadesOthers ? FADED_OPACITY : undefined,\n }}\n />\n )}\n {focused ? (\n <FocusedMarker\n status={step.status}\n color={focusedMarkerColor(step.status, isCurrent)}\n opacity={fade}\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' ? (\n <CheckmarkIcon size={12} />\n ) : (\n index + 1\n )}\n </span>\n )}\n <div\n className=\"flex min-w-0 flex-1 flex-col gap-[2px] pt-[2px]\"\n style={{ opacity: fade }}\n >\n {focused && (\n <div\n aria-hidden=\"true\"\n style={{ color: isCurrent ? ACCENT_FOREGROUND : NEUTRAL }}\n >\n <Text size=\"xsmall\" fontWeight=\"semi-bold\" color=\"inherit\">\n Step {index + 1}\n </Text>\n </div>\n )}\n <Text\n size={sizing.title}\n fontWeight=\"semi-bold\"\n color={locked ? 'dimmed' : 'primary'}\n >\n {step.title}\n {statusLabel && (\n <span className=\"sr-only\">, {statusLabel}</span>\n )}\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 {isCurrent && isRenderableNode(step.children) && (\n <div\n className=\"min-w-0\"\n style={{ marginTop: sizing.childrenGap }}\n >\n {step.children}\n </div>\n )}\n </div>\n {hasActions && (\n <span\n className=\"ml-[16px] flex min-w-[120px] items-center justify-end\"\n style={{ opacity: fade }}\n >\n {showsCompleteLabel(step) ? completeMark : step.action}\n </span>\n )}\n </li>\n );\n })}\n </ol>\n {/* After the list, so the hand-off reads the rows this commit rendered. */}\n <StepFocusHandOff listRef={listRef} currentRef={currentRef} />\n </>\n );\n};\n\nexport default StepList;\nexport { StepList };\n"],"names":["MARKER_SIZE","DIVIDER_WIDTH","SIZES","STATUS_LABELS","connectorStyle","padding","divider","BORDER","ACCENT","ACCENT_FOREGROUND","NEUTRAL","DIMMED","FADED_OPACITY","dashed","color","MARKER_CLASSES","FocusedMarker","status","opacity","jsxs","jsx","CheckmarkIcon","focusedMarkerColor","isCurrent","rowHolding","list","row","holdsFocus","StepFocusHandOff","React","_previous","_state","snapshot","isFocusDropped","wasCurrent","current","target","element","focusSection","keyOf","step","index","StepList","steps","size","variant","dividers","completeLabel","ariaLabel","ariaLabelledBy","className","sizing","listRef","useRef","currentRef","focused","fadesOthers","lineColor","solidLine","showsCompleteLabel","isRenderableNode","completeMark","Text","hasActions","Fragment","locked","statusLabel","fade"],"mappings":";;;;;;AAkDA,MAAMA,IAAc,IACdC,IAAgB,GAEhBC,IAQF;AAAA,EACA,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,MAAM,OAAO,UAAU,aAAa,SAAS,aAAa,GAAA;AAAA,EACzF,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,GAAA,GAAM,OAAO,SAAS,aAAa,UAAU,aAAa,EAAA;AAC5F,GAGMC,IAA4D;AAAA,EAC9D,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AACZ,GAGMC,IAAiB,CACnBC,GACAC,OACuB;AAAA,EACvB,kBAAkBD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AAA;AAAA,sBAAA;AAAA,sBAGhDN,EAAiBpB,EAAK,WAAW,KAC9B,gBAAApB;AAAA,wBAAC0C;AAAA,wBAAA;AAAA,0BACG,MAAMX,EAAO;AAAA,0BACb,OAAOc,IAAS,WAAW;AAAA,0BAE1B,UAAAzB,EAAK;AAAA,wBAAA;AAAA,sBAAA;AAAA,sBAGbjB,KAAaqC,EAAiBpB,EAAK,QAAQ,KACxC,gBAAApB;AAAA,wBAAC;AAAA,wBAAA;AAAA,0BACG,WAAU;AAAA,0BACV,OAAO,EAAE,WAAW+B,EAAO,YAAA;AAAA,0BAE1B,UAAAX,EAAK;AAAA,wBAAA;AAAA,sBAAA;AAAA,oBACV;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAGPuB,KACG,gBAAA3C;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACG,WAAU;AAAA,oBACV,OAAO,EAAE,SAAS+C,EAAA;AAAA,oBAEjB,UAAAR,EAAmBnB,CAAI,IAAIqB,IAAerB,EAAK;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACpD;AAAA,YAAA;AAAA,YA3FCD,EAAMC,GAAMC,CAAK;AAAA,UAAA;AAAA,QA+FlC,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA,IAGL,gBAAArB,EAACQ,GAAA,EAAiB,SAAAwB,GAAkB,YAAAE,EAAA,CAAwB;AAAA,EAAA,GAChE;AAER;"}
@@ -1,22 +1,20 @@
1
- const u = (r, e) => {
2
- if (r && !r.disabled) {
3
- r.focus({ preventScroll: !0 });
1
+ const d = (e, t, { preventScroll: o = !0 } = {}) => {
2
+ if (e && !e.disabled) {
3
+ e.focus({ preventScroll: o });
4
4
  return;
5
5
  }
6
- if (!e)
6
+ if (!t)
7
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
- };
8
+ const r = t.getAttribute("tabindex"), u = () => r === null ? t.removeAttribute("tabindex") : t.setAttribute("tabindex", r);
9
+ t.setAttribute("tabindex", "-1"), t.focus({ preventScroll: o }), t.getRootNode().activeElement === t ? t.addEventListener("blur", u, { once: !0 }) : u();
10
+ }, n = (e, t) => {
11
+ const { activeElement: o } = t;
12
+ return !!o && e.contains(o);
13
+ }, s = (e) => !e.activeElement || e.activeElement === e.body, i = ({ body: e, section: t }) => n(e, t.getRootNode()) || s(t.ownerDocument);
17
14
  export {
18
- u as focusSection,
19
- o as holdsFocus,
20
- s as isFocusLost
15
+ d as focusSection,
16
+ n as holdsFocus,
17
+ s as isFocusDropped,
18
+ i as isFocusLost
21
19
  };
22
20
  //# sourceMappingURL=collapseFocus.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collapseFocus.js","sources":["../../src/components/collapseFocus.ts"],"sourcesContent":["// Moving focus out of an Accordion body as it collapses; see `CollapseFocusHandOff`.\n\nexport const focusSection = (toggle: HTMLButtonElement | null, section: HTMLElement | null) => {\n if (toggle && !toggle.disabled) {\n toggle.focus({ preventScroll: true });\n return;\n }\n if (!section) {\n return;\n }\n // Focusable for this one stop, then back to whatever tabindex the consumer gave it.\n const previous = section.getAttribute('tabindex');\n const restore = () =>\n previous === null\n ? section.removeAttribute('tabindex')\n : section.setAttribute('tabindex', previous);\n section.setAttribute('tabindex', '-1');\n section.focus({ preventScroll: true });\n // Ignored inside an inert ancestor, where no blur would ever come to restore it.\n if ((section.getRootNode() as Document | ShadowRoot).activeElement === section) {\n section.addEventListener('blur', restore, { once: true });\n } else {\n restore();\n }\n};\n\n// Taken before the commit: an instant body is detached from its section by the update.\nexport interface FocusSnapshot {\n body: HTMLElement;\n section: HTMLElement;\n}\n\nexport const holdsFocus = (body: HTMLElement, root: Node) => {\n const { activeElement } = root as Document | ShadowRoot;\n return !!activeElement && body.contains(activeElement);\n};\n\n// Still inside a body that is inert or detached, or dropped to the page.\nexport const isFocusLost = ({ body, section }: FocusSnapshot) => {\n const page = section.ownerDocument;\n return (\n holdsFocus(body, section.getRootNode()) ||\n !page.activeElement ||\n page.activeElement === page.body\n );\n};\n"],"names":["focusSection","toggle","section","previous","restore","holdsFocus","body","root","activeElement","isFocusLost","page"],"mappings":"AAEO,MAAMA,IAAe,CAACC,GAAkCC,MAAgC;AAC3F,MAAID,KAAU,CAACA,EAAO,UAAU;AAC5B,IAAAA,EAAO,MAAM,EAAE,eAAe,GAAA,CAAM;AACpC;AAAA,EACJ;AACA,MAAI,CAACC;AACD;AAGJ,QAAMC,IAAWD,EAAQ,aAAa,UAAU,GAC1CE,IAAU,MACZD,MAAa,OACPD,EAAQ,gBAAgB,UAAU,IAClCA,EAAQ,aAAa,YAAYC,CAAQ;AACnD,EAAAD,EAAQ,aAAa,YAAY,IAAI,GACrCA,EAAQ,MAAM,EAAE,eAAe,GAAA,CAAM,GAEhCA,EAAQ,cAAwC,kBAAkBA,IACnEA,EAAQ,iBAAiB,QAAQE,GAAS,EAAE,MAAM,IAAM,IAExDA,EAAA;AAER,GAQaC,IAAa,CAACC,GAAmBC,MAAe;AACzD,QAAM,EAAE,eAAAC,MAAkBD;AAC1B,SAAO,CAAC,CAACC,KAAiBF,EAAK,SAASE,CAAa;AACzD,GAGaC,IAAc,CAAC,EAAE,MAAAH,GAAM,SAAAJ,QAA6B;AAC7D,QAAMQ,IAAOR,EAAQ;AACrB,SACIG,EAAWC,GAAMJ,EAAQ,YAAA,CAAa,KACtC,CAACQ,EAAK,iBACNA,EAAK,kBAAkBA,EAAK;AAEpC;"}
1
+ {"version":3,"file":"collapseFocus.js","sources":["../../src/components/collapseFocus.ts"],"sourcesContent":["// Handing focus on when the part of a component that holds it collapses or unmounts.\n\nexport const focusSection = (\n toggle: HTMLButtonElement | null,\n section: HTMLElement | null,\n { preventScroll = true }: { preventScroll?: boolean } = {},\n) => {\n if (toggle && !toggle.disabled) {\n toggle.focus({ preventScroll });\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 });\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\nexport const isFocusDropped = (page: Document) =>\n !page.activeElement || page.activeElement === page.body;\n\n// Still inside a body that is inert or detached, or dropped to the page.\nexport const isFocusLost = ({ body, section }: FocusSnapshot) =>\n holdsFocus(body, section.getRootNode()) || isFocusDropped(section.ownerDocument);\n"],"names":["focusSection","toggle","section","preventScroll","previous","restore","holdsFocus","body","root","activeElement","isFocusDropped","page","isFocusLost"],"mappings":"AAEO,MAAMA,IAAe,CACxBC,GACAC,GACA,EAAE,eAAAC,IAAgB,GAAA,IAAsC,OACvD;AACD,MAAIF,KAAU,CAACA,EAAO,UAAU;AAC5B,IAAAA,EAAO,MAAM,EAAE,eAAAE,GAAe;AAC9B;AAAA,EACJ;AACA,MAAI,CAACD;AACD;AAGJ,QAAME,IAAWF,EAAQ,aAAa,UAAU,GAC1CG,IAAU,MACZD,MAAa,OACPF,EAAQ,gBAAgB,UAAU,IAClCA,EAAQ,aAAa,YAAYE,CAAQ;AACnD,EAAAF,EAAQ,aAAa,YAAY,IAAI,GACrCA,EAAQ,MAAM,EAAE,eAAAC,GAAe,GAE1BD,EAAQ,cAAwC,kBAAkBA,IACnEA,EAAQ,iBAAiB,QAAQG,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,GAEaC,IAAiB,CAACC,MAC3B,CAACA,EAAK,iBAAiBA,EAAK,kBAAkBA,EAAK,MAG1CC,IAAc,CAAC,EAAE,MAAAL,GAAM,SAAAL,QAChCI,EAAWC,GAAML,EAAQ,YAAA,CAAa,KAAKQ,EAAeR,EAAQ,aAAa;"}
package/dist/index.d.ts CHANGED
@@ -5042,9 +5042,10 @@ declare interface ProgressSegmentsProps extends ProgressCommonProps {
5042
5042
  /**
5043
5043
  * Semantic colour role for a segment. Colours come from theme tokens by design — unlike
5044
5044
  * `color`/`trackColor`, which predate that rule, there is no free-form colour here. To
5045
- * restyle a role, override its token via `applyTheme` / `applyCustomTheme`.
5045
+ * restyle a role, override its token via `applyTheme` / `applyCustomTheme`. `accent` is the
5046
+ * brand's interaction colour, for progress through a flow rather than a status.
5046
5047
  */
5047
- export declare type ProgressSegmentVariant = 'default' | 'success' | 'warning' | 'error' | 'info';
5048
+ export declare type ProgressSegmentVariant = 'default' | 'success' | 'warning' | 'error' | 'info' | 'accent';
5048
5049
 
5049
5050
  declare interface ProgressValueProps extends ProgressCommonProps {
5050
5051
  value: number;
@@ -5569,6 +5570,7 @@ export declare const Sidebar: default_2.FC<SidebarProps> & {
5569
5570
  Switcher: default_2.ForwardRefExoticComponent<SidebarSwitcherProps & default_2.RefAttributes<HTMLButtonElement>>;
5570
5571
  Account: default_2.ForwardRefExoticComponent<SidebarAccountProps & default_2.RefAttributes<HTMLButtonElement>>;
5571
5572
  Usage: default_2.FC<UsageCardProps>;
5573
+ Progress: default_2.FC< SidebarProgressProps>;
5572
5574
  Panel: default_2.FC<{
5573
5575
  children: default_2.ReactNode;
5574
5576
  width?: number;
@@ -5598,6 +5600,30 @@ export declare interface SidebarAccountProps extends SidebarButtonAttributes {
5598
5600
 
5599
5601
  declare type SidebarButtonAttributes = Omit<default_2.ButtonHTMLAttributes<HTMLButtonElement>, 'style' | 'color' | 'children' | 'title' | 'name'>;
5600
5602
 
5603
+ declare interface SidebarProgressBaseProps {
5604
+ title: string;
5605
+ /** Steps done, out of `max`. */
5606
+ value: number;
5607
+ max: number;
5608
+ caption: default_2.ReactNode;
5609
+ busy?: boolean;
5610
+ /** Spoken in the link's name when `link` is set. Defaults to "`value` of `max`". */
5611
+ 'aria-valuetext'?: string;
5612
+ }
5613
+
5614
+ declare interface SidebarProgressLinkProps {
5615
+ /** An empty link element, such as `<a href>` or a router `Link`, that the whole card becomes. */
5616
+ link: default_2.ReactElement;
5617
+ /** The page `link` opens is the one on screen. */
5618
+ current?: boolean;
5619
+ }
5620
+
5621
+ /** `current` only exists alongside `link`: there is nothing else to mark. */
5622
+ export declare type SidebarProgressProps = SidebarProgressBaseProps & (SidebarProgressLinkProps | {
5623
+ link?: undefined;
5624
+ current?: never;
5625
+ });
5626
+
5601
5627
  export declare interface SidebarProps {
5602
5628
  collapsed?: boolean;
5603
5629
  /** Expanded from its rail, the sidebar floats over the page as a modal drawer: a scrim, Escape
@@ -6006,12 +6032,19 @@ export declare interface StepListItem {
6006
6032
  status: StepListStatus;
6007
6033
  /** Right of the text, e.g. the step's button. See `completeLabel` for a complete step. */
6008
6034
  action?: default_2.ReactNode;
6035
+ /** Under the description, shown only while this is the current step. */
6036
+ children?: default_2.ReactNode;
6009
6037
  }
6010
6038
 
6011
6039
  export declare interface StepListProps {
6012
6040
  steps: StepListItem[];
6013
6041
  /** `small` is the compact list for a sidebar: tighter rows and smaller text. */
6014
6042
  size?: StepListSize;
6043
+ /**
6044
+ * `focused` marks each step with a ring around a square and a "Step N" label, in the accent
6045
+ * on the current step only, and fades every other step, any locked one, and the lines.
6046
+ */
6047
+ variant?: StepListVariant;
6015
6048
  /** Rules a line under each row, for a list that fills its container edge to edge. */
6016
6049
  dividers?: boolean;
6017
6050
  /**
@@ -6029,6 +6062,8 @@ export declare type StepListSize = 'medium' | 'small';
6029
6062
 
6030
6063
  export declare type StepListStatus = 'complete' | 'open' | 'locked';
6031
6064
 
6065
+ declare type StepListVariant = 'numbered' | 'focused';
6066
+
6032
6067
  export declare const Stepper: default_2.FC<StepperProps | GroupedStepperProps>;
6033
6068
 
6034
6069
  declare interface StepperBaseProps {