@stackone/malachite 2.129.0 → 2.130.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,79 @@
1
+ import { jsx as a, jsxs as s, Fragment as b } from "react/jsx-runtime";
2
+ import h from "react";
3
+ import { Progress as u } from "./Progress.js";
4
+ import { VisuallyHidden as g } from "./VisuallyHidden.js";
5
+ import { paintOnChild as x } from "./asChild.js";
6
+ import { FOCUS_RING_INSET as f } from "./focusRing.js";
7
+ import { useSidebarCollapsed as v } from "./sidebarContext.js";
8
+ const p = "box-border flex w-full flex-col gap-2 rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-accent-border,rgba(0,175,102,0.2))] bg-[var(--malachite-accent-background-glass,rgba(0,175,102,0.08))] px-3 py-[10px] text-left no-underline transition-colors duration-200", N = `${p} cursor-pointer hover:border-[var(--malachite-control-border-hover,rgba(0,175,102,0.4))] ${f}`, _ = "[box-shadow:inset_0_0_0_1.5px_var(--malachite-accent-foreground,rgb(2,122,66))]", c = 5, d = { backgroundColor: "var(--malachite-card-background, rgb(255, 255, 255))" }, C = (r, e) => Math.min(Math.max(r, 0), e), m = ({
9
+ title: r,
10
+ value: e,
11
+ max: o,
12
+ caption: l,
13
+ busy: i = !1,
14
+ linked: t,
15
+ "aria-valuetext": n = `${e} of ${o}`
16
+ }) => /* @__PURE__ */ s(b, { children: [
17
+ /* @__PURE__ */ s("span", { className: "flex min-w-0 items-baseline gap-[6px]", children: [
18
+ /* @__PURE__ */ a("span", { className: "min-w-0 truncate text-[13px] leading-4 font-medium text-[var(--malachite-text-primary,rgb(10,10,10))]", children: r }),
19
+ !i && /* @__PURE__ */ s(
20
+ "span",
21
+ {
22
+ "aria-hidden": !0,
23
+ className: "ml-auto shrink-0 font-mono text-[11px] leading-4 text-[var(--malachite-accent-foreground,rgb(2,122,66))]",
24
+ children: [
25
+ e,
26
+ "/",
27
+ o
28
+ ]
29
+ }
30
+ ),
31
+ t && /* @__PURE__ */ a(g, { children: `, ${n},` })
32
+ ] }),
33
+ /* @__PURE__ */ a("span", { className: "block min-w-0 truncate text-[11.5px] leading-[15px] text-[var(--malachite-text-secondary,rgb(123,123,123))]", children: l }),
34
+ i ? /* @__PURE__ */ a(
35
+ "span",
36
+ {
37
+ className: "block rounded-[3px]",
38
+ style: { ...d, height: `${c}px` }
39
+ }
40
+ ) : /* @__PURE__ */ a("span", { "aria-hidden": t || void 0, className: "block", children: /* @__PURE__ */ a(
41
+ u,
42
+ {
43
+ height: c,
44
+ max: o,
45
+ segments: [{ value: e, variant: "accent" }],
46
+ "aria-label": r,
47
+ "aria-valuetext": n,
48
+ style: d
49
+ }
50
+ ) })
51
+ ] }), k = ({ link: r, current: e = !1, value: o, max: l, ...i }) => {
52
+ const t = { ...i, value: C(o, l), max: l };
53
+ if (r && !t.busy) {
54
+ const n = x(
55
+ r,
56
+ `${N} ${e ? _ : ""}`,
57
+ void 0,
58
+ /* @__PURE__ */ a(m, { ...t, linked: !0 })
59
+ );
60
+ return e ? h.cloneElement(n, {
61
+ "aria-current": "page"
62
+ }) : n;
63
+ }
64
+ return /* @__PURE__ */ a(
65
+ "div",
66
+ {
67
+ role: "group",
68
+ "aria-label": t.title,
69
+ "aria-busy": t.busy || void 0,
70
+ className: p,
71
+ children: /* @__PURE__ */ a(m, { ...t, linked: !1 })
72
+ }
73
+ );
74
+ }, A = (r) => v() ? null : /* @__PURE__ */ a("div", { className: "shrink-0 px-4 pb-4", children: /* @__PURE__ */ a(k, { ...r }) });
75
+ export {
76
+ A as SidebarProgress,
77
+ A as default
78
+ };
79
+ //# sourceMappingURL=SidebarProgress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidebarProgress.js","sources":["../../src/components/SidebarProgress.tsx"],"sourcesContent":["import React from 'react';\nimport Progress from './Progress';\nimport VisuallyHidden from './VisuallyHidden';\nimport { paintOnChild } from './asChild';\nimport { FOCUS_RING_INSET } from './focusRing';\nimport { useSidebarCollapsed } from './sidebarContext';\n\ninterface SidebarProgressBaseProps {\n title: string;\n /** Steps done, out of `max`. */\n value: number;\n max: number;\n caption: React.ReactNode;\n busy?: boolean;\n /** Spoken in the link's name when `link` is set. Defaults to \"`value` of `max`\". */\n 'aria-valuetext'?: string;\n}\n\ninterface SidebarProgressLinkProps {\n /** An empty link element, such as `<a href>` or a router `Link`, that the whole card becomes. */\n link: React.ReactElement;\n /** The page `link` opens is the one on screen. */\n current?: boolean;\n}\n\n/** `current` only exists alongside `link`: there is nothing else to mark. */\nexport type SidebarProgressProps = SidebarProgressBaseProps &\n (SidebarProgressLinkProps | { link?: undefined; current?: never });\n\nconst CARD = `box-border flex w-full flex-col gap-2 rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-accent-border,rgba(0,175,102,0.2))] bg-[var(--malachite-accent-background-glass,rgba(0,175,102,0.08))] px-3 py-[10px] text-left no-underline transition-colors duration-200`;\nconst LINK = `${CARD} cursor-pointer hover:border-[var(--malachite-control-border-hover,rgba(0,175,102,0.4))] ${FOCUS_RING_INSET}`;\n// Inset, like the focus ring, so neither is clipped by the scrolling body the card sits in.\nconst CURRENT = '[box-shadow:inset_0_0_0_1.5px_var(--malachite-accent-foreground,rgb(2,122,66))]';\nconst BAR_HEIGHT_PX = 5;\nconst TRACK = { backgroundColor: 'var(--malachite-card-background, rgb(255, 255, 255))' };\n\nconst clamp = (value: number, max: number): number => Math.min(Math.max(value, 0), max);\n\ntype CardContentProps = Omit<SidebarProgressProps, 'link' | 'current'> & { linked: boolean };\n\n// Browsers differ on whether a progressbar's value reaches its link's name, so a link speaks it as text.\nconst CardContent: React.FC<CardContentProps> = ({\n title,\n value,\n max,\n caption,\n busy = false,\n linked,\n 'aria-valuetext': ariaValueText = `${value} of ${max}`,\n}) => (\n <>\n <span className=\"flex min-w-0 items-baseline gap-[6px]\">\n <span className=\"min-w-0 truncate text-[13px] leading-4 font-medium text-[var(--malachite-text-primary,rgb(10,10,10))]\">\n {title}\n </span>\n {!busy && (\n <span\n aria-hidden\n className=\"ml-auto shrink-0 font-mono text-[11px] leading-4 text-[var(--malachite-accent-foreground,rgb(2,122,66))]\"\n >\n {value}/{max}\n </span>\n )}\n {linked && <VisuallyHidden>{`, ${ariaValueText},`}</VisuallyHidden>}\n </span>\n <span className=\"block min-w-0 truncate text-[11.5px] leading-[15px] text-[var(--malachite-text-secondary,rgb(123,123,123))]\">\n {caption}\n </span>\n {busy ? (\n <span\n className=\"block rounded-[3px]\"\n style={{ ...TRACK, height: `${BAR_HEIGHT_PX}px` }}\n />\n ) : (\n <span aria-hidden={linked || undefined} className=\"block\">\n <Progress\n height={BAR_HEIGHT_PX}\n max={max}\n segments={[{ value, variant: 'accent' }]}\n aria-label={title}\n aria-valuetext={ariaValueText}\n style={TRACK}\n />\n </span>\n )}\n </>\n);\n\nconst Card: React.FC<SidebarProgressProps> = ({ link, current = false, value, max, ...rest }) => {\n const content = { ...rest, value: clamp(value, max), max };\n if (link && !content.busy) {\n const card = paintOnChild(\n link,\n `${LINK} ${current ? CURRENT : ''}`,\n undefined,\n <CardContent {...content} linked />,\n );\n return current\n ? React.cloneElement(card, {\n 'aria-current': 'page',\n } as React.HTMLAttributes<HTMLElement>)\n : card;\n }\n return (\n <div\n role=\"group\"\n aria-label={content.title}\n aria-busy={content.busy || undefined}\n className={CARD}\n >\n <CardContent {...content} linked={false} />\n </div>\n );\n};\n\n/** A checklist's progress at the sidebar's gutter, as one link to the checklist; hidden while collapsed. */\nconst SidebarProgress: React.FC<SidebarProgressProps> = (props) => {\n const collapsed = useSidebarCollapsed();\n if (collapsed) {\n return null;\n }\n return (\n <div className=\"shrink-0 px-4 pb-4\">\n <Card {...props} />\n </div>\n );\n};\n\nexport { SidebarProgress };\nexport default SidebarProgress;\n"],"names":["CARD","LINK","FOCUS_RING_INSET","CURRENT","BAR_HEIGHT_PX","TRACK","clamp","value","max","CardContent","title","caption","busy","linked","ariaValueText","jsxs","Fragment","jsx","VisuallyHidden","Progress","Card","link","current","rest","content","card","paintOnChild","React","SidebarProgress","props","useSidebarCollapsed"],"mappings":";;;;;;;AA6BA,MAAMA,IAAO,2SACPC,IAAO,GAAGD,CAAI,4FAA4FE,CAAgB,IAE1HC,IAAU,mFACVC,IAAgB,GAChBC,IAAQ,EAAE,iBAAiB,uDAAA,GAE3BC,IAAQ,CAACC,GAAeC,MAAwB,KAAK,IAAI,KAAK,IAAID,GAAO,CAAC,GAAGC,CAAG,GAKhFC,IAA0C,CAAC;AAAA,EAC7C,OAAAC;AAAA,EACA,OAAAH;AAAA,EACA,KAAAC;AAAA,EACA,SAAAG;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAC;AAAA,EACA,kBAAkBC,IAAgB,GAAGP,CAAK,OAAOC,CAAG;AACxD,MACI,gBAAAO,EAAAC,GAAA,EACI,UAAA;AAAA,EAAA,gBAAAD,EAAC,QAAA,EAAK,WAAU,yCACZ,UAAA;AAAA,IAAA,gBAAAE,EAAC,QAAA,EAAK,WAAU,yGACX,UAAAP,GACL;AAAA,IACC,CAACE,KACE,gBAAAG;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,eAAW;AAAA,QACX,WAAU;AAAA,QAET,UAAA;AAAA,UAAAR;AAAA,UAAM;AAAA,UAAEC;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAGhBK,KAAU,gBAAAI,EAACC,GAAA,EAAgB,UAAA,KAAKJ,CAAa,IAAA,CAAI;AAAA,EAAA,GACtD;AAAA,EACA,gBAAAG,EAAC,QAAA,EAAK,WAAU,+GACX,UAAAN,GACL;AAAA,EACCC,IACG,gBAAAK;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,OAAO,EAAE,GAAGZ,GAAO,QAAQ,GAAGD,CAAa,KAAA;AAAA,IAAK;AAAA,EAAA,IAGpD,gBAAAa,EAAC,QAAA,EAAK,eAAaJ,KAAU,QAAW,WAAU,SAC9C,UAAA,gBAAAI;AAAA,IAACE;AAAA,IAAA;AAAA,MACG,QAAQf;AAAA,MACR,KAAAI;AAAA,MACA,UAAU,CAAC,EAAE,OAAAD,GAAO,SAAS,UAAU;AAAA,MACvC,cAAYG;AAAA,MACZ,kBAAgBI;AAAA,MAChB,OAAOT;AAAA,IAAA;AAAA,EAAA,EACX,CACJ;AAAA,GAER,GAGEe,IAAuC,CAAC,EAAE,MAAAC,GAAM,SAAAC,IAAU,IAAO,OAAAf,GAAO,KAAAC,GAAK,GAAGe,QAAW;AAC7F,QAAMC,IAAU,EAAE,GAAGD,GAAM,OAAOjB,EAAMC,GAAOC,CAAG,GAAG,KAAAA,EAAA;AACrD,MAAIa,KAAQ,CAACG,EAAQ,MAAM;AACvB,UAAMC,IAAOC;AAAA,MACTL;AAAA,MACA,GAAGpB,CAAI,IAAIqB,IAAUnB,IAAU,EAAE;AAAA,MACjC;AAAA,MACA,gBAAAc,EAACR,GAAA,EAAa,GAAGe,GAAS,QAAM,GAAA,CAAC;AAAA,IAAA;AAErC,WAAOF,IACDK,EAAM,aAAaF,GAAM;AAAA,MACrB,gBAAgB;AAAA,IAAA,CACkB,IACtCA;AAAA,EACV;AACA,SACI,gBAAAR;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,MAAK;AAAA,MACL,cAAYO,EAAQ;AAAA,MACpB,aAAWA,EAAQ,QAAQ;AAAA,MAC3B,WAAWxB;AAAA,MAEX,UAAA,gBAAAiB,EAACR,GAAA,EAAa,GAAGe,GAAS,QAAQ,GAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAGrD,GAGMI,IAAkD,CAACC,MACnCC,EAAA,IAEP,OAGP,gBAAAb,EAAC,SAAI,WAAU,sBACX,4BAACG,GAAA,EAAM,GAAGS,GAAO,EAAA,CACrB;"}
@@ -874,12 +874,12 @@ const zt = 160, kn = (e, n) => e.length === n.length && e.every((o, u) => o ===
874
874
  maxHeight: ge ? Ae : Jn(z, !!w)
875
875
  } : {}
