@stackone/malachite 2.76.0 → 2.78.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 +5 -5
- package/dist/components/Accordion.js +70 -51
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/BaseFormComponent.js +67 -57
- package/dist/components/BaseFormComponent.js.map +1 -1
- package/dist/components/Modal.js +50 -48
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/SidePanel.js +204 -145
- package/dist/components/SidePanel.js.map +1 -1
- package/dist/components/Stepper.js +100 -34
- package/dist/components/Stepper.js.map +1 -1
- package/dist/components/ToastItem.js +1 -1
- package/dist/components/ToastItem.js.map +1 -1
- package/dist/index.d.ts +52 -7
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,40 +1,106 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { FOCUS_RING as h } from "./focusRing.js";
|
|
3
|
+
const N = "var(--malachite-accent-foreground)", d = "color-mix(in srgb, var(--malachite-accent-foreground), white 50%)", C = "var(--malachite-card-border)", b = (o, e) => o === e ? N : o < e ? d : C, x = ({ label: o, isCurrent: e, onClick: s, className: a, style: c }) => s ? /* @__PURE__ */ n(
|
|
4
|
+
"button",
|
|
5
|
+
{
|
|
6
|
+
type: "button",
|
|
7
|
+
"aria-label": o,
|
|
8
|
+
"aria-current": e ? "step" : void 0,
|
|
9
|
+
onClick: s,
|
|
10
|
+
className: `${a} cursor-pointer p-0 ${h}`,
|
|
11
|
+
style: c
|
|
12
|
+
}
|
|
13
|
+
) : /* @__PURE__ */ n("span", { className: a, style: c }), k = (o, e, s) => {
|
|
14
|
+
const a = o.map(
|
|
15
|
+
(l, t) => o.slice(0, t).reduce((i, p) => i + Math.max(0, p.steps), 0)
|
|
16
|
+
), c = o.findIndex(
|
|
17
|
+
(l, t) => e >= a[t] && e < a[t] + l.steps
|
|
18
|
+
);
|
|
19
|
+
return o.map((l, t) => {
|
|
20
|
+
const i = a[t];
|
|
21
|
+
if (l.steps <= 0)
|
|
22
|
+
return null;
|
|
23
|
+
if (t !== c) {
|
|
24
|
+
const p = t < c;
|
|
25
|
+
return /* @__PURE__ */ n(
|
|
26
|
+
x,
|
|
27
|
+
{
|
|
28
|
+
label: `Go to ${l.label}`,
|
|
29
|
+
isCurrent: !1,
|
|
30
|
+
onClick: s && (() => s(i)),
|
|
31
|
+
className: "h-[8px] w-[16px] shrink-0 rounded-[3px] border-2 border-solid",
|
|
32
|
+
style: {
|
|
33
|
+
borderColor: p ? d : C,
|
|
34
|
+
backgroundColor: p ? d : "transparent"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
t
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ n(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
className: "mx-[6px] flex min-w-0 flex-1 gap-[4px] first:ml-0 last:mr-0",
|
|
44
|
+
children: Array.from({ length: Math.max(0, l.steps) }, (p, u) => {
|
|
45
|
+
const r = i + u;
|
|
46
|
+
return /* @__PURE__ */ n(
|
|
47
|
+
x,
|
|
48
|
+
{
|
|
49
|
+
label: `Go to step ${r + 1}`,
|
|
50
|
+
isCurrent: r === e,
|
|
51
|
+
onClick: s && (() => s(r)),
|
|
52
|
+
className: "h-[8px] min-w-0 flex-1 rounded-[3px] border-0",
|
|
53
|
+
style: { backgroundColor: b(r, e) }
|
|
54
|
+
},
|
|
55
|
+
r
|
|
56
|
+
);
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
t
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
}, y = ({
|
|
63
|
+
steps: o,
|
|
64
|
+
groups: e,
|
|
65
|
+
active: s,
|
|
66
|
+
onChange: a,
|
|
67
|
+
className: c = "",
|
|
7
68
|
"aria-label": l,
|
|
8
|
-
"aria-labelledby":
|
|
69
|
+
"aria-labelledby": t
|
|
9
70
|
}) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
71
|
+
const p = {
|
|
72
|
+
role: !!(l ?? t) ? "group" : void 0,
|
|
73
|
+
"aria-label": l,
|
|
74
|
+
"aria-labelledby": t
|
|
75
|
+
};
|
|
76
|
+
if (e)
|
|
77
|
+
return /* @__PURE__ */ n("div", { ...p, className: `flex w-full items-center gap-[4px] ${c}`, children: k(e, s, a) });
|
|
78
|
+
const u = Array.from({ length: Math.max(0, o) }, (r, m) => m);
|
|
79
|
+
return /* @__PURE__ */ n("div", { ...p, className: `flex gap-[4px] ${c}`, children: u.map((r) => {
|
|
80
|
+
const m = r === s, f = `h-[8px] rounded-full transition-all ${m ? "w-[28px]" : "w-[16px]"}`;
|
|
81
|
+
return a ? /* @__PURE__ */ n(
|
|
82
|
+
"button",
|
|
83
|
+
{
|
|
84
|
+
type: "button",
|
|
85
|
+
"aria-label": `Go to step ${r + 1}`,
|
|
86
|
+
"aria-current": m ? "step" : void 0,
|
|
87
|
+
onClick: () => a(r),
|
|
88
|
+
className: `${f} border-0 p-0 cursor-pointer`,
|
|
89
|
+
style: { backgroundColor: b(r, s) }
|
|
90
|
+
},
|
|
91
|
+
r
|
|
92
|
+
) : /* @__PURE__ */ n(
|
|
93
|
+
"span",
|
|
94
|
+
{
|
|
95
|
+
className: f,
|
|
96
|
+
style: { backgroundColor: b(r, s) }
|
|
97
|
+
},
|
|
98
|
+
r
|
|
99
|
+
);
|
|
100
|
+
}) });
|
|
35
101
|
};
|
|
36
102
|
export {
|
|
37
|
-
|
|
38
|
-
|
|
103
|
+
y as Stepper,
|
|
104
|
+
y as default
|
|
39
105
|
};
|
|
40
106
|
//# sourceMappingURL=Stepper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.js","sources":["../../src/components/Stepper.tsx"],"sourcesContent":["import React from 'react';\
|
|
1
|
+
{"version":3,"file":"Stepper.js","sources":["../../src/components/Stepper.tsx"],"sourcesContent":["import React from 'react';\nimport { FOCUS_RING } from './focusRing';\n\ninterface StepperBaseProps {\n /** Active step index (0-based), counted across every group when grouped. */\n active: number;\n /** When provided, each step becomes a clickable control. */\n onChange?: (index: number) => void;\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n}\n\nexport interface StepperProps extends StepperBaseProps {\n /** Total number of steps. */\n steps: number;\n groups?: never;\n}\n\nexport interface StepperGroup {\n /** Names the group's folded mark, e.g. a section title. */\n label: string;\n steps: number;\n}\n\n/**\n * Steps in consecutive groups. The active step's group opens into one bar per step across\n * the full width, and every other group folds to a short bar. Folded bars keep a fixed width\n * and the open group shares what is left, so allow about 20px per other group and 12px per\n * step in the open group.\n */\nexport interface GroupedStepperProps extends StepperBaseProps {\n groups: StepperGroup[];\n steps?: never;\n}\n\n// Completed steps get a lightened accent, the active step the full accent,\n// upcoming steps a neutral border colour.\nconst ACTIVE_COLOR = 'var(--malachite-accent-foreground)';\nconst COMPLETED_COLOR = 'color-mix(in srgb, var(--malachite-accent-foreground), white 50%)';\nconst UPCOMING_COLOR = 'var(--malachite-card-border)';\n\nconst stepColor = (index: number, active: number): string =>\n index === active ? ACTIVE_COLOR : index < active ? COMPLETED_COLOR : UPCOMING_COLOR;\n\ninterface MarkProps {\n label: string;\n isCurrent: boolean;\n onClick?: () => void;\n className: string;\n style: React.CSSProperties;\n}\n\nconst Mark: React.FC<MarkProps> = ({ label, isCurrent, onClick, className, style }) =>\n onClick ? (\n <button\n type=\"button\"\n aria-label={label}\n aria-current={isCurrent ? 'step' : undefined}\n onClick={onClick}\n className={`${className} cursor-pointer p-0 ${FOCUS_RING}`}\n style={style}\n />\n ) : (\n <span className={className} style={style} />\n );\n\nconst groupedMarks = (\n groups: StepperGroup[],\n active: number,\n onChange: ((index: number) => void) | undefined,\n): React.ReactNode[] => {\n const starts = groups.map((_, index) =>\n groups.slice(0, index).reduce((total, group) => total + Math.max(0, group.steps), 0),\n );\n const currentGroup = groups.findIndex(\n (group, index) => active >= starts[index] && active < starts[index] + group.steps,\n );\n\n return groups.map((group, groupIndex) => {\n const start = starts[groupIndex];\n if (group.steps <= 0) {\n return null;\n }\n if (groupIndex !== currentGroup) {\n const isDone = groupIndex < currentGroup;\n return (\n <Mark\n key={groupIndex}\n label={`Go to ${group.label}`}\n isCurrent={false}\n onClick={onChange && (() => onChange(start))}\n className=\"h-[8px] w-[16px] shrink-0 rounded-[3px] border-2 border-solid\"\n style={{\n borderColor: isDone ? COMPLETED_COLOR : UPCOMING_COLOR,\n backgroundColor: isDone ? COMPLETED_COLOR : 'transparent',\n }}\n />\n );\n }\n\n return (\n <div\n key={groupIndex}\n className=\"mx-[6px] flex min-w-0 flex-1 gap-[4px] first:ml-0 last:mr-0\"\n >\n {Array.from({ length: Math.max(0, group.steps) }, (_, offset) => {\n const index = start + offset;\n return (\n <Mark\n key={index}\n label={`Go to step ${index + 1}`}\n isCurrent={index === active}\n onClick={onChange && (() => onChange(index))}\n className=\"h-[8px] min-w-0 flex-1 rounded-[3px] border-0\"\n style={{ backgroundColor: stepColor(index, active) }}\n />\n );\n })}\n </div>\n );\n });\n};\n\nconst Stepper: React.FC<StepperProps | GroupedStepperProps> = ({\n steps,\n groups,\n active,\n onChange,\n className = '',\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => {\n // A role is what makes aria-label apply at all, but an unnamed group is pure noise\n // in the a11y tree, so the role only appears alongside a name. progressbar would be\n // wrong either way: its contents are presentational and cannot expose the step buttons.\n const isNamed = Boolean(ariaLabel ?? ariaLabelledBy);\n const groupProps = {\n role: isNamed ? 'group' : undefined,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n };\n\n if (groups) {\n return (\n <div {...groupProps} className={`flex w-full items-center gap-[4px] ${className}`}>\n {groupedMarks(groups, active, onChange)}\n </div>\n );\n }\n\n const segments = Array.from({ length: Math.max(0, steps) }, (_, index) => index);\n\n return (\n <div {...groupProps} className={`flex gap-[4px] ${className}`}>\n {segments.map((index) => {\n const isActive = index === active;\n const base = `h-[8px] rounded-full transition-all ${isActive ? 'w-[28px]' : 'w-[16px]'}`;\n\n if (!onChange) {\n return (\n <span\n key={index}\n className={base}\n style={{ backgroundColor: stepColor(index, active) }}\n />\n );\n }\n\n return (\n <button\n key={index}\n type=\"button\"\n aria-label={`Go to step ${index + 1}`}\n aria-current={isActive ? 'step' : undefined}\n onClick={() => onChange(index)}\n className={`${base} border-0 p-0 cursor-pointer`}\n style={{ backgroundColor: stepColor(index, active) }}\n />\n );\n })}\n </div>\n );\n};\n\nexport default Stepper;\nexport { Stepper };\n"],"names":["ACTIVE_COLOR","COMPLETED_COLOR","UPCOMING_COLOR","stepColor","index","active","Mark","label","isCurrent","onClick","className","style","jsx","FOCUS_RING","groupedMarks","groups","onChange","starts","_","total","group","currentGroup","groupIndex","start","isDone","offset","Stepper","steps","ariaLabel","ariaLabelledBy","groupProps","segments","isActive","base"],"mappings":";;AAsCA,MAAMA,IAAe,sCACfC,IAAkB,qEAClBC,IAAiB,gCAEjBC,IAAY,CAACC,GAAeC,MAC9BD,MAAUC,IAASL,IAAeI,IAAQC,IAASJ,IAAkBC,GAUnEI,IAA4B,CAAC,EAAE,OAAAC,GAAO,WAAAC,GAAW,SAAAC,GAAS,WAAAC,GAAW,OAAAC,QACvEF,IACI,gBAAAG;AAAA,EAAC;AAAA,EAAA;AAAA,IACG,MAAK;AAAA,IACL,cAAYL;AAAA,IACZ,gBAA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B,EAASZ,CAAK;AAAA,QAC7B,WAAW,GAAG6B,CAAI;AAAA,QAClB,OAAO,EAAE,iBAAiB9B,EAAUC,GAAOC,CAAM,EAAA;AAAA,MAAE;AAAA,MAN9CD;AAAA,IAAA,IAVL,gBAAAQ;AAAA,MAAC;AAAA,MAAA;AAAA,QAEG,WAAWqB;AAAA,QACX,OAAO,EAAE,iBAAiB9B,EAAUC,GAAOC,CAAM,EAAA;AAAA,MAAE;AAAA,MAF9CD;AAAA,IAAA;AAAA,EAkBrB,CAAC,EAAA,CACL;AAER;"}
|
|
@@ -35,7 +35,7 @@ const f = {
|
|
|
35
35
|
onClick: (e) => {
|
|
36
36
|
e.stopPropagation(), a(r.id);
|
|
37
37
|
},
|
|
38
|
-
className: "pointer-events-auto flex max-w-[480px] cursor-pointer items-start gap-[8px] rounded-
|
|
38
|
+
className: "pointer-events-auto flex max-w-[480px] cursor-pointer items-start gap-[8px] rounded-xl bg-[var(--malachite-tooltip-background,rgb(59,59,59))] px-[12px] py-[8px] text-[length:var(--malachite-font-size-medium,14px)] leading-[20px] text-[var(--malachite-tooltip-foreground,rgb(255,255,255))] [box-shadow:var(--malachite-tooltip-shadow,0px_0px_10px_0px_rgba(0,0,0,0.2))] animate-[malachite-toast-in_150ms_ease-out] motion-reduce:animate-none",
|
|
39
39
|
style: { overflowWrap: "anywhere" },
|
|
40
40
|
children: [
|
|
41
41
|
/* @__PURE__ */ l(d, { size: 16, className: `mt-[2px] shrink-0 ${f[r.variant]}` }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastItem.js","sources":["../../src/components/ToastItem.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport CheckCircleFilled from './CustomIcons/CheckCircleFilled';\nimport ErrorCircleFilled from './CustomIcons/ErrorCircleFilled';\nimport type { QueuedToast, ToastVariant } from './toastTypes';\n\n// The plain status tokens fall under 3:1 on the pill; the mix clears it in both themes.\nconst ICON_COLOR: Record<ToastVariant, string> = {\n success:\n 'text-[var(--malachite-text-success,rgb(2,122,66))] supports-[color:color-mix(in_srgb,red,red)]:text-[color-mix(in_srgb,var(--malachite-text-success,rgb(2,122,66))_70%,var(--malachite-tooltip-foreground,rgb(255,255,255)))]',\n error: 'text-[var(--malachite-text-destructive,rgb(237,53,54))] supports-[color:color-mix(in_srgb,red,red)]:text-[color-mix(in_srgb,var(--malachite-text-destructive,rgb(237,53,54))_70%,var(--malachite-tooltip-foreground,rgb(255,255,255)))]',\n};\n\ninterface ToastItemProps {\n toast: QueuedToast;\n duration: number;\n onDismiss: (id: number) => void;\n}\n\nconst ToastItem: React.FC<ToastItemProps> = ({ toast, duration, onDismiss }) => {\n const [paused, setPaused] = useState(false);\n const ref = useRef<HTMLDivElement>(null);\n const remaining = useRef(duration);\n\n // React's onPointerEnter never fires across this portal's shadow boundary.\n useEffect(() => {\n const el = ref.current;\n if (!el) {\n return;\n }\n const pause = () => setPaused(true);\n const resume = () => setPaused(false);\n el.addEventListener('pointerenter', pause);\n el.addEventListener('pointerleave', resume);\n return () => {\n el.removeEventListener('pointerenter', pause);\n el.removeEventListener('pointerleave', resume);\n };\n }, []);\n\n useEffect(() => {\n if (paused) {\n return;\n }\n const startedAt = Date.now();\n const timeout = setTimeout(() => onDismiss(toast.id), remaining.current);\n return () => {\n clearTimeout(timeout);\n remaining.current = Math.max(0, remaining.current - (Date.now() - startedAt));\n };\n }, [paused, onDismiss, toast.id]);\n\n const Icon = toast.variant === 'error' ? ErrorCircleFilled : CheckCircleFilled;\n\n return (\n // aria-hidden: the provider's live regions are the announced copy.\n <div\n ref={ref}\n aria-hidden=\"true\"\n data-toast={toast.variant}\n onClick={(event) => {\n // A portal bubbles through the React tree, to the provider's ancestors.\n event.stopPropagation();\n onDismiss(toast.id);\n }}\n className=\"pointer-events-auto flex max-w-[480px] cursor-pointer items-start gap-[8px] rounded-
|
|
1
|
+
{"version":3,"file":"ToastItem.js","sources":["../../src/components/ToastItem.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport CheckCircleFilled from './CustomIcons/CheckCircleFilled';\nimport ErrorCircleFilled from './CustomIcons/ErrorCircleFilled';\nimport type { QueuedToast, ToastVariant } from './toastTypes';\n\n// The plain status tokens fall under 3:1 on the pill; the mix clears it in both themes.\nconst ICON_COLOR: Record<ToastVariant, string> = {\n success:\n 'text-[var(--malachite-text-success,rgb(2,122,66))] supports-[color:color-mix(in_srgb,red,red)]:text-[color-mix(in_srgb,var(--malachite-text-success,rgb(2,122,66))_70%,var(--malachite-tooltip-foreground,rgb(255,255,255)))]',\n error: 'text-[var(--malachite-text-destructive,rgb(237,53,54))] supports-[color:color-mix(in_srgb,red,red)]:text-[color-mix(in_srgb,var(--malachite-text-destructive,rgb(237,53,54))_70%,var(--malachite-tooltip-foreground,rgb(255,255,255)))]',\n};\n\ninterface ToastItemProps {\n toast: QueuedToast;\n duration: number;\n onDismiss: (id: number) => void;\n}\n\nconst ToastItem: React.FC<ToastItemProps> = ({ toast, duration, onDismiss }) => {\n const [paused, setPaused] = useState(false);\n const ref = useRef<HTMLDivElement>(null);\n const remaining = useRef(duration);\n\n // React's onPointerEnter never fires across this portal's shadow boundary.\n useEffect(() => {\n const el = ref.current;\n if (!el) {\n return;\n }\n const pause = () => setPaused(true);\n const resume = () => setPaused(false);\n el.addEventListener('pointerenter', pause);\n el.addEventListener('pointerleave', resume);\n return () => {\n el.removeEventListener('pointerenter', pause);\n el.removeEventListener('pointerleave', resume);\n };\n }, []);\n\n useEffect(() => {\n if (paused) {\n return;\n }\n const startedAt = Date.now();\n const timeout = setTimeout(() => onDismiss(toast.id), remaining.current);\n return () => {\n clearTimeout(timeout);\n remaining.current = Math.max(0, remaining.current - (Date.now() - startedAt));\n };\n }, [paused, onDismiss, toast.id]);\n\n const Icon = toast.variant === 'error' ? ErrorCircleFilled : CheckCircleFilled;\n\n return (\n // aria-hidden: the provider's live regions are the announced copy.\n <div\n ref={ref}\n aria-hidden=\"true\"\n data-toast={toast.variant}\n onClick={(event) => {\n // A portal bubbles through the React tree, to the provider's ancestors.\n event.stopPropagation();\n onDismiss(toast.id);\n }}\n className=\"pointer-events-auto flex max-w-[480px] cursor-pointer items-start gap-[8px] rounded-xl bg-[var(--malachite-tooltip-background,rgb(59,59,59))] px-[12px] py-[8px] text-[length:var(--malachite-font-size-medium,14px)] leading-[20px] text-[var(--malachite-tooltip-foreground,rgb(255,255,255))] [box-shadow:var(--malachite-tooltip-shadow,0px_0px_10px_0px_rgba(0,0,0,0.2))] animate-[malachite-toast-in_150ms_ease-out] motion-reduce:animate-none\"\n style={{ overflowWrap: 'anywhere' }}\n >\n <Icon size={16} className={`mt-[2px] shrink-0 ${ICON_COLOR[toast.variant]}`} />\n <span>{toast.message}</span>\n </div>\n );\n};\n\nexport default ToastItem;\n"],"names":["ICON_COLOR","ToastItem","toast","duration","onDismiss","paused","setPaused","useState","ref","useRef","remaining","useEffect","el","pause","resume","startedAt","timeout","Icon","ErrorCircleFilled","CheckCircleFilled","jsxs","event","jsx"],"mappings":";;;;AAMA,MAAMA,IAA2C;AAAA,EAC7C,SACI;AAAA,EACJ,OAAO;AACX,GAQMC,IAAsC,CAAC,EAAE,OAAAC,GAAO,UAAAC,GAAU,WAAAC,QAAgB;AAC5E,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpCC,IAAMC,EAAuB,IAAI,GACjCC,IAAYD,EAAON,CAAQ;AAGjC,EAAAQ,EAAU,MAAM;AACZ,UAAMC,IAAKJ,EAAI;AACf,QAAI,CAACI;AACD;AAEJ,UAAMC,IAAQ,MAAMP,EAAU,EAAI,GAC5BQ,IAAS,MAAMR,EAAU,EAAK;AACpC,WAAAM,EAAG,iBAAiB,gBAAgBC,CAAK,GACzCD,EAAG,iBAAiB,gBAAgBE,CAAM,GACnC,MAAM;AACT,MAAAF,EAAG,oBAAoB,gBAAgBC,CAAK,GAC5CD,EAAG,oBAAoB,gBAAgBE,CAAM;AAAA,IACjD;AAAA,EACJ,GAAG,CAAA,CAAE,GAELH,EAAU,MAAM;AACZ,QAAIN;AACA;AAEJ,UAAMU,IAAY,KAAK,IAAA,GACjBC,IAAU,WAAW,MAAMZ,EAAUF,EAAM,EAAE,GAAGQ,EAAU,OAAO;AACvE,WAAO,MAAM;AACT,mBAAaM,CAAO,GACpBN,EAAU,UAAU,KAAK,IAAI,GAAGA,EAAU,WAAW,KAAK,IAAA,IAAQK,EAAU;AAAA,IAChF;AAAA,EACJ,GAAG,CAACV,GAAQD,GAAWF,EAAM,EAAE,CAAC;AAEhC,QAAMe,IAAOf,EAAM,YAAY,UAAUgB,IAAoBC;AAE7D;AAAA;AAAA,IAEI,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,KAAAZ;AAAA,QACA,eAAY;AAAA,QACZ,cAAYN,EAAM;AAAA,QAClB,SAAS,CAACmB,MAAU;AAEhB,UAAAA,EAAM,gBAAA,GACNjB,EAAUF,EAAM,EAAE;AAAA,QACtB;AAAA,QACA,WAAU;AAAA,QACV,OAAO,EAAE,cAAc,WAAA;AAAA,QAEvB,UAAA;AAAA,UAAA,gBAAAoB,EAACL,GAAA,EAAK,MAAM,IAAI,WAAW,qBAAqBjB,EAAWE,EAAM,OAAO,CAAC,GAAA,CAAI;AAAA,UAC7E,gBAAAoB,EAAC,QAAA,EAAM,UAAApB,EAAM,QAAA,CAAQ;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA;AAGjC;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,8 @@ declare interface AccordionBaseProps {
|
|
|
53
53
|
trailing?: default_2.ReactNode;
|
|
54
54
|
/** Before the title, outside the toggle button. */
|
|
55
55
|
leading?: default_2.ReactNode;
|
|
56
|
-
|
|
56
|
+
/** `gutter` puts the arrow before `leading` as its own mouse toggle; the title stays the keyboard one. */
|
|
57
|
+
arrowPosition?: 'start' | 'end' | 'gutter';
|
|
57
58
|
/** `false` keeps an open row on the card ground. */
|
|
58
59
|
highlightExpanded?: boolean;
|
|
59
60
|
defaultExpanded?: boolean;
|
|
@@ -2026,6 +2027,17 @@ export declare function getCurrentThemeMode(): 'light' | 'dark';
|
|
|
2026
2027
|
|
|
2027
2028
|
export declare const GlobeIcon: React.FC<IconProps_58>;
|
|
2028
2029
|
|
|
2030
|
+
/**
|
|
2031
|
+
* Steps in consecutive groups. The active step's group opens into one bar per step across
|
|
2032
|
+
* the full width, and every other group folds to a short bar. Folded bars keep a fixed width
|
|
2033
|
+
* and the open group shares what is left, so allow about 20px per other group and 12px per
|
|
2034
|
+
* step in the open group.
|
|
2035
|
+
*/
|
|
2036
|
+
export declare interface GroupedStepperProps extends StepperBaseProps {
|
|
2037
|
+
groups: StepperGroup[];
|
|
2038
|
+
steps?: never;
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2029
2041
|
export declare const IconBadge: default_2.FC<IconBadgeProps>;
|
|
2030
2042
|
|
|
2031
2043
|
export declare interface IconBadgeProps {
|
|
@@ -3660,7 +3672,8 @@ export declare interface ModalProps {
|
|
|
3660
3672
|
children: default_2.ReactNode;
|
|
3661
3673
|
}
|
|
3662
3674
|
|
|
3663
|
-
|
|
3675
|
+
/** `fullscreen` fills the window, inside the overlay's margin, in both directions. */
|
|
3676
|
+
export declare type ModalSize = 'small' | 'medium' | 'large' | 'fullscreen';
|
|
3664
3677
|
|
|
3665
3678
|
export declare type ModalSurface = 'card' | 'none';
|
|
3666
3679
|
|
|
@@ -4363,6 +4376,11 @@ export declare type RightSideContent = {
|
|
|
4363
4376
|
type?: 'link';
|
|
4364
4377
|
text: string;
|
|
4365
4378
|
href: string;
|
|
4379
|
+
} | {
|
|
4380
|
+
/** An action on the form itself, such as showing a panel of help beside it. */
|
|
4381
|
+
type: 'button';
|
|
4382
|
+
text: string;
|
|
4383
|
+
onClick: () => void;
|
|
4366
4384
|
};
|
|
4367
4385
|
|
|
4368
4386
|
declare const Row: default_2.FC<KeyValueListRowProps>;
|
|
@@ -4723,6 +4741,18 @@ export declare interface SidebarSwitcherProps extends SidebarButtonAttributes {
|
|
|
4723
4741
|
*/
|
|
4724
4742
|
export declare const SidePanel: default_2.FC<SidePanelProps>;
|
|
4725
4743
|
|
|
4744
|
+
export declare interface SidePanelAside {
|
|
4745
|
+
/** Shown in the aside's header, and names the column for assistive tech. */
|
|
4746
|
+
title: string;
|
|
4747
|
+
/** Content pinned right in the aside's header (e.g. a stepper). */
|
|
4748
|
+
headerExtra?: default_2.ReactNode;
|
|
4749
|
+
/** Pinned at the bottom, level with the panel's footer. */
|
|
4750
|
+
footer?: default_2.ReactNode;
|
|
4751
|
+
/** Whether the aside's body gets default padding, as the panel's `bodyPadding`. Default: true. */
|
|
4752
|
+
bodyPadding?: boolean;
|
|
4753
|
+
children: default_2.ReactNode;
|
|
4754
|
+
}
|
|
4755
|
+
|
|
4726
4756
|
export declare const SidePanelNavFooter: default_2.FC<SidePanelNavFooterProps>;
|
|
4727
4757
|
|
|
4728
4758
|
export declare interface SidePanelNavFooterProps {
|
|
@@ -4775,6 +4805,11 @@ export declare interface SidePanelProps {
|
|
|
4775
4805
|
}[];
|
|
4776
4806
|
/** Routes root-relative links in `callouts` through the app's router; see `MarkdownBlock`. */
|
|
4777
4807
|
renderLink?: RenderLink;
|
|
4808
|
+
/** A full-height column opened to the left, as wide again as `maxWidth`. The panel's own
|
|
4809
|
+
* header, body and footer keep their width and place; the aside's header and footer line
|
|
4810
|
+
* up with them. The aside is never narrower than 360px: a window too narrow for both
|
|
4811
|
+
* columns scrolls the panel sideways. */
|
|
4812
|
+
aside?: SidePanelAside;
|
|
4778
4813
|
children: default_2.ReactNode;
|
|
4779
4814
|
}
|
|
4780
4815
|
|
|
@@ -4984,12 +5019,10 @@ export declare type StatusPillTone = 'success' | 'neutral' | 'warning' | 'error'
|
|
|
4984
5019
|
|
|
4985
5020
|
export declare const StepCurrentIcon: React.FC<IconProps_104>;
|
|
4986
5021
|
|
|
4987
|
-
export declare const Stepper: default_2.FC<StepperProps>;
|
|
5022
|
+
export declare const Stepper: default_2.FC<StepperProps | GroupedStepperProps>;
|
|
4988
5023
|
|
|
4989
|
-
|
|
4990
|
-
/**
|
|
4991
|
-
steps: number;
|
|
4992
|
-
/** Active step index (0-based). */
|
|
5024
|
+
declare interface StepperBaseProps {
|
|
5025
|
+
/** Active step index (0-based), counted across every group when grouped. */
|
|
4993
5026
|
active: number;
|
|
4994
5027
|
/** When provided, each step becomes a clickable control. */
|
|
4995
5028
|
onChange?: (index: number) => void;
|
|
@@ -4998,6 +5031,18 @@ export declare interface StepperProps {
|
|
|
4998
5031
|
'aria-labelledby'?: string;
|
|
4999
5032
|
}
|
|
5000
5033
|
|
|
5034
|
+
export declare interface StepperGroup {
|
|
5035
|
+
/** Names the group's folded mark, e.g. a section title. */
|
|
5036
|
+
label: string;
|
|
5037
|
+
steps: number;
|
|
5038
|
+
}
|
|
5039
|
+
|
|
5040
|
+
export declare interface StepperProps extends StepperBaseProps {
|
|
5041
|
+
/** Total number of steps. */
|
|
5042
|
+
steps: number;
|
|
5043
|
+
groups?: never;
|
|
5044
|
+
}
|
|
5045
|
+
|
|
5001
5046
|
export declare interface StepTabItem {
|
|
5002
5047
|
key: string;
|
|
5003
5048
|
label: string;
|