@siyahi/ui 0.1.9-next.2 → 0.1.9-next.21

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.
Files changed (196) hide show
  1. package/DESIGN.md +30 -0
  2. package/README.md +82 -176
  3. package/THIRD_PARTY_NOTICES.md +11 -11
  4. package/agents/examples/accordion.tsx +39 -0
  5. package/agents/examples/alert.tsx +23 -0
  6. package/agents/examples/app-sidebar.tsx +38 -0
  7. package/agents/examples/avatar.tsx +14 -0
  8. package/agents/examples/badge.tsx +18 -0
  9. package/agents/examples/bar-list-labels.tsx +22 -0
  10. package/agents/examples/bar-list-sides.tsx +38 -0
  11. package/agents/examples/bar-list.tsx +24 -0
  12. package/agents/examples/breadcrumb.tsx +28 -0
  13. package/agents/examples/button-states.tsx +23 -0
  14. package/agents/examples/button.tsx +21 -0
  15. package/agents/examples/calendar.tsx +15 -0
  16. package/agents/examples/callout.tsx +33 -0
  17. package/agents/examples/card.tsx +34 -0
  18. package/agents/examples/change-bar.tsx +104 -0
  19. package/agents/examples/chart-area.tsx +39 -0
  20. package/agents/examples/chart-bar-flows.tsx +32 -0
  21. package/agents/examples/chart-bar-hourly.tsx +28 -0
  22. package/agents/examples/chart-bar-losses.tsx +29 -0
  23. package/agents/examples/chart-bar-sectors.tsx +72 -0
  24. package/agents/examples/chart-bar-years.tsx +40 -0
  25. package/agents/examples/chart-bar.tsx +56 -0
  26. package/agents/examples/chart-category-ticks.tsx +50 -0
  27. package/agents/examples/chart-line-events.tsx +47 -0
  28. package/agents/examples/chart-line-timeline.tsx +41 -0
  29. package/agents/examples/chart-line.tsx +57 -0
  30. package/agents/examples/code-block.tsx +38 -0
  31. package/agents/examples/collapsible.tsx +16 -0
  32. package/agents/examples/command.tsx +27 -0
  33. package/agents/examples/context-menu.tsx +15 -0
  34. package/agents/examples/copy-button.tsx +8 -0
  35. package/agents/examples/data-bar.tsx +121 -0
  36. package/agents/examples/data-table-compact.tsx +95 -0
  37. package/agents/examples/data-table-filters.tsx +103 -0
  38. package/agents/examples/data-table.tsx +98 -0
  39. package/agents/examples/delta.tsx +13 -0
  40. package/agents/examples/dialog.tsx +28 -0
  41. package/agents/examples/distribution-bar-budget.tsx +30 -0
  42. package/agents/examples/distribution-bar-tug.tsx +72 -0
  43. package/agents/examples/dropdown-menu.tsx +31 -0
  44. package/agents/examples/formatters.tsx +42 -0
  45. package/agents/examples/heatmap-calendar.tsx +60 -0
  46. package/agents/examples/heatmap-status.tsx +57 -0
  47. package/agents/examples/heatmap-weekday.tsx +75 -0
  48. package/agents/examples/input-states.tsx +33 -0
  49. package/agents/examples/input.tsx +17 -0
  50. package/agents/examples/local-time.tsx +14 -0
  51. package/agents/examples/metric-strip.tsx +46 -0
  52. package/agents/examples/overview-dashboard.tsx +18 -0
  53. package/agents/examples/page-hero.tsx +38 -0
  54. package/agents/examples/page-section.tsx +52 -0
  55. package/agents/examples/popover.tsx +23 -0
  56. package/agents/examples/price-chart.tsx +32 -0
  57. package/agents/examples/progress-tone.tsx +28 -0
  58. package/agents/examples/progress.tsx +10 -0
  59. package/agents/examples/range-position-table.tsx +101 -0
  60. package/agents/examples/range-position.tsx +53 -0
  61. package/agents/examples/scroll-area.tsx +20 -0
  62. package/agents/examples/section-cards-select.tsx +30 -0
  63. package/agents/examples/section-cards-trend.tsx +30 -0
  64. package/agents/examples/section-cards.tsx +48 -0
  65. package/agents/examples/select.tsx +27 -0
  66. package/agents/examples/separator.tsx +13 -0
  67. package/agents/examples/sheet.tsx +15 -0
  68. package/agents/examples/skeleton.tsx +11 -0
  69. package/agents/examples/slider.tsx +5 -0
  70. package/agents/examples/surfaces.tsx +116 -0
  71. package/agents/examples/table.tsx +50 -0
  72. package/agents/examples/tabs.tsx +16 -0
  73. package/agents/examples/target-rows.tsx +70 -0
  74. package/agents/examples/toggle-group.tsx +12 -0
  75. package/agents/examples/toggle.tsx +11 -0
  76. package/agents/examples/tooltip.tsx +13 -0
  77. package/agents/examples/treemap.tsx +88 -0
  78. package/agents/manifest.json +1081 -0
  79. package/agents/report-rules.json +7 -0
  80. package/dist/components/registry/charts/area-chart-card.js +25 -7
  81. package/dist/components/registry/charts/bar-chart-card.d.ts +0 -1
  82. package/dist/components/registry/charts/bar-chart-card.js +40 -26
  83. package/dist/components/registry/charts/line-chart-card.js +2 -2
  84. package/dist/components/registry/dashboard-01/section-cards.d.ts +2 -0
  85. package/dist/components/registry/dashboard-01/section-cards.js +42 -35
  86. package/dist/components/registry/dashboardcn/bar-list.js +18 -11
  87. package/dist/components/registry/dashboardcn/distribution-bar.js +1 -1
  88. package/dist/components/registry/dashboardcn/kpi-row-card.d.ts +29 -0
  89. package/dist/components/registry/dashboardcn/kpi-row-card.js +81 -0
  90. package/dist/components/registry/dashboardcn/sparkline.d.ts +22 -0
  91. package/dist/components/registry/dashboardcn/sparkline.js +117 -0
  92. package/dist/components/registry/heatmap/calendar-heatmap.d.ts +4 -2
  93. package/dist/components/registry/heatmap/calendar-heatmap.js +74 -33
  94. package/dist/components/registry/heatmap/status-heatmap.d.ts +5 -3
  95. package/dist/components/registry/heatmap/status-heatmap.js +37 -15
  96. package/dist/components/registry/heatmap/weekday-heatmap.d.ts +9 -3
  97. package/dist/components/registry/heatmap/weekday-heatmap.js +82 -47
  98. package/dist/components/registry/niko-table/core/data-table-context.d.ts +18 -1
  99. package/dist/components/registry/niko-table/core/data-table-context.js +7 -1
  100. package/dist/components/registry/niko-table/core/data-table-grouped-row.js +3 -1
  101. package/dist/components/registry/niko-table/core/data-table-root.js +39 -4
  102. package/dist/components/registry/niko-table/core/data-table-structure.js +17 -12
  103. package/dist/components/registry/niko-table/core/data-table.d.ts +2 -2
  104. package/dist/components/registry/niko-table/core/data-table.js +5 -1
  105. package/dist/components/registry/niko-table/filters/table-faceted-filter.js +4 -4
  106. package/dist/components/registry/niko-table/filters/table-search-filter.js +1 -1
  107. package/dist/components/registry/niko-table/lib/flex-columns.d.ts +1 -1
  108. package/dist/components/registry/niko-table/lib/flex-columns.js +3 -3
  109. package/dist/components/registry/niko-table/lib/styles.d.ts +1 -1
  110. package/dist/components/registry/niko-table/lib/styles.js +3 -3
  111. package/dist/components/registry/niko-table/types/index.d.ts +9 -0
  112. package/dist/components/registry/niko-table/ui/table.js +2 -2
  113. package/dist/components/registry/sidebar-07/app-sidebar.d.ts +1 -1
  114. package/dist/components/registry/sidebar-07/app-sidebar.js +3 -1
  115. package/dist/components/registry/sidebar-07/nav-main.d.ts +2 -1
  116. package/dist/components/registry/sidebar-07/nav-main.js +16 -3
  117. package/dist/components/siyahi/callout.d.ts +24 -0
  118. package/dist/components/siyahi/callout.js +40 -0
  119. package/dist/components/siyahi/change-bar.d.ts +21 -0
  120. package/dist/components/siyahi/change-bar.js +35 -0
  121. package/dist/components/siyahi/data-bar.d.ts +19 -0
  122. package/dist/components/siyahi/data-bar.js +29 -0
  123. package/dist/components/siyahi/data-table-compact-columns-toggle.d.ts +4 -0
  124. package/dist/components/siyahi/data-table-compact-columns-toggle.js +19 -0
  125. package/dist/components/siyahi/data-table-footnote.d.ts +12 -0
  126. package/dist/components/siyahi/data-table-footnote.js +35 -0
  127. package/dist/components/siyahi/default-sidebar-open.d.ts +8 -0
  128. package/dist/components/siyahi/default-sidebar-open.js +13 -0
  129. package/dist/components/siyahi/page-hero.d.ts +25 -0
  130. package/dist/components/siyahi/page-hero.js +41 -0
  131. package/dist/components/siyahi/page-section.d.ts +4 -1
  132. package/dist/components/siyahi/page-section.js +6 -3
  133. package/dist/components/siyahi/page-toc.d.ts +20 -0
  134. package/dist/components/siyahi/page-toc.js +76 -0
  135. package/dist/components/siyahi/panel-grid.d.ts +22 -0
  136. package/dist/components/siyahi/panel-grid.js +34 -0
  137. package/dist/components/siyahi/quote.d.ts +12 -0
  138. package/dist/components/siyahi/quote.js +23 -0
  139. package/dist/components/siyahi/range-position.d.ts +24 -0
  140. package/dist/components/siyahi/range-position.js +105 -0
  141. package/dist/components/siyahi/siyahi-provider.d.ts +13 -2
  142. package/dist/components/siyahi/siyahi-provider.js +17 -4
  143. package/dist/components/siyahi/target-rows.d.ts +34 -0
  144. package/dist/components/siyahi/target-rows.js +97 -0
  145. package/dist/components/siyahi/treemap.d.ts +4 -1
  146. package/dist/components/siyahi/treemap.js +78 -28
  147. package/dist/components/siyahi/warning-alert.d.ts +10 -0
  148. package/dist/components/siyahi/warning-alert.js +20 -0
  149. package/dist/components/ui/accordion.js +5 -5
  150. package/dist/components/ui/alert.js +2 -2
  151. package/dist/components/ui/badge.js +1 -1
  152. package/dist/components/ui/breadcrumb.js +2 -2
  153. package/dist/components/ui/button.js +10 -10
  154. package/dist/components/ui/calendar.js +1 -1
  155. package/dist/components/ui/card.js +4 -4
  156. package/dist/components/ui/chart.js +1 -1
  157. package/dist/components/ui/code-block.js +13 -12
  158. package/dist/components/ui/command.js +7 -6
  159. package/dist/components/ui/context-menu.js +7 -7
  160. package/dist/components/ui/dialog.js +5 -5
  161. package/dist/components/ui/dropdown-menu.js +8 -8
  162. package/dist/components/ui/input-group.js +11 -11
  163. package/dist/components/ui/input.js +1 -1
  164. package/dist/components/ui/popover.js +3 -3
  165. package/dist/components/ui/progress.js +1 -1
  166. package/dist/components/ui/select.js +6 -6
  167. package/dist/components/ui/sheet.js +5 -5
  168. package/dist/components/ui/sidebar.js +17 -18
  169. package/dist/components/ui/skeleton.js +1 -1
  170. package/dist/components/ui/slider.js +2 -2
  171. package/dist/components/ui/table.js +2 -2
  172. package/dist/components/ui/tabs.js +2 -2
  173. package/dist/components/ui/textarea.js +1 -1
  174. package/dist/components/ui/toggle-group.js +2 -2
  175. package/dist/components/ui/toggle.js +4 -4
  176. package/dist/components/ui/tooltip.js +2 -2
  177. package/dist/index.d.ts +21 -7
  178. package/dist/index.js +18 -4
  179. package/dist/lib/chart-frame.d.ts +25 -7
  180. package/dist/lib/chart-frame.js +251 -127
  181. package/dist/lib/chart-series.d.ts +12 -6
  182. package/dist/lib/compact-columns.d.ts +19 -0
  183. package/dist/lib/compact-columns.js +55 -0
  184. package/dist/lib/format.d.ts +7 -2
  185. package/dist/lib/format.js +54 -16
  186. package/dist/lib/heatmap-navigation.d.ts +8 -0
  187. package/dist/lib/heatmap-navigation.js +49 -0
  188. package/dist/lib/treemap.js +6 -1
  189. package/dist/lib/use-element-width.d.ts +5 -0
  190. package/dist/lib/use-element-width.js +15 -0
  191. package/package.json +4 -1
  192. package/registry.lock.json +16 -0
  193. package/report.css +33 -32
  194. package/styles/siyahi.css +221 -39
  195. package/dist/lib/recharts.d.ts +0 -2
  196. package/dist/lib/recharts.js +0 -1
