@timefoldai/viz-react 0.0.0 → 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 (288) hide show
  1. package/README.md +239 -1
  2. package/dist/THIRD-PARTY-NOTICES.txt +99 -0
  3. package/dist/a11y/AccessibleTable.d.mts +42 -0
  4. package/dist/a11y/AccessibleTable.mjs +82 -0
  5. package/dist/a11y/activation.d.mts +4 -0
  6. package/dist/a11y/activation.mjs +0 -0
  7. package/dist/analytics/AnalyticsProvider.d.mts +16 -0
  8. package/dist/analytics/AnalyticsProvider.mjs +32 -0
  9. package/dist/assets/Inter-latin-ext.woff2 +0 -0
  10. package/dist/badge/Badge.css +122 -0
  11. package/dist/badge/Badge.d.mts +50 -0
  12. package/dist/badge/Badge.mjs +145 -0
  13. package/dist/badge/Badge.module.css.mjs +15 -0
  14. package/dist/badge/BadgeFacetGroup.d.mts +23 -0
  15. package/dist/badge/BadgeFacetGroup.mjs +220 -0
  16. package/dist/badge/BadgeGroup.d.mts +13 -0
  17. package/dist/badge/BadgeGroup.mjs +53 -0
  18. package/dist/badge/BadgeList.d.mts +14 -0
  19. package/dist/badge/BadgeList.mjs +15 -0
  20. package/dist/badge/badge-facet-fit.d.mts +18 -0
  21. package/dist/badge/badge-facet-fit.mjs +50 -0
  22. package/dist/badge/badge-item.d.mts +19 -0
  23. package/dist/badge/badge-item.mjs +23 -0
  24. package/dist/button/CopyButton.d.mts +12 -0
  25. package/dist/button/CopyButton.mjs +52 -0
  26. package/dist/button/ShowAllButton.d.mts +14 -0
  27. package/dist/button/ShowAllButton.mjs +61 -0
  28. package/dist/button/ShowMoreButton.d.mts +13 -0
  29. package/dist/button/ShowMoreButton.mjs +51 -0
  30. package/dist/button/SolveButton.d.mts +16 -0
  31. package/dist/button/SolveButton.mjs +56 -0
  32. package/dist/charts/BarChart.css +59 -0
  33. package/dist/charts/BarChart.d.mts +26 -0
  34. package/dist/charts/BarChart.mjs +167 -0
  35. package/dist/charts/BarChart.module.css.mjs +10 -0
  36. package/dist/charts/ChartGrid.d.mts +8 -0
  37. package/dist/charts/ChartGrid.mjs +47 -0
  38. package/dist/charts/DistributionChart.d.mts +60 -0
  39. package/dist/charts/DistributionChart.mjs +151 -0
  40. package/dist/code/CodeBlock.d.mts +13 -0
  41. package/dist/code/CodeBlock.mjs +71 -0
  42. package/dist/composition-bar/CompositionBar.d.mts +24 -0
  43. package/dist/composition-bar/CompositionBar.mjs +124 -0
  44. package/dist/composition-bar/composition-shares.d.mts +8 -0
  45. package/dist/composition-bar/composition-shares.mjs +30 -0
  46. package/dist/data-gate/DataGate.d.mts +34 -0
  47. package/dist/data-gate/DataGate.mjs +80 -0
  48. package/dist/date-scope/DateScope.d.mts +30 -0
  49. package/dist/date-scope/DateScope.mjs +285 -0
  50. package/dist/design-system/part-props.d.mts +39 -0
  51. package/dist/design-system/part-props.mjs +0 -0
  52. package/dist/detail-panel/DetailPanel.d.mts +22 -0
  53. package/dist/detail-panel/DetailPanel.mjs +80 -0
  54. package/dist/detail-panel/DetailPanelSection.d.mts +20 -0
  55. package/dist/detail-panel/DetailPanelSection.mjs +27 -0
  56. package/dist/detail-panel/micro-label.d.mts +7 -0
  57. package/dist/detail-panel/micro-label.mjs +9 -0
  58. package/dist/env.d.mts +2 -0
  59. package/dist/env.mjs +4 -0
  60. package/dist/export/ExportCsvButton.d.mts +19 -0
  61. package/dist/export/ExportCsvButton.mjs +73 -0
  62. package/dist/export/download-csv.d.mts +5 -0
  63. package/dist/export/download-csv.mjs +11 -0
  64. package/dist/export/download-file.d.mts +11 -0
  65. package/dist/export/download-file.mjs +32 -0
  66. package/dist/export/download-json.d.mts +2 -0
  67. package/dist/export/download-json.mjs +8 -0
  68. package/dist/filter/FilterGroup.d.mts +24 -0
  69. package/dist/filter/FilterGroup.mjs +71 -0
  70. package/dist/filter/FilterGroupTitle.d.mts +3 -0
  71. package/dist/filter/FilterGroupTitle.mjs +18 -0
  72. package/dist/filter/FilterItem.d.mts +17 -0
  73. package/dist/filter/FilterItem.mjs +94 -0
  74. package/dist/filter/FilterPanel.d.mts +22 -0
  75. package/dist/filter/FilterPanel.mjs +158 -0
  76. package/dist/filter/FilterToggleButton.d.mts +15 -0
  77. package/dist/filter/FilterToggleButton.mjs +30 -0
  78. package/dist/filter/date-range.d.mts +8 -0
  79. package/dist/filter/date-range.mjs +13 -0
  80. package/dist/filter/filter-facet.d.mts +7 -0
  81. package/dist/filter/filter-facet.mjs +0 -0
  82. package/dist/heatmap/Heatmap.css +138 -0
  83. package/dist/heatmap/Heatmap.d.mts +10 -0
  84. package/dist/heatmap/Heatmap.mjs +370 -0
  85. package/dist/heatmap/Heatmap.module.css.mjs +17 -0
  86. package/dist/heatmap/HeatmapCell.d.mts +25 -0
  87. package/dist/heatmap/HeatmapCell.mjs +124 -0
  88. package/dist/heatmap/heatmap-scale.d.mts +19 -0
  89. package/dist/heatmap/heatmap-scale.mjs +43 -0
  90. package/dist/heatmap/heatmap-types.d.mts +49 -0
  91. package/dist/heatmap/heatmap-types.mjs +0 -0
  92. package/dist/hooks/use-controllable-state.d.mts +9 -0
  93. package/dist/hooks/use-controllable-state.mjs +44 -0
  94. package/dist/hooks/use-debounced-value.d.mts +1 -0
  95. package/dist/hooks/use-debounced-value.mjs +27 -0
  96. package/dist/hooks/use-detail-panel-layout.d.mts +18 -0
  97. package/dist/hooks/use-detail-panel-layout.mjs +94 -0
  98. package/dist/hooks/use-hover-card.d.mts +47 -0
  99. package/dist/hooks/use-hover-card.mjs +190 -0
  100. package/dist/hooks/use-hover-focus-card.d.mts +38 -0
  101. package/dist/hooks/use-hover-focus-card.mjs +321 -0
  102. package/dist/hooks/use-hover-intent.d.mts +6 -0
  103. package/dist/hooks/use-hover-intent.mjs +55 -0
  104. package/dist/hooks/use-merged-ref.d.mts +2 -0
  105. package/dist/hooks/use-merged-ref.mjs +36 -0
  106. package/dist/hooks/use-tracked-anchor.d.mts +14 -0
  107. package/dist/hooks/use-tracked-anchor.mjs +42 -0
  108. package/dist/index.d.mts +97 -0
  109. package/dist/index.mjs +88 -0
  110. package/dist/input/MenuButton.d.mts +47 -0
  111. package/dist/input/MenuButton.mjs +152 -0
  112. package/dist/interval-strip/IntervalStrip.css +7 -0
  113. package/dist/interval-strip/IntervalStrip.d.mts +39 -0
  114. package/dist/interval-strip/IntervalStrip.mjs +233 -0
  115. package/dist/interval-strip/IntervalStrip.module.css.mjs +4 -0
  116. package/dist/interval-strip/IntervalStripAxis.d.mts +18 -0
  117. package/dist/interval-strip/IntervalStripAxis.mjs +73 -0
  118. package/dist/interval-strip/interval-fill.d.mts +2 -0
  119. package/dist/interval-strip/interval-fill.mjs +13 -0
  120. package/dist/interval-strip/interval-layout.d.mts +33 -0
  121. package/dist/interval-strip/interval-layout.mjs +79 -0
  122. package/dist/layout/AppShell.css +103 -0
  123. package/dist/layout/AppShell.d.mts +73 -0
  124. package/dist/layout/AppShell.mjs +397 -0
  125. package/dist/layout/AppShell.module.css.mjs +16 -0
  126. package/dist/layout/ColorSchemeMenu.d.mts +14 -0
  127. package/dist/layout/ColorSchemeMenu.mjs +92 -0
  128. package/dist/layout/DemoDataPicker.d.mts +17 -0
  129. package/dist/layout/DemoDataPicker.mjs +150 -0
  130. package/dist/layout/OverflowMenu.d.mts +11 -0
  131. package/dist/layout/OverflowMenu.mjs +94 -0
  132. package/dist/layout/SidebarLayout.css +70 -0
  133. package/dist/layout/SidebarLayout.d.mts +33 -0
  134. package/dist/layout/SidebarLayout.mjs +129 -0
  135. package/dist/layout/SidebarLayout.module.css.mjs +8 -0
  136. package/dist/layout/use-date-scope-day.d.mts +23 -0
  137. package/dist/layout/use-date-scope-day.mjs +63 -0
  138. package/dist/layout/use-fill-height.d.mts +7 -0
  139. package/dist/layout/use-fill-height.mjs +50 -0
  140. package/dist/layout/use-followed-state.d.mts +5 -0
  141. package/dist/layout/use-followed-state.mjs +75 -0
  142. package/dist/layout/use-page-route.d.mts +10 -0
  143. package/dist/layout/use-page-route.mjs +65 -0
  144. package/dist/legend/Legend.d.mts +54 -0
  145. package/dist/legend/Legend.mjs +132 -0
  146. package/dist/map/MapLayersControl.d.mts +11 -0
  147. package/dist/map/MapLayersControl.mjs +157 -0
  148. package/dist/map/MapLocator.css +9 -0
  149. package/dist/map/MapLocator.d.mts +18 -0
  150. package/dist/map/MapLocator.mjs +97 -0
  151. package/dist/map/MapLocator.module.css.mjs +4 -0
  152. package/dist/map/MapMarker.d.mts +29 -0
  153. package/dist/map/MapMarker.mjs +265 -0
  154. package/dist/map/MapStops.d.mts +19 -0
  155. package/dist/map/MapStops.mjs +355 -0
  156. package/dist/map/MapView.css +24 -0
  157. package/dist/map/MapView.d.mts +11 -0
  158. package/dist/map/MapView.mjs +141 -0
  159. package/dist/map/MapWebgl.d.mts +9 -0
  160. package/dist/map/MapWebgl.mjs +727 -0
  161. package/dist/map/area-layers.d.mts +33 -0
  162. package/dist/map/area-layers.mjs +96 -0
  163. package/dist/map/control-group.d.mts +6 -0
  164. package/dist/map/control-group.mjs +12 -0
  165. package/dist/map/for-each-chunk.d.mts +4 -0
  166. package/dist/map/for-each-chunk.mjs +14 -0
  167. package/dist/map/highlight.d.mts +30 -0
  168. package/dist/map/highlight.mjs +99 -0
  169. package/dist/map/locator-tile.d.mts +24 -0
  170. package/dist/map/locator-tile.mjs +41 -0
  171. package/dist/map/map-sites.d.mts +12 -0
  172. package/dist/map/map-sites.mjs +39 -0
  173. package/dist/map/map-style.d.mts +24 -0
  174. package/dist/map/map-style.mjs +79 -0
  175. package/dist/map/marker-geometry.d.mts +5 -0
  176. package/dist/map/marker-geometry.mjs +13 -0
  177. package/dist/map/marker-icon.d.mts +26 -0
  178. package/dist/map/marker-icon.mjs +223 -0
  179. package/dist/map/observe-color-scheme.d.mts +5 -0
  180. package/dist/map/observe-color-scheme.mjs +19 -0
  181. package/dist/map/popup-placement.d.mts +20 -0
  182. package/dist/map/popup-placement.mjs +20 -0
  183. package/dist/map/route-layers.d.mts +28 -0
  184. package/dist/map/route-layers.mjs +73 -0
  185. package/dist/map/types.d.mts +97 -0
  186. package/dist/map/types.mjs +0 -0
  187. package/dist/map/use-painted-color-scheme.d.mts +6 -0
  188. package/dist/map/use-painted-color-scheme.mjs +43 -0
  189. package/dist/map/use-resolved-colors.d.mts +5 -0
  190. package/dist/map/use-resolved-colors.mjs +63 -0
  191. package/dist/pagination/paginationLabels.d.mts +6 -0
  192. package/dist/pagination/paginationLabels.mjs +8 -0
  193. package/dist/popover/Popover.css +176 -0
  194. package/dist/popover/Popover.d.mts +239 -0
  195. package/dist/popover/Popover.mjs +672 -0
  196. package/dist/popover/Popover.module.css.mjs +18 -0
  197. package/dist/popover/PopoverFacts.d.mts +24 -0
  198. package/dist/popover/PopoverFacts.mjs +63 -0
  199. package/dist/readout/Readout.d.mts +15 -0
  200. package/dist/readout/Readout.mjs +53 -0
  201. package/dist/readout/TimeZoneReadout.d.mts +11 -0
  202. package/dist/readout/TimeZoneReadout.mjs +46 -0
  203. package/dist/score-box/ScoreBox.css +62 -0
  204. package/dist/score-box/ScoreBox.d.mts +12 -0
  205. package/dist/score-box/ScoreBox.mjs +143 -0
  206. package/dist/score-box/ScoreBox.module.css.mjs +15 -0
  207. package/dist/segment-bar/Segment.d.mts +23 -0
  208. package/dist/segment-bar/Segment.mjs +27 -0
  209. package/dist/segment-bar/SegmentBar.css +44 -0
  210. package/dist/segment-bar/SegmentBar.d.mts +35 -0
  211. package/dist/segment-bar/SegmentBar.mjs +57 -0
  212. package/dist/segment-bar/SegmentBar.module.css.mjs +9 -0
  213. package/dist/segment-bar/segment-box.d.mts +10 -0
  214. package/dist/segment-bar/segment-box.mjs +30 -0
  215. package/dist/stat/Stat.d.mts +25 -0
  216. package/dist/stat/Stat.mjs +36 -0
  217. package/dist/stat/StatTile.d.mts +18 -0
  218. package/dist/stat/StatTile.mjs +37 -0
  219. package/dist/styles.css +1 -0
  220. package/dist/swatch/Swatch.d.mts +8 -0
  221. package/dist/swatch/Swatch.mjs +30 -0
  222. package/dist/swatch/legend-swatch.d.mts +3 -0
  223. package/dist/swatch/legend-swatch.mjs +0 -0
  224. package/dist/tab-bar/FilteredTabBar.d.mts +32 -0
  225. package/dist/tab-bar/FilteredTabBar.mjs +181 -0
  226. package/dist/tab-bar/TabBar.d.mts +22 -0
  227. package/dist/tab-bar/TabBar.mjs +151 -0
  228. package/dist/tab-bar/TabPanel.d.mts +9 -0
  229. package/dist/tab-bar/TabPanel.mjs +55 -0
  230. package/dist/tab-bar/assert-named-value.d.mts +4 -0
  231. package/dist/tab-bar/assert-named-value.mjs +6 -0
  232. package/dist/table/DataTable.d.mts +31 -0
  233. package/dist/table/DataTable.mjs +43 -0
  234. package/dist/theme/use-color-scheme.d.mts +14 -0
  235. package/dist/theme/use-color-scheme.mjs +92 -0
  236. package/dist/theme.css +58 -0
  237. package/dist/timeline/Timeline.d.mts +54 -0
  238. package/dist/timeline/Timeline.mjs +220 -0
  239. package/dist/timeline/TimelineBand.d.mts +18 -0
  240. package/dist/timeline/TimelineBand.mjs +30 -0
  241. package/dist/timeline/TimelineGroup.d.mts +7 -0
  242. package/dist/timeline/TimelineGroup.mjs +50 -0
  243. package/dist/timeline/TimelineItem.d.mts +19 -0
  244. package/dist/timeline/TimelineItem.mjs +64 -0
  245. package/dist/timeline/TimelineItemChip.css +153 -0
  246. package/dist/timeline/TimelineItemChip.d.mts +23 -0
  247. package/dist/timeline/TimelineItemChip.mjs +74 -0
  248. package/dist/timeline/TimelineItemChip.module.css.mjs +15 -0
  249. package/dist/timeline/TimelineItemMark.css +38 -0
  250. package/dist/timeline/TimelineItemMark.d.mts +15 -0
  251. package/dist/timeline/TimelineItemMark.mjs +129 -0
  252. package/dist/timeline/TimelineItemMark.module.css.mjs +4 -0
  253. package/dist/timeline/TimelineRoot.d.mts +19 -0
  254. package/dist/timeline/TimelineRoot.mjs +742 -0
  255. package/dist/timeline/TimelineRowHeader.d.mts +23 -0
  256. package/dist/timeline/TimelineRowHeader.mjs +244 -0
  257. package/dist/timeline/TimelineZoomHint.d.mts +9 -0
  258. package/dist/timeline/TimelineZoomHint.mjs +32 -0
  259. package/dist/timeline/axis-label.d.mts +5 -0
  260. package/dist/timeline/axis-label.mjs +53 -0
  261. package/dist/timeline/batched-dataset-writer.d.mts +29 -0
  262. package/dist/timeline/batched-dataset-writer.mjs +58 -0
  263. package/dist/timeline/row-card-side.d.mts +7 -0
  264. package/dist/timeline/row-card-side.mjs +6 -0
  265. package/dist/timeline/timeline-a11y.d.mts +33 -0
  266. package/dist/timeline/timeline-a11y.mjs +96 -0
  267. package/dist/timeline/timeline-context.d.mts +33 -0
  268. package/dist/timeline/timeline-context.mjs +40 -0
  269. package/dist/timeline/timeline-types.d.mts +126 -0
  270. package/dist/timeline/timeline-types.mjs +0 -0
  271. package/dist/timeline/timeline-utils.d.mts +52 -0
  272. package/dist/timeline/timeline-utils.mjs +130 -0
  273. package/dist/timeline/zoom-modifier.d.mts +21 -0
  274. package/dist/timeline/zoom-modifier.mjs +25 -0
  275. package/dist/toast/ToastProvider.d.mts +33 -0
  276. package/dist/toast/ToastProvider.mjs +257 -0
  277. package/dist/toast/toast-context.d.mts +2 -0
  278. package/dist/toast/toast-context.mjs +5 -0
  279. package/dist/tokens.css +1 -0
  280. package/dist/tooltip/Tooltip.d.mts +17 -0
  281. package/dist/tooltip/Tooltip.mjs +41 -0
  282. package/dist/tooltip/hover-open-delay.d.mts +2 -0
  283. package/dist/tooltip/hover-open-delay.mjs +4 -0
  284. package/dist/tooltip/is-text-cut.d.mts +1 -0
  285. package/dist/tooltip/is-text-cut.mjs +5 -0
  286. package/dist/vendor/components.d.mts +664 -0
  287. package/dist/vendor/components.mjs +2060 -0
  288. package/package.json +56 -5
