@galaxy-io/dls 1.3.6 → 1.4.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/dist/accordion/Accordion.js +2 -2
- package/dist/avatar/AvatarShimmer.d.ts +1 -1
- package/dist/buttons/Button.js +2 -2
- package/dist/charts/BarChart.js +18 -41
- package/dist/charts/ChartAxis.d.ts +2 -11
- package/dist/charts/ChartAxis.js +4 -5
- package/dist/charts/ChartFrame.js +1 -3
- package/dist/charts/ChartLegend.d.ts +1 -9
- package/dist/charts/ChartLegend.js +1 -27
- package/dist/charts/ChartPrimitives.d.ts +2 -15
- package/dist/charts/ChartPrimitives.js +48 -65
- package/dist/charts/ChartTooltip.js +4 -9
- package/dist/charts/LineChart.js +46 -67
- package/dist/charts/PieChart.js +19 -33
- package/dist/charts/constants.d.ts +0 -19
- package/dist/charts/constants.js +1 -78
- package/dist/charts/useChartInteraction.d.ts +11 -1
- package/dist/charts/useChartInteraction.js +7 -2
- package/dist/charts/useSeriesColorResolver.d.ts +0 -7
- package/dist/charts/useSeriesColorResolver.js +1 -2
- package/dist/dividers/HorizontalDivider.d.ts +4 -1
- package/dist/dividers/HorizontalDivider.js +28 -7
- package/dist/inputs/CopyInput.js +4 -1
- package/dist/inputs/Input.d.ts +1 -1
- package/dist/inputs/MultiSelectInput.js +3 -3
- package/dist/inputs/SelectInput.js +3 -3
- package/dist/inputs/SwitcherInput.d.ts +11 -0
- package/dist/inputs/SwitcherInput.js +41 -0
- package/dist/shapes/Square.d.ts +6 -0
- package/dist/shapes/Square.js +25 -0
- package/dist/styles.css +25 -26
- package/dist/table/SpreadsheetPrimitives.d.ts +6 -6
- package/dist/table/TablePrimitives.d.ts +6 -6
- package/dist/text/HotKeys.d.ts +20 -0
- package/dist/text/HotKeys.js +68 -0
- package/dist/toast/ToastProvider.js +1 -1
- package/dist/{animations → transform}/Fade.js +1 -1
- package/dist/transform/Flash.d.ts +3 -0
- package/dist/transform/Flash.js +14 -0
- package/dist/transform/Rotate.d.ts +8 -0
- package/dist/transform/Rotate.js +28 -0
- package/dist/{animations → transform}/ScaleFade.js +1 -1
- package/dist/transform/Spin.d.ts +7 -0
- package/dist/transform/Spin.js +20 -0
- package/package.json +4 -12
- package/dist/animations/Flashing.d.ts +0 -3
- package/dist/animations/Flashing.js +0 -14
- package/dist/animations/RotateWithTransition.d.ts +0 -8
- package/dist/animations/RotateWithTransition.js +0 -28
- package/dist/animations/SpinAnimation.d.ts +0 -7
- package/dist/animations/SpinAnimation.js +0 -20
- package/dist/animations/SpinVerticalAnimation.d.ts +0 -6
- package/dist/animations/SpinVerticalAnimation.js +0 -19
- package/dist/hotkeys/HotKeyBindings.d.ts +0 -7
- package/dist/hotkeys/HotKeyBindings.js +0 -23
- package/dist/hotkeys/HotKeySymbol.d.ts +0 -13
- package/dist/hotkeys/HotKeySymbol.js +0 -49
- package/dist/switcher/Switcher.d.ts +0 -11
- package/dist/switcher/Switcher.js +0 -41
- /package/dist/{animations → transform}/Fade.d.ts +0 -0
- /package/dist/{animations → transform}/ScaleFade.d.ts +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import { getCssSizeValue } from "../utils/linaria.js";
|
|
3
|
+
import Rotate from "../transform/Rotate.js";
|
|
3
4
|
import Text, { TextSize, TextVariant, TextWeight } from "../text/Text.js";
|
|
4
5
|
import FlexItem from "../containers/FlexItem.js";
|
|
5
6
|
import Icon, { IconVariant } from "../icons/Icon.js";
|
|
6
7
|
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
7
|
-
import RotateWithTransition from "../animations/RotateWithTransition.js";
|
|
8
8
|
import HorizontalDivider from "../dividers/HorizontalDivider.js";
|
|
9
9
|
/* empty css */
|
|
10
10
|
import { styled } from "@linaria/react";
|
|
@@ -107,7 +107,7 @@ var Accordion = ({ children, variant = "PRIMARY", size = "MEDIUM", icon, header,
|
|
|
107
107
|
}), /* @__PURE__ */ jsxs(FlexWrapper, {
|
|
108
108
|
alignItems: AlignItems.CENTER,
|
|
109
109
|
gap: 8,
|
|
110
|
-
children: [metric && metric, /* @__PURE__ */ jsx(
|
|
110
|
+
children: [metric && metric, /* @__PURE__ */ jsx(Rotate, {
|
|
111
111
|
isRotated: isOpen,
|
|
112
112
|
deg: -180,
|
|
113
113
|
children: /* @__PURE__ */ jsx(Icon, {
|
|
@@ -7,7 +7,7 @@ export declare const StyledAvatarShimmer: import("react").ComponentType<Pick<imp
|
|
|
7
7
|
theme: import("../theme").Theme;
|
|
8
8
|
} & {
|
|
9
9
|
as?: React.ElementType;
|
|
10
|
-
}, keyof import("react").ClassAttributes<HTMLDivElement> | keyof import("react").HTMLAttributes<HTMLDivElement
|
|
10
|
+
}, "$size" | "as" | keyof import("react").ClassAttributes<HTMLDivElement> | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
11
11
|
theme?: import("@callstack/react-theme-provider").$DeepPartial<import("../theme").Theme> | undefined;
|
|
12
12
|
}> & import("@callstack/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<import("react").ComponentType<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
13
13
|
$size?: number;
|
package/dist/buttons/Button.js
CHANGED
|
@@ -83,10 +83,10 @@ var LabelWrapper = /*#__PURE__*/ styled("span")({
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
function getTextVariant(variant, activeTheme) {
|
|
86
|
-
return match(variant).with("PRIMARY", () => activeTheme === GalaxyTheme.DARK ? TextVariant.PRIMARY : TextVariant.PRIMARY_ALT).with("PRIMARY_ALT", () => TextVariant.PRIMARY_ALT).with("SECONDARY", () => TextVariant.PRIMARY).with("TERTIARY", () => TextVariant.PRIMARY).with("SUCCESS", () => TextVariant.PRIMARY).with("ERROR", () => TextVariant.PRIMARY).exhaustive();
|
|
86
|
+
return match(variant).with("PRIMARY", () => activeTheme === GalaxyTheme.DARK ? TextVariant.PRIMARY : TextVariant.PRIMARY_ALT).with("PRIMARY_ALT", () => TextVariant.PRIMARY_ALT).with("SECONDARY", () => TextVariant.PRIMARY).with("TERTIARY", () => TextVariant.PRIMARY).with("SUCCESS", () => activeTheme === GalaxyTheme.DARK ? TextVariant.PRIMARY : TextVariant.PRIMARY_ALT).with("ERROR", () => activeTheme === GalaxyTheme.DARK ? TextVariant.PRIMARY : TextVariant.PRIMARY_ALT).exhaustive();
|
|
87
87
|
}
|
|
88
88
|
function getIconVariant(variant, activeTheme) {
|
|
89
|
-
return match(variant).with("PRIMARY", () => activeTheme === GalaxyTheme.DARK ? IconVariant.PRIMARY : IconVariant.PRIMARY_ALT).with("PRIMARY_ALT", () => IconVariant.PRIMARY_ALT).with("SECONDARY", () => IconVariant.PRIMARY).with("TERTIARY", () => IconVariant.PRIMARY).with("SUCCESS", () => IconVariant.PRIMARY).with("ERROR", () => IconVariant.PRIMARY).exhaustive();
|
|
89
|
+
return match(variant).with("PRIMARY", () => activeTheme === GalaxyTheme.DARK ? IconVariant.PRIMARY : IconVariant.PRIMARY_ALT).with("PRIMARY_ALT", () => IconVariant.PRIMARY_ALT).with("SECONDARY", () => IconVariant.PRIMARY).with("TERTIARY", () => IconVariant.PRIMARY).with("SUCCESS", () => activeTheme === GalaxyTheme.DARK ? IconVariant.PRIMARY : IconVariant.PRIMARY_ALT).with("ERROR", () => activeTheme === GalaxyTheme.DARK ? IconVariant.PRIMARY : IconVariant.PRIMARY_ALT).exhaustive();
|
|
90
90
|
}
|
|
91
91
|
var BUTTON_SIZE_TO_TEXT_SIZE_MAP = {
|
|
92
92
|
["SMALL"]: TextSize.BODY_SM,
|
package/dist/charts/BarChart.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { BarChartNormalization, ChartKind, ChartTargetShape } from "./types.js";
|
|
2
|
-
import { SKELETON_BAR_GROUPS } from "./constants.js";
|
|
3
2
|
import { useSeriesColorResolver } from "./useSeriesColorResolver.js";
|
|
4
3
|
import { useChartInteraction } from "./useChartInteraction.js";
|
|
5
4
|
import { useCartesianChartLayout } from "./useCartesianChartLayout.js";
|
|
6
5
|
import { getBarLegendItems } from "./barChartLegend.js";
|
|
7
6
|
import { buildBarChartGeometry, getBarValueDomain, roundedRectPath } from "./barChartGeometry.js";
|
|
8
|
-
import { ChartBarPath
|
|
7
|
+
import { ChartBarPath } from "./ChartPrimitives.js";
|
|
9
8
|
import ChartFrame from "./ChartFrame.js";
|
|
10
9
|
import { ChartCategoryAxis, ChartValueAxis } from "./ChartAxis.js";
|
|
11
10
|
import { useCallback, useMemo, useRef } from "react";
|
|
@@ -43,29 +42,9 @@ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRa
|
|
|
43
42
|
valueFormatter,
|
|
44
43
|
valueUnit
|
|
45
44
|
]);
|
|
46
|
-
/**
|
|
47
|
-
* The data actually rendered: the caller's, or the skeleton's while loading.
|
|
48
|
-
*
|
|
49
|
-
* Loading replaces the chart wholesale with ghost bars pushed through the
|
|
50
|
-
* real geometry pipeline, so the skeleton gets the true radii and spacing.
|
|
51
|
-
* The cast is safe because nothing derived from skeleton data ever surfaces:
|
|
52
|
-
* labels are hidden, targets are off, the legend shows stubs, and the
|
|
53
|
-
* accessible name says "loading" instead of counting.
|
|
54
|
-
*/
|
|
55
|
-
const displayGroups = useMemo(() => isLoading ? SKELETON_BAR_GROUPS.map((values, groupIndex) => ({
|
|
56
|
-
label: `skeleton-${groupIndex}`,
|
|
57
|
-
bars: values.map((value, barIndex) => ({
|
|
58
|
-
metric: `skeleton-${barIndex}`,
|
|
59
|
-
components: [{
|
|
60
|
-
key: "skeleton",
|
|
61
|
-
label: "",
|
|
62
|
-
value
|
|
63
|
-
}]
|
|
64
|
-
}))
|
|
65
|
-
})) : groups, [isLoading, groups]);
|
|
66
45
|
const { dimensions, domain, valueTicks, formatValue, formatLabel, formatAxisValue } = useCartesianChartLayout({
|
|
67
46
|
containerRef,
|
|
68
|
-
rawDomain: useMemo(() => getBarValueDomain(
|
|
47
|
+
rawDomain: useMemo(() => getBarValueDomain(groups, normalization), [groups, normalization]),
|
|
69
48
|
valueDomain,
|
|
70
49
|
width,
|
|
71
50
|
height,
|
|
@@ -90,10 +69,10 @@ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRa
|
|
|
90
69
|
* takes its metric's colour. Applying the metric colour to a stack would
|
|
91
70
|
* paint every segment identically.
|
|
92
71
|
*/
|
|
93
|
-
const isStacked = useMemo(() =>
|
|
94
|
-
const resolveColor = useCallback(({ metric, componentIndex, isStacked: barIsStacked, explicit }) =>
|
|
72
|
+
const isStacked = useMemo(() => groups.some((group) => group.bars.some((bar) => bar.components.length > 1)), [groups]);
|
|
73
|
+
const resolveColor = useCallback(({ metric, componentIndex, isStacked: barIsStacked, explicit }) => barIsStacked ? colors.resolveByIndex(componentIndex, explicit) : colors.resolve(metric, explicit), [colors]);
|
|
95
74
|
const geometry = useMemo(() => buildBarChartGeometry({
|
|
96
|
-
groups
|
|
75
|
+
groups,
|
|
97
76
|
plotWidth,
|
|
98
77
|
plotHeight,
|
|
99
78
|
normalization,
|
|
@@ -101,7 +80,7 @@ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRa
|
|
|
101
80
|
domain,
|
|
102
81
|
resolveColor
|
|
103
82
|
}), [
|
|
104
|
-
|
|
83
|
+
groups,
|
|
105
84
|
plotWidth,
|
|
106
85
|
plotHeight,
|
|
107
86
|
normalization,
|
|
@@ -109,7 +88,7 @@ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRa
|
|
|
109
88
|
domain,
|
|
110
89
|
resolveColor
|
|
111
90
|
]);
|
|
112
|
-
const isEmpty =
|
|
91
|
+
const isEmpty = groups.length === 0;
|
|
113
92
|
const legendItems = useMemo(() => getBarLegendItems({
|
|
114
93
|
isStacked,
|
|
115
94
|
series,
|
|
@@ -125,7 +104,8 @@ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRa
|
|
|
125
104
|
const interaction = useChartInteraction({
|
|
126
105
|
categoryCount: geometry.bands.length,
|
|
127
106
|
seriesKeys: legendKeys,
|
|
128
|
-
disabled: noTooltip || isLoading || isEmpty
|
|
107
|
+
disabled: noTooltip || isLoading || isEmpty,
|
|
108
|
+
isLoading
|
|
129
109
|
});
|
|
130
110
|
const buildCategoryTooltip = useCallback((index) => {
|
|
131
111
|
const band = geometry.bands[index];
|
|
@@ -160,14 +140,6 @@ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRa
|
|
|
160
140
|
width: band.width,
|
|
161
141
|
height: band.height
|
|
162
142
|
})), [geometry.bands]);
|
|
163
|
-
const marks = geometry.rects.map((rect) => /* @__PURE__ */ jsx(ChartBarPath, {
|
|
164
|
-
d: roundedRectPath(rect.x, rect.y, rect.width, rect.height, rect.radius, rect.corners),
|
|
165
|
-
fill: rect.color,
|
|
166
|
-
"data-state": interaction.getMarkState({
|
|
167
|
-
categoryIndex: rect.groupIndex,
|
|
168
|
-
seriesKey: isStacked ? rect.componentKey : rect.metric
|
|
169
|
-
})
|
|
170
|
-
}, rect.id));
|
|
171
143
|
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
172
144
|
containerRef,
|
|
173
145
|
dimensions,
|
|
@@ -186,17 +158,15 @@ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRa
|
|
|
186
158
|
marginLeft: dimensions.margin.left,
|
|
187
159
|
formatter: formatAxisValue,
|
|
188
160
|
showGrid,
|
|
189
|
-
showLabels: !isLoading,
|
|
190
161
|
title: valueAxisTitle
|
|
191
162
|
}), /* @__PURE__ */ jsx(ChartCategoryAxis, {
|
|
192
|
-
labels:
|
|
163
|
+
labels: groups.map((group) => group.label),
|
|
193
164
|
positions: categoryPositions,
|
|
194
165
|
step: categoryStep,
|
|
195
166
|
plotWidth,
|
|
196
167
|
plotHeight,
|
|
197
168
|
formatter: formatLabel,
|
|
198
169
|
mode: categoryLabelMode,
|
|
199
|
-
showLabels: !isLoading,
|
|
200
170
|
title: categoryAxisTitle
|
|
201
171
|
})] }),
|
|
202
172
|
noTooltip,
|
|
@@ -209,7 +179,14 @@ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRa
|
|
|
209
179
|
contentWhenEmpty,
|
|
210
180
|
showLegend,
|
|
211
181
|
legendItems,
|
|
212
|
-
children:
|
|
182
|
+
children: geometry.rects.map((rect) => /* @__PURE__ */ jsx(ChartBarPath, {
|
|
183
|
+
d: roundedRectPath(rect.x, rect.y, rect.width, rect.height, rect.radius, rect.corners),
|
|
184
|
+
fill: rect.color,
|
|
185
|
+
"data-state": interaction.getMarkState({
|
|
186
|
+
categoryIndex: rect.groupIndex,
|
|
187
|
+
seriesKey: isStacked ? rect.componentKey : rect.metric
|
|
188
|
+
})
|
|
189
|
+
}, rect.id))
|
|
213
190
|
});
|
|
214
191
|
};
|
|
215
192
|
//#endregion
|
|
@@ -22,13 +22,6 @@ interface ChartValueAxisProps {
|
|
|
22
22
|
plotHeight: number;
|
|
23
23
|
formatter: ChartValueFormatter;
|
|
24
24
|
showGrid?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Render the tick labels and title.
|
|
27
|
-
*
|
|
28
|
-
* Off while the chart is loading: the grid keeps the plot's structure, but
|
|
29
|
-
* numbers derived from placeholder data would read as data.
|
|
30
|
-
*/
|
|
31
|
-
showLabels?: boolean;
|
|
32
25
|
/**
|
|
33
26
|
* Rotated title in the left gutter.
|
|
34
27
|
*
|
|
@@ -37,7 +30,7 @@ interface ChartValueAxisProps {
|
|
|
37
30
|
*/
|
|
38
31
|
title?: string;
|
|
39
32
|
}
|
|
40
|
-
export declare const ChartValueAxis: ({ ticks, scale, plotWidth, plotHeight, marginLeft, formatter, showGrid,
|
|
33
|
+
export declare const ChartValueAxis: ({ ticks, scale, plotWidth, plotHeight, marginLeft, formatter, showGrid, title, }: ChartValueAxisProps) => import("react").JSX.Element;
|
|
41
34
|
interface ChartCategoryAxisProps {
|
|
42
35
|
labels: string[];
|
|
43
36
|
/** Left edge of each category's slot, in plot coordinates. */
|
|
@@ -49,8 +42,6 @@ interface ChartCategoryAxisProps {
|
|
|
49
42
|
plotHeight: number;
|
|
50
43
|
formatter: ChartLabelFormatter;
|
|
51
44
|
mode?: ChartCategoryLabelMode;
|
|
52
|
-
/** Render the labels and title. Off while loading — see the value axis. */
|
|
53
|
-
showLabels?: boolean;
|
|
54
45
|
/**
|
|
55
46
|
* Title below the tick labels.
|
|
56
47
|
*
|
|
@@ -58,5 +49,5 @@ interface ChartCategoryAxisProps {
|
|
|
58
49
|
*/
|
|
59
50
|
title?: string;
|
|
60
51
|
}
|
|
61
|
-
export declare const ChartCategoryAxis: ({ labels, positions, step, plotWidth, plotHeight, formatter, mode,
|
|
52
|
+
export declare const ChartCategoryAxis: ({ labels, positions, step, plotWidth, plotHeight, formatter, mode, title, }: ChartCategoryAxisProps) => import("react").JSX.Element;
|
|
62
53
|
export {};
|
package/dist/charts/ChartAxis.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getCategoryLabelStride } from "./chartScales.js";
|
|
|
6
6
|
import { ChartAxisLabelBox, ChartGridLine } from "./ChartPrimitives.js";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
//#region src/charts/ChartAxis.tsx
|
|
9
|
-
var ChartValueAxis = ({ ticks, scale, plotWidth, plotHeight, marginLeft, formatter, showGrid = true,
|
|
9
|
+
var ChartValueAxis = ({ ticks, scale, plotWidth, plotHeight, marginLeft, formatter, showGrid = true, title }) => {
|
|
10
10
|
const titleBand = title ? 26 : 0;
|
|
11
11
|
const labelWidth = Math.max(0, marginLeft - titleBand - 12);
|
|
12
12
|
return /* @__PURE__ */ jsxs("g", {
|
|
@@ -18,7 +18,7 @@ var ChartValueAxis = ({ ticks, scale, plotWidth, plotHeight, marginLeft, formatt
|
|
|
18
18
|
x2: plotWidth + 12,
|
|
19
19
|
y1: 0,
|
|
20
20
|
y2: 0
|
|
21
|
-
}),
|
|
21
|
+
}), labelWidth > 0 && /* @__PURE__ */ jsx(ChartAxisLabelBox, {
|
|
22
22
|
x: -marginLeft + titleBand,
|
|
23
23
|
y: -20 / 2,
|
|
24
24
|
width: labelWidth,
|
|
@@ -37,7 +37,7 @@ var ChartValueAxis = ({ ticks, scale, plotWidth, plotHeight, marginLeft, formatt
|
|
|
37
37
|
})
|
|
38
38
|
})
|
|
39
39
|
})]
|
|
40
|
-
}, tick)),
|
|
40
|
+
}, tick)), title && /* @__PURE__ */ jsx("g", {
|
|
41
41
|
transform: `translate(${-marginLeft + 18 / 2}, ${plotHeight / 2}) rotate(-90)`,
|
|
42
42
|
children: /* @__PURE__ */ jsx(ChartAxisLabelBox, {
|
|
43
43
|
x: -plotHeight / 2,
|
|
@@ -61,8 +61,7 @@ var ChartValueAxis = ({ ticks, scale, plotWidth, plotHeight, marginLeft, formatt
|
|
|
61
61
|
})]
|
|
62
62
|
});
|
|
63
63
|
};
|
|
64
|
-
var ChartCategoryAxis = ({ labels, positions, step, plotWidth, plotHeight, formatter, mode = ChartCategoryLabelMode.AUTO,
|
|
65
|
-
if (!showLabels) return null;
|
|
64
|
+
var ChartCategoryAxis = ({ labels, positions, step, plotWidth, plotHeight, formatter, mode = ChartCategoryLabelMode.AUTO, title }) => {
|
|
66
65
|
const formatted = labels.map(formatter);
|
|
67
66
|
const stride = mode === ChartCategoryLabelMode.AUTO ? getCategoryLabelStride(formatted, step) : 1;
|
|
68
67
|
const labelWidth = step * stride;
|
|
@@ -22,8 +22,7 @@ var ChartFrame = ({ containerRef, dimensions, fillWidth, fillHeight, interaction
|
|
|
22
22
|
* showing three. The two charts previously counted different things for the
|
|
23
23
|
* same situation, which is the drift this removes.
|
|
24
24
|
*/
|
|
25
|
-
const
|
|
26
|
-
const resolvedAriaLabel = ariaLabel ?? (isLoading ? `${kindLabel} chart, loading` : match(kind).with(ChartKind.PIE, () => `Pie chart with ${categoryCount} slices`).with(ChartKind.BAR, () => `Bar chart with ${categoryCount} categories and ${legendItems.length} series`).with(ChartKind.LINE, () => `Line chart with ${categoryCount} categories and ${legendItems.length} series`).exhaustive());
|
|
25
|
+
const resolvedAriaLabel = ariaLabel ?? match(kind).with(ChartKind.PIE, () => `Pie chart with ${categoryCount} slices`).with(ChartKind.BAR, () => `Bar chart with ${categoryCount} categories and ${legendItems.length} series`).with(ChartKind.LINE, () => `Line chart with ${categoryCount} categories and ${legendItems.length} series`).exhaustive();
|
|
27
26
|
const tooltipModel = useMemo(() => noTooltip || interaction.activeIndex === null ? null : buildCategoryTooltip(interaction.activeIndex), [
|
|
28
27
|
noTooltip,
|
|
29
28
|
buildCategoryTooltip,
|
|
@@ -122,7 +121,6 @@ var ChartFrame = ({ containerRef, dimensions, fillWidth, fillHeight, interaction
|
|
|
122
121
|
items: legendItems,
|
|
123
122
|
inset: legendInset ?? (legendRight ? 16 : margin.left),
|
|
124
123
|
vertical: legendRight,
|
|
125
|
-
isLoading,
|
|
126
124
|
hoveredKey: interaction.hoveredSeriesKey,
|
|
127
125
|
onItemEnter: interaction.onSeriesEnter,
|
|
128
126
|
onItemLeave: interaction.onSeriesLeave
|
|
@@ -7,14 +7,6 @@ interface ChartLegendProps {
|
|
|
7
7
|
hoveredKey?: string | null;
|
|
8
8
|
/** Stack entries in a column — the side-placed layout. */
|
|
9
9
|
vertical?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Render shimmer stubs instead of items.
|
|
12
|
-
*
|
|
13
|
-
* Keeps the legend's space reserved while the chart shows its skeleton, so
|
|
14
|
-
* data arriving doesn't shift the layout — which matters most beside a pie,
|
|
15
|
-
* where the legend's width decides the plot box's.
|
|
16
|
-
*/
|
|
17
|
-
isLoading?: boolean;
|
|
18
10
|
/**
|
|
19
11
|
* Supplying these makes the legend interactive. Omit them and it renders as
|
|
20
12
|
* inert text, with no button semantics for a screen reader to announce.
|
|
@@ -33,5 +25,5 @@ interface ChartLegendProps {
|
|
|
33
25
|
* Isolation only changes opacity, so the domain is untouched and the numbers
|
|
34
26
|
* keep meaning what they did.
|
|
35
27
|
*/
|
|
36
|
-
declare const ChartLegend: ({ items, inset, hoveredKey, vertical,
|
|
28
|
+
declare const ChartLegend: ({ items, inset, hoveredKey, vertical, onItemEnter, onItemLeave, }: ChartLegendProps) => import("react").JSX.Element | null;
|
|
37
29
|
export default ChartLegend;
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import Text, { TextSize } from "../text/Text.js";
|
|
2
|
-
import TextShimmer from "../text/TextShimmer.js";
|
|
3
2
|
import Circle from "../shapes/Circle.js";
|
|
4
3
|
import { ChartMarkState } from "./types.js";
|
|
5
4
|
import { ChartLegendItemButton, ChartLegendItemStatic, ChartLegendRow } from "./ChartPrimitives.js";
|
|
6
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
6
|
//#region src/charts/ChartLegend.tsx
|
|
8
7
|
/**
|
|
9
|
-
* Stub label widths in px, staggered so the placeholder reads as a legend
|
|
10
|
-
* rather than a repeated block. Three entries: enough to hold a legend's
|
|
11
|
-
* space without promising a series count.
|
|
12
|
-
*/
|
|
13
|
-
var SKELETON_LABEL_WIDTHS = [
|
|
14
|
-
40,
|
|
15
|
-
56,
|
|
16
|
-
48
|
|
17
|
-
];
|
|
18
|
-
/**
|
|
19
8
|
* Legend for the chart components.
|
|
20
9
|
*
|
|
21
10
|
* Hovering or focusing an entry isolates its series; leaving releases it.
|
|
@@ -26,22 +15,7 @@ var SKELETON_LABEL_WIDTHS = [
|
|
|
26
15
|
* Isolation only changes opacity, so the domain is untouched and the numbers
|
|
27
16
|
* keep meaning what they did.
|
|
28
17
|
*/
|
|
29
|
-
var ChartLegend = ({ items, inset, hoveredKey = null, vertical = false,
|
|
30
|
-
if (isLoading) return /* @__PURE__ */ jsx(ChartLegendRow, {
|
|
31
|
-
$inset: inset,
|
|
32
|
-
$vertical: vertical,
|
|
33
|
-
"data-active": "false",
|
|
34
|
-
children: SKELETON_LABEL_WIDTHS.map((labelWidth, index) => /* @__PURE__ */ jsxs(ChartLegendItemStatic, {
|
|
35
|
-
"data-state": ChartMarkState.ACTIVE,
|
|
36
|
-
children: [/* @__PURE__ */ jsx(TextShimmer, {
|
|
37
|
-
height: 8,
|
|
38
|
-
width: 8
|
|
39
|
-
}), /* @__PURE__ */ jsx(TextShimmer, {
|
|
40
|
-
height: 10,
|
|
41
|
-
width: labelWidth
|
|
42
|
-
})]
|
|
43
|
-
}, index))
|
|
44
|
-
});
|
|
18
|
+
var ChartLegend = ({ items, inset, hoveredKey = null, vertical = false, onItemEnter, onItemLeave }) => {
|
|
45
19
|
if (items.length === 0) return null;
|
|
46
20
|
const isInteractive = Boolean(onItemEnter);
|
|
47
21
|
const activeKey = hoveredKey;
|
|
@@ -55,19 +55,6 @@ export declare const ChartLinePath: import("@linaria/react").StyledComponent<imp
|
|
|
55
55
|
export declare const ChartAreaPath: import("@linaria/react").StyledComponent<import("react").SVGProps<SVGPathElement> & Record<never, unknown>>;
|
|
56
56
|
export declare const ChartPointCircle: import("@linaria/react").StyledComponent<import("react").SVGProps<SVGCircleElement> & Record<never, unknown>>;
|
|
57
57
|
export declare const ChartArcPath: import("@linaria/react").StyledComponent<import("react").SVGProps<SVGPathElement> & Record<never, unknown>>;
|
|
58
|
-
/**
|
|
59
|
-
* Wraps the marks while the chart is loading.
|
|
60
|
-
*
|
|
61
|
-
* Only motion lives here — the slow pulse shared with `TextShimmer` and
|
|
62
|
-
* `AvatarShimmer`, so a loading chart breathes in step with every other
|
|
63
|
-
* skeleton on the page. Colour arrives through the series resolver like any
|
|
64
|
-
* other mark colour, which is what lets bars and arcs ghost by `fill` and
|
|
65
|
-
* lines by `stroke` without per-shape CSS here.
|
|
66
|
-
*
|
|
67
|
-
* Under reduced motion the pulse pins at its midpoint rather than sitting at
|
|
68
|
-
* full strength, so the chart still reads as a placeholder and not as data.
|
|
69
|
-
*/
|
|
70
|
-
export declare const ChartSkeletonGroup: import("@linaria/react").StyledComponent<import("react").SVGProps<SVGGElement> & Record<never, unknown>>;
|
|
71
58
|
/**
|
|
72
59
|
* Per-category hit target, rendered above the marks.
|
|
73
60
|
*
|
|
@@ -145,7 +132,7 @@ export declare const ChartTooltipPositioner: import("react").ComponentType<Pick<
|
|
|
145
132
|
theme: import("../theme").Theme;
|
|
146
133
|
} & {
|
|
147
134
|
as?: React.ElementType;
|
|
148
|
-
}, keyof import("react").ClassAttributes<HTMLDivElement> | keyof import("react").HTMLAttributes<HTMLDivElement> | "
|
|
135
|
+
}, "as" | keyof import("react").ClassAttributes<HTMLDivElement> | keyof import("react").HTMLAttributes<HTMLDivElement> | "$x" | "$y" | "$isVisible"> & {
|
|
149
136
|
theme?: import("@callstack/react-theme-provider").$DeepPartial<import("../theme").Theme> | undefined;
|
|
150
137
|
}> & import("@callstack/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<import("react").ComponentType<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
151
138
|
$x: number;
|
|
@@ -187,7 +174,7 @@ export declare const ChartEmptyOverlay: import("react").ComponentType<Pick<impor
|
|
|
187
174
|
theme: import("../theme").Theme;
|
|
188
175
|
} & {
|
|
189
176
|
as?: React.ElementType;
|
|
190
|
-
}, keyof import("react").ClassAttributes<HTMLDivElement> | keyof import("react").HTMLAttributes<HTMLDivElement
|
|
177
|
+
}, "as" | keyof import("react").ClassAttributes<HTMLDivElement> | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
191
178
|
theme?: import("@callstack/react-theme-provider").$DeepPartial<import("../theme").Theme> | undefined;
|
|
192
179
|
}> & import("@callstack/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<import("react").ComponentType<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
193
180
|
theme: import("../theme").Theme;
|
|
@@ -138,23 +138,6 @@ var ChartArcPath = /*#__PURE__*/ styled("path")({
|
|
|
138
138
|
propsAsIs: true
|
|
139
139
|
});
|
|
140
140
|
/**
|
|
141
|
-
* Wraps the marks while the chart is loading.
|
|
142
|
-
*
|
|
143
|
-
* Only motion lives here — the slow pulse shared with `TextShimmer` and
|
|
144
|
-
* `AvatarShimmer`, so a loading chart breathes in step with every other
|
|
145
|
-
* skeleton on the page. Colour arrives through the series resolver like any
|
|
146
|
-
* other mark colour, which is what lets bars and arcs ghost by `fill` and
|
|
147
|
-
* lines by `stroke` without per-shape CSS here.
|
|
148
|
-
*
|
|
149
|
-
* Under reduced motion the pulse pins at its midpoint rather than sitting at
|
|
150
|
-
* full strength, so the chart still reads as a placeholder and not as data.
|
|
151
|
-
*/
|
|
152
|
-
var ChartSkeletonGroup = /*#__PURE__*/ styled("g")({
|
|
153
|
-
name: "ChartSkeletonGroup",
|
|
154
|
-
class: "c1wvzvu4",
|
|
155
|
-
propsAsIs: true
|
|
156
|
-
});
|
|
157
|
-
/**
|
|
158
141
|
* Per-category hit target, rendered above the marks.
|
|
159
142
|
*
|
|
160
143
|
* Hit testing the full column rather than the bars themselves means a two-pixel
|
|
@@ -167,7 +150,7 @@ var ChartSkeletonGroup = /*#__PURE__*/ styled("g")({
|
|
|
167
150
|
*/
|
|
168
151
|
var ChartHitTarget = /*#__PURE__*/ styled("rect")({
|
|
169
152
|
name: "ChartHitTarget",
|
|
170
|
-
class: "
|
|
153
|
+
class: "c1wvzvu4",
|
|
171
154
|
propsAsIs: true
|
|
172
155
|
});
|
|
173
156
|
/**
|
|
@@ -180,7 +163,7 @@ var ChartHitTarget = /*#__PURE__*/ styled("rect")({
|
|
|
180
163
|
*/
|
|
181
164
|
var ChartHitTargetPath = /*#__PURE__*/ styled("path")({
|
|
182
165
|
name: "ChartHitTargetPath",
|
|
183
|
-
class: "
|
|
166
|
+
class: "c17guewt",
|
|
184
167
|
propsAsIs: true
|
|
185
168
|
});
|
|
186
169
|
/**
|
|
@@ -188,24 +171,24 @@ var ChartHitTargetPath = /*#__PURE__*/ styled("path")({
|
|
|
188
171
|
* zero — the line under the bars is what makes them read as resting on a
|
|
189
172
|
* baseline.
|
|
190
173
|
*/
|
|
191
|
-
var
|
|
174
|
+
var _exp15 = () => ({ theme }) => theme.color.border.primary;
|
|
192
175
|
var ChartGridLine = withTheme(/*#__PURE__*/ styled("line")({
|
|
193
176
|
name: "ChartGridLine",
|
|
194
|
-
class: "
|
|
177
|
+
class: "cblgiyf",
|
|
195
178
|
propsAsIs: true,
|
|
196
|
-
vars: { "
|
|
179
|
+
vars: { "cblgiyf-0": [_exp15()] }
|
|
197
180
|
}));
|
|
198
181
|
/** Vertical rule marking the hovered category on a line chart. */
|
|
199
|
-
var
|
|
182
|
+
var _exp16 = () => ({ theme }) => theme.color.border.secondary;
|
|
200
183
|
var ChartCursorLine = withTheme(/*#__PURE__*/ styled("line")({
|
|
201
184
|
name: "ChartCursorLine",
|
|
202
|
-
class: "
|
|
185
|
+
class: "c1lr03cc",
|
|
203
186
|
propsAsIs: true,
|
|
204
|
-
vars: { "
|
|
187
|
+
vars: { "c1lr03cc-0": [_exp16()] }
|
|
205
188
|
}));
|
|
206
189
|
var ChartAxisLabelBox = /*#__PURE__*/ styled("foreignObject")({
|
|
207
190
|
name: "ChartAxisLabelBox",
|
|
208
|
-
class: "
|
|
191
|
+
class: "cizy1s8",
|
|
209
192
|
propsAsIs: true
|
|
210
193
|
});
|
|
211
194
|
/**
|
|
@@ -215,21 +198,21 @@ var ChartAxisLabelBox = /*#__PURE__*/ styled("foreignObject")({
|
|
|
215
198
|
* than teleporting, and it stays mounted while hidden so the fade can actually
|
|
216
199
|
* run — unmounting on hide is why a fade-out never appears.
|
|
217
200
|
*/
|
|
218
|
-
var
|
|
219
|
-
var
|
|
220
|
-
var
|
|
221
|
-
var
|
|
222
|
-
var
|
|
201
|
+
var _exp17 = () => ({ $x }) => `${$x}px`;
|
|
202
|
+
var _exp18 = () => ({ $y }) => `${$y}px`;
|
|
203
|
+
var _exp21 = () => ({ theme }) => theme.color.border.primary;
|
|
204
|
+
var _exp22 = () => ({ theme }) => theme.color.background.primary;
|
|
205
|
+
var _exp23 = () => ({ $isVisible }) => $isVisible ? 1 : 0;
|
|
223
206
|
var ChartTooltipPositioner = withTheme(/*#__PURE__*/ styled("div")({
|
|
224
207
|
name: "ChartTooltipPositioner",
|
|
225
|
-
class: "
|
|
208
|
+
class: "c1ukq11d",
|
|
226
209
|
propsAsIs: false,
|
|
227
210
|
vars: {
|
|
228
|
-
"
|
|
229
|
-
"
|
|
230
|
-
"
|
|
231
|
-
"
|
|
232
|
-
"
|
|
211
|
+
"c1ukq11d-0": [_exp17()],
|
|
212
|
+
"c1ukq11d-1": [_exp18()],
|
|
213
|
+
"c1ukq11d-2": [_exp21()],
|
|
214
|
+
"c1ukq11d-3": [_exp22()],
|
|
215
|
+
"c1ukq11d-4": [_exp23()]
|
|
233
216
|
}
|
|
234
217
|
}));
|
|
235
218
|
/**
|
|
@@ -240,32 +223,32 @@ var ChartTooltipPositioner = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
240
223
|
* of the DLS. `pointer-events: none` keeps it from stealing hover from the arc
|
|
241
224
|
* behind it.
|
|
242
225
|
*/
|
|
243
|
-
var
|
|
244
|
-
var
|
|
245
|
-
var
|
|
226
|
+
var _exp27 = () => ({ $centerX }) => `${$centerX}px`;
|
|
227
|
+
var _exp28 = () => ({ $centerY }) => `${$centerY}px`;
|
|
228
|
+
var _exp30 = () => ({ $diameter }) => `${$diameter}px`;
|
|
246
229
|
var ChartCenterBox = /*#__PURE__*/ styled("div")({
|
|
247
230
|
name: "ChartCenterBox",
|
|
248
|
-
class: "
|
|
231
|
+
class: "cwcko2m",
|
|
249
232
|
propsAsIs: false,
|
|
250
233
|
vars: {
|
|
251
|
-
"
|
|
252
|
-
"
|
|
253
|
-
"
|
|
234
|
+
"cwcko2m-0": [_exp27()],
|
|
235
|
+
"cwcko2m-1": [_exp28()],
|
|
236
|
+
"cwcko2m-2": [_exp30()]
|
|
254
237
|
}
|
|
255
238
|
});
|
|
256
239
|
/**
|
|
257
240
|
* Sits slightly above centre, over where the bars would be, so the axes stay
|
|
258
241
|
* legible underneath.
|
|
259
242
|
*/
|
|
260
|
-
var
|
|
261
|
-
var
|
|
243
|
+
var _exp31 = () => ({ theme }) => theme.color.border.primary;
|
|
244
|
+
var _exp32 = () => ({ theme }) => theme.color.background.tertiary;
|
|
262
245
|
var ChartEmptyOverlay = withTheme(/*#__PURE__*/ styled("div")({
|
|
263
246
|
name: "ChartEmptyOverlay",
|
|
264
|
-
class: "
|
|
247
|
+
class: "cqwhvyz",
|
|
265
248
|
propsAsIs: false,
|
|
266
249
|
vars: {
|
|
267
|
-
"
|
|
268
|
-
"
|
|
250
|
+
"cqwhvyz-0": [_exp31()],
|
|
251
|
+
"cqwhvyz-1": [_exp32()]
|
|
269
252
|
}
|
|
270
253
|
}));
|
|
271
254
|
/**
|
|
@@ -277,23 +260,23 @@ var ChartEmptyOverlay = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
277
260
|
* the marks dim instantly while their legend entries sit through the full
|
|
278
261
|
* {@link CHART_RESTORE_DELAY_MS}, and the two visibly fall out of step.
|
|
279
262
|
*/
|
|
280
|
-
var
|
|
281
|
-
var
|
|
282
|
-
var
|
|
283
|
-
var
|
|
284
|
-
var
|
|
285
|
-
var
|
|
263
|
+
var _exp33 = () => ({ $vertical }) => $vertical ? "column" : "row";
|
|
264
|
+
var _exp34 = () => ({ $vertical }) => $vertical ? "nowrap" : "wrap";
|
|
265
|
+
var _exp35 = () => ({ $vertical }) => $vertical ? "flex-start" : "center";
|
|
266
|
+
var _exp36 = () => ({ $vertical }) => $vertical ? "8px" : "8px 16px";
|
|
267
|
+
var _exp37 = () => ({ $vertical }) => $vertical ? "0" : "10px";
|
|
268
|
+
var _exp38 = () => ({ $inset }) => `${$inset}px`;
|
|
286
269
|
var ChartLegendRow = /*#__PURE__*/ styled("div")({
|
|
287
270
|
name: "ChartLegendRow",
|
|
288
|
-
class: "
|
|
271
|
+
class: "c1iaray",
|
|
289
272
|
propsAsIs: false,
|
|
290
273
|
vars: {
|
|
291
|
-
"
|
|
292
|
-
"
|
|
293
|
-
"
|
|
294
|
-
"
|
|
295
|
-
"
|
|
296
|
-
"
|
|
274
|
+
"c1iaray-0": [_exp33()],
|
|
275
|
+
"c1iaray-1": [_exp34()],
|
|
276
|
+
"c1iaray-2": [_exp35()],
|
|
277
|
+
"c1iaray-3": [_exp36()],
|
|
278
|
+
"c1iaray-4": [_exp37()],
|
|
279
|
+
"c1iaray-5": [_exp38()]
|
|
297
280
|
}
|
|
298
281
|
});
|
|
299
282
|
/**
|
|
@@ -310,14 +293,14 @@ var ChartLegendRow = /*#__PURE__*/ styled("div")({
|
|
|
310
293
|
*/
|
|
311
294
|
var ChartLegendItemButton = /*#__PURE__*/ styled("button")({
|
|
312
295
|
name: "ChartLegendItemButton",
|
|
313
|
-
class: "
|
|
296
|
+
class: "cz6jod1",
|
|
314
297
|
propsAsIs: false
|
|
315
298
|
});
|
|
316
299
|
/** The same row, when the legend is inert — no button semantics to announce. */
|
|
317
300
|
var ChartLegendItemStatic = /*#__PURE__*/ styled("div")({
|
|
318
301
|
name: "ChartLegendItemStatic",
|
|
319
|
-
class: "
|
|
302
|
+
class: "c1de5mqk",
|
|
320
303
|
propsAsIs: false
|
|
321
304
|
});
|
|
322
305
|
//#endregion
|
|
323
|
-
export { ChartArcPath, ChartAreaPath, ChartAxisLabelBox, ChartBarPath, ChartCenterBox, ChartCursorLine, ChartEmptyOverlay, ChartGridLine, ChartHitTarget, ChartHitTargetPath, ChartLegendItemButton, ChartLegendItemStatic, ChartLegendRow, ChartLinePath, ChartPlotBox, ChartPlotGroup, ChartPointCircle, ChartRoot,
|
|
306
|
+
export { ChartArcPath, ChartAreaPath, ChartAxisLabelBox, ChartBarPath, ChartCenterBox, ChartCursorLine, ChartEmptyOverlay, ChartGridLine, ChartHitTarget, ChartHitTargetPath, ChartLegendItemButton, ChartLegendItemStatic, ChartLegendRow, ChartLinePath, ChartPlotBox, ChartPlotGroup, ChartPointCircle, ChartRoot, ChartSvg, ChartTooltipPositioner };
|
|
@@ -34,7 +34,6 @@ var ChartTooltip = ({ model, containerWidth, containerHeight, anchorHalfWidth, p
|
|
|
34
34
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
35
35
|
size: TextSize.BODY_SM,
|
|
36
36
|
variant: TextVariant.TERTIARY,
|
|
37
|
-
isEllipsis: true,
|
|
38
37
|
children: displayed.label
|
|
39
38
|
}), /* @__PURE__ */ jsx(FlexWrapper, {
|
|
40
39
|
direction: FlexDirection.COLUMN,
|
|
@@ -48,7 +47,6 @@ var ChartTooltip = ({ model, containerWidth, containerHeight, anchorHalfWidth, p
|
|
|
48
47
|
children: [/* @__PURE__ */ jsxs(FlexWrapper, {
|
|
49
48
|
alignItems: AlignItems.CENTER,
|
|
50
49
|
gap: 6,
|
|
51
|
-
minWidth: 0,
|
|
52
50
|
children: [/* @__PURE__ */ jsx(FlexItem, {
|
|
53
51
|
shrink: 0,
|
|
54
52
|
children: /* @__PURE__ */ jsx(Circle, {
|
|
@@ -60,13 +58,10 @@ var ChartTooltip = ({ model, containerWidth, containerHeight, anchorHalfWidth, p
|
|
|
60
58
|
isEllipsis: true,
|
|
61
59
|
children: row.label
|
|
62
60
|
})]
|
|
63
|
-
}), /* @__PURE__ */ jsx(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
weight: TextWeight.MEDIUM,
|
|
68
|
-
children: row.formattedValue
|
|
69
|
-
})
|
|
61
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
62
|
+
size: TextSize.BODY_SM,
|
|
63
|
+
weight: TextWeight.MEDIUM,
|
|
64
|
+
children: row.formattedValue
|
|
70
65
|
})]
|
|
71
66
|
}, row.key))
|
|
72
67
|
})]
|