@galaxy-io/dls 1.3.4 → 1.3.5

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.
@@ -34,10 +34,20 @@ import { styled } from "@linaria/react";
34
34
  * `min-width: 0` is load-bearing rather than cosmetic — without it a chart in a
35
35
  * flex row feeds its min-content width back into the ResizeObserver and the
36
36
  * measurement can oscillate.
37
+ *
38
+ * `$legendRight` rotates the layout: plot box and legend become a row with
39
+ * `align-items: center`, which is the whole of "the legend is vertically
40
+ * centred on the pie" — the pie is inscribed centred in its box, so centring
41
+ * the legend against the box centres it against the pie. It also holds in the
42
+ * other direction: a legend taller than the box centres the *pie* against the
43
+ * legend instead of pinning it to the top.
37
44
  */
38
45
  var _exp = () => ({ $fillWidth }) => $fillWidth ? "flex" : "inline-flex";
39
- var _exp2 = () => ({ $fillWidth }) => $fillWidth ? "100%" : "auto";
40
- var _exp3 = () => ({ $fillHeight }) => $fillHeight ? "100%" : "auto";
46
+ var _exp2 = () => ({ $legendRight }) => $legendRight ? "row" : "column";
47
+ var _exp3 = () => ({ $legendRight }) => $legendRight ? "center" : "stretch";
48
+ var _exp4 = () => ({ $legendRight }) => $legendRight ? "center" : "normal";
49
+ var _exp5 = () => ({ $fillWidth }) => $fillWidth ? "100%" : "auto";
50
+ var _exp6 = () => ({ $fillHeight }) => $fillHeight ? "100%" : "auto";
41
51
  var ChartRoot = /*#__PURE__*/ styled("div")({
42
52
  name: "ChartRoot",
43
53
  class: "c1hcga6s",
@@ -45,7 +55,10 @@ var ChartRoot = /*#__PURE__*/ styled("div")({
45
55
  vars: {
46
56
  "c1hcga6s-0": [_exp()],
47
57
  "c1hcga6s-1": [_exp2()],
48
- "c1hcga6s-2": [_exp3()]
58
+ "c1hcga6s-2": [_exp3()],
59
+ "c1hcga6s-3": [_exp4()],
60
+ "c1hcga6s-4": [_exp5()],
61
+ "c1hcga6s-5": [_exp6()]
49
62
  }
50
63
  });
51
64
  /**
@@ -64,19 +77,21 @@ var ChartRoot = /*#__PURE__*/ styled("div")({
64
77
  * `min-height: 0` is required with it: a flex item's automatic minimum size is
65
78
  * its content, which would let the SVG hold the box open above its track.
66
79
  */
67
- var _exp4 = () => ({ $reservedAspectRatio }) => $reservedAspectRatio ?? "auto";
68
- var _exp5 = () => ({ $reservedHeight }) => $reservedHeight ? `${$reservedHeight}px` : "auto";
69
- var _exp6 = () => ({ $fillHeight }) => $fillHeight ? "1 1 0%" : "0 1 auto";
70
- var _exp7 = () => ({ $fillHeight }) => $fillHeight ? "0" : "auto";
80
+ var _exp7 = () => ({ $legendRight }) => $legendRight ? "auto" : "100%";
81
+ var _exp8 = () => ({ $reservedAspectRatio, $squareFromHeight }) => $squareFromHeight ? "1" : $reservedAspectRatio ?? "auto";
82
+ var _exp9 = () => ({ $reservedHeight, $fillHeight, $legendRight }) => $fillHeight && $legendRight ? "100%" : $reservedHeight ? `${$reservedHeight}px` : "auto";
83
+ var _exp0 = () => ({ $fillHeight, $legendRight, $squareFromHeight }) => $legendRight ? $squareFromHeight ? "0 1 auto" : "1 1 auto" : $fillHeight ? "1 1 0%" : "0 1 auto";
84
+ var _exp1 = () => ({ $fillHeight }) => $fillHeight ? "0" : "auto";
71
85
  var ChartPlotBox = /*#__PURE__*/ styled("div")({
72
86
  name: "ChartPlotBox",
73
87
  class: "c1fvbgkp",
74
88
  propsAsIs: false,
75
89
  vars: {
76
- "c1fvbgkp-0": [_exp4()],
77
- "c1fvbgkp-1": [_exp5()],
78
- "c1fvbgkp-2": [_exp6()],
79
- "c1fvbgkp-3": [_exp7()]
90
+ "c1fvbgkp-0": [_exp7()],
91
+ "c1fvbgkp-1": [_exp8()],
92
+ "c1fvbgkp-2": [_exp9()],
93
+ "c1fvbgkp-3": [_exp0()],
94
+ "c1fvbgkp-4": [_exp1()]
80
95
  }
81
96
  });
82
97
  /**
@@ -123,40 +138,19 @@ var ChartArcPath = /*#__PURE__*/ styled("path")({
123
138
  propsAsIs: true
124
139
  });
125
140
  /**
126
- * Wrapper for the category target layer.
127
- *
128
- * Exists to carry the focus-ring colour: the targets themselves are plain
129
- * `styled.x` because they receive refs (see the module note above), so they
130
- * cannot read the theme directly. Setting `color` here lets them use
131
- * `currentColor` and still take the token rather than inheriting whatever the
132
- * consumer's page happens to set.
133
- */
134
- var _exp11 = () => ({ theme }) => theme.color.border.selected;
135
- var ChartCategoryTargetLayer = withTheme(/*#__PURE__*/ styled("g")({
136
- name: "ChartCategoryTargetLayer",
137
- class: "c1wvzvu4",
138
- propsAsIs: true,
139
- vars: { "c1wvzvu4-0": [_exp11()] }
140
- }));
141
- /**
142
- * Shared by both target shapes.
143
- *
144
- * The ring is a `stroke`, not an `outline`: `outline` on SVG elements is a late
145
- * arrival in WebKit and `outline-offset` behaves inconsistently across engines,
146
- * while a stroke on a transparent shape is universally supported — and it
147
- * traces a pie arc, which a rectangular outline could not.
148
- */
149
- /**
150
141
  * Per-category hit target, rendered above the marks.
151
142
  *
152
143
  * Hit testing the full column rather than the bars themselves means a two-pixel
153
144
  * bar is as easy to hover as a two-hundred-pixel one, and crossing between
154
145
  * segments inside a category fires no events at all — so the tooltip holds
155
146
  * still instead of chasing each segment.
147
+ *
148
+ * No cursor and no focus treatment: the target only previews on hover, and a
149
+ * pointer cursor would promise a click that does nothing.
156
150
  */
157
151
  var ChartHitTarget = /*#__PURE__*/ styled("rect")({
158
152
  name: "ChartHitTarget",
159
- class: "c17guewt",
153
+ class: "c1wvzvu4",
160
154
  propsAsIs: true
161
155
  });
162
156
  /**
@@ -164,18 +158,12 @@ var ChartHitTarget = /*#__PURE__*/ styled("rect")({
164
158
  *
165
159
  * A pie has no category axis to band, so its targets are the arc shapes
166
160
  * themselves — drawn again, transparent, above the marks. That keeps hit
167
- * testing and focus identical across all three charts instead of the pie
168
- * hit-testing its visible arcs directly.
161
+ * testing identical across all three charts instead of the pie hit-testing its
162
+ * visible arcs directly.
169
163
  */
170
164
  var ChartHitTargetPath = /*#__PURE__*/ styled("path")({
171
165
  name: "ChartHitTargetPath",
172
- class: "cblgiyf",
173
- propsAsIs: true
174
- });
175
- /** Full-plot backdrop; clicking it clears a pinned category. */
176
- var ChartBackdrop = /*#__PURE__*/ styled("rect")({
177
- name: "ChartBackdrop",
178
- class: "c1lr03cc",
166
+ class: "c17guewt",
179
167
  propsAsIs: true
180
168
  });
181
169
  /**
@@ -183,24 +171,24 @@ var ChartBackdrop = /*#__PURE__*/ styled("rect")({
183
171
  * zero — the line under the bars is what makes them read as resting on a
184
172
  * baseline.
185
173
  */
186
- var _exp14 = () => ({ theme }) => theme.color.border.primary;
174
+ var _exp15 = () => ({ theme }) => theme.color.border.primary;
187
175
  var ChartGridLine = withTheme(/*#__PURE__*/ styled("line")({
188
176
  name: "ChartGridLine",
189
- class: "cizy1s8",
177
+ class: "cblgiyf",
190
178
  propsAsIs: true,
191
- vars: { "cizy1s8-0": [_exp14()] }
179
+ vars: { "cblgiyf-0": [_exp15()] }
192
180
  }));
193
181
  /** Vertical rule marking the hovered category on a line chart. */
194
- var _exp15 = () => ({ theme }) => theme.color.border.secondary;
182
+ var _exp16 = () => ({ theme }) => theme.color.border.secondary;
195
183
  var ChartCursorLine = withTheme(/*#__PURE__*/ styled("line")({
196
184
  name: "ChartCursorLine",
197
- class: "c1ukq11d",
185
+ class: "c1lr03cc",
198
186
  propsAsIs: true,
199
- vars: { "c1ukq11d-0": [_exp15()] }
187
+ vars: { "c1lr03cc-0": [_exp16()] }
200
188
  }));
201
189
  var ChartAxisLabelBox = /*#__PURE__*/ styled("foreignObject")({
202
190
  name: "ChartAxisLabelBox",
203
- class: "cwcko2m",
191
+ class: "cizy1s8",
204
192
  propsAsIs: true
205
193
  });
206
194
  /**
@@ -210,21 +198,21 @@ var ChartAxisLabelBox = /*#__PURE__*/ styled("foreignObject")({
210
198
  * than teleporting, and it stays mounted while hidden so the fade can actually
211
199
  * run — unmounting on hide is why a fade-out never appears.
212
200
  */
213
- var _exp16 = () => ({ $x }) => `${$x}px`;
214
- var _exp17 = () => ({ $y }) => `${$y}px`;
215
- var _exp20 = () => ({ theme }) => theme.color.border.primary;
216
- var _exp21 = () => ({ theme }) => theme.color.background.primary;
217
- var _exp22 = () => ({ $isVisible }) => $isVisible ? 1 : 0;
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;
218
206
  var ChartTooltipPositioner = withTheme(/*#__PURE__*/ styled("div")({
219
207
  name: "ChartTooltipPositioner",
220
- class: "cqwhvyz",
208
+ class: "c1ukq11d",
221
209
  propsAsIs: false,
222
210
  vars: {
223
- "cqwhvyz-0": [_exp16()],
224
- "cqwhvyz-1": [_exp17()],
225
- "cqwhvyz-2": [_exp20()],
226
- "cqwhvyz-3": [_exp21()],
227
- "cqwhvyz-4": [_exp22()]
211
+ "c1ukq11d-0": [_exp17()],
212
+ "c1ukq11d-1": [_exp18()],
213
+ "c1ukq11d-2": [_exp21()],
214
+ "c1ukq11d-3": [_exp22()],
215
+ "c1ukq11d-4": [_exp23()]
228
216
  }
229
217
  }));
230
218
  /**
@@ -235,32 +223,32 @@ var ChartTooltipPositioner = withTheme(/*#__PURE__*/ styled("div")({
235
223
  * of the DLS. `pointer-events: none` keeps it from stealing hover from the arc
236
224
  * behind it.
237
225
  */
238
- var _exp26 = () => ({ $centerX }) => `${$centerX}px`;
239
- var _exp27 = () => ({ $centerY }) => `${$centerY}px`;
240
- var _exp29 = () => ({ $diameter }) => `${$diameter}px`;
226
+ var _exp27 = () => ({ $centerX }) => `${$centerX}px`;
227
+ var _exp28 = () => ({ $centerY }) => `${$centerY}px`;
228
+ var _exp30 = () => ({ $diameter }) => `${$diameter}px`;
241
229
  var ChartCenterBox = /*#__PURE__*/ styled("div")({
242
230
  name: "ChartCenterBox",
243
- class: "c1iaray",
231
+ class: "cwcko2m",
244
232
  propsAsIs: false,
245
233
  vars: {
246
- "c1iaray-0": [_exp26()],
247
- "c1iaray-1": [_exp27()],
248
- "c1iaray-2": [_exp29()]
234
+ "cwcko2m-0": [_exp27()],
235
+ "cwcko2m-1": [_exp28()],
236
+ "cwcko2m-2": [_exp30()]
249
237
  }
250
238
  });
251
239
  /**
252
240
  * Sits slightly above centre, over where the bars would be, so the axes stay
253
241
  * legible underneath.
254
242
  */
255
- var _exp30 = () => ({ theme }) => theme.color.border.primary;
256
- var _exp31 = () => ({ theme }) => theme.color.background.tertiary;
243
+ var _exp31 = () => ({ theme }) => theme.color.border.primary;
244
+ var _exp32 = () => ({ theme }) => theme.color.background.tertiary;
257
245
  var ChartEmptyOverlay = withTheme(/*#__PURE__*/ styled("div")({
258
246
  name: "ChartEmptyOverlay",
259
- class: "cz6jod1",
247
+ class: "cqwhvyz",
260
248
  propsAsIs: false,
261
249
  vars: {
262
- "cz6jod1-0": [_exp30()],
263
- "cz6jod1-1": [_exp31()]
250
+ "cqwhvyz-0": [_exp31()],
251
+ "cqwhvyz-1": [_exp32()]
264
252
  }
265
253
  }));
266
254
  /**
@@ -272,34 +260,47 @@ var ChartEmptyOverlay = withTheme(/*#__PURE__*/ styled("div")({
272
260
  * the marks dim instantly while their legend entries sit through the full
273
261
  * {@link CHART_RESTORE_DELAY_MS}, and the two visibly fall out of step.
274
262
  */
275
- var _exp32 = () => ({ $inset }) => `${$inset}px`;
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`;
276
269
  var ChartLegendRow = /*#__PURE__*/ styled("div")({
277
270
  name: "ChartLegendRow",
278
- class: "c1de5mqk",
271
+ class: "c1iaray",
279
272
  propsAsIs: false,
280
- vars: { "c1de5mqk-0": [_exp32()] }
273
+ vars: {
274
+ "c1iaray-0": [_exp33()],
275
+ "c1iaray-1": [_exp34()],
276
+ "c1iaray-2": [_exp35()],
277
+ "c1iaray-3": [_exp36()],
278
+ "c1iaray-4": [_exp37()],
279
+ "c1iaray-5": [_exp38()]
280
+ }
281
281
  });
282
282
  /**
283
283
  * One legend entry, when the legend is interactive.
284
284
  *
285
- * A real `<button>` rather than a styled div: it is clickable, so it has to be
286
- * reachable and operable by keyboard. `aria-pressed` carries the pinned state
287
- * the only thing here a screen reader can truthfully announce, since the plot
288
- * itself is `role="img"` and its marks are not in the accessibility tree.
285
+ * A real `<button>` rather than a styled div so it sits in the tab order:
286
+ * focusing an entry previews its series exactly as hovering does, which is the
287
+ * one keyboard affordance the charts keep the plot itself is `role="img"` and
288
+ * its marks are not in the accessibility tree. Activating it does nothing;
289
+ * isolation follows the pointer or the focus and releases with it.
289
290
  *
290
291
  * Shares the mark opacity ramp via `data-state`, so an entry recedes in step
291
292
  * with the series it names.
292
293
  */
293
294
  var ChartLegendItemButton = /*#__PURE__*/ styled("button")({
294
295
  name: "ChartLegendItemButton",
295
- class: "cjirv6a",
296
+ class: "cz6jod1",
296
297
  propsAsIs: false
297
298
  });
298
299
  /** The same row, when the legend is inert — no button semantics to announce. */
299
300
  var ChartLegendItemStatic = /*#__PURE__*/ styled("div")({
300
301
  name: "ChartLegendItemStatic",
301
- class: "c1armna5",
302
+ class: "c1de5mqk",
302
303
  propsAsIs: false
303
304
  });
304
305
  //#endregion
305
- export { ChartArcPath, ChartAreaPath, ChartAxisLabelBox, ChartBackdrop, ChartBarPath, ChartCategoryTargetLayer, ChartCenterBox, ChartCursorLine, ChartEmptyOverlay, ChartGridLine, ChartHitTarget, ChartHitTargetPath, ChartLegendItemButton, ChartLegendItemStatic, ChartLegendRow, ChartLinePath, ChartPlotBox, ChartPlotGroup, ChartPointCircle, ChartRoot, ChartSvg, ChartTooltipPositioner };
306
+ export { ChartArcPath, ChartAreaPath, ChartAxisLabelBox, ChartBarPath, ChartCenterBox, ChartCursorLine, ChartEmptyOverlay, ChartGridLine, ChartHitTarget, ChartHitTargetPath, ChartLegendItemButton, ChartLegendItemStatic, ChartLegendRow, ChartLinePath, ChartPlotBox, ChartPlotGroup, ChartPointCircle, ChartRoot, ChartSvg, ChartTooltipPositioner };
@@ -25,12 +25,6 @@ export type LineChartProps<TMetric extends string> = BaseCartesianChartProps & C
25
25
  strokeWidth?: number;
26
26
  /** Draw a vertical rule at the active category. @default true */
27
27
  showCursor?: boolean;
28
- /**
29
- * Notified when a category is pinned or unpinned by a click.
30
- *
31
- * The index is a position on the category axis.
32
- */
33
- onPinnedChange?: (categoryIndex: number | null) => void;
34
28
  };
35
29
  /**
36
30
  * Line chart over a categorical x-axis.
@@ -40,5 +34,5 @@ export type LineChartProps<TMetric extends string> = BaseCartesianChartProps & C
40
34
  * what a reader wants, and it avoids the proximity search a
41
35
  * nearest-point-to-cursor model needs.
42
36
  */
43
- declare const LineChart: <TMetric extends string>({ series, lines, categories, width, height, fillWidth, fillHeight, aspectRatio, margin, curve, strokeWidth, showCursor, valueUnit, valueFormatter, labelFormatter, valueDomain, categoryLabelMode, categoryAxisTitle, valueAxisTitle, showGrid, showLegend, noTooltip, tooltipRenderer, isLoading, contentWhenEmpty, ariaLabel, ariaDescription, onPinnedChange, }: LineChartProps<TMetric>) => import("react").JSX.Element;
37
+ declare const LineChart: <TMetric extends string>({ series, lines, categories, width, height, fillWidth, fillHeight, aspectRatio, margin, curve, strokeWidth, showCursor, valueUnit, valueFormatter, labelFormatter, valueDomain, categoryLabelMode, categoryAxisTitle, valueAxisTitle, showGrid, showLegend, noTooltip, tooltipRenderer, isLoading, contentWhenEmpty, ariaLabel, ariaDescription, }: LineChartProps<TMetric>) => import("react").JSX.Element;
44
38
  export default LineChart;
@@ -18,7 +18,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
18
18
  * what a reader wants, and it avoids the proximity search a
19
19
  * nearest-point-to-cursor model needs.
20
20
  */
21
- var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeight, aspectRatio, margin, curve = LineChartCurve.SMOOTH, strokeWidth, showCursor = true, valueUnit, valueFormatter, labelFormatter, valueDomain, categoryLabelMode, categoryAxisTitle, valueAxisTitle, showGrid = true, showLegend = true, noTooltip = false, tooltipRenderer, isLoading = false, contentWhenEmpty, ariaLabel, ariaDescription, onPinnedChange }) => {
21
+ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeight, aspectRatio, margin, curve = LineChartCurve.SMOOTH, strokeWidth, showCursor = true, valueUnit, valueFormatter, labelFormatter, valueDomain, categoryLabelMode, categoryAxisTitle, valueAxisTitle, showGrid = true, showLegend = true, noTooltip = false, tooltipRenderer, isLoading = false, contentWhenEmpty, ariaLabel, ariaDescription }) => {
22
22
  const containerRef = useRef(null);
23
23
  const colors = useSeriesColorResolver(series);
24
24
  const { dimensions, domain, valueTicks, formatValue, formatLabel } = useCartesianChartLayout({
@@ -69,8 +69,7 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
69
69
  categoryCount: geometry.columns.length,
70
70
  seriesKeys: legendKeys,
71
71
  disabled: noTooltip || isLoading || isEmpty,
72
- isLoading,
73
- onPinnedChange
72
+ isLoading
74
73
  });
75
74
  const activeColumn = interaction.activeIndex === null ? null : geometry.columns[interaction.activeIndex];
76
75
  const buildCategoryTooltip = useCallback((index) => {
@@ -32,13 +32,6 @@ export type PieChartProps<TSlice extends string> = BaseChartProps & ChartSize &
32
32
  * Ignored when `innerRadiusRatio` is 0.
33
33
  */
34
34
  centerContent?: ReactNode;
35
- /**
36
- * Notified when a slice is pinned or unpinned by a click.
37
- *
38
- * The index is a position in the *rendered* arcs, which excludes folded
39
- * slices and may include the aggregated bucket.
40
- */
41
- onPinnedChange?: (sliceIndex: number | null) => void;
42
35
  };
43
36
  /**
44
37
  * Pie and donut chart.
@@ -47,5 +40,5 @@ export type PieChartProps<TSlice extends string> = BaseChartProps & ChartSize &
47
40
  * each arc is its own target. Small slices are folded into an "Other" bucket by
48
41
  * default, which keeps every remaining arc large enough to actually hit.
49
42
  */
50
- declare const PieChart: <TSlice extends string>({ series, slices, width, height, fillWidth, fillHeight, aspectRatio, margin, innerRadiusRatio, padAngle, cornerRadius, minSliceShare, aggregatedLabel, centerContent, valueUnit, valueFormatter, labelFormatter, showLegend, noTooltip, tooltipRenderer, isLoading, contentWhenEmpty, ariaLabel, ariaDescription, onPinnedChange, }: PieChartProps<TSlice>) => import("react").JSX.Element;
43
+ declare const PieChart: <TSlice extends string>({ series, slices, width, height, fillWidth, fillHeight, aspectRatio, margin, innerRadiusRatio, padAngle, cornerRadius, minSliceShare, aggregatedLabel, centerContent, valueUnit, valueFormatter, labelFormatter, showLegend, noTooltip, tooltipRenderer, isLoading, contentWhenEmpty, ariaLabel, ariaDescription, }: PieChartProps<TSlice>) => import("react").JSX.Element;
51
44
  export default PieChart;
@@ -1,5 +1,5 @@
1
1
  import FlexWrapper, { AlignItems, FlexDirection, JustifyContent } from "../containers/FlexWrapper.js";
2
- import { ChartKind, ChartTargetShape } from "./types.js";
2
+ import { ChartKind, ChartLegendPlacement, ChartTargetShape } from "./types.js";
3
3
  import { PIE_CHART_MARGIN, PIE_MIN_SLICE_SHARE } from "./constants.js";
4
4
  import { useSeriesColorResolver } from "./useSeriesColorResolver.js";
5
5
  import { ChartTooltipVerticalAlign } from "./useChartTooltipPosition.js";
@@ -19,7 +19,7 @@ import { jsx } from "react/jsx-runtime";
19
19
  * each arc is its own target. Small slices are folded into an "Other" bucket by
20
20
  * default, which keeps every remaining arc large enough to actually hit.
21
21
  */
22
- var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRatio, margin, innerRadiusRatio, padAngle, cornerRadius, minSliceShare = PIE_MIN_SLICE_SHARE, aggregatedLabel, centerContent, valueUnit, valueFormatter, labelFormatter, showLegend = true, noTooltip = false, tooltipRenderer, isLoading = false, contentWhenEmpty, ariaLabel, ariaDescription, onPinnedChange }) => {
22
+ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRatio, margin, innerRadiusRatio, padAngle, cornerRadius, minSliceShare = PIE_MIN_SLICE_SHARE, aggregatedLabel, centerContent, valueUnit, valueFormatter, labelFormatter, showLegend = true, noTooltip = false, tooltipRenderer, isLoading = false, contentWhenEmpty, ariaLabel, ariaDescription }) => {
23
23
  const containerRef = useRef(null);
24
24
  const colors = useSeriesColorResolver(series);
25
25
  const dimensions = useChartDimensions({
@@ -77,8 +77,7 @@ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRa
77
77
  categoryCount: geometry.arcs.length,
78
78
  seriesKeys: legendKeys,
79
79
  disabled: noTooltip || isLoading || isEmpty,
80
- isLoading,
81
- onPinnedChange
80
+ isLoading
82
81
  });
83
82
  const buildCategoryTooltip = useCallback((index) => {
84
83
  const chartArc = geometry.arcs[index];
@@ -101,28 +100,10 @@ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRa
101
100
  formatLabel
102
101
  ]);
103
102
  /**
104
- * A slice reads better than the generic "label: row, row" sentence.
105
- *
106
- * The frame's default would render "Enterprise: 42.1% of total 1,240", which
107
- * puts the share where a reader expects the value.
108
- */
109
- const describeCategory = useCallback((index) => {
110
- const chartArc = geometry.arcs[index];
111
- if (!chartArc) return "";
112
- const share = `${Math.round(chartArc.share * 1e3) / 10}% of total`;
113
- return `${formatLabel(chartArc.label)}, ${formatValue(chartArc.value)}, ${share}`;
114
- }, [
115
- geometry.arcs,
116
- formatValue,
117
- formatLabel
118
- ]);
119
- /**
120
103
  * Targets reuse each arc's own `d`, drawn again transparent above the marks.
121
104
  *
122
- * The arcs themselves stop being interactive: hit testing, focus and the
123
- * focus ring then work identically on all three charts, instead of the pie
124
- * attaching handlers permanently and toggling `data-interactive` while the
125
- * cartesian charts rendered their targets away.
105
+ * The arcs themselves stay pure marks: hit testing then works identically on
106
+ * all three charts, instead of the pie hit-testing its visible arcs directly.
126
107
  */
127
108
  const categoryTargets = useMemo(() => geometry.arcs.map((chartArc) => ({
128
109
  key: chartArc.id,
@@ -145,8 +126,6 @@ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRa
145
126
  tooltipRenderer,
146
127
  categoryTargets,
147
128
  categoryTargetsTransform: `translate(${geometry.centerX}, ${geometry.centerY})`,
148
- wrapCategoryNavigation: true,
149
- describeCategory,
150
129
  placeAwayFromX: geometry.centerX,
151
130
  verticalAlign: ChartTooltipVerticalAlign.CENTERED,
152
131
  isEmpty,
@@ -154,7 +133,7 @@ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRa
154
133
  contentWhenEmpty,
155
134
  showLegend,
156
135
  legendItems,
157
- legendInset: 0,
136
+ legendPlacement: ChartLegendPlacement.RIGHT,
158
137
  plotOverlay: showCenter && !isEmpty ? /* @__PURE__ */ jsx(ChartDonutCenter, {
159
138
  centerX: dimensions.margin.left + geometry.centerX,
160
139
  centerY: dimensions.margin.top + geometry.centerY,
@@ -1,5 +1,5 @@
1
1
  import { ChartValueUnit } from "./types";
2
- import type { ChartLabelFormatter, ChartPlotTooltipModel, ChartValueFormatter } from "./types";
2
+ import type { ChartLabelFormatter, ChartValueFormatter } from "./types";
3
3
  /**
4
4
  * Format a value with a built-in unit.
5
5
  *
@@ -17,11 +17,3 @@ export declare function formatChartValue(value: number, unit: ChartValueUnit): s
17
17
  export declare function resolveValueFormatter(valueFormatter?: ChartValueFormatter, unit?: ChartValueUnit): ChartValueFormatter;
18
18
  /** Pick the effective label formatter, defaulting to identity. */
19
19
  export declare function resolveLabelFormatter(labelFormatter?: ChartLabelFormatter): ChartLabelFormatter;
20
- /**
21
- * Flatten a tooltip model into one sentence, for a screen reader.
22
- *
23
- * Derived from the tooltip rather than written separately so the two cannot
24
- * drift: whatever a sighted reader sees on hover is what a keyboard reader
25
- * hears on focus, by construction.
26
- */
27
- export declare function describeTooltipModel(model: ChartPlotTooltipModel): string;
@@ -55,17 +55,5 @@ function resolveValueFormatter(valueFormatter, unit) {
55
55
  function resolveLabelFormatter(labelFormatter) {
56
56
  return labelFormatter ?? ((label) => label);
57
57
  }
58
- /**
59
- * Flatten a tooltip model into one sentence, for a screen reader.
60
- *
61
- * Derived from the tooltip rather than written separately so the two cannot
62
- * drift: whatever a sighted reader sees on hover is what a keyboard reader
63
- * hears on focus, by construction.
64
- */
65
- function describeTooltipModel(model) {
66
- if (model.rows.length === 0) return model.label;
67
- const rows = model.rows.map((row) => `${row.label} ${row.formattedValue}`).join(", ");
68
- return `${model.label}: ${rows}`;
69
- }
70
58
  //#endregion
71
- export { describeTooltipModel, formatChartValue, resolveLabelFormatter, resolveValueFormatter };
59
+ export { formatChartValue, resolveLabelFormatter, resolveValueFormatter };
@@ -185,27 +185,24 @@ export declare const CHART_RESTORE_DELAY_MS = 200;
185
185
  *
186
186
  * The grammar is inherited from the reference charts and is the opposite of the
187
187
  * obvious one: hovering does not brighten the hovered mark, it *softens*
188
- * everything else. `MUTED` applies to marks outside the hovered category;
189
- * `FADED` to marks outside a *pinned* one.
188
+ * everything else. `MUTED` applies to marks outside the hovered category or
189
+ * series.
190
190
  *
191
191
  * The step down from ACTIVE is deliberately steep. These are large filled areas
192
192
  * — bars and arcs — and a filled shape still reads as present at an opacity
193
193
  * where a hairline would have vanished, so a timid step barely registers as a
194
194
  * highlight at all.
195
- *
196
- * Keep `FADED` below `MUTED`, or pinning becomes visually indistinguishable
197
- * from hovering — the pin exists to say "I am holding this one", which only
198
- * reads if the rest recede further than they do on hover.
199
195
  */
200
196
  export declare const CHART_MARK_OPACITY_ACTIVE = 1;
201
197
  export declare const CHART_MARK_OPACITY_MUTED = 0.1;
202
- export declare const CHART_MARK_OPACITY_FADED = 0.04;
203
198
  /** Distance in px between the tooltip and its anchor. */
204
199
  export declare const CHART_TOOLTIP_OFFSET = 10;
205
200
  /** Minimum width of the tooltip, in px. */
206
201
  export declare const CHART_TOOLTIP_MIN_WIDTH = 168;
207
202
  /** Maximum width of the tooltip, in px. */
208
203
  export declare const CHART_TOOLTIP_MAX_WIDTH = 320;
204
+ /** Gap in px between the plot box and a side-placed legend. */
205
+ export declare const CHART_LEGEND_SIDE_GAP = 16;
209
206
  /**
210
207
  * Approximate width of one CAPTION-size character.
211
208
  *
@@ -195,27 +195,24 @@ var CHART_RESTORE_DELAY_MS = 200;
195
195
  *
196
196
  * The grammar is inherited from the reference charts and is the opposite of the
197
197
  * obvious one: hovering does not brighten the hovered mark, it *softens*
198
- * everything else. `MUTED` applies to marks outside the hovered category;
199
- * `FADED` to marks outside a *pinned* one.
198
+ * everything else. `MUTED` applies to marks outside the hovered category or
199
+ * series.
200
200
  *
201
201
  * The step down from ACTIVE is deliberately steep. These are large filled areas
202
202
  * — bars and arcs — and a filled shape still reads as present at an opacity
203
203
  * where a hairline would have vanished, so a timid step barely registers as a
204
204
  * highlight at all.
205
- *
206
- * Keep `FADED` below `MUTED`, or pinning becomes visually indistinguishable
207
- * from hovering — the pin exists to say "I am holding this one", which only
208
- * reads if the rest recede further than they do on hover.
209
205
  */
210
206
  var CHART_MARK_OPACITY_ACTIVE = 1;
211
207
  var CHART_MARK_OPACITY_MUTED = .1;
212
- var CHART_MARK_OPACITY_FADED = .04;
213
208
  /** Distance in px between the tooltip and its anchor. */
214
209
  var CHART_TOOLTIP_OFFSET = 10;
215
210
  /** Minimum width of the tooltip, in px. */
216
211
  var CHART_TOOLTIP_MIN_WIDTH = 168;
217
212
  /** Maximum width of the tooltip, in px. */
218
213
  var CHART_TOOLTIP_MAX_WIDTH = 320;
214
+ /** Gap in px between the plot box and a side-placed legend. */
215
+ var CHART_LEGEND_SIDE_GAP = 16;
219
216
  /**
220
217
  * Approximate width of one CAPTION-size character.
221
218
  *
@@ -264,4 +261,4 @@ var CHART_PALETTE_ORDER = [
264
261
  ChartPalette.RED
265
262
  ];
266
263
  //#endregion
267
- export { AGGREGATED_SLICE_KEY, AUTO_MARGIN_LEFT_STEP, AXIS_TITLE_BAND, AXIS_TITLE_GAP, BAR_GAP_COMFORTABLE, BAR_GAP_MEDIUM, BAR_GAP_TIGHT, BAR_RADIUS, BAR_RADIUS_NARROW, BAR_WIDTH_RATIO, CAPTION_CHAR_WIDTH_PX, CATEGORY_AXIS_LABEL_GAP, CATEGORY_AXIS_LABEL_HEIGHT, CHART_MARK_OPACITY_ACTIVE, CHART_MARK_OPACITY_FADED, CHART_MARK_OPACITY_MUTED, CHART_PALETTE_ORDER, CHART_RESTORE_DELAY_MS, CHART_TOOLTIP_MAX_WIDTH, CHART_TOOLTIP_MIN_WIDTH, CHART_TOOLTIP_OFFSET, CHART_TRANSITION_MS, DEFAULT_CHART_MARGIN, DEFAULT_LINE_STROKE_WIDTH, DEFAULT_VALUE_TICK_COUNT, GRID_LINE_BLEED, GROUP_GAP_COMFORTABLE, GROUP_GAP_MEDIUM, GROUP_GAP_TIGHT, LINE_AREA_OPACITY, LINE_POINT_RADIUS, MAX_AUTO_MARGIN_LEFT, MAX_BAR_WIDTH, MAX_GAP_SHARE, MIN_AUTO_MARGIN_LEFT, MIN_BARS_FOR_TIGHT_SPACING, MIN_BAR_LENGTH, MIN_CATEGORY_LABEL_GAP, NARROW_BAR_WIDTH, PIE_CHART_MARGIN, PIE_CORNER_RADIUS, PIE_DONUT_INNER_RATIO, PIE_MAX_AUTO_INNER_RATIO, PIE_MAX_INSET_SHARE, PIE_MIN_SLICE_SHARE, PIE_PAD_ANGLE, PIE_TOOLTIP_ANCHOR_INSET, STACK_SEGMENT_GAP, VALUE_AXIS_LABEL_HEIGHT, VALUE_AXIS_TICK_GAP, WIDTH_FOR_MEDIUM_SPACING, WIDTH_FOR_TIGHT_SPACING };
264
+ export { AGGREGATED_SLICE_KEY, AUTO_MARGIN_LEFT_STEP, AXIS_TITLE_BAND, AXIS_TITLE_GAP, BAR_GAP_COMFORTABLE, BAR_GAP_MEDIUM, BAR_GAP_TIGHT, BAR_RADIUS, BAR_RADIUS_NARROW, BAR_WIDTH_RATIO, CAPTION_CHAR_WIDTH_PX, CATEGORY_AXIS_LABEL_GAP, CATEGORY_AXIS_LABEL_HEIGHT, CHART_LEGEND_SIDE_GAP, CHART_MARK_OPACITY_ACTIVE, CHART_MARK_OPACITY_MUTED, CHART_PALETTE_ORDER, CHART_RESTORE_DELAY_MS, CHART_TOOLTIP_MAX_WIDTH, CHART_TOOLTIP_MIN_WIDTH, CHART_TOOLTIP_OFFSET, CHART_TRANSITION_MS, DEFAULT_CHART_MARGIN, DEFAULT_LINE_STROKE_WIDTH, DEFAULT_VALUE_TICK_COUNT, GRID_LINE_BLEED, GROUP_GAP_COMFORTABLE, GROUP_GAP_MEDIUM, GROUP_GAP_TIGHT, LINE_AREA_OPACITY, LINE_POINT_RADIUS, MAX_AUTO_MARGIN_LEFT, MAX_BAR_WIDTH, MAX_GAP_SHARE, MIN_AUTO_MARGIN_LEFT, MIN_BARS_FOR_TIGHT_SPACING, MIN_BAR_LENGTH, MIN_CATEGORY_LABEL_GAP, NARROW_BAR_WIDTH, PIE_CHART_MARGIN, PIE_CORNER_RADIUS, PIE_DONUT_INNER_RATIO, PIE_MAX_AUTO_INNER_RATIO, PIE_MAX_INSET_SHARE, PIE_MIN_SLICE_SHARE, PIE_PAD_ANGLE, PIE_TOOLTIP_ANCHOR_INSET, STACK_SEGMENT_GAP, VALUE_AXIS_LABEL_HEIGHT, VALUE_AXIS_TICK_GAP, WIDTH_FOR_MEDIUM_SPACING, WIDTH_FOR_TIGHT_SPACING };
@@ -120,6 +120,18 @@ export declare enum ChartKind {
120
120
  LINE = "LINE",
121
121
  PIE = "PIE"
122
122
  }
123
+ /**
124
+ * Where the legend sits relative to the plot.
125
+ *
126
+ * Its own enum rather than a branch on {@link ChartKind}, which promises to be
127
+ * nothing but a label for the accessible name.
128
+ */
129
+ export declare enum ChartLegendPlacement {
130
+ /** Beneath the plot, wrapping — the cartesian layout. */
131
+ BOTTOM = "BOTTOM",
132
+ /** Beside the plot, stacked, vertically centred on it — the pie layout. */
133
+ RIGHT = "RIGHT"
134
+ }
123
135
  /** How the category axis copes when labels outgrow their slots. */
124
136
  export declare enum ChartCategoryLabelMode {
125
137
  /** Render every label that fits; otherwise show every nth. The default. */
@@ -139,12 +151,10 @@ export declare enum ChartCategoryLabelMode {
139
151
  * DOM and trigger a React warning.
140
152
  */
141
153
  export declare enum ChartMarkState {
142
- /** Full strength — the default, and the hovered or pinned category. */
154
+ /** Full strength — the default, and the hovered category. */
143
155
  ACTIVE = "active",
144
156
  /** Softened, for categories other than the hovered one. */
145
- MUTED = "muted",
146
- /** Furthest back, for categories outside a pinned one. */
147
- FADED = "faded"
157
+ MUTED = "muted"
148
158
  }
149
159
  /** Which pair of a rectangle's corners carries the radius. */
150
160
  export declare enum BarCorners {
@@ -80,6 +80,19 @@ var ChartKind = /* @__PURE__ */ function(ChartKind) {
80
80
  ChartKind["PIE"] = "PIE";
81
81
  return ChartKind;
82
82
  }({});
83
+ /**
84
+ * Where the legend sits relative to the plot.
85
+ *
86
+ * Its own enum rather than a branch on {@link ChartKind}, which promises to be
87
+ * nothing but a label for the accessible name.
88
+ */
89
+ var ChartLegendPlacement = /* @__PURE__ */ function(ChartLegendPlacement) {
90
+ /** Beneath the plot, wrapping — the cartesian layout. */
91
+ ChartLegendPlacement["BOTTOM"] = "BOTTOM";
92
+ /** Beside the plot, stacked, vertically centred on it — the pie layout. */
93
+ ChartLegendPlacement["RIGHT"] = "RIGHT";
94
+ return ChartLegendPlacement;
95
+ }({});
83
96
  /** How the category axis copes when labels outgrow their slots. */
84
97
  var ChartCategoryLabelMode = /* @__PURE__ */ function(ChartCategoryLabelMode) {
85
98
  /** Render every label that fits; otherwise show every nth. The default. */
@@ -100,12 +113,10 @@ var ChartCategoryLabelMode = /* @__PURE__ */ function(ChartCategoryLabelMode) {
100
113
  * DOM and trigger a React warning.
101
114
  */
102
115
  var ChartMarkState = /* @__PURE__ */ function(ChartMarkState) {
103
- /** Full strength — the default, and the hovered or pinned category. */
116
+ /** Full strength — the default, and the hovered category. */
104
117
  ChartMarkState["ACTIVE"] = "active";
105
118
  /** Softened, for categories other than the hovered one. */
106
119
  ChartMarkState["MUTED"] = "muted";
107
- /** Furthest back, for categories outside a pinned one. */
108
- ChartMarkState["FADED"] = "faded";
109
120
  return ChartMarkState;
110
121
  }({});
111
122
  /** Which pair of a rectangle's corners carries the radius. */
@@ -152,4 +163,4 @@ var ChartTargetShape = /* @__PURE__ */ function(ChartTargetShape) {
152
163
  return ChartTargetShape;
153
164
  }({});
154
165
  //#endregion
155
- export { BarChartNormalization, BarCorners, ChartCategoryLabelMode, ChartKind, ChartMarkState, ChartPalette, ChartTargetShape, ChartValueUnit, LineChartCurve };
166
+ export { BarChartNormalization, BarCorners, ChartCategoryLabelMode, ChartKind, ChartLegendPlacement, ChartMarkState, ChartPalette, ChartTargetShape, ChartValueUnit, LineChartCurve };