@sybilion/uilib 1.8.2 → 1.8.4
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/dist/esm/src/components/ui/BarChart/BarChart.js +39 -7
- package/dist/esm/src/components/ui/Chart/components/BaseChartWrapper.js +71 -6
- package/dist/esm/src/components/ui/Chart/components/BaseChartWrapper.styl.js +2 -2
- package/dist/esm/src/components/ui/Chart/components/ChartAxes.js +11 -3
- package/dist/esm/src/components/ui/Chart/components/ChartTooltipContent.js +6 -3
- package/dist/esm/src/components/ui/Chart/components/QuantileBands.js +1 -1
- package/dist/esm/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.js +20 -0
- package/dist/esm/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.styl.js +7 -0
- package/dist/esm/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.js +2 -2
- package/dist/esm/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.styl.js +2 -2
- package/dist/esm/src/components/ui/ChartAreaInteractive/ChartLines.js +49 -13
- package/dist/esm/src/components/ui/StackedAreaChart/StackedAreaChart.helpers.js +45 -11
- package/dist/esm/src/components/ui/StackedAreaChart/StackedAreaChart.js +15 -8
- package/dist/esm/src/components/ui/TimeRangeControls/TimeRangeControls.js +1 -1
- package/dist/esm/src/components/ui/Toggle/Toggle.styl.js +2 -2
- package/dist/esm/src/components/ui/ToggleGroup/ToggleGroup.js +1 -1
- package/dist/esm/src/components/ui/ToggleGroup/ToggleGroup.styl.js +1 -1
- package/dist/esm/types/src/components/ui/BarChart/BarChart.types.d.ts +22 -0
- package/dist/esm/types/src/components/ui/Chart/chartForecastVisualization.types.d.ts +5 -0
- package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.d.ts +22 -5
- package/dist/esm/types/src/components/ui/Chart/components/ChartAxes.d.ts +8 -1
- package/dist/esm/types/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.d.ts +22 -0
- package/dist/esm/types/src/components/ui/Chart/components/SeriesLegend/index.d.ts +1 -0
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.d.ts +1 -1
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.types.d.ts +7 -0
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartLines.d.ts +10 -1
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/chartHistories.d.ts +5 -0
- package/dist/esm/types/src/components/ui/StackedAreaChart/StackedAreaChart.helpers.d.ts +10 -3
- package/dist/esm/types/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.d.ts +1 -1
- package/dist/esm/types/src/components/ui/StackedAreaChart/StackedAreaChart.types.d.ts +9 -0
- package/dist/esm/types/src/components/ui/TimeRangeControls/TimeRangeControls.d.ts +7 -1
- package/dist/esm/types/src/components/ui/Toggle/Toggle.types.d.ts +1 -1
- package/dist/esm/types/src/components/ui/ToggleGroup/ToggleGroup.helpers.d.ts +2 -2
- package/dist/esm/types/src/components/ui/ToggleGroup/ToggleGroup.types.d.ts +3 -3
- package/dist/esm/types/tests/viewChartGaps.test.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/ui/BarChart/AGENT.md +4 -0
- package/src/components/ui/BarChart/BarChart.styl.d.ts +1 -1
- package/src/components/ui/BarChart/BarChart.tsx +107 -21
- package/src/components/ui/BarChart/BarChart.types.ts +22 -0
- package/src/components/ui/Chart/AGENT.md +3 -0
- package/src/components/ui/Chart/chartForecastVisualization.types.ts +5 -0
- package/src/components/ui/Chart/components/BaseChartWrapper.styl +5 -0
- package/src/components/ui/Chart/components/BaseChartWrapper.styl.d.ts +1 -0
- package/src/components/ui/Chart/components/BaseChartWrapper.tsx +124 -5
- package/src/components/ui/Chart/components/ChartAxes.tsx +29 -5
- package/src/components/ui/Chart/components/ChartTooltipContent.tsx +6 -3
- package/src/components/ui/Chart/components/QuantileBands.tsx +1 -0
- package/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.styl +34 -0
- package/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.styl.d.ts +12 -0
- package/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.tsx +70 -0
- package/src/components/ui/Chart/components/SeriesLegend/index.ts +1 -0
- package/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.styl +5 -0
- package/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.styl.d.ts +1 -0
- package/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.tsx +7 -1
- package/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.types.ts +7 -0
- package/src/components/ui/ChartAreaInteractive/ChartLines.tsx +110 -40
- package/src/components/ui/ChartAreaInteractive/chartHistories.ts +5 -0
- package/src/components/ui/StackedAreaChart/AGENT.md +1 -0
- package/src/components/ui/StackedAreaChart/StackedAreaChart.helpers.ts +54 -13
- package/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.tsx +1 -1
- package/src/components/ui/StackedAreaChart/StackedAreaChart.tsx +36 -12
- package/src/components/ui/StackedAreaChart/StackedAreaChart.types.ts +9 -0
- package/src/components/ui/TimeRangeControls/AGENT.md +1 -1
- package/src/components/ui/TimeRangeControls/TimeRangeControls.test.tsx +21 -0
- package/src/components/ui/TimeRangeControls/TimeRangeControls.tsx +13 -2
- package/src/components/ui/Toggle/Toggle.styl +24 -0
- package/src/components/ui/Toggle/Toggle.styl.d.ts +1 -0
- package/src/components/ui/Toggle/Toggle.types.ts +1 -1
- package/src/components/ui/ToggleGroup/AGENT.md +1 -0
- package/src/components/ui/ToggleGroup/ToggleGroup.helpers.ts +2 -2
- package/src/components/ui/ToggleGroup/ToggleGroup.styl +8 -0
- package/src/components/ui/ToggleGroup/ToggleGroup.tsx +1 -0
- package/src/components/ui/ToggleGroup/ToggleGroup.types.ts +3 -3
- package/src/docs/pages/ChartAreaInteractivePage.tsx +34 -0
- package/src/docs/pages/TimeRangeControlsPage.tsx +9 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { forwardRef, useMemo } from 'react';
|
|
4
|
-
import { ChartTooltip } from '../Chart/Chart.js';
|
|
5
4
|
import ChartS from '../Chart/Chart.styl.js';
|
|
6
5
|
import { getChartSeriesColor } from '../Chart/chartSeriesPalette.js';
|
|
6
|
+
import { ChartContainer } from '../Chart/components/ChartContainer.js';
|
|
7
|
+
import { ChartPlacedTooltip } from '../Chart/components/ChartPlacedTooltip.js';
|
|
7
8
|
import { useLegendState } from '../Chart/hooks/useLegendState.js';
|
|
8
|
-
import { ComposedChart, CartesianGrid, XAxis, YAxis, ReferenceArea, Bar, Area, Line } from 'recharts';
|
|
9
|
-
import { stackRows, stackWeights, valueAxis, chartTop, yearTicks, MARGIN_KEY, yearLabel, compareRowZones, compareZones } from './StackedAreaChart.helpers.js';
|
|
9
|
+
import { ComposedChart, CartesianGrid, XAxis, Label, YAxis, ReferenceArea, Bar, Area, Line } from 'recharts';
|
|
10
|
+
import { stackRows, stackWeights, valueAxis, chartBottom, chartTop, yearTicks, MARGIN_KEY, yearLabel, compareRowZones, compareZones } from './StackedAreaChart.helpers.js';
|
|
10
11
|
import S from './StackedAreaChart.styl.js';
|
|
11
12
|
import { StackedTooltip } from './StackedAreaChart.tooltip.js';
|
|
12
|
-
import { ChartContainer } from '../Chart/components/ChartContainer.js';
|
|
13
13
|
|
|
14
14
|
const STACK_ID = 'stack';
|
|
15
15
|
const DEFAULT_BARS_BELOW = 3;
|
|
@@ -32,13 +32,15 @@ const splitKeys = (joined) => joined.split(KEY_SEP).slice(1);
|
|
|
32
32
|
*/
|
|
33
33
|
const ZONE_Z_INDEX = 50;
|
|
34
34
|
const AXIS_LINE = { stroke: 'var(--border)', strokeWidth: 1 };
|
|
35
|
+
/** Room for an x-axis title under the ticks (recharts' default is 30). */
|
|
36
|
+
const X_AXIS_HEIGHT_WITH_LABEL = 44;
|
|
35
37
|
const layerColor = (layer, index) => layer.color ?? getChartSeriesColor(index);
|
|
36
38
|
const overlayColor = (overlay) => overlay.color ?? DEFAULT_OVERLAY_COLOR;
|
|
37
39
|
function LegendEntry({ swatch, label, extra, dimmed, onClick, }) {
|
|
38
40
|
const content = (jsxs(Fragment, { children: [swatch, label, extra != null && jsx("span", { className: S.legendExtra, children: extra })] }));
|
|
39
41
|
return onClick ? (jsx("button", { type: "button", className: cn(ChartS.legendItem, S.legendButton, dimmed && S.dimmed), "aria-pressed": !dimmed, onClick: onClick, children: content })) : (jsx("span", { className: ChartS.legendItem, children: content }));
|
|
40
42
|
}
|
|
41
|
-
const StackedAreaChart = forwardRef(({ className, data, xKey, layers, overlays = NO_OVERLAYS, margin, showWeights = true, yearTicks: yearTicks$1 = false, barsBelow = DEFAULT_BARS_BELOW, zoneLabels = DEFAULT_ZONE_LABELS, hiddenKeys, onToggleKey, showLegend = true, showTooltip = true, showGrid = true, valueFormatter, xTickFormatter, tooltipLabelFormatter, height, ...props }, ref) => {
|
|
43
|
+
const StackedAreaChart = forwardRef(({ className, data, xKey, layers, overlays = NO_OVERLAYS, margin, showWeights = true, yearTicks: yearTicks$1 = false, barsBelow = DEFAULT_BARS_BELOW, zoneLabels = DEFAULT_ZONE_LABELS, hiddenKeys, onToggleKey, showLegend = true, showTooltip = true, showGrid = true, valueFormatter, tooltipValueFormatter = valueFormatter, xTickFormatter, tooltipLabelFormatter, xAxisLabel, yAxisLabel, height, ...props }, ref) => {
|
|
42
44
|
const legend = useLegendState();
|
|
43
45
|
const hidden = hiddenKeys ?? legend.hiddenSeries;
|
|
44
46
|
// With hiddenKeys and no onToggleKey nothing can change visibility, so
|
|
@@ -76,7 +78,10 @@ const StackedAreaChart = forwardRef(({ className, data, xKey, layers, overlays =
|
|
|
76
78
|
}, [zonesOn, compareKey, asBars, rows, xKey, visibleKeys]);
|
|
77
79
|
const zoneKinds = ['above', 'below'].filter(kind => zones.some(zone => zone.kind === kind));
|
|
78
80
|
const visibleLinesJoined = joinKeys(overlays.filter(o => !hidden.has(o.key)).map(o => o.key));
|
|
79
|
-
const yAxis = useMemo(() =>
|
|
81
|
+
const yAxis = useMemo(() => {
|
|
82
|
+
const lines = splitKeys(visibleLinesJoined);
|
|
83
|
+
return valueAxis(chartTop(rows, visibleKeys, lines), undefined, undefined, chartBottom(rows, visibleKeys, lines));
|
|
84
|
+
}, [rows, visibleKeys, visibleLinesJoined]);
|
|
80
85
|
const ticks = useMemo(() => (yearTicks$1 ? yearTicks(data, xKey) : undefined), [yearTicks$1, data, xKey]);
|
|
81
86
|
const config = useMemo(() => {
|
|
82
87
|
const out = {};
|
|
@@ -104,13 +109,15 @@ const StackedAreaChart = forwardRef(({ className, data, xKey, layers, overlays =
|
|
|
104
109
|
return (jsxs("div", { ref: ref, className: cn(S.root, className), ...props, children: [jsx(ChartContainer, { config: config, style: height ? { height: `${height}px` } : undefined, children: jsxs(ComposedChart, { data: rows, accessibilityLayer: true, children: [showGrid && (jsx(CartesianGrid, { stroke: "var(--border)", strokeWidth: 0.6, vertical: false })), jsx(XAxis, { dataKey: xKey,
|
|
105
110
|
// A point scale runs the areas edge to edge and starts and ends
|
|
106
111
|
// each zone on its rows; bars keep a band each.
|
|
107
|
-
scale: asBars ? 'auto' : 'point', ticks: ticks, tickFormatter: ticks ? yearLabel : xTickFormatter, minTickGap: ticks ? 8 : 24, tickLine: false, axisLine: AXIS_LINE }), jsx(YAxis
|
|
112
|
+
scale: asBars ? 'auto' : 'point', ticks: ticks, tickFormatter: ticks ? yearLabel : xTickFormatter, minTickGap: ticks ? 8 : 24, tickLine: false, axisLine: AXIS_LINE, height: xAxisLabel ? X_AXIS_HEIGHT_WITH_LABEL : undefined, children: xAxisLabel && (jsx(Label, { value: xAxisLabel, position: "insideBottom", offset: 0 })) }), jsx(YAxis
|
|
108
113
|
// Our own steps: automatic rounding can double the axis when the
|
|
109
114
|
// margin nudges the top past a round number.
|
|
110
115
|
, {
|
|
111
116
|
// Our own steps: automatic rounding can double the axis when the
|
|
112
117
|
// margin nudges the top past a round number.
|
|
113
|
-
domain: [0, yAxis.max], ticks: yAxis.ticks, allowDataOverflow: true, tickFormatter: valueFormatter,
|
|
118
|
+
domain: [yAxis.min ?? 0, yAxis.max], ticks: yAxis.ticks, allowDataOverflow: true, tickFormatter: valueFormatter,
|
|
119
|
+
// Room for the rotated title beside the ticks.
|
|
120
|
+
width: yAxisLabel ? 72 : 56, tickLine: false, axisLine: AXIS_LINE, children: yAxisLabel && (jsx(Label, { value: yAxisLabel, angle: -90, position: "insideLeft" })) }), showTooltip && (jsx(ChartPlacedTooltip, { content: tooltip => (jsx(StackedTooltip, { active: tooltip.active, payload: tooltip.payload, label: tooltip.label, config: config, valueFormatter: tooltipValueFormatter, labelFormatter: tooltipLabelFormatter })) })), zones.map(zone => (jsx(ReferenceArea, { x1: zone.x1, x2: zone.x2, fill: ZONE_FILL[zone.kind], fillOpacity: 1, stroke: "none", ifOverflow: "hidden", zIndex: ZONE_Z_INDEX }, `${zone.kind}-${String(zone.x1)}`))), layers.map((layer, index) => asBars ? (jsx(Bar, { dataKey: layer.key, name: layer.key, fill: layerColor(layer, index), maxBarSize: 96, hide: hidden.has(layer.key), ...stackProps }, layer.key)) : (jsx(Area, { type: "monotone", dataKey: layer.key, name: layer.key, fill: layerColor(layer, index), fillOpacity: 1, hide: hidden.has(layer.key), ...stackProps }, layer.key))), margin &&
|
|
114
121
|
(asBars ? (jsx(Bar, { dataKey: MARGIN_KEY, name: MARGIN_KEY, fill: marginColor, maxBarSize: 96, hide: !marginOn, ...stackProps }, MARGIN_KEY)) : (jsx(Area, { type: "monotone", dataKey: MARGIN_KEY, name: MARGIN_KEY, fill: marginColor, fillOpacity: 1, hide: !marginOn, ...stackProps }, MARGIN_KEY))), overlays.map(overlay => {
|
|
115
122
|
const color = overlayColor(overlay);
|
|
116
123
|
return (jsx(Line, { type: "linear", dataKey: overlay.key, name: overlay.key, stroke: color, strokeWidth: 1.75, dot: asBars ? { r: 4, fill: color, stroke: color } : false, activeDot: false, connectNulls: true, isAnimationActive: false, hide: hidden.has(overlay.key) }, overlay.key));
|
|
@@ -26,7 +26,7 @@ TimeRangeSelect.displayName = 'TimeRangeSelect';
|
|
|
26
26
|
* The preset ranges as a toggle row from 768px up, and as a select below it
|
|
27
27
|
* (CSS shows one of the two), so the control stays on a phone.
|
|
28
28
|
*/
|
|
29
|
-
const TimeRangeControls = memo(({ timeRange, onTimeRangeChange, loading }) => (jsxs("div", { className: S.timeRangeContainer, children: [jsx(ToggleGroup, { type: "single", value: toggleValueForTimeRange(timeRange), onValueChange: onTimeRangeChange, variant:
|
|
29
|
+
const TimeRangeControls = memo(({ timeRange, onTimeRangeChange, loading, variant = 'default', }) => (jsxs("div", { className: S.timeRangeContainer, children: [jsx(ToggleGroup, { type: "single", value: toggleValueForTimeRange(timeRange), onValueChange: onTimeRangeChange, variant: variant === 'segmented' ? 'segmented' : 'outline', disabled: loading, className: S.timeRangeToggleGroup, children: TIME_RANGES.map(range => (jsx(ToggleGroupItem, { value: range, className: S.timeRangeToggleItem, children: range }, range))) }), jsx(TimeRangeSelect, { timeRange: timeRange, onTimeRangeChange: onTimeRangeChange, loading: loading })] })));
|
|
30
30
|
TimeRangeControls.displayName = 'TimeRangeControls';
|
|
31
31
|
|
|
32
32
|
export { TimeRangeControls, TimeRangeSelect };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styleInject from 'style-inject';
|
|
2
2
|
|
|
3
|
-
var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.Toggle_toggle__zrQdU{align-items:center;background-color:transparent;color:var(--muted-foreground);cursor:pointer;display:inline-flex;font-size:var(--text-sm);font-weight:600;gap:.5rem;justify-content:center;transition:all .15s ease-in-out;white-space:nowrap}.Toggle_toggle__zrQdU:hover{background-color:var(--muted-80);color:var(--muted-foreground)}.Toggle_toggle__zrQdU:disabled{opacity:.5;pointer-events:none}.Toggle_toggle__zrQdU[data-state=on]{background-color:var(--background);box-shadow:0 1px 2px 0 rgba(0,0,0,.05);color:var(--foreground)}.Toggle_toggle__zrQdU svg{flex-shrink:0;pointer-events:none}.Toggle_toggle__zrQdU svg:not([class*=size-]){height:1rem;width:1rem}.Toggle_toggle__zrQdU:focus-visible:not(:disabled):not([data-disabled]){outline:2px solid var(--focus-outline-color,var(--ring));outline:var(--focus-outline-width,2px) solid var(--focus-outline-color,var(--ring));outline-offset:2px;outline-offset:var(--focus-outline-offset,2px)}.Toggle_toggle__zrQdU[aria-invalid=true]{border-color:var(--destructive);box-shadow:0 0 0 3px var(--destructive-20)}.dark .Toggle_toggle__zrQdU[aria-invalid=true]{box-shadow:0 0 0 3px var(--destructive-40)}.Toggle_variant-default__n4-yB{border-radius:.375rem}.Toggle_variant-outline__J4zWJ{background-color:transparent;border:none}.Toggle_variant-outline__J4zWJ:hover{color:var(--foreground)}.Toggle_variant-outline__J4zWJ[data-state=on]{background-color:var(--background);color:var(--foreground)}.Toggle_size-md__llTAJ,.Toggle_size-sm__hODTn{border-radius:.375rem;height:1.75rem;padding-left:.75rem;padding-right:.75rem}.Toggle_size-lg__Y6-g6{border-radius:.5rem;height:2rem;padding-left:.875rem;padding-right:.875rem}";
|
|
4
|
-
var S = {"toggle":"Toggle_toggle__zrQdU","variant-default":"Toggle_variant-default__n4-yB","variant-outline":"Toggle_variant-outline__J4zWJ","size-sm":"Toggle_size-sm__hODTn","size-md":"Toggle_size-md__llTAJ","size-lg":"Toggle_size-lg__Y6-g6"};
|
|
3
|
+
var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.Toggle_toggle__zrQdU{align-items:center;background-color:transparent;color:var(--muted-foreground);cursor:pointer;display:inline-flex;font-size:var(--text-sm);font-weight:600;gap:.5rem;justify-content:center;transition:all .15s ease-in-out;white-space:nowrap}.Toggle_toggle__zrQdU:hover{background-color:var(--muted-80);color:var(--muted-foreground)}.Toggle_toggle__zrQdU:disabled{opacity:.5;pointer-events:none}.Toggle_toggle__zrQdU[data-state=on]{background-color:var(--background);box-shadow:0 1px 2px 0 rgba(0,0,0,.05);color:var(--foreground)}.Toggle_toggle__zrQdU svg{flex-shrink:0;pointer-events:none}.Toggle_toggle__zrQdU svg:not([class*=size-]){height:1rem;width:1rem}.Toggle_toggle__zrQdU:focus-visible:not(:disabled):not([data-disabled]){outline:2px solid var(--focus-outline-color,var(--ring));outline:var(--focus-outline-width,2px) solid var(--focus-outline-color,var(--ring));outline-offset:2px;outline-offset:var(--focus-outline-offset,2px)}.Toggle_toggle__zrQdU[aria-invalid=true]{border-color:var(--destructive);box-shadow:0 0 0 3px var(--destructive-20)}.dark .Toggle_toggle__zrQdU[aria-invalid=true]{box-shadow:0 0 0 3px var(--destructive-40)}.Toggle_variant-default__n4-yB{border-radius:.375rem}.Toggle_variant-outline__J4zWJ{background-color:transparent;border:none}.Toggle_variant-outline__J4zWJ:hover{color:var(--foreground)}.Toggle_variant-outline__J4zWJ[data-state=on]{background-color:var(--background);color:var(--foreground)}.Toggle_toggle__zrQdU.Toggle_variant-segmented__V36EN{background-color:transparent;border:none;border-radius:6px;color:var(--muted-foreground);font-size:var(--text-xs);font-weight:400;height:auto;line-height:1.4;padding:4px 10px}.Toggle_toggle__zrQdU.Toggle_variant-segmented__V36EN:hover{background-color:transparent;color:var(--foreground)}.Toggle_toggle__zrQdU.Toggle_variant-segmented__V36EN[data-state=on]{background-color:var(--background);border-radius:6px;box-shadow:0 1px 2px 0 rgba(0,0,0,.08);color:var(--foreground)}.Toggle_size-md__llTAJ,.Toggle_size-sm__hODTn{border-radius:.375rem;height:1.75rem;padding-left:.75rem;padding-right:.75rem}.Toggle_size-lg__Y6-g6{border-radius:.5rem;height:2rem;padding-left:.875rem;padding-right:.875rem}";
|
|
4
|
+
var S = {"toggle":"Toggle_toggle__zrQdU","variant-default":"Toggle_variant-default__n4-yB","variant-outline":"Toggle_variant-outline__J4zWJ","variant-segmented":"Toggle_variant-segmented__V36EN","size-sm":"Toggle_size-sm__hODTn","size-md":"Toggle_size-md__llTAJ","size-lg":"Toggle_size-lg__Y6-g6"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
7
7
|
export { S as default };
|
|
@@ -8,7 +8,7 @@ import S from './ToggleGroup.styl.js';
|
|
|
8
8
|
|
|
9
9
|
const ToggleGroupContext = createContext(getDefaultContextValues());
|
|
10
10
|
function ToggleGroup({ className, variant, size, children, disabled, ...props }) {
|
|
11
|
-
return (jsx(ToggleGroupPrimitive.Root, { "data-slot": "toggle-group", "data-disabled": disabled ? '' : undefined, className: cn(S.container, className), ...props, children: jsx(ToggleGroupContext.Provider, { value: { variant, size }, children: children }) }));
|
|
11
|
+
return (jsx(ToggleGroupPrimitive.Root, { "data-slot": "toggle-group", "data-variant": variant, "data-disabled": disabled ? '' : undefined, className: cn(S.container, className), ...props, children: jsx(ToggleGroupContext.Provider, { value: { variant, size }, children: children }) }));
|
|
12
12
|
}
|
|
13
13
|
function ToggleGroupItem({ className, children, variant, size, ...props }) {
|
|
14
14
|
const context = useContext(ToggleGroupContext);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styleInject from 'style-inject';
|
|
2
2
|
|
|
3
|
-
var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.ToggleGroup_container__HKgJE{align-items:center;border-radius:var(--p-6);display:flex;font-weight:600;gap:var(--p-1);transition:opacity .1s ease-out;width:-moz-fit-content;width:fit-content}.ToggleGroup_container__HKgJE[data-disabled]{opacity:.5;pointer-events:none}.ToggleGroup_item__Jz9yW{border:none;border-radius:var(--p-4);box-shadow:none;color:var(--muted-foreground);flex-shrink:0;transition:all .15s ease-in-out}.ToggleGroup_item__Jz9yW:focus{z-index:10}.ToggleGroup_item__Jz9yW:focus-visible:not(:disabled):not([data-disabled]){outline:2px solid var(--focus-outline-color,var(--ring));outline:var(--focus-outline-width,2px) solid var(--focus-outline-color,var(--ring));outline-offset:2px;outline-offset:var(--focus-outline-offset,2px)}.ToggleGroup_item__Jz9yW:focus-visible{z-index:10}.ToggleGroup_item__Jz9yW[data-state=on]{border-radius:var(--p-6);color:var(--foreground)}.ToggleGroup_item__Jz9yW[data-disabled]{opacity:.5;pointer-events:none}";
|
|
3
|
+
var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.ToggleGroup_container__HKgJE{align-items:center;border-radius:var(--p-6);display:flex;font-weight:600;gap:var(--p-1);transition:opacity .1s ease-out;width:-moz-fit-content;width:fit-content}.ToggleGroup_container__HKgJE[data-disabled]{opacity:.5;pointer-events:none}.ToggleGroup_container__HKgJE[data-variant=segmented]{background-color:var(--sb-slate-100);border-radius:8px;font-weight:400;gap:2px;padding:2px}.ToggleGroup_item__Jz9yW{border:none;border-radius:var(--p-4);box-shadow:none;color:var(--muted-foreground);flex-shrink:0;transition:all .15s ease-in-out}.ToggleGroup_item__Jz9yW:focus{z-index:10}.ToggleGroup_item__Jz9yW:focus-visible:not(:disabled):not([data-disabled]){outline:2px solid var(--focus-outline-color,var(--ring));outline:var(--focus-outline-width,2px) solid var(--focus-outline-color,var(--ring));outline-offset:2px;outline-offset:var(--focus-outline-offset,2px)}.ToggleGroup_item__Jz9yW:focus-visible{z-index:10}.ToggleGroup_item__Jz9yW[data-state=on]{border-radius:var(--p-6);color:var(--foreground)}.ToggleGroup_item__Jz9yW[data-disabled]{opacity:.5;pointer-events:none}";
|
|
4
4
|
var S = {"container":"ToggleGroup_container__HKgJE","item":"ToggleGroup_item__Jz9yW"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
@@ -23,6 +23,28 @@ export interface BarChartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'chi
|
|
|
23
23
|
showGrid?: boolean;
|
|
24
24
|
/** Formats numeric axis tick values. */
|
|
25
25
|
valueFormatter?: (value: number) => string;
|
|
26
|
+
/** Formats the tooltip's values (for example with a unit); without it they print as they are. */
|
|
27
|
+
tooltipValueFormatter?: (value: number) => string;
|
|
28
|
+
/** Formats the category axis's ticks. */
|
|
29
|
+
categoryTickFormatter?: (value: string | number) => string;
|
|
30
|
+
/** Formats the tooltip's category label. */
|
|
31
|
+
tooltipLabelFormatter?: (value: string | number) => string;
|
|
32
|
+
/** Title of the category axis. */
|
|
33
|
+
categoryAxisLabel?: string;
|
|
34
|
+
/** Title of the value axis. */
|
|
35
|
+
valueAxisLabel?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Keys of hidden series. With it, the host owns visibility; without it
|
|
38
|
+
* (and with onToggleKey) the chart keeps the hidden set itself.
|
|
39
|
+
*/
|
|
40
|
+
hiddenKeys?: ReadonlySet<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Called with a series key when its legend entry is clicked. Without it the
|
|
43
|
+
* legend is plain text.
|
|
44
|
+
*/
|
|
45
|
+
onToggleKey?: (key: string) => void;
|
|
26
46
|
/** Fixed chart height in px; defaults to a 16:9 responsive box. */
|
|
27
47
|
height?: number;
|
|
48
|
+
/** Draw the bars at once, without the grow-in animation. */
|
|
49
|
+
disableAnimation?: boolean;
|
|
28
50
|
}
|
|
@@ -83,6 +83,11 @@ export interface QuantileBandConfig {
|
|
|
83
83
|
strokeOpacity?: number;
|
|
84
84
|
type?: 'monotone' | 'linear' | 'step' | 'stepBefore' | 'stepAfter' | 'basis' | 'natural';
|
|
85
85
|
fillPattern?: 'solid' | 'dots' | 'lines';
|
|
86
|
+
/**
|
|
87
|
+
* List the range in the tooltip (default true). Read by the Recharts charts'
|
|
88
|
+
* bands (BaseChartWrapper, ChartAreaInteractive's default mode).
|
|
89
|
+
*/
|
|
90
|
+
showInTooltip?: boolean;
|
|
86
91
|
/**
|
|
87
92
|
* Fill across months with no range (default true). Read by the Recharts
|
|
88
93
|
* charts' bands (BaseChartWrapper, ChartAreaInteractive's default mode),
|
|
@@ -53,6 +53,12 @@ export interface BaseChartWrapperProps {
|
|
|
53
53
|
historyOnTop?: boolean;
|
|
54
54
|
/** Mark each line's last point with a dot (default: on). */
|
|
55
55
|
showEndDots?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Dot a point a line would leave invisible, so it still shows: with no
|
|
58
|
+
* value on either side on a line not drawn across gaps, or a line's only
|
|
59
|
+
* value on one drawn across them (default: off).
|
|
60
|
+
*/
|
|
61
|
+
dotLonePoints?: boolean;
|
|
56
62
|
formatDate?: (value: string, detailed?: boolean) => string;
|
|
57
63
|
labelFormatter?: (value: unknown) => string;
|
|
58
64
|
onLegendClick?: (data: LegendPayload, index: number, event: any) => void;
|
|
@@ -81,6 +87,13 @@ export interface BaseChartWrapperProps {
|
|
|
81
87
|
showChartAxesLegend?: boolean;
|
|
82
88
|
xAxisLabel?: string;
|
|
83
89
|
yAxisLabel?: string;
|
|
90
|
+
/**
|
|
91
|
+
* `category` (default) gives every row one slot; `number` places the rows
|
|
92
|
+
* by their `date` read as a number (`'12.5'`), spaced by value.
|
|
93
|
+
*/
|
|
94
|
+
xAxisType?: 'category' | 'number';
|
|
95
|
+
/** The x values to label (for example the first day of each month). */
|
|
96
|
+
xTicks?: ReadonlyArray<string | number>;
|
|
84
97
|
showActiveDots?: boolean;
|
|
85
98
|
overlayElements?: ReactNode;
|
|
86
99
|
hiddenSeries?: Set<string>;
|
|
@@ -91,7 +104,15 @@ export interface BaseChartWrapperProps {
|
|
|
91
104
|
onFailedAnalysisClick?: (analysisId?: number | string) => void;
|
|
92
105
|
maxVisibleItems?: number;
|
|
93
106
|
preventDeselection?: boolean;
|
|
94
|
-
|
|
107
|
+
/**
|
|
108
|
+
* `default`: the analyses legend (forecast icons, +N overflow, latest
|
|
109
|
+
* first). `svg`: drawn into the chart for export. `plain`: one entry per
|
|
110
|
+
* line, in `legendOrder` (else histories then forecasts), each a button
|
|
111
|
+
* that hides or shows it through `onLegendClick`.
|
|
112
|
+
*/
|
|
113
|
+
legendVariant?: 'default' | 'svg' | 'plain';
|
|
114
|
+
/** With `legendVariant="plain"`: the lines' data keys in legend order. */
|
|
115
|
+
legendOrder?: string[];
|
|
95
116
|
legendWidth?: number;
|
|
96
117
|
legendMarginLeft?: number;
|
|
97
118
|
containerProps?: Omit<ComponentProps<typeof ChartContainer>, 'config' | 'className' | 'children'>;
|
|
@@ -111,8 +132,4 @@ export interface BaseChartWrapperProps {
|
|
|
111
132
|
/** Isolate a single series by data key; `allDataKeys` lists every toggleable key. */
|
|
112
133
|
onShowOnly?: (dataKey: string, allDataKeys: string[]) => void;
|
|
113
134
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Base chart wrapper component with common structure
|
|
116
|
-
* Handles container, grid, axes, tooltip, and legend
|
|
117
|
-
*/
|
|
118
135
|
export declare function BaseChartWrapper(props: BaseChartWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,6 +10,13 @@ interface ChartAxesProps {
|
|
|
10
10
|
yMin?: number;
|
|
11
11
|
yMax?: number;
|
|
12
12
|
autoScaleYAxis?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* `category` (default) gives every row one slot; `number` places the rows
|
|
15
|
+
* by their `date` read as a number, from the smallest to the largest.
|
|
16
|
+
*/
|
|
17
|
+
xAxisType?: 'category' | 'number';
|
|
18
|
+
/** The x values to label; without it recharts picks them. */
|
|
19
|
+
xTicks?: ReadonlyArray<string | number>;
|
|
13
20
|
/**
|
|
14
21
|
* Draw no axes. A hidden x-axis is kept, so the tooltip still names the
|
|
15
22
|
* row's date. The y-axis keeps fixed `yMin`/`yMax` (with `autoScaleYAxis`
|
|
@@ -18,5 +25,5 @@ interface ChartAxesProps {
|
|
|
18
25
|
*/
|
|
19
26
|
hide?: boolean;
|
|
20
27
|
}
|
|
21
|
-
export declare function ChartAxes({ xAxisClassName, yAxisClassName, xAxisLabel, yAxisLabel, formatDate, formatNumber, xMin, xMax, yMin, yMax, autoScaleYAxis, hide, }: ChartAxesProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function ChartAxes({ xAxisClassName, yAxisClassName, xAxisLabel, yAxisLabel, formatDate, formatNumber, xMin, xMax, yMin, yMax, autoScaleYAxis, xAxisType, xTicks, hide, }: ChartAxesProps): import("react/jsx-runtime").JSX.Element;
|
|
22
29
|
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type SeriesLegendItem = {
|
|
3
|
+
/** The series' data key; the legend hands it back on a click. */
|
|
4
|
+
dataKey: string;
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
color: string;
|
|
7
|
+
/** Draw the swatch as a dashed line (a forecast line). */
|
|
8
|
+
dashed?: boolean;
|
|
9
|
+
/** Draw the swatch as a filled square (a bar or an area) instead of a line. */
|
|
10
|
+
square?: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A plain legend: one entry per series, in the order given, each a button
|
|
14
|
+
* that hides or shows its series. A hidden series' entry is dimmed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function SeriesLegend({ items, hiddenSeries, onToggle, className, }: {
|
|
17
|
+
items: SeriesLegendItem[];
|
|
18
|
+
hiddenSeries?: ReadonlySet<string>;
|
|
19
|
+
/** Without it the entries are text, not buttons. */
|
|
20
|
+
onToggle?: (dataKey: string) => void;
|
|
21
|
+
className?: string;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SeriesLegend, type SeriesLegendItem } from './SeriesLegend';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ChartAreaInteractiveProps } from './ChartAreaInteractive.types';
|
|
2
2
|
export declare const chartConfig: {};
|
|
3
|
-
export declare function ChartAreaInteractive({ className, chartContainerClassName, legendClassName, xAxisClassName, yAxisClassName, timeRange, onTimeRangeChange, pinMonth, onPinMonthChange, onPreviewMonthChange, chartData, forecastData, historyData, error, loading, isDarkTheme, footerActions, mode, selectedForecast, upperQuantiles, lowerQuantiles, selectedLowerQuantile, selectedUpperQuantile, onLowerQuantileChange, onUpperQuantileChange, lowerThreshold, upperThreshold, onLowerThresholdChange, onUpperThresholdChange, discreteThresholdValues, headerActions, excludeLegendIds, loadingAnalyses, onLegendClick, onAnalysisSelect, disableTimeRangeSelector, enableTimeRangeBrush, forecastLineStyle, selectedAnalysisId, chartRenderId, toggleLegendSeries, ensureAnalysisSeriesVisible, overlayForecastData, hiddenSeries, disableForecastHistoricalBridge, overlayElements: overlayElementsProp, ...restProps }: ChartAreaInteractiveProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function ChartAreaInteractive({ className, chartContainerClassName, legendClassName, xAxisClassName, yAxisClassName, timeRange, onTimeRangeChange, pinMonth, onPinMonthChange, onPreviewMonthChange, chartData, forecastData, historyData, error, loading, isDarkTheme, footerActions, mode, selectedForecast, upperQuantiles, lowerQuantiles, selectedLowerQuantile, selectedUpperQuantile, onLowerQuantileChange, onUpperQuantileChange, lowerThreshold, upperThreshold, onLowerThresholdChange, onUpperThresholdChange, discreteThresholdValues, headerActions, headerTitle, timeRangeVariant, excludeLegendIds, loadingAnalyses, onLegendClick, onAnalysisSelect, disableTimeRangeSelector, enableTimeRangeBrush, forecastLineStyle, selectedAnalysisId, chartRenderId, toggleLegendSeries, ensureAnalysisSeriesVisible, overlayForecastData, hiddenSeries, disableForecastHistoricalBridge, overlayElements: overlayElementsProp, ...restProps }: ChartAreaInteractiveProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.types.d.ts
CHANGED
|
@@ -44,6 +44,13 @@ export interface ChartAreaInteractiveProps extends BaseChartWrapperProps {
|
|
|
44
44
|
upper: number[];
|
|
45
45
|
};
|
|
46
46
|
headerActions?: React.ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* Shown at the start of the header row, before the time range control,
|
|
49
|
+
* which then sits at the row's end (e.g. a one-line summary of the chart).
|
|
50
|
+
*/
|
|
51
|
+
headerTitle?: React.ReactNode;
|
|
52
|
+
/** The time range control's look (`TimeRangeControls` `variant`). */
|
|
53
|
+
timeRangeVariant?: 'default' | 'segmented';
|
|
47
54
|
loadingAnalyses?: Set<string>;
|
|
48
55
|
onLegendClick?: (data: LegendPayload) => undefined | boolean;
|
|
49
56
|
disableTimeRangeSelector?: boolean;
|
|
@@ -19,6 +19,11 @@ export type ForecastItemData = {
|
|
|
19
19
|
* histories, a forecast joins one only when this names it.
|
|
20
20
|
*/
|
|
21
21
|
continues?: string | number;
|
|
22
|
+
/**
|
|
23
|
+
* Draw this line across rows it has no value for. Without it the chart's
|
|
24
|
+
* `connectForecastNulls` decides.
|
|
25
|
+
*/
|
|
26
|
+
connectNulls?: boolean;
|
|
22
27
|
};
|
|
23
28
|
export type Dot = {
|
|
24
29
|
x: number;
|
|
@@ -43,6 +48,8 @@ export type HistoryLine = {
|
|
|
43
48
|
dataKey: string;
|
|
44
49
|
name: string;
|
|
45
50
|
color: string;
|
|
51
|
+
/** The line's own `connectNulls`, when it sets one. */
|
|
52
|
+
connectNulls?: boolean;
|
|
46
53
|
};
|
|
47
54
|
/** Default colour of the history at `index`: the forecast palette from its far end. */
|
|
48
55
|
export declare function getHistoryColor(index: number): string;
|
|
@@ -50,7 +57,7 @@ export declare function getHistoryColor(index: number): string;
|
|
|
50
57
|
export declare function resolveHistoryLines(histories?: HistoryItemData[]): HistoryLine[];
|
|
51
58
|
/** Same tint logic as intervals/threshold overlays: band fill follows forecast line hex when known. */
|
|
52
59
|
export declare function resolveQuantileBandFillForForecastLine(lineColor: string, forecastIndex: number): string;
|
|
53
|
-
export declare const ChartLines: import("react").MemoExoticComponent<({ chartData, forecastData, historyData, hiddenSeries, isDarkTheme, shouldAnimate, historicalLineColor, showLegend, forecastLineStyle, disableAnimation, disableHistoricalAnimation, connectHistoryNulls, connectForecastNulls, historyOnTop, showEndDots, }: {
|
|
60
|
+
export declare const ChartLines: import("react").MemoExoticComponent<({ chartData, forecastData, historyData, hiddenSeries, isDarkTheme, shouldAnimate, historicalLineColor, showLegend, forecastLineStyle, disableAnimation, disableHistoricalAnimation, connectHistoryNulls, connectForecastNulls, historyOnTop, showEndDots, dotLonePoints, }: {
|
|
54
61
|
chartData: ChartDataPoint[];
|
|
55
62
|
forecastData?: ForecastItemData[];
|
|
56
63
|
/** Several history lines (one per product). Omit for the single `historical` line. */
|
|
@@ -74,4 +81,6 @@ export declare const ChartLines: import("react").MemoExoticComponent<({ chartDat
|
|
|
74
81
|
historyOnTop?: boolean;
|
|
75
82
|
/** Mark each line's last point with a dot (default: on). */
|
|
76
83
|
showEndDots?: boolean;
|
|
84
|
+
/** Dot a point a gapped line leaves alone (default: off). */
|
|
85
|
+
dotLonePoints?: boolean;
|
|
77
86
|
}) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -21,6 +21,11 @@ export type HistoryItemData = {
|
|
|
21
21
|
* colour to both.
|
|
22
22
|
*/
|
|
23
23
|
color?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Draw this line across rows it has no value for. Without it the chart's
|
|
26
|
+
* `connectHistoryNulls` decides.
|
|
27
|
+
*/
|
|
28
|
+
connectNulls?: boolean;
|
|
24
29
|
};
|
|
25
30
|
/** Data key of one history line in `chartData` rows. */
|
|
26
31
|
export declare function historySeriesKey(id: string | number): string;
|
|
@@ -48,13 +48,20 @@ export declare function compareRowZones(rows: readonly StackedAreaChartDatum[],
|
|
|
48
48
|
* A value axis from 0 for a top value: at most `maxIntervals` steps of
|
|
49
49
|
* 1, 2, 2.5 or 5 × 10ⁿ, with a little headroom above the top. Small changes
|
|
50
50
|
* in the top (a margin being typed) move the axis by one step at most,
|
|
51
|
-
* instead of doubling it the way automatic rounding can.
|
|
51
|
+
* instead of doubling it the way automatic rounding can. A `bottom` below 0
|
|
52
|
+
* (a negative layer or line) starts the axis at a step below it, as `min`.
|
|
52
53
|
*/
|
|
53
|
-
export declare function valueAxis(top: number, maxIntervals?: number, headroom?: number): {
|
|
54
|
+
export declare function valueAxis(top: number, maxIntervals?: number, headroom?: number, bottom?: number): {
|
|
55
|
+
min?: number;
|
|
54
56
|
max: number;
|
|
55
57
|
ticks: number[];
|
|
56
58
|
};
|
|
57
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* The lowest point the stack (a negative layer or margin pulls it below 0)
|
|
61
|
+
* or a line reaches; 0 when nothing is negative.
|
|
62
|
+
*/
|
|
63
|
+
export declare function chartBottom(rows: readonly StackedAreaChartDatum[], layerKeys: readonly string[], lineKeys: readonly string[]): number;
|
|
64
|
+
/** The highest point the stack (layers plus margin) or a line reaches. */
|
|
58
65
|
export declare function chartTop(rows: readonly StackedAreaChartDatum[], layerKeys: readonly string[], lineKeys: readonly string[]): number;
|
|
59
66
|
/**
|
|
60
67
|
* The x value of the first row in each year, when x values are date strings
|
|
@@ -76,6 +76,15 @@ export interface StackedAreaChartProps extends Omit<HTMLAttributes<HTMLDivElemen
|
|
|
76
76
|
showGrid?: boolean;
|
|
77
77
|
/** Formats numeric y-axis ticks and tooltip values. */
|
|
78
78
|
valueFormatter?: (value: number) => string;
|
|
79
|
+
/**
|
|
80
|
+
* Formats the tooltip's values (for example with a unit), when they should
|
|
81
|
+
* read differently from the axis. Defaults to `valueFormatter`.
|
|
82
|
+
*/
|
|
83
|
+
tooltipValueFormatter?: (value: number) => string;
|
|
84
|
+
/** Title under the x axis. */
|
|
85
|
+
xAxisLabel?: string;
|
|
86
|
+
/** Title along the y axis. */
|
|
87
|
+
yAxisLabel?: string;
|
|
79
88
|
/** Formats x-axis ticks (ignored for year ticks, which show the year). */
|
|
80
89
|
xTickFormatter?: (value: string | number) => string;
|
|
81
90
|
/** Formats the tooltip's x label. */
|
|
@@ -2,6 +2,12 @@ export type TimeRangeControlsProps = {
|
|
|
2
2
|
timeRange: string;
|
|
3
3
|
onTimeRangeChange: (range: string) => void;
|
|
4
4
|
loading?: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The toggle row's look: `default` (plain buttons) or `segmented` (small
|
|
7
|
+
* buttons on a grey track, the picked one raised). The select shown below
|
|
8
|
+
* 768px is the same either way.
|
|
9
|
+
*/
|
|
10
|
+
variant?: 'default' | 'segmented';
|
|
5
11
|
};
|
|
6
12
|
/**
|
|
7
13
|
* The preset ranges as a select. A range that is not a preset (one dragged on
|
|
@@ -12,4 +18,4 @@ export declare const TimeRangeSelect: import("react").MemoExoticComponent<({ tim
|
|
|
12
18
|
* The preset ranges as a toggle row from 768px up, and as a select below it
|
|
13
19
|
* (CSS shows one of the two), so the control stays on a phone.
|
|
14
20
|
*/
|
|
15
|
-
export declare const TimeRangeControls: import("react").MemoExoticComponent<({ timeRange, onTimeRangeChange, loading }: TimeRangeControlsProps) => import("react/jsx-runtime").JSX.Element>;
|
|
21
|
+
export declare const TimeRangeControls: import("react").MemoExoticComponent<({ timeRange, onTimeRangeChange, loading, variant, }: TimeRangeControlsProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -2,6 +2,6 @@ import type { ComponentProps } from 'react';
|
|
|
2
2
|
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
3
3
|
export interface ToggleProps extends ComponentProps<typeof TogglePrimitive.Root> {
|
|
4
4
|
className?: string;
|
|
5
|
-
variant?: 'default' | 'outline';
|
|
5
|
+
variant?: 'default' | 'outline' | 'segmented';
|
|
6
6
|
size?: 'sm' | 'md' | 'lg';
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ToggleGroupContextValue } from './ToggleGroup.types';
|
|
2
|
-
export declare const getContextValues: (context: ToggleGroupContextValue, itemVariant?: "default" | "outline", itemSize?: "sm" | "md" | "lg") => {
|
|
3
|
-
variant: "default" | "outline";
|
|
2
|
+
export declare const getContextValues: (context: ToggleGroupContextValue, itemVariant?: "default" | "outline" | "segmented", itemSize?: "sm" | "md" | "lg") => {
|
|
3
|
+
variant: "default" | "outline" | "segmented";
|
|
4
4
|
size: "sm" | "md" | "lg";
|
|
5
5
|
};
|
|
6
6
|
export declare const getDefaultContextValues: () => ToggleGroupContextValue;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export interface ToggleGroupContextValue {
|
|
2
2
|
size?: 'sm' | 'md' | 'lg';
|
|
3
|
-
variant?: 'default' | 'outline';
|
|
3
|
+
variant?: 'default' | 'outline' | 'segmented';
|
|
4
4
|
}
|
|
5
5
|
interface ToggleGroupBaseProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
6
6
|
size?: 'sm' | 'md' | 'lg';
|
|
7
|
-
variant?: 'default' | 'outline';
|
|
7
|
+
variant?: 'default' | 'outline' | 'segmented';
|
|
8
8
|
orientation?: 'horizontal' | 'vertical';
|
|
9
9
|
dir?: 'ltr' | 'rtl';
|
|
10
10
|
rovingFocus?: boolean;
|
|
@@ -27,6 +27,6 @@ export type ToggleGroupProps = ToggleGroupSingleProps | ToggleGroupMultipleProps
|
|
|
27
27
|
export interface ToggleGroupItemProps extends React.ComponentPropsWithoutRef<'button'> {
|
|
28
28
|
value: string;
|
|
29
29
|
size?: 'sm' | 'md' | 'lg';
|
|
30
|
-
variant?: 'default' | 'outline';
|
|
30
|
+
variant?: 'default' | 'outline' | 'segmented';
|
|
31
31
|
}
|
|
32
32
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
package/package.json
CHANGED
|
@@ -14,3 +14,7 @@ BarChart compares values across categories. Provide rows of data, a category key
|
|
|
14
14
|
## Do
|
|
15
15
|
|
|
16
16
|
- Start the value axis at zero so bar lengths stay proportional.
|
|
17
|
+
- Pass `valueFormatter` for the axis and `tooltipValueFormatter` for the tooltip (for example with a unit; without it the tooltip prints the raw value); `categoryTickFormatter` and `tooltipLabelFormatter` format the categories (dates, for instance).
|
|
18
|
+
- Name the axes with `categoryAxisLabel` and `valueAxisLabel`.
|
|
19
|
+
- The legend sits under the chart box (it adds its own height to `height`). It is plain text unless `onToggleKey` is passed; then a click hides or shows a series. Pass `hiddenKeys` too when the host must remember which are hidden.
|
|
20
|
+
- `disableAnimation` draws the bars at once (for a page that is exported or printed).
|