@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,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useToast } from "../toast/ToastProvider.mjs";
|
|
3
|
+
import Tooltip$1 from "../tooltip/Tooltip.mjs";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { CopyValueButton } from "../vendor/components.mjs";
|
|
7
|
+
// src/button/CopyButton.tsx
|
|
8
|
+
/**
|
|
9
|
+
* An icon button that copies `value` to the clipboard, confirming with a check mark; a failure is a toast.
|
|
10
|
+
*
|
|
11
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
|
|
12
|
+
* @category Controls
|
|
13
|
+
*/
|
|
14
|
+
function CopyButton(t0) {
|
|
15
|
+
const $ = c(10);
|
|
16
|
+
const { value, label } = t0;
|
|
17
|
+
const { show } = useToast();
|
|
18
|
+
let t1;
|
|
19
|
+
if ($[0] !== show || $[1] !== value) {
|
|
20
|
+
t1 = () => show(`Could not copy ${value} to the clipboard.`, { state: "negative" });
|
|
21
|
+
$[0] = show;
|
|
22
|
+
$[1] = value;
|
|
23
|
+
$[2] = t1;
|
|
24
|
+
} else t1 = $[2];
|
|
25
|
+
let t2;
|
|
26
|
+
if ($[3] !== label || $[4] !== t1 || $[5] !== value) {
|
|
27
|
+
t2 = /* @__PURE__ */ jsx(CopyValueButton, {
|
|
28
|
+
"data-slot": "copy-button",
|
|
29
|
+
variant: "soft",
|
|
30
|
+
size: "xs",
|
|
31
|
+
value,
|
|
32
|
+
label,
|
|
33
|
+
onError: t1
|
|
34
|
+
});
|
|
35
|
+
$[3] = label;
|
|
36
|
+
$[4] = t1;
|
|
37
|
+
$[5] = value;
|
|
38
|
+
$[6] = t2;
|
|
39
|
+
} else t2 = $[6];
|
|
40
|
+
let t3;
|
|
41
|
+
if ($[7] !== label || $[8] !== t2) {
|
|
42
|
+
t3 = /* @__PURE__ */ jsx(Tooltip$1, {
|
|
43
|
+
label,
|
|
44
|
+
children: t2
|
|
45
|
+
});
|
|
46
|
+
$[7] = label;
|
|
47
|
+
$[8] = t2;
|
|
48
|
+
$[9] = t3;
|
|
49
|
+
} else t3 = $[9];
|
|
50
|
+
return t3;
|
|
51
|
+
}
|
|
52
|
+
export { CopyButton as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ButtonProps } from "../vendor/components.mjs";
|
|
2
|
+
/** The props of `ShowAllButton`, the button that expands or collapses a list. */
|
|
3
|
+
export interface ShowAllButtonProps extends Omit<ButtonProps, "asChild" | "children" | "leadingIcon" | "trailingIcon" | "soloIcon" | "onClick" | "aria-expanded"> {
|
|
4
|
+
expanded: boolean;
|
|
5
|
+
onExpandedChange: (expanded: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The "Show all" / "Show less" expander for a list truncated by default —
|
|
9
|
+
* the filter panel's facet groups, the efficiency panel's breakdown groups.
|
|
10
|
+
*
|
|
11
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/
|
|
12
|
+
* @category Controls
|
|
13
|
+
*/
|
|
14
|
+
export default function ShowAllButton({ expanded, onExpandedChange, ...props }: ShowAllButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Button } from "../vendor/components.mjs";
|
|
5
|
+
import { TbChevronDown, TbChevronUp } from "react-icons/tb";
|
|
6
|
+
// src/button/ShowAllButton.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The "Show all" / "Show less" expander for a list truncated by default —
|
|
9
|
+
* the filter panel's facet groups, the efficiency panel's breakdown groups.
|
|
10
|
+
*
|
|
11
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/
|
|
12
|
+
* @category Controls
|
|
13
|
+
*/
|
|
14
|
+
function ShowAllButton(t0) {
|
|
15
|
+
const $ = c(13);
|
|
16
|
+
let expanded;
|
|
17
|
+
let onExpandedChange;
|
|
18
|
+
let props;
|
|
19
|
+
if ($[0] !== t0) {
|
|
20
|
+
({expanded, onExpandedChange, ...props} = t0);
|
|
21
|
+
$[0] = t0;
|
|
22
|
+
$[1] = expanded;
|
|
23
|
+
$[2] = onExpandedChange;
|
|
24
|
+
$[3] = props;
|
|
25
|
+
} else {
|
|
26
|
+
expanded = $[1];
|
|
27
|
+
onExpandedChange = $[2];
|
|
28
|
+
props = $[3];
|
|
29
|
+
}
|
|
30
|
+
const t1 = expanded ? TbChevronUp : TbChevronDown;
|
|
31
|
+
let t2;
|
|
32
|
+
if ($[4] !== expanded || $[5] !== onExpandedChange) {
|
|
33
|
+
t2 = () => onExpandedChange(!expanded);
|
|
34
|
+
$[4] = expanded;
|
|
35
|
+
$[5] = onExpandedChange;
|
|
36
|
+
$[6] = t2;
|
|
37
|
+
} else t2 = $[6];
|
|
38
|
+
const t3 = expanded ? "Show less" : "Show all";
|
|
39
|
+
let t4;
|
|
40
|
+
if ($[7] !== expanded || $[8] !== props || $[9] !== t1 || $[10] !== t2 || $[11] !== t3) {
|
|
41
|
+
t4 = /* @__PURE__ */ jsx(Button, {
|
|
42
|
+
type: "button",
|
|
43
|
+
"data-slot": "show-all-button",
|
|
44
|
+
variant: "ghost",
|
|
45
|
+
size: "sm",
|
|
46
|
+
trailingIcon: t1,
|
|
47
|
+
"aria-expanded": expanded,
|
|
48
|
+
onClick: t2,
|
|
49
|
+
...props,
|
|
50
|
+
children: t3
|
|
51
|
+
});
|
|
52
|
+
$[7] = expanded;
|
|
53
|
+
$[8] = props;
|
|
54
|
+
$[9] = t1;
|
|
55
|
+
$[10] = t2;
|
|
56
|
+
$[11] = t3;
|
|
57
|
+
$[12] = t4;
|
|
58
|
+
} else t4 = $[12];
|
|
59
|
+
return t4;
|
|
60
|
+
}
|
|
61
|
+
export { ShowAllButton as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ButtonProps } from "../vendor/components.mjs";
|
|
2
|
+
/** The props of `ShowMoreButton`, the button that reveals the next step of a truncated list. */
|
|
3
|
+
export interface ShowMoreButtonProps extends Omit<ButtonProps, "asChild" | "children" | "leadingIcon" | "trailingIcon" | "soloIcon" | "onClick"> {
|
|
4
|
+
remaining: number;
|
|
5
|
+
step: number;
|
|
6
|
+
onReveal: () => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Reveals the next step of a long, truncated list — with no way back.
|
|
10
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
|
|
11
|
+
* @category Controls
|
|
12
|
+
*/
|
|
13
|
+
export default function ShowMoreButton({ remaining, step, onReveal, ...props }: ShowMoreButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Button } from "../vendor/components.mjs";
|
|
5
|
+
import { TbChevronDown } from "react-icons/tb";
|
|
6
|
+
// src/button/ShowMoreButton.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Reveals the next step of a long, truncated list — with no way back.
|
|
9
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
|
|
10
|
+
* @category Controls
|
|
11
|
+
*/
|
|
12
|
+
function ShowMoreButton(t0) {
|
|
13
|
+
const $ = c(9);
|
|
14
|
+
let onReveal;
|
|
15
|
+
let props;
|
|
16
|
+
let remaining;
|
|
17
|
+
let step;
|
|
18
|
+
if ($[0] !== t0) {
|
|
19
|
+
({remaining, step, onReveal, ...props} = t0);
|
|
20
|
+
$[0] = t0;
|
|
21
|
+
$[1] = onReveal;
|
|
22
|
+
$[2] = props;
|
|
23
|
+
$[3] = remaining;
|
|
24
|
+
$[4] = step;
|
|
25
|
+
} else {
|
|
26
|
+
onReveal = $[1];
|
|
27
|
+
props = $[2];
|
|
28
|
+
remaining = $[3];
|
|
29
|
+
step = $[4];
|
|
30
|
+
}
|
|
31
|
+
const t1 = `Show ${Math.min(step, remaining)} more`;
|
|
32
|
+
let t2;
|
|
33
|
+
if ($[5] !== onReveal || $[6] !== props || $[7] !== t1) {
|
|
34
|
+
t2 = /* @__PURE__ */ jsx(Button, {
|
|
35
|
+
type: "button",
|
|
36
|
+
"data-slot": "show-more-button",
|
|
37
|
+
variant: "ghost",
|
|
38
|
+
size: "sm",
|
|
39
|
+
trailingIcon: TbChevronDown,
|
|
40
|
+
onClick: onReveal,
|
|
41
|
+
...props,
|
|
42
|
+
children: t1
|
|
43
|
+
});
|
|
44
|
+
$[5] = onReveal;
|
|
45
|
+
$[6] = props;
|
|
46
|
+
$[7] = t1;
|
|
47
|
+
$[8] = t2;
|
|
48
|
+
} else t2 = $[8];
|
|
49
|
+
return t2;
|
|
50
|
+
}
|
|
51
|
+
export { ShowMoreButton as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SolvePhase } from "@timefoldai/viz-core";
|
|
2
|
+
/** The phase of the solve a `SolveButton` shows: viz-core's `SolvePhase`. */
|
|
3
|
+
export type SolveButtonPhase = SolvePhase;
|
|
4
|
+
/** The props of `SolveButton`: its label, its phase and its toggle. */
|
|
5
|
+
export interface SolveButtonProps {
|
|
6
|
+
label: string;
|
|
7
|
+
phase: SolveButtonPhase;
|
|
8
|
+
onToggle: () => void | Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Starts or stops a solve. Takes `viz-platform`'s `useSolveControl()` as props.
|
|
12
|
+
*
|
|
13
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
|
|
14
|
+
* @category Controls
|
|
15
|
+
*/
|
|
16
|
+
export default function SolveButton({ label, phase, onToggle }: SolveButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Button } from "../vendor/components.mjs";
|
|
5
|
+
import { TbLoader2, TbPlayerPlayFilled, TbSquareFilled } from "react-icons/tb";
|
|
6
|
+
// src/button/SolveButton.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Starts or stops a solve. Takes `viz-platform`'s `useSolveControl()` as props.
|
|
9
|
+
*
|
|
10
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
|
|
11
|
+
* @category Controls
|
|
12
|
+
*/
|
|
13
|
+
function SolveButton(t0) {
|
|
14
|
+
const $ = c(10);
|
|
15
|
+
const { label, phase, onToggle } = t0;
|
|
16
|
+
const t1 = phase === "solving" ? TbSquareFilled : TbPlayerPlayFilled;
|
|
17
|
+
const t2 = phase === "starting" || phase === "preparing";
|
|
18
|
+
let t3;
|
|
19
|
+
if ($[0] !== label) {
|
|
20
|
+
t3 = /* @__PURE__ */ jsx("span", {
|
|
21
|
+
"data-slot": "solve-button-label",
|
|
22
|
+
children: label
|
|
23
|
+
});
|
|
24
|
+
$[0] = label;
|
|
25
|
+
$[1] = t3;
|
|
26
|
+
} else t3 = $[1];
|
|
27
|
+
let t4;
|
|
28
|
+
if ($[2] !== phase) {
|
|
29
|
+
t4 = (phase === "starting" || phase === "solving") && /* @__PURE__ */ jsx(TbLoader2, {
|
|
30
|
+
"aria-hidden": true,
|
|
31
|
+
"data-slot": "solve-button-spinner",
|
|
32
|
+
className: "size-4 motion-safe:animate-spin"
|
|
33
|
+
});
|
|
34
|
+
$[2] = phase;
|
|
35
|
+
$[3] = t4;
|
|
36
|
+
} else t4 = $[3];
|
|
37
|
+
let t5;
|
|
38
|
+
if ($[4] !== onToggle || $[5] !== t1 || $[6] !== t2 || $[7] !== t3 || $[8] !== t4) {
|
|
39
|
+
t5 = /* @__PURE__ */ jsxs(Button, {
|
|
40
|
+
variant: "soft",
|
|
41
|
+
type: "button",
|
|
42
|
+
leadingIcon: t1,
|
|
43
|
+
loading: t2,
|
|
44
|
+
onClick: onToggle,
|
|
45
|
+
children: [t3, t4]
|
|
46
|
+
});
|
|
47
|
+
$[4] = onToggle;
|
|
48
|
+
$[5] = t1;
|
|
49
|
+
$[6] = t2;
|
|
50
|
+
$[7] = t3;
|
|
51
|
+
$[8] = t4;
|
|
52
|
+
$[9] = t5;
|
|
53
|
+
} else t5 = $[9];
|
|
54
|
+
return t5;
|
|
55
|
+
}
|
|
56
|
+
export { SolveButton as default };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.e20vzq_bar-chart {
|
|
3
|
+
--chart-radius: .25rem;
|
|
4
|
+
--max: 100;
|
|
5
|
+
--chart-track: color-mix(in oklab,
|
|
6
|
+
var(--tf-color-foreground) 4%,
|
|
7
|
+
var(--tf-color-background));
|
|
8
|
+
height: var(--chart-height, 4rem);
|
|
9
|
+
gap: 1px;
|
|
10
|
+
display: flex;
|
|
11
|
+
position: relative;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.e20vzq_bar-chart .e20vzq_bar {
|
|
15
|
+
background: var(--chart-track);
|
|
16
|
+
border-radius: var(--chart-radius);
|
|
17
|
+
flex-grow: 1;
|
|
18
|
+
position: relative;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.e20vzq_bar-chart .e20vzq_bar:hover {
|
|
22
|
+
background: color-mix(in oklab,
|
|
23
|
+
var(--tf-color-foreground) 15%,
|
|
24
|
+
var(--tf-color-background));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.e20vzq_bar-chart .e20vzq_bar .e20vzq_value {
|
|
28
|
+
inset-inline: 0;
|
|
29
|
+
height: calc(var(--viz-bar-chart-size) / var(--max) * 100%);
|
|
30
|
+
min-height: var(--viz-bar-chart-min-height, 0);
|
|
31
|
+
border-radius: var(--chart-radius);
|
|
32
|
+
background: var(--viz-bar-chart-color, var(--viz-chart-bar));
|
|
33
|
+
position: absolute;
|
|
34
|
+
bottom: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.e20vzq_bar-chart .e20vzq_max {
|
|
38
|
+
color: var(--tf-color-foreground);
|
|
39
|
+
font-size: .5625rem;
|
|
40
|
+
font-family: var(--tf-font-mono);
|
|
41
|
+
margin-right: .4em;
|
|
42
|
+
position: absolute;
|
|
43
|
+
right: 100%;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.e20vzq_viz-distribution-average {
|
|
47
|
+
color: var(--tf-color-primary);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:where(.dark, .dark *) .e20vzq_viz-distribution-average {
|
|
51
|
+
color: var(--tf-primary-200);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:where(.dark, .dark *) .e20vzq_bar-chart {
|
|
55
|
+
--chart-track: color-mix(in oklab,
|
|
56
|
+
var(--tf-color-foreground) 7%,
|
|
57
|
+
var(--tf-color-background));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/** A bar of `BarChart`: its id, value, label and colour. */
|
|
3
|
+
export interface BarChartBar {
|
|
4
|
+
id: string;
|
|
5
|
+
value: number;
|
|
6
|
+
label?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
/** @defaultValue `label` and `value`, as the bar's entry in the chart's `aria-label` */
|
|
9
|
+
description?: string;
|
|
10
|
+
}
|
|
11
|
+
/** The props of `BarChart`: its bars, its accessible label and its popover. */
|
|
12
|
+
export interface BarChartProps<Bar extends BarChartBar> extends Pick<React.ComponentProps<"div">, "className" | "style" | "ref"> {
|
|
13
|
+
bars: Bar[];
|
|
14
|
+
"aria-label": string;
|
|
15
|
+
renderPopover?: (bar: Bar) => ReactNode;
|
|
16
|
+
showLabels?: boolean;
|
|
17
|
+
minBarHeight?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A bar chart, rendered as a single `role="img"` graphic: the bars encode value by height and are `aria-hidden`.
|
|
21
|
+
* The required `aria-label` names the chart and the image's name then lists every bar, a card's facts included.
|
|
22
|
+
*
|
|
23
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
|
|
24
|
+
* @category Charts
|
|
25
|
+
*/
|
|
26
|
+
export default function BarChart<Bar extends BarChartBar>({ bars, "aria-label": ariaLabel, renderPopover, showLabels, minBarHeight, className, style, ref }: BarChartProps<Bar>): import("react").JSX.Element;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useHoverCardState } from "../hooks/use-hover-card.mjs";
|
|
3
|
+
import Popover, { hasPopoverContent } from "../popover/Popover.mjs";
|
|
4
|
+
import Tooltip from "../tooltip/Tooltip.mjs";
|
|
5
|
+
import BarChart_module_default from "./BarChart.module.css.mjs";
|
|
6
|
+
import { c } from "react/compiler-runtime";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import clsx$1 from "clsx";
|
|
9
|
+
// src/charts/BarChart.tsx
|
|
10
|
+
function isSameBar(a, b) {
|
|
11
|
+
return a.id === b.id;
|
|
12
|
+
}
|
|
13
|
+
function describeBar({ label, value, description }) {
|
|
14
|
+
return description ?? (label == null ? String(value) : `${label} ${value}`);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A bar chart, rendered as a single `role="img"` graphic: the bars encode value by height and are `aria-hidden`.
|
|
18
|
+
* The required `aria-label` names the chart and the image's name then lists every bar, a card's facts included.
|
|
19
|
+
*
|
|
20
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
|
|
21
|
+
* @category Charts
|
|
22
|
+
*/
|
|
23
|
+
function BarChart(t0) {
|
|
24
|
+
const $ = c(35);
|
|
25
|
+
const { bars, "aria-label": ariaLabel, renderPopover, showLabels, minBarHeight, className, style, ref } = t0;
|
|
26
|
+
let t1;
|
|
27
|
+
if ($[0] !== bars) {
|
|
28
|
+
t1 = bars.length > 0 ? Math.max(...bars.map(_temp)) : 0;
|
|
29
|
+
$[0] = bars;
|
|
30
|
+
$[1] = t1;
|
|
31
|
+
} else t1 = $[1];
|
|
32
|
+
const maxValue = t1;
|
|
33
|
+
let t2;
|
|
34
|
+
if ($[2] !== bars) {
|
|
35
|
+
t2 = bars.map(describeBar).join(", ");
|
|
36
|
+
$[2] = bars;
|
|
37
|
+
$[3] = t2;
|
|
38
|
+
} else t2 = $[3];
|
|
39
|
+
const enumeration = t2;
|
|
40
|
+
const summary = enumeration ? `${ariaLabel}: ${enumeration}` : ariaLabel;
|
|
41
|
+
const card = useHoverCardState(isSameBar);
|
|
42
|
+
const shownId = card.shown?.id;
|
|
43
|
+
let t3;
|
|
44
|
+
if ($[4] !== bars || $[5] !== card || $[6] !== className || $[7] !== maxValue || $[8] !== minBarHeight || $[9] !== ref || $[10] !== renderPopover || $[11] !== showLabels || $[12] !== shownId || $[13] !== style || $[14] !== summary) {
|
|
45
|
+
let t4;
|
|
46
|
+
if ($[16] !== shownId) {
|
|
47
|
+
t4 = (bar_0) => bar_0.id === shownId;
|
|
48
|
+
$[16] = shownId;
|
|
49
|
+
$[17] = t4;
|
|
50
|
+
} else t4 = $[17];
|
|
51
|
+
const shownBar = bars.find(t4);
|
|
52
|
+
const cardContent = shownBar && renderPopover?.(shownBar);
|
|
53
|
+
let t5;
|
|
54
|
+
if ($[18] !== className) {
|
|
55
|
+
t5 = clsx$1(BarChart_module_default["bar-chart"], className);
|
|
56
|
+
$[18] = className;
|
|
57
|
+
$[19] = t5;
|
|
58
|
+
} else t5 = $[19];
|
|
59
|
+
let t6;
|
|
60
|
+
if ($[20] !== maxValue) {
|
|
61
|
+
t6 = /* @__PURE__ */ jsx("div", {
|
|
62
|
+
className: BarChart_module_default.max,
|
|
63
|
+
"data-slot": "bar-chart-max",
|
|
64
|
+
children: maxValue
|
|
65
|
+
});
|
|
66
|
+
$[20] = maxValue;
|
|
67
|
+
$[21] = t6;
|
|
68
|
+
} else t6 = $[21];
|
|
69
|
+
let t7;
|
|
70
|
+
if ($[22] !== bars || $[23] !== card || $[24] !== maxValue || $[25] !== minBarHeight || $[26] !== renderPopover || $[27] !== showLabels) {
|
|
71
|
+
let t8;
|
|
72
|
+
if ($[29] !== card || $[30] !== maxValue || $[31] !== minBarHeight || $[32] !== renderPopover || $[33] !== showLabels) {
|
|
73
|
+
t8 = (bar_1) => {
|
|
74
|
+
const barElement = /* @__PURE__ */ jsx("div", {
|
|
75
|
+
className: BarChart_module_default.bar,
|
|
76
|
+
"data-slot": "bar-chart-bar",
|
|
77
|
+
"aria-hidden": "true",
|
|
78
|
+
onPointerEnter: renderPopover ? (event) => card.open({
|
|
79
|
+
id: bar_1.id,
|
|
80
|
+
element: event.currentTarget
|
|
81
|
+
}) : void 0,
|
|
82
|
+
onPointerLeave: renderPopover ? (event_0) => card.leave({
|
|
83
|
+
id: bar_1.id,
|
|
84
|
+
element: event_0.currentTarget
|
|
85
|
+
}) : void 0,
|
|
86
|
+
children: bar_1.value > 0 && /* @__PURE__ */ jsx("div", {
|
|
87
|
+
className: BarChart_module_default.value,
|
|
88
|
+
"data-slot": "bar-chart-value",
|
|
89
|
+
style: {
|
|
90
|
+
"--viz-bar-chart-size": `${bar_1.value / maxValue * 100}`,
|
|
91
|
+
"--viz-bar-chart-color": bar_1.color,
|
|
92
|
+
"--viz-bar-chart-min-height": minBarHeight === void 0 ? void 0 : `${minBarHeight}px`
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}, bar_1.id);
|
|
96
|
+
const withHint = !renderPopover && bar_1.label != null ? /* @__PURE__ */ jsx(Tooltip, {
|
|
97
|
+
label: `${bar_1.label}: ${bar_1.value}`,
|
|
98
|
+
side: "bottom",
|
|
99
|
+
children: barElement
|
|
100
|
+
}, bar_1.id) : barElement;
|
|
101
|
+
return showLabels && bar_1.label != null ? /* @__PURE__ */ jsxs("div", {
|
|
102
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
103
|
+
"data-slot": "bar-chart-column",
|
|
104
|
+
children: [withHint, /* @__PURE__ */ jsx("div", {
|
|
105
|
+
className: "text-viz-muted mono mt-1 truncate text-left text-[.5625rem]",
|
|
106
|
+
"data-slot": "bar-chart-label",
|
|
107
|
+
"aria-hidden": "true",
|
|
108
|
+
children: bar_1.label
|
|
109
|
+
})]
|
|
110
|
+
}, bar_1.id) : withHint;
|
|
111
|
+
};
|
|
112
|
+
$[29] = card;
|
|
113
|
+
$[30] = maxValue;
|
|
114
|
+
$[31] = minBarHeight;
|
|
115
|
+
$[32] = renderPopover;
|
|
116
|
+
$[33] = showLabels;
|
|
117
|
+
$[34] = t8;
|
|
118
|
+
} else t8 = $[34];
|
|
119
|
+
t7 = bars.map(t8);
|
|
120
|
+
$[22] = bars;
|
|
121
|
+
$[23] = card;
|
|
122
|
+
$[24] = maxValue;
|
|
123
|
+
$[25] = minBarHeight;
|
|
124
|
+
$[26] = renderPopover;
|
|
125
|
+
$[27] = showLabels;
|
|
126
|
+
$[28] = t7;
|
|
127
|
+
} else t7 = $[28];
|
|
128
|
+
t3 = /* @__PURE__ */ jsxs("div", {
|
|
129
|
+
ref,
|
|
130
|
+
className: t5,
|
|
131
|
+
style,
|
|
132
|
+
"data-slot": "bar-chart",
|
|
133
|
+
role: "img",
|
|
134
|
+
"aria-label": summary,
|
|
135
|
+
children: [
|
|
136
|
+
t6,
|
|
137
|
+
t7,
|
|
138
|
+
renderPopover && /* @__PURE__ */ jsx(Popover, {
|
|
139
|
+
...card.popoverProps,
|
|
140
|
+
open: card.popoverProps.open && hasPopoverContent(cardContent),
|
|
141
|
+
"aria-label": "Bar details",
|
|
142
|
+
anchor: card.shown?.element ?? null,
|
|
143
|
+
side: "bottom",
|
|
144
|
+
sideOffset: 6,
|
|
145
|
+
children: cardContent
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
});
|
|
149
|
+
$[4] = bars;
|
|
150
|
+
$[5] = card;
|
|
151
|
+
$[6] = className;
|
|
152
|
+
$[7] = maxValue;
|
|
153
|
+
$[8] = minBarHeight;
|
|
154
|
+
$[9] = ref;
|
|
155
|
+
$[10] = renderPopover;
|
|
156
|
+
$[11] = showLabels;
|
|
157
|
+
$[12] = shownId;
|
|
158
|
+
$[13] = style;
|
|
159
|
+
$[14] = summary;
|
|
160
|
+
$[15] = t3;
|
|
161
|
+
} else t3 = $[15];
|
|
162
|
+
return t3;
|
|
163
|
+
}
|
|
164
|
+
function _temp(bar) {
|
|
165
|
+
return bar.value;
|
|
166
|
+
}
|
|
167
|
+
export { BarChart as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './BarChart.css';
|
|
2
|
+
// src/charts/BarChart.module.css
|
|
3
|
+
var BarChart_module_default = {
|
|
4
|
+
"bar": "e20vzq_bar",
|
|
5
|
+
"bar-chart": "e20vzq_bar-chart",
|
|
6
|
+
"max": "e20vzq_max",
|
|
7
|
+
"value": "e20vzq_value",
|
|
8
|
+
"viz-distribution-average": "e20vzq_viz-distribution-average"
|
|
9
|
+
};
|
|
10
|
+
export { BarChart_module_default as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The props of `ChartGrid`, the props of a `div`. */
|
|
2
|
+
export type ChartGridProps = React.ComponentProps<"div">;
|
|
3
|
+
/**
|
|
4
|
+
* The grid a page's distribution charts sit in: as many columns of 13em–25em as fit.
|
|
5
|
+
*
|
|
6
|
+
* @category Charts
|
|
7
|
+
*/
|
|
8
|
+
export default function ChartGrid({ children, className, ...props }: ChartGridProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import clsx$1 from "clsx";
|
|
4
|
+
// src/charts/ChartGrid.tsx
|
|
5
|
+
/**
|
|
6
|
+
* The grid a page's distribution charts sit in: as many columns of 13em–25em as fit.
|
|
7
|
+
*
|
|
8
|
+
* @category Charts
|
|
9
|
+
*/
|
|
10
|
+
function ChartGrid(t0) {
|
|
11
|
+
const $ = c(10);
|
|
12
|
+
let children;
|
|
13
|
+
let className;
|
|
14
|
+
let props;
|
|
15
|
+
if ($[0] !== t0) {
|
|
16
|
+
({children, className, ...props} = t0);
|
|
17
|
+
$[0] = t0;
|
|
18
|
+
$[1] = children;
|
|
19
|
+
$[2] = className;
|
|
20
|
+
$[3] = props;
|
|
21
|
+
} else {
|
|
22
|
+
children = $[1];
|
|
23
|
+
className = $[2];
|
|
24
|
+
props = $[3];
|
|
25
|
+
}
|
|
26
|
+
let t1;
|
|
27
|
+
if ($[4] !== className) {
|
|
28
|
+
t1 = clsx$1("@container mb-[3em] grid grid-cols-[repeat(auto-fit,minmax(min(100%,13em),1fr))] gap-x-[5em] gap-y-[3em] *:max-w-[25em]", className);
|
|
29
|
+
$[4] = className;
|
|
30
|
+
$[5] = t1;
|
|
31
|
+
} else t1 = $[5];
|
|
32
|
+
let t2;
|
|
33
|
+
if ($[6] !== children || $[7] !== props || $[8] !== t1) {
|
|
34
|
+
t2 = /* @__PURE__ */ jsx("div", {
|
|
35
|
+
"data-slot": "chart-grid",
|
|
36
|
+
className: t1,
|
|
37
|
+
...props,
|
|
38
|
+
children
|
|
39
|
+
});
|
|
40
|
+
$[6] = children;
|
|
41
|
+
$[7] = props;
|
|
42
|
+
$[8] = t1;
|
|
43
|
+
$[9] = t2;
|
|
44
|
+
} else t2 = $[9];
|
|
45
|
+
return t2;
|
|
46
|
+
}
|
|
47
|
+
export { ChartGrid as default };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* One bucket of a distribution chart: its value bounds, label, count and the indices of its values.
|
|
4
|
+
* An open end is `-Infinity` or `Infinity`, and the bucket of `"isolate-min"` has `min` equal to `max`.
|
|
5
|
+
*/
|
|
6
|
+
export interface DistributionChartBucket {
|
|
7
|
+
min: number;
|
|
8
|
+
max: number;
|
|
9
|
+
label: string;
|
|
10
|
+
count: number;
|
|
11
|
+
indices: number[];
|
|
12
|
+
}
|
|
13
|
+
/** The value extent that `DistributionChart` splits into buckets, from `min` to `max`. */
|
|
14
|
+
export interface DistributionChartDomain {
|
|
15
|
+
min: number;
|
|
16
|
+
max: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The extra buckets around `domain`: `"overflow"` adds an under- and an over-domain bucket, `"isolate-min"` gives
|
|
20
|
+
* `domain.min` a bucket of its own, `"both"` does both, and `"plain"` neither, so values outside the domain drop.
|
|
21
|
+
*/
|
|
22
|
+
export type DistributionChartBucketLayout = "plain" | "overflow" | "isolate-min" | "both";
|
|
23
|
+
/** What one bucket shows in place of the defaults, as `bucketOverride` returns it. */
|
|
24
|
+
export interface DistributionChartBucketOverride {
|
|
25
|
+
label?: string;
|
|
26
|
+
/** @see BarChartBar.color */
|
|
27
|
+
color?: string;
|
|
28
|
+
}
|
|
29
|
+
/** The props of `DistributionChart`: the values it buckets and its title. */
|
|
30
|
+
export interface DistributionChartProps extends Pick<React.ComponentProps<"div">, "className" | "style" | "ref"> {
|
|
31
|
+
data: (number | null)[];
|
|
32
|
+
title: string;
|
|
33
|
+
/** @remarks The equal buckets across `domain`; `bucketLayout` adds its extra buckets beside them. */
|
|
34
|
+
bucketCount: number;
|
|
35
|
+
/** @defaultValue `{ min: 0, max: 100 }` */
|
|
36
|
+
domain?: DistributionChartDomain;
|
|
37
|
+
/** @defaultValue `"overflow"` */
|
|
38
|
+
bucketLayout?: DistributionChartBucketLayout;
|
|
39
|
+
/** @defaultValue a percentage, `${value}%` */
|
|
40
|
+
formatValue?: (value: number) => string;
|
|
41
|
+
/** @see BarChartProps.showLabels */
|
|
42
|
+
showLabels?: boolean;
|
|
43
|
+
bucketOverride?: (bucket: DistributionChartBucket) => DistributionChartBucketOverride | undefined;
|
|
44
|
+
/** @see BarChartProps.minBarHeight */
|
|
45
|
+
minBarHeight?: number;
|
|
46
|
+
headline?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
overflowLabel?: string;
|
|
49
|
+
renderPopover?: (bucket: DistributionChartBucket) => ReactNode;
|
|
50
|
+
/** @defaultValue the bucket's label and count, as its entry in the chart's `aria-label` */
|
|
51
|
+
describeBucket?: (bucket: DistributionChartBucket) => string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A histogram of `data` bucketed into `bucketCount` buckets across `domain`, with the
|
|
55
|
+
* average called out above the bars.
|
|
56
|
+
*
|
|
57
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
|
|
58
|
+
* @category Charts
|
|
59
|
+
*/
|
|
60
|
+
export default function DistributionChart({ data, title, bucketCount, domain, bucketLayout, formatValue, showLabels, bucketOverride, minBarHeight, headline, description, overflowLabel, renderPopover, describeBucket, className, style, ref }: DistributionChartProps): import("react").JSX.Element;
|