@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,63 @@
|
|
|
1
|
+
import { PopoverDataGrid, PopoverDataGridItem } from "./Popover.mjs";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/popover/PopoverFacts.tsx
|
|
5
|
+
const STATE_TEXT = {
|
|
6
|
+
positive: "var(--viz-text-success)",
|
|
7
|
+
negative: "var(--viz-text-alert)"
|
|
8
|
+
};
|
|
9
|
+
/** A fact's value as a card draws it, tinted by its `state` when it has one. */
|
|
10
|
+
function popoverFactValue({ value, state }) {
|
|
11
|
+
return state ? /* @__PURE__ */ jsx("span", {
|
|
12
|
+
"data-state": state,
|
|
13
|
+
style: { color: STATE_TEXT[state] },
|
|
14
|
+
children: value
|
|
15
|
+
}) : value;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A popover's facts as label/value rows, a value tinted by its `state`.
|
|
19
|
+
*
|
|
20
|
+
* @category Overlays
|
|
21
|
+
*/
|
|
22
|
+
function PopoverFactsGrid(t0) {
|
|
23
|
+
const $ = c(8);
|
|
24
|
+
let facts;
|
|
25
|
+
let grid;
|
|
26
|
+
if ($[0] !== t0) {
|
|
27
|
+
({facts, ...grid} = t0);
|
|
28
|
+
$[0] = t0;
|
|
29
|
+
$[1] = facts;
|
|
30
|
+
$[2] = grid;
|
|
31
|
+
} else {
|
|
32
|
+
facts = $[1];
|
|
33
|
+
grid = $[2];
|
|
34
|
+
}
|
|
35
|
+
let t1;
|
|
36
|
+
if ($[3] !== facts) {
|
|
37
|
+
t1 = facts.map(_temp);
|
|
38
|
+
$[3] = facts;
|
|
39
|
+
$[4] = t1;
|
|
40
|
+
} else t1 = $[4];
|
|
41
|
+
let t2;
|
|
42
|
+
if ($[5] !== grid || $[6] !== t1) {
|
|
43
|
+
t2 = /* @__PURE__ */ jsx(PopoverDataGrid, {
|
|
44
|
+
...grid,
|
|
45
|
+
children: t1
|
|
46
|
+
});
|
|
47
|
+
$[5] = grid;
|
|
48
|
+
$[6] = t1;
|
|
49
|
+
$[7] = t2;
|
|
50
|
+
} else t2 = $[7];
|
|
51
|
+
return t2;
|
|
52
|
+
}
|
|
53
|
+
/** The facts as one line of text: `Label: value; Label: value`, so a value may itself hold a comma. */
|
|
54
|
+
function _temp(fact) {
|
|
55
|
+
return /* @__PURE__ */ jsx(PopoverDataGridItem, {
|
|
56
|
+
label: fact.label,
|
|
57
|
+
value: popoverFactValue(fact)
|
|
58
|
+
}, fact.label);
|
|
59
|
+
}
|
|
60
|
+
function popoverFactsText(facts) {
|
|
61
|
+
return facts.map(({ label, value }) => `${label}: ${value}`).join("; ");
|
|
62
|
+
}
|
|
63
|
+
export { PopoverFactsGrid, popoverFactValue, popoverFactsText };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The props of `Readout`, the props of a `span`. */
|
|
2
|
+
export interface ReadoutProps extends React.ComponentProps<"span"> {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* An inert chip showing a value the reader cannot change — a timezone offset, a
|
|
7
|
+
* scroll instruction — in a row that also holds controls.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* A `<span>`, not a disabled button, with the design-system control height and radius so it lines up with
|
|
11
|
+
* the `Button`s in its row.
|
|
12
|
+
*
|
|
13
|
+
* @category Data display
|
|
14
|
+
*/
|
|
15
|
+
export default function Readout({ children, className, ...props }: ReadoutProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import clsx$1 from "clsx";
|
|
5
|
+
// src/readout/Readout.tsx
|
|
6
|
+
/**
|
|
7
|
+
* An inert chip showing a value the reader cannot change — a timezone offset, a
|
|
8
|
+
* scroll instruction — in a row that also holds controls.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* A `<span>`, not a disabled button, with the design-system control height and radius so it lines up with
|
|
12
|
+
* the `Button`s in its row.
|
|
13
|
+
*
|
|
14
|
+
* @category Data display
|
|
15
|
+
*/
|
|
16
|
+
function Readout(t0) {
|
|
17
|
+
const $ = c(10);
|
|
18
|
+
let children;
|
|
19
|
+
let className;
|
|
20
|
+
let props;
|
|
21
|
+
if ($[0] !== t0) {
|
|
22
|
+
({children, className, ...props} = t0);
|
|
23
|
+
$[0] = t0;
|
|
24
|
+
$[1] = children;
|
|
25
|
+
$[2] = className;
|
|
26
|
+
$[3] = props;
|
|
27
|
+
} else {
|
|
28
|
+
children = $[1];
|
|
29
|
+
className = $[2];
|
|
30
|
+
props = $[3];
|
|
31
|
+
}
|
|
32
|
+
let t1;
|
|
33
|
+
if ($[4] !== className) {
|
|
34
|
+
t1 = clsx$1("text-viz-readout-foreground bg-viz-tint inline-flex h-(--tf-control-height) items-center rounded-lg px-3 text-[0.8125rem] font-medium whitespace-nowrap", className);
|
|
35
|
+
$[4] = className;
|
|
36
|
+
$[5] = t1;
|
|
37
|
+
} else t1 = $[5];
|
|
38
|
+
let t2;
|
|
39
|
+
if ($[6] !== children || $[7] !== props || $[8] !== t1) {
|
|
40
|
+
t2 = /* @__PURE__ */ jsx("span", {
|
|
41
|
+
"data-slot": "readout",
|
|
42
|
+
className: t1,
|
|
43
|
+
...props,
|
|
44
|
+
children
|
|
45
|
+
});
|
|
46
|
+
$[6] = children;
|
|
47
|
+
$[7] = props;
|
|
48
|
+
$[8] = t1;
|
|
49
|
+
$[9] = t2;
|
|
50
|
+
} else t2 = $[9];
|
|
51
|
+
return t2;
|
|
52
|
+
}
|
|
53
|
+
export { Readout as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The props of `TimeZoneReadout`: the time zone it shows. */
|
|
2
|
+
export interface TimeZoneReadoutProps {
|
|
3
|
+
offsetSeconds: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The dataset's UTC offset as a readout, with a hint that the page shows every time at it.
|
|
7
|
+
*
|
|
8
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
|
|
9
|
+
* @category Data display
|
|
10
|
+
*/
|
|
11
|
+
export default function TimeZoneReadout({ offsetSeconds }: TimeZoneReadoutProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { formatTimeZoneOffset } from "../timeline/timeline-utils.mjs";
|
|
3
|
+
import Tooltip from "../tooltip/Tooltip.mjs";
|
|
4
|
+
import Readout from "./Readout.mjs";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/readout/TimeZoneReadout.tsx
|
|
8
|
+
const TIME_ZONE_HINT = "This page shows every time at the dataset's UTC offset.";
|
|
9
|
+
/**
|
|
10
|
+
* The dataset's UTC offset as a readout, with a hint that the page shows every time at it.
|
|
11
|
+
*
|
|
12
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
|
|
13
|
+
* @category Data display
|
|
14
|
+
*/
|
|
15
|
+
function TimeZoneReadout(t0) {
|
|
16
|
+
const $ = c(5);
|
|
17
|
+
const { offsetSeconds } = t0;
|
|
18
|
+
let t1;
|
|
19
|
+
if ($[0] !== offsetSeconds) {
|
|
20
|
+
t1 = formatTimeZoneOffset(offsetSeconds);
|
|
21
|
+
$[0] = offsetSeconds;
|
|
22
|
+
$[1] = t1;
|
|
23
|
+
} else t1 = $[1];
|
|
24
|
+
let t2;
|
|
25
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
26
|
+
t2 = /* @__PURE__ */ jsxs("span", {
|
|
27
|
+
className: "sr-only",
|
|
28
|
+
children: [" ", TIME_ZONE_HINT]
|
|
29
|
+
});
|
|
30
|
+
$[2] = t2;
|
|
31
|
+
} else t2 = $[2];
|
|
32
|
+
let t3;
|
|
33
|
+
if ($[3] !== t1) {
|
|
34
|
+
t3 = /* @__PURE__ */ jsx(Tooltip, {
|
|
35
|
+
label: TIME_ZONE_HINT,
|
|
36
|
+
children: /* @__PURE__ */ jsxs(Readout, {
|
|
37
|
+
tabIndex: 0,
|
|
38
|
+
children: [t1, t2]
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
$[3] = t1;
|
|
42
|
+
$[4] = t3;
|
|
43
|
+
} else t3 = $[4];
|
|
44
|
+
return t3;
|
|
45
|
+
}
|
|
46
|
+
export { TimeZoneReadout as default };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
._6QhLGG_score-box {
|
|
3
|
+
font-family: var(--tf-font-mono);
|
|
4
|
+
white-space: nowrap;
|
|
5
|
+
align-items: center;
|
|
6
|
+
gap: .75rem;
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
._6QhLGG_score-box-title {
|
|
11
|
+
font-family: var(--tf-font-sans);
|
|
12
|
+
letter-spacing: .06em;
|
|
13
|
+
text-transform: uppercase;
|
|
14
|
+
color: var(--viz-text-muted);
|
|
15
|
+
font-size: .75rem;
|
|
16
|
+
font-weight: 700;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
._6QhLGG_score-box-item {
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: .4rem;
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
._6QhLGG_score-box-item + ._6QhLGG_score-box-item {
|
|
26
|
+
border-left: var(--tf-border-width-1) solid var(--tf-color-border);
|
|
27
|
+
padding-left: .75rem;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
._6QhLGG_score-box-item._6QhLGG_hard ._6QhLGG_score-box-dot {
|
|
31
|
+
background: var(--viz-score-hard);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
._6QhLGG_score-box-item._6QhLGG_medium ._6QhLGG_score-box-dot {
|
|
35
|
+
background: var(--viz-score-medium);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
._6QhLGG_score-box-item._6QhLGG_soft ._6QhLGG_score-box-dot {
|
|
39
|
+
background: var(--viz-score-soft);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
._6QhLGG_score-box-item._6QhLGG_simple ._6QhLGG_score-box-value {
|
|
43
|
+
color: var(--tf-color-foreground);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
._6QhLGG_score-box-dot {
|
|
47
|
+
border-radius: 50%;
|
|
48
|
+
flex: none;
|
|
49
|
+
width: .5rem;
|
|
50
|
+
height: .5rem;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
._6QhLGG_score-box-value {
|
|
54
|
+
font-variant-numeric: tabular-nums;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
._6QhLGG_score-box-label {
|
|
59
|
+
font-family: var(--tf-font-sans);
|
|
60
|
+
color: var(--viz-text-muted);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The props of `ScoreBox`: the score string it shows. */
|
|
2
|
+
export interface ScoreBoxProps extends Omit<React.ComponentProps<"div">, "children"> {
|
|
3
|
+
score?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Compact score readout: each parsed score level with a severity dot. A level too long to
|
|
7
|
+
* fit shortens to a rounded rung, with the exact value in a tooltip.
|
|
8
|
+
*
|
|
9
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
|
|
10
|
+
* @category Data display
|
|
11
|
+
*/
|
|
12
|
+
export default function ScoreBox({ score, className, ...props }: ScoreBoxProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import Tooltip from "../tooltip/Tooltip.mjs";
|
|
2
|
+
import ScoreBox_module_default from "./ScoreBox.module.css.mjs";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import clsx$1 from "clsx";
|
|
6
|
+
import { formatCompactNumber, parseScore } from "@timefoldai/viz-core";
|
|
7
|
+
// src/score-box/ScoreBox.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Compact score readout: each parsed score level with a severity dot. A level too long to
|
|
10
|
+
* fit shortens to a rounded rung, with the exact value in a tooltip.
|
|
11
|
+
*
|
|
12
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
|
|
13
|
+
* @category Data display
|
|
14
|
+
*/
|
|
15
|
+
function ScoreBox(t0) {
|
|
16
|
+
const $ = c(11);
|
|
17
|
+
let className;
|
|
18
|
+
let props;
|
|
19
|
+
let score;
|
|
20
|
+
if ($[0] !== t0) {
|
|
21
|
+
({score, className, ...props} = t0);
|
|
22
|
+
$[0] = t0;
|
|
23
|
+
$[1] = className;
|
|
24
|
+
$[2] = props;
|
|
25
|
+
$[3] = score;
|
|
26
|
+
} else {
|
|
27
|
+
className = $[1];
|
|
28
|
+
props = $[2];
|
|
29
|
+
score = $[3];
|
|
30
|
+
}
|
|
31
|
+
let t1;
|
|
32
|
+
if ($[4] !== className || $[5] !== props || $[6] !== score) {
|
|
33
|
+
const { levels } = parseScore(score);
|
|
34
|
+
let t2;
|
|
35
|
+
if ($[8] !== className) {
|
|
36
|
+
t2 = clsx$1(ScoreBox_module_default["score-box"], className);
|
|
37
|
+
$[8] = className;
|
|
38
|
+
$[9] = t2;
|
|
39
|
+
} else t2 = $[9];
|
|
40
|
+
let t3;
|
|
41
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
42
|
+
t3 = /* @__PURE__ */ jsx("span", {
|
|
43
|
+
className: ScoreBox_module_default["score-box-title"],
|
|
44
|
+
"data-slot": "score-box-title",
|
|
45
|
+
children: "Score"
|
|
46
|
+
});
|
|
47
|
+
$[10] = t3;
|
|
48
|
+
} else t3 = $[10];
|
|
49
|
+
t1 = /* @__PURE__ */ jsxs("div", {
|
|
50
|
+
className: t2,
|
|
51
|
+
"data-slot": "score-box",
|
|
52
|
+
...props,
|
|
53
|
+
children: [t3, levels.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
54
|
+
className: ScoreBox_module_default["score-box-item"],
|
|
55
|
+
"data-slot": "score-box-item",
|
|
56
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
57
|
+
className: ScoreBox_module_default["score-box-value"],
|
|
58
|
+
"data-slot": "score-box-value",
|
|
59
|
+
children: "—"
|
|
60
|
+
})
|
|
61
|
+
}) : levels.map(_temp)]
|
|
62
|
+
});
|
|
63
|
+
$[4] = className;
|
|
64
|
+
$[5] = props;
|
|
65
|
+
$[6] = score;
|
|
66
|
+
$[7] = t1;
|
|
67
|
+
} else t1 = $[7];
|
|
68
|
+
return t1;
|
|
69
|
+
}
|
|
70
|
+
function _temp(level) {
|
|
71
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
72
|
+
className: clsx$1(ScoreBox_module_default["score-box-item"], ScoreBox_module_default[level.kind]),
|
|
73
|
+
"data-slot": "score-box-item",
|
|
74
|
+
children: [
|
|
75
|
+
level.kind !== "simple" && /* @__PURE__ */ jsx("span", {
|
|
76
|
+
className: ScoreBox_module_default["score-box-dot"],
|
|
77
|
+
"data-slot": "score-box-dot",
|
|
78
|
+
"aria-hidden": "true"
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ jsx(ScoreValue, { raw: level.raw }),
|
|
81
|
+
level.label && /* @__PURE__ */ jsx("span", {
|
|
82
|
+
className: ScoreBox_module_default["score-box-label"],
|
|
83
|
+
"data-slot": "score-box-label",
|
|
84
|
+
children: level.label
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
}, level.id);
|
|
88
|
+
}
|
|
89
|
+
function ScoreValue(t0) {
|
|
90
|
+
const $ = c(14);
|
|
91
|
+
const { raw } = t0;
|
|
92
|
+
let t1;
|
|
93
|
+
if ($[0] !== raw) {
|
|
94
|
+
t1 = formatCompactNumber(raw);
|
|
95
|
+
$[0] = raw;
|
|
96
|
+
$[1] = t1;
|
|
97
|
+
} else t1 = $[1];
|
|
98
|
+
const { text, exact, shortened } = t1;
|
|
99
|
+
const t2 = shortened ? "true" : void 0;
|
|
100
|
+
const t3 = shortened ? 0 : void 0;
|
|
101
|
+
let t4;
|
|
102
|
+
if ($[2] !== exact || $[3] !== shortened || $[4] !== text) {
|
|
103
|
+
t4 = shortened ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
104
|
+
"aria-hidden": true,
|
|
105
|
+
children: text
|
|
106
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
107
|
+
className: "sr-only",
|
|
108
|
+
children: exact
|
|
109
|
+
})] }) : text;
|
|
110
|
+
$[2] = exact;
|
|
111
|
+
$[3] = shortened;
|
|
112
|
+
$[4] = text;
|
|
113
|
+
$[5] = t4;
|
|
114
|
+
} else t4 = $[5];
|
|
115
|
+
let t5;
|
|
116
|
+
if ($[6] !== t2 || $[7] !== t3 || $[8] !== t4) {
|
|
117
|
+
t5 = /* @__PURE__ */ jsx("span", {
|
|
118
|
+
className: ScoreBox_module_default["score-box-value"],
|
|
119
|
+
"data-slot": "score-box-value",
|
|
120
|
+
"data-shortened": t2,
|
|
121
|
+
tabIndex: t3,
|
|
122
|
+
children: t4
|
|
123
|
+
});
|
|
124
|
+
$[6] = t2;
|
|
125
|
+
$[7] = t3;
|
|
126
|
+
$[8] = t4;
|
|
127
|
+
$[9] = t5;
|
|
128
|
+
} else t5 = $[9];
|
|
129
|
+
const value = t5;
|
|
130
|
+
let t6;
|
|
131
|
+
if ($[10] !== exact || $[11] !== shortened || $[12] !== value) {
|
|
132
|
+
t6 = shortened ? /* @__PURE__ */ jsx(Tooltip, {
|
|
133
|
+
label: exact,
|
|
134
|
+
children: value
|
|
135
|
+
}) : value;
|
|
136
|
+
$[10] = exact;
|
|
137
|
+
$[11] = shortened;
|
|
138
|
+
$[12] = value;
|
|
139
|
+
$[13] = t6;
|
|
140
|
+
} else t6 = $[13];
|
|
141
|
+
return t6;
|
|
142
|
+
}
|
|
143
|
+
export { ScoreBox as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import './ScoreBox.css';
|
|
2
|
+
// src/score-box/ScoreBox.module.css
|
|
3
|
+
var ScoreBox_module_default = {
|
|
4
|
+
"hard": "_6QhLGG_hard",
|
|
5
|
+
"medium": "_6QhLGG_medium",
|
|
6
|
+
"score-box": "_6QhLGG_score-box",
|
|
7
|
+
"score-box-dot": "_6QhLGG_score-box-dot",
|
|
8
|
+
"score-box-item": "_6QhLGG_score-box-item",
|
|
9
|
+
"score-box-label": "_6QhLGG_score-box-label",
|
|
10
|
+
"score-box-title": "_6QhLGG_score-box-title",
|
|
11
|
+
"score-box-value": "_6QhLGG_score-box-value",
|
|
12
|
+
"simple": "_6QhLGG_simple",
|
|
13
|
+
"soft": "_6QhLGG_soft"
|
|
14
|
+
};
|
|
15
|
+
export { ScoreBox_module_default as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** A segment's look: `default` and `waiting` are the timeline chip colours, `empty` the unfilled share. */
|
|
2
|
+
export type SegmentVariant = "primary" | "default" | "waiting" | "empty";
|
|
3
|
+
/** A segment's verdict, in the timeline chip colours; it fills the segment in place of the `variant`. */
|
|
4
|
+
export type SegmentState = "positive" | "negative" | "warning" | "neutral";
|
|
5
|
+
/** The colour of a segment: a look (`variant`) or a verdict (`state`), never both. */
|
|
6
|
+
export type SegmentTint = {
|
|
7
|
+
/** @defaultValue `"primary"` */
|
|
8
|
+
variant?: SegmentVariant;
|
|
9
|
+
state?: never;
|
|
10
|
+
} | {
|
|
11
|
+
state: SegmentState;
|
|
12
|
+
variant?: never;
|
|
13
|
+
};
|
|
14
|
+
/** The props of `Segment`: its percentage and its colour. */
|
|
15
|
+
export type SegmentProps = SegmentTint & {
|
|
16
|
+
percentage?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A filled share of a segment bar.
|
|
20
|
+
*
|
|
21
|
+
* @category Data display
|
|
22
|
+
*/
|
|
23
|
+
export default function Segment({ percentage, variant, state }: SegmentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SegmentBox } from "./segment-box.mjs";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/segment-bar/Segment.tsx
|
|
5
|
+
/**
|
|
6
|
+
* A filled share of a segment bar.
|
|
7
|
+
*
|
|
8
|
+
* @category Data display
|
|
9
|
+
*/
|
|
10
|
+
function Segment(t0) {
|
|
11
|
+
const $ = c(4);
|
|
12
|
+
const { percentage, variant, state } = t0;
|
|
13
|
+
let t1;
|
|
14
|
+
if ($[0] !== percentage || $[1] !== state || $[2] !== variant) {
|
|
15
|
+
t1 = /* @__PURE__ */ jsx(SegmentBox, {
|
|
16
|
+
percentage,
|
|
17
|
+
variant,
|
|
18
|
+
state
|
|
19
|
+
});
|
|
20
|
+
$[0] = percentage;
|
|
21
|
+
$[1] = state;
|
|
22
|
+
$[2] = variant;
|
|
23
|
+
$[3] = t1;
|
|
24
|
+
} else t1 = $[3];
|
|
25
|
+
return t1;
|
|
26
|
+
}
|
|
27
|
+
export { Segment as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
._2fCMrW_segment-bar {
|
|
3
|
+
--height: 12px;
|
|
4
|
+
--gap: 2px;
|
|
5
|
+
width: var(--viz-segment-bar-width);
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
._2fCMrW_segment-bar[data-has-popover] {
|
|
10
|
+
cursor: help;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
._2fCMrW_segment-bar ._2fCMrW_segments {
|
|
14
|
+
height: var(--height);
|
|
15
|
+
border-radius: 99px;
|
|
16
|
+
display: flex;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
._2fCMrW_segment-bar ._2fCMrW_segment {
|
|
21
|
+
min-width: var(--min-segment, 0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
._2fCMrW_segment-bar ._2fCMrW_segment:not(:last-child) {
|
|
25
|
+
border-right: var(--gap) solid var(--tf-color-background);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
td > ._2fCMrW_segment-bar {
|
|
29
|
+
padding-block: .5em;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
._2fCMrW_segment-bar-popover {
|
|
33
|
+
width: max-content;
|
|
34
|
+
min-width: max(var(--viz-segment-bar-width), 16em);
|
|
35
|
+
--viz-popover-label-width: calc(22ch + 22 * .08em);
|
|
36
|
+
max-width: 100%;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
._2fCMrW_segment-bar[data-size="sm"] {
|
|
40
|
+
--height: 6px;
|
|
41
|
+
--gap: 0;
|
|
42
|
+
--min-segment: 2px;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PopoverFact } from "../popover/PopoverFacts.mjs";
|
|
2
|
+
import { SegmentProps } from "./Segment.mjs";
|
|
3
|
+
/** The height and segment gap of a `SegmentBar`. */
|
|
4
|
+
export type SegmentBarSize = "sm" | "md";
|
|
5
|
+
/** The props of `SegmentBar`: its name or the `facts` its card states (at least one), its width and its segments. */
|
|
6
|
+
export type SegmentBarProps = ({
|
|
7
|
+
"aria-label": string;
|
|
8
|
+
"aria-hidden"?: never;
|
|
9
|
+
facts?: never;
|
|
10
|
+
popover?: React.ReactNode;
|
|
11
|
+
} | {
|
|
12
|
+
"aria-hidden": true;
|
|
13
|
+
"aria-label"?: never;
|
|
14
|
+
facts?: never;
|
|
15
|
+
popover?: React.ReactNode;
|
|
16
|
+
} | {
|
|
17
|
+
facts: [PopoverFact, ...PopoverFact[]];
|
|
18
|
+
"aria-label"?: never;
|
|
19
|
+
"aria-hidden"?: never;
|
|
20
|
+
popover?: never;
|
|
21
|
+
}) & Pick<React.ComponentProps<"div">, "className" | "style" | "ref"> & {
|
|
22
|
+
/** @defaultValue `"10em"` */
|
|
23
|
+
width?: React.CSSProperties["width"];
|
|
24
|
+
/** @defaultValue `"md"` */
|
|
25
|
+
size?: SegmentBarSize;
|
|
26
|
+
children?: React.ReactElement<SegmentProps> | React.ReactElement<SegmentProps>[] | (React.ReactElement<SegmentProps> | boolean)[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Horizontal segmented bar of proportional segments, one `role="img"`. Its name states what its card says, since the
|
|
30
|
+
* card opens for the pointer alone: `facts` give both; `aria-hidden` marks a bar whose facts are text.
|
|
31
|
+
*
|
|
32
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
|
|
33
|
+
* @category Data display
|
|
34
|
+
*/
|
|
35
|
+
export default function SegmentBar({ width, facts, popover: content, size, children, className, style, ref, ...name }: SegmentBarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useHoverCard } from "../hooks/use-hover-card.mjs";
|
|
3
|
+
import Popover from "../popover/Popover.mjs";
|
|
4
|
+
import { PopoverFactsGrid, popoverFactsText } from "../popover/PopoverFacts.mjs";
|
|
5
|
+
import SegmentBar_module_default from "./SegmentBar.module.css.mjs";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useRef } from "react";
|
|
8
|
+
import clsx$1 from "clsx";
|
|
9
|
+
// src/segment-bar/SegmentBar.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Horizontal segmented bar of proportional segments, one `role="img"`. Its name states what its card says, since the
|
|
12
|
+
* card opens for the pointer alone: `facts` give both; `aria-hidden` marks a bar whose facts are text.
|
|
13
|
+
*
|
|
14
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
|
|
15
|
+
* @category Data display
|
|
16
|
+
*/
|
|
17
|
+
function SegmentBar({ width = "10em", facts, popover: content, size = "md", children, className, style, ref, ...name }) {
|
|
18
|
+
const bar = useRef(null);
|
|
19
|
+
const card = useHoverCard();
|
|
20
|
+
const popover = facts ? /* @__PURE__ */ jsx(PopoverFactsGrid, { facts }) : content;
|
|
21
|
+
const factsName = facts ? { "aria-label": popoverFactsText(facts) } : {};
|
|
22
|
+
const sizing = { "--viz-segment-bar-width": width };
|
|
23
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
24
|
+
ref,
|
|
25
|
+
className: clsx$1(SegmentBar_module_default["segment-bar"], className),
|
|
26
|
+
"data-slot": "segment-bar",
|
|
27
|
+
"data-size": size,
|
|
28
|
+
"data-has-popover": popover ? "" : void 0,
|
|
29
|
+
role: "img",
|
|
30
|
+
...name,
|
|
31
|
+
...factsName,
|
|
32
|
+
style: {
|
|
33
|
+
...sizing,
|
|
34
|
+
...style
|
|
35
|
+
},
|
|
36
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
37
|
+
ref: bar,
|
|
38
|
+
className: SegmentBar_module_default.segments,
|
|
39
|
+
"data-slot": "segment-bar-segments",
|
|
40
|
+
...popover ? card.triggerProps(true) : {},
|
|
41
|
+
children
|
|
42
|
+
}), popover && /* @__PURE__ */ jsx(Popover, {
|
|
43
|
+
...card.popoverProps,
|
|
44
|
+
"aria-label": "Bar details",
|
|
45
|
+
anchor: bar,
|
|
46
|
+
side: "bottom",
|
|
47
|
+
sideOffset: 6,
|
|
48
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
49
|
+
className: SegmentBar_module_default["segment-bar-popover"],
|
|
50
|
+
"data-slot": "segment-bar-popover",
|
|
51
|
+
style: sizing,
|
|
52
|
+
children: popover
|
|
53
|
+
})
|
|
54
|
+
})]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export { SegmentBar as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './SegmentBar.css';
|
|
2
|
+
// src/segment-bar/SegmentBar.module.css
|
|
3
|
+
var SegmentBar_module_default = {
|
|
4
|
+
"segment": "_2fCMrW_segment",
|
|
5
|
+
"segment-bar": "_2fCMrW_segment-bar",
|
|
6
|
+
"segment-bar-popover": "_2fCMrW_segment-bar-popover",
|
|
7
|
+
"segments": "_2fCMrW_segments"
|
|
8
|
+
};
|
|
9
|
+
export { SegmentBar_module_default as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SegmentState, SegmentVariant } from "./Segment.mjs";
|
|
2
|
+
export declare function segmentFill(variant?: SegmentVariant, state?: SegmentState): string;
|
|
3
|
+
interface SegmentBoxProps {
|
|
4
|
+
percentage?: number;
|
|
5
|
+
variant?: SegmentVariant;
|
|
6
|
+
state?: SegmentState;
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function SegmentBox({ percentage, variant, state, color }: SegmentBoxProps): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import SegmentBar_module_default from "./SegmentBar.module.css.mjs";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { clsx } from "clsx";
|
|
4
|
+
// src/segment-bar/segment-box.tsx
|
|
5
|
+
const FILL = {
|
|
6
|
+
primary: "var(--tf-color-primary)",
|
|
7
|
+
default: "var(--viz-item-default)",
|
|
8
|
+
waiting: "var(--viz-item-waiting)",
|
|
9
|
+
empty: "var(--viz-empty)",
|
|
10
|
+
positive: "var(--viz-item-positive)",
|
|
11
|
+
negative: "var(--viz-item-negative)",
|
|
12
|
+
warning: "var(--viz-item-warning)",
|
|
13
|
+
neutral: "var(--viz-item-neutral)"
|
|
14
|
+
};
|
|
15
|
+
function segmentFill(variant = "primary", state) {
|
|
16
|
+
return FILL[state ?? variant];
|
|
17
|
+
}
|
|
18
|
+
function SegmentBox({ percentage, variant = "primary", state, color }) {
|
|
19
|
+
return /* @__PURE__ */ jsx("div", {
|
|
20
|
+
className: clsx(SegmentBar_module_default.segment, "bg-(--viz-segment-color)"),
|
|
21
|
+
"data-slot": "segment",
|
|
22
|
+
"data-variant": state === void 0 && !color ? variant : void 0,
|
|
23
|
+
"data-state": state,
|
|
24
|
+
style: {
|
|
25
|
+
width: `${percentage ?? 0}%`,
|
|
26
|
+
"--viz-segment-color": color ?? segmentFill(variant, state)
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export { SegmentBox, segmentFill };
|