@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,33 @@
1
+ import { MapAreaData, MapAreaGeometry, MapAreaLayer, MapAreaLayerVariant } from "./types.mjs";
2
+ import { MapHighlight } from "./highlight.mjs";
3
+ import { LayerProps } from "react-map-gl/maplibre";
4
+ type FillLayerProps = Extract<LayerProps, {
5
+ type: "fill";
6
+ }>;
7
+ type LineLayerProps = Extract<LayerProps, {
8
+ type: "line";
9
+ }>;
10
+ export declare const DEFAULT_AREA_COLOR = "var(--viz-cat-1)";
11
+ /** The drawn areas as GeoJSON features: an area of a hidden or unlisted layer, or with an unresolved colour, is left out. */
12
+ export declare function areaFeatures(areas: readonly MapAreaData[], { layers, hidden, colors }: {
13
+ layers: readonly MapAreaLayer[];
14
+ hidden: ReadonlySet<string>;
15
+ colors: Readonly<Record<string, string>>;
16
+ }): {
17
+ type: "FeatureCollection";
18
+ features: {
19
+ type: "Feature";
20
+ properties: {
21
+ variant: MapAreaLayerVariant;
22
+ color: string;
23
+ group: string | null;
24
+ muted: boolean;
25
+ };
26
+ geometry: MapAreaGeometry;
27
+ }[];
28
+ };
29
+ /** The layers panel's rows: each layer that draws an area the filter keeps, in the given order. */
30
+ export declare function listedAreaLayers(layers: readonly MapAreaLayer[], areas: readonly MapAreaData[]): MapAreaLayer[];
31
+ /** The area layers back to front: the filled areas' tint, their solid edge, and the dotted edges. */
32
+ export declare function areaLayers(highlight: MapHighlight): [FillLayerProps, LineLayerProps, LineLayerProps];
33
+ export {};
@@ -0,0 +1,96 @@
1
+ // src/map/area-layers.ts
2
+ const DEFAULT_AREA_COLOR = "var(--viz-cat-1)";
3
+ const FILL_OPACITY = .12;
4
+ const EDGE_OPACITY = .9;
5
+ const EDGE_WIDTH = 1.5;
6
+ const DOTTED_WIDTH = 2.5;
7
+ const DOT_PATTERN = [0, 2];
8
+ /** The drawn areas as GeoJSON features: an area of a hidden or unlisted layer, or with an unresolved colour, is left out. */
9
+ function areaFeatures(areas, { layers, hidden, colors }) {
10
+ const variantOf = new Map(layers.map((layer) => [layer.id, layer.variant]));
11
+ return {
12
+ type: "FeatureCollection",
13
+ features: areas.flatMap((area) => {
14
+ const variant = variantOf.get(area.layer);
15
+ const color = colors[area.color ?? "var(--viz-cat-1)"];
16
+ return variant && color && !hidden.has(area.layer) ? [{
17
+ type: "Feature",
18
+ properties: {
19
+ variant,
20
+ color,
21
+ group: area.group ?? null,
22
+ muted: area.muted === true
23
+ },
24
+ geometry: area.geometry
25
+ }] : [];
26
+ })
27
+ };
28
+ }
29
+ /** The layers panel's rows: each layer that draws an area the filter keeps, in the given order. */
30
+ function listedAreaLayers(layers, areas) {
31
+ return layers.filter((layer) => areas.some((area) => area.layer === layer.id && area.muted !== true));
32
+ }
33
+ function emphasis(highlight, opacity) {
34
+ if (highlight.group !== null && highlight.dim) return [
35
+ "case",
36
+ [
37
+ "==",
38
+ ["get", "group"],
39
+ highlight.group
40
+ ],
41
+ opacity,
42
+ 0
43
+ ];
44
+ return [
45
+ "case",
46
+ ["get", "muted"],
47
+ 0,
48
+ opacity
49
+ ];
50
+ }
51
+ const isFilled = [
52
+ "==",
53
+ ["get", "variant"],
54
+ "filled"
55
+ ];
56
+ /** The area layers back to front: the filled areas' tint, their solid edge, and the dotted edges. */
57
+ function areaLayers(highlight) {
58
+ return [
59
+ {
60
+ id: "areas-fill",
61
+ type: "fill",
62
+ filter: isFilled,
63
+ paint: {
64
+ "fill-color": ["get", "color"],
65
+ "fill-opacity": emphasis(highlight, FILL_OPACITY)
66
+ }
67
+ },
68
+ {
69
+ id: "areas-edge",
70
+ type: "line",
71
+ filter: isFilled,
72
+ layout: { "line-join": "round" },
73
+ paint: {
74
+ "line-color": ["get", "color"],
75
+ "line-width": EDGE_WIDTH,
76
+ "line-opacity": emphasis(highlight, EDGE_OPACITY)
77
+ }
78
+ },
79
+ {
80
+ id: "areas-dotted",
81
+ type: "line",
82
+ filter: ["!", isFilled],
83
+ layout: {
84
+ "line-cap": "round",
85
+ "line-join": "round"
86
+ },
87
+ paint: {
88
+ "line-color": ["get", "color"],
89
+ "line-width": DOTTED_WIDTH,
90
+ "line-dasharray": DOT_PATTERN,
91
+ "line-opacity": emphasis(highlight, EDGE_OPACITY)
92
+ }
93
+ }
94
+ ];
95
+ }
96
+ export { DEFAULT_AREA_COLOR, areaFeatures, areaLayers, listedAreaLayers };
@@ -0,0 +1,6 @@
1
+ /** A react-map-gl `useControl` factory for an element in maplibre's control-group box, which the caller portals into. */
2
+ export declare function createControlGroup(): {
3
+ element: HTMLDivElement;
4
+ onAdd: () => HTMLDivElement;
5
+ onRemove: () => void;
6
+ };
@@ -0,0 +1,12 @@
1
+ // src/map/control-group.ts
2
+ /** A react-map-gl `useControl` factory for an element in maplibre's control-group box, which the caller portals into. */
3
+ function createControlGroup() {
4
+ const element = document.createElement("div");
5
+ element.className = "maplibregl-ctrl maplibregl-ctrl-group";
6
+ return {
7
+ element,
8
+ onAdd: () => element,
9
+ onRemove: () => element.remove()
10
+ };
11
+ }
12
+ export { createControlGroup };
@@ -0,0 +1,4 @@
1
+ type ChunkResult = void | "stop";
2
+ /** Runs `run` on `items` a chunk at a time, one task per chunk, until it answers "stop". */
3
+ export declare function forEachChunk<T>(items: readonly T[], size: number, run: (chunk: readonly T[]) => ChunkResult | Promise<ChunkResult>): Promise<void>;
4
+ export {};
@@ -0,0 +1,14 @@
1
+ // src/map/for-each-chunk.ts
2
+ /** Runs `run` on `items` a chunk at a time, one task per chunk, until it answers "stop". */
3
+ async function forEachChunk(items, size, run) {
4
+ for (let start = 0; start < items.length; start += size) {
5
+ if (start > 0) await nextTask();
6
+ if (await run(items.slice(start, start + size)) === "stop") return;
7
+ }
8
+ }
9
+ function nextTask() {
10
+ return new Promise((resolve) => {
11
+ setTimeout(resolve, 0);
12
+ });
13
+ }
14
+ export { forEachChunk };
@@ -0,0 +1,30 @@
1
+ import { MapMarkerData, MapRouteData } from "./types.mjs";
2
+ import { ExpressionSpecification } from "maplibre-gl";
3
+ /** The resolved route/marker emphasis for one render of the map. */
4
+ export interface MapHighlight {
5
+ group: string | null;
6
+ dim: boolean;
7
+ }
8
+ /**
9
+ * Resolve which route group (e.g. one vehicle) the map should emphasise: a locked group wins,
10
+ * then a hovered route's group, then a group owning every route that is not muted.
11
+ */
12
+ export declare function resolveHighlight({ hoveredGroup, lockedGroup, routes }: {
13
+ hoveredGroup?: string | null;
14
+ lockedGroup?: string | null;
15
+ routes: readonly MapRouteData[];
16
+ }): MapHighlight;
17
+ /**
18
+ * The route layer's paint and sort inputs for a highlight, as expressions on each feature's `group` and `muted`: the
19
+ * emphasised group draws opaque on top, others hide while the highlight dims, and muted ones hide while it does not.
20
+ */
21
+ export declare function routeEmphasis(highlight: MapHighlight): {
22
+ opacity: ExpressionSpecification;
23
+ sortKey: ExpressionSpecification | number;
24
+ };
25
+ /** The stop layers' opacity for a highlight: stops outside its group fade while it dims, muted stops fade otherwise. */
26
+ export declare function stopEmphasis(highlight: MapHighlight): ExpressionSpecification;
27
+ /** Whether a DOM marker fades for a highlight, by the rule `stopEmphasis` paints the stop layers with. */
28
+ export declare function isDimmed(highlight: MapHighlight, marker: Pick<MapMarkerData, "group" | "muted">): boolean;
29
+ /** The groups that have an unmuted item, as one key: a filter change moves it, a solve that reorders items does not. */
30
+ export declare function unmutedGroupsKey(items: readonly Pick<MapMarkerData, "group" | "muted">[]): string;
@@ -0,0 +1,99 @@
1
+ // src/map/highlight.ts
2
+ const ROUTE_OPACITY = .9;
3
+ const ROUTE_OPACITY_ACTIVE = 1;
4
+ const ROUTE_OPACITY_HIDDEN = 0;
5
+ /**
6
+ * Resolve which route group (e.g. one vehicle) the map should emphasise: a locked group wins,
7
+ * then a hovered route's group, then a group owning every route that is not muted.
8
+ */
9
+ function resolveHighlight({ hoveredGroup, lockedGroup, routes }) {
10
+ if (lockedGroup != null) return {
11
+ group: lockedGroup,
12
+ dim: true
13
+ };
14
+ if (hoveredGroup != null && routes.some((route) => route.group === hoveredGroup)) return {
15
+ group: hoveredGroup,
16
+ dim: true
17
+ };
18
+ const unmuted = routes.filter((route) => route.muted !== true);
19
+ const first = unmuted[0]?.group;
20
+ if (first != null && unmuted.every((route) => route.group === first)) return {
21
+ group: first,
22
+ dim: false
23
+ };
24
+ return {
25
+ group: null,
26
+ dim: false
27
+ };
28
+ }
29
+ const IS_MUTED = ["get", "muted"];
30
+ /**
31
+ * The route layer's paint and sort inputs for a highlight, as expressions on each feature's `group` and `muted`: the
32
+ * emphasised group draws opaque on top, others hide while the highlight dims, and muted ones hide while it does not.
33
+ */
34
+ function routeEmphasis(highlight) {
35
+ if (highlight.group === null) return {
36
+ opacity: [
37
+ "case",
38
+ IS_MUTED,
39
+ ROUTE_OPACITY_HIDDEN,
40
+ ROUTE_OPACITY
41
+ ],
42
+ sortKey: 0
43
+ };
44
+ const isEmphasised = [
45
+ "==",
46
+ ["get", "group"],
47
+ highlight.group
48
+ ];
49
+ return {
50
+ opacity: highlight.dim ? [
51
+ "case",
52
+ isEmphasised,
53
+ ROUTE_OPACITY_ACTIVE,
54
+ ROUTE_OPACITY_HIDDEN
55
+ ] : [
56
+ "case",
57
+ IS_MUTED,
58
+ ROUTE_OPACITY_HIDDEN,
59
+ isEmphasised,
60
+ ROUTE_OPACITY_ACTIVE,
61
+ ROUTE_OPACITY
62
+ ],
63
+ sortKey: [
64
+ "case",
65
+ isEmphasised,
66
+ 1,
67
+ 0
68
+ ]
69
+ };
70
+ }
71
+ const STOP_OPACITY_DIMMED = .3;
72
+ /** The stop layers' opacity for a highlight: stops outside its group fade while it dims, muted stops fade otherwise. */
73
+ function stopEmphasis(highlight) {
74
+ if (highlight.group === null || !highlight.dim) return [
75
+ "case",
76
+ IS_MUTED,
77
+ STOP_OPACITY_DIMMED,
78
+ 1
79
+ ];
80
+ return [
81
+ "case",
82
+ [
83
+ "==",
84
+ ["get", "group"],
85
+ highlight.group
86
+ ],
87
+ 1,
88
+ STOP_OPACITY_DIMMED
89
+ ];
90
+ }
91
+ /** Whether a DOM marker fades for a highlight, by the rule `stopEmphasis` paints the stop layers with. */
92
+ function isDimmed(highlight, marker) {
93
+ return highlight.group !== null && highlight.dim ? marker.group !== highlight.group : marker.muted === true;
94
+ }
95
+ /** The groups that have an unmuted item, as one key: a filter change moves it, a solve that reorders items does not. */
96
+ function unmutedGroupsKey(items) {
97
+ return [...new Set(items.flatMap((item) => item.muted === true || item.group === void 0 ? [] : [item.group]))].toSorted().join("|");
98
+ }
99
+ export { isDimmed, resolveHighlight, routeEmphasis, stopEmphasis, unmutedGroupsKey };
@@ -0,0 +1,24 @@
1
+ /** Web-Mercator tiles are square and this many pixels on a side. */
2
+ export declare const TILE_SIZE = 256;
3
+ export interface LocatorTile {
4
+ url: string;
5
+ offsetX: number;
6
+ offsetY: number;
7
+ pinX: number;
8
+ pinY: number;
9
+ }
10
+ /**
11
+ * A still crop of the OpenStreetMap basemap centred as closely as one tile
12
+ * allows on `[latitude, longitude]`.
13
+ *
14
+ * @remarks
15
+ * One tile request, not a stitched grid: OSM's tile-usage policy rules out the
16
+ * volume. The clamp is the cost, so `pinX`/`pinY` carry the real position.
17
+ * Undefined outside the projection's range. A `mapStyle` override never reaches it.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const tile = locatorTile(52.29451, 4.9726, 132, 84);
22
+ * ```
23
+ */
24
+ export declare function locatorTile(latitude: number, longitude: number, width: number, height: number): LocatorTile | undefined;
@@ -0,0 +1,41 @@
1
+ import { OSM_RASTER_TILE_URL } from "./map-style.mjs";
2
+ // src/map/locator-tile.ts
3
+ /** Web-Mercator tiles are square and this many pixels on a side. */
4
+ const TILE_SIZE = 256;
5
+ const LOCATOR_ZOOM = 14;
6
+ /**
7
+ * A still crop of the OpenStreetMap basemap centred as closely as one tile
8
+ * allows on `[latitude, longitude]`.
9
+ *
10
+ * @remarks
11
+ * One tile request, not a stitched grid: OSM's tile-usage policy rules out the
12
+ * volume. The clamp is the cost, so `pinX`/`pinY` carry the real position.
13
+ * Undefined outside the projection's range. A `mapStyle` override never reaches it.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const tile = locatorTile(52.29451, 4.9726, 132, 84);
18
+ * ```
19
+ */
20
+ function locatorTile(latitude, longitude, width, height) {
21
+ if (!Number.isFinite(latitude) || !Number.isFinite(longitude) || Math.abs(latitude) > 85.05112878 || Math.abs(longitude) > 180) return;
22
+ const scale = 2 ** LOCATOR_ZOOM;
23
+ const latitudeRadians = latitude * Math.PI / 180;
24
+ const tileX = (longitude + 180) / 360 * scale;
25
+ const tileY = (1 - Math.log(Math.tan(latitudeRadians) + 1 / Math.cos(latitudeRadians)) / Math.PI) / 2 * scale;
26
+ const column = Math.floor(tileX);
27
+ const row = Math.floor(tileY);
28
+ const withinX = (tileX - column) * 256;
29
+ const withinY = (tileY - row) * 256;
30
+ const clamp = (value, max) => Math.min(Math.max(value, 0), max);
31
+ const cropLeft = clamp(withinX - width / 2, 256 - width);
32
+ const cropTop = clamp(withinY - height / 2, 256 - height);
33
+ return {
34
+ url: OSM_RASTER_TILE_URL.replace("{z}", String(LOCATOR_ZOOM)).replace("{x}", String(column)).replace("{y}", String(row)),
35
+ offsetX: -cropLeft,
36
+ offsetY: -cropTop,
37
+ pinX: withinX - cropLeft,
38
+ pinY: withinY - cropTop
39
+ };
40
+ }
41
+ export { TILE_SIZE, locatorTile };
@@ -0,0 +1,12 @@
1
+ import { MapMarkerData, MapMarkerUnmetRequirement } from "./types.mjs";
2
+ /** Every marker of one group at one position, drawn as one mark: `marker` shows, `members` are in rank order. */
3
+ export interface MapSite<TMarker extends MapMarkerData> {
4
+ key: string;
5
+ marker: TMarker;
6
+ members: TMarker[];
7
+ count: number;
8
+ rank: number;
9
+ unmet: MapMarkerUnmetRequirement[];
10
+ }
11
+ /** Group markers by position and group; a site's `rank` orders placement, so the lowest rank wins a crowded spot. */
12
+ export declare function groupBySite<TMarker extends MapMarkerData>(markers: readonly TMarker[]): MapSite<TMarker>[];
@@ -0,0 +1,39 @@
1
+ // src/map/map-sites.ts
2
+ const UNSEQUENCED_RANK = 1e3;
3
+ function markerRank(marker) {
4
+ if (marker.kind === "unassigned") return -1;
5
+ if (marker.kind === "startLocation" || marker.kind === "endLocation") return 0;
6
+ if (marker.unreachable) return 1;
7
+ return 2 + (marker.sequence ?? UNSEQUENCED_RANK);
8
+ }
9
+ function siteKey(marker) {
10
+ const [longitude, latitude] = marker.position;
11
+ return `${marker.group ?? ""}@${longitude.toFixed(6)},${latitude.toFixed(6)}`;
12
+ }
13
+ function unmetByAnyMember(members) {
14
+ return [...new Map(members.flatMap((member) => (member.unmet ?? []).map((requirement) => [requirement.key, requirement]))).values()].toSorted((first, second) => first.key.localeCompare(second.key));
15
+ }
16
+ /** Group markers by position and group; a site's `rank` orders placement, so the lowest rank wins a crowded spot. */
17
+ function groupBySite(markers) {
18
+ const byKey = /* @__PURE__ */ new Map();
19
+ for (const marker of markers) {
20
+ const key = siteKey(marker);
21
+ const members = byKey.get(key);
22
+ if (members) members.push(marker);
23
+ else byKey.set(key, [marker]);
24
+ }
25
+ return [...byKey].map(([key, members]) => {
26
+ const ranked = members.toSorted((first, second) => markerRank(first) - markerRank(second));
27
+ const [shown] = ranked;
28
+ if (!shown) throw new Error(`site ${key} has no markers`);
29
+ return {
30
+ key,
31
+ marker: shown,
32
+ members: ranked,
33
+ count: members.length,
34
+ rank: markerRank(shown),
35
+ unmet: unmetByAnyMember(ranked)
36
+ };
37
+ });
38
+ }
39
+ export { groupBySite };
@@ -0,0 +1,24 @@
1
+ import { RasterLayerSpecification, RequestParameters, StyleSpecification } from "maplibre-gl";
2
+ /** The raster layer `OSM_RASTER_STYLE` declares, and the one `withBasemapPaint` retints. */
3
+ export declare const OSM_RASTER_LAYER_ID = "osm";
4
+ /** The tile template `OSM_RASTER_STYLE` serves, and the one `locatorTile` reads
5
+ * directly: a `mapStyle` override retargets the map but not the still crop. */
6
+ export declare const OSM_RASTER_TILE_URL = "https://tile.openstreetmap.org/{z}/{x}/{y}.png";
7
+ /** The referrer policy of every map request: a tile server that refuses a request without a `Referer` still
8
+ * gets the origin when the host page sends `Referrer-Policy: same-origin`. */
9
+ export declare const MAP_REFERRER_POLICY: ReferrerPolicy;
10
+ /** A maplibre `transformRequest` that sends each request with `MAP_REFERRER_POLICY`. */
11
+ export declare function withMapReferrerPolicy(url: string): RequestParameters;
12
+ /** Default basemap: OpenStreetMap raster tiles, for dev and quickstart volume only.
13
+ * A deployment overrides it through `MapView`'s `mapStyle` prop — see SECURITY.md. */
14
+ export declare const OSM_RASTER_STYLE: StyleSpecification;
15
+ export type ColorScheme = "light" | "dark";
16
+ /** Theme-reactive raster paint for `OSM_RASTER_LAYER_ID`: desaturates the tiles and adjusts
17
+ * brightness so route and marker colours keep contrast. Every scheme sets every property. */
18
+ export declare const OSM_RASTER_PAINT: Record<ColorScheme, Pick<NonNullable<RasterLayerSpecification["paint"]>, "raster-saturation" | "raster-brightness-min" | "raster-brightness-max">>;
19
+ /** The style with `OSM_RASTER_PAINT[scheme]` on its `OSM_RASTER_LAYER_ID` raster layer;
20
+ * a style URL or a style without that layer comes back as the same reference. */
21
+ export declare function withBasemapPaint(style: string | StyleSpecification, scheme: ColorScheme): string | StyleSpecification;
22
+ /** A minimal, fully-offline style: a single neutral background layer, no remote sources.
23
+ * Applied as a fallback if the configured style fails to load, and used by stories/tests. */
24
+ export declare const OFFLINE_FALLBACK_STYLE: StyleSpecification;
@@ -0,0 +1,79 @@
1
+ // src/map/map-style.ts
2
+ /** The raster layer `OSM_RASTER_STYLE` declares, and the one `withBasemapPaint` retints. */
3
+ const OSM_RASTER_LAYER_ID = "osm";
4
+ /** The tile template `OSM_RASTER_STYLE` serves, and the one `locatorTile` reads
5
+ * directly: a `mapStyle` override retargets the map but not the still crop. */
6
+ const OSM_RASTER_TILE_URL = "https://tile.openstreetmap.org/{z}/{x}/{y}.png";
7
+ /** The referrer policy of every map request: a tile server that refuses a request without a `Referer` still
8
+ * gets the origin when the host page sends `Referrer-Policy: same-origin`. */
9
+ const MAP_REFERRER_POLICY = "strict-origin-when-cross-origin";
10
+ /** A maplibre `transformRequest` that sends each request with `MAP_REFERRER_POLICY`. */
11
+ function withMapReferrerPolicy(url) {
12
+ return {
13
+ url,
14
+ referrerPolicy: MAP_REFERRER_POLICY
15
+ };
16
+ }
17
+ /** Default basemap: OpenStreetMap raster tiles, for dev and quickstart volume only.
18
+ * A deployment overrides it through `MapView`'s `mapStyle` prop — see SECURITY.md. */
19
+ const OSM_RASTER_STYLE = {
20
+ version: 8,
21
+ sources: { osm: {
22
+ type: "raster",
23
+ tiles: [OSM_RASTER_TILE_URL],
24
+ tileSize: 256,
25
+ maxzoom: 19,
26
+ attribution: "© OpenStreetMap contributors"
27
+ } },
28
+ layers: [{
29
+ id: "osm",
30
+ type: "raster",
31
+ source: "osm"
32
+ }]
33
+ };
34
+ /** Theme-reactive raster paint for `OSM_RASTER_LAYER_ID`: desaturates the tiles and adjusts
35
+ * brightness so route and marker colours keep contrast. Every scheme sets every property. */
36
+ const OSM_RASTER_PAINT = {
37
+ light: {
38
+ "raster-saturation": -.8,
39
+ "raster-brightness-min": .35,
40
+ "raster-brightness-max": 1
41
+ },
42
+ dark: {
43
+ "raster-saturation": -1,
44
+ "raster-brightness-min": .85,
45
+ "raster-brightness-max": .05
46
+ }
47
+ };
48
+ /** The style with `OSM_RASTER_PAINT[scheme]` on its `OSM_RASTER_LAYER_ID` raster layer;
49
+ * a style URL or a style without that layer comes back as the same reference. */
50
+ function withBasemapPaint(style, scheme) {
51
+ if (typeof style === "string") return style;
52
+ const basemapIndex = style.layers.findIndex((layer) => layer.id === "osm" && layer.type === "raster");
53
+ if (basemapIndex === -1) return style;
54
+ const basemap = style.layers[basemapIndex];
55
+ const layers = [...style.layers];
56
+ layers[basemapIndex] = {
57
+ ...basemap,
58
+ paint: {
59
+ ...basemap.paint,
60
+ ...OSM_RASTER_PAINT[scheme]
61
+ }
62
+ };
63
+ return {
64
+ ...style,
65
+ layers
66
+ };
67
+ }
68
+ /** A minimal, fully-offline style: a single neutral background layer, no remote sources.
69
+ * Applied as a fallback if the configured style fails to load, and used by stories/tests. */
70
+ const OFFLINE_FALLBACK_STYLE = {
71
+ version: 8,
72
+ sources: {},
73
+ layers: [{
74
+ id: "background",
75
+ type: "background",
76
+ paint: { "background-color": "#eef0f5" }
77
+ }]
78
+ };
79
+ export { MAP_REFERRER_POLICY, OFFLINE_FALLBACK_STYLE, OSM_RASTER_LAYER_ID, OSM_RASTER_PAINT, OSM_RASTER_STYLE, OSM_RASTER_TILE_URL, withBasemapPaint, withMapReferrerPolicy };
@@ -0,0 +1,5 @@
1
+ import { MapMarkerData } from "./types.mjs";
2
+ /** The viewBox width of the pill a numbered stop draws, which grows with the digits of its `sequence`. */
3
+ export declare function stopPillViewBoxWidth(sequence: number | undefined): number;
4
+ /** Where a `raised` badge sits on `host`'s top-left corner, in pixels: over its edge, clear of its number. */
5
+ export declare function mapMarkerBadgeOffset(host: MapMarkerData): [number, number];
@@ -0,0 +1,13 @@
1
+ // src/map/marker-geometry.ts
2
+ const STOP_HEIGHT = 22;
3
+ const PILL_VIEWBOX_HEIGHT = 24;
4
+ /** The viewBox width of the pill a numbered stop draws, which grows with the digits of its `sequence`. */
5
+ function stopPillViewBoxWidth(sequence) {
6
+ const digits = sequence === void 0 ? 0 : String(sequence).length;
7
+ return Math.max(PILL_VIEWBOX_HEIGHT, Math.round(16 + digits * 6));
8
+ }
9
+ /** Where a `raised` badge sits on `host`'s top-left corner, in pixels: over its edge, clear of its number. */
10
+ function mapMarkerBadgeOffset(host) {
11
+ return [-9 - ((host.kind === "visit" ? stopPillViewBoxWidth(host.sequence) * STOP_HEIGHT / PILL_VIEWBOX_HEIGHT : STOP_HEIGHT) - STOP_HEIGHT) / 2, -9];
12
+ }
13
+ export { mapMarkerBadgeOffset, stopPillViewBoxWidth };
@@ -0,0 +1,26 @@
1
+ import { MapSite } from "./map-sites.mjs";
2
+ import { MapMarkerData } from "./types.mjs";
3
+ /** The resolved colours an icon is drawn with: GL images cannot read a CSS `var()`.
4
+ * @remarks An `*Ink` key colours a badge or plate glyph, as `--viz-map-unmet-ink` does; it is no marker `textColor`. */
5
+ export interface MarkerIconPalette {
6
+ halo: string;
7
+ badge: string;
8
+ badgeInk: string;
9
+ unreachable: string;
10
+ unreachableInk: string;
11
+ unmet: string;
12
+ unmetInk: string;
13
+ }
14
+ export declare const ICON_PIXEL_RATIO = 2;
15
+ /** The colours one site's icon is drawn in, resolved: its fill and the text colour of the number or glyph on it. */
16
+ export interface MarkerIconColors {
17
+ site: MapSite<MapMarkerData>;
18
+ fill: string;
19
+ textColor: string;
20
+ }
21
+ /** The image key of a site's icon: two sites share an image exactly when they look the same. */
22
+ export declare function markerIconKey({ site, fill, textColor }: MarkerIconColors, palette: MarkerIconPalette): string;
23
+ /** The SVG markup of each site's icon, in order, rendered through React so the GL image and the DOM glyph match. */
24
+ export declare function markerIconMarkup(icons: readonly MarkerIconColors[], palette: MarkerIconPalette): string[];
25
+ /** Rasterise one SVG icon to the bitmap maplibre's `addImage` takes, at {@link ICON_PIXEL_RATIO}. */
26
+ export declare function rasteriseIcon(markup: string): Promise<ImageData>;