@timefoldai/viz-react 0.0.0-stage → 0.1.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.
Files changed (289) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +240 -2
  3. package/dist/THIRD-PARTY-NOTICES.txt +99 -0
  4. package/dist/a11y/AccessibleTable.d.mts +42 -0
  5. package/dist/a11y/AccessibleTable.mjs +82 -0
  6. package/dist/a11y/activation.d.mts +4 -0
  7. package/dist/a11y/activation.mjs +0 -0
  8. package/dist/analytics/AnalyticsProvider.d.mts +16 -0
  9. package/dist/analytics/AnalyticsProvider.mjs +32 -0
  10. package/dist/assets/Inter-latin-ext.woff2 +0 -0
  11. package/dist/badge/Badge.css +122 -0
  12. package/dist/badge/Badge.d.mts +50 -0
  13. package/dist/badge/Badge.mjs +145 -0
  14. package/dist/badge/Badge.module.css.mjs +15 -0
  15. package/dist/badge/BadgeFacetGroup.d.mts +23 -0
  16. package/dist/badge/BadgeFacetGroup.mjs +220 -0
  17. package/dist/badge/BadgeGroup.d.mts +13 -0
  18. package/dist/badge/BadgeGroup.mjs +53 -0
  19. package/dist/badge/BadgeList.d.mts +14 -0
  20. package/dist/badge/BadgeList.mjs +15 -0
  21. package/dist/badge/badge-facet-fit.d.mts +18 -0
  22. package/dist/badge/badge-facet-fit.mjs +50 -0
  23. package/dist/badge/badge-item.d.mts +19 -0
  24. package/dist/badge/badge-item.mjs +23 -0
  25. package/dist/button/CopyButton.d.mts +12 -0
  26. package/dist/button/CopyButton.mjs +52 -0
  27. package/dist/button/ShowAllButton.d.mts +14 -0
  28. package/dist/button/ShowAllButton.mjs +61 -0
  29. package/dist/button/ShowMoreButton.d.mts +13 -0
  30. package/dist/button/ShowMoreButton.mjs +51 -0
  31. package/dist/button/SolveButton.d.mts +16 -0
  32. package/dist/button/SolveButton.mjs +56 -0
  33. package/dist/charts/BarChart.css +59 -0
  34. package/dist/charts/BarChart.d.mts +26 -0
  35. package/dist/charts/BarChart.mjs +167 -0
  36. package/dist/charts/BarChart.module.css.mjs +10 -0
  37. package/dist/charts/ChartGrid.d.mts +8 -0
  38. package/dist/charts/ChartGrid.mjs +47 -0
  39. package/dist/charts/DistributionChart.d.mts +60 -0
  40. package/dist/charts/DistributionChart.mjs +151 -0
  41. package/dist/code/CodeBlock.d.mts +13 -0
  42. package/dist/code/CodeBlock.mjs +71 -0
  43. package/dist/composition-bar/CompositionBar.d.mts +24 -0
  44. package/dist/composition-bar/CompositionBar.mjs +124 -0
  45. package/dist/composition-bar/composition-shares.d.mts +8 -0
  46. package/dist/composition-bar/composition-shares.mjs +30 -0
  47. package/dist/data-gate/DataGate.d.mts +34 -0
  48. package/dist/data-gate/DataGate.mjs +80 -0
  49. package/dist/date-scope/DateScope.d.mts +30 -0
  50. package/dist/date-scope/DateScope.mjs +285 -0
  51. package/dist/design-system/part-props.d.mts +39 -0
  52. package/dist/design-system/part-props.mjs +0 -0
  53. package/dist/detail-panel/DetailPanel.d.mts +22 -0
  54. package/dist/detail-panel/DetailPanel.mjs +80 -0
  55. package/dist/detail-panel/DetailPanelSection.d.mts +20 -0
  56. package/dist/detail-panel/DetailPanelSection.mjs +27 -0
  57. package/dist/detail-panel/micro-label.d.mts +7 -0
  58. package/dist/detail-panel/micro-label.mjs +9 -0
  59. package/dist/env.d.mts +2 -0
  60. package/dist/env.mjs +4 -0
  61. package/dist/export/ExportCsvButton.d.mts +19 -0
  62. package/dist/export/ExportCsvButton.mjs +73 -0
  63. package/dist/export/download-csv.d.mts +5 -0
  64. package/dist/export/download-csv.mjs +11 -0
  65. package/dist/export/download-file.d.mts +11 -0
  66. package/dist/export/download-file.mjs +32 -0
  67. package/dist/export/download-json.d.mts +2 -0
  68. package/dist/export/download-json.mjs +8 -0
  69. package/dist/filter/FilterGroup.d.mts +24 -0
  70. package/dist/filter/FilterGroup.mjs +71 -0
  71. package/dist/filter/FilterGroupTitle.d.mts +3 -0
  72. package/dist/filter/FilterGroupTitle.mjs +18 -0
  73. package/dist/filter/FilterItem.d.mts +17 -0
  74. package/dist/filter/FilterItem.mjs +94 -0
  75. package/dist/filter/FilterPanel.d.mts +22 -0
  76. package/dist/filter/FilterPanel.mjs +158 -0
  77. package/dist/filter/FilterToggleButton.d.mts +15 -0
  78. package/dist/filter/FilterToggleButton.mjs +30 -0
  79. package/dist/filter/date-range.d.mts +8 -0
  80. package/dist/filter/date-range.mjs +13 -0
  81. package/dist/filter/filter-facet.d.mts +7 -0
  82. package/dist/filter/filter-facet.mjs +0 -0
  83. package/dist/heatmap/Heatmap.css +138 -0
  84. package/dist/heatmap/Heatmap.d.mts +10 -0
  85. package/dist/heatmap/Heatmap.mjs +370 -0
  86. package/dist/heatmap/Heatmap.module.css.mjs +17 -0
  87. package/dist/heatmap/HeatmapCell.d.mts +25 -0
  88. package/dist/heatmap/HeatmapCell.mjs +124 -0
  89. package/dist/heatmap/heatmap-scale.d.mts +19 -0
  90. package/dist/heatmap/heatmap-scale.mjs +43 -0
  91. package/dist/heatmap/heatmap-types.d.mts +49 -0
  92. package/dist/heatmap/heatmap-types.mjs +0 -0
  93. package/dist/hooks/use-controllable-state.d.mts +9 -0
  94. package/dist/hooks/use-controllable-state.mjs +44 -0
  95. package/dist/hooks/use-debounced-value.d.mts +1 -0
  96. package/dist/hooks/use-debounced-value.mjs +27 -0
  97. package/dist/hooks/use-detail-panel-layout.d.mts +18 -0
  98. package/dist/hooks/use-detail-panel-layout.mjs +94 -0
  99. package/dist/hooks/use-hover-card.d.mts +47 -0
  100. package/dist/hooks/use-hover-card.mjs +190 -0
  101. package/dist/hooks/use-hover-focus-card.d.mts +38 -0
  102. package/dist/hooks/use-hover-focus-card.mjs +321 -0
  103. package/dist/hooks/use-hover-intent.d.mts +6 -0
  104. package/dist/hooks/use-hover-intent.mjs +55 -0
  105. package/dist/hooks/use-merged-ref.d.mts +2 -0
  106. package/dist/hooks/use-merged-ref.mjs +36 -0
  107. package/dist/hooks/use-tracked-anchor.d.mts +14 -0
  108. package/dist/hooks/use-tracked-anchor.mjs +42 -0
  109. package/dist/index.d.mts +97 -0
  110. package/dist/index.mjs +88 -0
  111. package/dist/input/MenuButton.d.mts +47 -0
  112. package/dist/input/MenuButton.mjs +152 -0
  113. package/dist/interval-strip/IntervalStrip.css +7 -0
  114. package/dist/interval-strip/IntervalStrip.d.mts +39 -0
  115. package/dist/interval-strip/IntervalStrip.mjs +233 -0
  116. package/dist/interval-strip/IntervalStrip.module.css.mjs +4 -0
  117. package/dist/interval-strip/IntervalStripAxis.d.mts +18 -0
  118. package/dist/interval-strip/IntervalStripAxis.mjs +73 -0
  119. package/dist/interval-strip/interval-fill.d.mts +2 -0
  120. package/dist/interval-strip/interval-fill.mjs +13 -0
  121. package/dist/interval-strip/interval-layout.d.mts +33 -0
  122. package/dist/interval-strip/interval-layout.mjs +79 -0
  123. package/dist/layout/AppShell.css +103 -0
  124. package/dist/layout/AppShell.d.mts +73 -0
  125. package/dist/layout/AppShell.mjs +397 -0
  126. package/dist/layout/AppShell.module.css.mjs +16 -0
  127. package/dist/layout/ColorSchemeMenu.d.mts +14 -0
  128. package/dist/layout/ColorSchemeMenu.mjs +92 -0
  129. package/dist/layout/DemoDataPicker.d.mts +17 -0
  130. package/dist/layout/DemoDataPicker.mjs +150 -0
  131. package/dist/layout/OverflowMenu.d.mts +11 -0
  132. package/dist/layout/OverflowMenu.mjs +94 -0
  133. package/dist/layout/SidebarLayout.css +70 -0
  134. package/dist/layout/SidebarLayout.d.mts +33 -0
  135. package/dist/layout/SidebarLayout.mjs +129 -0
  136. package/dist/layout/SidebarLayout.module.css.mjs +8 -0
  137. package/dist/layout/use-date-scope-day.d.mts +23 -0
  138. package/dist/layout/use-date-scope-day.mjs +63 -0
  139. package/dist/layout/use-fill-height.d.mts +7 -0
  140. package/dist/layout/use-fill-height.mjs +50 -0
  141. package/dist/layout/use-followed-state.d.mts +5 -0
  142. package/dist/layout/use-followed-state.mjs +75 -0
  143. package/dist/layout/use-page-route.d.mts +10 -0
  144. package/dist/layout/use-page-route.mjs +65 -0
  145. package/dist/legend/Legend.d.mts +54 -0
  146. package/dist/legend/Legend.mjs +132 -0
  147. package/dist/map/MapLayersControl.d.mts +11 -0
  148. package/dist/map/MapLayersControl.mjs +157 -0
  149. package/dist/map/MapLocator.css +9 -0
  150. package/dist/map/MapLocator.d.mts +18 -0
  151. package/dist/map/MapLocator.mjs +97 -0
  152. package/dist/map/MapLocator.module.css.mjs +4 -0
  153. package/dist/map/MapMarker.d.mts +29 -0
  154. package/dist/map/MapMarker.mjs +265 -0
  155. package/dist/map/MapStops.d.mts +19 -0
  156. package/dist/map/MapStops.mjs +355 -0
  157. package/dist/map/MapView.css +24 -0
  158. package/dist/map/MapView.d.mts +11 -0
  159. package/dist/map/MapView.mjs +141 -0
  160. package/dist/map/MapWebgl.d.mts +9 -0
  161. package/dist/map/MapWebgl.mjs +727 -0
  162. package/dist/map/area-layers.d.mts +33 -0
  163. package/dist/map/area-layers.mjs +96 -0
  164. package/dist/map/control-group.d.mts +6 -0
  165. package/dist/map/control-group.mjs +12 -0
  166. package/dist/map/for-each-chunk.d.mts +4 -0
  167. package/dist/map/for-each-chunk.mjs +14 -0
  168. package/dist/map/highlight.d.mts +30 -0
  169. package/dist/map/highlight.mjs +99 -0
  170. package/dist/map/locator-tile.d.mts +24 -0
  171. package/dist/map/locator-tile.mjs +41 -0
  172. package/dist/map/map-sites.d.mts +12 -0
  173. package/dist/map/map-sites.mjs +39 -0
  174. package/dist/map/map-style.d.mts +24 -0
  175. package/dist/map/map-style.mjs +79 -0
  176. package/dist/map/marker-geometry.d.mts +5 -0
  177. package/dist/map/marker-geometry.mjs +13 -0
  178. package/dist/map/marker-icon.d.mts +26 -0
  179. package/dist/map/marker-icon.mjs +223 -0
  180. package/dist/map/observe-color-scheme.d.mts +5 -0
  181. package/dist/map/observe-color-scheme.mjs +19 -0
  182. package/dist/map/popup-placement.d.mts +20 -0
  183. package/dist/map/popup-placement.mjs +20 -0
  184. package/dist/map/route-layers.d.mts +28 -0
  185. package/dist/map/route-layers.mjs +73 -0
  186. package/dist/map/types.d.mts +97 -0
  187. package/dist/map/types.mjs +0 -0
  188. package/dist/map/use-painted-color-scheme.d.mts +6 -0
  189. package/dist/map/use-painted-color-scheme.mjs +43 -0
  190. package/dist/map/use-resolved-colors.d.mts +5 -0
  191. package/dist/map/use-resolved-colors.mjs +63 -0
  192. package/dist/pagination/paginationLabels.d.mts +6 -0
  193. package/dist/pagination/paginationLabels.mjs +8 -0
  194. package/dist/popover/Popover.css +176 -0
  195. package/dist/popover/Popover.d.mts +239 -0
  196. package/dist/popover/Popover.mjs +672 -0
  197. package/dist/popover/Popover.module.css.mjs +18 -0
  198. package/dist/popover/PopoverFacts.d.mts +24 -0
  199. package/dist/popover/PopoverFacts.mjs +63 -0
  200. package/dist/readout/Readout.d.mts +15 -0
  201. package/dist/readout/Readout.mjs +53 -0
  202. package/dist/readout/TimeZoneReadout.d.mts +11 -0
  203. package/dist/readout/TimeZoneReadout.mjs +46 -0
  204. package/dist/score-box/ScoreBox.css +62 -0
  205. package/dist/score-box/ScoreBox.d.mts +12 -0
  206. package/dist/score-box/ScoreBox.mjs +143 -0
  207. package/dist/score-box/ScoreBox.module.css.mjs +15 -0
  208. package/dist/segment-bar/Segment.d.mts +23 -0
  209. package/dist/segment-bar/Segment.mjs +27 -0
  210. package/dist/segment-bar/SegmentBar.css +44 -0
  211. package/dist/segment-bar/SegmentBar.d.mts +35 -0
  212. package/dist/segment-bar/SegmentBar.mjs +57 -0
  213. package/dist/segment-bar/SegmentBar.module.css.mjs +9 -0
  214. package/dist/segment-bar/segment-box.d.mts +10 -0
  215. package/dist/segment-bar/segment-box.mjs +30 -0
  216. package/dist/stat/Stat.d.mts +25 -0
  217. package/dist/stat/Stat.mjs +36 -0
  218. package/dist/stat/StatTile.d.mts +18 -0
  219. package/dist/stat/StatTile.mjs +37 -0
  220. package/dist/styles.css +1 -0
  221. package/dist/swatch/Swatch.d.mts +8 -0
  222. package/dist/swatch/Swatch.mjs +30 -0
  223. package/dist/swatch/legend-swatch.d.mts +3 -0
  224. package/dist/swatch/legend-swatch.mjs +0 -0
  225. package/dist/tab-bar/FilteredTabBar.d.mts +32 -0
  226. package/dist/tab-bar/FilteredTabBar.mjs +181 -0
  227. package/dist/tab-bar/TabBar.d.mts +22 -0
  228. package/dist/tab-bar/TabBar.mjs +151 -0
  229. package/dist/tab-bar/TabPanel.d.mts +9 -0
  230. package/dist/tab-bar/TabPanel.mjs +55 -0
  231. package/dist/tab-bar/assert-named-value.d.mts +4 -0
  232. package/dist/tab-bar/assert-named-value.mjs +6 -0
  233. package/dist/table/DataTable.d.mts +31 -0
  234. package/dist/table/DataTable.mjs +43 -0
  235. package/dist/theme/use-color-scheme.d.mts +14 -0
  236. package/dist/theme/use-color-scheme.mjs +92 -0
  237. package/dist/theme.css +58 -0
  238. package/dist/timeline/Timeline.d.mts +54 -0
  239. package/dist/timeline/Timeline.mjs +220 -0
  240. package/dist/timeline/TimelineBand.d.mts +18 -0
  241. package/dist/timeline/TimelineBand.mjs +30 -0
  242. package/dist/timeline/TimelineGroup.d.mts +7 -0
  243. package/dist/timeline/TimelineGroup.mjs +50 -0
  244. package/dist/timeline/TimelineItem.d.mts +19 -0
  245. package/dist/timeline/TimelineItem.mjs +64 -0
  246. package/dist/timeline/TimelineItemChip.css +153 -0
  247. package/dist/timeline/TimelineItemChip.d.mts +23 -0
  248. package/dist/timeline/TimelineItemChip.mjs +74 -0
  249. package/dist/timeline/TimelineItemChip.module.css.mjs +15 -0
  250. package/dist/timeline/TimelineItemMark.css +38 -0
  251. package/dist/timeline/TimelineItemMark.d.mts +15 -0
  252. package/dist/timeline/TimelineItemMark.mjs +129 -0
  253. package/dist/timeline/TimelineItemMark.module.css.mjs +4 -0
  254. package/dist/timeline/TimelineRoot.d.mts +19 -0
  255. package/dist/timeline/TimelineRoot.mjs +742 -0
  256. package/dist/timeline/TimelineRowHeader.d.mts +23 -0
  257. package/dist/timeline/TimelineRowHeader.mjs +244 -0
  258. package/dist/timeline/TimelineZoomHint.d.mts +9 -0
  259. package/dist/timeline/TimelineZoomHint.mjs +32 -0
  260. package/dist/timeline/axis-label.d.mts +5 -0
  261. package/dist/timeline/axis-label.mjs +53 -0
  262. package/dist/timeline/batched-dataset-writer.d.mts +29 -0
  263. package/dist/timeline/batched-dataset-writer.mjs +58 -0
  264. package/dist/timeline/row-card-side.d.mts +7 -0
  265. package/dist/timeline/row-card-side.mjs +6 -0
  266. package/dist/timeline/timeline-a11y.d.mts +33 -0
  267. package/dist/timeline/timeline-a11y.mjs +96 -0
  268. package/dist/timeline/timeline-context.d.mts +33 -0
  269. package/dist/timeline/timeline-context.mjs +40 -0
  270. package/dist/timeline/timeline-types.d.mts +126 -0
  271. package/dist/timeline/timeline-types.mjs +0 -0
  272. package/dist/timeline/timeline-utils.d.mts +52 -0
  273. package/dist/timeline/timeline-utils.mjs +130 -0
  274. package/dist/timeline/zoom-modifier.d.mts +21 -0
  275. package/dist/timeline/zoom-modifier.mjs +25 -0
  276. package/dist/toast/ToastProvider.d.mts +33 -0
  277. package/dist/toast/ToastProvider.mjs +257 -0
  278. package/dist/toast/toast-context.d.mts +2 -0
  279. package/dist/toast/toast-context.mjs +5 -0
  280. package/dist/tokens.css +1 -0
  281. package/dist/tooltip/Tooltip.d.mts +17 -0
  282. package/dist/tooltip/Tooltip.mjs +41 -0
  283. package/dist/tooltip/hover-open-delay.d.mts +2 -0
  284. package/dist/tooltip/hover-open-delay.mjs +4 -0
  285. package/dist/tooltip/is-text-cut.d.mts +1 -0
  286. package/dist/tooltip/is-text-cut.mjs +5 -0
  287. package/dist/vendor/components.d.mts +664 -0
  288. package/dist/vendor/components.mjs +2060 -0
  289. package/package.json +61 -3