@@ -0,0 +1,76 @@
1
+ import { cn } from "cn";
2
+ import { ChevronRightIcon } from "lucide-react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { useEffect, useRef, useState } from "react";
5
+ //#region src/components/siyahi/page-toc.tsx
6
+ /**
7
+ * A long page's sections as one sticky "On this page" index. It stays at the top while the reader scrolls,
8
+ * underlines the section in view in the link colour, and scrolls sideways on a phone with the current link kept
9
+ * in sight.
10
+ */
11
+ function PageToc({ items, label = "On this page", className }) {
12
+ const nav = useRef(null);
13
+ const active = useActiveSection(items, nav);
14
+ const strip = useRef(null);
15
+ useEffect(() => {
16
+ const link = strip.current?.querySelector(`a[href="#${CSS.escape(active ?? "")}"]`);
17
+ const box = strip.current;
18
+ if (!link || !box) return;
19
+ const left = link.offsetLeft - box.clientWidth / 2 + link.offsetWidth / 2;
20
+ box.scrollTo({
21
+ left,
22
+ behavior: "smooth"
23
+ });
24
+ }, [active]);
25
+ return /* @__PURE__ */ jsx("nav", {
26
+ ref: nav,
27
+ "aria-label": label,
28
+ "data-slot": "page-toc",
29
+ className: cn("sticky top-0 z-10 -mx-4 border-b bg-background px-4 sm:mx-0 sm:px-0", className),
30
+ children: /* @__PURE__ */ jsxs("div", {
31
+ ref: strip,
32
+ className: "flex items-baseline gap-x-4 overflow-x-auto py-2.5 mask-r-from-90% [scrollbar-width:none] sm:mask-none",
33
+ children: [/* @__PURE__ */ jsxs("span", {
34
+ "aria-hidden": true,
35
+ className: "flex shrink-0 cursor-default items-center gap-1 self-center text-[0.6875rem] font-medium tracking-wider text-muted-foreground uppercase select-none",
36
+ children: [label, /* @__PURE__ */ jsx(ChevronRightIcon, { className: "size-3.5" })]
37
+ }), items.map((item) => /* @__PURE__ */ jsx("a", {
38
+ href: `#${item.id}`,
39
+ "aria-current": item.id === active ? "location" : void 0,
40
+ onClick: (event) => {
41
+ event.preventDefault();
42
+ document.getElementById(item.id)?.scrollIntoView({ behavior: "smooth" });
43
+ },
44
+ className: "shrink-0 text-sm whitespace-nowrap text-muted-foreground decoration-2 underline-offset-[6px] transition-colors hover:text-foreground hover:underline hover:decoration-border aria-[current=location]:font-medium aria-[current=location]:text-link aria-[current=location]:underline aria-[current=location]:decoration-current",
45
+ children: item.title
46
+ }, item.id))]
47
+ })
48
+ });
49
+ }
50
+ function useActiveSection(items, strip) {
51
+ const [active, setActive] = useState(items[0]?.id);
52
+ const ids = items.map((item) => item.id).join(" ");
53
+ useEffect(() => {
54
+ const sections = ids.split(" ").flatMap((id) => document.getElementById(id) ?? []);
55
+ if (sections.length === 0) return;
56
+ const update = () => {
57
+ const stripBottom = strip.current?.getBoundingClientRect().bottom ?? 0;
58
+ const line = (section) => Math.max(stripBottom, Number.parseFloat(getComputedStyle(section).scrollMarginTop) || 0, innerHeight * .3);
59
+ const reached = sections.filter((section) => section.getBoundingClientRect().top <= line(section) + 1);
60
+ setActive((reached.at(-1) ?? sections[0]).id);
61
+ };
62
+ update();
63
+ addEventListener("scroll", update, {
64
+ passive: true,
65
+ capture: true
66
+ });
67
+ addEventListener("resize", update);
68
+ return () => {
69
+ removeEventListener("scroll", update, { capture: true });
70
+ removeEventListener("resize", update);
71
+ };
72
+ }, [ids, strip]);
73
+ return active;
74
+ }
75
+ //#endregion
76
+ export { PageToc };
@@ -0,0 +1,22 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/components/siyahi/panel-grid.d.ts
3
+ declare const COLUMNS: {
4
+ readonly 1: "";
5
+ readonly 2: "@2xl/panels:grid-cols-2";
6
+ readonly 3: "@2xl/panels:grid-cols-2 @5xl/panels:grid-cols-3";
7
+ readonly 4: "@2xl/panels:grid-cols-2 @5xl/panels:grid-cols-4";
8
+ };
9
+ export interface PanelGridProps {
10
+ /** Blocks across on a wide page; two on a medium one, and one on a phone. */
11
+ columns?: keyof typeof COLUMNS;
12
+ children: ReactNode;
13
+ className?: string;
14
+ }
15
+ /**
16
+ * Data blocks side by side: chart cards, tables, a MetricStrip. On a ruled surface a hairline parts them across and
17
+ * down, with a rule above and below the grid; open leaves whitespace between them, and card a gap between boxes.
18
+ * Each block's left and top edges carry its rules, and the grid clips the ones on its own edges.
19
+ */
20
+ export declare function PanelGrid({ columns, children, className }: PanelGridProps): import("react").JSX.Element;
21
+ //#endregion
22
+ export {};
@@ -0,0 +1,34 @@
1
+ import { useSurface } from "./siyahi-provider.js";
2
+ import { cn } from "cn";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { Children } from "react";
5
+ //#region src/components/siyahi/panel-grid.tsx
6
+ const COLUMNS = {
7
+ 1: "",
8
+ 2: "@2xl/panels:grid-cols-2",
9
+ 3: "@2xl/panels:grid-cols-2 @5xl/panels:grid-cols-3",
10
+ 4: "@2xl/panels:grid-cols-2 @5xl/panels:grid-cols-4"
11
+ };
12
+ /**
13
+ * Data blocks side by side: chart cards, tables, a MetricStrip. On a ruled surface a hairline parts them across and
14
+ * down, with a rule above and below the grid; open leaves whitespace between them, and card a gap between boxes.
15
+ * Each block's left and top edges carry its rules, and the grid clips the ones on its own edges.
16
+ */
17
+ function PanelGrid({ columns = 2, children, className }) {
18
+ const surface = useSurface();
19
+ const ruled = surface === "ruled";
20
+ return /* @__PURE__ */ jsx("div", {
21
+ "data-slot": "panel-grid",
22
+ className: cn("@container/panels", ruled && "overflow-clip border-y", className),
23
+ children: /* @__PURE__ */ jsx("div", {
24
+ className: cn("grid grid-cols-1", COLUMNS[columns], ruled ? "-mt-px -ml-px" : surface === "open" ? "gap-x-8 gap-y-6" : "gap-4"),
25
+ children: Children.map(children, (child) => /* @__PURE__ */ jsx("div", {
26
+ "data-slot": "panel",
27
+ className: cn("min-w-0", ruled && "border-t border-l"),
28
+ children: child
29
+ }))
30
+ })
31
+ });
32
+ }
33
+ //#endregion
34
+ export { PanelGrid };
@@ -0,0 +1,12 @@
1
+ import { ComponentProps, ReactNode } from "react";
2
+ //#region src/components/siyahi/quote.d.ts
3
+ export interface QuoteProps extends ComponentProps<"blockquote"> {
4
+ /** Who said it, or where it is from, set under the quote. */
5
+ source?: ReactNode;
6
+ }
7
+ /**
8
+ * A quotation set apart from the prose on a muted panel, with its source under it. The panel is the whole box, not a
9
+ * stripe down one side.
10
+ */
11
+ export declare function Quote({ source, className, children, ...props }: QuoteProps): import("react").JSX.Element;
12
+ //#endregion
@@ -0,0 +1,23 @@
1
+ import { cn } from "cn";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ //#region src/components/siyahi/quote.tsx
4
+ /**
5
+ * A quotation set apart from the prose on a muted panel, with its source under it. The panel is the whole box, not a
6
+ * stripe down one side.
7
+ */
8
+ function Quote({ source, className, children, ...props }) {
9
+ return /* @__PURE__ */ jsxs("figure", {
10
+ "data-slot": "quote",
11
+ className: cn("flex flex-col gap-2 rounded-lg bg-muted/60 px-4 py-3", className),
12
+ children: [/* @__PURE__ */ jsx("blockquote", {
13
+ className: "text-pretty italic",
14
+ ...props,
15
+ children
16
+ }), source && /* @__PURE__ */ jsx("figcaption", {
17
+ className: "text-sm text-muted-foreground",
18
+ children: source
19
+ })]
20
+ });
21
+ }
22
+ //#endregion
23
+ export { Quote };
@@ -0,0 +1,24 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/components/siyahi/range-position.d.ts
3
+ export interface RangePositionProps {
4
+ low: number;
5
+ high: number;
6
+ value: number;
7
+ /** Names the low end: "52-week low". */
8
+ lowLabel?: string;
9
+ highLabel?: string;
10
+ /** Follows the percentage in the full variant: "of the way up the 52-week range". */
11
+ caption?: ReactNode;
12
+ /** Writes low, high and value; useFormat().money by default. */
13
+ valueFormatter?: (value: number) => string;
14
+ /** compact fits a table cell: the ends' figures either side of the track, nothing above it. */
15
+ variant?: "full" | "compact";
16
+ className?: string;
17
+ }
18
+ /**
19
+ * How far a value sits between a low and a high, such as a price in its 52-week range: a track filled to the value
20
+ * with a hollow thumb on it, the ends labelled, and in the full variant the share written large with the value over
21
+ * the thumb.
22
+ */
23
+ export declare function RangePosition({ low, high, value, lowLabel, highLabel, caption, valueFormatter, variant, className }: RangePositionProps): import("react").JSX.Element;
24
+ //#endregion
@@ -0,0 +1,105 @@
1
+ import { useFormat } from "../../lib/format.js";
2
+ import { cn } from "cn";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/components/siyahi/range-position.tsx
5
+ /**
6
+ * How far a value sits between a low and a high, such as a price in its 52-week range: a track filled to the value
7
+ * with a hollow thumb on it, the ends labelled, and in the full variant the share written large with the value over
8
+ * the thumb.
9
+ */
10
+ function RangePosition({ low, high, value, lowLabel = "Low", highLabel = "High", caption = "of the way up the range", valueFormatter, variant = "full", className }) {
11
+ const f = useFormat();
12
+ const write = valueFormatter ?? f.money;
13
+ const share = high > low ? Math.min(1, Math.max(0, (value - low) / (high - low))) : 0;
14
+ const at = `${(share * 100).toFixed(2)}%`;
15
+ const track = /* @__PURE__ */ jsxs("div", {
16
+ role: "meter",
17
+ "aria-label": `${lowLabel} to ${highLabel}`,
18
+ "aria-valuemin": low,
19
+ "aria-valuemax": high,
20
+ "aria-valuenow": value,
21
+ "aria-valuetext": `${write(value)}, ${f.pct(share, 0)} of the way from ${write(low)} to ${write(high)}`,
22
+ className: "relative h-1.5 min-w-12 flex-1 rounded-full bg-muted",
23
+ children: [/* @__PURE__ */ jsx("div", {
24
+ "data-slot": "range-fill",
25
+ className: "absolute inset-y-0 left-0 rounded-full bg-foreground",
26
+ style: { width: at }
27
+ }), /* @__PURE__ */ jsx("div", {
28
+ "data-slot": "range-thumb",
29
+ className: cn("absolute top-1/2 -translate-1/2 rounded-full border-2 border-foreground bg-card", variant === "full" ? "size-3.5" : "size-2.5"),
30
+ style: { left: at }
31
+ })]
32
+ });
33
+ if (variant === "compact") return /* @__PURE__ */ jsxs("div", {
34
+ "data-slot": "range-position",
35
+ className: cn("flex items-center gap-2 text-xs text-muted-foreground tabular-nums", className),
36
+ children: [
37
+ /* @__PURE__ */ jsx("span", {
38
+ className: "min-w-12 text-right",
39
+ children: write(low)
40
+ }),
41
+ track,
42
+ /* @__PURE__ */ jsx("span", {
43
+ className: "min-w-12",
44
+ children: write(high)
45
+ })
46
+ ]
47
+ });
48
+ return /* @__PURE__ */ jsxs("div", {
49
+ "data-slot": "range-position",
50
+ className: cn("grid gap-3", className),
51
+ children: [/* @__PURE__ */ jsxs("p", {
52
+ className: "flex flex-wrap items-baseline gap-x-2",
53
+ children: [/* @__PURE__ */ jsx("span", {
54
+ className: "text-4xl font-semibold tracking-tight tabular-nums",
55
+ children: f.pct(share, 0)
56
+ }), /* @__PURE__ */ jsx("span", {
57
+ className: "text-sm text-muted-foreground",
58
+ children: caption
59
+ })]
60
+ }), /* @__PURE__ */ jsxs("div", {
61
+ className: "grid gap-1.5",
62
+ children: [
63
+ /* @__PURE__ */ jsx("div", {
64
+ className: "relative h-5",
65
+ children: /* @__PURE__ */ jsx("span", {
66
+ "data-slot": "range-value",
67
+ className: "absolute text-sm font-semibold whitespace-nowrap tabular-nums",
68
+ style: {
69
+ left: at,
70
+ transform: `translateX(-${at})`
71
+ },
72
+ children: write(value)
73
+ })
74
+ }),
75
+ /* @__PURE__ */ jsx("div", {
76
+ className: "flex",
77
+ children: track
78
+ }),
79
+ /* @__PURE__ */ jsxs("div", {
80
+ className: "mt-1 flex justify-between gap-4 text-xs text-muted-foreground",
81
+ children: [/* @__PURE__ */ jsxs("span", { children: [
82
+ lowLabel,
83
+ " ",
84
+ /* @__PURE__ */ jsx("span", {
85
+ className: "text-foreground tabular-nums",
86
+ children: write(low)
87
+ })
88
+ ] }), /* @__PURE__ */ jsxs("span", {
89
+ className: "text-right",
90
+ children: [
91
+ highLabel,
92
+ " ",
93
+ /* @__PURE__ */ jsx("span", {
94
+ className: "text-foreground tabular-nums",
95
+ children: write(high)
96
+ })
97
+ ]
98
+ })]
99
+ })
100
+ ]
101
+ })]
102
+ });
103
+ }
104
+ //#endregion
105
+ export { RangePosition };
@@ -1,12 +1,23 @@
1
1
  import { SiyahiLocale } from "../../lib/locale.js";
