@galaxy-io/dls 1.5.5 → 1.5.6

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.
@@ -24,5 +24,5 @@ export type BarChartProps<TMetric extends string, TComponentKey extends string =
24
24
  * `bars` in a group render side by side, several `components` in a bar stack,
25
25
  * and a chart doing both at once needs no extra configuration.
26
26
  */
27
- declare const BarChart: <TMetric extends string, TComponentKey extends string = string>({ series, groups, width, height, fillWidth, fillHeight, aspectRatio, margin, normalization, showCursor, valueUnit, valueFormatter, labelFormatter, valueDomain, categoryLabelMode, categoryAxisTitle, valueAxisTitle, showGrid, showLegend, legendMaxItems, noTooltip, tooltipRenderer, isLoading, contentWhenEmpty, ariaLabel, ariaDescription, }: BarChartProps<TMetric, TComponentKey>) => import("react").JSX.Element;
27
+ declare const BarChart: <TMetric extends string, TComponentKey extends string = string>({ series, groups, width, height, fillWidth, fillHeight, aspectRatio, margin, normalization, showCursor, valueUnit, valueFormatter, labelFormatter, valueDomain, categoryLabelMode, categoryAxisTitle, valueAxisTitle, showGrid, showLegend, legendMaxItems, noTooltip, tooltipRenderer, tooltipMaxItems, isLoading, contentWhenEmpty, ariaLabel, ariaDescription, }: BarChartProps<TMetric, TComponentKey>) => import("react").JSX.Element;
28
28
  export default BarChart;
@@ -17,7 +17,7 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
17
17
  * `bars` in a group render side by side, several `components` in a bar stack,
18
18
  * and a chart doing both at once needs no extra configuration.
19
19
  */
20
- var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRatio, margin, normalization = BarChartNormalization.NONE, showCursor = true, valueUnit, valueFormatter, labelFormatter, valueDomain, categoryLabelMode, categoryAxisTitle, valueAxisTitle, showGrid = true, showLegend = true, legendMaxItems, noTooltip = false, tooltipRenderer, isLoading = false, contentWhenEmpty, ariaLabel, ariaDescription }) => {
20
+ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRatio, margin, normalization = BarChartNormalization.NONE, showCursor = true, valueUnit, valueFormatter, labelFormatter, valueDomain, categoryLabelMode, categoryAxisTitle, valueAxisTitle, showGrid = true, showLegend = true, legendMaxItems, noTooltip = false, tooltipRenderer, tooltipMaxItems, isLoading = false, contentWhenEmpty, ariaLabel, ariaDescription }) => {
21
21
  const containerRef = useRef(null);
22
22
  const colors = useSeriesColorResolver(series);
23
23
  /**
@@ -176,6 +176,7 @@ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRa
176
176
  noTooltip,
177
177
  buildCategoryTooltip,
178
178
  tooltipRenderer,
179
+ tooltipMaxItems,
179
180
  categoryTargets,
180
181
  anchorHalfWidth: categoryStep / 2,
181
182
  isEmpty,
@@ -78,6 +78,8 @@ export interface ChartFrameProps {
78
78
  */
79
79
  buildCategoryTooltip: (index: number) => ChartPlotTooltipModel | null;
80
80
  tooltipRenderer?: ChartTooltipRenderer;
81
+ /** Row cap for the built-in tooltip body. See {@link BaseChartProps.tooltipMaxItems}. */
82
+ tooltipMaxItems?: number;
81
83
  /**
82
84
  * One target per category, in plot coordinates and in category order.
83
85
  *
@@ -109,5 +111,5 @@ export interface ChartFrameProps {
109
111
  */
110
112
  legendInset?: number;
111
113
  }