876
876
  },
877
- children: d ? /* @__PURE__ */ r("div", { className: "flex flex-col w-full", style: h, children: /* @__PURE__ */ y("div", { className: "flex flex-col items-center justify-center bg-[var(--malachite-table-row-background,#fff)] w-full py-12", children: [
877
+ children: d ? /* @__PURE__ */ r("div", { className: "flex flex-col w-full", style: h, children: /* @__PURE__ */ y("div", { className: "flex flex-col items-center justify-center bg-[var(--malachite-table-row-background,#fff)] w-full px-4 py-12 text-center", children: [
878
878
  /* @__PURE__ */ r("div", { className: "text-[var(--malachite-text-secondary)] text-[14px] font-medium mb-1", children: N }),
879
879
  /* @__PURE__ */ r("div", { className: "text-[var(--malachite-text-secondary)] text-[13px]", children: S })
880
880
  ] }) }) : o ? /* @__PURE__ */ r("div", { className: "flex flex-col w-full", style: h, children: Array.from({ length: Ye }).map(
881
881
  (s, l) => k(l, l === Ye - 1)
882
- ) }) : T.length === 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col w-full", style: h, children: /* @__PURE__ */ y("div", { className: "flex flex-col items-center justify-center bg-[var(--malachite-table-row-background,#fff)] w-full py-12", children: [
882
+ ) }) : T.length === 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col w-full", style: h, children: /* @__PURE__ */ y("div", { className: "flex flex-col items-center justify-center bg-[var(--malachite-table-row-background,#fff)] w-full px-4 py-12 text-center", children: [
883
883
  /* @__PURE__ */ r("div", { className: "text-[var(--malachite-text-secondary)] text-[14px] font-medium", children: F }),
884
884
  M && /* @__PURE__ */ r("div", { className: "text-[var(--malachite-text-secondary)] text-[13px] mt-1", children: M })
885
885
  ] }) }) : (() => {