@@ -0,0 +1,50 @@
1
+ import { SlotIcon } from "../vendor/components.mjs";
2
+ import { VizCategory } from "@timefoldai/viz-core";
3
+ /** A verdict on a record; a badge with no `state` and no `category` is neutral. */
4
+ export type BadgeState = "positive" | "negative" | "warning";
5
+ /** The badge forms other than the default label: the `outline` count pill and the `priority` compound. */
6
+ export type BadgeVariant = "outline" | "priority";
7
+ /** The `Badge` props shared by every badge form. */
8
+ export interface BadgeBaseProps extends Omit<React.ComponentProps<"span">, "color"> {
9
+ temporary?: boolean;
10
+ }
11
+ /** `ComponentProps<"span">` gives every span attribute pass-through, including `ref`. */
12
+ export type BadgeProps = BadgeBaseProps & ({
13
+ variant: "outline";
14
+ count?: number;
15
+ label?: never;
16
+ category?: never;
17
+ state?: never;
18
+ fullLabel?: never;
19
+ border?: never;
20
+ leadingIcon?: never;
21
+ trailingIcon?: never;
22
+ } | {
23
+ variant: "priority";
24
+ label: string;
25
+ count?: never;
26
+ category?: never;
27
+ state?: never;
28
+ fullLabel?: never;
29
+ border?: never;
30
+ leadingIcon?: never;
31
+ trailingIcon?: never;
32
+ } | {
33
+ variant?: never;
34
+ label?: never;
35
+ count?: never;
36
+ category?: VizCategory;
37
+ state?: BadgeState;
38
+ fullLabel?: string;
39
+ border?: boolean;
40
+ leadingIcon?: SlotIcon;
41
+ trailingIcon?: SlotIcon;
42
+ });
43
+ /**
44
+ * The design-system badge, plus the viz parts it cannot draw: a categorical colour, a cut label
45
+ * with its tooltip, the outline pill with its count, the priority compound and the temporary mark.
46
+ *
47
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
48
+ * @category Data display
49
+ */
50
+ export default function Badge(props: BadgeProps): import("react").JSX.Element;
@@ -0,0 +1,145 @@
1
+ "use client";
2
+ import { isTextCut } from "../tooltip/is-text-cut.mjs";
3
+ import Tooltip$1 from "../tooltip/Tooltip.mjs";
4
+ import Badge_module_default from "./Badge.module.css.mjs";
5
+ import { c } from "react/compiler-runtime";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { useCallback, useRef, useState } from "react";
8
+ import { Badge as Badge$1 } from "../vendor/components.mjs";
9
+ import clsx$1 from "clsx";
10
+ // src/badge/Badge.tsx
11
+ const STATE_COLOR = {
12
+ positive: "green",
13
+ negative: "red",
14
+ warning: "yellow"
15
+ };
16
+ /**
17
+ * The design-system badge, plus the viz parts it cannot draw: a categorical colour, a cut label
18
+ * with its tooltip, the outline pill with its count, the priority compound and the temporary mark.
19
+ *
20
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
21
+ * @category Data display
22
+ */
23
+ function Badge(props) {
24
+ const $ = c(6);
25
+ if (props.variant === "priority") {
26
+ let t0;
27
+ if ($[0] !== props) {
28
+ t0 = /* @__PURE__ */ jsx(PriorityBadge, { ...props });
29
+ $[0] = props;
30
+ $[1] = t0;
31
+ } else t0 = $[1];
32
+ return t0;
33
+ }
34
+ if (props.variant === "outline") {
35
+ let t0;
36
+ if ($[2] !== props) {
37
+ t0 = /* @__PURE__ */ jsx(OutlineBadge, { ...props });
38
+ $[2] = props;
39
+ $[3] = t0;
40
+ } else t0 = $[3];
41
+ return t0;
42
+ }
43
+ let t0;
44
+ if ($[4] !== props) {
45
+ t0 = /* @__PURE__ */ jsx(PillBadge, { ...props });
46
+ $[4] = props;
47
+ $[5] = t0;
48
+ } else t0 = $[5];
49
+ return t0;
50
+ }
51
+ function OutlineBadge({ count, children, className, temporary = false, variant, ...props }) {
52
+ return /* @__PURE__ */ jsxs("span", {
53
+ "data-slot": "badge",
54
+ "data-variant": variant,
55
+ className: clsx$1(Badge_module_default.outline, "max-w-full shrink-0 overflow-hidden", temporary && Badge_module_default.temporary, className),
56
+ ...props,
57
+ children: [
58
+ count !== void 0 && /* @__PURE__ */ jsx("span", {
59
+ className: Badge_module_default.count,
60
+ "data-slot": "badge-count",
61
+ children: count
62
+ }),
63
+ children,
64
+ temporary && /* @__PURE__ */ jsx("span", {
65
+ className: "sr-only",
66
+ children: " (temporary)"
67
+ })
68
+ ]
69
+ });
70
+ }
71
+ function PriorityBadge({ label, children, className, temporary = false, variant, ...props }) {
72
+ return /* @__PURE__ */ jsxs("span", {
73
+ "data-slot": "badge",
74
+ "data-variant": variant,
75
+ className: clsx$1(Badge_module_default.priority, temporary && Badge_module_default.temporary, className),
76
+ ...props,
77
+ children: [
78
+ /* @__PURE__ */ jsx("span", {
79
+ className: Badge_module_default["priority-label"],
80
+ children: label
81
+ }),
82
+ /* @__PURE__ */ jsx("span", {
83
+ className: Badge_module_default["priority-value"],
84
+ "data-slot": "badge-priority-value",
85
+ children
86
+ }),
87
+ temporary && /* @__PURE__ */ jsx("span", {
88
+ className: "sr-only",
89
+ children: " (temporary)"
90
+ })
91
+ ]
92
+ });
93
+ }
94
+ function PillBadge({ category, className, children, state, temporary = false, fullLabel, border, leadingIcon, trailingIcon, style, ...props }) {
95
+ const labelRef = useRef(null);
96
+ const [labelCut, setLabelCut] = useState(false);
97
+ const isLabelCut = () => isTextCut(labelRef.current);
98
+ const watchLabel = useCallback((label) => {
99
+ labelRef.current = label;
100
+ if (!label) return;
101
+ const measure = () => setLabelCut(isTextCut(label));
102
+ const resizes = new ResizeObserver(measure);
103
+ const edits = new MutationObserver(measure);
104
+ resizes.observe(label);
105
+ edits.observe(label, {
106
+ subtree: true,
107
+ childList: true,
108
+ characterData: true
109
+ });
110
+ return () => {
111
+ resizes.disconnect();
112
+ edits.disconnect();
113
+ };
114
+ }, []);
115
+ const badge = /* @__PURE__ */ jsxs(Badge$1, {
116
+ "data-slot": "badge",
117
+ "data-state": state,
118
+ tabIndex: labelCut ? 0 : void 0,
119
+ color: state === void 0 ? "neutral" : STATE_COLOR[state],
120
+ border,
121
+ leadingIcon,
122
+ trailingIcon,
123
+ className: clsx$1(Badge_module_default.badge, "relative max-w-full shrink-0 overflow-hidden", temporary && Badge_module_default.temporary, category != null && Badge_module_default.categorised, className),
124
+ style: {
125
+ ...category != null ? { "--viz-badge-color": `var(--viz-cat-${category})` } : void 0,
126
+ ...style
127
+ },
128
+ ...props,
129
+ children: [fullLabel === void 0 ? children : /* @__PURE__ */ jsx("span", {
130
+ ref: watchLabel,
131
+ "data-slot": "badge-label",
132
+ className: "relative min-w-0 truncate",
133
+ children
134
+ }), temporary && /* @__PURE__ */ jsx("span", {
135
+ className: "sr-only",
136
+ children: " (temporary)"
137
+ })]
138
+ });
139
+ return fullLabel === void 0 ? badge : /* @__PURE__ */ jsx(Tooltip$1, {
140
+ label: fullLabel,
141
+ shouldOpen: isLabelCut,
142
+ children: badge
143
+ });
144
+ }
145
+ export { Badge as default };
@@ -0,0 +1,15 @@
1
+ import './Badge.css';
2
+ // src/badge/Badge.module.css
3
+ var Badge_module_default = {
4
+ "badge": "aNZ4oW_badge",
5
+ "badge-group": "aNZ4oW_badge-group",
6
+ "categorised": "aNZ4oW_categorised",
7
+ "count": "aNZ4oW_count",
8
+ "no-wrap": "aNZ4oW_no-wrap",
9
+ "outline": "aNZ4oW_outline",
10
+ "priority": "aNZ4oW_priority",
11
+ "priority-label": "aNZ4oW_priority-label",
12
+ "priority-value": "aNZ4oW_priority-value",
13
+ "temporary": "aNZ4oW_temporary"
14
+ };
15
+ export { Badge_module_default as default };
@@ -0,0 +1,23 @@
1
+ import { BadgeListValue } from "./badge-item.mjs";
2
+ import { SlotIcon } from "../vendor/components.mjs";
3
+ /**
4
+ * One facet's values, plus the icon rendered before each of its badges (skills, tags, risk
5
+ * factors, …).
6
+ */
7
+ export interface BadgeFacet {
8
+ items: BadgeListValue[] | null | undefined;
9
+ icon?: SlotIcon;
10
+ /** @defaultValue false */
11
+ temporary?: boolean;
12
+ }
13
+ /** The props of `BadgeFacetGroup`: its labelled facets and the attributes of its root `div`. */
14
+ export interface BadgeFacetGroupProps extends Omit<React.ComponentProps<"div">, "children"> {
15
+ facets: BadgeFacet[];
16
+ noWrap?: boolean;
17
+ }
18
+ /**
19
+ * Several `BadgeList`-shaped facets sharing one overflow budget, folding overflow into a
20
+ * single trailing "+N" chip.
21
+ * @category Data display
22
+ */
23
+ export default function BadgeFacetGroup({ facets, noWrap, ref, ...props }: BadgeFacetGroupProps): import("react").JSX.Element | null;
@@ -0,0 +1,220 @@
1
+ "use client";
2
+ import { useMergedRef } from "../hooks/use-merged-ref.mjs";
3
+ import Badge from "./Badge.mjs";
4
+ import { fitWithReservedChip, growWithExactChip } from "./badge-facet-fit.mjs";
5
+ import { renderBadgeItem, valueOf } from "./badge-item.mjs";
6
+ import BadgeGroup from "./BadgeGroup.mjs";
7
+ import { c } from "react/compiler-runtime";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { useEffect, useState } from "react";
10
+ // src/badge/BadgeFacetGroup.tsx
11
+ const KEY_SEPARATOR = "\0";
12
+ const MEASURER_STYLE = {
13
+ position: "fixed",
14
+ top: -9999,
15
+ left: -9999,
16
+ visibility: "hidden",
17
+ width: "max-content",
18
+ pointerEvents: "none"
19
+ };
20
+ function renderedWidth(el) {
21
+ return el.getBoundingClientRect().width;
22
+ }
23
+ /**
24
+ * Several `BadgeList`-shaped facets sharing one overflow budget, folding overflow into a
25
+ * single trailing "+N" chip.
26
+ * @category Data display
27
+ */
28
+ function BadgeFacetGroup(t0) {
29
+ const $ = c(35);
30
+ let facets;
31
+ let noWrap;
32
+ let props;
33
+ let ref;
34
+ if ($[0] !== t0) {
35
+ ({facets, noWrap, ref, ...props} = t0);
36
+ $[0] = t0;
37
+ $[1] = facets;
38
+ $[2] = noWrap;
39
+ $[3] = props;
40
+ $[4] = ref;
41
+ } else {
42
+ facets = $[1];
43
+ noWrap = $[2];
44
+ props = $[3];
45
+ ref = $[4];
46
+ }
47
+ const entries = facets.flatMap(_temp);
48
+ const entryCount = entries.length;
49
+ const entriesKey = entries.map(_temp2).join(KEY_SEPARATOR);
50
+ const [measurerEl, setMeasurerEl] = useState(null);
51
+ const [containerEl, setContainerEl] = useState(null);
52
+ const containerRef = useMergedRef(setContainerEl, ref);
53
+ const [containerWidth, setContainerWidth] = useState(0);
54
+ const [measurement, setMeasurement] = useState(null);
55
+ const [chipCorrection, setChipCorrection] = useState(null);
56
+ useEffect(() => {
57
+ if (!measurerEl || entryCount === 0) return;
58
+ const measure = () => {
59
+ const badgeWidths = Array.from(measurerEl.querySelectorAll(":scope > [data-slot=\"badge\"]"), renderedWidth);
60
+ const reservedChipWidth = badgeWidths.pop();
61
+ if (reservedChipWidth === void 0) return;
62
+ setMeasurement({
63
+ entriesKey,
64
+ widths: badgeWidths,
65
+ gap: parseFloat(getComputedStyle(measurerEl).columnGap) || 0,
66
+ reservedChipWidth
67
+ });
68
+ };
69
+ const observer = new ResizeObserver(measure);
70
+ observer.observe(measurerEl);
71
+ return () => observer.disconnect();
72
+ }, [
73
+ measurerEl,
74
+ entriesKey,
75
+ entryCount
76
+ ]);
77
+ let t1;
78
+ let t2;
79
+ if ($[5] !== containerEl) {
80
+ t1 = () => {
81
+ if (!containerEl) return;
82
+ const observer_0 = new ResizeObserver((observerEntries) => {
83
+ setContainerWidth(observerEntries[0]?.contentRect.width ?? 0);
84
+ });
85
+ observer_0.observe(containerEl);
86
+ return () => observer_0.disconnect();
87
+ };
88
+ t2 = [containerEl];
89
+ $[5] = containerEl;
90
+ $[6] = t1;
91
+ $[7] = t2;
92
+ } else {
93
+ t1 = $[6];
94
+ t2 = $[7];
95
+ }
96
+ useEffect(t1, t2);
97
+ const reservedFit = measurement?.entriesKey === entriesKey && containerWidth > 0 ? fitWithReservedChip(measurement.widths, measurement.gap, containerWidth, measurement.reservedChipWidth) : null;
98
+ const isChipCorrected = chipCorrection?.measurement === measurement && chipCorrection.containerWidth === containerWidth;
99
+ const layout = isChipCorrected ? chipCorrection.fit : reservedFit;
100
+ let t3;
101
+ let t4;
102
+ if ($[8] !== containerEl || $[9] !== containerWidth || $[10] !== isChipCorrected || $[11] !== measurement || $[12] !== reservedFit) {
103
+ t3 = () => {
104
+ if (!containerEl || !measurement || !reservedFit) return;
105
+ if (reservedFit.hiddenCount === 0 || isChipCorrected) return;
106
+ const badgeEls = containerEl.querySelectorAll(":scope > [data-slot=\"badge\"]");
107
+ const chipEl = badgeEls[badgeEls.length - 1];
108
+ if (chipEl?.dataset.overflowCount !== String(reservedFit.hiddenCount)) return;
109
+ setChipCorrection({
110
+ measurement,
111
+ containerWidth,
112
+ fit: growWithExactChip(measurement.widths, measurement.gap, containerWidth, reservedFit, renderedWidth(chipEl))
113
+ });
114
+ };
115
+ t4 = [
116
+ containerEl,
117
+ measurement,
118
+ reservedFit,
119
+ isChipCorrected,
120
+ containerWidth
121
+ ];
122
+ $[8] = containerEl;
123
+ $[9] = containerWidth;
124
+ $[10] = isChipCorrected;
125
+ $[11] = measurement;
126
+ $[12] = reservedFit;
127
+ $[13] = t3;
128
+ $[14] = t4;
129
+ } else {
130
+ t3 = $[13];
131
+ t4 = $[14];
132
+ }
133
+ useEffect(t3, t4);
134
+ if (entryCount === 0) return null;
135
+ const allBadges = entries.map(_temp3);
136
+ const overflowChip = _temp4;
137
+ const visibleBadges = layout ? allBadges.slice(0, layout.visibleCount) : allBadges;
138
+ let t5;
139
+ if ($[15] !== entryCount || $[16] !== overflowChip) {
140
+ t5 = overflowChip("reserve", entryCount);
141
+ $[15] = entryCount;
142
+ $[16] = overflowChip;
143
+ $[17] = t5;
144
+ } else t5 = $[17];
145
+ let t6;
146
+ if ($[18] !== allBadges || $[19] !== setMeasurerEl || $[20] !== t5) {
147
+ t6 = /* @__PURE__ */ jsxs(BadgeGroup, {
148
+ ref: setMeasurerEl,
149
+ "aria-hidden": "true",
150
+ style: MEASURER_STYLE,
151
+ children: [allBadges, t5]
152
+ });
153
+ $[18] = allBadges;
154
+ $[19] = setMeasurerEl;
155
+ $[20] = t5;
156
+ $[21] = t6;
157
+ } else t6 = $[21];
158
+ const t7 = layout ? "fitted" : "measuring";
159
+ let t8;
160
+ if ($[22] !== layout || $[23] !== overflowChip) {
161
+ t8 = layout && layout.hiddenCount > 0 && overflowChip("overflow", layout.hiddenCount);
162
+ $[22] = layout;
163
+ $[23] = overflowChip;
164
+ $[24] = t8;
165
+ } else t8 = $[24];
166
+ let t9;
167
+ if ($[25] !== containerRef || $[26] !== noWrap || $[27] !== props || $[28] !== t7 || $[29] !== t8 || $[30] !== visibleBadges) {
168
+ t9 = /* @__PURE__ */ jsxs(BadgeGroup, {
169
+ ...props,
170
+ ref: containerRef,
171
+ "data-state": t7,
172
+ noWrap,
173
+ children: [visibleBadges, t8]
174
+ });
175
+ $[25] = containerRef;
176
+ $[26] = noWrap;
177
+ $[27] = props;
178
+ $[28] = t7;
179
+ $[29] = t8;
180
+ $[30] = visibleBadges;
181
+ $[31] = t9;
182
+ } else t9 = $[31];
183
+ let t10;
184
+ if ($[32] !== t6 || $[33] !== t9) {
185
+ t10 = /* @__PURE__ */ jsxs(Fragment, { children: [t6, t9] });
186
+ $[32] = t6;
187
+ $[33] = t9;
188
+ $[34] = t10;
189
+ } else t10 = $[34];
190
+ return t10;
191
+ }
192
+ function _temp4(key, count) {
193
+ return /* @__PURE__ */ jsxs(Badge, {
194
+ "data-overflow-count": count,
195
+ children: [`+${count}`, /* @__PURE__ */ jsx("span", {
196
+ className: "sr-only",
197
+ children: " more"
198
+ })]
199
+ }, key);
200
+ }
201
+ function _temp3(t0, index) {
202
+ const { item: item_1, icon, temporary } = t0;
203
+ return renderBadgeItem(item_1, {
204
+ key: index,
205
+ icon,
206
+ temporary
207
+ });
208
+ }
209
+ function _temp2(t0) {
210
+ const { item: item_0 } = t0;
211
+ return valueOf(item_0);
212
+ }
213
+ function _temp(facet) {
214
+ return (facet.items ?? []).map((item) => ({
215
+ item,
216
+ icon: facet.icon,
217
+ temporary: facet.temporary
218
+ }));
219
+ }
220
+ export { BadgeFacetGroup as default };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `ComponentProps<"div">` gives every div attribute pass-through, including `ref` —
3
+ * `BadgeFacetGroup`'s measurer needs a ref onto this container.
4
+ */
5
+ export interface BadgeGroupProps extends React.ComponentProps<"div"> {
6
+ noWrap?: boolean;
7
+ }
8
+ /**
9
+ * A horizontal group of `Badge`s (a flex row that wraps).
10
+ *
11
+ * @category Data display
12
+ */
13
+ export default function BadgeGroup({ children, className, noWrap, ...props }: BadgeGroupProps): import("react").JSX.Element;
@@ -0,0 +1,53 @@
1
+ import Badge_module_default from "./Badge.module.css.mjs";
2
+ import { c } from "react/compiler-runtime";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import clsx$1 from "clsx";
5
+ // src/badge/BadgeGroup.tsx
6
+ /**
7
+ * A horizontal group of `Badge`s (a flex row that wraps).
8
+ *
9
+ * @category Data display
10
+ */
11
+ function BadgeGroup(t0) {
12
+ const $ = c(12);
13
+ let children;
14
+ let className;
15
+ let noWrap;
16
+ let props;
17
+ if ($[0] !== t0) {
18
+ ({children, className, noWrap, ...props} = t0);
19
+ $[0] = t0;
20
+ $[1] = children;
21
+ $[2] = className;
22
+ $[3] = noWrap;
23
+ $[4] = props;
24
+ } else {
25
+ children = $[1];
26
+ className = $[2];
27
+ noWrap = $[3];
28
+ props = $[4];
29
+ }
30
+ const t1 = noWrap && Badge_module_default["no-wrap"];
31
+ let t2;
32
+ if ($[5] !== className || $[6] !== t1) {
33
+ t2 = clsx$1(Badge_module_default["badge-group"], "flex items-center", t1, className);
34
+ $[5] = className;
35
+ $[6] = t1;
36
+ $[7] = t2;
37
+ } else t2 = $[7];
38
+ let t3;
39
+ if ($[8] !== children || $[9] !== props || $[10] !== t2) {
40
+ t3 = /* @__PURE__ */ jsx("div", {
41
+ "data-slot": "badge-group",
42
+ className: t2,
43
+ ...props,
44
+ children
45
+ });
46
+ $[8] = children;
47
+ $[9] = props;
48
+ $[10] = t2;
49
+ $[11] = t3;
50
+ } else t3 = $[11];
51
+ return t3;
52
+ }
53
+ export { BadgeGroup as default };
@@ -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;