@stackone/malachite 2.116.0 → 2.118.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 +19 -9
- package/dist/assets/icons/caret_down.svg.js +2 -2
- package/dist/assets/icons/caret_down.svg.js.map +1 -1
- package/dist/assets/icons/caret_up.svg.js +2 -2
- package/dist/assets/icons/caret_up.svg.js.map +1 -1
- package/dist/assets/icons/minus.svg.js +6 -0
- package/dist/assets/icons/minus.svg.js.map +1 -0
- package/dist/assets/icons/warning_circle_filled.svg.js +3 -3
- package/dist/assets/icons/warning_circle_filled.svg.js.map +1 -1
- package/dist/components/Alert.js +3 -3
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/BaseFormComponent.js +84 -64
- package/dist/components/BaseFormComponent.js.map +1 -1
- package/dist/components/ClampText.js +89 -15
- package/dist/components/ClampText.js.map +1 -1
- package/dist/components/CustomIcons/MinusIcon.js +16 -0
- package/dist/components/CustomIcons/MinusIcon.js.map +1 -0
- package/dist/components/CustomIcons/index.js +150 -147
- package/dist/components/CustomIcons/index.js.map +1 -1
- package/dist/components/Dropdown.js +449 -439
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/FieldBlock.js +32 -21
- package/dist/components/FieldBlock.js.map +1 -1
- package/dist/components/GuideTimeline/GuideJumpMenu.js +74 -0
- package/dist/components/GuideTimeline/GuideJumpMenu.js.map +1 -0
- package/dist/components/GuideTimeline/GuideProgress.js +81 -0
- package/dist/components/GuideTimeline/GuideProgress.js.map +1 -0
- package/dist/components/GuideTimeline/GuideTimeline.js +313 -0
- package/dist/components/GuideTimeline/GuideTimeline.js.map +1 -0
- package/dist/components/GuideTimeline/guideTimelinePositions.js +23 -0
- package/dist/components/GuideTimeline/guideTimelinePositions.js.map +1 -0
- package/dist/components/Link.js +11 -10
- package/dist/components/Link.js.map +1 -1
- package/dist/components/MultiSelect.js +1 -1
- package/dist/components/MultiSelect.js.map +1 -1
- package/dist/components/SidePanel.js +382 -227
- package/dist/components/SidePanel.js.map +1 -1
- package/dist/components/Tooltip.js +1 -1
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/TruncatedTooltip.js +1 -1
- package/dist/components/TruncatedTooltip.js.map +1 -1
- package/dist/components/ZoomableImage.js +144 -32
- package/dist/components/ZoomableImage.js.map +1 -1
- package/dist/components/sidePanelOverlay.js +7 -0
- package/dist/components/sidePanelOverlay.js.map +1 -0
- package/dist/index.d.ts +149 -11
- package/dist/index.js +265 -255
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as n, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as k } from "react";
|
|
3
|
+
import g from "../ActionMenu.js";
|
|
4
|
+
import { Button as E } from "../Button.js";
|
|
5
|
+
import T from "../CustomIcons/CaretDownIcon.js";
|
|
6
|
+
import { guideTimelinePositions as $, activeIndexOf as x } from "./guideTimelinePositions.js";
|
|
7
|
+
const d = 320, I = { width: d, maxWidth: "100%", minWidth: 0 }, L = {
|
|
8
|
+
flexShrink: 0,
|
|
9
|
+
fontFamily: "var(--malachite-font-mono, monospace)"
|
|
10
|
+
}, W = {
|
|
11
|
+
minWidth: 0,
|
|
12
|
+
overflow: "hidden",
|
|
13
|
+
textOverflow: "ellipsis",
|
|
14
|
+
whiteSpace: "nowrap"
|
|
15
|
+
}, v = {
|
|
16
|
+
display: "flex",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
gap: 8,
|
|
19
|
+
minWidth: 0
|
|
20
|
+
}, R = ({
|
|
21
|
+
sections: s,
|
|
22
|
+
active: p,
|
|
23
|
+
onSelect: a,
|
|
24
|
+
label: m = "Jump to step"
|
|
25
|
+
}) => {
|
|
26
|
+
const l = k(() => $(s), [s]), e = l[x(l, p)], f = s.flatMap((i, o) => {
|
|
27
|
+
const r = l.find((t) => t.sectionIndex === o), c = (e == null ? void 0 : e.sectionIndex) === o, h = {
|
|
28
|
+
key: `section:${i.key}`,
|
|
29
|
+
label: /* @__PURE__ */ n("span", { style: { fontWeight: 600 }, children: `${o + 1} · ${i.title}` }),
|
|
30
|
+
current: c && i.steps.length === 0,
|
|
31
|
+
intent: ((e == null ? void 0 : e.sectionIndex) ?? 0) > o ? "accent" : void 0,
|
|
32
|
+
onClick: () => a((r == null ? void 0 : r.key) ?? i.key)
|
|
33
|
+
}, y = c ? l.filter(
|
|
34
|
+
(t) => t.sectionIndex === o && i.steps.length > 0
|
|
35
|
+
).map((t) => ({
|
|
36
|
+
key: `step:${t.key}`,
|
|
37
|
+
label: `${t.code} ${t.title}`,
|
|
38
|
+
current: t.key === (e == null ? void 0 : e.key),
|
|
39
|
+
indent: !0,
|
|
40
|
+
onClick: () => a(t.key)
|
|
41
|
+
})) : [];
|
|
42
|
+
return [h, ...y];
|
|
43
|
+
});
|
|
44
|
+
return e ? /* @__PURE__ */ n(
|
|
45
|
+
g,
|
|
46
|
+
{
|
|
47
|
+
label: m,
|
|
48
|
+
placement: "bottom-end",
|
|
49
|
+
minWidth: d,
|
|
50
|
+
items: f,
|
|
51
|
+
trigger: /* @__PURE__ */ n(
|
|
52
|
+
E,
|
|
53
|
+
{
|
|
54
|
+
variant: "surface",
|
|
55
|
+
size: "medium",
|
|
56
|
+
icon: /* @__PURE__ */ n(T, { size: 12 }),
|
|
57
|
+
iconPosition: "end",
|
|
58
|
+
contentAlign: "start",
|
|
59
|
+
style: I,
|
|
60
|
+
"aria-label": `${m}, on ${e.code} ${e.title}`,
|
|
61
|
+
children: /* @__PURE__ */ u("span", { style: v, children: [
|
|
62
|
+
/* @__PURE__ */ n("span", { style: L, children: e.code }),
|
|
63
|
+
/* @__PURE__ */ n("span", { style: W, children: e.title })
|
|
64
|
+
] })
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
) : null;
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
R as GuideJumpMenu,
|
|
72
|
+
R as default
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=GuideJumpMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GuideJumpMenu.js","sources":["../../../src/components/GuideTimeline/GuideJumpMenu.tsx"],"sourcesContent":["import type React from 'react';\nimport { useMemo } from 'react';\nimport ActionMenu from '../ActionMenu';\nimport Button from '../Button';\nimport CaretDownIcon from '../CustomIcons/CaretDownIcon';\nimport type { ActionMenuItem } from '../actionMenuTypes';\nimport {\n type GuideTimelineSection,\n activeIndexOf,\n guideTimelinePositions,\n} from './guideTimelinePositions';\n\nexport interface GuideJumpMenuProps {\n sections: GuideTimelineSection[];\n /** The step the reader is on, as `GuideTimeline`'s `active`. */\n active?: string;\n onSelect: (key: string) => void;\n /** Names the menu. Default: `Jump to step`. */\n label?: string;\n}\n\nconst MENU_WIDTH = 320;\n// As wide as its menu whatever the step's title, so it holds still as the reader scrolls; it\n// gives way only when the header is too narrow for it.\nconst TRIGGER_STYLE: React.CSSProperties = { width: MENU_WIDTH, maxWidth: '100%', minWidth: 0 };\nconst CODE_STYLE: React.CSSProperties = {\n flexShrink: 0,\n fontFamily: 'var(--malachite-font-mono, monospace)',\n};\nconst TITLE_STYLE: React.CSSProperties = {\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n};\nconst TRIGGER_LABEL_STYLE: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n gap: 8,\n minWidth: 0,\n};\n\n/**\n * Jumps to a step of a `GuideTimeline`. Its button shows the step the reader is on; the menu lists\n * every section, with the steps of the current one indented under it. Sections already\n * passed read in the accent colour.\n */\nconst GuideJumpMenu: React.FC<GuideJumpMenuProps> = ({\n sections,\n active,\n onSelect,\n label = 'Jump to step',\n}) => {\n const positions = useMemo(() => guideTimelinePositions(sections), [sections]);\n const current = positions[activeIndexOf(positions, active)];\n const items = sections.flatMap((section, sectionIndex): ActionMenuItem[] => {\n const first = positions.find((position) => position.sectionIndex === sectionIndex);\n const isCurrent = current?.sectionIndex === sectionIndex;\n const heading: ActionMenuItem = {\n key: `section:${section.key}`,\n label: (\n <span style={{ fontWeight: 600 }}>{`${sectionIndex + 1} · ${section.title}`}</span>\n ),\n current: isCurrent && section.steps.length === 0,\n intent: (current?.sectionIndex ?? 0) > sectionIndex ? 'accent' : undefined,\n onClick: () => onSelect(first?.key ?? section.key),\n };\n const steps: ActionMenuItem[] = isCurrent\n ? positions\n .filter(\n (position) =>\n position.sectionIndex === sectionIndex && section.steps.length > 0,\n )\n .map((position) => ({\n key: `step:${position.key}`,\n label: `${position.code} ${position.title}`,\n current: position.key === current?.key,\n indent: true,\n onClick: () => onSelect(position.key),\n }))\n : [];\n\n return [heading, ...steps];\n });\n\n if (!current) {\n return null;\n }\n\n return (\n <ActionMenu\n label={label}\n placement=\"bottom-end\"\n minWidth={MENU_WIDTH}\n items={items}\n trigger={\n <Button\n variant=\"surface\"\n size=\"medium\"\n icon={<CaretDownIcon size={12} />}\n iconPosition=\"end\"\n contentAlign=\"start\"\n style={TRIGGER_STYLE}\n aria-label={`${label}, on ${current.code} ${current.title}`}\n >\n <span style={TRIGGER_LABEL_STYLE}>\n <span style={CODE_STYLE}>{current.code}</span>\n <span style={TITLE_STYLE}>{current.title}</span>\n </span>\n </Button>\n }\n />\n );\n};\n\nexport default GuideJumpMenu;\nexport { GuideJumpMenu };\n"],"names":["MENU_WIDTH","TRIGGER_STYLE","CODE_STYLE","TITLE_STYLE","TRIGGER_LABEL_STYLE","GuideJumpMenu","sections","active","onSelect","label","positions","useMemo","guideTimelinePositions","current","activeIndexOf","items","section","sectionIndex","first","position","isCurrent","heading","jsx","steps","ActionMenu","Button","CaretDownIcon","jsxs"],"mappings":";;;;;;AAqBA,MAAMA,IAAa,KAGbC,IAAqC,EAAE,OAAOD,GAAY,UAAU,QAAQ,UAAU,EAAA,GACtFE,IAAkC;AAAA,EACpC,YAAY;AAAA,EACZ,YA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AAA,EAAS;AAAA,MACnC,QAAQ;AAAA,MACR,SAAS,MAAML,EAASW,EAAS,GAAG;AAAA,IAAA,EACtC,IACN,CAAA;AAEN,WAAO,CAACE,GAAS,GAAGE,CAAK;AAAA,EAC7B,CAAC;AAED,SAAKV,IAKD,gBAAAS;AAAA,IAACE;AAAA,IAAA;AAAA,MACG,OAAAf;AAAA,MACA,WAAU;AAAA,MACV,UAAUT;AAAA,MACV,OAAAe;AAAA,MACA,SACI,gBAAAO;AAAA,QAACG;AAAA,QAAA;AAAA,UACG,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,MAAM,gBAAAH,EAACI,GAAA,EAAc,MAAM,GAAA,CAAI;AAAA,UAC/B,cAAa;AAAA,UACb,cAAa;AAAA,UACb,OAAOzB;AAAA,UACP,cAAY,GAAGQ,CAAK,QAAQI,EAAQ,IAAI,IAAIA,EAAQ,KAAK;AAAA,UAEzD,UAAA,gBAAAc,EAAC,QAAA,EAAK,OAAOvB,GACT,UAAA;AAAA,YAAA,gBAAAkB,EAAC,QAAA,EAAK,OAAOpB,GAAa,UAAAW,EAAQ,MAAK;AAAA,YACvC,gBAAAS,EAAC,QAAA,EAAK,OAAOnB,GAAc,YAAQ,MAAA,CAAM;AAAA,UAAA,EAAA,CAC7C;AAAA,QAAA;AAAA,MAAA;AAAA,IACJ;AAAA,EAAA,IAvBD;AA2Bf;"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as m } from "react";
|
|
3
|
+
import { guideTimelinePositions as u, activeIndexOf as f } from "./guideTimelinePositions.js";
|
|
4
|
+
const g = {
|
|
5
|
+
display: "flex",
|
|
6
|
+
justifyContent: "space-between",
|
|
7
|
+
gap: 12,
|
|
8
|
+
fontSize: 12,
|
|
9
|
+
lineHeight: "16px",
|
|
10
|
+
color: "var(--malachite-text-secondary, rgb(123, 123, 123))"
|
|
11
|
+
}, x = {
|
|
12
|
+
minWidth: 0,
|
|
13
|
+
overflow: "hidden",
|
|
14
|
+
textOverflow: "ellipsis",
|
|
15
|
+
whiteSpace: "nowrap"
|
|
16
|
+
}, v = {
|
|
17
|
+
fontFamily: "var(--malachite-font-mono, monospace)",
|
|
18
|
+
color: "var(--malachite-text-primary, rgb(10, 10, 10))"
|
|
19
|
+
}, y = { display: "flex", gap: 3, height: 6 }, b = {
|
|
20
|
+
position: "relative",
|
|
21
|
+
overflow: "hidden",
|
|
22
|
+
borderRadius: 2,
|
|
23
|
+
backgroundColor: "var(--malachite-card-background, rgb(255, 255, 255))"
|
|
24
|
+
}, S = {
|
|
25
|
+
position: "absolute",
|
|
26
|
+
inset: "0 auto 0 0",
|
|
27
|
+
backgroundColor: "var(--malachite-text-success)"
|
|
28
|
+
}, T = ({
|
|
29
|
+
sections: a,
|
|
30
|
+
active: c,
|
|
31
|
+
"aria-label": d = "Progress"
|
|
32
|
+
}) => {
|
|
33
|
+
const e = m(() => u(a), [a]), i = f(e, c), o = e[i];
|
|
34
|
+
return o ? /* @__PURE__ */ s("div", { style: { display: "flex", flexDirection: "column", gap: 8, minWidth: 0 }, children: [
|
|
35
|
+
/* @__PURE__ */ t("div", { style: g, children: /* @__PURE__ */ s("span", { style: x, children: [
|
|
36
|
+
"Step ",
|
|
37
|
+
/* @__PURE__ */ t("span", { style: v, children: o.code }),
|
|
38
|
+
" · ",
|
|
39
|
+
o.title
|
|
40
|
+
] }) }),
|
|
41
|
+
/* @__PURE__ */ t(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
role: "progressbar",
|
|
45
|
+
"aria-label": d,
|
|
46
|
+
"aria-valuemin": 0,
|
|
47
|
+
"aria-valuemax": e.length,
|
|
48
|
+
"aria-valuenow": i + 1,
|
|
49
|
+
"aria-valuetext": `Step ${i + 1} of ${e.length}`,
|
|
50
|
+
style: y,
|
|
51
|
+
children: a.map((p, n) => {
|
|
52
|
+
const l = e.filter(
|
|
53
|
+
(r) => r.sectionIndex === n
|
|
54
|
+
), h = e.slice(0, i + 1).filter((r) => r.sectionIndex === n).length;
|
|
55
|
+
return /* @__PURE__ */ t(
|
|
56
|
+
"span",
|
|
57
|
+
{
|
|
58
|
+
"aria-hidden": "true",
|
|
59
|
+
style: { ...b, flex: l.length },
|
|
60
|
+
children: /* @__PURE__ */ t(
|
|
61
|
+
"span",
|
|
62
|
+
{
|
|
63
|
+
style: {
|
|
64
|
+
...S,
|
|
65
|
+
width: `${h / l.length * 100}%`
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
},
|
|
70
|
+
p.key
|
|
71
|
+
);
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
] }) : null;
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
T as GuideProgress,
|
|
79
|
+
T as default
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=GuideProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GuideProgress.js","sources":["../../../src/components/GuideTimeline/GuideProgress.tsx"],"sourcesContent":["import type React from 'react';\nimport { useMemo } from 'react';\nimport {\n type GuideTimelineSection,\n activeIndexOf,\n guideTimelinePositions,\n} from './guideTimelinePositions';\n\nexport interface GuideProgressProps {\n sections: GuideTimelineSection[];\n /** The step the reader is on, as `GuideTimeline`'s `active`. */\n active?: string;\n /** Names the bar. Default: `Progress`. */\n 'aria-label'?: string;\n}\n\nconst ROW_STYLE: React.CSSProperties = {\n display: 'flex',\n justifyContent: 'space-between',\n gap: 12,\n fontSize: 12,\n lineHeight: '16px',\n color: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n};\nconst WHERE_STYLE: React.CSSProperties = {\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n};\nconst CODE_STYLE: React.CSSProperties = {\n fontFamily: 'var(--malachite-font-mono, monospace)',\n color: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n};\n\nconst BAR_STYLE: React.CSSProperties = { display: 'flex', gap: 3, height: 6 };\n// The warm card's own tone is the footer's, so the track is white to read against it.\nconst SEGMENT_STYLE: React.CSSProperties = {\n position: 'relative',\n overflow: 'hidden',\n borderRadius: 2,\n backgroundColor: 'var(--malachite-card-background, rgb(255, 255, 255))',\n};\nconst FILL_STYLE: React.CSSProperties = {\n position: 'absolute',\n inset: '0 auto 0 0',\n backgroundColor: 'var(--malachite-text-success)',\n};\n\n/**\n * Where the reader is in a `GuideTimeline`: `Step 2.2 · title`, and a bar cut into one\n * segment per section, each as long as its steps and filling as they are passed. For a footer.\n */\nconst GuideProgress: React.FC<GuideProgressProps> = ({\n sections,\n active,\n 'aria-label': ariaLabel = 'Progress',\n}) => {\n const positions = useMemo(() => guideTimelinePositions(sections), [sections]);\n const index = activeIndexOf(positions, active);\n const current = positions[index];\n\n if (!current) {\n return null;\n }\n\n return (\n <div style={{ display: 'flex', flexDirection: 'column', gap: 8, minWidth: 0 }}>\n <div style={ROW_STYLE}>\n <span style={WHERE_STYLE}>\n Step <span style={CODE_STYLE}>{current.code}</span> · {current.title}\n </span>\n </div>\n <div\n role=\"progressbar\"\n aria-label={ariaLabel}\n aria-valuemin={0}\n aria-valuemax={positions.length}\n aria-valuenow={index + 1}\n aria-valuetext={`Step ${index + 1} of ${positions.length}`}\n style={BAR_STYLE}\n >\n {sections.map((section, sectionIndex) => {\n const inSection = positions.filter(\n (position) => position.sectionIndex === sectionIndex,\n );\n const passed = positions\n .slice(0, index + 1)\n .filter((position) => position.sectionIndex === sectionIndex).length;\n\n return (\n <span\n key={section.key}\n aria-hidden=\"true\"\n style={{ ...SEGMENT_STYLE, flex: inSection.length }}\n >\n <span\n style={{\n ...FILL_STYLE,\n width: `${(passed / inSection.length) * 100}%`,\n }}\n />\n </span>\n );\n })}\n </div>\n </div>\n );\n};\n\nexport default GuideProgress;\nexport { GuideProgress };\n"],"names":["ROW_STYLE","WHERE_STYLE","CODE_STYLE","BAR_STYLE","SEGMENT_STYLE","FILL_STYLE","GuideProgress","sections","active","ariaLabel","positions","useMemo","guideTimelinePositions","index","activeIndexOf","current","jsxs","jsx","section","sectionIndex","inSection","position","passed"],"mappings":";;;AAgBA,MAAMA,IAAiC;AAAA,EACnC,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,KAAK;AAAA,EACL,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,OAAO;AACX,GACMC,IAAmC;AAAA,EACrC,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AAChB,GACMC,IAAkC;AAAA,EACpC,YAAY;AAAA,EACZ,OAAO;AACX,GAEMC,IAAiC,EAAE,SAAS,QAAQ,KAAK,GAAG,QAAQ,EAAA,GAEpEC,IAAqC;AAAA,EACvC,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,iBAAiB;AACrB,GACMC,IAAkC;AAAA,EACpC,UAAU;AAAA,EACV,OAAO;AAAA,EACP,iBAAiB;AACrB,GAMMC,IAA8C,CAAC;AAAA,EACjD,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,cAAcC,IAAY;AAC9B,MAAM;AACF,QAAMC,IAAYC,EAAQ,MAAMC,EAAuBL,CAAQ,GAAG,CAACA,CAAQ,CAAC,GACtEM,IAAQC,EAAcJ,GAAWF,CAAM,GACvCO,IAAUL,EAAUG,CAAK;AAE/B,SAAKE,IAKD,gBAAAC,EAAC,OAAA,EAAI,OAAO,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,GAAG,UAAU,EAAA,GACtE,UAAA;AAAA,IAAA,gBAAAC,EAAC,SAAI,OAAOjB,GACR,UAAA,gBAAAgB,EAAC,QAAA,EAAK,OAAOf,GAAa,UAAA;AAAA,MAAA;AAAA,MACjB,gBAAAgB,EAAC,QAAA,EAAK,OAAOf,GAAa,YAAQ,MAAK;AAAA,MAAO;AAAA,MAAIa,EAAQ;AAAA,IAAA,EAAA,CACnE,EAAA,CACJ;AAAA,IACA,gBAAAE;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,MAAK;AAAA,QACL,cAAYR;AAAA,QACZ,iBAAe;AAAA,QACf,iBAAeC,EAAU;AAAA,QACzB,iBAAeG,IAAQ;AAAA,QACvB,kBAAgB,QAAQA,IAAQ,CAAC,OAAOH,EAAU,MAAM;AAAA,QACxD,OAAOP;AAAA,QAEN,UAAAI,EAAS,IAAI,CAACW,GAASC,MAAiB;AACrC,gBAAMC,IAAYV,EAAU;AAAA,YACxB,CAACW,MAAaA,EAAS,iBAAiBF;AAAA,UAAA,GAEtCG,IAASZ,EACV,MAAM,GAAGG,IAAQ,CAAC,EAClB,OAAO,CAACQ,MAAaA,EAAS,iBAAiBF,CAAY,EAAE;AAElE,iBACI,gBAAAF;AAAA,YAAC;AAAA,YAAA;AAAA,cAEG,eAAY;AAAA,cACZ,OAAO,EAAE,GAAGb,GAAe,MAAMgB,EAAU,OAAA;AAAA,cAE3C,UAAA,gBAAAH;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,OAAO;AAAA,oBACH,GAAGZ;AAAA,oBACH,OAAO,GAAIiB,IAASF,EAAU,SAAU,GAAG;AAAA,kBAAA;AAAA,gBAC/C;AAAA,cAAA;AAAA,YACJ;AAAA,YATKF,EAAQ;AAAA,UAAA;AAAA,QAYzB,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA,EACL,GACJ,IA3CO;AA6Cf;"}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { jsxs as a, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as S, useEffect as k, useMemo as N } from "react";
|
|
3
|
+
import B from "../CustomIcons/CheckmarkIcon.js";
|
|
4
|
+
import { guideTimelinePositions as Y, activeIndexOf as q } from "./guideTimelinePositions.js";
|
|
5
|
+
const g = "data-timeline-step", G = 40, J = 700, R = "var(--malachite-card-warm-background, rgb(244, 242, 240))", w = "var(--malachite-text-primary, rgb(10, 10, 10))", _ = (e) => ({
|
|
6
|
+
backgroundColor: "var(--malachite-card-border, rgb(224, 222, 220))",
|
|
7
|
+
backgroundImage: `linear-gradient(color-mix(in srgb, ${R}, ${w} ${e}%), color-mix(in srgb, ${R}, ${w} ${e}%))`
|
|
8
|
+
}), O = _(14), M = "var(--malachite-accent-foreground, rgb(2, 122, 66))", K = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, j = (e) => e === null ? null : /(auto|scroll)/.test(getComputedStyle(e).overflowY) ? e : j(e.parentElement), z = (e) => Array.from(e.querySelectorAll(`[${g}]`)), U = (e, n, c) => ({
|
|
9
|
+
flexShrink: 0,
|
|
10
|
+
width: n,
|
|
11
|
+
height: n,
|
|
12
|
+
boxSizing: "border-box",
|
|
13
|
+
borderRadius: c,
|
|
14
|
+
display: "inline-flex",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
justifyContent: "center",
|
|
17
|
+
fontSize: n > 24 ? 13 : 11,
|
|
18
|
+
fontWeight: 600,
|
|
19
|
+
lineHeight: 1,
|
|
20
|
+
transition: "background-color 200ms, color 200ms",
|
|
21
|
+
// Done is solid, so the rail never shows through it; the current one is outlined in the accent.
|
|
22
|
+
...e === "done" ? { backgroundColor: M, color: "var(--malachite-card-background, rgb(255, 255, 255))" } : e === "current" ? {
|
|
23
|
+
backgroundColor: "var(--malachite-card-background, rgb(255, 255, 255))",
|
|
24
|
+
color: M,
|
|
25
|
+
boxShadow: `inset 0 0 0 1.5px ${M}`
|
|
26
|
+
} : {
|
|
27
|
+
backgroundColor: "var(--malachite-card-background, rgb(255, 255, 255))",
|
|
28
|
+
color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
29
|
+
boxShadow: "inset 0 0 0 1px var(--malachite-card-border, rgb(224, 222, 220))"
|
|
30
|
+
}
|
|
31
|
+
}), A = ({ state: e, label: n, size: c, radius: h, style: T }) => /* @__PURE__ */ o("span", { "aria-hidden": "true", style: { ...U(e, c, h), ...T }, children: e === "done" ? /* @__PURE__ */ o(B, { size: c > 24 ? 14 : 12 }) : n }), H = (e, n) => e === n ? "current" : e < n ? "done" : "todo", P = { position: "absolute", left: 33, width: 2, ...O }, ee = ({
|
|
32
|
+
sections: e,
|
|
33
|
+
active: n,
|
|
34
|
+
onActiveChange: c,
|
|
35
|
+
end: h,
|
|
36
|
+
"aria-label": T
|
|
37
|
+
}) => {
|
|
38
|
+
var W;
|
|
39
|
+
const E = S(null), m = S(n), s = S(null), f = S(c);
|
|
40
|
+
k(() => {
|
|
41
|
+
f.current = c;
|
|
42
|
+
});
|
|
43
|
+
const b = N(() => Y(e), [e]), C = q(b, n), F = ((W = b[C]) == null ? void 0 : W.sectionIndex) ?? 0;
|
|
44
|
+
return k(() => {
|
|
45
|
+
const r = E.current, t = j((r == null ? void 0 : r.parentElement) ?? null);
|
|
46
|
+
if (!r || !t)
|
|
47
|
+
return;
|
|
48
|
+
const d = () => {
|
|
49
|
+
var p;
|
|
50
|
+
if (s.current !== null)
|
|
51
|
+
return;
|
|
52
|
+
const l = z(r), y = t.getBoundingClientRect().top + G, $ = t.scrollTop + t.clientHeight >= t.scrollHeight - 4, x = l.filter((v) => v.getBoundingClientRect().top <= y), i = $ ? l[l.length - 1] : x[x.length - 1] ?? l[0], u = (i == null ? void 0 : i.getAttribute(g)) ?? void 0;
|
|
53
|
+
u !== void 0 && u !== m.current && (m.current = u, (p = f.current) == null || p.call(f, u));
|
|
54
|
+
};
|
|
55
|
+
return t.addEventListener("scroll", d, { passive: !0 }), () => t.removeEventListener("scroll", d);
|
|
56
|
+
}, []), k(() => {
|
|
57
|
+
var d;
|
|
58
|
+
const r = E.current;
|
|
59
|
+
if (n === void 0 || n === m.current || !r)
|
|
60
|
+
return;
|
|
61
|
+
m.current = n;
|
|
62
|
+
const t = z(r).find((l) => l.getAttribute(g) === n);
|
|
63
|
+
t && (s.current !== null && clearTimeout(s.current), s.current = setTimeout(() => {
|
|
64
|
+
s.current = null;
|
|
65
|
+
}, J), (d = t.scrollIntoView) == null || d.call(t, {
|
|
66
|
+
behavior: K() ? "auto" : "smooth",
|
|
67
|
+
block: "start"
|
|
68
|
+
}));
|
|
69
|
+
}, [n]), k(
|
|
70
|
+
() => () => {
|
|
71
|
+
s.current !== null && clearTimeout(s.current);
|
|
72
|
+
},
|
|
73
|
+
[]
|
|
74
|
+
), // It ends on `end` with the usual 20px under it: reaching the bottom makes the last step
|
|
75
|
+
// current, so there is no need to leave room to scroll it to the top.
|
|
76
|
+
/* @__PURE__ */ a("div", { ref: E, "aria-label": T, style: { padding: "0 20px 20px" }, children: [
|
|
77
|
+
e.map((r, t) => {
|
|
78
|
+
const d = t === 0, l = t === e.length - 1, y = r.steps.length > 0, $ = H(t, F), x = {
|
|
79
|
+
position: "relative",
|
|
80
|
+
marginLeft: 13,
|
|
81
|
+
padding: `20px 0 ${l ? 16 : 48}px 29px`,
|
|
82
|
+
scrollMarginTop: 16
|
|
83
|
+
};
|
|
84
|
+
return /* @__PURE__ */ a(
|
|
85
|
+
"section",
|
|
86
|
+
{
|
|
87
|
+
"aria-label": `Section ${t + 1}: ${r.title}`,
|
|
88
|
+
style: { position: "relative" },
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ a(
|
|
91
|
+
"div",
|
|
92
|
+
{
|
|
93
|
+
style: {
|
|
94
|
+
position: "relative",
|
|
95
|
+
margin: "0 -20px",
|
|
96
|
+
padding: "10px 10px 0",
|
|
97
|
+
background: R
|
|
98
|
+
},
|
|
99
|
+
children: [
|
|
100
|
+
d ? null : /* @__PURE__ */ o(
|
|
101
|
+
"span",
|
|
102
|
+
{
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
style: { ...P, top: 0, height: 28 }
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ o(
|
|
108
|
+
"span",
|
|
109
|
+
{
|
|
110
|
+
"aria-hidden": "true",
|
|
111
|
+
style: { ...P, bottom: 0, height: 16 }
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ a(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
style: {
|
|
118
|
+
position: "relative",
|
|
119
|
+
padding: "14px 10px 12px",
|
|
120
|
+
borderRadius: 12,
|
|
121
|
+
display: "flex",
|
|
122
|
+
alignItems: "center",
|
|
123
|
+
gap: 12,
|
|
124
|
+
..._(8)
|
|
125
|
+
},
|
|
126
|
+
children: [
|
|
127
|
+
/* @__PURE__ */ o(
|
|
128
|
+
A,
|
|
129
|
+
{
|
|
130
|
+
state: $,
|
|
131
|
+
label: String(t + 1),
|
|
132
|
+
size: 28,
|
|
133
|
+
radius: 9,
|
|
134
|
+
style: { position: "relative" }
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ a(
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
style: {
|
|
141
|
+
minWidth: 0,
|
|
142
|
+
display: "flex",
|
|
143
|
+
flexDirection: "column",
|
|
144
|
+
gap: 2
|
|
145
|
+
},
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ o(
|
|
148
|
+
"span",
|
|
149
|
+
{
|
|
150
|
+
style: {
|
|
151
|
+
fontSize: 11,
|
|
152
|
+
fontWeight: 500,
|
|
153
|
+
color: "var(--malachite-text-secondary, rgb(76, 75, 75))"
|
|
154
|
+
},
|
|
155
|
+
children: `Section ${t + 1} of ${e.length}`
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
/* @__PURE__ */ o(
|
|
159
|
+
"h2",
|
|
160
|
+
{
|
|
161
|
+
style: {
|
|
162
|
+
margin: 0,
|
|
163
|
+
fontSize: 15,
|
|
164
|
+
lineHeight: "20px",
|
|
165
|
+
fontWeight: 600,
|
|
166
|
+
color: w,
|
|
167
|
+
whiteSpace: "nowrap",
|
|
168
|
+
overflow: "hidden",
|
|
169
|
+
textOverflow: "ellipsis"
|
|
170
|
+
},
|
|
171
|
+
children: r.title
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
/* @__PURE__ */ a("div", { style: x, ...y ? {} : { [g]: r.key }, children: [
|
|
184
|
+
/* @__PURE__ */ o(
|
|
185
|
+
"span",
|
|
186
|
+
{
|
|
187
|
+
"aria-hidden": "true",
|
|
188
|
+
style: {
|
|
189
|
+
position: "absolute",
|
|
190
|
+
left: 0,
|
|
191
|
+
top: 0,
|
|
192
|
+
bottom: 0,
|
|
193
|
+
width: 2,
|
|
194
|
+
...O
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
r.description ? /* @__PURE__ */ o(
|
|
199
|
+
"div",
|
|
200
|
+
{
|
|
201
|
+
style: {
|
|
202
|
+
fontSize: 13,
|
|
203
|
+
lineHeight: "20px",
|
|
204
|
+
color: "var(--malachite-text-secondary, rgb(76, 75, 75))"
|
|
205
|
+
},
|
|
206
|
+
children: r.description
|
|
207
|
+
}
|
|
208
|
+
) : null,
|
|
209
|
+
y ? /* @__PURE__ */ o(
|
|
210
|
+
"ol",
|
|
211
|
+
{
|
|
212
|
+
style: {
|
|
213
|
+
margin: r.description ? "20px 0 0" : 0,
|
|
214
|
+
padding: 0,
|
|
215
|
+
listStyle: "none",
|
|
216
|
+
display: "flex",
|
|
217
|
+
flexDirection: "column",
|
|
218
|
+
// 8px more than within a step, so a screenshot reads as its own step's.
|
|
219
|
+
gap: 30
|
|
220
|
+
},
|
|
221
|
+
children: r.steps.map((i, u) => {
|
|
222
|
+
var L;
|
|
223
|
+
const p = b.findIndex(
|
|
224
|
+
(D) => D.key === i.key
|
|
225
|
+
), v = H(p, C), I = ((L = b[p]) == null ? void 0 : L.code) ?? "";
|
|
226
|
+
return /* @__PURE__ */ a(
|
|
227
|
+
"li",
|
|
228
|
+
{
|
|
229
|
+
[g]: i.key,
|
|
230
|
+
"aria-current": v === "current" ? "step" : void 0,
|
|
231
|
+
style: {
|
|
232
|
+
position: "relative",
|
|
233
|
+
scrollMarginTop: 16,
|
|
234
|
+
display: "flex",
|
|
235
|
+
flexDirection: "column",
|
|
236
|
+
gap: 10,
|
|
237
|
+
minWidth: 0
|
|
238
|
+
},
|
|
239
|
+
children: [
|
|
240
|
+
/* @__PURE__ */ o(
|
|
241
|
+
A,
|
|
242
|
+
{
|
|
243
|
+
state: v,
|
|
244
|
+
label: I.split(".")[1] ?? String(u + 1),
|
|
245
|
+
size: 24,
|
|
246
|
+
radius: 8,
|
|
247
|
+
style: {
|
|
248
|
+
position: "absolute",
|
|
249
|
+
left: -40,
|
|
250
|
+
top: -1
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
/* @__PURE__ */ a(
|
|
255
|
+
"div",
|
|
256
|
+
{
|
|
257
|
+
style: {
|
|
258
|
+
display: "flex",
|
|
259
|
+
alignItems: "baseline",
|
|
260
|
+
gap: 8,
|
|
261
|
+
minHeight: 22
|
|
262
|
+
},
|
|
263
|
+
children: [
|
|
264
|
+
/* @__PURE__ */ o(
|
|
265
|
+
"span",
|
|
266
|
+
{
|
|
267
|
+
style: {
|
|
268
|
+
fontFamily: "var(--malachite-font-mono, monospace)",
|
|
269
|
+
fontSize: 12,
|
|
270
|
+
fontWeight: 500,
|
|
271
|
+
color: "var(--malachite-text-secondary, rgb(123, 123, 123))"
|
|
272
|
+
},
|
|
273
|
+
children: I
|
|
274
|
+
}
|
|
275
|
+
),
|
|
276
|
+
/* @__PURE__ */ o(
|
|
277
|
+
"h3",
|
|
278
|
+
{
|
|
279
|
+
style: {
|
|
280
|
+
margin: 0,
|
|
281
|
+
fontSize: 15,
|
|
282
|
+
lineHeight: "20px",
|
|
283
|
+
fontWeight: 600,
|
|
284
|
+
color: w
|
|
285
|
+
},
|
|
286
|
+
children: i.title
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
),
|
|
292
|
+
i.children
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
i.key
|
|
296
|
+
);
|
|
297
|
+
})
|
|
298
|
+
}
|
|
299
|
+
) : null
|
|
300
|
+
] })
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
r.key
|
|
304
|
+
);
|
|
305
|
+
}),
|
|
306
|
+
h ? /* @__PURE__ */ o("div", { style: { marginTop: 8 }, children: h }) : null
|
|
307
|
+
] });
|
|
308
|
+
};
|
|
309
|
+
export {
|
|
310
|
+
ee as GuideTimeline,
|
|
311
|
+
ee as default
|
|
312
|
+
};
|
|
313
|
+
//# sourceMappingURL=GuideTimeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GuideTimeline.js","sources":["../../../src/components/GuideTimeline/GuideTimeline.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from 'react';\nimport CheckmarkIcon from '../CustomIcons/CheckmarkIcon';\nimport {\n type GuideTimelineSection,\n activeIndexOf,\n guideTimelinePositions,\n} from './guideTimelinePositions';\n\nexport interface GuideTimelineProps {\n sections: GuideTimelineSection[];\n /** The step in view. Setting it to a step the reader is not on scrolls there. */\n active?: string;\n /** Called as the reader scrolls another step to the top, so a menu or progress bar can follow. */\n onActiveChange?: (key: string) => void;\n /** After the last section, such as what to do once the steps are done. */\n end?: React.ReactNode;\n 'aria-label'?: string;\n}\n\ntype MarkState = 'done' | 'current' | 'todo';\n\nconst STEP_ATTR = 'data-timeline-step';\n// A step counts as reached once its top is near the top of the scroller.\nconst SPY_OFFSET_PX = 40;\n// A jump scrolls smoothly past the steps in between; they are not reported while it does.\nconst JUMP_SETTLE_MS = 700;\n\nconst WARM = 'var(--malachite-card-warm-background, rgb(244, 242, 240))';\nconst INK = 'var(--malachite-text-primary, rgb(10, 10, 10))';\n// The heading band and the rail are the warm ground darkened, so they follow it in every theme.\n// `backgroundImage` carries the mix over a plain colour, for browsers without `color-mix()`.\nconst darkerWarm = (percent: number): React.CSSProperties => ({\n backgroundColor: 'var(--malachite-card-border, rgb(224, 222, 220))',\n backgroundImage: `linear-gradient(color-mix(in srgb, ${WARM}, ${INK} ${percent}%), color-mix(in srgb, ${WARM}, ${INK} ${percent}%))`,\n});\nconst RAIL = darkerWarm(14);\nconst ACCENT = 'var(--malachite-accent-foreground, rgb(2, 122, 66))';\n\nconst prefersReducedMotion = (): boolean =>\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n\nconst scrollParentOf = (node: HTMLElement | null): HTMLElement | null =>\n node === null\n ? null\n : /(auto|scroll)/.test(getComputedStyle(node).overflowY)\n ? node\n : scrollParentOf(node.parentElement);\n\nconst stepElements = (root: HTMLElement): HTMLElement[] =>\n Array.from(root.querySelectorAll<HTMLElement>(`[${STEP_ATTR}]`));\n\nconst markStyle = (state: MarkState, size: number, radius: number): React.CSSProperties => ({\n flexShrink: 0,\n width: size,\n height: size,\n boxSizing: 'border-box',\n borderRadius: radius,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n fontSize: size > 24 ? 13 : 11,\n fontWeight: 600,\n lineHeight: 1,\n transition: 'background-color 200ms, color 200ms',\n // Done is solid, so the rail never shows through it; the current one is outlined in the accent.\n ...(state === 'done'\n ? { backgroundColor: ACCENT, color: 'var(--malachite-card-background, rgb(255, 255, 255))' }\n : state === 'current'\n ? {\n backgroundColor: 'var(--malachite-card-background, rgb(255, 255, 255))',\n color: ACCENT,\n boxShadow: `inset 0 0 0 1.5px ${ACCENT}`,\n }\n : {\n backgroundColor: 'var(--malachite-card-background, rgb(255, 255, 255))',\n color: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n boxShadow: 'inset 0 0 0 1px var(--malachite-card-border, rgb(224, 222, 220))',\n }),\n});\n\nconst Mark: React.FC<{\n state: MarkState;\n label: string;\n size: number;\n radius: number;\n style?: React.CSSProperties;\n}> = ({ state, label, size, radius, style }) => (\n <span aria-hidden=\"true\" style={{ ...markStyle(state, size, radius), ...style }}>\n {state === 'done' ? <CheckmarkIcon size={size > 24 ? 14 : 12} /> : label}\n </span>\n);\n\nconst stateOf = (index: number, activeIndex: number): MarkState =>\n index === activeIndex ? 'current' : index < activeIndex ? 'done' : 'todo';\n\n// Measured from the band the heading sticks in, which runs the column's full width.\nconst RAIL_LINE: React.CSSProperties = { position: 'absolute', left: 33, width: 2, ...RAIL };\n\n/**\n * A guide laid out as one scrolling column: each section a heading with a numbered mark, its\n * steps strung on a rail below it, coded `1.1`, `1.2` so a step names its section without the\n * heading in view. Marks before the\n * `active` step show a check. Place it in a scrolling container with no padding of its own,\n * such as a SidePanel aside with `bodyPadding: false`; it reports the step scrolled to the\n * top through `onActiveChange`, and scrolls to a step when `active` is set to it.\n */\nconst GuideTimeline: React.FC<GuideTimelineProps> = ({\n sections,\n active,\n onActiveChange,\n end,\n 'aria-label': ariaLabel,\n}) => {\n const rootRef = useRef<HTMLDivElement | null>(null);\n const reported = useRef<string | undefined>(active);\n const jumping = useRef<ReturnType<typeof setTimeout> | null>(null);\n const onActiveChangeRef = useRef(onActiveChange);\n useEffect(() => {\n onActiveChangeRef.current = onActiveChange;\n });\n const positions = useMemo(() => guideTimelinePositions(sections), [sections]);\n const activeIndex = activeIndexOf(positions, active);\n const activeSection = positions[activeIndex]?.sectionIndex ?? 0;\n\n useEffect(() => {\n const root = rootRef.current;\n const scroller = scrollParentOf(root?.parentElement ?? null);\n if (!root || !scroller) {\n return undefined;\n }\n const onScroll = () => {\n if (jumping.current !== null) {\n return;\n }\n const steps = stepElements(root);\n const line = scroller.getBoundingClientRect().top + SPY_OFFSET_PX;\n const atEnd = scroller.scrollTop + scroller.clientHeight >= scroller.scrollHeight - 4;\n const passed = steps.filter((step) => step.getBoundingClientRect().top <= line);\n const pick = atEnd ? steps[steps.length - 1] : (passed[passed.length - 1] ?? steps[0]);\n const key = pick?.getAttribute(STEP_ATTR) ?? undefined;\n if (key !== undefined && key !== reported.current) {\n reported.current = key;\n onActiveChangeRef.current?.(key);\n }\n };\n scroller.addEventListener('scroll', onScroll, { passive: true });\n return () => scroller.removeEventListener('scroll', onScroll);\n }, []);\n\n useEffect(() => {\n const root = rootRef.current;\n if (active === undefined || active === reported.current || !root) {\n return;\n }\n reported.current = active;\n const target = stepElements(root).find((step) => step.getAttribute(STEP_ATTR) === active);\n if (!target) {\n return;\n }\n if (jumping.current !== null) {\n clearTimeout(jumping.current);\n }\n jumping.current = setTimeout(() => {\n jumping.current = null;\n }, JUMP_SETTLE_MS);\n target.scrollIntoView?.({\n behavior: prefersReducedMotion() ? 'auto' : 'smooth',\n block: 'start',\n });\n }, [active]);\n\n useEffect(\n () => () => {\n if (jumping.current !== null) {\n clearTimeout(jumping.current);\n }\n },\n [],\n );\n\n return (\n // It ends on `end` with the usual 20px under it: reaching the bottom makes the last step\n // current, so there is no need to leave room to scroll it to the top.\n <div ref={rootRef} aria-label={ariaLabel} style={{ padding: '0 20px 20px' }}>\n {sections.map((section, sectionIndex) => {\n const isFirst = sectionIndex === 0;\n const isLast = sectionIndex === sections.length - 1;\n const hasSteps = section.steps.length > 0;\n const sectionState = stateOf(sectionIndex, activeSection);\n const railStyle: React.CSSProperties = {\n position: 'relative',\n marginLeft: 13,\n padding: `20px 0 ${isLast ? 16 : 48}px 29px`,\n scrollMarginTop: 16,\n };\n\n return (\n <section\n key={section.key}\n aria-label={`Section ${sectionIndex + 1}: ${section.title}`}\n style={{ position: 'relative' }}\n >\n {/* It scrolls with its steps: each step's code names its section. */}\n <div\n style={{\n position: 'relative',\n margin: '0 -20px',\n padding: '10px 10px 0',\n background: WARM,\n }}\n >\n {isFirst ? null : (\n <span\n aria-hidden=\"true\"\n style={{ ...RAIL_LINE, top: 0, height: 28 }}\n />\n )}\n <span\n aria-hidden=\"true\"\n style={{ ...RAIL_LINE, bottom: 0, height: 16 }}\n />\n <div\n style={{\n position: 'relative',\n padding: '14px 10px 12px',\n borderRadius: 12,\n display: 'flex',\n alignItems: 'center',\n gap: 12,\n ...darkerWarm(8),\n }}\n >\n <Mark\n state={sectionState}\n label={String(sectionIndex + 1)}\n size={28}\n radius={9}\n style={{ position: 'relative' }}\n />\n <div\n style={{\n minWidth: 0,\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n }}\n >\n <span\n style={{\n fontSize: 11,\n fontWeight: 500,\n color: 'var(--malachite-text-secondary, rgb(76, 75, 75))',\n }}\n >\n {`Section ${sectionIndex + 1} of ${sections.length}`}\n </span>\n <h2\n style={{\n margin: 0,\n fontSize: 15,\n lineHeight: '20px',\n fontWeight: 600,\n color: INK,\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {section.title}\n </h2>\n </div>\n </div>\n </div>\n <div style={railStyle} {...(hasSteps ? {} : { [STEP_ATTR]: section.key })}>\n <span\n aria-hidden=\"true\"\n style={{\n position: 'absolute',\n left: 0,\n top: 0,\n bottom: 0,\n width: 2,\n ...RAIL,\n }}\n />\n {section.description ? (\n <div\n style={{\n fontSize: 13,\n lineHeight: '20px',\n color: 'var(--malachite-text-secondary, rgb(76, 75, 75))',\n }}\n >\n {section.description}\n </div>\n ) : null}\n {hasSteps ? (\n <ol\n style={{\n margin: section.description ? '20px 0 0' : 0,\n padding: 0,\n listStyle: 'none',\n display: 'flex',\n flexDirection: 'column',\n // 8px more than within a step, so a screenshot reads as its own step's.\n gap: 30,\n }}\n >\n {section.steps.map((step, stepIndex) => {\n const index = positions.findIndex(\n (position) => position.key === step.key,\n );\n const state = stateOf(index, activeIndex);\n const code = positions[index]?.code ?? '';\n\n return (\n <li\n key={step.key}\n {...{ [STEP_ATTR]: step.key }}\n aria-current={\n state === 'current' ? 'step' : undefined\n }\n style={{\n position: 'relative',\n scrollMarginTop: 16,\n display: 'flex',\n flexDirection: 'column',\n gap: 10,\n minWidth: 0,\n }}\n >\n <Mark\n state={state}\n label={\n code.split('.')[1] ?? String(stepIndex + 1)\n }\n size={24}\n radius={8}\n style={{\n position: 'absolute',\n left: -40,\n top: -1,\n }}\n />\n <div\n style={{\n display: 'flex',\n alignItems: 'baseline',\n gap: 8,\n minHeight: 22,\n }}\n >\n <span\n style={{\n fontFamily:\n 'var(--malachite-font-mono, monospace)',\n fontSize: 12,\n fontWeight: 500,\n color: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n }}\n >\n {code}\n </span>\n <h3\n style={{\n margin: 0,\n fontSize: 15,\n lineHeight: '20px',\n fontWeight: 600,\n color: INK,\n }}\n >\n {step.title}\n </h3>\n </div>\n {step.children}\n </li>\n );\n })}\n </ol>\n ) : null}\n </div>\n </section>\n );\n })}\n {end ? <div style={{ marginTop: 8 }}>{end}</div> : null}\n </div>\n );\n};\n\nexport default GuideTimeline;\nexport { GuideTimeline };\n"],"names":["STEP_ATTR","SPY_OFFSET_PX","JUMP_SETTLE_MS","WARM","INK","darkerWarm","percent","RAIL","ACCENT","prefersReducedMotion","scrollParentOf","node","stepElements","root","markStyle","state","size","radius","Mark","label","style","jsx","CheckmarkIcon","stateOf","index","activeIndex","RAIL_LINE","GuideTimeline","sections","active","onActiveChange","end","ariaLabel","rootRef","useRef","reported","jumping","onActiveChangeRef","useEffect","positions","useMemo","guideTimelinePositions","activeIndexOf","activeSection","_a","scroller","onScroll","steps","line","atEnd","passed","step","pick","key","target","jsxs","section","sectionIndex","isFirst","isLast","hasSteps","sectionState","railStyle","stepIndex","position","code"],"mappings":";;;;AAqBA,MAAMA,IAAY,sBAEZC,IAAgB,IAEhBC,IAAiB,KAEjBC,IAAO,6DACPC,IAAM,kDAGNC,IAAa,CAACC,OAA0C;AAAA,EAC1D,iBAAiB;AAAA,EACjB,iBAAiB,sCAAsCH,CAAI,KAAKC,CAAG,IAAIE,CAAO,0BAA0BH,CAAI,KAAKC,CAAG,IAAIE,CAAO;AACnI,IACMC,IAAOF,EAAW,EAAE,GACpBG,IAAS,uDAETC,IAAuB,MACzB,OAAO,SAAW,OAClB,OA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A,kCAAC;AAAA,kCAAA;AAAA,oCACG,OAAO;AAAA,sCACH,YACI;AAAA,sCACJ,UAAU;AAAA,sCACV,YAAY;AAAA,sCACZ,OAAO;AAAA,oCAAA;AAAA,oCAGV,UAAA4C;AAAA,kCAAA;AAAA,gCAAA;AAAA,gCAEL,gBAAA5C;AAAA,kCAAC;AAAA,kCAAA;AAAA,oCACG,OAAO;AAAA,sCACH,QAAQ;AAAA,sCACR,UAAU;AAAA,sCACV,YAAY;AAAA,sCACZ,YAAY;AAAA,sCACZ,OAAOjB;AAAA,oCAAA;AAAA,oCAGV,UAAA+C,EAAK;AAAA,kCAAA;AAAA,gCAAA;AAAA,8BACV;AAAA,4BAAA;AAAA,0BAAA;AAAA,0BAEHA,EAAK;AAAA,wBAAA;AAAA,sBAAA;AAAA,sBA1DDA,EAAK;AAAA,oBAAA;AAAA,kBA6DtB,CAAC;AAAA,gBAAA;AAAA,cAAA,IAEL;AAAA,YAAA,EAAA,CACR;AAAA,UAAA;AAAA,QAAA;AAAA,QAvLKK,EAAQ;AAAA,MAAA;AAAA,IA0LzB,CAAC;AAAA,IACAzB,sBAAO,OAAA,EAAI,OAAO,EAAE,WAAW,KAAM,UAAAA,EAAA,CAAI,IAAS;AAAA,EAAA,EAAA,CACvD;AAER;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const k = (l) => l.flatMap(
|
|
2
|
+
(e, t) => e.steps.length === 0 ? [
|
|
3
|
+
{
|
|
4
|
+
key: e.key,
|
|
5
|
+
code: `${t + 1}`,
|
|
6
|
+
title: e.title,
|
|
7
|
+
sectionIndex: t
|
|
8
|
+
}
|
|
9
|
+
] : e.steps.map((a, i) => ({
|
|
10
|
+
key: a.key,
|
|
11
|
+
code: `${t + 1}.${i + 1}`,
|
|
12
|
+
title: a.title,
|
|
13
|
+
sectionIndex: t
|
|
14
|
+
}))
|
|
15
|
+
), y = (l, e) => Math.max(
|
|
16
|
+
0,
|
|
17
|
+
l.findIndex((t) => t.key === e)
|
|
18
|
+
);
|
|
19
|
+
export {
|
|
20
|
+
y as activeIndexOf,
|
|
21
|
+
k as guideTimelinePositions
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=guideTimelinePositions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guideTimelinePositions.js","sources":["../../../src/components/GuideTimeline/guideTimelinePositions.ts"],"sourcesContent":["import type React from 'react';\n\nexport interface GuideTimelineStep {\n key: string;\n title: string;\n children?: React.ReactNode;\n}\n\nexport interface GuideTimelineSection {\n key: string;\n title: string;\n /** Under the section's heading, above its steps. A section without steps is this alone. */\n description?: React.ReactNode;\n steps: GuideTimelineStep[];\n}\n\n/** One place a reader can be: a step, or a section that has no steps. */\nexport interface GuideTimelinePosition {\n key: string;\n /** `2.2` for a section's second step, `3` for a section without steps. */\n code: string;\n title: string;\n sectionIndex: number;\n}\n\nexport const guideTimelinePositions = (\n sections: readonly GuideTimelineSection[],\n): GuideTimelinePosition[] =>\n sections.flatMap((section, sectionIndex) =>\n section.steps.length === 0\n ? [\n {\n key: section.key,\n code: `${sectionIndex + 1}`,\n title: section.title,\n sectionIndex,\n },\n ]\n : section.steps.map((step, stepIndex) => ({\n key: step.key,\n code: `${sectionIndex + 1}.${stepIndex + 1}`,\n title: step.title,\n sectionIndex,\n })),\n );\n\n/** Where `active` sits, or the first position when it is missing or unknown. */\nexport const activeIndexOf = (\n positions: readonly GuideTimelinePosition[],\n active: string | undefined,\n): number =>\n Math.max(\n 0,\n positions.findIndex((position) => position.key === active),\n );\n"],"names":["guideTimelinePositions","sections","section","sectionIndex","step","stepIndex","activeIndexOf","positions","active","position"],"mappings":"AAyBO,MAAMA,IAAyB,CAClCC,MAEAA,EAAS;AAAA,EAAQ,CAACC,GAASC,MACvBD,EAAQ,MAAM,WAAW,IACnB;AAAA,IACI;AAAA,MACI,KAAKA,EAAQ;AAAA,MACb,MAAM,GAAGC,IAAe,CAAC;AAAA,MACzB,OAAOD,EAAQ;AAAA,MACf,cAAAC;AAAA,IAAA;AAAA,EACJ,IAEJD,EAAQ,MAAM,IAAI,CAACE,GAAMC,OAAe;AAAA,IACpC,KAAKD,EAAK;AAAA,IACV,MAAM,GAAGD,IAAe,CAAC,IAAIE,IAAY,CAAC;AAAA,IAC1C,OAAOD,EAAK;AAAA,IACZ,cAAAD;AAAA,EAAA,EACF;AACZ,GAGSG,IAAgB,CACzBC,GACAC,MAEA,KAAK;AAAA,EACD;AAAA,EACAD,EAAU,UAAU,CAACE,MAAaA,EAAS,QAAQD,CAAM;AAC7D;"}
|
package/dist/components/Link.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
-
import { FOCUS_RING as
|
|
3
|
-
import { isRootRelative as
|
|
4
|
-
const
|
|
2
|
+
import { FOCUS_RING as g } from "./focusRing.js";
|
|
3
|
+
import { isRootRelative as d } from "./safeHref.js";
|
|
4
|
+
const v = "inline-block max-w-full min-w-0 truncate align-bottom", p = (e) => {
|
|
5
5
|
if (!e) return "";
|
|
6
6
|
switch (e) {
|
|
7
7
|
case "xsmall":
|
|
@@ -19,23 +19,24 @@ const d = (e) => {
|
|
|
19
19
|
default:
|
|
20
20
|
return "";
|
|
21
21
|
}
|
|
22
|
-
},
|
|
22
|
+
}, N = ({
|
|
23
23
|
children: e,
|
|
24
24
|
href: t,
|
|
25
|
-
target:
|
|
26
|
-
rel:
|
|
25
|
+
target: s = "_blank",
|
|
26
|
+
rel: l = "noopener noreferrer",
|
|
27
27
|
className: o = "",
|
|
28
28
|
color: i = "default",
|
|
29
29
|
size: m,
|
|
30
30
|
underline: c = !0,
|
|
31
|
+
truncate: u = !1,
|
|
31
32
|
onClick: a,
|
|
32
33
|
renderLink: r
|
|
33
34
|
}) => {
|
|
34
|
-
const x = i === "dimmed" ? "text-[var(--malachite-text-dimmed)] hover:text-[var(--malachite-text-primary)]" : "text-[var(--malachite-text-link-foreground)] hover:text-[var(--malachite-text-link-foreground-hover)]",
|
|
35
|
-
return r &&
|
|
35
|
+
const x = i === "dimmed" ? "text-[var(--malachite-text-dimmed)] hover:text-[var(--malachite-text-primary)]" : "text-[var(--malachite-text-link-foreground)] hover:text-[var(--malachite-text-link-foreground-hover)]", f = p(m), n = `${c ? "underline" : "no-underline"} rounded-xs cursor-pointer transition-colors duration-200 ease-in-out ${g} ${x} ${f} ${u ? v : ""} ${o}`;
|
|
36
|
+
return r && d(t) ? r({ href: t, className: n, children: e, ...a ? { onClick: a } : {} }) : /* @__PURE__ */ h("a", { href: t, target: s, rel: l, className: n, onClick: a, children: e });
|
|
36
37
|
};
|
|
37
38
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
N as Link,
|
|
40
|
+
N as default
|
|
40
41
|
};
|
|
41
42
|
//# sourceMappingURL=Link.js.map
|