112
- declare const ChartFrame: ({ containerRef, dimensions, fillWidth, fillHeight, interaction, kind, categoryCount, ariaLabel, ariaDescription, axes, children, plotOverlay, noTooltip, buildCategoryTooltip, tooltipRenderer, categoryTargets, categoryTargetsTransform, anchorHalfWidth, placeAwayFromX, verticalAlign, isEmpty, isLoading, contentWhenEmpty, showLegend, legendItems, legendMaxItems, legendPlacement, legendInset, }: ChartFrameProps) => import("react").JSX.Element;
114
+ declare const ChartFrame: ({ containerRef, dimensions, fillWidth, fillHeight, interaction, kind, categoryCount, ariaLabel, ariaDescription, axes, children, plotOverlay, noTooltip, buildCategoryTooltip, tooltipRenderer, tooltipMaxItems, categoryTargets, categoryTargetsTransform, anchorHalfWidth, placeAwayFromX, verticalAlign, isEmpty, isLoading, contentWhenEmpty, showLegend, legendItems, legendMaxItems, legendPlacement, legendInset, }: ChartFrameProps) => import("react").JSX.Element;
113
115
  export default ChartFrame;
@@ -9,7 +9,7 @@ import { match } from "ts-pattern";
9
9
  import { useId, useMemo } from "react";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
11
  //#region src/charts/ChartFrame.tsx
