@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,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import MenuButton from "../input/MenuButton.mjs";
|
|
3
|
+
import { useColorSchemeMenu } from "./ColorSchemeMenu.mjs";
|
|
4
|
+
import { useDemoDataMenu } from "./DemoDataPicker.mjs";
|
|
5
|
+
import AppShell_module_default from "./AppShell.module.css.mjs";
|
|
6
|
+
import { c } from "react/compiler-runtime";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { TbAppWindow, TbDatabase, TbMenu2, TbPalette } from "react-icons/tb";
|
|
9
|
+
// src/layout/OverflowMenu.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Narrow-viewport overflow: folds the page switcher, the data picker and the
|
|
12
|
+
* colour-scheme switch into a single "more" menu, each as its own submenu.
|
|
13
|
+
*/
|
|
14
|
+
function OverflowMenu(t0) {
|
|
15
|
+
const $ = c(16);
|
|
16
|
+
const { pageMenu, demo, action } = t0;
|
|
17
|
+
const colorScheme = useColorSchemeMenu();
|
|
18
|
+
const demoData = useDemoDataMenu(demo);
|
|
19
|
+
let t1;
|
|
20
|
+
if ($[0] !== pageMenu) {
|
|
21
|
+
t1 = pageMenu ? [{
|
|
22
|
+
value: "page",
|
|
23
|
+
label: "Page",
|
|
24
|
+
icon: TbAppWindow,
|
|
25
|
+
submenu: pageMenu
|
|
26
|
+
}] : [];
|
|
27
|
+
$[0] = pageMenu;
|
|
28
|
+
$[1] = t1;
|
|
29
|
+
} else t1 = $[1];
|
|
30
|
+
let t2;
|
|
31
|
+
if ($[2] !== demoData.menu) {
|
|
32
|
+
t2 = {
|
|
33
|
+
value: "demo-data",
|
|
34
|
+
label: "Demo data",
|
|
35
|
+
icon: TbDatabase,
|
|
36
|
+
submenu: demoData.menu
|
|
37
|
+
};
|
|
38
|
+
$[2] = demoData.menu;
|
|
39
|
+
$[3] = t2;
|
|
40
|
+
} else t2 = $[3];
|
|
41
|
+
let t3;
|
|
42
|
+
if ($[4] !== colorScheme) {
|
|
43
|
+
t3 = {
|
|
44
|
+
value: "theme",
|
|
45
|
+
label: "Theme",
|
|
46
|
+
icon: TbPalette,
|
|
47
|
+
submenu: colorScheme
|
|
48
|
+
};
|
|
49
|
+
$[4] = colorScheme;
|
|
50
|
+
$[5] = t3;
|
|
51
|
+
} else t3 = $[5];
|
|
52
|
+
let t4;
|
|
53
|
+
if ($[6] !== action) {
|
|
54
|
+
t4 = action ? [{
|
|
55
|
+
value: "harness-action",
|
|
56
|
+
label: action.label,
|
|
57
|
+
icon: action.icon,
|
|
58
|
+
disabled: action.disabled,
|
|
59
|
+
onSelect: action.onClick
|
|
60
|
+
}] : [];
|
|
61
|
+
$[6] = action;
|
|
62
|
+
$[7] = t4;
|
|
63
|
+
} else t4 = $[7];
|
|
64
|
+
let t5;
|
|
65
|
+
if ($[8] !== t1 || $[9] !== t2 || $[10] !== t3 || $[11] !== t4) {
|
|
66
|
+
t5 = /* @__PURE__ */ jsx(MenuButton, {
|
|
67
|
+
label: "More",
|
|
68
|
+
soloIcon: TbMenu2,
|
|
69
|
+
sections: [{ options: [
|
|
70
|
+
...t1,
|
|
71
|
+
t2,
|
|
72
|
+
t3,
|
|
73
|
+
...t4
|
|
74
|
+
] }]
|
|
75
|
+
});
|
|
76
|
+
$[8] = t1;
|
|
77
|
+
$[9] = t2;
|
|
78
|
+
$[10] = t3;
|
|
79
|
+
$[11] = t4;
|
|
80
|
+
$[12] = t5;
|
|
81
|
+
} else t5 = $[12];
|
|
82
|
+
let t6;
|
|
83
|
+
if ($[13] !== demoData.fileInput || $[14] !== t5) {
|
|
84
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
85
|
+
className: AppShell_module_default["main-nav-overflow"],
|
|
86
|
+
children: [demoData.fileInput, t5]
|
|
87
|
+
});
|
|
88
|
+
$[13] = demoData.fileInput;
|
|
89
|
+
$[14] = t5;
|
|
90
|
+
$[15] = t6;
|
|
91
|
+
} else t6 = $[15];
|
|
92
|
+
return t6;
|
|
93
|
+
}
|
|
94
|
+
export { OverflowMenu as default };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.iKG_YG_layout-sidebar {
|
|
3
|
+
gap: calc(var(--sidebar-gutter) * 2);
|
|
4
|
+
flex: auto;
|
|
5
|
+
min-height: 100%;
|
|
6
|
+
display: flex;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.iKG_YG_layout-sidebar > .iKG_YG_content {
|
|
10
|
+
flex-grow: 1;
|
|
11
|
+
min-width: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.iKG_YG_layout-sidebar aside {
|
|
15
|
+
margin: calc(var(--main-padding-y) * -1)
|
|
16
|
+
calc(var(--main-padding-x) * -1);
|
|
17
|
+
padding: 0 var(--sidebar-gutter);
|
|
18
|
+
flex-grow: 0;
|
|
19
|
+
flex-shrink: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@media (width <= 767px) {
|
|
23
|
+
.iKG_YG_layout-sidebar {
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.iKG_YG_layout-sidebar aside {
|
|
28
|
+
background: var(--tf-color-background);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.iKG_YG_layout-sidebar aside:first-child {
|
|
32
|
+
border-bottom: var(--tf-border-width-1) solid var(--tf-color-border);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.iKG_YG_layout-sidebar aside:last-child {
|
|
36
|
+
border-top: var(--tf-border-width-1) solid var(--tf-color-border);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.iKG_YG_main-sidebar {
|
|
41
|
+
--main-sidebar-width: 18rem;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
aside.iKG_YG_main-sidebar {
|
|
45
|
+
padding-block: 1em;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@media (width >= 768px) {
|
|
49
|
+
aside.iKG_YG_main-sidebar {
|
|
50
|
+
padding-block: var(--sidebar-gutter);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.iKG_YG_main-sidebar {
|
|
54
|
+
width: var(--main-sidebar-width);
|
|
55
|
+
border-right: var(--tf-border-width-1) solid var(--tf-color-border);
|
|
56
|
+
z-index: 1;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
display: flex;
|
|
59
|
+
position: relative;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.iKG_YG_layout-sidebar:has( > aside:empty) {
|
|
64
|
+
gap: 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.iKG_YG_layout-sidebar:has( > aside:empty) > aside:empty {
|
|
68
|
+
display: none;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The props of `SidebarLayout`: the attributes of its root `div` and its two columns as children. */
|
|
2
|
+
export interface SidebarLayoutProps extends React.ComponentProps<"div"> {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Layout with a sidebar and a content area.
|
|
7
|
+
*
|
|
8
|
+
* @category Layout
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <SidebarLayout>
|
|
12
|
+
* <SidebarLayoutSidebar>…</SidebarLayoutSidebar>
|
|
13
|
+
* <SidebarLayoutContent>…</SidebarLayoutContent>
|
|
14
|
+
* </SidebarLayout>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export default function SidebarLayout({ children, className, ...props }: SidebarLayoutProps): import("react").JSX.Element;
|
|
18
|
+
/** The props of `SidebarLayoutSidebar`: the attributes of its `aside`. */
|
|
19
|
+
export type SidebarLayoutSidebarProps = React.ComponentProps<"aside">;
|
|
20
|
+
/**
|
|
21
|
+
* The sidebar column of a `SidebarLayout`.
|
|
22
|
+
*
|
|
23
|
+
* @category Layout
|
|
24
|
+
*/
|
|
25
|
+
export declare function SidebarLayoutSidebar({ className, ...props }: SidebarLayoutSidebarProps): import("react").JSX.Element;
|
|
26
|
+
/** The props of `SidebarLayoutContent`: the attributes of its `div`. */
|
|
27
|
+
export type SidebarLayoutContentProps = React.ComponentProps<"div">;
|
|
28
|
+
/**
|
|
29
|
+
* The content column of a `SidebarLayout`.
|
|
30
|
+
*
|
|
31
|
+
* @category Layout
|
|
32
|
+
*/
|
|
33
|
+
export declare function SidebarLayoutContent({ className, ...props }: SidebarLayoutContentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import SidebarLayout_module_default from "./SidebarLayout.module.css.mjs";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import clsx$1 from "clsx";
|
|
5
|
+
// src/layout/SidebarLayout.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Layout with a sidebar and a content area.
|
|
8
|
+
*
|
|
9
|
+
* @category Layout
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <SidebarLayout>
|
|
13
|
+
* <SidebarLayoutSidebar>…</SidebarLayoutSidebar>
|
|
14
|
+
* <SidebarLayoutContent>…</SidebarLayoutContent>
|
|
15
|
+
* </SidebarLayout>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function SidebarLayout(t0) {
|
|
19
|
+
const $ = c(10);
|
|
20
|
+
let children;
|
|
21
|
+
let className;
|
|
22
|
+
let props;
|
|
23
|
+
if ($[0] !== t0) {
|
|
24
|
+
({children, className, ...props} = t0);
|
|
25
|
+
$[0] = t0;
|
|
26
|
+
$[1] = children;
|
|
27
|
+
$[2] = className;
|
|
28
|
+
$[3] = props;
|
|
29
|
+
} else {
|
|
30
|
+
children = $[1];
|
|
31
|
+
className = $[2];
|
|
32
|
+
props = $[3];
|
|
33
|
+
}
|
|
34
|
+
let t1;
|
|
35
|
+
if ($[4] !== className) {
|
|
36
|
+
t1 = clsx$1(SidebarLayout_module_default["layout-sidebar"], className);
|
|
37
|
+
$[4] = className;
|
|
38
|
+
$[5] = t1;
|
|
39
|
+
} else t1 = $[5];
|
|
40
|
+
let t2;
|
|
41
|
+
if ($[6] !== children || $[7] !== props || $[8] !== t1) {
|
|
42
|
+
t2 = /* @__PURE__ */ jsx("div", {
|
|
43
|
+
className: t1,
|
|
44
|
+
"data-slot": "sidebar-layout",
|
|
45
|
+
...props,
|
|
46
|
+
children
|
|
47
|
+
});
|
|
48
|
+
$[6] = children;
|
|
49
|
+
$[7] = props;
|
|
50
|
+
$[8] = t1;
|
|
51
|
+
$[9] = t2;
|
|
52
|
+
} else t2 = $[9];
|
|
53
|
+
return t2;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The sidebar column of a `SidebarLayout`.
|
|
57
|
+
*
|
|
58
|
+
* @category Layout
|
|
59
|
+
*/
|
|
60
|
+
function SidebarLayoutSidebar(t0) {
|
|
61
|
+
const $ = c(8);
|
|
62
|
+
let className;
|
|
63
|
+
let props;
|
|
64
|
+
if ($[0] !== t0) {
|
|
65
|
+
({className, ...props} = t0);
|
|
66
|
+
$[0] = t0;
|
|
67
|
+
$[1] = className;
|
|
68
|
+
$[2] = props;
|
|
69
|
+
} else {
|
|
70
|
+
className = $[1];
|
|
71
|
+
props = $[2];
|
|
72
|
+
}
|
|
73
|
+
let t1;
|
|
74
|
+
if ($[3] !== className) {
|
|
75
|
+
t1 = clsx$1(SidebarLayout_module_default["main-sidebar"], className);
|
|
76
|
+
$[3] = className;
|
|
77
|
+
$[4] = t1;
|
|
78
|
+
} else t1 = $[4];
|
|
79
|
+
let t2;
|
|
80
|
+
if ($[5] !== props || $[6] !== t1) {
|
|
81
|
+
t2 = /* @__PURE__ */ jsx("aside", {
|
|
82
|
+
className: t1,
|
|
83
|
+
"data-slot": "sidebar-layout-sidebar",
|
|
84
|
+
...props
|
|
85
|
+
});
|
|
86
|
+
$[5] = props;
|
|
87
|
+
$[6] = t1;
|
|
88
|
+
$[7] = t2;
|
|
89
|
+
} else t2 = $[7];
|
|
90
|
+
return t2;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The content column of a `SidebarLayout`.
|
|
94
|
+
*
|
|
95
|
+
* @category Layout
|
|
96
|
+
*/
|
|
97
|
+
function SidebarLayoutContent(t0) {
|
|
98
|
+
const $ = c(8);
|
|
99
|
+
let className;
|
|
100
|
+
let props;
|
|
101
|
+
if ($[0] !== t0) {
|
|
102
|
+
({className, ...props} = t0);
|
|
103
|
+
$[0] = t0;
|
|
104
|
+
$[1] = className;
|
|
105
|
+
$[2] = props;
|
|
106
|
+
} else {
|
|
107
|
+
className = $[1];
|
|
108
|
+
props = $[2];
|
|
109
|
+
}
|
|
110
|
+
let t1;
|
|
111
|
+
if ($[3] !== className) {
|
|
112
|
+
t1 = clsx$1(SidebarLayout_module_default.content, className);
|
|
113
|
+
$[3] = className;
|
|
114
|
+
$[4] = t1;
|
|
115
|
+
} else t1 = $[4];
|
|
116
|
+
let t2;
|
|
117
|
+
if ($[5] !== props || $[6] !== t1) {
|
|
118
|
+
t2 = /* @__PURE__ */ jsx("div", {
|
|
119
|
+
className: t1,
|
|
120
|
+
"data-slot": "sidebar-layout-content",
|
|
121
|
+
...props
|
|
122
|
+
});
|
|
123
|
+
$[5] = props;
|
|
124
|
+
$[6] = t1;
|
|
125
|
+
$[7] = t2;
|
|
126
|
+
} else t2 = $[7];
|
|
127
|
+
return t2;
|
|
128
|
+
}
|
|
129
|
+
export { SidebarLayoutContent, SidebarLayoutSidebar, SidebarLayout as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './SidebarLayout.css';
|
|
2
|
+
// src/layout/SidebarLayout.module.css
|
|
3
|
+
var SidebarLayout_module_default = {
|
|
4
|
+
"content": "iKG_YG_content",
|
|
5
|
+
"layout-sidebar": "iKG_YG_layout-sidebar",
|
|
6
|
+
"main-sidebar": "iKG_YG_main-sidebar"
|
|
7
|
+
};
|
|
8
|
+
export { SidebarLayout_module_default as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** What {@link useDateScopeDay} returns: the selected day and the functions that change it. */
|
|
2
|
+
export interface UseDateScopeDayResult {
|
|
3
|
+
/** @remarks `yyyy-MM-dd`, or `null` before the planning window is known. */
|
|
4
|
+
day: string | null;
|
|
5
|
+
/** @remarks Clamped to the planning window; a no-op while the window isn't known yet. */
|
|
6
|
+
setDay: (day: string) => void;
|
|
7
|
+
/** @remarks Keeps the current day when the opening day moves, as `setDay` does; for a reader who pans a view. */
|
|
8
|
+
stopFollowing: () => void;
|
|
9
|
+
}
|
|
10
|
+
/** Options for {@link useDateScopeDay}. */
|
|
11
|
+
export interface UseDateScopeDayOptions {
|
|
12
|
+
/** @remarks `yyyy-MM-dd`; the day follows it until a day is set. Defaults to the window's first day. */
|
|
13
|
+
openingDay?: string;
|
|
14
|
+
/** @remarks A new value (a new dataset) makes the day follow `openingDay` again. */
|
|
15
|
+
resetKey?: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A single selected calendar day, clamped to a planning window and shared by
|
|
19
|
+
* every view that scopes itself to "one day of the plan".
|
|
20
|
+
*
|
|
21
|
+
* @remarks `windowStart`/`windowEnd` are ISO-8601 offset date-times; the returned day is a plain `yyyy-MM-dd`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useDateScopeDay(windowStart: string | undefined, windowEnd: string | undefined, { openingDay, resetKey }?: UseDateScopeDayOptions): UseDateScopeDayResult;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useFollowedState } from "./use-followed-state.mjs";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import "react";
|
|
5
|
+
import { isoLocalDate } from "@timefoldai/viz-core";
|
|
6
|
+
// src/layout/use-date-scope-day.ts
|
|
7
|
+
function clamp(day, min, max) {
|
|
8
|
+
if (day < min) return min;
|
|
9
|
+
if (day > max) return max;
|
|
10
|
+
return day;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A single selected calendar day, clamped to a planning window and shared by
|
|
14
|
+
* every view that scopes itself to "one day of the plan".
|
|
15
|
+
*
|
|
16
|
+
* @remarks `windowStart`/`windowEnd` are ISO-8601 offset date-times; the returned day is a plain `yyyy-MM-dd`.
|
|
17
|
+
*/
|
|
18
|
+
function useDateScopeDay(windowStart, windowEnd, t0) {
|
|
19
|
+
const $ = c(12);
|
|
20
|
+
let t1;
|
|
21
|
+
if ($[0] !== t0) {
|
|
22
|
+
t1 = t0 === void 0 ? {} : t0;
|
|
23
|
+
$[0] = t0;
|
|
24
|
+
$[1] = t1;
|
|
25
|
+
} else t1 = $[1];
|
|
26
|
+
const { openingDay, resetKey } = t1;
|
|
27
|
+
let t2;
|
|
28
|
+
if ($[2] !== windowStart) {
|
|
29
|
+
t2 = windowStart ? isoLocalDate(windowStart) : void 0;
|
|
30
|
+
$[2] = windowStart;
|
|
31
|
+
$[3] = t2;
|
|
32
|
+
} else t2 = $[3];
|
|
33
|
+
const min = t2;
|
|
34
|
+
const max = windowEnd ? isoLocalDate(windowEnd) : void 0;
|
|
35
|
+
const [followed, setFollowed, stopFollowing] = useFollowedState(openingDay ?? min, resetKey);
|
|
36
|
+
const day = followed === void 0 || min === void 0 || max === void 0 ? followed ?? null : clamp(followed, min, max);
|
|
37
|
+
let t3;
|
|
38
|
+
if ($[4] !== max || $[5] !== min || $[6] !== setFollowed) {
|
|
39
|
+
t3 = (next) => {
|
|
40
|
+
if (min === void 0 || max === void 0) return;
|
|
41
|
+
setFollowed(clamp(next, min, max));
|
|
42
|
+
};
|
|
43
|
+
$[4] = max;
|
|
44
|
+
$[5] = min;
|
|
45
|
+
$[6] = setFollowed;
|
|
46
|
+
$[7] = t3;
|
|
47
|
+
} else t3 = $[7];
|
|
48
|
+
const setDay = t3;
|
|
49
|
+
let t4;
|
|
50
|
+
if ($[8] !== day || $[9] !== setDay || $[10] !== stopFollowing) {
|
|
51
|
+
t4 = {
|
|
52
|
+
day,
|
|
53
|
+
setDay,
|
|
54
|
+
stopFollowing
|
|
55
|
+
};
|
|
56
|
+
$[8] = day;
|
|
57
|
+
$[9] = setDay;
|
|
58
|
+
$[10] = stopFollowing;
|
|
59
|
+
$[11] = t4;
|
|
60
|
+
} else t4 = $[11];
|
|
61
|
+
return t4;
|
|
62
|
+
}
|
|
63
|
+
export { useDateScopeDay };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The height that lets `element` reach the bottom of `available` pixels, after the content above and below it.
|
|
3
|
+
* Measured from the content, never from a min-height's slack, so a page taller than its content still fills.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useFillHeight(element: HTMLElement | null, available: number | undefined, { exclude }?: {
|
|
6
|
+
exclude?: Element | null;
|
|
7
|
+
}): number | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLayoutEffect, useState } from "react";
|
|
3
|
+
// src/layout/use-fill-height.ts
|
|
4
|
+
function pixels(value) {
|
|
5
|
+
return Number.parseFloat(value) || 0;
|
|
6
|
+
}
|
|
7
|
+
function isInFlow(element) {
|
|
8
|
+
const { position } = getComputedStyle(element);
|
|
9
|
+
return position !== "absolute" && position !== "fixed";
|
|
10
|
+
}
|
|
11
|
+
function contentBelow(node, parent, exclude) {
|
|
12
|
+
const nodeBottom = node.getBoundingClientRect().bottom;
|
|
13
|
+
let lowestEdge = nodeBottom + pixels(getComputedStyle(node).marginBottom);
|
|
14
|
+
for (let sibling = node.nextElementSibling; sibling; sibling = sibling.nextElementSibling) {
|
|
15
|
+
const rect = sibling.getBoundingClientRect();
|
|
16
|
+
if (sibling === exclude || !isInFlow(sibling) || rect.top < nodeBottom) continue;
|
|
17
|
+
lowestEdge = Math.max(lowestEdge, rect.bottom + pixels(getComputedStyle(sibling).marginBottom));
|
|
18
|
+
}
|
|
19
|
+
const parentStyle = getComputedStyle(parent);
|
|
20
|
+
return lowestEdge - nodeBottom + pixels(parentStyle.paddingBottom) + pixels(parentStyle.borderBottomWidth);
|
|
21
|
+
}
|
|
22
|
+
function spaceBelow(element, exclude) {
|
|
23
|
+
let space = 0;
|
|
24
|
+
for (let node = element; node.parentElement && node !== document.body; node = node.parentElement) space += contentBelow(node, node.parentElement, exclude);
|
|
25
|
+
return space;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The height that lets `element` reach the bottom of `available` pixels, after the content above and below it.
|
|
29
|
+
* Measured from the content, never from a min-height's slack, so a page taller than its content still fills.
|
|
30
|
+
*/
|
|
31
|
+
function useFillHeight(element, available, { exclude = null } = {}) {
|
|
32
|
+
const [height, setHeight] = useState();
|
|
33
|
+
useLayoutEffect(() => {
|
|
34
|
+
if (!element || available === void 0) return;
|
|
35
|
+
const measure = () => {
|
|
36
|
+
const top = element.getBoundingClientRect().top + window.scrollY;
|
|
37
|
+
setHeight(Math.max(0, Math.floor(available - top - spaceBelow(element, exclude))));
|
|
38
|
+
};
|
|
39
|
+
const observer = new ResizeObserver(measure);
|
|
40
|
+
measure();
|
|
41
|
+
for (let node = element.parentElement; node; node = node.parentElement) observer.observe(node);
|
|
42
|
+
return () => observer.disconnect();
|
|
43
|
+
}, [
|
|
44
|
+
element,
|
|
45
|
+
available,
|
|
46
|
+
exclude
|
|
47
|
+
]);
|
|
48
|
+
return element && available !== void 0 ? height : void 0;
|
|
49
|
+
}
|
|
50
|
+
export { useFillHeight };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State that follows `opening` until it is set or told to stop following, such as a date scope that opens on the
|
|
3
|
+
* first planned day. A new `resetKey` (a new dataset) makes it follow `opening` again.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useFollowedState<T>(opening: T, resetKey: unknown): readonly [T, (value: T) => void, () => void];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
// src/layout/use-followed-state.ts
|
|
5
|
+
/**
|
|
6
|
+
* State that follows `opening` until it is set or told to stop following, such as a date scope that opens on the
|
|
7
|
+
* first planned day. A new `resetKey` (a new dataset) makes it follow `opening` again.
|
|
8
|
+
*/
|
|
9
|
+
function useFollowedState(opening, resetKey) {
|
|
10
|
+
const $ = c(9);
|
|
11
|
+
let t0;
|
|
12
|
+
if ($[0] !== opening || $[1] !== resetKey) {
|
|
13
|
+
t0 = {
|
|
14
|
+
value: opening,
|
|
15
|
+
follows: true,
|
|
16
|
+
resetKey
|
|
17
|
+
};
|
|
18
|
+
$[0] = opening;
|
|
19
|
+
$[1] = resetKey;
|
|
20
|
+
$[2] = t0;
|
|
21
|
+
} else t0 = $[2];
|
|
22
|
+
const [state, setState] = useState(t0);
|
|
23
|
+
let t1;
|
|
24
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
25
|
+
t1 = (value) => setState((current) => ({
|
|
26
|
+
...current,
|
|
27
|
+
value,
|
|
28
|
+
follows: false
|
|
29
|
+
}));
|
|
30
|
+
$[3] = t1;
|
|
31
|
+
} else t1 = $[3];
|
|
32
|
+
const set = t1;
|
|
33
|
+
let t2;
|
|
34
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
35
|
+
t2 = () => setState(_temp);
|
|
36
|
+
$[4] = t2;
|
|
37
|
+
} else t2 = $[4];
|
|
38
|
+
const stopFollowing = t2;
|
|
39
|
+
if (state.resetKey !== resetKey || state.follows && !Object.is(state.value, opening)) {
|
|
40
|
+
setState({
|
|
41
|
+
value: opening,
|
|
42
|
+
follows: true,
|
|
43
|
+
resetKey
|
|
44
|
+
});
|
|
45
|
+
let t3;
|
|
46
|
+
if ($[5] !== opening) {
|
|
47
|
+
t3 = [
|
|
48
|
+
opening,
|
|
49
|
+
set,
|
|
50
|
+
stopFollowing
|
|
51
|
+
];
|
|
52
|
+
$[5] = opening;
|
|
53
|
+
$[6] = t3;
|
|
54
|
+
} else t3 = $[6];
|
|
55
|
+
return t3;
|
|
56
|
+
}
|
|
57
|
+
let t3;
|
|
58
|
+
if ($[7] !== state.value) {
|
|
59
|
+
t3 = [
|
|
60
|
+
state.value,
|
|
61
|
+
set,
|
|
62
|
+
stopFollowing
|
|
63
|
+
];
|
|
64
|
+
$[7] = state.value;
|
|
65
|
+
$[8] = t3;
|
|
66
|
+
} else t3 = $[8];
|
|
67
|
+
return t3;
|
|
68
|
+
}
|
|
69
|
+
function _temp(current_0) {
|
|
70
|
+
return current_0.follows ? {
|
|
71
|
+
...current_0,
|
|
72
|
+
follows: false
|
|
73
|
+
} : current_0;
|
|
74
|
+
}
|
|
75
|
+
export { useFollowedState };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single, URL-addressable source of truth for the active top-level view.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* `navigate`'s `{ replace: true }` is for platform-driven tab clicks: it replaces the current history entry
|
|
6
|
+
* instead of pushing a new one, since the embed shares session history with the platform page.
|
|
7
|
+
*/
|
|
8
|
+
export declare function usePageRoute(defaultPage: string): [string, (page: string, options?: {
|
|
9
|
+
replace?: boolean;
|
|
10
|
+
}) => void];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
// src/layout/use-page-route.ts
|
|
5
|
+
function readPageFromUrl() {
|
|
6
|
+
return new URLSearchParams(window.location.search).get("page");
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Single, URL-addressable source of truth for the active top-level view.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* `navigate`'s `{ replace: true }` is for platform-driven tab clicks: it replaces the current history entry
|
|
13
|
+
* instead of pushing a new one, since the embed shares session history with the platform page.
|
|
14
|
+
*/
|
|
15
|
+
function usePageRoute(defaultPage) {
|
|
16
|
+
const $ = c(8);
|
|
17
|
+
let t0;
|
|
18
|
+
if ($[0] !== defaultPage) {
|
|
19
|
+
t0 = () => readPageFromUrl() ?? defaultPage;
|
|
20
|
+
$[0] = defaultPage;
|
|
21
|
+
$[1] = t0;
|
|
22
|
+
} else t0 = $[1];
|
|
23
|
+
const [page, setPage] = useState(t0);
|
|
24
|
+
let t1;
|
|
25
|
+
let t2;
|
|
26
|
+
if ($[2] !== defaultPage) {
|
|
27
|
+
t1 = () => {
|
|
28
|
+
const onPopState = () => setPage(readPageFromUrl() ?? defaultPage);
|
|
29
|
+
window.addEventListener("popstate", onPopState);
|
|
30
|
+
return () => window.removeEventListener("popstate", onPopState);
|
|
31
|
+
};
|
|
32
|
+
t2 = [defaultPage];
|
|
33
|
+
$[2] = defaultPage;
|
|
34
|
+
$[3] = t1;
|
|
35
|
+
$[4] = t2;
|
|
36
|
+
} else {
|
|
37
|
+
t1 = $[3];
|
|
38
|
+
t2 = $[4];
|
|
39
|
+
}
|
|
40
|
+
useEffect(t1, t2);
|
|
41
|
+
let t3;
|
|
42
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
43
|
+
t3 = (nextPage, options) => {
|
|
44
|
+
setPage(nextPage);
|
|
45
|
+
const params = new URLSearchParams(window.location.search);
|
|
46
|
+
if (params.get("page") === nextPage) return;
|
|
47
|
+
params.set("page", nextPage);
|
|
48
|
+
params.delete("apiKey");
|
|
49
|
+
const query = params.toString();
|
|
50
|
+
const url = `${window.location.pathname}${query ? `?${query}` : ""}${window.location.hash}`;
|
|
51
|
+
if (options?.replace) window.history.replaceState(window.history.state, "", url);
|
|
52
|
+
else window.history.pushState(window.history.state, "", url);
|
|
53
|
+
};
|
|
54
|
+
$[5] = t3;
|
|
55
|
+
} else t3 = $[5];
|
|
56
|
+
const navigate = t3;
|
|
57
|
+
let t4;
|
|
58
|
+
if ($[6] !== page) {
|
|
59
|
+
t4 = [page, navigate];
|
|
60
|
+
$[6] = page;
|
|
61
|
+
$[7] = t4;
|
|
62
|
+
} else t4 = $[7];
|
|
63
|
+
return t4;
|
|
64
|
+
}
|
|
65
|
+
export { usePageRoute };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { IntervalStripFill } from "../interval-strip/IntervalStrip.mjs";
|
|
2
|
+
import { LegendSwatch } from "../swatch/legend-swatch.mjs";
|
|
3
|
+
import { TimelineItemTint } from "../timeline/timeline-types.mjs";
|
|
4
|
+
/** The {@link LegendSwatch} values a timeline mark can take. */
|
|
5
|
+
export type TimelineLegendSwatch = Exclude<LegendSwatch, "fill">;
|
|
6
|
+
/** An entry of a timeline legend: its label, swatch and variant. */
|
|
7
|
+
export type TimelineLegendEntry = TimelineItemTint & {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
swatch?: TimelineLegendSwatch;
|
|
11
|
+
};
|
|
12
|
+
/** The {@link LegendSwatch} values an interval strip mark can take: a segment's `fill`, or the `hatch` of a gap. */
|
|
13
|
+
export type IntervalStripLegendSwatch = Extract<LegendSwatch, "fill" | "hatch">;
|
|
14
|
+
/** An entry of an interval strip legend: its label, its fill and its swatch shape. */
|
|
15
|
+
export type IntervalStripLegendEntry = {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
} & ((IntervalStripFill & {
|
|
19
|
+
/** @defaultValue "fill" */
|
|
20
|
+
swatch?: "fill";
|
|
21
|
+
}) | {
|
|
22
|
+
swatch: "hatch";
|
|
23
|
+
state?: never;
|
|
24
|
+
variant?: never;
|
|
25
|
+
});
|
|
26
|
+
/** The props of `Legend`: the chart whose marks it keys, and its entries. */
|
|
27
|
+
export type LegendProps = Pick<React.ComponentProps<"ul">, "className" | "style" | "ref"> & {
|
|
28
|
+
"aria-label"?: string;
|
|
29
|
+
} & ({
|
|
30
|
+
variant: "timeline";
|
|
31
|
+
entries: TimelineLegendEntry[];
|
|
32
|
+
} | {
|
|
33
|
+
variant: "interval-strip";
|
|
34
|
+
entries: IntervalStripLegendEntry[];
|
|
35
|
+
});
|
|
36
|
+
/** The chart whose marks a `Legend` keys. */
|
|
37
|
+
export type LegendVariant = LegendProps["variant"];
|
|
38
|
+
/** An always-visible key for a chart's wordless marks: a timeline's band fills, or an interval strip's segment
|
|
39
|
+
* fills and gaps. A strip band's colour must read before the pointer finds it.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <Legend
|
|
44
|
+
* variant="timeline"
|
|
45
|
+
* entries={[
|
|
46
|
+
* { id: "preferred", label: "Preferred", state: "positive" },
|
|
47
|
+
* { id: "overlap", label: "Overlap", swatch: "hatch", state: "negative" },
|
|
48
|
+
* ]}
|
|
49
|
+
* />
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @category Charts
|
|
53
|
+
*/
|
|
54
|
+
export default function Legend(props: LegendProps): import("react").JSX.Element;
|