@siyahi/ui 0.1.9-next.3 → 0.1.9-next.31

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 (254) hide show
  1. package/DESIGN.md +251 -0
  2. package/README.md +94 -177
  3. package/THIRD_PARTY_NOTICES.md +11 -11
  4. package/agents/examples/accordion.tsx +39 -0
  5. package/agents/examples/alert.tsx +24 -0
  6. package/agents/examples/app-sidebar.tsx +40 -0
  7. package/agents/examples/avatar.tsx +24 -0
  8. package/agents/examples/badge.tsx +26 -0
  9. package/agents/examples/bar-list-labels.tsx +22 -0
  10. package/agents/examples/bar-list-sides.tsx +40 -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 +11 -0
  16. package/agents/examples/callout.tsx +33 -0
  17. package/agents/examples/card.tsx +36 -0
  18. package/agents/examples/change-bar.tsx +104 -0
  19. package/agents/examples/change-grid-money.tsx +36 -0
  20. package/agents/examples/change-grid.tsx +43 -0
  21. package/agents/examples/chart-area-log.tsx +45 -0
  22. package/agents/examples/chart-area.tsx +39 -0
  23. package/agents/examples/chart-bar-flows.tsx +32 -0
  24. package/agents/examples/chart-bar-hourly.tsx +28 -0
  25. package/agents/examples/chart-bar-losses.tsx +29 -0
  26. package/agents/examples/chart-bar-teams.tsx +72 -0
  27. package/agents/examples/chart-bar-years.tsx +42 -0
  28. package/agents/examples/chart-bar.tsx +56 -0
  29. package/agents/examples/chart-category-ticks.tsx +50 -0
  30. package/agents/examples/chart-line-events.tsx +47 -0
  31. package/agents/examples/chart-line-forecast.tsx +36 -0
  32. package/agents/examples/chart-line-log.tsx +39 -0
  33. package/agents/examples/chart-line-quiet.tsx +114 -0
  34. package/agents/examples/chart-line-timeline.tsx +41 -0
  35. package/agents/examples/chart-line.tsx +57 -0
  36. package/agents/examples/chart-panels.tsx +94 -0
  37. package/agents/examples/code-block.tsx +40 -0
  38. package/agents/examples/collapsible.tsx +18 -0
  39. package/agents/examples/command.tsx +29 -0
  40. package/agents/examples/context-menu.tsx +17 -0
  41. package/agents/examples/copy-button.tsx +8 -0
  42. package/agents/examples/data-bar.tsx +114 -0
  43. package/agents/examples/data-table-compact.tsx +93 -0
  44. package/agents/examples/data-table-filters.tsx +103 -0
  45. package/agents/examples/data-table.tsx +96 -0
  46. package/agents/examples/delta.tsx +18 -0
  47. package/agents/examples/dialog.tsx +28 -0
  48. package/agents/examples/distribution-bar-budget.tsx +30 -0
  49. package/agents/examples/distribution-bar-tug.tsx +74 -0
  50. package/agents/examples/drawdown-chart.tsx +35 -0
  51. package/agents/examples/dropdown-menu.tsx +31 -0
  52. package/agents/examples/field.tsx +108 -0
  53. package/agents/examples/formatters.tsx +42 -0
  54. package/agents/examples/heatmap-calendar-signed.tsx +67 -0
  55. package/agents/examples/heatmap-calendar.tsx +62 -0
  56. package/agents/examples/heatmap-status.tsx +61 -0
  57. package/agents/examples/heatmap-weekday.tsx +72 -0
  58. package/agents/examples/histogram-chart.tsx +28 -0
  59. package/agents/examples/input-states.tsx +23 -0
  60. package/agents/examples/input.tsx +17 -0
  61. package/agents/examples/local-time.tsx +14 -0
  62. package/agents/examples/metric-strip.tsx +46 -0
  63. package/agents/examples/overview-dashboard.tsx +180 -0
  64. package/agents/examples/page-hero.tsx +38 -0
  65. package/agents/examples/page-section.tsx +52 -0
  66. package/agents/examples/popover.tsx +23 -0
  67. package/agents/examples/price-chart.tsx +32 -0
  68. package/agents/examples/progress-tone.tsx +29 -0
  69. package/agents/examples/progress.tsx +10 -0
  70. package/agents/examples/range-position-table.tsx +113 -0
  71. package/agents/examples/range-position.tsx +55 -0
  72. package/agents/examples/scatter-chart-quadrants.tsx +63 -0
  73. package/agents/examples/scatter-chart-scales.tsx +46 -0
  74. package/agents/examples/scatter-chart.tsx +78 -0
  75. package/agents/examples/scroll-area.tsx +22 -0
  76. package/agents/examples/section-cards-select.tsx +28 -0
  77. package/agents/examples/section-cards-trend.tsx +32 -0
  78. package/agents/examples/section-cards.tsx +48 -0
  79. package/agents/examples/select.tsx +27 -0
  80. package/agents/examples/separator.tsx +13 -0
  81. package/agents/examples/sheet.tsx +15 -0
  82. package/agents/examples/skeleton.tsx +11 -0
  83. package/agents/examples/slider.tsx +5 -0
  84. package/agents/examples/slope-chart-market.tsx +33 -0
  85. package/agents/examples/slope-chart.tsx +26 -0
  86. package/agents/examples/stale-blocks.tsx +56 -0
  87. package/agents/examples/surfaces.tsx +116 -0
  88. package/agents/examples/table.tsx +60 -0
  89. package/agents/examples/tabs.tsx +16 -0
  90. package/agents/examples/target-rows.tsx +74 -0
  91. package/agents/examples/toggle-group.tsx +12 -0
  92. package/agents/examples/toggle.tsx +11 -0
  93. package/agents/examples/tooltip.tsx +13 -0
  94. package/agents/examples/treemap.tsx +93 -0
  95. package/agents/examples/waterfall-chart-stores.tsx +27 -0
  96. package/agents/examples/waterfall-chart.tsx +37 -0
  97. package/agents/manifest.json +1391 -0
  98. package/agents/report-rules.json +7 -0
  99. package/dist/components/registry/charts/area-chart-card.d.ts +7 -3
  100. package/dist/components/registry/charts/area-chart-card.js +56 -10
  101. package/dist/components/registry/charts/bar-chart-card.d.ts +1 -1
  102. package/dist/components/registry/charts/bar-chart-card.js +20 -22
  103. package/dist/components/registry/charts/line-chart-card.d.ts +3 -3
  104. package/dist/components/registry/charts/line-chart-card.js +44 -9
  105. package/dist/components/registry/dashboard-01/section-cards.d.ts +6 -0
  106. package/dist/components/registry/dashboard-01/section-cards.js +51 -35
  107. package/dist/components/registry/dashboardcn/bar-list.js +17 -10
  108. package/dist/components/registry/dashboardcn/distribution-bar.js +6 -4
  109. package/dist/components/registry/dashboardcn/kpi-row-card.d.ts +29 -0
  110. package/dist/components/registry/dashboardcn/kpi-row-card.js +81 -0
  111. package/dist/components/registry/dashboardcn/sparkline.d.ts +22 -0
  112. package/dist/components/registry/dashboardcn/sparkline.js +117 -0
  113. package/dist/components/registry/heatmap/calendar-heatmap.d.ts +11 -3
  114. package/dist/components/registry/heatmap/calendar-heatmap.js +164 -45
  115. package/dist/components/registry/heatmap/status-heatmap.d.ts +5 -3
  116. package/dist/components/registry/heatmap/status-heatmap.js +115 -54
  117. package/dist/components/registry/heatmap/weekday-heatmap.d.ts +9 -3
  118. package/dist/components/registry/heatmap/weekday-heatmap.js +83 -53
  119. package/dist/components/registry/niko-table/core/data-table-context.d.ts +18 -1
  120. package/dist/components/registry/niko-table/core/data-table-context.js +7 -1
  121. package/dist/components/registry/niko-table/core/data-table-grouped-row.js +3 -1
  122. package/dist/components/registry/niko-table/core/data-table-root.js +39 -4
  123. package/dist/components/registry/niko-table/core/data-table-structure.js +17 -12
  124. package/dist/components/registry/niko-table/core/data-table.d.ts +2 -2
  125. package/dist/components/registry/niko-table/core/data-table.js +5 -1
  126. package/dist/components/registry/niko-table/filters/table-faceted-filter.js +5 -5
  127. package/dist/components/registry/niko-table/filters/table-search-filter.js +1 -1
  128. package/dist/components/registry/niko-table/lib/flex-columns.d.ts +1 -1
  129. package/dist/components/registry/niko-table/lib/flex-columns.js +3 -3
  130. package/dist/components/registry/niko-table/lib/styles.d.ts +1 -1
  131. package/dist/components/registry/niko-table/lib/styles.js +3 -3
  132. package/dist/components/registry/niko-table/types/index.d.ts +9 -0
  133. package/dist/components/registry/niko-table/ui/table.js +2 -2
  134. package/dist/components/registry/sidebar-07/app-sidebar.d.ts +1 -1
  135. package/dist/components/registry/sidebar-07/app-sidebar.js +3 -1
  136. package/dist/components/registry/sidebar-07/nav-main.d.ts +2 -1
  137. package/dist/components/registry/sidebar-07/nav-main.js +16 -3
  138. package/dist/components/siyahi/callout.d.ts +17 -0
  139. package/dist/components/siyahi/callout.js +34 -0
  140. package/dist/components/siyahi/change-bar.d.ts +21 -0
  141. package/dist/components/siyahi/change-bar.js +35 -0
  142. package/dist/components/siyahi/change-grid.d.ts +31 -0
  143. package/dist/components/siyahi/change-grid.js +74 -0
  144. package/dist/components/siyahi/data-bar.d.ts +19 -0
  145. package/dist/components/siyahi/data-bar.js +29 -0
  146. package/dist/components/siyahi/data-table-compact-columns-toggle.d.ts +4 -0
  147. package/dist/components/siyahi/data-table-compact-columns-toggle.js +19 -0
  148. package/dist/components/siyahi/data-table-footnote.d.ts +12 -0
  149. package/dist/components/siyahi/data-table-footnote.js +35 -0
  150. package/dist/components/siyahi/default-sidebar-open.d.ts +8 -0
  151. package/dist/components/siyahi/default-sidebar-open.js +13 -0
  152. package/dist/components/siyahi/delta.d.ts +5 -1
  153. package/dist/components/siyahi/delta.js +14 -9
  154. package/dist/components/siyahi/drawdown-chart.d.ts +34 -0
  155. package/dist/components/siyahi/drawdown-chart.js +102 -0
  156. package/dist/components/siyahi/histogram-chart.d.ts +57 -0
  157. package/dist/components/siyahi/histogram-chart.js +134 -0
  158. package/dist/components/siyahi/page-hero.d.ts +23 -0
  159. package/dist/components/siyahi/page-hero.js +43 -0
  160. package/dist/components/siyahi/page-section.d.ts +4 -1
  161. package/dist/components/siyahi/page-section.js +6 -3
  162. package/dist/components/siyahi/page-toc.d.ts +20 -0
  163. package/dist/components/siyahi/page-toc.js +76 -0
  164. package/dist/components/siyahi/panel-grid.d.ts +24 -0
  165. package/dist/components/siyahi/panel-grid.js +37 -0
  166. package/dist/components/siyahi/quote.d.ts +12 -0
  167. package/dist/components/siyahi/quote.js +23 -0
  168. package/dist/components/siyahi/range-position.d.ts +24 -0
  169. package/dist/components/siyahi/range-position.js +105 -0
  170. package/dist/components/siyahi/scale-toggle.d.ts +32 -0
  171. package/dist/components/siyahi/scale-toggle.js +61 -0
  172. package/dist/components/siyahi/scatter-chart.d.ts +69 -0
  173. package/dist/components/siyahi/scatter-chart.js +395 -0
  174. package/dist/components/siyahi/siyahi-provider.d.ts +15 -2
  175. package/dist/components/siyahi/siyahi-provider.js +17 -4
  176. package/dist/components/siyahi/slope-chart.d.ts +35 -0
  177. package/dist/components/siyahi/slope-chart.js +159 -0
  178. package/dist/components/siyahi/stale-note.d.ts +9 -0
  179. package/dist/components/siyahi/stale-note.js +12 -0
  180. package/dist/components/siyahi/status-alert.d.ts +15 -0
  181. package/dist/components/siyahi/status-alert.js +29 -0
  182. package/dist/components/siyahi/status-badge.d.ts +15 -0
  183. package/dist/components/siyahi/status-badge.js +24 -0
  184. package/dist/components/siyahi/target-rows.d.ts +34 -0
  185. package/dist/components/siyahi/target-rows.js +97 -0
  186. package/dist/components/siyahi/tone-progress.d.ts +1 -1
  187. package/dist/components/siyahi/tone-progress.js +1 -1
  188. package/dist/components/siyahi/treemap.d.ts +8 -5
  189. package/dist/components/siyahi/treemap.js +80 -34
  190. package/dist/components/siyahi/waterfall-chart.d.ts +51 -0
  191. package/dist/components/siyahi/waterfall-chart.js +147 -0
  192. package/dist/components/ui/accordion.js +5 -5
  193. package/dist/components/ui/alert.js +2 -2
  194. package/dist/components/ui/badge.js +1 -1
  195. package/dist/components/ui/breadcrumb.js +2 -2
  196. package/dist/components/ui/button.js +10 -10
  197. package/dist/components/ui/calendar.js +1 -1
  198. package/dist/components/ui/card.js +4 -4
  199. package/dist/components/ui/chart.js +1 -1
  200. package/dist/components/ui/code-block.js +13 -12
  201. package/dist/components/ui/command.js +7 -6
  202. package/dist/components/ui/context-menu.js +7 -7
  203. package/dist/components/ui/dialog.js +5 -5
  204. package/dist/components/ui/dropdown-menu.js +8 -8
  205. package/dist/components/ui/field.d.ts +26 -0
  206. package/dist/components/ui/field.js +109 -0
  207. package/dist/components/ui/input-group.js +11 -11
  208. package/dist/components/ui/input.js +1 -1
  209. package/dist/components/ui/label.d.ts +5 -0
  210. package/dist/components/ui/label.js +13 -0
  211. package/dist/components/ui/popover.js +3 -3
  212. package/dist/components/ui/progress.js +1 -1
  213. package/dist/components/ui/select.js +6 -6
  214. package/dist/components/ui/sheet.js +5 -5
  215. package/dist/components/ui/sidebar.js +17 -18
  216. package/dist/components/ui/skeleton.js +1 -1
  217. package/dist/components/ui/slider.js +2 -2
  218. package/dist/components/ui/table.js +2 -2
  219. package/dist/components/ui/tabs.js +2 -2
  220. package/dist/components/ui/textarea.js +1 -1
  221. package/dist/components/ui/toggle-group.js +2 -2
  222. package/dist/components/ui/toggle.js +4 -4
  223. package/dist/components/ui/tooltip.js +2 -2
  224. package/dist/index.d.ts +35 -8
  225. package/dist/index.js +30 -4
  226. package/dist/lib/chart-frame.d.ts +51 -7
  227. package/dist/lib/chart-frame.js +390 -133
  228. package/dist/lib/chart-marks.d.ts +83 -0
  229. package/dist/lib/chart-marks.js +216 -0
  230. package/dist/lib/chart-series.d.ts +42 -10
  231. package/dist/lib/compact-columns.d.ts +19 -0
  232. package/dist/lib/compact-columns.js +55 -0
  233. package/dist/lib/fit-text.d.ts +6 -0
  234. package/dist/lib/fit-text.js +11 -0
  235. package/dist/lib/format.d.ts +8 -3
  236. package/dist/lib/format.js +55 -17
  237. package/dist/lib/heat.d.ts +7 -0
  238. package/dist/lib/heat.js +14 -0
  239. package/dist/lib/heatmap-navigation.d.ts +8 -0
  240. package/dist/lib/heatmap-navigation.js +49 -0
  241. package/dist/lib/scatter.d.ts +88 -0
  242. package/dist/lib/scatter.js +179 -0
  243. package/dist/lib/ticks.d.ts +27 -0
  244. package/dist/lib/ticks.js +67 -0
  245. package/dist/lib/tone.d.ts +36 -0
  246. package/dist/lib/tone.js +35 -0
  247. package/dist/lib/treemap.d.ts +0 -5
  248. package/dist/lib/treemap.js +1 -11
  249. package/dist/lib/use-element-width.d.ts +5 -0
  250. package/dist/lib/use-element-width.js +15 -0
  251. package/package.json +5 -1
  252. package/registry.lock.json +16 -0
  253. package/report.css +63 -47
  254. package/styles/siyahi.css +708 -55