12
- var ChartFrame = ({ containerRef, dimensions, fillWidth, fillHeight, interaction, kind, categoryCount, ariaLabel, ariaDescription, axes, children, plotOverlay, noTooltip = false, buildCategoryTooltip, tooltipRenderer, categoryTargets, categoryTargetsTransform, anchorHalfWidth, placeAwayFromX, verticalAlign, isEmpty, isLoading = false, contentWhenEmpty, showLegend = false, legendItems, legendMaxItems, legendPlacement = ChartLegendPlacement.BOTTOM, legendInset }) => {
12
+ var ChartFrame = ({ containerRef, dimensions, fillWidth, fillHeight, interaction, kind, categoryCount, ariaLabel, ariaDescription, axes, children, plotOverlay, noTooltip = false, buildCategoryTooltip, tooltipRenderer, tooltipMaxItems, categoryTargets, categoryTargetsTransform, anchorHalfWidth, placeAwayFromX, verticalAlign, isEmpty, isLoading = false, contentWhenEmpty, showLegend = false, legendItems, legendMaxItems, legendPlacement = ChartLegendPlacement.BOTTOM, legendInset }) => {
13
13
  const { width, height, margin, isMeasured, reservedHeight, reservedAspectRatio } = dimensions;
14
14
  const generatedId = useId();
15
15
  const descriptionId = ariaDescription ? `${generatedId}-desc` : void 0;
@@ -101,7 +101,8 @@ var ChartFrame = ({ containerRef, dimensions, fillWidth, fillHeight, interaction
101
101
  anchorHalfWidth,
102
102
  placeAwayFromX: placeAwayFromX === void 0 ? void 0 : placeAwayFromX + margin.left,
103
103
  verticalAlign,
104
- renderer: tooltipRenderer
104
+ renderer: tooltipRenderer,
105
+ maxItems: tooltipMaxItems
105
106
  }),
106
107
  isMeasured && isEmpty && !isLoading && /* @__PURE__ */ jsx(ChartEmptyState, { content: contentWhenEmpty })
107
108
  ]
@@ -23,6 +23,8 @@ interface ChartTooltipProps {
23
23
  placeAwayFromX?: number;
24
24
  verticalAlign?: ChartTooltipVerticalAlign;
25
25
  renderer?: ChartTooltipRenderer;
26
+ /** Cap on built-in body rows; the rest collapse into "+N more". */
27
+ maxItems?: number;
26
28
  }
27
- declare const ChartTooltip: ({ model, containerWidth, containerHeight, anchorHalfWidth, placeAwayFromX, verticalAlign, renderer, }: ChartTooltipProps) => import("react").JSX.Element;
29
+ declare const ChartTooltip: ({ model, containerWidth, containerHeight, anchorHalfWidth, placeAwayFromX, verticalAlign, renderer, maxItems, }: ChartTooltipProps) => import("react").JSX.Element;
28
30
  export default ChartTooltip;
@@ -7,7 +7,7 @@ import { ChartTooltipGrid, ChartTooltipLabelCell, ChartTooltipPositioner, ChartT
7
7
  import { Fragment, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  //#region src/charts/ChartTooltip.tsx
10
- var ChartTooltip = ({ model, containerWidth, containerHeight, anchorHalfWidth, placeAwayFromX, verticalAlign, renderer }) => {
10
+ var ChartTooltip = ({ model, containerWidth, containerHeight, anchorHalfWidth, placeAwayFromX, verticalAlign, renderer, maxItems }) => {
11
11
  const [retained, setRetained] = useState(model);
12
12
  if (model !== null && model !== retained) setRetained(model);
13
13
  const { tooltipRef, x, y, isMeasured } = useChartTooltipPosition({
@@ -20,6 +20,10 @@ var ChartTooltip = ({ model, containerWidth, containerHeight, anchorHalfWidth, p
20
20
  verticalAlign
21
21
  });
22
22
  const displayed = model ?? retained;
23
+ const rows = displayed?.rows ?? [];
24
+ const cap = maxItems === void 0 ? rows.length : Math.max(1, maxItems);
25
+ const visibleRows = rows.slice(0, cap);
26
+ const hiddenCount = rows.length - visibleRows.length;
23
27
  return /* @__PURE__ */ jsx(ChartTooltipPositioner, {
24
28
  ref: tooltipRef,
25
29
  $x: x,
@@ -31,31 +35,38 @@ var ChartTooltip = ({ model, containerWidth, containerHeight, anchorHalfWidth, p
31
35
  direction: FlexDirection.COLUMN,
32
36
  gap: 8,
33
37
  fillWidth: true,
34
- children: [/* @__PURE__ */ jsx(Text, {
35
- size: TextSize.BODY_SM,
36
- variant: TextVariant.TERTIARY,
37
- isEllipsis: true,
38
- children: displayed.label
39
- }), displayed.rows.length === 0 ? /* @__PURE__ */ jsx(Text, {
40
- size: TextSize.BODY_SM,
41
- variant: TextVariant.SECONDARY,
42
- children: "No data"
43
- }) : /* @__PURE__ */ jsx(ChartTooltipGrid, { children: displayed.rows.map((row) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(ChartTooltipLabelCell, { children: [/* @__PURE__ */ jsx(FlexItem, {
44
- shrink: 0,
45
- children: /* @__PURE__ */ jsx(Circle, {
46
- size: 8,
47
- hex: row.color
38
+ children: [
39
+ /* @__PURE__ */ jsx(Text, {
40
+ variant: TextVariant.SECONDARY,
41
+ isEllipsis: true,
42
+ children: displayed.label
43
+ }),
44
+ displayed.rows.length === 0 ? /* @__PURE__ */ jsx(Text, {
45
+ size: TextSize.BODY_SM,
46
+ variant: TextVariant.SECONDARY,
47
+ children: "No data"
48
+ }) : /* @__PURE__ */ jsx(ChartTooltipGrid, { children: visibleRows.map((row) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(ChartTooltipLabelCell, { children: [/* @__PURE__ */ jsx(FlexItem, {
49
+ shrink: 0,
50
+ children: /* @__PURE__ */ jsx(Circle, {
51
+ size: 8,
52
+ hex: row.color
53
+ })
54
+ }), /* @__PURE__ */ jsx(Text, {
55
+ size: TextSize.BODY_SM,
56
+ isEllipsis: true,
57
+ children: row.label
58
+ })] }), /* @__PURE__ */ jsx(ChartTooltipValueCell, { children: /* @__PURE__ */ jsx(Text, {
59
+ size: TextSize.BODY_SM,
60
+ weight: TextWeight.MEDIUM,
61
+ align: "right",
62
+ children: row.formattedValue
63
+ }) })] }, row.key)) }),
64
+ hiddenCount > 0 && /* @__PURE__ */ jsx(Text, {
65
+ size: TextSize.BODY_SM,
66
+ variant: TextVariant.SECONDARY,
67
+ children: `+${hiddenCount} more`
48
68
  })
49
- }), /* @__PURE__ */ jsx(Text, {
50
- size: TextSize.BODY_SM,
51
- isEllipsis: true,
52
- children: row.label
53
- })] }), /* @__PURE__ */ jsx(ChartTooltipValueCell, { children: /* @__PURE__ */ jsx(Text, {
54
- size: TextSize.BODY_SM,
55
- weight: TextWeight.MEDIUM,
56
- align: "right",
57
- children: row.formattedValue
58
- }) })] }, row.key)) })]
69
+ ]
59
70
  })
60
71
  });
61
72
  };
@@ -34,5 +34,5 @@ export type LineChartProps<TMetric extends string> = BaseCartesianChartProps & C
34
34
  * what a reader wants, and it avoids the proximity search a
35
35
  * nearest-point-to-cursor model needs.
36
36
  */
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, legendMaxItems, noTooltip, tooltipRenderer, isLoading, contentWhenEmpty, ariaLabel, ariaDescription, }: 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, legendMaxItems, noTooltip, tooltipRenderer, tooltipMaxItems, isLoading, contentWhenEmpty, ariaLabel, ariaDescription, }: LineChartProps<TMetric>) => import("react").JSX.Element;
38
38
  export default LineChart;
