@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.
- package/README.md +239 -1
- package/dist/THIRD-PARTY-NOTICES.txt +99 -0
- package/dist/a11y/AccessibleTable.d.mts +42 -0
- package/dist/a11y/AccessibleTable.mjs +82 -0
- package/dist/a11y/activation.d.mts +4 -0
- package/dist/a11y/activation.mjs +0 -0
- package/dist/analytics/AnalyticsProvider.d.mts +16 -0
- package/dist/analytics/AnalyticsProvider.mjs +32 -0
- package/dist/assets/Inter-latin-ext.woff2 +0 -0
- package/dist/badge/Badge.css +122 -0
- package/dist/badge/Badge.d.mts +50 -0
- package/dist/badge/Badge.mjs +145 -0
- package/dist/badge/Badge.module.css.mjs +15 -0
- package/dist/badge/BadgeFacetGroup.d.mts +23 -0
- package/dist/badge/BadgeFacetGroup.mjs +220 -0
- package/dist/badge/BadgeGroup.d.mts +13 -0
- package/dist/badge/BadgeGroup.mjs +53 -0
- package/dist/badge/BadgeList.d.mts +14 -0
- package/dist/badge/BadgeList.mjs +15 -0
- package/dist/badge/badge-facet-fit.d.mts +18 -0
- package/dist/badge/badge-facet-fit.mjs +50 -0
- package/dist/badge/badge-item.d.mts +19 -0
- package/dist/badge/badge-item.mjs +23 -0
- package/dist/button/CopyButton.d.mts +12 -0
- package/dist/button/CopyButton.mjs +52 -0
- package/dist/button/ShowAllButton.d.mts +14 -0
- package/dist/button/ShowAllButton.mjs +61 -0
- package/dist/button/ShowMoreButton.d.mts +13 -0
- package/dist/button/ShowMoreButton.mjs +51 -0
- package/dist/button/SolveButton.d.mts +16 -0
- package/dist/button/SolveButton.mjs +56 -0
- package/dist/charts/BarChart.css +59 -0
- package/dist/charts/BarChart.d.mts +26 -0
- package/dist/charts/BarChart.mjs +167 -0
- package/dist/charts/BarChart.module.css.mjs +10 -0
- package/dist/charts/ChartGrid.d.mts +8 -0
- package/dist/charts/ChartGrid.mjs +47 -0
- package/dist/charts/DistributionChart.d.mts +60 -0
- package/dist/charts/DistributionChart.mjs +151 -0
- package/dist/code/CodeBlock.d.mts +13 -0
- package/dist/code/CodeBlock.mjs +71 -0
- package/dist/composition-bar/CompositionBar.d.mts +24 -0
- package/dist/composition-bar/CompositionBar.mjs +124 -0
- package/dist/composition-bar/composition-shares.d.mts +8 -0
- package/dist/composition-bar/composition-shares.mjs +30 -0
- package/dist/data-gate/DataGate.d.mts +34 -0
- package/dist/data-gate/DataGate.mjs +80 -0
- package/dist/date-scope/DateScope.d.mts +30 -0
- package/dist/date-scope/DateScope.mjs +285 -0
- package/dist/design-system/part-props.d.mts +39 -0
- package/dist/design-system/part-props.mjs +0 -0
- package/dist/detail-panel/DetailPanel.d.mts +22 -0
- package/dist/detail-panel/DetailPanel.mjs +80 -0
- package/dist/detail-panel/DetailPanelSection.d.mts +20 -0
- package/dist/detail-panel/DetailPanelSection.mjs +27 -0
- package/dist/detail-panel/micro-label.d.mts +7 -0
- package/dist/detail-panel/micro-label.mjs +9 -0
- package/dist/env.d.mts +2 -0
- package/dist/env.mjs +4 -0
- package/dist/export/ExportCsvButton.d.mts +19 -0
- package/dist/export/ExportCsvButton.mjs +73 -0
- package/dist/export/download-csv.d.mts +5 -0
- package/dist/export/download-csv.mjs +11 -0
- package/dist/export/download-file.d.mts +11 -0
- package/dist/export/download-file.mjs +32 -0
- package/dist/export/download-json.d.mts +2 -0
- package/dist/export/download-json.mjs +8 -0
- package/dist/filter/FilterGroup.d.mts +24 -0
- package/dist/filter/FilterGroup.mjs +71 -0
- package/dist/filter/FilterGroupTitle.d.mts +3 -0
- package/dist/filter/FilterGroupTitle.mjs +18 -0
- package/dist/filter/FilterItem.d.mts +17 -0
- package/dist/filter/FilterItem.mjs +94 -0
- package/dist/filter/FilterPanel.d.mts +22 -0
- package/dist/filter/FilterPanel.mjs +158 -0
- package/dist/filter/FilterToggleButton.d.mts +15 -0
- package/dist/filter/FilterToggleButton.mjs +30 -0
- package/dist/filter/date-range.d.mts +8 -0
- package/dist/filter/date-range.mjs +13 -0
- package/dist/filter/filter-facet.d.mts +7 -0
- package/dist/filter/filter-facet.mjs +0 -0
- package/dist/heatmap/Heatmap.css +138 -0
- package/dist/heatmap/Heatmap.d.mts +10 -0
- package/dist/heatmap/Heatmap.mjs +370 -0
- package/dist/heatmap/Heatmap.module.css.mjs +17 -0
- package/dist/heatmap/HeatmapCell.d.mts +25 -0
- package/dist/heatmap/HeatmapCell.mjs +124 -0
- package/dist/heatmap/heatmap-scale.d.mts +19 -0
- package/dist/heatmap/heatmap-scale.mjs +43 -0
- package/dist/heatmap/heatmap-types.d.mts +49 -0
- package/dist/heatmap/heatmap-types.mjs +0 -0
- package/dist/hooks/use-controllable-state.d.mts +9 -0
- package/dist/hooks/use-controllable-state.mjs +44 -0
- package/dist/hooks/use-debounced-value.d.mts +1 -0
- package/dist/hooks/use-debounced-value.mjs +27 -0
- package/dist/hooks/use-detail-panel-layout.d.mts +18 -0
- package/dist/hooks/use-detail-panel-layout.mjs +94 -0
- package/dist/hooks/use-hover-card.d.mts +47 -0
- package/dist/hooks/use-hover-card.mjs +190 -0
- package/dist/hooks/use-hover-focus-card.d.mts +38 -0
- package/dist/hooks/use-hover-focus-card.mjs +321 -0
- package/dist/hooks/use-hover-intent.d.mts +6 -0
- package/dist/hooks/use-hover-intent.mjs +55 -0
- package/dist/hooks/use-merged-ref.d.mts +2 -0
- package/dist/hooks/use-merged-ref.mjs +36 -0
- package/dist/hooks/use-tracked-anchor.d.mts +14 -0
- package/dist/hooks/use-tracked-anchor.mjs +42 -0
- package/dist/index.d.mts +97 -0
- package/dist/index.mjs +88 -0
- package/dist/input/MenuButton.d.mts +47 -0
- package/dist/input/MenuButton.mjs +152 -0
- package/dist/interval-strip/IntervalStrip.css +7 -0
- package/dist/interval-strip/IntervalStrip.d.mts +39 -0
- package/dist/interval-strip/IntervalStrip.mjs +233 -0
- package/dist/interval-strip/IntervalStrip.module.css.mjs +4 -0
- package/dist/interval-strip/IntervalStripAxis.d.mts +18 -0
- package/dist/interval-strip/IntervalStripAxis.mjs +73 -0
- package/dist/interval-strip/interval-fill.d.mts +2 -0
- package/dist/interval-strip/interval-fill.mjs +13 -0
- package/dist/interval-strip/interval-layout.d.mts +33 -0
- package/dist/interval-strip/interval-layout.mjs +79 -0
- package/dist/layout/AppShell.css +103 -0
- package/dist/layout/AppShell.d.mts +73 -0
- package/dist/layout/AppShell.mjs +397 -0
- package/dist/layout/AppShell.module.css.mjs +16 -0
- package/dist/layout/ColorSchemeMenu.d.mts +14 -0
- package/dist/layout/ColorSchemeMenu.mjs +92 -0
- package/dist/layout/DemoDataPicker.d.mts +17 -0
- package/dist/layout/DemoDataPicker.mjs +150 -0
- package/dist/layout/OverflowMenu.d.mts +11 -0
- package/dist/layout/OverflowMenu.mjs +94 -0
- package/dist/layout/SidebarLayout.css +70 -0
- package/dist/layout/SidebarLayout.d.mts +33 -0
- package/dist/layout/SidebarLayout.mjs +129 -0
- package/dist/layout/SidebarLayout.module.css.mjs +8 -0
- package/dist/layout/use-date-scope-day.d.mts +23 -0
- package/dist/layout/use-date-scope-day.mjs +63 -0
- package/dist/layout/use-fill-height.d.mts +7 -0
- package/dist/layout/use-fill-height.mjs +50 -0
- package/dist/layout/use-followed-state.d.mts +5 -0
- package/dist/layout/use-followed-state.mjs +75 -0
- package/dist/layout/use-page-route.d.mts +10 -0
- package/dist/layout/use-page-route.mjs +65 -0
- package/dist/legend/Legend.d.mts +54 -0
- package/dist/legend/Legend.mjs +132 -0
- package/dist/map/MapLayersControl.d.mts +11 -0
- package/dist/map/MapLayersControl.mjs +157 -0
- package/dist/map/MapLocator.css +9 -0
- package/dist/map/MapLocator.d.mts +18 -0
- package/dist/map/MapLocator.mjs +97 -0
- package/dist/map/MapLocator.module.css.mjs +4 -0
- package/dist/map/MapMarker.d.mts +29 -0
- package/dist/map/MapMarker.mjs +265 -0
- package/dist/map/MapStops.d.mts +19 -0
- package/dist/map/MapStops.mjs +355 -0
- package/dist/map/MapView.css +24 -0
- package/dist/map/MapView.d.mts +11 -0
- package/dist/map/MapView.mjs +141 -0
- package/dist/map/MapWebgl.d.mts +9 -0
- package/dist/map/MapWebgl.mjs +727 -0
- package/dist/map/area-layers.d.mts +33 -0
- package/dist/map/area-layers.mjs +96 -0
- package/dist/map/control-group.d.mts +6 -0
- package/dist/map/control-group.mjs +12 -0
- package/dist/map/for-each-chunk.d.mts +4 -0
- package/dist/map/for-each-chunk.mjs +14 -0
- package/dist/map/highlight.d.mts +30 -0
- package/dist/map/highlight.mjs +99 -0
- package/dist/map/locator-tile.d.mts +24 -0
- package/dist/map/locator-tile.mjs +41 -0
- package/dist/map/map-sites.d.mts +12 -0
- package/dist/map/map-sites.mjs +39 -0
- package/dist/map/map-style.d.mts +24 -0
- package/dist/map/map-style.mjs +79 -0
- package/dist/map/marker-geometry.d.mts +5 -0
- package/dist/map/marker-geometry.mjs +13 -0
- package/dist/map/marker-icon.d.mts +26 -0
- package/dist/map/marker-icon.mjs +223 -0
- package/dist/map/observe-color-scheme.d.mts +5 -0
- package/dist/map/observe-color-scheme.mjs +19 -0
- package/dist/map/popup-placement.d.mts +20 -0
- package/dist/map/popup-placement.mjs +20 -0
- package/dist/map/route-layers.d.mts +28 -0
- package/dist/map/route-layers.mjs +73 -0
- package/dist/map/types.d.mts +97 -0
- package/dist/map/types.mjs +0 -0
- package/dist/map/use-painted-color-scheme.d.mts +6 -0
- package/dist/map/use-painted-color-scheme.mjs +43 -0
- package/dist/map/use-resolved-colors.d.mts +5 -0
- package/dist/map/use-resolved-colors.mjs +63 -0
- package/dist/pagination/paginationLabels.d.mts +6 -0
- package/dist/pagination/paginationLabels.mjs +8 -0
- package/dist/popover/Popover.css +176 -0
- package/dist/popover/Popover.d.mts +239 -0
- package/dist/popover/Popover.mjs +672 -0
- package/dist/popover/Popover.module.css.mjs +18 -0
- package/dist/popover/PopoverFacts.d.mts +24 -0
- package/dist/popover/PopoverFacts.mjs +63 -0
- package/dist/readout/Readout.d.mts +15 -0
- package/dist/readout/Readout.mjs +53 -0
- package/dist/readout/TimeZoneReadout.d.mts +11 -0
- package/dist/readout/TimeZoneReadout.mjs +46 -0
- package/dist/score-box/ScoreBox.css +62 -0
- package/dist/score-box/ScoreBox.d.mts +12 -0
- package/dist/score-box/ScoreBox.mjs +143 -0
- package/dist/score-box/ScoreBox.module.css.mjs +15 -0
- package/dist/segment-bar/Segment.d.mts +23 -0
- package/dist/segment-bar/Segment.mjs +27 -0
- package/dist/segment-bar/SegmentBar.css +44 -0
- package/dist/segment-bar/SegmentBar.d.mts +35 -0
- package/dist/segment-bar/SegmentBar.mjs +57 -0
- package/dist/segment-bar/SegmentBar.module.css.mjs +9 -0
- package/dist/segment-bar/segment-box.d.mts +10 -0
- package/dist/segment-bar/segment-box.mjs +30 -0
- package/dist/stat/Stat.d.mts +25 -0
- package/dist/stat/Stat.mjs +36 -0
- package/dist/stat/StatTile.d.mts +18 -0
- package/dist/stat/StatTile.mjs +37 -0
- package/dist/styles.css +1 -0
- package/dist/swatch/Swatch.d.mts +8 -0
- package/dist/swatch/Swatch.mjs +30 -0
- package/dist/swatch/legend-swatch.d.mts +3 -0
- package/dist/swatch/legend-swatch.mjs +0 -0
- package/dist/tab-bar/FilteredTabBar.d.mts +32 -0
- package/dist/tab-bar/FilteredTabBar.mjs +181 -0
- package/dist/tab-bar/TabBar.d.mts +22 -0
- package/dist/tab-bar/TabBar.mjs +151 -0
- package/dist/tab-bar/TabPanel.d.mts +9 -0
- package/dist/tab-bar/TabPanel.mjs +55 -0
- package/dist/tab-bar/assert-named-value.d.mts +4 -0
- package/dist/tab-bar/assert-named-value.mjs +6 -0
- package/dist/table/DataTable.d.mts +31 -0
- package/dist/table/DataTable.mjs +43 -0
- package/dist/theme/use-color-scheme.d.mts +14 -0
- package/dist/theme/use-color-scheme.mjs +92 -0
- package/dist/theme.css +58 -0
- package/dist/timeline/Timeline.d.mts +54 -0
- package/dist/timeline/Timeline.mjs +220 -0
- package/dist/timeline/TimelineBand.d.mts +18 -0
- package/dist/timeline/TimelineBand.mjs +30 -0
- package/dist/timeline/TimelineGroup.d.mts +7 -0
- package/dist/timeline/TimelineGroup.mjs +50 -0
- package/dist/timeline/TimelineItem.d.mts +19 -0
- package/dist/timeline/TimelineItem.mjs +64 -0
- package/dist/timeline/TimelineItemChip.css +153 -0
- package/dist/timeline/TimelineItemChip.d.mts +23 -0
- package/dist/timeline/TimelineItemChip.mjs +74 -0
- package/dist/timeline/TimelineItemChip.module.css.mjs +15 -0
- package/dist/timeline/TimelineItemMark.css +38 -0
- package/dist/timeline/TimelineItemMark.d.mts +15 -0
- package/dist/timeline/TimelineItemMark.mjs +129 -0
- package/dist/timeline/TimelineItemMark.module.css.mjs +4 -0
- package/dist/timeline/TimelineRoot.d.mts +19 -0
- package/dist/timeline/TimelineRoot.mjs +742 -0
- package/dist/timeline/TimelineRowHeader.d.mts +23 -0
- package/dist/timeline/TimelineRowHeader.mjs +244 -0
- package/dist/timeline/TimelineZoomHint.d.mts +9 -0
- package/dist/timeline/TimelineZoomHint.mjs +32 -0
- package/dist/timeline/axis-label.d.mts +5 -0
- package/dist/timeline/axis-label.mjs +53 -0
- package/dist/timeline/batched-dataset-writer.d.mts +29 -0
- package/dist/timeline/batched-dataset-writer.mjs +58 -0
- package/dist/timeline/row-card-side.d.mts +7 -0
- package/dist/timeline/row-card-side.mjs +6 -0
- package/dist/timeline/timeline-a11y.d.mts +33 -0
- package/dist/timeline/timeline-a11y.mjs +96 -0
- package/dist/timeline/timeline-context.d.mts +33 -0
- package/dist/timeline/timeline-context.mjs +40 -0
- package/dist/timeline/timeline-types.d.mts +126 -0
- package/dist/timeline/timeline-types.mjs +0 -0
- package/dist/timeline/timeline-utils.d.mts +52 -0
- package/dist/timeline/timeline-utils.mjs +130 -0
- package/dist/timeline/zoom-modifier.d.mts +21 -0
- package/dist/timeline/zoom-modifier.mjs +25 -0
- package/dist/toast/ToastProvider.d.mts +33 -0
- package/dist/toast/ToastProvider.mjs +257 -0
- package/dist/toast/toast-context.d.mts +2 -0
- package/dist/toast/toast-context.mjs +5 -0
- package/dist/tokens.css +1 -0
- package/dist/tooltip/Tooltip.d.mts +17 -0
- package/dist/tooltip/Tooltip.mjs +41 -0
- package/dist/tooltip/hover-open-delay.d.mts +2 -0
- package/dist/tooltip/hover-open-delay.mjs +4 -0
- package/dist/tooltip/is-text-cut.d.mts +1 -0
- package/dist/tooltip/is-text-cut.mjs +5 -0
- package/dist/vendor/components.d.mts +664 -0
- package/dist/vendor/components.mjs +2060 -0
- package/package.json +56 -5
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SegmentTint } from "../segment-bar/Segment.mjs";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
/** One share of a row's load bar: its size and its colour. */
|
|
4
|
+
export type TimelineRowHeaderLoadPart = SegmentTint & {
|
|
5
|
+
id: string;
|
|
6
|
+
/** @remarks The part's share of the row's capacity, where `1` is all of it. */
|
|
7
|
+
share: number;
|
|
8
|
+
};
|
|
9
|
+
/** The props of `TimelineRowHeader`: a row's label, detail, metric and load. */
|
|
10
|
+
export interface TimelineRowHeaderProps extends React.ComponentProps<"div"> {
|
|
11
|
+
label: string;
|
|
12
|
+
detail?: string;
|
|
13
|
+
note?: string;
|
|
14
|
+
metric?: string;
|
|
15
|
+
load?: TimelineRowHeaderLoadPart[];
|
|
16
|
+
leading?: ReactNode;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
/** A timeline group's row header: a label line with `detail`, a `note`, a full-width `load` bar with its
|
|
20
|
+
* `metric`, and a badge strip (`children`); a `leading` mark sits beside them all.
|
|
21
|
+
* @category Charts
|
|
22
|
+
*/
|
|
23
|
+
export default function TimelineRowHeader({ label, detail, note, metric, load, leading, children, className, ...props }: TimelineRowHeaderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import Segment from "../segment-bar/Segment.mjs";
|
|
2
|
+
import SegmentBar from "../segment-bar/SegmentBar.mjs";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Children } from "react";
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
// src/timeline/TimelineRowHeader.tsx
|
|
8
|
+
const MUTED_TEXT = "text-viz-muted font-mono text-[.6875rem] tabular-nums whitespace-nowrap";
|
|
9
|
+
function loadSegments(parts) {
|
|
10
|
+
const shown = parts.filter((part) => Number.isFinite(part.share) && part.share > 0);
|
|
11
|
+
const used = shown.reduce((sum, part) => sum + part.share, 0);
|
|
12
|
+
const scale = Math.max(1, used);
|
|
13
|
+
return {
|
|
14
|
+
parts: shown.map((part) => ({
|
|
15
|
+
...part,
|
|
16
|
+
share: part.share / scale * 100
|
|
17
|
+
})),
|
|
18
|
+
remainder: Math.max(0, 1 - used) / scale * 100
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function LoadBar(t0) {
|
|
22
|
+
const $ = c(18);
|
|
23
|
+
const { parts } = t0;
|
|
24
|
+
let T0;
|
|
25
|
+
let t1;
|
|
26
|
+
let t2;
|
|
27
|
+
let t3;
|
|
28
|
+
let t4;
|
|
29
|
+
let t5;
|
|
30
|
+
let t6;
|
|
31
|
+
if ($[0] !== parts) {
|
|
32
|
+
const segments = loadSegments(parts);
|
|
33
|
+
t5 = "timeline-row-header-load";
|
|
34
|
+
t6 = "min-w-0 flex-1";
|
|
35
|
+
T0 = SegmentBar;
|
|
36
|
+
t1 = "sm";
|
|
37
|
+
t2 = "100%";
|
|
38
|
+
t3 = true;
|
|
39
|
+
t4 = [...segments.parts.map(_temp), segments.remainder > 0 && /* @__PURE__ */ jsx(Segment, {
|
|
40
|
+
percentage: segments.remainder,
|
|
41
|
+
variant: "empty"
|
|
42
|
+
}, "remainder")];
|
|
43
|
+
$[0] = parts;
|
|
44
|
+
$[1] = T0;
|
|
45
|
+
$[2] = t1;
|
|
46
|
+
$[3] = t2;
|
|
47
|
+
$[4] = t3;
|
|
48
|
+
$[5] = t4;
|
|
49
|
+
$[6] = t5;
|
|
50
|
+
$[7] = t6;
|
|
51
|
+
} else {
|
|
52
|
+
T0 = $[1];
|
|
53
|
+
t1 = $[2];
|
|
54
|
+
t2 = $[3];
|
|
55
|
+
t3 = $[4];
|
|
56
|
+
t4 = $[5];
|
|
57
|
+
t5 = $[6];
|
|
58
|
+
t6 = $[7];
|
|
59
|
+
}
|
|
60
|
+
let t7;
|
|
61
|
+
if ($[8] !== T0 || $[9] !== t1 || $[10] !== t2 || $[11] !== t3 || $[12] !== t4) {
|
|
62
|
+
t7 = /* @__PURE__ */ jsx(T0, {
|
|
63
|
+
size: t1,
|
|
64
|
+
width: t2,
|
|
65
|
+
"aria-hidden": t3,
|
|
66
|
+
children: t4
|
|
67
|
+
});
|
|
68
|
+
$[8] = T0;
|
|
69
|
+
$[9] = t1;
|
|
70
|
+
$[10] = t2;
|
|
71
|
+
$[11] = t3;
|
|
72
|
+
$[12] = t4;
|
|
73
|
+
$[13] = t7;
|
|
74
|
+
} else t7 = $[13];
|
|
75
|
+
let t8;
|
|
76
|
+
if ($[14] !== t5 || $[15] !== t6 || $[16] !== t7) {
|
|
77
|
+
t8 = /* @__PURE__ */ jsx("div", {
|
|
78
|
+
"data-slot": t5,
|
|
79
|
+
className: t6,
|
|
80
|
+
children: t7
|
|
81
|
+
});
|
|
82
|
+
$[14] = t5;
|
|
83
|
+
$[15] = t6;
|
|
84
|
+
$[16] = t7;
|
|
85
|
+
$[17] = t8;
|
|
86
|
+
} else t8 = $[17];
|
|
87
|
+
return t8;
|
|
88
|
+
}
|
|
89
|
+
/** A timeline group's row header: a label line with `detail`, a `note`, a full-width `load` bar with its
|
|
90
|
+
* `metric`, and a badge strip (`children`); a `leading` mark sits beside them all.
|
|
91
|
+
* @category Charts
|
|
92
|
+
*/
|
|
93
|
+
function _temp(part) {
|
|
94
|
+
return /* @__PURE__ */ jsx(Segment, {
|
|
95
|
+
...part,
|
|
96
|
+
percentage: part.share
|
|
97
|
+
}, part.id);
|
|
98
|
+
}
|
|
99
|
+
function TimelineRowHeader(t0) {
|
|
100
|
+
const $ = c(38);
|
|
101
|
+
let children;
|
|
102
|
+
let className;
|
|
103
|
+
let detail;
|
|
104
|
+
let label;
|
|
105
|
+
let leading;
|
|
106
|
+
let load;
|
|
107
|
+
let metric;
|
|
108
|
+
let note;
|
|
109
|
+
let props;
|
|
110
|
+
if ($[0] !== t0) {
|
|
111
|
+
({label, detail, note, metric, load, leading, children, className, ...props} = t0);
|
|
112
|
+
$[0] = t0;
|
|
113
|
+
$[1] = children;
|
|
114
|
+
$[2] = className;
|
|
115
|
+
$[3] = detail;
|
|
116
|
+
$[4] = label;
|
|
117
|
+
$[5] = leading;
|
|
118
|
+
$[6] = load;
|
|
119
|
+
$[7] = metric;
|
|
120
|
+
$[8] = note;
|
|
121
|
+
$[9] = props;
|
|
122
|
+
} else {
|
|
123
|
+
children = $[1];
|
|
124
|
+
className = $[2];
|
|
125
|
+
detail = $[3];
|
|
126
|
+
label = $[4];
|
|
127
|
+
leading = $[5];
|
|
128
|
+
load = $[6];
|
|
129
|
+
metric = $[7];
|
|
130
|
+
note = $[8];
|
|
131
|
+
props = $[9];
|
|
132
|
+
}
|
|
133
|
+
const t1 = leading ? "grid-cols-[auto_minmax(0,1fr)]" : "grid-cols-[minmax(0,1fr)]";
|
|
134
|
+
let t2;
|
|
135
|
+
if ($[10] !== className || $[11] !== t1) {
|
|
136
|
+
t2 = clsx("grid min-w-0 gap-1.5", t1, className);
|
|
137
|
+
$[10] = className;
|
|
138
|
+
$[11] = t1;
|
|
139
|
+
$[12] = t2;
|
|
140
|
+
} else t2 = $[12];
|
|
141
|
+
let t3;
|
|
142
|
+
if ($[13] !== leading) {
|
|
143
|
+
t3 = leading && /* @__PURE__ */ jsx("div", {
|
|
144
|
+
"data-slot": "timeline-row-header-leading",
|
|
145
|
+
className: "col-start-1 row-start-1 flex items-center self-center",
|
|
146
|
+
children: leading
|
|
147
|
+
});
|
|
148
|
+
$[13] = leading;
|
|
149
|
+
$[14] = t3;
|
|
150
|
+
} else t3 = $[14];
|
|
151
|
+
let t4;
|
|
152
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
153
|
+
t4 = clsx("col-[-2/-1] min-w-0", "row-start-1 flex min-h-[1lh] items-center gap-1.5");
|
|
154
|
+
$[15] = t4;
|
|
155
|
+
} else t4 = $[15];
|
|
156
|
+
let t5;
|
|
157
|
+
if ($[16] !== label) {
|
|
158
|
+
t5 = /* @__PURE__ */ jsx("span", {
|
|
159
|
+
"data-slot": "timeline-row-header-label",
|
|
160
|
+
className: "min-w-0 flex-1 truncate font-semibold",
|
|
161
|
+
children: label
|
|
162
|
+
});
|
|
163
|
+
$[16] = label;
|
|
164
|
+
$[17] = t5;
|
|
165
|
+
} else t5 = $[17];
|
|
166
|
+
let t6;
|
|
167
|
+
if ($[18] !== detail) {
|
|
168
|
+
t6 = detail !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
169
|
+
"data-slot": "timeline-row-header-detail",
|
|
170
|
+
className: clsx(MUTED_TEXT, "flex-none"),
|
|
171
|
+
children: detail
|
|
172
|
+
});
|
|
173
|
+
$[18] = detail;
|
|
174
|
+
$[19] = t6;
|
|
175
|
+
} else t6 = $[19];
|
|
176
|
+
let t7;
|
|
177
|
+
if ($[20] !== t5 || $[21] !== t6) {
|
|
178
|
+
t7 = /* @__PURE__ */ jsxs("div", {
|
|
179
|
+
className: t4,
|
|
180
|
+
children: [t5, t6]
|
|
181
|
+
});
|
|
182
|
+
$[20] = t5;
|
|
183
|
+
$[21] = t6;
|
|
184
|
+
$[22] = t7;
|
|
185
|
+
} else t7 = $[22];
|
|
186
|
+
let t8;
|
|
187
|
+
if ($[23] !== note) {
|
|
188
|
+
t8 = note !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
189
|
+
"data-slot": "timeline-row-header-note",
|
|
190
|
+
className: clsx(MUTED_TEXT, "col-[-2/-1] min-w-0", "truncate"),
|
|
191
|
+
children: note
|
|
192
|
+
});
|
|
193
|
+
$[23] = note;
|
|
194
|
+
$[24] = t8;
|
|
195
|
+
} else t8 = $[24];
|
|
196
|
+
let t9;
|
|
197
|
+
if ($[25] !== load || $[26] !== metric) {
|
|
198
|
+
t9 = (load !== void 0 || metric !== void 0) && /* @__PURE__ */ jsxs("div", {
|
|
199
|
+
className: clsx("col-[-2/-1] min-w-0", "flex items-center gap-[.375rem]"),
|
|
200
|
+
children: [load && /* @__PURE__ */ jsx(LoadBar, { parts: load }), metric !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
201
|
+
"data-slot": "timeline-row-header-metric",
|
|
202
|
+
className: clsx(MUTED_TEXT, "flex-none"),
|
|
203
|
+
children: metric
|
|
204
|
+
})]
|
|
205
|
+
});
|
|
206
|
+
$[25] = load;
|
|
207
|
+
$[26] = metric;
|
|
208
|
+
$[27] = t9;
|
|
209
|
+
} else t9 = $[27];
|
|
210
|
+
let t10;
|
|
211
|
+
if ($[28] !== children) {
|
|
212
|
+
t10 = Children.toArray(children).length > 0 && /* @__PURE__ */ jsx("div", {
|
|
213
|
+
className: clsx("col-[-2/-1] min-w-0", "empty:hidden"),
|
|
214
|
+
children
|
|
215
|
+
});
|
|
216
|
+
$[28] = children;
|
|
217
|
+
$[29] = t10;
|
|
218
|
+
} else t10 = $[29];
|
|
219
|
+
let t11;
|
|
220
|
+
if ($[30] !== props || $[31] !== t10 || $[32] !== t2 || $[33] !== t3 || $[34] !== t7 || $[35] !== t8 || $[36] !== t9) {
|
|
221
|
+
t11 = /* @__PURE__ */ jsxs("div", {
|
|
222
|
+
"data-slot": "timeline-row-header",
|
|
223
|
+
className: t2,
|
|
224
|
+
...props,
|
|
225
|
+
children: [
|
|
226
|
+
t3,
|
|
227
|
+
t7,
|
|
228
|
+
t8,
|
|
229
|
+
t9,
|
|
230
|
+
t10
|
|
231
|
+
]
|
|
232
|
+
});
|
|
233
|
+
$[30] = props;
|
|
234
|
+
$[31] = t10;
|
|
235
|
+
$[32] = t2;
|
|
236
|
+
$[33] = t3;
|
|
237
|
+
$[34] = t7;
|
|
238
|
+
$[35] = t8;
|
|
239
|
+
$[36] = t9;
|
|
240
|
+
$[37] = t11;
|
|
241
|
+
} else t11 = $[37];
|
|
242
|
+
return t11;
|
|
243
|
+
}
|
|
244
|
+
export { TimelineRowHeader as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ZoomModifier } from "./zoom-modifier.mjs";
|
|
2
|
+
export interface TimelineZoomHintProps {
|
|
3
|
+
modifier?: ZoomModifier;
|
|
4
|
+
touch?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** The one-line "how do I zoom this?" hint for a timeline's footer. Names the same
|
|
7
|
+
* per-platform modifier {@link buildVisOptions} configures; a coarse pointer gets "Pinch to zoom".
|
|
8
|
+
*/
|
|
9
|
+
export default function TimelineZoomHint({ modifier, touch }: TimelineZoomHintProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import Readout from "../readout/Readout.mjs";
|
|
3
|
+
import { detectZoomModifier, isCoarsePointer } from "./zoom-modifier.mjs";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/timeline/TimelineZoomHint.tsx
|
|
7
|
+
/** The one-line "how do I zoom this?" hint for a timeline's footer. Names the same
|
|
8
|
+
* per-platform modifier {@link buildVisOptions} configures; a coarse pointer gets "Pinch to zoom".
|
|
9
|
+
*/
|
|
10
|
+
function TimelineZoomHint(t0) {
|
|
11
|
+
const $ = c(4);
|
|
12
|
+
const { modifier, touch } = t0;
|
|
13
|
+
const isTouch = touch ?? isCoarsePointer();
|
|
14
|
+
let t1;
|
|
15
|
+
if ($[0] !== modifier) {
|
|
16
|
+
t1 = modifier ?? detectZoomModifier();
|
|
17
|
+
$[0] = modifier;
|
|
18
|
+
$[1] = t1;
|
|
19
|
+
} else t1 = $[1];
|
|
20
|
+
const t2 = isTouch ? "Pinch to zoom" : `${t1.label} + scroll to zoom`;
|
|
21
|
+
let t3;
|
|
22
|
+
if ($[2] !== t2) {
|
|
23
|
+
t3 = /* @__PURE__ */ jsx(Readout, {
|
|
24
|
+
"data-slot": "timeline-zoom-hint",
|
|
25
|
+
children: t2
|
|
26
|
+
});
|
|
27
|
+
$[2] = t2;
|
|
28
|
+
$[3] = t3;
|
|
29
|
+
} else t3 = $[3];
|
|
30
|
+
return t3;
|
|
31
|
+
}
|
|
32
|
+
export { TimelineZoomHint as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The longest day label whose widest date fits the column, down to the day of the month.
|
|
2
|
+
* It sizes by the widest date, so every label on an axis shares one format. */
|
|
3
|
+
export declare function formatDayLabel(date: Date, dayWidthPx: number): string;
|
|
4
|
+
/** The longest hour label that fits the column, down to the hour, which a narrower column clips. */
|
|
5
|
+
export declare function formatHourLabel(date: Date, hourColumnWidthPx: number): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/timeline/axis-label.ts
|
|
2
|
+
const DAY_CHARACTER_WIDTH_PX = 8;
|
|
3
|
+
const HOUR_CHARACTER_WIDTH_PX = 6;
|
|
4
|
+
const LABEL_INSET_PX = 15;
|
|
5
|
+
const weekday = new Intl.DateTimeFormat("en-US", { weekday: "short" });
|
|
6
|
+
const dayOfMonth = new Intl.DateTimeFormat("en-US", { day: "numeric" });
|
|
7
|
+
const longMonth = new Intl.DateTimeFormat("en-US", { month: "long" });
|
|
8
|
+
const shortMonth = new Intl.DateTimeFormat("en-US", { month: "short" });
|
|
9
|
+
const hourAndMinute = new Intl.DateTimeFormat("en-GB", {
|
|
10
|
+
hour: "2-digit",
|
|
11
|
+
minute: "2-digit",
|
|
12
|
+
hourCycle: "h23"
|
|
13
|
+
});
|
|
14
|
+
const hourOnly = new Intl.DateTimeFormat("en-GB", {
|
|
15
|
+
hour: "2-digit",
|
|
16
|
+
hourCycle: "h23"
|
|
17
|
+
});
|
|
18
|
+
const DAY_TIERS = [
|
|
19
|
+
{
|
|
20
|
+
widestCharacters: 16,
|
|
21
|
+
label: (date) => `${weekday.format(date)} ${dayOfMonth.format(date)} ${longMonth.format(date)}`
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
widestCharacters: 10,
|
|
25
|
+
label: (date) => `${weekday.format(date)} ${dayOfMonth.format(date)} ${shortMonth.format(date)}`
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
widestCharacters: 6,
|
|
29
|
+
label: (date) => `${dayOfMonth.format(date)} ${shortMonth.format(date)}`
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
const HOUR_TIERS = [{
|
|
33
|
+
widestCharacters: 5,
|
|
34
|
+
label: (date) => hourAndMinute.format(date)
|
|
35
|
+
}, {
|
|
36
|
+
widestCharacters: 2,
|
|
37
|
+
label: (date) => hourOnly.format(date)
|
|
38
|
+
}];
|
|
39
|
+
function longestFitting(tiers, characterWidthPx, columnWidthPx) {
|
|
40
|
+
return tiers.find(({ widestCharacters }) => widestCharacters * characterWidthPx + LABEL_INSET_PX <= columnWidthPx);
|
|
41
|
+
}
|
|
42
|
+
/** The longest day label whose widest date fits the column, down to the day of the month.
|
|
43
|
+
* It sizes by the widest date, so every label on an axis shares one format. */
|
|
44
|
+
function formatDayLabel(date, dayWidthPx) {
|
|
45
|
+
const tier = longestFitting(DAY_TIERS, DAY_CHARACTER_WIDTH_PX, dayWidthPx);
|
|
46
|
+
return tier ? tier.label(date) : dayOfMonth.format(date);
|
|
47
|
+
}
|
|
48
|
+
/** The longest hour label that fits the column, down to the hour, which a narrower column clips. */
|
|
49
|
+
function formatHourLabel(date, hourColumnWidthPx) {
|
|
50
|
+
const tier = longestFitting(HOUR_TIERS, HOUR_CHARACTER_WIDTH_PX, hourColumnWidthPx);
|
|
51
|
+
return tier ? tier.label(date) : hourOnly.format(date);
|
|
52
|
+
}
|
|
53
|
+
export { formatDayLabel, formatHourLabel };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TimelineId } from "./timeline-types.mjs";
|
|
2
|
+
import { DataSet } from "vis-data";
|
|
3
|
+
type IdentifiableRow = {
|
|
4
|
+
id?: TimelineId;
|
|
5
|
+
group?: TimelineId;
|
|
6
|
+
};
|
|
7
|
+
type DrawnGroups = Pick<DataSet<{
|
|
8
|
+
id?: TimelineId;
|
|
9
|
+
}>, "get">;
|
|
10
|
+
/** Coalesces per-child DataSet writes into one remove and one update per flush, since vis-timeline re-sorts
|
|
11
|
+
* every group's items on EACH dispatch. Last write per id wins. A row moving to a group that `groups` does not
|
|
12
|
+
* hold yet is removed and added again: vis-timeline would keep it in its old group as well.
|
|
13
|
+
* @see {@link https://github.com/visjs/vis-timeline} `ItemSet._onUpdate` / `_order()` / `_moveToGroup()`
|
|
14
|
+
*/
|
|
15
|
+
export declare class BatchedDataSetWriter<Row extends IdentifiableRow> {
|
|
16
|
+
private readonly pending;
|
|
17
|
+
private flushScheduled;
|
|
18
|
+
private readonly target;
|
|
19
|
+
private readonly groups;
|
|
20
|
+
constructor(target: DataSet<Row>, groups?: DrawnGroups);
|
|
21
|
+
update(row: Row & {
|
|
22
|
+
id: TimelineId;
|
|
23
|
+
}): void;
|
|
24
|
+
remove(id: TimelineId): void;
|
|
25
|
+
private scheduleFlush;
|
|
26
|
+
flush(): void;
|
|
27
|
+
private movesToUndrawnGroup;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/timeline/batched-dataset-writer.ts
|
|
2
|
+
/** Coalesces per-child DataSet writes into one remove and one update per flush, since vis-timeline re-sorts
|
|
3
|
+
* every group's items on EACH dispatch. Last write per id wins. A row moving to a group that `groups` does not
|
|
4
|
+
* hold yet is removed and added again: vis-timeline would keep it in its old group as well.
|
|
5
|
+
* @see {@link https://github.com/visjs/vis-timeline} `ItemSet._onUpdate` / `_order()` / `_moveToGroup()`
|
|
6
|
+
*/
|
|
7
|
+
var BatchedDataSetWriter = class {
|
|
8
|
+
pending = /* @__PURE__ */ new Map();
|
|
9
|
+
flushScheduled = false;
|
|
10
|
+
target;
|
|
11
|
+
groups;
|
|
12
|
+
constructor(target, groups) {
|
|
13
|
+
this.target = target;
|
|
14
|
+
this.groups = groups;
|
|
15
|
+
}
|
|
16
|
+
update(row) {
|
|
17
|
+
this.pending.set(row.id, {
|
|
18
|
+
op: "update",
|
|
19
|
+
row
|
|
20
|
+
});
|
|
21
|
+
this.scheduleFlush();
|
|
22
|
+
}
|
|
23
|
+
remove(id) {
|
|
24
|
+
this.pending.set(id, { op: "remove" });
|
|
25
|
+
this.scheduleFlush();
|
|
26
|
+
}
|
|
27
|
+
scheduleFlush() {
|
|
28
|
+
if (this.flushScheduled) return;
|
|
29
|
+
this.flushScheduled = true;
|
|
30
|
+
queueMicrotask(() => {
|
|
31
|
+
this.flushScheduled = false;
|
|
32
|
+
this.flush();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
flush() {
|
|
36
|
+
if (this.pending.size === 0) return;
|
|
37
|
+
const updates = [];
|
|
38
|
+
const removals = [];
|
|
39
|
+
for (const [id, entry] of this.pending) {
|
|
40
|
+
if (entry.op === "remove") {
|
|
41
|
+
removals.push(id);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
updates.push(entry.row);
|
|
45
|
+
if (this.movesToUndrawnGroup(entry.row)) removals.push(id);
|
|
46
|
+
}
|
|
47
|
+
this.pending.clear();
|
|
48
|
+
if (removals.length > 0) this.target.remove(removals);
|
|
49
|
+
if (updates.length > 0) this.target.update(updates);
|
|
50
|
+
}
|
|
51
|
+
movesToUndrawnGroup(row) {
|
|
52
|
+
if (!this.groups) return false;
|
|
53
|
+
const current = this.target.get(row.id);
|
|
54
|
+
if (current === null || current.group === row.group) return false;
|
|
55
|
+
return row.group === void 0 || this.groups.get(row.group) === null;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
export { BatchedDataSetWriter };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type RowCardSide = "right" | "bottom";
|
|
2
|
+
/** Beside its row when the measured card fits before the viewport's right edge, else below the row. */
|
|
3
|
+
export declare function rowCardSide({ anchorRight, cardWidth, viewportWidth }: {
|
|
4
|
+
anchorRight: number;
|
|
5
|
+
cardWidth: number;
|
|
6
|
+
viewportWidth: number;
|
|
7
|
+
}): RowCardSide;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// src/timeline/row-card-side.ts
|
|
2
|
+
/** Beside its row when the measured card fits before the viewport's right edge, else below the row. */
|
|
3
|
+
function rowCardSide({ anchorRight, cardWidth, viewportWidth }) {
|
|
4
|
+
return anchorRight + cardWidth > viewportWidth ? "bottom" : "right";
|
|
5
|
+
}
|
|
6
|
+
export { rowCardSide };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TimelineItemRow } from "./timeline-context.mjs";
|
|
2
|
+
import { TimelineId, TimelineItemDescriptor } from "./timeline-types.mjs";
|
|
3
|
+
/** Scalar descriptors from the live item DataSet rows. The cursor, table, and announcer
|
|
4
|
+
* derive from these — never the (virtualized) DOM — so an off-screen item stays navigable. */
|
|
5
|
+
export declare function rowsToDescriptors(rows: TimelineItemRow[]): TimelineItemDescriptor[];
|
|
6
|
+
/** Non-background items ordered by start time (then id) — the sequence the keyboard
|
|
7
|
+
* cursor walks. Background spans are excluded and reachable by pointer only. */
|
|
8
|
+
export declare function orderItemsChronologically(items: TimelineItemDescriptor[]): TimelineItemDescriptor[];
|
|
9
|
+
export type CursorAction = "first" | "last" | "next" | "prev" | "nextGroup" | "prevGroup";
|
|
10
|
+
/** Where the keyboard cursor rests: on an item, or on a drawn group (row) with no item to land on. */
|
|
11
|
+
export type TimelineCursor = {
|
|
12
|
+
kind: "item";
|
|
13
|
+
id: TimelineId;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "group";
|
|
16
|
+
id: TimelineId;
|
|
17
|
+
};
|
|
18
|
+
/** Pure cursor reducer; `null` means the key moves nothing. ←/→ and Home/End walk the time-ordered items; ↑/↓ walk
|
|
19
|
+
* `groups` in drawn order, onto a group's first item or onto the group itself when it has none. */
|
|
20
|
+
export declare function moveCursor(action: CursorAction, current: TimelineCursor | null, ordered: TimelineItemDescriptor[], groups: TimelineId[]): TimelineCursor | null;
|
|
21
|
+
export declare function formatTimeRange(start: number, end: number): string;
|
|
22
|
+
/** The polite-live-region announcement for a focused item, independent of whether its DOM
|
|
23
|
+
* node is rendered. It ends with the item's own `statusLabel` when the app passes one, never a colour's word. */
|
|
24
|
+
export declare function announceItem(desc: TimelineItemDescriptor, groupLabel: string | undefined): string;
|
|
25
|
+
/** The window a key moves the view to, or `null` when the key does not pan or zoom. Page Up and Page Down pan by one
|
|
26
|
+
* window, `+` and `-` halve or double its width around its middle; the engine then clamps to its zoom and bounds. */
|
|
27
|
+
export declare function stepWindow(key: string, window: {
|
|
28
|
+
start: Date;
|
|
29
|
+
end: Date;
|
|
30
|
+
}): {
|
|
31
|
+
start: Date;
|
|
32
|
+
end: Date;
|
|
33
|
+
} | null;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { compareNatural } from "@timefoldai/viz-core";
|
|
2
|
+
// src/timeline/timeline-a11y.ts
|
|
3
|
+
/** Scalar descriptors from the live item DataSet rows. The cursor, table, and announcer
|
|
4
|
+
* derive from these — never the (virtualized) DOM — so an off-screen item stays navigable. */
|
|
5
|
+
function rowsToDescriptors(rows) {
|
|
6
|
+
return rows.map((row) => ({
|
|
7
|
+
id: row.id ?? "",
|
|
8
|
+
group: row.group,
|
|
9
|
+
start: +new Date(row.start),
|
|
10
|
+
end: +new Date(row.end ?? row.start),
|
|
11
|
+
type: row.type ?? "range",
|
|
12
|
+
variant: row.variant,
|
|
13
|
+
state: row.state,
|
|
14
|
+
label: row.label,
|
|
15
|
+
statusLabel: row.statusLabel
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
/** Non-background items ordered by start time (then id) — the sequence the keyboard
|
|
19
|
+
* cursor walks. Background spans are excluded and reachable by pointer only. */
|
|
20
|
+
function orderItemsChronologically(items) {
|
|
21
|
+
return [...items].filter((item) => item.type !== "background").sort((a, b) => a.start - b.start || compareNatural(String(a.id), String(b.id)));
|
|
22
|
+
}
|
|
23
|
+
function clampedStep(forward, index, last) {
|
|
24
|
+
if (index < 0) return forward ? 0 : last;
|
|
25
|
+
return forward ? Math.min(index + 1, last) : Math.max(index - 1, 0);
|
|
26
|
+
}
|
|
27
|
+
function moveAlongItems(action, current, ordered) {
|
|
28
|
+
const last = ordered.length - 1;
|
|
29
|
+
if (last < 0) return null;
|
|
30
|
+
if (current?.kind === "group" && (action === "next" || action === "prev")) return null;
|
|
31
|
+
const index = current?.kind === "item" ? ordered.findIndex((d) => d.id === current.id) : -1;
|
|
32
|
+
const targetItem = ordered[action === "first" ? 0 : action === "last" ? last : clampedStep(action === "next", index, last)];
|
|
33
|
+
return targetItem ? {
|
|
34
|
+
kind: "item",
|
|
35
|
+
id: targetItem.id
|
|
36
|
+
} : null;
|
|
37
|
+
}
|
|
38
|
+
function moveAlongGroups(forward, current, ordered, groups) {
|
|
39
|
+
if (groups.length === 0) return null;
|
|
40
|
+
const currentGroup = current?.kind === "item" ? ordered.find((d) => d.id === current.id)?.group : current?.id;
|
|
41
|
+
const group = groups[clampedStep(forward, currentGroup === void 0 ? -1 : groups.indexOf(currentGroup), groups.length - 1)];
|
|
42
|
+
if (group === void 0) return null;
|
|
43
|
+
const firstItem = ordered.find((d) => d.group === group);
|
|
44
|
+
return firstItem ? {
|
|
45
|
+
kind: "item",
|
|
46
|
+
id: firstItem.id
|
|
47
|
+
} : {
|
|
48
|
+
kind: "group",
|
|
49
|
+
id: group
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Pure cursor reducer; `null` means the key moves nothing. ←/→ and Home/End walk the time-ordered items; ↑/↓ walk
|
|
53
|
+
* `groups` in drawn order, onto a group's first item or onto the group itself when it has none. */
|
|
54
|
+
function moveCursor(action, current, ordered, groups) {
|
|
55
|
+
if (action === "nextGroup" || action === "prevGroup") return moveAlongGroups(action === "nextGroup", current, ordered, groups);
|
|
56
|
+
return moveAlongItems(action, current, ordered);
|
|
57
|
+
}
|
|
58
|
+
function formatDateTime(ms) {
|
|
59
|
+
return new Date(ms).toLocaleString("en-GB", {
|
|
60
|
+
month: "short",
|
|
61
|
+
day: "numeric",
|
|
62
|
+
hour: "2-digit",
|
|
63
|
+
minute: "2-digit"
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function formatTimeRange(start, end) {
|
|
67
|
+
return `${formatDateTime(start)}–${formatDateTime(end)}`;
|
|
68
|
+
}
|
|
69
|
+
/** The polite-live-region announcement for a focused item, independent of whether its DOM
|
|
70
|
+
* node is rendered. It ends with the item's own `statusLabel` when the app passes one, never a colour's word. */
|
|
71
|
+
function announceItem(desc, groupLabel) {
|
|
72
|
+
const name = desc.label ?? String(desc.id);
|
|
73
|
+
const prefix = groupLabel ? `${groupLabel}, ` : "";
|
|
74
|
+
const status = desc.statusLabel ? `, ${desc.statusLabel}` : "";
|
|
75
|
+
return `${prefix}${name}, ${formatTimeRange(desc.start, desc.end)}${status}`;
|
|
76
|
+
}
|
|
77
|
+
const WINDOW_KEYS = {
|
|
78
|
+
PageDown: (start, width) => [start + width, start + 2 * width],
|
|
79
|
+
PageUp: (start, width) => [start - width, start],
|
|
80
|
+
"+": (start, width) => [start + width / 4, start + 3 * width / 4],
|
|
81
|
+
"=": (start, width) => [start + width / 4, start + 3 * width / 4],
|
|
82
|
+
"-": (start, width) => [start - width / 2, start + 3 * width / 2]
|
|
83
|
+
};
|
|
84
|
+
/** The window a key moves the view to, or `null` when the key does not pan or zoom. Page Up and Page Down pan by one
|
|
85
|
+
* window, `+` and `-` halve or double its width around its middle; the engine then clamps to its zoom and bounds. */
|
|
86
|
+
function stepWindow(key, window) {
|
|
87
|
+
const step = WINDOW_KEYS[key];
|
|
88
|
+
if (!step) return null;
|
|
89
|
+
const start = +window.start;
|
|
90
|
+
const [nextStart, nextEnd] = step(start, +window.end - start);
|
|
91
|
+
return {
|
|
92
|
+
start: new Date(nextStart),
|
|
93
|
+
end: new Date(nextEnd)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export { announceItem, formatTimeRange, moveCursor, orderItemsChronologically, rowsToDescriptors, stepWindow };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BatchedDataSetWriter } from "./batched-dataset-writer.mjs";
|
|
2
|
+
import { TimelineId, TimelineItemState, TimelineItemVariant } from "./timeline-types.mjs";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { TimelineGroup, TimelineItem } from "vis-timeline/standalone";
|
|
5
|
+
/** Internal vis-data row for an item: the vis "add" interface plus the scalar a11y
|
|
6
|
+
* fields stashed on the row so the table/cursor/announcer derive from `itemsDS.get()` alone. */
|
|
7
|
+
export type TimelineItemRow = TimelineItem & {
|
|
8
|
+
label?: string;
|
|
9
|
+
variant: TimelineItemVariant;
|
|
10
|
+
state?: TimelineItemState;
|
|
11
|
+
statusLabel?: string;
|
|
12
|
+
};
|
|
13
|
+
export type TimelineGroupRow = TimelineGroup & {
|
|
14
|
+
label?: string;
|
|
15
|
+
};
|
|
16
|
+
export interface TimelineContextValue {
|
|
17
|
+
itemsWriter: BatchedDataSetWriter<TimelineItemRow>;
|
|
18
|
+
groupsWriter: BatchedDataSetWriter<TimelineGroupRow>;
|
|
19
|
+
timeZoneOffsetSeconds?: number;
|
|
20
|
+
itemPopovers: Map<TimelineId, ReactNode>;
|
|
21
|
+
groupPopovers: Map<TimelineId, ReactNode>;
|
|
22
|
+
itemHosts: Map<TimelineId, HTMLElement>;
|
|
23
|
+
groupHosts: Map<TimelineId, HTMLElement>;
|
|
24
|
+
onGroupPointerEnter: (id: TimelineId) => void;
|
|
25
|
+
onGroupPointerLeave: (id: TimelineId) => void;
|
|
26
|
+
onGroupFocus: (id: TimelineId) => void;
|
|
27
|
+
onGroupBlur: (id: TimelineId) => void;
|
|
28
|
+
registerGroup: () => void;
|
|
29
|
+
}
|
|
30
|
+
export declare const TimelineContextProvider: import("react").Provider<TimelineContextValue | null>;
|
|
31
|
+
export declare function useTimelineContext(): TimelineContextValue;
|
|
32
|
+
/** Keeps `registry[id] = value` for the life of the calling component; an `undefined` value registers nothing. */
|
|
33
|
+
export declare function useRegistryEntry<Key, Value>(registry: Map<Key, Value>, id: Key, value: Value | undefined): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { createContext, use, useEffect } from "react";
|
|
4
|
+
// src/timeline/timeline-context.ts
|
|
5
|
+
const TimelineContext = createContext(null);
|
|
6
|
+
const TimelineContextProvider = TimelineContext.Provider;
|
|
7
|
+
function useTimelineContext() {
|
|
8
|
+
const context = use(TimelineContext);
|
|
9
|
+
if (!context) throw new Error("TimelineItem and TimelineGroup must be rendered inside TimelineRoot");
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
/** Keeps `registry[id] = value` for the life of the calling component; an `undefined` value registers nothing. */
|
|
13
|
+
function useRegistryEntry(registry, id, value) {
|
|
14
|
+
const $ = c(5);
|
|
15
|
+
let t0;
|
|
16
|
+
let t1;
|
|
17
|
+
if ($[0] !== id || $[1] !== registry || $[2] !== value) {
|
|
18
|
+
t0 = () => {
|
|
19
|
+
if (value !== void 0) registry.set(id, value);
|
|
20
|
+
return () => {
|
|
21
|
+
registry.delete(id);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
t1 = [
|
|
25
|
+
registry,
|
|
26
|
+
id,
|
|
27
|
+
value
|
|
28
|
+
];
|
|
29
|
+
$[0] = id;
|
|
30
|
+
$[1] = registry;
|
|
31
|
+
$[2] = value;
|
|
32
|
+
$[3] = t0;
|
|
33
|
+
$[4] = t1;
|
|
34
|
+
} else {
|
|
35
|
+
t0 = $[3];
|
|
36
|
+
t1 = $[4];
|
|
37
|
+
}
|
|
38
|
+
useEffect(t0, t1);
|
|
39
|
+
}
|
|
40
|
+
export { TimelineContextProvider, useRegistryEntry, useTimelineContext };
|