@stackone/malachite 2.127.0 → 2.129.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPONENTS.md +2 -1
- package/dist/components/PillButtonGroup.js +35 -0
- package/dist/components/PillButtonGroup.js.map +1 -0
- package/dist/components/StepList.js +155 -74
- package/dist/components/StepList.js.map +1 -1
- package/dist/components/collapseFocus.js +14 -16
- package/dist/components/collapseFocus.js.map +1 -1
- package/dist/index.d.ts +32 -0
- package/dist/index.js +367 -365
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
package/COMPONENTS.md
CHANGED
|
@@ -102,7 +102,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
102
102
|
- **`SearchTrigger`** — A button drawn as a filled search field, for opening a command palette or search dialog from app chrome such as a sidebar. It is not an input — typing happens in what it opens. `shortcut` draws flat `<kbd>` chips at the end (not `Keycap`, whose raised shadow reads as a second button inside a filled field), kept out of the accessible name; `iconOnly` makes a 36px icon tile matching a collapsed `NavItem`, named by `label`. _Key props:_ `label` (default `Search`), `shortcut` (`ReactNode[]`), `iconOnly`, `aria-label`, `className`, plus native button attributes (`onClick`, `aria-haspopup`, `aria-expanded`, `aria-keyshortcuts`).
|
|
103
103
|
- **`FooterNav`** — Footer navigation bar of links. _Key props:_ `FooterNavLink[]`.
|
|
104
104
|
- **`FooterLinks`** — Inline list of footer links (e.g. terms, privacy, support).
|
|
105
|
-
- **`StepList`** — A numbered, vertical list of setup steps: a marker per step joined by a line that turns solid once a step is complete, each step’s title and description, and an optional trailing action such as its button. Steps are `complete` (a tick on the accent fill), `open` (an accent ring) or `locked` (dimmed). The first open step carries `aria-current="step"
|
|
105
|
+
- **`StepList`** — A numbered, vertical list of setup steps: a marker per step joined by a line that turns solid once a step is complete, each step’s title and description, and an optional trailing action such as its button. Steps are `complete` (a tick on the accent fill), `open` (an accent ring) or `locked` (dimmed). The first open step carries `aria-current="step"` and is the only one to show its `children` under the description, so finishing a step collapses its content and opens the next one’s; focus that an update drops from the current step moves to the step now current, else stays on that row; dropped from any other row it stays on that row, else moves to the current step; failing both it moves to the list. `variant="focused"` marks each step with a ring around a rounded square (a tick once complete, an empty dimmed ring while locked) and a "Step N" label above its title, both in the accent on the current step only, and fades every other step and every connecting line to 40%, so the current step stands out; with no current step only locked steps fade. `size="small"` is the compact list for a sidebar; `dividers` rules a line under each row for a list that fills its container. `completeLabel` shows a dot and that label, such as "Completed", in the action column of a complete step with no `action`, hidden from assistive tech, which already hears the state. For a horizontal progress readout use `Stepper`; for a clickable step header use `StepTabs`. _Key props:_ `steps` (`key`, `title`, `description`, `status`, `action`, `children`), `variant` (`numbered` | `focused`), `size`, `dividers`, `completeLabel`, `aria-label`, `aria-labelledby`, `className`.
|
|
106
106
|
- **`StepTabs`** — Header for a short, ordered flow — a two-step drawer or wizard panel. Each step is a button carrying `aria-current="step"`, not a tab: the body beneath is the step’s form, so it keeps the normal tab order instead of adopting a `tablist`’s arrow-key contract. States are current / complete (a check, still reachable so the user can go back) / upcoming. For a read-only progress readout use `Stepper`. _Key props:_ `items` (`key`, `label`, `hint`, `disabled`), `activeKey`, `completedKeys`, `onChange`, `aria-label`, `aria-labelledby`, `className`.
|
|
107
107
|
- **`CommandPalette`** — Chrome for a command palette, over a headless library that keeps its own elements. `FieldRow`/`Field` take the query input, `List` the scrolling viewport (with a bottom fade for `hasMoreBelow`), `Group` + `Heading` a titled section, and `Row` one result — composing leading/label/tags/crumb/meta/status/hint so names start and statuses end on the same x down the list. `Message` covers empty and loading, `Legend` documents the scope sigils, `Footer` the key hints. Everything the library owns is taken through `asChild`, so its role, id, state and handlers are untouched.
|
|
108
108
|
- **`Keycap`** — One key on a keyboard, drawn as a cap — `esc`, `⌘`, a caret, or a sigil a user types to scope a search. Renders a `<kbd>`, or a button as soon as either `onClick` or `disabled` is passed — `disabled={false}` included, since naming the prop at all is the statement that the cap is a control. `SidePanelNavFooter` is built on it.
|
|
@@ -118,6 +118,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
118
118
|
- **`CloseButton`** — The bare X that dismisses a screen, panel or wizard: secondary at rest, primary on hover and keyboard focus, with no box or background at either. Use it instead of a `ghost` `Button` (which draws a hover box) or `no-style` (which has no disabled look). `surface="inverse"` is for a panel that stays dark in every theme, such as `SplitScreenLayout`’s, and reads the `closeButton` theme tokens. `loading` swaps the X for a spinner and sets `aria-busy`. Disabled and loading both use `aria-disabled` rather than `disabled`, so they ignore clicks but stay focusable and can still trigger a `Tooltip` explaining why. Named "Close" unless `aria-label` says otherwise. _Key props:_ `onClick`, `aria-label`, `size` (`small` 24px | `medium` 32px, 12px glyph), `surface` (`default` | `inverse`), `disabled`, `loading`.
|
|
119
119
|
- **`AccessPills`** — Three toggle pills, R / W / D, saying which effects an account grants (Read, Write, Delete) — on a linked-account row and in the header above the rows. Each pill is a button with `aria-pressed`, named in full by its state (`Write: some actions off`), and a tooltip on hover and focus spells that name out, since a letter alone is cryptic. On paints the effect’s tint (Read in `Tag`’s primary, Write in warning, Delete in error, the colours the dashboard already gives these effects), `"mixed"` (some, not all, of its actions on) an empty pill with a dashed border, off a neutral one. The colours come from the theme and there is no colour prop. It reports only which pill was pressed through `onToggle`: any cascade between effects (Read off turning Write and Delete off, say) and what pressing a mixed pill means belong to the caller. A pill in `disabled` stays focusable with `aria-disabled`, ignores clicks and keys, and its tooltip shows `disabledReason` instead, which is also its accessible description. `size="dense"` draws 24×20 pills in place of 26×24, for a narrow screen. _Key props:_ `value` (`{ read, write, delete }`, each `true` | `false` | `"mixed"`), `onToggle(effect)`, `disabled` (per effect), `disabledReason` (per effect, or one string), `size` (`default` | `dense`), `aria-label`, `aria-labelledby`.
|
|
120
120
|
- **`PillButton`** — Pill-shaped button, often used for filters/toggleable chips. `shape="tab"` squares the top corners so a row of them reads as attached to whatever sits above — the controls under a chat composer. Pass `href` and an interactive, non-disabled pill renders a real anchor (cmd-click, copy-link) instead of navigating from `onClick`; a disabled or `interactive={false}` pill stays static, and an unsafe scheme such as `javascript:` is dropped. `target="_blank"` always carries `noopener noreferrer`. _Key props:_ `label`, `icon`, `trailingIcon`, `selected`, `pressed` (makes a button pill a toggle: announces `aria-pressed` and paints the selected look while true, in place of `selected`; not on a link pill or the `assistant` tone), `disabled`, `interactive`, `size`, `variant`, `shape` (`pill` | `tab`), `onClick`, `href`, `target`, `rel`.
|
|
121
|
+
- **`PillButtonGroup`** — A named `group` around a wrapping row of `PillButton`s, so a screen reader announces the question a set of toggle pills answers, such as “Which finding is wrong?”. `label` shows the name above the pills and names the group by it; without one, the type requires `aria-label` or `aria-labelledby`, one name source only. An empty name warns in development. _Key props:_ `label` (visible name, a string or element), `aria-label` or `aria-labelledby` (exactly one of the three), `className`.
|
|
121
122
|
- **`CopyButton`** — The small copy control a copyable `Input` ends with, for a copyable value that is not an input, such as a list of scopes beside its label, so the two read the same. With `value` it copies and shows a check for a second; without, the click is the caller’s. _Key props:_ `value`, `onCopy`, `copied`, `aria-label`, `tooltip`.
|
|
122
123
|
- **`BannerButton`** — A banner that is one button: the warm ground, an icon in a white tile, a title with one line under it, and an arrow at the end that darkens on hover. For an offer of help beside a form, such as opening its setup guide, that wants more presence than a link and less than a primary button. Pass `aria-expanded` when it opens and closes something. _Key props:_ `icon`, `title`, `description`, `trailing`, `onClick`, `aria-expanded`, `aria-controls`, `aria-label`.
|
|
123
124
|
- **`Link`** — Styled anchor/link text. Opens in a new tab by default; with `renderLink`, a root-relative href goes through the app's own link component instead (href, classes, children and `onClick` when set; no `target` or `rel`), while any other href keeps the new-tab anchor. _Key props:_ `href`, `color` (`default` | `dimmed` | `inherit`; `inherit` takes the surrounding text colour, for a name in a tinted row, and thickens its underline on hover, a cue that shows on any surface and theme; it is always underlined, whatever `underline` says), `size`, `underline`, `truncate` (as a flex item, shrinks and ellipsizes the label), `onClick`, `renderLink`, `target`, `rel`.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsxs as d, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useId as s } from "react";
|
|
3
|
+
import m from "./Typography/Text.js";
|
|
4
|
+
import { devWarning as p } from "./devWarning.js";
|
|
5
|
+
import { isRenderableNode as u } from "./renderableNode.js";
|
|
6
|
+
const g = ({
|
|
7
|
+
children: t,
|
|
8
|
+
className: n = "",
|
|
9
|
+
label: o,
|
|
10
|
+
"aria-label": a,
|
|
11
|
+
"aria-labelledby": i
|
|
12
|
+
}) => {
|
|
13
|
+
const l = s(), e = u(o);
|
|
14
|
+
return !e && !a && !i && p(
|
|
15
|
+
`PillButtonGroup.unnamed:${l}`,
|
|
16
|
+
"PillButtonGroup got an empty `label`, `aria-label` or `aria-labelledby`, so screen readers announce the group with no name."
|
|
17
|
+
), /* @__PURE__ */ d(
|
|
18
|
+
"div",
|
|
19
|
+
{
|
|
20
|
+
role: "group",
|
|
21
|
+
"aria-label": e ? void 0 : a || void 0,
|
|
22
|
+
"aria-labelledby": e ? l : i || void 0,
|
|
23
|
+
className: `flex flex-col gap-2 ${n}`,
|
|
24
|
+
children: [
|
|
25
|
+
e && /* @__PURE__ */ r("div", { id: l, children: /* @__PURE__ */ r(m, { size: "small", children: o }) }),
|
|
26
|
+
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: t })
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
g as PillButtonGroup,
|
|
33
|
+
g as default
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=PillButtonGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PillButtonGroup.js","sources":["../../src/components/PillButtonGroup.tsx"],"sourcesContent":["import type React from 'react';\nimport { useId } from 'react';\nimport Text from './Typography/Text';\nimport { devWarning } from './devWarning';\nimport { isRenderableNode } from './renderableNode';\n\ninterface PillButtonGroupBaseProps {\n children: React.ReactNode;\n className?: string;\n}\n\ntype PillButtonGroupNameProps =\n | { label: string | React.ReactElement; 'aria-label'?: never; 'aria-labelledby'?: never }\n | { label?: never; 'aria-label': string; 'aria-labelledby'?: never }\n | { label?: never; 'aria-label'?: never; 'aria-labelledby': string };\n\nexport type PillButtonGroupProps = PillButtonGroupBaseProps & PillButtonGroupNameProps;\n\nconst PillButtonGroup: React.FC<PillButtonGroupProps> = ({\n children,\n className = '',\n label,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => {\n const labelId = useId();\n const hasLabel = isRenderableNode(label);\n if (!hasLabel && !ariaLabel && !ariaLabelledBy) {\n devWarning(\n `PillButtonGroup.unnamed:${labelId}`,\n 'PillButtonGroup got an empty `label`, `aria-label` or `aria-labelledby`, so screen readers announce the group with no name.',\n );\n }\n return (\n <div\n role=\"group\"\n aria-label={hasLabel ? undefined : ariaLabel || undefined}\n aria-labelledby={hasLabel ? labelId : ariaLabelledBy || undefined}\n className={`flex flex-col gap-2 ${className}`}\n >\n {hasLabel && (\n <div id={labelId}>\n <Text size=\"small\">{label}</Text>\n </div>\n )}\n <div className=\"flex flex-wrap items-center gap-2\">{children}</div>\n </div>\n );\n};\n\nexport default PillButtonGroup;\nexport { PillButtonGroup };\n"],"names":["PillButtonGroup","children","className","label","ariaLabel","ariaLabelledBy","labelId","useId","hasLabel","isRenderableNode","devWarning","jsxs","jsx","Text"],"mappings":";;;;;AAkBA,MAAMA,IAAkD,CAAC;AAAA,EACrD,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,cAAcC;AAAA,EACd,mBAAmBC;AACvB,MAAM;AACF,QAAMC,IAAUC,EAAA,GACVC,IAAWC,EAAiBN,CAAK;AACvC,SAAI,CAACK,KAAY,CAACJ,KAAa,CAACC,KAC5BK;AAAA,IACI,2BAA2BJ,CAAO;AAAA,IAClC;AAAA,EAAA,GAIJ,gBAAAK;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,MAAK;AAAA,MACL,cAAYH,IAAW,SAAYJ,KAAa;AAAA,MAChD,mBAAiBI,IAAWF,IAAUD,KAAkB;AAAA,MACxD,WAAW,uBAAuBH,CAAS;AAAA,MAE1C,UAAA;AAAA,QAAAM,KACG,gBAAAI,EAAC,SAAI,IAAIN,GACL,4BAACO,GAAA,EAAK,MAAK,SAAS,UAAAV,EAAA,CAAM,EAAA,CAC9B;AAAA,QAEJ,gBAAAS,EAAC,OAAA,EAAI,WAAU,qCAAqC,UAAAX,EAAA,CAAS;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGzE;"}
|
|
@@ -1,115 +1,196 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
},
|
|
13
|
-
insetInlineStart:
|
|
14
|
-
top:
|
|
15
|
-
height: `calc(100% - ${i - (r ?
|
|
16
|
-
}),
|
|
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
|
-
},
|
|
21
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"aria-
|
|
27
|
-
|
|
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
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
] }),
|
|
33
|
-
(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
|
-
|
|
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":
|
|
42
|
-
"aria-labelledby":
|
|
43
|
-
className: `isolate m-0 list-none p-0 ${
|
|
44
|
-
children:
|
|
45
|
-
const
|
|
46
|
-
return /* @__PURE__ */
|
|
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
|
-
|
|
87
|
+
ref: m ? k : void 0,
|
|
88
|
+
"aria-current": m ? "step" : void 0,
|
|
50
89
|
style: {
|
|
51
|
-
padding: `${
|
|
52
|
-
borderBottom:
|
|
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
|
-
|
|
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
|
-
...
|
|
63
|
-
background: e.status === "complete" ?
|
|
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__ */
|
|
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] ${
|
|
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__ */
|
|
120
|
+
children: e.status === "complete" ? /* @__PURE__ */ a(D, { size: 12 }) : p + 1
|
|
74
121
|
}
|
|
75
122
|
),
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
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
|
-
|
|
113
|
-
|
|
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,IAAQ,CAACC,GAAoBC,MAA0BD,EAAK,OAAO,IAAIC,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mBhB,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,EAAQ,IAAIL,IAAc,IAAI;AAAA,EAChD,KAA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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
|
|
2
|
-
if (
|
|
3
|
-
|
|
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 (!
|
|
6
|
+
if (!t)
|
|
7
7
|
return;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
const { activeElement:
|
|
12
|
-
return !!
|
|
13
|
-
}, s = ({ body:
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
s as
|
|
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":["//
|
|
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
|
@@ -4816,6 +4816,29 @@ declare interface PillButtonBaseProps {
|
|
|
4816
4816
|
rel?: string;
|
|
4817
4817
|
}
|
|
4818
4818
|
|
|
4819
|
+
export declare const PillButtonGroup: default_2.FC<PillButtonGroupProps>;
|
|
4820
|
+
|
|
4821
|
+
declare interface PillButtonGroupBaseProps {
|
|
4822
|
+
children: default_2.ReactNode;
|
|
4823
|
+
className?: string;
|
|
4824
|
+
}
|
|
4825
|
+
|
|
4826
|
+
declare type PillButtonGroupNameProps = {
|
|
4827
|
+
label: string | default_2.ReactElement;
|
|
4828
|
+
'aria-label'?: never;
|
|
4829
|
+
'aria-labelledby'?: never;
|
|
4830
|
+
} | {
|
|
4831
|
+
label?: never;
|
|
4832
|
+
'aria-label': string;
|
|
4833
|
+
'aria-labelledby'?: never;
|
|
4834
|
+
} | {
|
|
4835
|
+
label?: never;
|
|
4836
|
+
'aria-label'?: never;
|
|
4837
|
+
'aria-labelledby': string;
|
|
4838
|
+
};
|
|
4839
|
+
|
|
4840
|
+
export declare type PillButtonGroupProps = PillButtonGroupBaseProps & PillButtonGroupNameProps;
|
|
4841
|
+
|
|
4819
4842
|
declare type PillButtonProps = PillButtonBaseProps & ({
|
|
4820
4843
|
tone?: Extract<PillButtonTone, 'default'>;
|
|
4821
4844
|
pressed?: boolean;
|
|
@@ -5983,12 +6006,19 @@ export declare interface StepListItem {
|
|
|
5983
6006
|
status: StepListStatus;
|
|
5984
6007
|
/** Right of the text, e.g. the step's button. See `completeLabel` for a complete step. */
|
|
5985
6008
|
action?: default_2.ReactNode;
|
|
6009
|
+
/** Under the description, shown only while this is the current step. */
|
|
6010
|
+
children?: default_2.ReactNode;
|
|
5986
6011
|
}
|
|
5987
6012
|
|
|
5988
6013
|
export declare interface StepListProps {
|
|
5989
6014
|
steps: StepListItem[];
|
|
5990
6015
|
/** `small` is the compact list for a sidebar: tighter rows and smaller text. */
|
|
5991
6016
|
size?: StepListSize;
|
|
6017
|
+
/**
|
|
6018
|
+
* `focused` marks each step with a ring around a square and a "Step N" label, in the accent
|
|
6019
|
+
* on the current step only, and fades every other step, any locked one, and the lines.
|
|
6020
|
+
*/
|
|
6021
|
+
variant?: StepListVariant;
|
|
5992
6022
|
/** Rules a line under each row, for a list that fills its container edge to edge. */
|
|
5993
6023
|
dividers?: boolean;
|
|
5994
6024
|
/**
|
|
@@ -6006,6 +6036,8 @@ export declare type StepListSize = 'medium' | 'small';
|
|
|
6006
6036
|
|
|
6007
6037
|
export declare type StepListStatus = 'complete' | 'open' | 'locked';
|
|
6008
6038
|
|
|
6039
|
+
declare type StepListVariant = 'numbered' | 'focused';
|
|
6040
|
+
|
|
6009
6041
|
export declare const Stepper: default_2.FC<StepperProps | GroupedStepperProps>;
|
|
6010
6042
|
|
|
6011
6043
|
declare interface StepperBaseProps {
|