@@ -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 bg-muted",
23
+ children: [/* @__PURE__ */ jsx("div", {
24
+ "data-slot": "range-fill",
25
+ className: "absolute inset-y-0 left-0 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 };
@@ -0,0 +1,32 @@
1
+ import { AxisScale } from "../../lib/ticks.js";
2
+ import { ReactNode } from "react";
3
+ //#region src/components/siyahi/scale-toggle.d.ts
4
+ /** Why Log is disabled when a value is at or below zero. */
5
+ export declare const LOG_BLOCKED = "Log needs every value above zero";
6
+ export interface ScaleToggleProps {
7
+ /** The group's accessible name, such as "Share of book scale". */
8
+ label: string;
9
+ /** The axis' name shown before the buttons, for a card with a toggle on each axis. */
10
+ caption?: string;
11
+ value: AxisScale;
12
+ onValueChange: (scale: AxisScale) => void;
13
+ /** Why log cannot draw this data, such as a value at or below zero: Log is disabled and this shows beside it. */
14
+ logBlocked?: string;
15
+ }
16
+ /** Linear and Log buttons for one chart axis, in the header's toggle style. */
17
+ export declare function ScaleToggle({ label, caption, value, onValueChange, logBlocked }: ScaleToggleProps): import("react").JSX.Element;
18
+ export interface AxisScaleOptions extends Omit<ScaleToggleProps, "value" | "onValueChange"> {
19
+ /** The page's scale: the first selection. */
20
+ initial: AxisScale;
21
+ /** Show the buttons. */
22
+ toggle: boolean;
23
+ }
24
+ /**
25
+ * The scale an axis draws on, and its buttons when `toggle` is set. The page's scale is the first selection; after
26
+ * that the reader's pick holds. Log falls back to linear while `logBlocked` says why it cannot draw the data.
27
+ */
28
+ export declare function useAxisScale({ initial, toggle, ...buttons }: AxisScaleOptions): {
29
+ scale: AxisScale;
30
+ buttons: ReactNode;
31
+ };
32
+ //#endregion
@@ -0,0 +1,61 @@
1
+ import { ToggleGroup, ToggleGroupItem } from "../ui/toggle-group.js";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useId, useState } from "react";
4
+ //#region src/components/siyahi/scale-toggle.tsx
5
+ /** Why Log is disabled when a value is at or below zero. */
6
+ const LOG_BLOCKED = "Log needs every value above zero";
7
+ /** Linear and Log buttons for one chart axis, in the header's toggle style. */
8
+ function ScaleToggle({ label, caption, value, onValueChange, logBlocked }) {
9
+ const reason = useId();
10
+ return /* @__PURE__ */ jsxs("div", {
11
+ "data-slot": "scale-toggle",
12
+ className: "flex flex-wrap items-center gap-x-2 gap-y-1",
13
+ children: [
14
+ caption && /* @__PURE__ */ jsx("span", {
15
+ className: "text-xs text-muted-foreground",
16
+ children: caption
17
+ }),
18
+ /* @__PURE__ */ jsxs(ToggleGroup, {
19
+ value: [value],
20
+ onValueChange: ([next]) => next && onValueChange(next === "log" ? "log" : "linear"),
21
+ variant: "outline",
22
+ size: "sm",
23
+ spacing: 0,
24
+ "aria-label": label,
25
+ "aria-describedby": logBlocked ? reason : void 0,
26
+ children: [/* @__PURE__ */ jsx(ToggleGroupItem, {
27
+ value: "linear",
28
+ children: "Linear"
29
+ }), /* @__PURE__ */ jsx(ToggleGroupItem, {
30
+ value: "log",
31
+ disabled: logBlocked !== void 0,
32
+ children: "Log"
33
+ })]
34
+ }),
35
+ logBlocked && /* @__PURE__ */ jsx("span", {
36
+ id: reason,
37
+ className: "text-xs text-muted-foreground",
38
+ children: logBlocked
39
+ })
40
+ ]
41
+ });
42
+ }
43
+ /**
44
+ * The scale an axis draws on, and its buttons when `toggle` is set. The page's scale is the first selection; after
45
+ * that the reader's pick holds. Log falls back to linear while `logBlocked` says why it cannot draw the data.
46
+ */
47
+ function useAxisScale({ initial, toggle, ...buttons }) {
48
+ const [picked, setPicked] = useState(initial);
49
+ const wanted = toggle ? picked : initial;
50
+ const scale = buttons.logBlocked ? "linear" : wanted;
51
+ return {
52
+ scale,
53
+ buttons: toggle ? /* @__PURE__ */ jsx(ScaleToggle, {
54
+ ...buttons,
55
+ value: scale,
56
+ onValueChange: setPicked
57
+ }) : null
58
+ };
59
+ }
60
+ //#endregion
61
+ export { LOG_BLOCKED, ScaleToggle, useAxisScale };
@@ -0,0 +1,69 @@
1
+ import { AxisScale } from "../../lib/ticks.js";
2
+ import { ScatterQuadrants } from "../../lib/scatter.js";
3
+ import { ReactNode } from "react";
4
+ //#region src/components/siyahi/scatter-chart.d.ts
5
+ export interface ScatterPoint {
6
+ name: string;
7
+ /** Across. */
8
+ x: number;
9
+ /** Up. `null` when unknown: the point is not drawn, so say on the page how many are missing. */
10
+ y: number | null;
11
+ /** Unique key when names repeat, such as one product sold in two regions. Defaults to `name`. */
12
+ key?: string;
13
+ /**
14
+ * A weight, such as a holding's value: the dot's area follows it. Give every point a size, or none. A size that is
15
+ * not a positive number draws the smallest dot and leaves the others' sizes as they are.
16
+ */
17
+ size?: number;
18
+ }
19
+ /** One tooltip row: a label and its figure, such as ["Sales", "₹9.8L"]. */
20
+ export type ScatterDetail = readonly [label: string, value: string];
21
+ export interface ScatterChartCardProps<T extends ScatterPoint> {
22
+ title: ReactNode;
23
+ description?: ReactNode;
24
+ /** A scope badge or a toggle, top right of the card, before any scale buttons. */
25
+ action?: ReactNode;
26
+ /** Most important first: earlier points take the labels. */
27
+ points: T[];
28
+ /** Height of the plot, in pixels. */
29
+ height: number;
30
+ /** What the x axis measures, under it, such as "Share of sales". */
31
+ xLabel: string;
32
+ /** What the y axis measures, beside it, such as "Growth on last year". */
33
+ yLabel: string;
34
+ /**
35
+ * "log" spreads values across powers of ten, for sizes that run from tiny to large. With xScaleToggle it is the
36
+ * first selection. Log draws only when every x is above zero; otherwise the axis is linear.
37
+ */
38
+ xScale?: AxisScale;
39
+ /** Linear and Log buttons for the x axis in the header, so a reader can switch. */
40
+ xScaleToggle?: boolean;
41
+ /** As xScale, for the y axis: log draws only when every y is above zero. */
42
+ yScale?: AxisScale;
43
+ /** Linear and Log buttons for the y axis in the header. */
44
+ yScaleToggle?: boolean;
45
+ /** The x ticks and the tooltip's x figure. Defaults to the locale's numbers. */
46
+ xFormatter?: (value: number) => string;
47
+ /** The y ticks and the tooltip's y figure. Defaults to the locale's numbers. */
48
+ yFormatter?: (value: number) => string;
49
+ /** How many points get their name beside the dot, at most; a name with no free spot is left to the tooltip. */
50
+ labels?: number;
51
+ /** The tooltip's rows under the point's name, and what a screen reader hears. Defaults to the two axes' figures. */
52
+ details?: (point: T) => readonly ScatterDetail[];
53
+ /** The point that carries a ring, matched by key; pass back what onSelect gave. */
54
+ selected?: T | null;
55
+ /** Gets a tapped or keyed point, and null on a second tap, Escape or a tap on the plot. */
56
+ onSelect?: (point: T | null) => void;
57
+ /** Lines under the chart, such as a caption or how many points are not drawn. */
58
+ footer?: ReactNode;
59
+ /** Dashed lines at a value on each axis, splitting the plot into four, and the corners' names. */
60
+ quadrants?: ScatterQuadrants;
61
+ /** Names the size in the tooltip, such as "Value". Defaults to "Size". */
62
+ sizeLabel?: string;
63
+ /** The tooltip's size figure. Defaults to the locale's numbers. */
64
+ sizeFormatter?: (value: number) => string;
65
+ }
66
+ /** Two measures per item as dots, such as size against growth, with the leading names beside their dots. */
67
+ export declare function ScatterChartCard<T extends ScatterPoint>({ title, description, action, points, height, xLabel, yLabel, xScale, xScaleToggle, yScale, yScaleToggle, xFormatter, yFormatter, labels, details, selected, onSelect, footer, quadrants, sizeLabel, sizeFormatter }: ScatterChartCardProps<T>): import("react").JSX.Element;
68
+ //#endregion
69
+ export type { ScatterQuadrants };