@@ -0,0 +1,14 @@
1
+ import { BadgeListValue } from "./badge-item.mjs";
2
+ import { SlotIcon } from "../vendor/components.mjs";
3
+ /** The props of `BadgeList`: the values to draw as badges and their shared icon. */
4
+ export type BadgeListProps = {
5
+ items: BadgeListValue[] | null | undefined;
6
+ icon?: SlotIcon;
7
+ };
8
+ /**
9
+ * Renders a list of values (strings, or `{id}`-keyed objects) as colour-coded `Badge`s.
10
+ *
11
+ * @category Data display
12
+ */
13
+ export default function BadgeList({ items, icon }: BadgeListProps): import("react").ReactNode[] | null;
14
+ export type { BadgeListValue };
@@ -0,0 +1,15 @@
1
+ import { renderBadgeItem } from "./badge-item.mjs";
2
+ // src/badge/BadgeList.tsx
3
+ /**
4
+ * Renders a list of values (strings, or `{id}`-keyed objects) as colour-coded `Badge`s.
5
+ *
6
+ * @category Data display
7
+ */
8
+ function BadgeList({ items, icon }) {
9
+ if (!items || items.length === 0) return null;
10
+ return items.map((item, index) => renderBadgeItem(item, {
11
+ key: index,
12
+ icon
13
+ }));
14
+ }
15
+ export { BadgeList as default };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The pure arithmetic behind `BadgeFacetGroup`'s overflow fit: given each badge's measured
3
+ * width, the flex gap, and the available width, decide how many fit and whether a chip is needed.
4
+ */
5
+ export interface FitResult {
6
+ visibleCount: number;
7
+ hiddenCount: number;
8
+ }
9
+ /**
10
+ * Pass 1 (conservative): the largest prefix that fits alongside a chip reserved at its
11
+ * widest possible width, so the result can never overflow once rendered.
12
+ */
13
+ export declare function fitWithReservedChip(widths: number[], gap: number, availableWidth: number, reservedChipWidth: number): FitResult;
14
+ /**
15
+ * Pass 2 (corrective, at most once per fit): grows `fit` using the chip's actual measured
16
+ * width, which is usually narrower than pass 1's reserved worst case.
17
+ */
18
+ export declare function growWithExactChip(widths: number[], gap: number, availableWidth: number, fit: FitResult, exactChipWidth: number): FitResult;
@@ -0,0 +1,50 @@
1
+ // src/badge/badge-facet-fit.ts
2
+ function sum(values) {
3
+ let total = 0;
4
+ for (const value of values) total += value;
5
+ return total;
6
+ }
7
+ function badgesWidth(widths, k, gap) {
8
+ if (k <= 0) return 0;
9
+ return sum(widths.slice(0, k)) + gap * (k - 1);
10
+ }
11
+ function withChip(widths, k, gap, chipWidth) {
12
+ if (k === 0) return chipWidth;
13
+ return badgesWidth(widths, k, gap) + gap + chipWidth;
14
+ }
15
+ /**
16
+ * Pass 1 (conservative): the largest prefix that fits alongside a chip reserved at its
17
+ * widest possible width, so the result can never overflow once rendered.
18
+ */
19
+ function fitWithReservedChip(widths, gap, availableWidth, reservedChipWidth) {
20
+ const n = widths.length;
21
+ if (n === 0) return {
22
+ visibleCount: 0,
23
+ hiddenCount: 0
24
+ };
25
+ if (badgesWidth(widths, n, gap) <= availableWidth) return {
26
+ visibleCount: n,
27
+ hiddenCount: 0
28
+ };
29
+ let k = n - 1;
30
+ while (k > 0 && withChip(widths, k, gap, reservedChipWidth) > availableWidth) k -= 1;
31
+ return {
32
+ visibleCount: k,
33
+ hiddenCount: n - k
34
+ };
35
+ }
36
+ /**
37
+ * Pass 2 (corrective, at most once per fit): grows `fit` using the chip's actual measured
38
+ * width, which is usually narrower than pass 1's reserved worst case.
39
+ */
40
+ function growWithExactChip(widths, gap, availableWidth, fit, exactChipWidth) {
41
+ const n = widths.length;
42
+ if (fit.hiddenCount === 0) return fit;
43
+ let k = fit.visibleCount;
44
+ while (k < n - 1 && withChip(widths, k + 1, gap, exactChipWidth) <= availableWidth) k += 1;
45
+ return {
46
+ visibleCount: k,
47
+ hiddenCount: n - k
48
+ };
49
+ }
50
+ export { fitWithReservedChip, growWithExactChip };
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from "react";
2
+ import { SlotIcon } from "../vendor/components.mjs";
3
+ /** A facet value: either a plain string, or an `{id}`-keyed object (skills). */
4
+ export type BadgeListValue = string | {
5
+ id: string;
6
+ };
7
+ /** A value's display string — the string itself, or an `{id}`-keyed object's `id`. */
8
+ export declare function valueOf(item: BadgeListValue): string;
9
+ export type BadgeItemOptions = {
10
+ key?: string | number;
11
+ icon?: SlotIcon;
12
+ /** @defaultValue false */
13
+ temporary?: boolean;
14
+ };
15
+ /**
16
+ * Renders one `BadgeListValue` as a colour-coded `Badge`, keyed on the caller's `key` or
17
+ * its own display value. The one place a value maps to a `Badge`.
18
+ */
19
+ export declare function renderBadgeItem(item: BadgeListValue, { key, icon, temporary }?: BadgeItemOptions): ReactNode;
@@ -0,0 +1,23 @@
1
+ import Badge from "./Badge.mjs";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { pickCategory } from "@timefoldai/viz-core";
4
+ // src/badge/badge-item.tsx
5
+ /** A value's display string — the string itself, or an `{id}`-keyed object's `id`. */
6
+ function valueOf(item) {
7
+ return typeof item === "string" ? item : item.id;
8
+ }
9
+ /**
10
+ * Renders one `BadgeListValue` as a colour-coded `Badge`, keyed on the caller's `key` or
11
+ * its own display value. The one place a value maps to a `Badge`.
12
+ */
13
+ function renderBadgeItem(item, { key, icon, temporary = false } = {}) {
14
+ const value = valueOf(item);
15
+ return /* @__PURE__ */ jsx(Badge, {
16
+ category: pickCategory(value),
17
+ temporary,
18
+ leadingIcon: icon,
19
+ fullLabel: value,
20
+ children: value
21
+ }, key ?? value);
22
+ }
23
+ export { renderBadgeItem, valueOf };
@@ -0,0 +1,12 @@
1
+ /** The props of `CopyButton`: the value it copies and its label. */
2
+ export interface CopyButtonProps {
3
+ value: string;
4
+ label: string;
5
+ }
6
+ /**
7
+ * An icon button that copies `value` to the clipboard, confirming with a check mark; a failure is a toast.
8
+ *
9
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
10
+ * @category Controls
11
+ */
12
+ export default function CopyButton({ value, label }: CopyButtonProps): import("react").JSX.Element;
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { useToast } from "../toast/ToastProvider.mjs";
3
+ import Tooltip$1 from "../tooltip/Tooltip.mjs";
4
+ import { c } from "react/compiler-runtime";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { CopyValueButton } from "../vendor/components.mjs";
7
+ // src/button/CopyButton.tsx
8
+ /**
9
+ * An icon button that copies `value` to the clipboard, confirming with a check mark; a failure is a toast.
10
+ *
11
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
12
+ * @category Controls
13
+ */
14
+ function CopyButton(t0) {
15
+ const $ = c(10);
16
+ const { value, label } = t0;
17
+ const { show } = useToast();
18
+ let t1;
19
+ if ($[0] !== show || $[1] !== value) {
20
+ t1 = () => show(`Could not copy ${value} to the clipboard.`, { state: "negative" });
21
+ $[0] = show;
22
+ $[1] = value;
23
+ $[2] = t1;
24
+ } else t1 = $[2];
25
+ let t2;
26
+ if ($[3] !== label || $[4] !== t1 || $[5] !== value) {
27
+ t2 = /* @__PURE__ */ jsx(CopyValueButton, {
28
+ "data-slot": "copy-button",
29
+ variant: "soft",
30
+ size: "xs",
31
+ value,
32
+ label,
33
+ onError: t1
34
+ });
35
+ $[3] = label;
36
+ $[4] = t1;
37
+ $[5] = value;
38
+ $[6] = t2;
39
+ } else t2 = $[6];
40
+ let t3;
41
+ if ($[7] !== label || $[8] !== t2) {
42
+ t3 = /* @__PURE__ */ jsx(Tooltip$1, {
43
+ label,
44
+ children: t2
45
+ });
46
+ $[7] = label;
47
+ $[8] = t2;
48
+ $[9] = t3;
49
+ } else t3 = $[9];
50
+ return t3;
51
+ }
52
+ export { CopyButton as default };
@@ -0,0 +1,14 @@
1
+ import { ButtonProps } from "../vendor/components.mjs";
2
+ /** The props of `ShowAllButton`, the button that expands or collapses a list. */
3
+ export interface ShowAllButtonProps extends Omit<ButtonProps, "asChild" | "children" | "leadingIcon" | "trailingIcon" | "soloIcon" | "onClick" | "aria-expanded"> {
4
+ expanded: boolean;
5
+ onExpandedChange: (expanded: boolean) => void;
6
+ }
7
+ /**
8
+ * The "Show all" / "Show less" expander for a list truncated by default —
9
+ * the filter panel's facet groups, the efficiency panel's breakdown groups.
10
+ *
11
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/
12
+ * @category Controls
13
+ */
14
+ export default function ShowAllButton({ expanded, onExpandedChange, ...props }: ShowAllButtonProps): import("react").JSX.Element;
@@ -0,0 +1,61 @@
1
+ "use client";
2
+ import { c } from "react/compiler-runtime";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { Button } from "../vendor/components.mjs";
5
+ import { TbChevronDown, TbChevronUp } from "react-icons/tb";
6
+ // src/button/ShowAllButton.tsx
7
+ /**
8
+ * The "Show all" / "Show less" expander for a list truncated by default —
9
+ * the filter panel's facet groups, the efficiency panel's breakdown groups.
10
+ *
11
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/
12
+ * @category Controls
13
+ */
14
+ function ShowAllButton(t0) {
15
+ const $ = c(13);
16
+ let expanded;
17
+ let onExpandedChange;
18
+ let props;
19
+ if ($[0] !== t0) {
20
+ ({expanded, onExpandedChange, ...props} = t0);
21
+ $[0] = t0;
22
+ $[1] = expanded;
23
+ $[2] = onExpandedChange;
24
+ $[3] = props;
25
+ } else {
26
+ expanded = $[1];
27
+ onExpandedChange = $[2];
28
+ props = $[3];
29
+ }
30
+ const t1 = expanded ? TbChevronUp : TbChevronDown;
31
+ let t2;
32
+ if ($[4] !== expanded || $[5] !== onExpandedChange) {
33
+ t2 = () => onExpandedChange(!expanded);
34
+ $[4] = expanded;
35
+ $[5] = onExpandedChange;
36
+ $[6] = t2;
37
+ } else t2 = $[6];
38
+ const t3 = expanded ? "Show less" : "Show all";
39
+ let t4;
40
+ if ($[7] !== expanded || $[8] !== props || $[9] !== t1 || $[10] !== t2 || $[11] !== t3) {
41
+ t4 = /* @__PURE__ */ jsx(Button, {
42
+ type: "button",
43
+ "data-slot": "show-all-button",
44
+ variant: "ghost",
45
+ size: "sm",
46
+ trailingIcon: t1,
47
+ "aria-expanded": expanded,
48
+ onClick: t2,
49
+ ...props,
50
+ children: t3
51
+ });
52
+ $[7] = expanded;
53
+ $[8] = props;
54
+ $[9] = t1;
55
+ $[10] = t2;
56
+ $[11] = t3;
57
+ $[12] = t4;
58
+ } else t4 = $[12];
59
+ return t4;
60
+ }
61
+ export { ShowAllButton as default };
@@ -0,0 +1,13 @@
1
+ import { ButtonProps } from "../vendor/components.mjs";
2
+ /** The props of `ShowMoreButton`, the button that reveals the next step of a truncated list. */
3
+ export interface ShowMoreButtonProps extends Omit<ButtonProps, "asChild" | "children" | "leadingIcon" | "trailingIcon" | "soloIcon" | "onClick"> {
4
+ remaining: number;
5
+ step: number;
6
+ onReveal: () => void;
7
+ }
8
+ /**
9
+ * Reveals the next step of a long, truncated list — with no way back.
10
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
11
+ * @category Controls
12
+ */
13
+ export default function ShowMoreButton({ remaining, step, onReveal, ...props }: ShowMoreButtonProps): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { c } from "react/compiler-runtime";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { Button } from "../vendor/components.mjs";
5
+ import { TbChevronDown } from "react-icons/tb";
6
+ // src/button/ShowMoreButton.tsx
7
+ /**
8
+ * Reveals the next step of a long, truncated list — with no way back.
9
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
10
+ * @category Controls
11
+ */
12
+ function ShowMoreButton(t0) {
13
+ const $ = c(9);
14
+ let onReveal;
15
+ let props;
16
+ let remaining;
17
+ let step;
18
+ if ($[0] !== t0) {
19
+ ({remaining, step, onReveal, ...props} = t0);
20
+ $[0] = t0;
21
+ $[1] = onReveal;
22
+ $[2] = props;
23
+ $[3] = remaining;
24
+ $[4] = step;
25
+ } else {
26
+ onReveal = $[1];
27
+ props = $[2];
28
+ remaining = $[3];
29
+ step = $[4];
30
+ }
31
+ const t1 = `Show ${Math.min(step, remaining)} more`;
32
+ let t2;
33
+ if ($[5] !== onReveal || $[6] !== props || $[7] !== t1) {
34
+ t2 = /* @__PURE__ */ jsx(Button, {
35
+ type: "button",
36
+ "data-slot": "show-more-button",
37
+ variant: "ghost",
38
+ size: "sm",
39
+ trailingIcon: TbChevronDown,
40
+ onClick: onReveal,
41
+ ...props,
42
+ children: t1
43
+ });
44
+ $[5] = onReveal;
45
+ $[6] = props;
46
+ $[7] = t1;
47
+ $[8] = t2;
48
+ } else t2 = $[8];
49
+ return t2;
50
+ }
51
+ export { ShowMoreButton as default };
@@ -0,0 +1,16 @@
1
+ import { SolvePhase } from "@timefoldai/viz-core";
2
+ /** The phase of the solve a `SolveButton` shows: viz-core's `SolvePhase`. */
3
+ export type SolveButtonPhase = SolvePhase;
4
+ /** The props of `SolveButton`: its label, its phase and its toggle. */
5
+ export interface SolveButtonProps {
6
+ label: string;
7
+ phase: SolveButtonPhase;
8
+ onToggle: () => void | Promise<void>;
9
+ }
10
+ /**
11
+ * Starts or stops a solve. Takes `viz-platform`'s `useSolveControl()` as props.
12
+ *
13
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
14
+ * @category Controls
15
+ */
16
+ export default function SolveButton({ label, phase, onToggle }: SolveButtonProps): import("react").JSX.Element;
@@ -0,0 +1,56 @@
1
+ "use client";
2
+ import { c } from "react/compiler-runtime";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { Button } from "../vendor/components.mjs";
5
+ import { TbLoader2, TbPlayerPlayFilled, TbSquareFilled } from "react-icons/tb";
6
+ // src/button/SolveButton.tsx
7
+ /**
8
+ * Starts or stops a solve. Takes `viz-platform`'s `useSolveControl()` as props.
9
+ *
10
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
11
+ * @category Controls
12
+ */
13
+ function SolveButton(t0) {
14
+ const $ = c(10);
15
+ const { label, phase, onToggle } = t0;
16
+ const t1 = phase === "solving" ? TbSquareFilled : TbPlayerPlayFilled;
17
+ const t2 = phase === "starting" || phase === "preparing";
18
+ let t3;
19
+ if ($[0] !== label) {
20
+ t3 = /* @__PURE__ */ jsx("span", {
21
+ "data-slot": "solve-button-label",
22
+ children: label
23
+ });
24
+ $[0] = label;
25
+ $[1] = t3;
26
+ } else t3 = $[1];
27
+ let t4;
28
+ if ($[2] !== phase) {
29
+ t4 = (phase === "starting" || phase === "solving") && /* @__PURE__ */ jsx(TbLoader2, {
30
+ "aria-hidden": true,
31
+ "data-slot": "solve-button-spinner",
32
+ className: "size-4 motion-safe:animate-spin"
33
+ });
34
+ $[2] = phase;
35
+ $[3] = t4;
36
+ } else t4 = $[3];
37
+ let t5;
38
+ if ($[4] !== onToggle || $[5] !== t1 || $[6] !== t2 || $[7] !== t3 || $[8] !== t4) {
39
+ t5 = /* @__PURE__ */ jsxs(Button, {
40
+ variant: "soft",
41
+ type: "button",
42
+ leadingIcon: t1,
43
+ loading: t2,
44
+ onClick: onToggle,
45
+ children: [t3, t4]
46
+ });
47
+ $[4] = onToggle;
48
+ $[5] = t1;
49
+ $[6] = t2;
50
+ $[7] = t3;
51
+ $[8] = t4;
52
+ $[9] = t5;
53
+ } else t5 = $[9];
54
+ return t5;
55
+ }
56
+ export { SolveButton as default };
@@ -0,0 +1,59 @@
1
+ @layer components {
2
+ .e20vzq_bar-chart {
3
+ --chart-radius: .25rem;
4
+ --max: 100;
5
+ --chart-track: color-mix(in oklab,
6
+ var(--tf-color-foreground) 4%,
7
+ var(--tf-color-background));
8
+ height: var(--chart-height, 4rem);
9
+ gap: 1px;
10
+ display: flex;
11
+ position: relative;
12
+ }
13
+
14
+ .e20vzq_bar-chart .e20vzq_bar {
15
+ background: var(--chart-track);
16
+ border-radius: var(--chart-radius);
17
+ flex-grow: 1;
18
+ position: relative;
19
+ }
20
+
21
+ .e20vzq_bar-chart .e20vzq_bar:hover {
22
+ background: color-mix(in oklab,
23
+ var(--tf-color-foreground) 15%,
24
+ var(--tf-color-background));
25
+ }
26
+
27
+ .e20vzq_bar-chart .e20vzq_bar .e20vzq_value {
28
+ inset-inline: 0;
29
+ height: calc(var(--viz-bar-chart-size) / var(--max) * 100%);
30
+ min-height: var(--viz-bar-chart-min-height, 0);
31
+ border-radius: var(--chart-radius);
32
+ background: var(--viz-bar-chart-color, var(--viz-chart-bar));
33
+ position: absolute;
34
+ bottom: 0;
35
+ }
36
+
37
+ .e20vzq_bar-chart .e20vzq_max {
38
+ color: var(--tf-color-foreground);
39
+ font-size: .5625rem;
40
+ font-family: var(--tf-font-mono);
41
+ margin-right: .4em;
42
+ position: absolute;
43
+ right: 100%;
44
+ }
45
+
46
+ .e20vzq_viz-distribution-average {
47
+ color: var(--tf-color-primary);
48
+ }
49
+
50
+ :where(.dark, .dark *) .e20vzq_viz-distribution-average {
51
+ color: var(--tf-primary-200);
52
+ }
53
+
54
+ :where(.dark, .dark *) .e20vzq_bar-chart {
55
+ --chart-track: color-mix(in oklab,
56
+ var(--tf-color-foreground) 7%,
57
+ var(--tf-color-background));
58
+ }
59
+ }
@@ -0,0 +1,26 @@
1
+ import { ReactNode } from "react";
2
+ /** A bar of `BarChart`: its id, value, label and colour. */
3
+ export interface BarChartBar {
4
+ id: string;
5
+ value: number;
6
+ label?: string;
7
+ color?: string;
8
+ /** @defaultValue `label` and `value`, as the bar's entry in the chart's `aria-label` */
9
+ description?: string;
10
+ }
11
+ /** The props of `BarChart`: its bars, its accessible label and its popover. */
12
+ export interface BarChartProps<Bar extends BarChartBar> extends Pick<React.ComponentProps<"div">, "className" | "style" | "ref"> {
13
+ bars: Bar[];
14
+ "aria-label": string;
15
+ renderPopover?: (bar: Bar) => ReactNode;
16
+ showLabels?: boolean;
17
+ minBarHeight?: number;
18
+ }
19
+ /**
20
+ * A bar chart, rendered as a single `role="img"` graphic: the bars encode value by height and are `aria-hidden`.
21
+ * The required `aria-label` names the chart and the image's name then lists every bar, a card's facts included.
22
+ *
23
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
24
+ * @category Charts
25
+ */
26
+ export default function BarChart<Bar extends BarChartBar>({ bars, "aria-label": ariaLabel, renderPopover, showLabels, minBarHeight, className, style, ref }: BarChartProps<Bar>): import("react").JSX.Element;
@@ -0,0 +1,167 @@
1
+ "use client";
2
+ import { useHoverCardState } from "../hooks/use-hover-card.mjs";
3
+ import Popover, { hasPopoverContent } from "../popover/Popover.mjs";
4
+ import Tooltip from "../tooltip/Tooltip.mjs";
5
+ import BarChart_module_default from "./BarChart.module.css.mjs";
6
+ import { c } from "react/compiler-runtime";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import clsx$1 from "clsx";
9
+ // src/charts/BarChart.tsx
10
+ function isSameBar(a, b) {
11
+ return a.id === b.id;
12
+ }
13
+ function describeBar({ label, value, description }) {
14
+ return description ?? (label == null ? String(value) : `${label} ${value}`);
15
+ }
16
+ /**
17
+ * A bar chart, rendered as a single `role="img"` graphic: the bars encode value by height and are `aria-hidden`.
18
+ * The required `aria-label` names the chart and the image's name then lists every bar, a card's facts included.
19
+ *
20
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
21
+ * @category Charts
22
+ */
23
+ function BarChart(t0) {
24
+ const $ = c(35);
25
+ const { bars, "aria-label": ariaLabel, renderPopover, showLabels, minBarHeight, className, style, ref } = t0;
26
+ let t1;
27
+ if ($[0] !== bars) {
28
+ t1 = bars.length > 0 ? Math.max(...bars.map(_temp)) : 0;
29
+ $[0] = bars;
30
+ $[1] = t1;
31
+ } else t1 = $[1];
32
+ const maxValue = t1;
33
+ let t2;
34
+ if ($[2] !== bars) {
35
+ t2 = bars.map(describeBar).join(", ");
36
+ $[2] = bars;
37
+ $[3] = t2;
38
+ } else t2 = $[3];
39
+ const enumeration = t2;
40
+ const summary = enumeration ? `${ariaLabel}: ${enumeration}` : ariaLabel;
41
+ const card = useHoverCardState(isSameBar);
42
+ const shownId = card.shown?.id;
43
+ let t3;
44
+ if ($[4] !== bars || $[5] !== card || $[6] !== className || $[7] !== maxValue || $[8] !== minBarHeight || $[9] !== ref || $[10] !== renderPopover || $[11] !== showLabels || $[12] !== shownId || $[13] !== style || $[14] !== summary) {
45
+ let t4;
46
+ if ($[16] !== shownId) {
47
+ t4 = (bar_0) => bar_0.id === shownId;
48
+ $[16] = shownId;
49
+ $[17] = t4;
50
+ } else t4 = $[17];
51
+ const shownBar = bars.find(t4);
52
+ const cardContent = shownBar && renderPopover?.(shownBar);
53
+ let t5;
54
+ if ($[18] !== className) {
55
+ t5 = clsx$1(BarChart_module_default["bar-chart"], className);
56
+ $[18] = className;
57
+ $[19] = t5;
58
+ } else t5 = $[19];
59
+ let t6;
60
+ if ($[20] !== maxValue) {
61
+ t6 = /* @__PURE__ */ jsx("div", {
62
+ className: BarChart_module_default.max,
63
+ "data-slot": "bar-chart-max",
64
+ children: maxValue
65
+ });
66
+ $[20] = maxValue;
67
+ $[21] = t6;
68
+ } else t6 = $[21];
69
+ let t7;
70
+ if ($[22] !== bars || $[23] !== card || $[24] !== maxValue || $[25] !== minBarHeight || $[26] !== renderPopover || $[27] !== showLabels) {
71
+ let t8;
72
+ if ($[29] !== card || $[30] !== maxValue || $[31] !== minBarHeight || $[32] !== renderPopover || $[33] !== showLabels) {
73
+ t8 = (bar_1) => {
74
+ const barElement = /* @__PURE__ */ jsx("div", {
75
+ className: BarChart_module_default.bar,
76
+ "data-slot": "bar-chart-bar",
77
+ "aria-hidden": "true",
78
+ onPointerEnter: renderPopover ? (event) => card.open({
79
+ id: bar_1.id,
80
+ element: event.currentTarget
81
+ }) : void 0,
82
+ onPointerLeave: renderPopover ? (event_0) => card.leave({
83
+ id: bar_1.id,
84
+ element: event_0.currentTarget
85
+ }) : void 0,
86
+ children: bar_1.value > 0 && /* @__PURE__ */ jsx("div", {
87
+ className: BarChart_module_default.value,
88
+ "data-slot": "bar-chart-value",
89
+ style: {
90
+ "--viz-bar-chart-size": `${bar_1.value / maxValue * 100}`,
91
+ "--viz-bar-chart-color": bar_1.color,
92
+ "--viz-bar-chart-min-height": minBarHeight === void 0 ? void 0 : `${minBarHeight}px`
93
+ }
94
+ })
95
+ }, bar_1.id);
96
+ const withHint = !renderPopover && bar_1.label != null ? /* @__PURE__ */ jsx(Tooltip, {
97
+ label: `${bar_1.label}: ${bar_1.value}`,
98
+ side: "bottom",
99
+ children: barElement
100
+ }, bar_1.id) : barElement;
101
+ return showLabels && bar_1.label != null ? /* @__PURE__ */ jsxs("div", {
102
+ className: "flex min-w-0 flex-1 flex-col",
103
+ "data-slot": "bar-chart-column",
104
+ children: [withHint, /* @__PURE__ */ jsx("div", {
105
+ className: "text-viz-muted mono mt-1 truncate text-left text-[.5625rem]",
106
+ "data-slot": "bar-chart-label",
107
+ "aria-hidden": "true",
108
+ children: bar_1.label
109
+ })]
110
+ }, bar_1.id) : withHint;
111
+ };
112
+ $[29] = card;
113
+ $[30] = maxValue;
114
+ $[31] = minBarHeight;
115
+ $[32] = renderPopover;
116
+ $[33] = showLabels;
117
+ $[34] = t8;
118
+ } else t8 = $[34];
119
+ t7 = bars.map(t8);
120
+ $[22] = bars;
121
+ $[23] = card;
122
+ $[24] = maxValue;
123
+ $[25] = minBarHeight;
124
+ $[26] = renderPopover;
125
+ $[27] = showLabels;
126
+ $[28] = t7;
127
+ } else t7 = $[28];
128
+ t3 = /* @__PURE__ */ jsxs("div", {
129
+ ref,
130
+ className: t5,
131
+ style,
132
+ "data-slot": "bar-chart",
133
+ role: "img",
134
+ "aria-label": summary,
135
+ children: [
136
+ t6,
137
+ t7,
138
+ renderPopover && /* @__PURE__ */ jsx(Popover, {
139
+ ...card.popoverProps,
140
+ open: card.popoverProps.open && hasPopoverContent(cardContent),
141
+ "aria-label": "Bar details",
142
+ anchor: card.shown?.element ?? null,
143
+ side: "bottom",
144
+ sideOffset: 6,
145
+ children: cardContent
146
+ })
147
+ ]
148
+ });
149
+ $[4] = bars;
150
+ $[5] = card;
151
+ $[6] = className;
152
+ $[7] = maxValue;
153
+ $[8] = minBarHeight;
154
+ $[9] = ref;
155
+ $[10] = renderPopover;
156
+ $[11] = showLabels;
157
+ $[12] = shownId;
158
+ $[13] = style;
159
+ $[14] = summary;
160
+ $[15] = t3;
161
+ } else t3 = $[15];
162
+ return t3;
163
+ }
164
+ function _temp(bar) {
165
+ return bar.value;
166
+ }
167
+ export { BarChart as default };