@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.
- package/LICENSE +202 -0
- package/README.md +240 -2
- 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 +61 -3
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useDebouncedValue } from "../hooks/use-debounced-value.mjs";
|
|
3
|
+
import Legend from "../legend/Legend.mjs";
|
|
4
|
+
import { paginationLabels } from "../pagination/paginationLabels.mjs";
|
|
5
|
+
import TimelineBand from "./TimelineBand.mjs";
|
|
6
|
+
import TimelineGroup from "./TimelineGroup.mjs";
|
|
7
|
+
import { TimelineItem } from "./TimelineItem.mjs";
|
|
8
|
+
import TimelineRoot from "./TimelineRoot.mjs";
|
|
9
|
+
import TimelineZoomHint from "./TimelineZoomHint.mjs";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
12
|
+
import { Pagination, SearchInput } from "../vendor/components.mjs";
|
|
13
|
+
import { compareNatural } from "@timefoldai/viz-core";
|
|
14
|
+
// src/timeline/Timeline.tsx
|
|
15
|
+
function compareByLabel(a, b) {
|
|
16
|
+
return compareNatural(a.label ?? "", b.label ?? "");
|
|
17
|
+
}
|
|
18
|
+
function compareByOrderThenLabel(a, b) {
|
|
19
|
+
return (a.order ?? 0) - (b.order ?? 0) || compareByLabel(a, b);
|
|
20
|
+
}
|
|
21
|
+
const sortedRowsByItems = /* @__PURE__ */ new WeakMap();
|
|
22
|
+
/**
|
|
23
|
+
* The row order of an ungrouped chart: by start, then by label (between rows
|
|
24
|
+
* that start together), sorted once per `items` array, so a caller must not change one in place.
|
|
25
|
+
*/
|
|
26
|
+
function sortUngroupedRows(items) {
|
|
27
|
+
const cached = sortedRowsByItems.get(items);
|
|
28
|
+
if (cached) return cached;
|
|
29
|
+
const sorted = items.map((item) => ({
|
|
30
|
+
item,
|
|
31
|
+
start: new Date(item.start).getTime()
|
|
32
|
+
})).sort((a, b) => a.start - b.start || compareByLabel(a.item, b.item)).map(({ item }) => item);
|
|
33
|
+
sortedRowsByItems.set(items, sorted);
|
|
34
|
+
return sorted;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A paged Timeline / Gantt chart — the entrypoint for rendering a model's schedule.
|
|
38
|
+
* A data layer over {@link TimelineRoot}: sorts and pages `groups` (by `order`, then label) or `items` into rows.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <Timeline
|
|
43
|
+
* items={items}
|
|
44
|
+
* groups={groups}
|
|
45
|
+
* options={{ timeZoneOffsetSeconds }}
|
|
46
|
+
* aria-label="Shifts timeline"
|
|
47
|
+
* />
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/grid/
|
|
51
|
+
* @category Charts
|
|
52
|
+
*/
|
|
53
|
+
function Timeline({ items, bands, markers, groups, options, bounds = "data", visibleRange, defaultVisibleRange, onVisibleRangeChange, "aria-label": ariaLabel, legend, pageSize = 10, paginationPosition = "bottom", searchable = false, highlightedGroup = null, onHighlightedGroupChange, onGroupClick, fitKey, className, style, ref }) {
|
|
54
|
+
const [currentPage, setCurrentPage] = useState(0);
|
|
55
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
56
|
+
const debouncedSearch = useDebouncedValue(searchTerm, 300);
|
|
57
|
+
const [lastUserRange, setLastUserRange] = useState(void 0);
|
|
58
|
+
const [carriedRange, setCarriedRange] = useState(void 0);
|
|
59
|
+
const onUserRangeChange = useCallback((window) => {
|
|
60
|
+
setLastUserRange(window);
|
|
61
|
+
onVisibleRangeChange?.(window);
|
|
62
|
+
}, [onVisibleRangeChange]);
|
|
63
|
+
const chartFrameRef = useRef(null);
|
|
64
|
+
const [reservedHeight, setReservedHeight] = useState(void 0);
|
|
65
|
+
const [frameHeight, setFrameHeight] = useState();
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const frame = chartFrameRef.current;
|
|
68
|
+
if (!frame) return;
|
|
69
|
+
const observer = new ResizeObserver(() => setFrameHeight(frame.getBoundingClientRect().height));
|
|
70
|
+
observer.observe(frame);
|
|
71
|
+
return () => observer.disconnect();
|
|
72
|
+
}, []);
|
|
73
|
+
const sortedGroups = useMemo(() => [...groups ?? []].sort(compareByOrderThenLabel), [groups]);
|
|
74
|
+
const sortedItems = useMemo(() => groups ? items : sortUngroupedRows(items), [items, groups]);
|
|
75
|
+
const searchedGroups = useMemo(() => {
|
|
76
|
+
if (!debouncedSearch) return sortedGroups;
|
|
77
|
+
const query = debouncedSearch.toLowerCase();
|
|
78
|
+
return sortedGroups.filter((group) => group.label?.toLowerCase().includes(query));
|
|
79
|
+
}, [sortedGroups, debouncedSearch]);
|
|
80
|
+
const searchedItems = useMemo(() => {
|
|
81
|
+
if (!debouncedSearch || groups) return sortedItems;
|
|
82
|
+
const query_0 = debouncedSearch.toLowerCase();
|
|
83
|
+
return sortedItems.filter((item) => item.label?.toLowerCase().includes(query_0));
|
|
84
|
+
}, [
|
|
85
|
+
sortedItems,
|
|
86
|
+
debouncedSearch,
|
|
87
|
+
groups
|
|
88
|
+
]);
|
|
89
|
+
let effectiveCurrentPage = currentPage;
|
|
90
|
+
const [prevSearch, setPrevSearch] = useState(debouncedSearch);
|
|
91
|
+
if (prevSearch !== debouncedSearch) {
|
|
92
|
+
setPrevSearch(debouncedSearch);
|
|
93
|
+
setCurrentPage(0);
|
|
94
|
+
effectiveCurrentPage = 0;
|
|
95
|
+
setCarriedRange(void 0);
|
|
96
|
+
setLastUserRange(void 0);
|
|
97
|
+
}
|
|
98
|
+
const [prevHighlight, setPrevHighlight] = useState(highlightedGroup);
|
|
99
|
+
if (prevHighlight !== highlightedGroup) {
|
|
100
|
+
setPrevHighlight(highlightedGroup);
|
|
101
|
+
const highlightedIndex = searchedGroups.findIndex((group_0) => group_0.id === highlightedGroup);
|
|
102
|
+
const highlightedPage = Math.floor(highlightedIndex / pageSize);
|
|
103
|
+
if (highlightedIndex >= 0 && highlightedPage !== effectiveCurrentPage) {
|
|
104
|
+
setCarriedRange(lastUserRange);
|
|
105
|
+
setReservedHeight(frameHeight);
|
|
106
|
+
setCurrentPage(highlightedPage);
|
|
107
|
+
effectiveCurrentPage = highlightedPage;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const totalPages = Math.ceil((groups ? searchedGroups.length : searchedItems.length || 1) / pageSize);
|
|
111
|
+
const safePage = Math.min(effectiveCurrentPage, Math.max(0, totalPages - 1));
|
|
112
|
+
if (safePage !== effectiveCurrentPage) setCurrentPage(safePage);
|
|
113
|
+
const { groupsToShow: groupsToShow_0, itemsToShow, bandsToShow } = useMemo(() => {
|
|
114
|
+
const groupsToShow = searchedGroups.slice(safePage * pageSize, (safePage + 1) * pageSize);
|
|
115
|
+
const visibleGroupIds = new Set(groupsToShow.map((group_1) => group_1.id));
|
|
116
|
+
return {
|
|
117
|
+
groupsToShow,
|
|
118
|
+
itemsToShow: groups ? items.filter((item_0) => item_0.group != null && visibleGroupIds.has(item_0.group)) : searchedItems.slice(safePage * pageSize, (safePage + 1) * pageSize),
|
|
119
|
+
bandsToShow: groups ? stripsLast((bands ?? []).filter((band) => band.group != null && visibleGroupIds.has(band.group))) : []
|
|
120
|
+
};
|
|
121
|
+
}, [
|
|
122
|
+
searchedGroups,
|
|
123
|
+
searchedItems,
|
|
124
|
+
items,
|
|
125
|
+
bands,
|
|
126
|
+
groups,
|
|
127
|
+
safePage,
|
|
128
|
+
pageSize
|
|
129
|
+
]);
|
|
130
|
+
const showLegend = legend !== void 0 && legend.length > 0;
|
|
131
|
+
const showTopPager = paginationPosition !== "bottom" && totalPages > 1;
|
|
132
|
+
const showBottomPager = paginationPosition !== "top";
|
|
133
|
+
const showTopToolbar = searchable || showTopPager;
|
|
134
|
+
const goToPage = (page) => {
|
|
135
|
+
setCarriedRange(lastUserRange);
|
|
136
|
+
setReservedHeight(chartFrameRef.current?.getBoundingClientRect().height);
|
|
137
|
+
setCurrentPage(page - 1);
|
|
138
|
+
};
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (reservedHeight === void 0) return;
|
|
141
|
+
const frame_0 = requestAnimationFrame(() => {
|
|
142
|
+
setReservedHeight(void 0);
|
|
143
|
+
});
|
|
144
|
+
return () => {
|
|
145
|
+
cancelAnimationFrame(frame_0);
|
|
146
|
+
};
|
|
147
|
+
}, [reservedHeight, safePage]);
|
|
148
|
+
const pager = (position) => /* @__PURE__ */ jsx(Pagination, {
|
|
149
|
+
...paginationLabels,
|
|
150
|
+
current: safePage + 1,
|
|
151
|
+
pageCount: totalPages,
|
|
152
|
+
onPageChange: goToPage,
|
|
153
|
+
className: "justify-end",
|
|
154
|
+
"data-slot": "timeline-pagination",
|
|
155
|
+
"aria-label": `pagination, ${position} the timeline`
|
|
156
|
+
});
|
|
157
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
158
|
+
ref,
|
|
159
|
+
className,
|
|
160
|
+
style,
|
|
161
|
+
"data-slot": "timeline",
|
|
162
|
+
children: [
|
|
163
|
+
showTopToolbar && /* @__PURE__ */ jsxs("div", {
|
|
164
|
+
className: "toolbar",
|
|
165
|
+
children: [searchable && /* @__PURE__ */ jsx(SearchInput, {
|
|
166
|
+
"aria-label": "Search",
|
|
167
|
+
placeholder: "Search…",
|
|
168
|
+
containerProps: { className: "w-auto" },
|
|
169
|
+
value: searchTerm,
|
|
170
|
+
onChange: (event) => {
|
|
171
|
+
setSearchTerm(event.target.value);
|
|
172
|
+
}
|
|
173
|
+
}), showTopPager && /* @__PURE__ */ jsx("div", {
|
|
174
|
+
className: "right ml-auto",
|
|
175
|
+
children: pager("above")
|
|
176
|
+
})]
|
|
177
|
+
}),
|
|
178
|
+
/* @__PURE__ */ jsx("div", {
|
|
179
|
+
ref: chartFrameRef,
|
|
180
|
+
style: { minHeight: reservedHeight },
|
|
181
|
+
children: /* @__PURE__ */ jsxs(TimelineRoot, {
|
|
182
|
+
"aria-label": ariaLabel,
|
|
183
|
+
markers,
|
|
184
|
+
options,
|
|
185
|
+
bounds,
|
|
186
|
+
visibleRange,
|
|
187
|
+
defaultVisibleRange: carriedRange ?? defaultVisibleRange,
|
|
188
|
+
onVisibleRangeChange: onUserRangeChange,
|
|
189
|
+
fitKey: fitKey === void 0 ? void 0 : `${fitKey}#${debouncedSearch}`,
|
|
190
|
+
onHighlightedGroupChange,
|
|
191
|
+
onGroupClick,
|
|
192
|
+
children: [
|
|
193
|
+
bandsToShow.map((band_0) => /* @__PURE__ */ jsx(TimelineBand, { ...band_0 }, String(band_0.id))),
|
|
194
|
+
itemsToShow.map((item_1) => /* @__PURE__ */ jsx(TimelineItem, { ...item_1 }, String(item_1.id))),
|
|
195
|
+
groupsToShow_0.map((group_2, index) => /* @__PURE__ */ jsx(TimelineGroup, {
|
|
196
|
+
...group_2,
|
|
197
|
+
order: index,
|
|
198
|
+
highlighted: group_2.id === highlightedGroup
|
|
199
|
+
}, String(group_2.id)))
|
|
200
|
+
]
|
|
201
|
+
}, safePage)
|
|
202
|
+
}),
|
|
203
|
+
/* @__PURE__ */ jsxs("div", {
|
|
204
|
+
"data-slot": "timeline-footer",
|
|
205
|
+
className: "toolbar mt-[calc(var(--main-padding-y)+1.5em)] mb-0 justify-between",
|
|
206
|
+
children: [showLegend && /* @__PURE__ */ jsx(Legend, {
|
|
207
|
+
variant: "timeline",
|
|
208
|
+
entries: legend
|
|
209
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
210
|
+
className: "ml-auto flex flex-wrap items-center justify-end gap-[1em]",
|
|
211
|
+
children: [/* @__PURE__ */ jsx(TimelineZoomHint, {}), showBottomPager && pager("below")]
|
|
212
|
+
})]
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function stripsLast(bands) {
|
|
218
|
+
return [...bands.filter((band) => band.fill !== "strip"), ...bands.filter((band) => band.fill === "strip")];
|
|
219
|
+
}
|
|
220
|
+
export { Timeline as default, sortUngroupedRows };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TimelineBandProps } from "./timeline-types.mjs";
|
|
2
|
+
/** A span behind a row's items: a full-height `tint` or `shade` wash, or a thin wordless `strip` at the top of the
|
|
3
|
+
* row whose `popover` opens when `TimelineRoot` hit-tests its box.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <TimelineBand
|
|
8
|
+
* id="window"
|
|
9
|
+
* group="alice"
|
|
10
|
+
* start={start}
|
|
11
|
+
* end={end}
|
|
12
|
+
* state="neutral"
|
|
13
|
+
* />
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @category Charts
|
|
17
|
+
*/
|
|
18
|
+
export default function TimelineBand({ fill, ...item }: TimelineBandProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { TimelineEntry } from "./TimelineItem.mjs";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/timeline/TimelineBand.tsx
|
|
5
|
+
/** A span behind a row's items: a full-height `tint` or `shade` wash, or a thin wordless `strip` at the top of the
|
|
6
|
+
* row whose `popover` opens when `TimelineRoot` hit-tests its box.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <TimelineBand
|
|
11
|
+
* id="window"
|
|
12
|
+
* group="alice"
|
|
13
|
+
* start={start}
|
|
14
|
+
* end={end}
|
|
15
|
+
* state="neutral"
|
|
16
|
+
* />
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @category Charts
|
|
20
|
+
*/
|
|
21
|
+
function TimelineBand({ fill = "tint", ...item }) {
|
|
22
|
+
return /* @__PURE__ */ jsx(TimelineEntry, {
|
|
23
|
+
...item,
|
|
24
|
+
type: "background",
|
|
25
|
+
className: fill === "shade" ? "viz-band-shade" : void 0,
|
|
26
|
+
slot: "timeline-band",
|
|
27
|
+
fill
|
|
28
|
+
}, fill);
|
|
29
|
+
}
|
|
30
|
+
export { TimelineBand as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TimelineGroupProps } from "./timeline-types.mjs";
|
|
2
|
+
/** A timeline group (a row/lane). Owns its own vis-data group row and portals live `children`
|
|
3
|
+
* into a host element with no `tabIndex` of its own — a child's keyboard focus opens the row's `popover`.
|
|
4
|
+
*
|
|
5
|
+
* @category Charts
|
|
6
|
+
*/
|
|
7
|
+
export default function TimelineGroup({ id, label, order, highlighted, popover, children }: TimelineGroupProps): import("react").ReactPortal;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { hasPopoverContent } from "../popover/Popover.mjs";
|
|
3
|
+
import { useRegistryEntry, useTimelineContext } from "./timeline-context.mjs";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useEffect, useLayoutEffect, useState } from "react";
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
import { createPortal } from "react-dom";
|
|
8
|
+
// src/timeline/TimelineGroup.tsx
|
|
9
|
+
/** A timeline group (a row/lane). Owns its own vis-data group row and portals live `children`
|
|
10
|
+
* into a host element with no `tabIndex` of its own — a child's keyboard focus opens the row's `popover`.
|
|
11
|
+
*
|
|
12
|
+
* @category Charts
|
|
13
|
+
*/
|
|
14
|
+
function TimelineGroup({ id, label, order, highlighted = false, popover, children }) {
|
|
15
|
+
const { groupsWriter, groupPopovers, groupHosts, onGroupPointerEnter, onGroupPointerLeave, onGroupFocus, onGroupBlur, registerGroup } = useTimelineContext();
|
|
16
|
+
const [host] = useState(() => document.createElement("div"));
|
|
17
|
+
useRegistryEntry(groupHosts, id, host);
|
|
18
|
+
useLayoutEffect(registerGroup, [registerGroup]);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
groupsWriter.update({
|
|
21
|
+
id,
|
|
22
|
+
label,
|
|
23
|
+
order,
|
|
24
|
+
className: clsx("timeline-group", highlighted && "tf-row-highlight"),
|
|
25
|
+
content: host
|
|
26
|
+
});
|
|
27
|
+
return () => {
|
|
28
|
+
groupsWriter.remove(id);
|
|
29
|
+
};
|
|
30
|
+
}, [
|
|
31
|
+
groupsWriter,
|
|
32
|
+
id,
|
|
33
|
+
label,
|
|
34
|
+
order,
|
|
35
|
+
highlighted,
|
|
36
|
+
host
|
|
37
|
+
]);
|
|
38
|
+
useRegistryEntry(groupPopovers, id, hasPopoverContent(popover) ? popover : void 0);
|
|
39
|
+
return createPortal(/* @__PURE__ */ jsx("div", {
|
|
40
|
+
"data-slot": "timeline-group-anchor",
|
|
41
|
+
onPointerEnter: () => onGroupPointerEnter(id),
|
|
42
|
+
onPointerLeave: () => onGroupPointerLeave(id),
|
|
43
|
+
onFocus: (event) => {
|
|
44
|
+
if (event.target.matches(":focus-visible")) onGroupFocus(id);
|
|
45
|
+
},
|
|
46
|
+
onBlur: () => onGroupBlur(id),
|
|
47
|
+
children: children ?? String(id)
|
|
48
|
+
}), host);
|
|
49
|
+
}
|
|
50
|
+
export { TimelineGroup as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TimelineBandFill, TimelineItemProps, TimelineItemType } from "./timeline-types.mjs";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
type TimelineEntryProps = TimelineItemProps & {
|
|
4
|
+
/** @defaultValue "range" */
|
|
5
|
+
type?: TimelineItemType;
|
|
6
|
+
/** @defaultValue "timeline-item" */
|
|
7
|
+
slot?: "timeline-item" | "timeline-band";
|
|
8
|
+
fill?: TimelineBandFill;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function TimelineEntry({ id, group, start, end, type, variant, state, contentAlign, label, popover, className, slot, fill, statusLabel, muted, children }: TimelineEntryProps): import("react").ReactPortal;
|
|
12
|
+
/**
|
|
13
|
+
* A single timeline item. Owns its own vis-data row and portals `children` as live
|
|
14
|
+
* React into a stable element vis-timeline uses as content, so event handlers survive.
|
|
15
|
+
*
|
|
16
|
+
* @category Charts
|
|
17
|
+
*/
|
|
18
|
+
export declare const TimelineItem: (props: TimelineItemProps) => ReactNode;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { hasPopoverContent } from "../popover/Popover.mjs";
|
|
3
|
+
import { useRegistryEntry, useTimelineContext } from "./timeline-context.mjs";
|
|
4
|
+
import { getTimezonedDate } from "./timeline-utils.mjs";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
import { createPortal } from "react-dom";
|
|
8
|
+
// src/timeline/TimelineItem.tsx
|
|
9
|
+
function TimelineEntry({ id, group, start, end, type = "range", variant = "default", state, contentAlign = "sticky", label, popover, className, slot = "timeline-item", fill, statusLabel, muted = false, children }) {
|
|
10
|
+
const { itemsWriter, timeZoneOffsetSeconds, itemPopovers, itemHosts } = useTimelineContext();
|
|
11
|
+
const [host] = useState(() => {
|
|
12
|
+
const element = document.createElement("div");
|
|
13
|
+
element.dataset.slot = slot;
|
|
14
|
+
if (fill !== void 0) element.dataset.fill = fill;
|
|
15
|
+
return element;
|
|
16
|
+
});
|
|
17
|
+
useRegistryEntry(itemHosts, id, host);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
itemsWriter.update({
|
|
20
|
+
id,
|
|
21
|
+
group,
|
|
22
|
+
start: getTimezonedDate(start, timeZoneOffsetSeconds),
|
|
23
|
+
end: getTimezonedDate(end, timeZoneOffsetSeconds),
|
|
24
|
+
type,
|
|
25
|
+
variant,
|
|
26
|
+
state,
|
|
27
|
+
align: contentAlign === "sticky" ? "auto" : "left",
|
|
28
|
+
label,
|
|
29
|
+
statusLabel,
|
|
30
|
+
className: clsx(className, "timeline-item", `viz-item-${state ?? variant}`, muted && "viz-item-muted"),
|
|
31
|
+
content: host,
|
|
32
|
+
title: ""
|
|
33
|
+
});
|
|
34
|
+
return () => {
|
|
35
|
+
itemsWriter.remove(id);
|
|
36
|
+
};
|
|
37
|
+
}, [
|
|
38
|
+
itemsWriter,
|
|
39
|
+
id,
|
|
40
|
+
group,
|
|
41
|
+
start,
|
|
42
|
+
end,
|
|
43
|
+
type,
|
|
44
|
+
variant,
|
|
45
|
+
state,
|
|
46
|
+
contentAlign,
|
|
47
|
+
label,
|
|
48
|
+
statusLabel,
|
|
49
|
+
muted,
|
|
50
|
+
className,
|
|
51
|
+
host,
|
|
52
|
+
timeZoneOffsetSeconds
|
|
53
|
+
]);
|
|
54
|
+
useRegistryEntry(itemPopovers, id, hasPopoverContent(popover) ? popover : void 0);
|
|
55
|
+
return createPortal(children ?? (type === "background" ? null : String(id)), host);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A single timeline item. Owns its own vis-data row and portals `children` as live
|
|
59
|
+
* React into a stable element vis-timeline uses as content, so event handlers survive.
|
|
60
|
+
*
|
|
61
|
+
* @category Charts
|
|
62
|
+
*/
|
|
63
|
+
const TimelineItem = TimelineEntry;
|
|
64
|
+
export { TimelineEntry, TimelineItem };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.KK3ZEq_chip {
|
|
3
|
+
block-size: 2rem;
|
|
4
|
+
font-size: .75rem;
|
|
5
|
+
container-type: inline-size;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.KK3ZEq_row {
|
|
9
|
+
white-space: nowrap;
|
|
10
|
+
align-items: center;
|
|
11
|
+
gap: .3125rem;
|
|
12
|
+
block-size: 100%;
|
|
13
|
+
padding: 0 .3125rem;
|
|
14
|
+
display: flex;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.KK3ZEq_label {
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
flex: auto;
|
|
21
|
+
min-width: 0;
|
|
22
|
+
font-weight: 600;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.KK3ZEq_time {
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
font-family: var(--tf-font-mono);
|
|
29
|
+
font-variant-numeric: tabular-nums;
|
|
30
|
+
flex: none;
|
|
31
|
+
margin-left: auto;
|
|
32
|
+
font-size: .65rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.KK3ZEq_overflow {
|
|
36
|
+
border: var(--tf-border-width-1) solid
|
|
37
|
+
color-mix(in oklab, var(--tf-color-foreground) 12%, transparent);
|
|
38
|
+
font-family: var(--tf-font-mono);
|
|
39
|
+
border-radius: .1875rem;
|
|
40
|
+
flex: none;
|
|
41
|
+
padding: 0 .1875rem;
|
|
42
|
+
font-size: .59375rem;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@container (width <= 132px) {
|
|
46
|
+
.KK3ZEq_overflow {
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@container (width <= 90px) {
|
|
52
|
+
.KK3ZEq_time {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@container (width <= 62px) {
|
|
58
|
+
.KK3ZEq_row [data-slot="timeline-item-mark"][data-variant="pinned"] ~ [data-slot="timeline-item-mark"][data-variant="priority"] {
|
|
59
|
+
display: none !important;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@container (width <= 34px) {
|
|
64
|
+
.KK3ZEq_row [data-slot="timeline-item-mark"][data-variant="priority"] {
|
|
65
|
+
display: none !important;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@container (8px <= width <= 34px) {
|
|
70
|
+
.KK3ZEq_row:not(.KK3ZEq_iconOnlyRow):has([data-slot="timeline-item-mark"][data-variant="pinned"]) {
|
|
71
|
+
justify-content: center;
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.KK3ZEq_row:not(.KK3ZEq_iconOnlyRow):has([data-slot="timeline-item-mark"][data-variant="pinned"]) .KK3ZEq_label {
|
|
76
|
+
display: none;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@container (width < 8px) {
|
|
81
|
+
.KK3ZEq_row [data-slot="timeline-item-mark"][data-variant="pinned"] {
|
|
82
|
+
display: none !important;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@container (width < 62px) {
|
|
87
|
+
.KK3ZEq_row [data-slot="timeline-item-mark"][data-variant="pinned"] ~ [data-slot="timeline-item-mark"][data-variant="unreachable"] {
|
|
88
|
+
display: none !important;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@container (width < 34px) {
|
|
93
|
+
.KK3ZEq_row [data-slot="timeline-item-mark"][data-variant="unreachable"] {
|
|
94
|
+
display: none !important;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.KK3ZEq_iconOnlyRow {
|
|
99
|
+
justify-content: center;
|
|
100
|
+
padding: 0 .125rem;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.KK3ZEq_iconOnlyGlyph {
|
|
104
|
+
font-size: .875rem;
|
|
105
|
+
display: inline-flex;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@container (width < 18px) {
|
|
109
|
+
[data-slot="timeline-item-chip-icon"] {
|
|
110
|
+
display: none;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.KK3ZEq_connectorRow {
|
|
115
|
+
align-items: center;
|
|
116
|
+
block-size: 2rem;
|
|
117
|
+
padding: 0 .125rem;
|
|
118
|
+
display: flex;
|
|
119
|
+
container-type: inline-size;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.KK3ZEq_connectorBar {
|
|
123
|
+
background-color: var(--viz-timeline-item-color);
|
|
124
|
+
border-radius: 999px;
|
|
125
|
+
flex: auto;
|
|
126
|
+
justify-content: center;
|
|
127
|
+
align-items: center;
|
|
128
|
+
block-size: .75rem;
|
|
129
|
+
display: flex;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.KK3ZEq_connectorGlyph {
|
|
133
|
+
color: contrast-color(var(--viz-timeline-item-color));
|
|
134
|
+
font-size: .75rem;
|
|
135
|
+
display: inline-flex;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@supports not (color: contrast-color(red)) {
|
|
139
|
+
.KK3ZEq_connectorGlyph {
|
|
140
|
+
background: color-mix(in oklab,
|
|
141
|
+
var(--tf-color-background) 80%,
|
|
142
|
+
transparent);
|
|
143
|
+
color: var(--tf-color-foreground);
|
|
144
|
+
border-radius: 999px;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@container (width < 16px) {
|
|
149
|
+
[data-slot="timeline-item-chip-connector-icon"] {
|
|
150
|
+
display: none;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/** How a chip lays out: a `label` line, an `icon` alone, or a `connector` pill with the glyph on it. */
|
|
3
|
+
export type TimelineItemChipVariant = "label" | "icon" | "connector";
|
|
4
|
+
/** The props of `TimelineItemChip`: the label, time and leading content of an item, and its layout `variant`. */
|
|
5
|
+
export type TimelineItemChipProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
6
|
+
label: string;
|
|
7
|
+
} & ({
|
|
8
|
+
/** @defaultValue "label" */
|
|
9
|
+
variant?: "label";
|
|
10
|
+
leading?: ReactNode;
|
|
11
|
+
time?: string;
|
|
12
|
+
overflowCount?: number;
|
|
13
|
+
} | {
|
|
14
|
+
variant: "icon" | "connector";
|
|
15
|
+
leading: ReactNode;
|
|
16
|
+
time?: never;
|
|
17
|
+
overflowCount?: never;
|
|
18
|
+
});
|
|
19
|
+
/** A timeline item's content: one line that adapts to its width by container query, the glyph alone, or a
|
|
20
|
+
* connector pill for a span whose colour and shape carry its meaning. `leading` is a bare glyph.
|
|
21
|
+
* @category Charts
|
|
22
|
+
*/
|
|
23
|
+
export default function TimelineItemChip({ label, time, leading, overflowCount, variant, className, ...props }: TimelineItemChipProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import TimelineItemChip_module_default from "./TimelineItemChip.module.css.mjs";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { clsx } from "clsx";
|
|
5
|
+
// src/timeline/TimelineItemChip.tsx
|
|
6
|
+
/** A timeline item's content: one line that adapts to its width by container query, the glyph alone, or a
|
|
7
|
+
* connector pill for a span whose colour and shape carry its meaning. `leading` is a bare glyph.
|
|
8
|
+
* @category Charts
|
|
9
|
+
*/
|
|
10
|
+
function TimelineItemChip({ label, time, leading, overflowCount, variant = "label", className, ...props }) {
|
|
11
|
+
if (variant === "connector") return /* @__PURE__ */ jsxs("div", {
|
|
12
|
+
className: clsx(TimelineItemChip_module_default.connectorRow, className),
|
|
13
|
+
"data-slot": "timeline-item-chip",
|
|
14
|
+
"data-variant": variant,
|
|
15
|
+
...props,
|
|
16
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
17
|
+
className: TimelineItemChip_module_default.connectorBar,
|
|
18
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
19
|
+
className: TimelineItemChip_module_default.connectorGlyph,
|
|
20
|
+
"data-slot": "timeline-item-chip-connector-icon",
|
|
21
|
+
children: leading
|
|
22
|
+
})
|
|
23
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
24
|
+
className: "sr-only",
|
|
25
|
+
children: label
|
|
26
|
+
})]
|
|
27
|
+
});
|
|
28
|
+
const root = {
|
|
29
|
+
className: clsx(TimelineItemChip_module_default.chip, className),
|
|
30
|
+
"data-slot": "timeline-item-chip",
|
|
31
|
+
"data-variant": variant,
|
|
32
|
+
...props
|
|
33
|
+
};
|
|
34
|
+
if (variant === "icon") return /* @__PURE__ */ jsx("div", {
|
|
35
|
+
...root,
|
|
36
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
37
|
+
className: clsx(TimelineItemChip_module_default.row, TimelineItemChip_module_default.iconOnlyRow),
|
|
38
|
+
children: [leading && /* @__PURE__ */ jsx("span", {
|
|
39
|
+
className: TimelineItemChip_module_default.iconOnlyGlyph,
|
|
40
|
+
"data-slot": "timeline-item-chip-icon",
|
|
41
|
+
children: leading
|
|
42
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
43
|
+
className: "sr-only",
|
|
44
|
+
"data-slot": "timeline-item-chip-label",
|
|
45
|
+
children: label
|
|
46
|
+
})]
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
return /* @__PURE__ */ jsx("div", {
|
|
50
|
+
...root,
|
|
51
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
52
|
+
className: TimelineItemChip_module_default.row,
|
|
53
|
+
children: [
|
|
54
|
+
leading,
|
|
55
|
+
/* @__PURE__ */ jsx("span", {
|
|
56
|
+
className: TimelineItemChip_module_default.label,
|
|
57
|
+
"data-slot": "timeline-item-chip-label",
|
|
58
|
+
children: label
|
|
59
|
+
}),
|
|
60
|
+
time && /* @__PURE__ */ jsx("span", {
|
|
61
|
+
className: TimelineItemChip_module_default.time,
|
|
62
|
+
"data-slot": "timeline-item-chip-time",
|
|
63
|
+
children: time
|
|
64
|
+
}),
|
|
65
|
+
!!overflowCount && /* @__PURE__ */ jsxs("span", {
|
|
66
|
+
className: TimelineItemChip_module_default.overflow,
|
|
67
|
+
"data-slot": "timeline-item-chip-overflow",
|
|
68
|
+
children: ["+", overflowCount]
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export { TimelineItemChip as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import './TimelineItemChip.css';
|
|
2
|
+
// src/timeline/TimelineItemChip.module.css
|
|
3
|
+
var TimelineItemChip_module_default = {
|
|
4
|
+
"chip": "KK3ZEq_chip",
|
|
5
|
+
"connectorBar": "KK3ZEq_connectorBar",
|
|
6
|
+
"connectorGlyph": "KK3ZEq_connectorGlyph",
|
|
7
|
+
"connectorRow": "KK3ZEq_connectorRow",
|
|
8
|
+
"iconOnlyGlyph": "KK3ZEq_iconOnlyGlyph",
|
|
9
|
+
"iconOnlyRow": "KK3ZEq_iconOnlyRow",
|
|
10
|
+
"label": "KK3ZEq_label",
|
|
11
|
+
"overflow": "KK3ZEq_overflow",
|
|
12
|
+
"row": "KK3ZEq_row",
|
|
13
|
+
"time": "KK3ZEq_time"
|
|
14
|
+
};
|
|
15
|
+
export { TimelineItemChip_module_default as default };
|