2
2
  import { ReactNode } from "react";
3
3
  //#region src/components/siyahi/siyahi-provider.d.ts
4
+ /**
5
+ * How a data block sits on the page. "ruled": no box, hairlines between blocks in a PanelGrid. "open": no box and no
6
+ * lines, the block's content level with the page's text. "card": shadcn's own card, a filled box with a 1px ring.
7
+ */
8
+ export type Surface = "ruled" | "open" | "card";
4
9
  export interface SiyahiProviderProps {
5
10
  /** Any setting left out keeps its default: en-IN, INR, Asia/Kolkata. */
6
11
  locale?: Partial<SiyahiLocale>;
12
+ /**
13
+ * Set it on a nested provider for one part of a page. Left out, a provider keeps the surface around it, so a
14
+ * provider that only changes the locale changes nothing else; the outermost default is "card".
15
+ */
16
+ surface?: Surface;
7
17
  children: ReactNode;
8
18
  }
9
- /** Wrap the app once. Carries the locale and the tooltip provider shadcn asks for. */
10
- export declare function SiyahiProvider({ locale, children }: SiyahiProviderProps): import("react").JSX.Element;
19
+ /** Wrap the app once. Carries the locale, the surface and the tooltip provider shadcn asks for. */
20
+ export declare function SiyahiProvider({ locale, surface, children }: SiyahiProviderProps): import("react").JSX.Element;
11
21
  export declare function useLocale(): SiyahiLocale;