@@ -18,7 +18,7 @@ import { Fragment as Fragment$1, 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, legendMaxItems, noTooltip = false, tooltipRenderer, isLoading = false, contentWhenEmpty, ariaLabel, ariaDescription }) => {
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, legendMaxItems, noTooltip = false, tooltipRenderer, tooltipMaxItems, 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({
@@ -136,6 +136,7 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
136
136
  noTooltip,
137
137
  buildCategoryTooltip,
138
138
  tooltipRenderer,
139
+ tooltipMaxItems,
139
140
  categoryTargets,
140
141
  anchorHalfWidth: geometry.step / 2,
141
142
  isEmpty,
@@ -40,5 +40,5 @@ export type PieChartProps<TSlice extends string> = BaseChartProps & ChartSize &
40
40
  * each arc is its own target. Small slices are folded into an "Other" bucket by
41
41
  * default, which keeps every remaining arc large enough to actually hit.
42
42
  */
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, legendMaxItems, noTooltip, tooltipRenderer, isLoading, contentWhenEmpty, ariaLabel, ariaDescription, }: 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, legendMaxItems, noTooltip, tooltipRenderer, tooltipMaxItems, isLoading, contentWhenEmpty, ariaLabel, ariaDescription, }: PieChartProps<TSlice>) => import("react").JSX.Element;
44
44
  export default PieChart;
@@ -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, legendMaxItems, noTooltip = false, tooltipRenderer, isLoading = false, contentWhenEmpty, ariaLabel, ariaDescription }) => {
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, legendMaxItems, noTooltip = false, tooltipRenderer, tooltipMaxItems, isLoading = false, contentWhenEmpty, ariaLabel, ariaDescription }) => {
23
23
  const containerRef = useRef(null);
24
24
  const colors = useSeriesColorResolver(series);
25
25
  const dimensions = useChartDimensions({
@@ -124,6 +124,7 @@ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRa
124
124
  noTooltip,
125
125
  buildCategoryTooltip,
126
126
  tooltipRenderer,
127
+ tooltipMaxItems,
127
128
  categoryTargets,
128
129
  categoryTargetsTransform: `translate(${geometry.centerX}, ${geometry.centerY})`,
129
130
  placeAwayFromX: geometry.centerX,
@@ -448,6 +448,12 @@ export interface BaseChartProps {
448
448
  tooltipRenderer?: ChartTooltipRenderer;
449
449
  /** Suppress the tooltip and its hit targets entirely. */
450
450
  noTooltip?: boolean;
451
+ /**
452
+ * Cap on tooltip rows. Rows past the cap collapse into an inert "+N more"
453
+ * line. Applies to the built-in body only; a custom `tooltipRenderer`
454
+ * receives the full model. Clamped to at least 1.
455
+ */
456
+ tooltipMaxItems?: number;
451
457
  /** Show the legend beneath the plot. */
452
458
  showLegend?: boolean;
453
459
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galaxy-io/dls",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "Galaxy Design Language System",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",