@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,223 @@
1
+ "use client";
2
+ import { MarkerGlyph, UnmetPlate } from "./MapMarker.mjs";
3
+ import { stopPillViewBoxWidth } from "./marker-geometry.mjs";
4
+ import { c } from "react/compiler-runtime";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { flushSync } from "react-dom";
7
+ import { TbMapPinOff } from "react-icons/tb";
8
+ import { createRoot } from "react-dom/client";
9
+ // src/map/marker-icon.tsx
10
+ const ICON_PIXEL_RATIO = 2;
11
+ const GLYPH_HEIGHT = 22;
12
+ const EXTRAS_PAD = 7;
13
+ const OVERLAY_SIZE = 12;
14
+ const BADGE_HEIGHT = 12;
15
+ function glyphSize(marker) {
16
+ switch (marker.kind ?? "point") {
17
+ case "visit": return [stopPillViewBoxWidth(marker.sequence) * GLYPH_HEIGHT / 24, GLYPH_HEIGHT];
18
+ case "startLocation":
19
+ case "endLocation":
20
+ case "unassigned": return [22, 22];
21
+ case "point": return [16, 16];
22
+ case "bead": return [14, 14];
23
+ default: return [20, 20];
24
+ }
25
+ }
26
+ function countLabel(count) {
27
+ return count > 99 ? "99+" : String(count);
28
+ }
29
+ /** The image key of a site's icon: two sites share an image exactly when they look the same. */
30
+ function markerIconKey({ site, fill, textColor }, palette) {
31
+ const { marker, count, unmet } = site;
32
+ return [
33
+ marker.kind ?? "point",
34
+ marker.sequence ?? "",
35
+ marker.unreachable ? "u" : "",
36
+ unmet.map((requirement) => requirement.key).join(","),
37
+ count > 1 ? countLabel(count) : "",
38
+ fill,
39
+ textColor,
40
+ palette.halo,
41
+ palette.badge,
42
+ palette.badgeInk,
43
+ palette.unreachable,
44
+ palette.unreachableInk,
45
+ palette.unmet,
46
+ palette.unmetInk
47
+ ].join("|");
48
+ }
49
+ function MarkerIcon(t0) {
50
+ const $ = c(42);
51
+ const { site, fill, textColor, palette } = t0;
52
+ const { marker, count, unmet } = site;
53
+ let t1;
54
+ if ($[0] !== marker) {
55
+ t1 = glyphSize(marker);
56
+ $[0] = marker;
57
+ $[1] = t1;
58
+ } else t1 = $[1];
59
+ const [width, height] = t1;
60
+ const pad = count > 1 || marker.unreachable === true || unmet.length > 0 ? EXTRAS_PAD : 0;
61
+ let t2;
62
+ if ($[2] !== count) {
63
+ t2 = countLabel(count);
64
+ $[2] = count;
65
+ $[3] = t2;
66
+ } else t2 = $[3];
67
+ const label = t2;
68
+ const badgeWidth = 8 + label.length * 5.5;
69
+ const right = pad + width;
70
+ const overlayY = count > 1 ? pad + height - OVERLAY_SIZE + 4 : pad - 4;
71
+ const t3 = width + 2 * pad;
72
+ const t4 = height + 2 * pad;
73
+ const t5 = marker.kind ?? "point";
74
+ let t6;
75
+ if ($[4] !== fill || $[5] !== marker.sequence || $[6] !== palette.halo || $[7] !== t5 || $[8] !== textColor) {
76
+ t6 = /* @__PURE__ */ jsx(MarkerGlyph, {
77
+ kind: t5,
78
+ sequence: marker.sequence,
79
+ fill,
80
+ textColor,
81
+ halo: palette.halo
82
+ });
83
+ $[4] = fill;
84
+ $[5] = marker.sequence;
85
+ $[6] = palette.halo;
86
+ $[7] = t5;
87
+ $[8] = textColor;
88
+ $[9] = t6;
89
+ } else t6 = $[9];
90
+ let t7;
91
+ if ($[10] !== height || $[11] !== pad || $[12] !== t6 || $[13] !== width) {
92
+ t7 = /* @__PURE__ */ jsx("svg", {
93
+ x: pad,
94
+ y: pad,
95
+ width,
96
+ height,
97
+ children: t6
98
+ });
99
+ $[10] = height;
100
+ $[11] = pad;
101
+ $[12] = t6;
102
+ $[13] = width;
103
+ $[14] = t7;
104
+ } else t7 = $[14];
105
+ let t8;
106
+ if ($[15] !== height || $[16] !== pad || $[17] !== palette.unmet || $[18] !== palette.unmetInk || $[19] !== palette.unreachableInk || $[20] !== unmet) {
107
+ t8 = unmet.length > 0 && /* @__PURE__ */ jsx(UnmetPlate, {
108
+ unmet,
109
+ x: pad - 4,
110
+ y: pad + height - 12 + 4,
111
+ fill: palette.unmet,
112
+ ink: palette.unmetInk,
113
+ border: palette.unreachableInk
114
+ });
115
+ $[15] = height;
116
+ $[16] = pad;
117
+ $[17] = palette.unmet;
118
+ $[18] = palette.unmetInk;
119
+ $[19] = palette.unreachableInk;
120
+ $[20] = unmet;
121
+ $[21] = t8;
122
+ } else t8 = $[21];
123
+ let t9;
124
+ if ($[22] !== marker.unreachable || $[23] !== overlayY || $[24] !== palette.unreachable || $[25] !== palette.unreachableInk || $[26] !== right) {
125
+ t9 = marker.unreachable && /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
126
+ x: right - OVERLAY_SIZE + 4,
127
+ y: overlayY,
128
+ width: OVERLAY_SIZE,
129
+ height: OVERLAY_SIZE,
130
+ rx: "2",
131
+ fill: palette.unreachable,
132
+ stroke: palette.unreachableInk
133
+ }), /* @__PURE__ */ jsx(TbMapPinOff, {
134
+ x: right - OVERLAY_SIZE + 6,
135
+ y: overlayY + 2,
136
+ size: 8,
137
+ color: palette.unreachableInk
138
+ })] });
139
+ $[22] = marker.unreachable;
140
+ $[23] = overlayY;
141
+ $[24] = palette.unreachable;
142
+ $[25] = palette.unreachableInk;
143
+ $[26] = right;
144
+ $[27] = t9;
145
+ } else t9 = $[27];
146
+ let t10;
147
+ if ($[28] !== badgeWidth || $[29] !== count || $[30] !== label || $[31] !== palette.badge || $[32] !== palette.badgeInk || $[33] !== right) {
148
+ t10 = count > 1 && /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
149
+ x: right - badgeWidth / 2,
150
+ y: "0.75",
151
+ width: badgeWidth,
152
+ height: BADGE_HEIGHT,
153
+ rx: BADGE_HEIGHT / 2,
154
+ fill: palette.badge,
155
+ stroke: palette.badgeInk,
156
+ strokeWidth: "1.5"
157
+ }), /* @__PURE__ */ jsx("text", {
158
+ x: right,
159
+ y: "9.9",
160
+ textAnchor: "middle",
161
+ fontSize: "9",
162
+ fontWeight: "700",
163
+ fill: palette.badgeInk,
164
+ children: label
165
+ })] });
166
+ $[28] = badgeWidth;
167
+ $[29] = count;
168
+ $[30] = label;
169
+ $[31] = palette.badge;
170
+ $[32] = palette.badgeInk;
171
+ $[33] = right;
172
+ $[34] = t10;
173
+ } else t10 = $[34];
174
+ let t11;
175
+ if ($[35] !== t10 || $[36] !== t3 || $[37] !== t4 || $[38] !== t7 || $[39] !== t8 || $[40] !== t9) {
176
+ t11 = /* @__PURE__ */ jsxs("svg", {
177
+ xmlns: "http://www.w3.org/2000/svg",
178
+ width: t3,
179
+ height: t4,
180
+ fontFamily: "Inter, system-ui, sans-serif",
181
+ children: [
182
+ t7,
183
+ t8,
184
+ t9,
185
+ t10
186
+ ]
187
+ });
188
+ $[35] = t10;
189
+ $[36] = t3;
190
+ $[37] = t4;
191
+ $[38] = t7;
192
+ $[39] = t8;
193
+ $[40] = t9;
194
+ $[41] = t11;
195
+ } else t11 = $[41];
196
+ return t11;
197
+ }
198
+ /** The SVG markup of each site's icon, in order, rendered through React so the GL image and the DOM glyph match. */
199
+ function markerIconMarkup(icons, palette) {
200
+ const host = document.createElement("div");
201
+ const root = createRoot(host);
202
+ flushSync(() => root.render(icons.map((icon) => /* @__PURE__ */ jsx(MarkerIcon, {
203
+ ...icon,
204
+ palette
205
+ }, icon.site.key))));
206
+ const markup = [...host.children].map((svg) => svg.outerHTML);
207
+ root.unmount();
208
+ return markup;
209
+ }
210
+ /** Rasterise one SVG icon to the bitmap maplibre's `addImage` takes, at {@link ICON_PIXEL_RATIO}. */
211
+ async function rasteriseIcon(markup) {
212
+ const image = new Image();
213
+ image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`;
214
+ await image.decode();
215
+ const canvas = document.createElement("canvas");
216
+ canvas.width = Math.ceil(image.width * 2);
217
+ canvas.height = Math.ceil(image.height * 2);
218
+ const context = canvas.getContext("2d", { willReadFrequently: true });
219
+ if (!context) throw new Error("a 2D canvas context is required to draw map icons");
220
+ context.drawImage(image, 0, 0, canvas.width, canvas.height);
221
+ return context.getImageData(0, 0, canvas.width, canvas.height);
222
+ }
223
+ export { ICON_PIXEL_RATIO, markerIconKey, markerIconMarkup, rasteriseIcon };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Subscribes to the theme at `element` changing: a `.dark` class or a `data-viz-theme` scope flipping on it or on an
3
+ * ancestor, or the OS `prefers-color-scheme` query. Returns an unsubscribe function.
4
+ */
5
+ export declare function observeColorScheme(element: Element, onChange: () => void): () => void;
@@ -0,0 +1,19 @@
1
+ // src/map/observe-color-scheme.ts
2
+ /**
3
+ * Subscribes to the theme at `element` changing: a `.dark` class or a `data-viz-theme` scope flipping on it or on an
4
+ * ancestor, or the OS `prefers-color-scheme` query. Returns an unsubscribe function.
5
+ */
6
+ function observeColorScheme(element, onChange) {
7
+ const observer = new MutationObserver(onChange);
8
+ for (let node = element; node !== null; node = node.parentElement) observer.observe(node, {
9
+ attributes: true,
10
+ attributeFilter: ["class", "data-viz-theme"]
11
+ });
12
+ const query = window.matchMedia("(prefers-color-scheme: dark)");
13
+ query.addEventListener("change", onChange);
14
+ return () => {
15
+ observer.disconnect();
16
+ query.removeEventListener("change", onChange);
17
+ };
18
+ }
19
+ export { observeColorScheme };
@@ -0,0 +1,20 @@
1
+ interface Size {
2
+ width: number;
3
+ height: number;
4
+ }
5
+ export interface PopupPlacement {
6
+ anchor: "top" | "bottom";
7
+ offset: [number, number];
8
+ maxWidth: string;
9
+ }
10
+ /** Where a map card sits inside the map: above its stop if it fits, else below, else on the roomier side, held in. */
11
+ export declare function placePopup({ point, card, map, gap }: {
12
+ point: {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ card: Size;
17
+ map: Size;
18
+ gap: number;
19
+ }): PopupPlacement;
20
+ export {};
@@ -0,0 +1,20 @@
1
+ // src/map/popup-placement.ts
2
+ /** Where a map card sits inside the map: above its stop if it fits, else below, else on the roomier side, held in. */
3
+ function placePopup({ point, card, map, gap }) {
4
+ const roomAbove = point.y - gap;
5
+ const roomBelow = map.height - point.y - gap;
6
+ const fitsAbove = roomAbove >= card.height;
7
+ const fitsBelow = roomBelow >= card.height;
8
+ const anchor = fitsAbove || !fitsBelow && roomAbove >= roomBelow ? "bottom" : "top";
9
+ const overflow = fitsAbove || fitsBelow ? 0 : card.height - Math.max(roomAbove, roomBelow);
10
+ const shiftY = anchor === "bottom" ? overflow : -Math.min(overflow, point.y + gap);
11
+ const halfWidth = Math.min(card.width, map.width) / 2;
12
+ const overLeft = halfWidth - point.x;
13
+ const overRight = point.x + halfWidth - map.width;
14
+ return {
15
+ anchor,
16
+ offset: [overLeft > 0 ? overLeft : Math.min(0, -overRight), (anchor === "bottom" ? -gap : gap) + shiftY],
17
+ maxWidth: `${map.width}px`
18
+ };
19
+ }
20
+ export { placePopup };
@@ -0,0 +1,28 @@
1
+ import { LngLatTuple, MapRouteData } from "./types.mjs";
2
+ import { MapHighlight } from "./highlight.mjs";
3
+ import { LayerProps } from "react-map-gl/maplibre";
4
+ export declare const DEFAULT_ROUTE_COLOR = "var(--viz-cat-1)";
5
+ export declare const ROUTE_HIT_LAYER_ID = "routes-hit";
6
+ type LineLayerProps = Extract<LayerProps, {
7
+ type: "line";
8
+ }>;
9
+ /** The routes as GeoJSON lines, each with its resolved colour; a route whose colour is not resolved yet is left out. */
10
+ export declare function routeFeatures(routes: readonly MapRouteData[], resolvedColors: Readonly<Record<string, string>>): {
11
+ type: "FeatureCollection";
12
+ features: {
13
+ type: "Feature";
14
+ properties: {
15
+ color: string;
16
+ group: string | null;
17
+ dashed: boolean;
18
+ muted: boolean;
19
+ };
20
+ geometry: {
21
+ type: "LineString";
22
+ coordinates: LngLatTuple[];
23
+ };
24
+ }[];
25
+ };
26
+ /** The route layers back to front: the dashed lines, the solid lines over them, and the wide transparent hit line. */
27
+ export declare function routeLayers(highlight: MapHighlight): LineLayerProps[];
28
+ export {};
@@ -0,0 +1,73 @@
1
+ import { routeEmphasis } from "./highlight.mjs";
2
+ // src/map/route-layers.ts
3
+ const DEFAULT_ROUTE_COLOR = "var(--viz-cat-1)";
4
+ const ROUTE_HIT_LAYER_ID = "routes-hit";
5
+ const LINE_WIDTH = 3;
6
+ const DASH_PATTERN = [1.5, 1.5];
7
+ /** The routes as GeoJSON lines, each with its resolved colour; a route whose colour is not resolved yet is left out. */
8
+ function routeFeatures(routes, resolvedColors) {
9
+ return {
10
+ type: "FeatureCollection",
11
+ features: routes.flatMap((route) => {
12
+ const color = resolvedColors[route.color ?? "var(--viz-cat-1)"];
13
+ return color ? [{
14
+ type: "Feature",
15
+ properties: {
16
+ color,
17
+ group: route.group ?? null,
18
+ dashed: route.dashed === true,
19
+ muted: route.muted === true
20
+ },
21
+ geometry: {
22
+ type: "LineString",
23
+ coordinates: route.path
24
+ }
25
+ }] : [];
26
+ })
27
+ };
28
+ }
29
+ function lineLayer(highlight, style) {
30
+ const { opacity, sortKey } = routeEmphasis(highlight);
31
+ const dashed = style === "dashed";
32
+ return {
33
+ id: dashed ? "routes-line-dashed" : "routes-line",
34
+ type: "line",
35
+ filter: [
36
+ dashed ? "==" : "!=",
37
+ ["get", "dashed"],
38
+ true
39
+ ],
40
+ layout: {
41
+ "line-cap": dashed ? "butt" : "round",
42
+ "line-join": "round",
43
+ "line-sort-key": sortKey
44
+ },
45
+ paint: {
46
+ "line-color": ["get", "color"],
47
+ "line-width": LINE_WIDTH,
48
+ "line-opacity": opacity,
49
+ ...dashed && { "line-dasharray": DASH_PATTERN }
50
+ }
51
+ };
52
+ }
53
+ /** The route layers back to front: the dashed lines, the solid lines over them, and the wide transparent hit line. */
54
+ function routeLayers(highlight) {
55
+ return [
56
+ lineLayer(highlight, "dashed"),
57
+ lineLayer(highlight, "solid"),
58
+ {
59
+ id: ROUTE_HIT_LAYER_ID,
60
+ type: "line",
61
+ layout: {
62
+ "line-cap": "round",
63
+ "line-join": "round"
64
+ },
65
+ paint: {
66
+ "line-color": "transparent",
67
+ "line-width": 14,
68
+ "line-opacity": 0
69
+ }
70
+ }
71
+ ];
72
+ }
73
+ export { DEFAULT_ROUTE_COLOR, ROUTE_HIT_LAYER_ID, routeFeatures, routeLayers };
@@ -0,0 +1,97 @@
1
+ import { AccessibleTableData } from "../a11y/AccessibleTable.mjs";
2
+ import { StyleSpecification } from "maplibre-gl";
3
+ import { IconType } from "react-icons";
4
+ /** A `[longitude, latitude]` pair (GeoJSON axis order — the canonical order for
5
+ * the whole map API; model adapters swap to it once at their boundary). */
6
+ export type LngLatTuple = [number, number];
7
+ /** The built-in marker glyphs. `point` is the neutral default; `bead`, a small ring, is a stop of another day. */
8
+ export type MapMarkerKind = "startLocation" | "endLocation" | "visit" | "break" | "unassigned" | "bead" | "point";
9
+ /** A requirement the marker's assignment fails: its icon shows struck through on the marker's bottom-left plate. */
10
+ export interface MapMarkerUnmetRequirement {
11
+ key: string;
12
+ icon: IconType;
13
+ }
14
+ /** A marker; a model narrows `data` to its own record by extending this, and `MapView` hands that type back. */
15
+ export interface MapMarkerData {
16
+ id: string;
17
+ position: LngLatTuple;
18
+ kind?: MapMarkerKind;
19
+ group?: string;
20
+ color?: string;
21
+ /** @defaultValue `var(--tf-neutral-000)`; the number or icon drawn on `color`, which must clear 4.5:1 on it */
22
+ textColor?: string;
23
+ label: string;
24
+ sequence?: number;
25
+ unreachable?: boolean;
26
+ unmet?: MapMarkerUnmetRequirement[];
27
+ /** @defaultValue `[0, 0]`, the marker centred on its position; pixels right and down otherwise; a `content` marker only */
28
+ offset?: [number, number];
29
+ /** @defaultValue `false`; `true` draws a `content` marker above every stop, the selected one included, as a badge */
30
+ raised?: boolean;
31
+ /** @defaultValue `false`; `true` fades the marker as a hover fades other groups, until a hover lights its own */
32
+ muted?: boolean;
33
+ content?: React.ReactNode;
34
+ data?: unknown;
35
+ }
36
+ /** A route drawn on the map: its path, group and colour. */
37
+ export interface MapRouteData {
38
+ id: string;
39
+ path: LngLatTuple[];
40
+ group?: string;
41
+ color?: string;
42
+ /** @defaultValue `false`; `true` draws the line dashed, below the solid lines */
43
+ dashed?: boolean;
44
+ /** @defaultValue `false`; `true` hides the line as a hover hides other groups, until a hover lights its own */
45
+ muted?: boolean;
46
+ }
47
+ /** A GeoJSON `Polygon` or `MultiPolygon` in `[longitude, latitude]` order; a polygon's rings after the first are holes. */
48
+ export type MapAreaGeometry = {
49
+ type: "Polygon";
50
+ coordinates: LngLatTuple[][];
51
+ } | {
52
+ type: "MultiPolygon";
53
+ coordinates: LngLatTuple[][][];
54
+ };
55
+ /** An area on the map; `layer` names the {@link MapAreaLayer} that draws it and that the layers panel can hide. */
56
+ export interface MapAreaData {
57
+ id: string;
58
+ layer: string;
59
+ geometry: MapAreaGeometry;
60
+ group?: string;
61
+ color?: string;
62
+ /** @defaultValue `false`; `true` hides the area as a hover hides other groups, until a hover lights its own */
63
+ muted?: boolean;
64
+ }
65
+ /** A row of the map's layers panel: `filled` tints the area and draws a solid edge, `dotted` draws a dotted edge only. */
66
+ export interface MapAreaLayer {
67
+ id: string;
68
+ label: string;
69
+ variant: MapAreaLayerVariant;
70
+ }
71
+ /** How a map area is drawn: filled or dotted. */
72
+ export type MapAreaLayerVariant = "filled" | "dotted";
73
+ /** The props of `MapView`: its markers, routes and areas. */
74
+ export interface MapViewProps<TMarker extends MapMarkerData = MapMarkerData> extends Pick<React.ComponentProps<"div">, "className" | "style" | "ref"> {
75
+ markers?: TMarker[];
76
+ routes?: MapRouteData[];
77
+ areas?: MapAreaData[];
78
+ areaLayers?: MapAreaLayer[];
79
+ /** @defaultValue OSM_RASTER_STYLE */
80
+ mapStyle?: string | StyleSpecification;
81
+ fitKey?: string;
82
+ /** @remarks A change fits the camera again to every marker and route point, unless the reader moved the map. */
83
+ refitKey?: string;
84
+ /** @remarks Called once the map has drawn its markers, or at once when this browser cannot draw the map. */
85
+ onMarkersShown?: () => void;
86
+ /** @remarks Called when the reader pans or zooms (pointer, wheel, keyboard or controls), not when the map fits itself. */
87
+ onUserMove?: () => void;
88
+ renderPopover?: (marker: TMarker) => React.ReactNode;
89
+ selectedMarkerId?: string | null;
90
+ onSelectedMarkerIdChange?: (id: string | null) => void;
91
+ highlightedGroup?: string | null;
92
+ onHighlightedGroupChange?: (group: string | null) => void;
93
+ lockedGroup?: string | null;
94
+ onLockedGroupChange?: (group: string | null) => void;
95
+ accessibleTable?: AccessibleTableData;
96
+ progressLabel?: string;
97
+ }
File without changes
@@ -0,0 +1,6 @@
1
+ import { ColorScheme } from "./map-style.mjs";
2
+ /**
3
+ * The colour scheme `element` paints (a `.dark` class on it or an ancestor), kept live.
4
+ * Reads the document root until the element mounts.
5
+ */
6
+ export declare function usePaintedColorScheme(element: Element | null): ColorScheme;
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { observeColorScheme } from "./observe-color-scheme.mjs";
3
+ import { c } from "react/compiler-runtime";
4
+ import { useEffect, useState } from "react";
5
+ // src/map/use-painted-color-scheme.ts
6
+ function paintedScheme(element) {
7
+ if (typeof document === "undefined") return "light";
8
+ return (element ?? document.documentElement).closest(".dark") ? "dark" : "light";
9
+ }
10
+ /**
11
+ * The colour scheme `element` paints (a `.dark` class on it or an ancestor), kept live.
12
+ * Reads the document root until the element mounts.
13
+ */
14
+ function usePaintedColorScheme(element) {
15
+ const $ = c(5);
16
+ let t0;
17
+ if ($[0] !== element) {
18
+ t0 = () => paintedScheme(element);
19
+ $[0] = element;
20
+ $[1] = t0;
21
+ } else t0 = $[1];
22
+ const [scheme, setScheme] = useState(t0);
23
+ let t1;
24
+ let t2;
25
+ if ($[2] !== element) {
26
+ t1 = () => {
27
+ if (!element) return;
28
+ const update = () => setScheme(paintedScheme(element));
29
+ update();
30
+ return observeColorScheme(element, update);
31
+ };
32
+ t2 = [element];
33
+ $[2] = element;
34
+ $[3] = t1;
35
+ $[4] = t2;
36
+ } else {
37
+ t1 = $[3];
38
+ t2 = $[4];
39
+ }
40
+ useEffect(t1, t2);
41
+ return scheme;
42
+ }
43
+ export { usePaintedColorScheme };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * CSS colour → GL-parseable hex, resolved where the map sits so a scoped theme applies, and re-resolved
3
+ * on every `.dark`/`data-viz-theme` change or the OS preference, since GL literals can't read a CSS `var()`.
4
+ */
5
+ export declare function useResolvedColors(colors: readonly string[], element: Element | null): Record<string, string>;
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ import { observeColorScheme } from "./observe-color-scheme.mjs";
3
+ import { c } from "react/compiler-runtime";
4
+ import { useEffect, useState } from "react";
5
+ import { normalizeCssColor } from "@timefoldai/viz-core";
6
+ // src/map/use-resolved-colors.ts
7
+ function resolve(colors, element) {
8
+ const out = {};
9
+ for (const raw of colors) {
10
+ let value = raw;
11
+ if (raw.includes("var(")) {
12
+ const probe = document.createElement("span");
13
+ probe.style.color = raw;
14
+ element.appendChild(probe);
15
+ value = getComputedStyle(probe).color;
16
+ probe.remove();
17
+ }
18
+ out[raw] = normalizeCssColor(value);
19
+ }
20
+ return out;
21
+ }
22
+ /**
23
+ * CSS colour → GL-parseable hex, resolved where the map sits so a scoped theme applies, and re-resolved
24
+ * on every `.dark`/`data-viz-theme` change or the OS preference, since GL literals can't read a CSS `var()`.
25
+ */
26
+ function useResolvedColors(colors, element) {
27
+ const $ = c(5);
28
+ let t0;
29
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
30
+ t0 = {};
31
+ $[0] = t0;
32
+ } else t0 = $[0];
33
+ const [resolved, setResolved] = useState(t0);
34
+ let t1;
35
+ let t2;
36
+ if ($[1] !== colors || $[2] !== element) {
37
+ t1 = () => {
38
+ if (!element) return;
39
+ const update = () => {
40
+ setResolved((previous) => {
41
+ const next = resolve(colors, element);
42
+ return Object.keys(next).length === Object.keys(previous).length && Object.entries(next).every((t3) => {
43
+ const [color, hex] = t3;
44
+ return previous[color] === hex;
45
+ }) ? previous : next;
46
+ });
47
+ };
48
+ update();
49
+ return observeColorScheme(element, update);
50
+ };
51
+ t2 = [colors, element];
52
+ $[1] = colors;
53
+ $[2] = element;
54
+ $[3] = t1;
55
+ $[4] = t2;
56
+ } else {
57
+ t1 = $[3];
58
+ t2 = $[4];
59
+ }
60
+ useEffect(t1, t2);
61
+ return resolved;
62
+ }
63
+ export { useResolvedColors };
@@ -0,0 +1,6 @@
1
+ /** The default English labels of a pager's buttons. */
2
+ export declare const paginationLabels: {
3
+ previousLabel: string;
4
+ nextLabel: string;
5
+ pageLabel: (page: number) => string;
6
+ };
@@ -0,0 +1,8 @@
1
+ // src/pagination/paginationLabels.ts
2
+ /** The default English labels of a pager's buttons. */
3
+ const paginationLabels = {
4
+ previousLabel: "Previous page",
5
+ nextLabel: "Next page",
6
+ pageLabel: (page) => `Page ${page}`
7
+ };
8
+ export { paginationLabels };