22
+ export declare function useSurface(): Surface;
12
23
  //#endregion
@@ -4,8 +4,9 @@ import { jsx } from "react/jsx-runtime";
4
4
  import { createContext, use, useMemo } from "react";
5
5
  //#region src/components/siyahi/siyahi-provider.tsx
6
6
  const LocaleContext = createContext(defaultLocale);
7
- /** Wrap the app once. Carries the locale and the tooltip provider shadcn asks for. */
8
- function SiyahiProvider({ locale, children }) {
7
+ const SurfaceContext = createContext("card");
8
+ /** Wrap the app once. Carries the locale, the surface and the tooltip provider shadcn asks for. */
9
+ function SiyahiProvider({ locale, surface, children }) {
9
10
  const { numberLocale, currency, timeZone } = {
10
11
  ...defaultLocale,
11
12
  ...locale
@@ -19,13 +20,25 @@ function SiyahiProvider({ locale, children }) {
19
20
  currency,
20
21
  timeZone
21
22
  ]);
23
+ const around = use(SurfaceContext);
22
24
  return /* @__PURE__ */ jsx(LocaleContext, {
23
25
  value,
24
- children: /* @__PURE__ */ jsx(TooltipProvider, { children })
26
+ children: /* @__PURE__ */ jsx(SurfaceContext, {
27
+ value: surface ?? around,
28
+ children: /* @__PURE__ */ jsx(TooltipProvider, { children: surface ? /* @__PURE__ */ jsx("div", {
29
+ "data-slot": "siyahi-provider",
30
+ "data-surface": surface,
31
+ className: "contents",
32
+ children
33
+ }) : children })
34
+ })
25
35
  });
26
36
  }
27
37
  function useLocale() {
28
38
  return use(LocaleContext);
29
39
  }
40
+ function useSurface() {
41
+ return use(SurfaceContext);
42
+ }
30
43
  //#endregion
31
- export { SiyahiProvider, useLocale };
44
+ export { SiyahiProvider, useLocale, useSurface };
@@ -0,0 +1,34 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/components/siyahi/target-rows.d.ts
3
+ /** Where a row stands against its target. A warning is for a real problem, not merely a miss. */
4
+ export interface TargetStatus {
5
+ kind: "met" | "missed" | "warning";
6
+ /** A few words: "On target", "2.1 pts under", "Rebalance". */
7
+ label: string;
8
+ }
9
+ export interface TargetRow {
10
+ label: ReactNode;
11
+ /** A muted line under the label, such as the asset class. */
12
+ detail?: ReactNode;
13
+ value: number;
14
+ target: number;
15
+ /** Qualitative ranges behind the bar as [from, to]; each later band draws a grey step darker, so nest them. */
16
+ bands?: [number, number][];
17
+ status?: TargetStatus;
18
+ /** Tells rows apart when labels are not plain unique text. */
19
+ key?: string;
20
+ }
21
+ export interface TargetRowsProps {
22
+ rows: TargetRow[];
23
+ /** The scale every row shares; by default 0 to the largest value, target or band edge. */
24
+ domain?: [number, number];
25
+ /** Writes the value and the target; useFormat().count by default. */
26
+ valueFormatter?: (value: number) => string;
27
+ className?: string;
28
+ }
29
+ /**
30
+ * Bullet rows: each row's label, value and status beside a track where the value is a solid bar, the target a tall
31
+ * tick and the qualitative ranges grey bands. On a narrow card the label and value stack above the track.
32
+ */
33
+ export declare function TargetRows({ rows, domain, valueFormatter, className }: TargetRowsProps): import("react").JSX.Element;
34
+ //#endregion
@@ -0,0 +1,97 @@
1
+ import { useFormat } from "../../lib/format.js";
2
+ import { cn } from "cn";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/components/siyahi/target-rows.tsx
5
+ const GLYPH = {
6
+ met: "✓",
7
+ missed: "—",
8
+ warning: "⚠"
9
+ };
10
+ const BAND_DEPTH = [
11
+ 14,
12
+ 26,
13
+ 38
14
+ ];
15
+ /**
16
+ * Bullet rows: each row's label, value and status beside a track where the value is a solid bar, the target a tall
17
+ * tick and the qualitative ranges grey bands. On a narrow card the label and value stack above the track.
18
+ */
19
+ function TargetRows({ rows, domain, valueFormatter, className }) {
20
+ const f = useFormat();
21
+ const write = valueFormatter ?? f.count;
22
+ const [low, high] = domain ?? [0, Math.max(...rows.flatMap((row) => [
23
+ row.value,
24
+ row.target,
25
+ ...row.bands?.flat() ?? []
26
+ ]))];
27
+ const at = (value) => `${(Math.min(1, Math.max(0, (value - low) / (high - low || 1))) * 100).toFixed(2)}%`;
28
+ return /* @__PURE__ */ jsx("ul", {
29
+ "data-slot": "target-rows",
30
+ className: cn("@container/target divide-y", className),
31
+ children: rows.map((row, index) => /* @__PURE__ */ jsxs("li", {
32
+ "data-slot": "target-row",
33
+ className: "flex flex-col gap-3 py-3 @lg/target:flex-row @lg/target:items-center @lg/target:gap-6",
34
+ children: [/* @__PURE__ */ jsxs("div", {
35
+ className: "flex min-w-0 flex-col text-sm @lg/target:w-64 @lg/target:shrink-0",
36
+ children: [
37
+ /* @__PURE__ */ jsxs("div", {
38
+ className: "flex items-baseline justify-between gap-3",
39
+ children: [/* @__PURE__ */ jsx("span", {
40
+ className: "truncate font-medium",
41
+ children: row.label
42
+ }), /* @__PURE__ */ jsx("span", {
43
+ className: "shrink-0 text-base font-semibold tabular-nums",
44
+ children: write(row.value)
45
+ })]
46
+ }),
47
+ /* @__PURE__ */ jsxs("div", {
48
+ className: "flex justify-between gap-3 text-muted-foreground",
49
+ children: [/* @__PURE__ */ jsx("span", {
50
+ className: "truncate",
51
+ children: row.detail
52
+ }), /* @__PURE__ */ jsxs("span", {
53
+ className: "shrink-0 tabular-nums",
54
+ children: ["Target ", write(row.target)]
55
+ })]
56
+ }),
57
+ row.status && /* @__PURE__ */ jsxs("span", {
58
+ "data-slot": "target-status",
59
+ "data-kind": row.status.kind,
60
+ className: "mt-1 flex gap-1.5",
61
+ children: [/* @__PURE__ */ jsx("span", {
62
+ "aria-hidden": "true",
63
+ className: cn("w-4 text-center", row.status.kind === "warning" && "text-warning", row.status.kind === "missed" && "text-muted-foreground"),
64
+ children: GLYPH[row.status.kind]
65
+ }), row.status.label]
66
+ })
67
+ ]
68
+ }), /* @__PURE__ */ jsxs("div", {
69
+ "aria-hidden": "true",
70
+ className: "relative h-5 rounded-sm bg-muted @lg/target:flex-1",
71
+ children: [
72
+ row.bands?.map(([from, to], step) => /* @__PURE__ */ jsx("div", {
73
+ "data-slot": "target-band",
74
+ className: "absolute inset-y-0",
75
+ style: {
76
+ left: at(Math.min(from, to)),
77
+ right: `calc(100% - ${at(Math.max(from, to))})`,
78
+ background: `color-mix(in oklab, var(--foreground) ${BAND_DEPTH[Math.min(step, BAND_DEPTH.length - 1)]}%, var(--muted))`
79
+ }
80
+ }, `${from}:${to}`)),
81
+ /* @__PURE__ */ jsx("div", {
82
+ "data-slot": "target-value",
83
+ className: "absolute inset-y-1.5 left-0 bg-foreground",
84
+ style: { width: at(row.value) }
85
+ }),
86
+ /* @__PURE__ */ jsx("div", {
87
+ "data-slot": "target-tick",
88
+ className: "absolute -inset-y-1 w-0.5 -translate-x-1/2 bg-foreground ring-1 ring-card",
89
+ style: { left: at(row.target) }
90
+ })
91
+ ]
92
+ })]
93
+ }, row.key ?? (typeof row.label === "string" ? row.label : index)))
94
+ });
95
+ }
96
+ //#endregion
97
+ export { TargetRows };
@@ -15,7 +15,10 @@ export interface TreemapProps<T extends TreemapItem> {
15
15
  height: number;
16
16
  /** ±range: the change, as a fraction, that takes the deepest heat step. Default 0.05 (±5%); a range that is not a positive number uses the default. */
17
17
  range?: number;
18
- /** Gets the item under the pointer, and null when the pointer moves onto a group's name or leaves the map. */
18
+ /**
19
+ * Gets the item under a mouse, and null when it moves onto a group's name or leaves the map. A tap fires no hover:
20
+ * on a touch screen it selects, so the page shows the tile in place rather than in a card at the finger.
21
+ */
19
22
  onHover?: (item: T | null) => void;
20
23
  /** The selected item, matched by key, whose tile carries a ring. Pass back what onSelect gave. */
21
24
  selected?: T | null;