@galaxy-io/dls 1.3.6 → 1.4.1
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 +20 -43
- package/dist/charts/ChartAxis.d.ts +2 -11
- package/dist/charts/ChartAxis.js +4 -5
- package/dist/charts/ChartEmptyState.js +3 -3
- 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 +16 -15
- package/dist/charts/ChartPrimitives.js +74 -65
- package/dist/charts/ChartTooltip.js +19 -37
- package/dist/charts/LineChart.js +48 -69
- 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/icons/GalaxyLogomark3D.js +4 -4
- package/dist/inputs/ColorInput.js +2 -2
- package/dist/inputs/CopyInput.js +4 -1
- package/dist/inputs/Input.d.ts +1 -1
- package/dist/inputs/MultiSelectInput.js +6 -6
- package/dist/inputs/SelectInput.js +6 -6
- 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 +28 -26
- package/dist/table/SpreadsheetCell.js +2 -2
- 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 +3 -3
- 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
|
@@ -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,24 +198,50 @@ 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.tertiary;
|
|
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
|
/**
|
|
219
|
+
* Two-column tooltip body: label column, one gutter, value column.
|
|
220
|
+
*
|
|
221
|
+
* A grid rather than per-row `space-between`, so every row shares the same
|
|
222
|
+
* column boundary: the value column is sized by the widest value and every
|
|
223
|
+
* value is guaranteed its full width, while the labels take the remainder and
|
|
224
|
+
* all ellipsize against the same edge. Per-row flex made the label→value gap
|
|
225
|
+
* drift with each label's length, which read as misalignment down the list.
|
|
226
|
+
*/
|
|
227
|
+
var ChartTooltipGrid = /*#__PURE__*/ styled("div")({
|
|
228
|
+
name: "ChartTooltipGrid",
|
|
229
|
+
class: "cwcko2m",
|
|
230
|
+
propsAsIs: false
|
|
231
|
+
});
|
|
232
|
+
/** Swatch + label. `min-width: 0` is what lets the label actually ellipsize. */
|
|
233
|
+
var ChartTooltipLabelCell = /*#__PURE__*/ styled("div")({
|
|
234
|
+
name: "ChartTooltipLabelCell",
|
|
235
|
+
class: "cqwhvyz",
|
|
236
|
+
propsAsIs: false
|
|
237
|
+
});
|
|
238
|
+
/** Right-aligned and never wrapped — the value always shows in full. */
|
|
239
|
+
var ChartTooltipValueCell = /*#__PURE__*/ styled("div")({
|
|
240
|
+
name: "ChartTooltipValueCell",
|
|
241
|
+
class: "c1iaray",
|
|
242
|
+
propsAsIs: false
|
|
243
|
+
});
|
|
244
|
+
/**
|
|
236
245
|
* Content well inside a donut hole.
|
|
237
246
|
*
|
|
238
247
|
* Rendered as HTML positioned over the SVG rather than as `<text>`, so the
|
|
@@ -240,32 +249,32 @@ var ChartTooltipPositioner = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
240
249
|
* of the DLS. `pointer-events: none` keeps it from stealing hover from the arc
|
|
241
250
|
* behind it.
|
|
242
251
|
*/
|
|
243
|
-
var
|
|
244
|
-
var
|
|
245
|
-
var
|
|
252
|
+
var _exp27 = () => ({ $centerX }) => `${$centerX}px`;
|
|
253
|
+
var _exp28 = () => ({ $centerY }) => `${$centerY}px`;
|
|
254
|
+
var _exp30 = () => ({ $diameter }) => `${$diameter}px`;
|
|
246
255
|
var ChartCenterBox = /*#__PURE__*/ styled("div")({
|
|
247
256
|
name: "ChartCenterBox",
|
|
248
|
-
class: "
|
|
257
|
+
class: "cz6jod1",
|
|
249
258
|
propsAsIs: false,
|
|
250
259
|
vars: {
|
|
251
|
-
"
|
|
252
|
-
"
|
|
253
|
-
"
|
|
260
|
+
"cz6jod1-0": [_exp27()],
|
|
261
|
+
"cz6jod1-1": [_exp28()],
|
|
262
|
+
"cz6jod1-2": [_exp30()]
|
|
254
263
|
}
|
|
255
264
|
});
|
|
256
265
|
/**
|
|
257
266
|
* Sits slightly above centre, over where the bars would be, so the axes stay
|
|
258
267
|
* legible underneath.
|
|
259
268
|
*/
|
|
260
|
-
var
|
|
261
|
-
var
|
|
269
|
+
var _exp31 = () => ({ theme }) => theme.color.border.primary;
|
|
270
|
+
var _exp32 = () => ({ theme }) => theme.color.background.primary;
|
|
262
271
|
var ChartEmptyOverlay = withTheme(/*#__PURE__*/ styled("div")({
|
|
263
272
|
name: "ChartEmptyOverlay",
|
|
264
|
-
class: "
|
|
273
|
+
class: "c1de5mqk",
|
|
265
274
|
propsAsIs: false,
|
|
266
275
|
vars: {
|
|
267
|
-
"
|
|
268
|
-
"
|
|
276
|
+
"c1de5mqk-0": [_exp31()],
|
|
277
|
+
"c1de5mqk-1": [_exp32()]
|
|
269
278
|
}
|
|
270
279
|
}));
|
|
271
280
|
/**
|
|
@@ -277,23 +286,23 @@ var ChartEmptyOverlay = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
277
286
|
* the marks dim instantly while their legend entries sit through the full
|
|
278
287
|
* {@link CHART_RESTORE_DELAY_MS}, and the two visibly fall out of step.
|
|
279
288
|
*/
|
|
280
|
-
var
|
|
281
|
-
var
|
|
282
|
-
var
|
|
283
|
-
var
|
|
284
|
-
var
|
|
285
|
-
var
|
|
289
|
+
var _exp33 = () => ({ $vertical }) => $vertical ? "column" : "row";
|
|
290
|
+
var _exp34 = () => ({ $vertical }) => $vertical ? "nowrap" : "wrap";
|
|
291
|
+
var _exp35 = () => ({ $vertical }) => $vertical ? "flex-start" : "center";
|
|
292
|
+
var _exp36 = () => ({ $vertical }) => $vertical ? "8px" : "8px 16px";
|
|
293
|
+
var _exp37 = () => ({ $vertical }) => $vertical ? "0" : "10px";
|
|
294
|
+
var _exp38 = () => ({ $inset }) => `${$inset}px`;
|
|
286
295
|
var ChartLegendRow = /*#__PURE__*/ styled("div")({
|
|
287
296
|
name: "ChartLegendRow",
|
|
288
|
-
class: "
|
|
297
|
+
class: "cjirv6a",
|
|
289
298
|
propsAsIs: false,
|
|
290
299
|
vars: {
|
|
291
|
-
"
|
|
292
|
-
"
|
|
293
|
-
"
|
|
294
|
-
"
|
|
295
|
-
"
|
|
296
|
-
"
|
|
300
|
+
"cjirv6a-0": [_exp33()],
|
|
301
|
+
"cjirv6a-1": [_exp34()],
|
|
302
|
+
"cjirv6a-2": [_exp35()],
|
|
303
|
+
"cjirv6a-3": [_exp36()],
|
|
304
|
+
"cjirv6a-4": [_exp37()],
|
|
305
|
+
"cjirv6a-5": [_exp38()]
|
|
297
306
|
}
|
|
298
307
|
});
|
|
299
308
|
/**
|
|
@@ -310,14 +319,14 @@ var ChartLegendRow = /*#__PURE__*/ styled("div")({
|
|
|
310
319
|
*/
|
|
311
320
|
var ChartLegendItemButton = /*#__PURE__*/ styled("button")({
|
|
312
321
|
name: "ChartLegendItemButton",
|
|
313
|
-
class: "
|
|
322
|
+
class: "c1armna5",
|
|
314
323
|
propsAsIs: false
|
|
315
324
|
});
|
|
316
325
|
/** The same row, when the legend is inert — no button semantics to announce. */
|
|
317
326
|
var ChartLegendItemStatic = /*#__PURE__*/ styled("div")({
|
|
318
327
|
name: "ChartLegendItemStatic",
|
|
319
|
-
class: "
|
|
328
|
+
class: "cgd77rv",
|
|
320
329
|
propsAsIs: false
|
|
321
330
|
});
|
|
322
331
|
//#endregion
|
|
323
|
-
export { ChartArcPath, ChartAreaPath, ChartAxisLabelBox, ChartBarPath, ChartCenterBox, ChartCursorLine, ChartEmptyOverlay, ChartGridLine, ChartHitTarget, ChartHitTargetPath, ChartLegendItemButton, ChartLegendItemStatic, ChartLegendRow, ChartLinePath, ChartPlotBox, ChartPlotGroup, ChartPointCircle, ChartRoot,
|
|
332
|
+
export { ChartArcPath, ChartAreaPath, ChartAxisLabelBox, ChartBarPath, ChartCenterBox, ChartCursorLine, ChartEmptyOverlay, ChartGridLine, ChartHitTarget, ChartHitTargetPath, ChartLegendItemButton, ChartLegendItemStatic, ChartLegendRow, ChartLinePath, ChartPlotBox, ChartPlotGroup, ChartPointCircle, ChartRoot, ChartSvg, ChartTooltipGrid, ChartTooltipLabelCell, ChartTooltipPositioner, ChartTooltipValueCell };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Text, { TextSize, TextVariant, TextWeight } from "../text/Text.js";
|
|
2
2
|
import FlexItem from "../containers/FlexItem.js";
|
|
3
|
-
import FlexWrapper, {
|
|
3
|
+
import FlexWrapper, { FlexDirection } from "../containers/FlexWrapper.js";
|
|
4
4
|
import Circle from "../shapes/Circle.js";
|
|
5
5
|
import { useChartTooltipPosition } from "./useChartTooltipPosition.js";
|
|
6
|
-
import { ChartTooltipPositioner } from "./ChartPrimitives.js";
|
|
7
|
-
import { useState } from "react";
|
|
6
|
+
import { ChartTooltipGrid, ChartTooltipLabelCell, ChartTooltipPositioner, ChartTooltipValueCell } from "./ChartPrimitives.js";
|
|
7
|
+
import { Fragment, useState } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
//#region src/charts/ChartTooltip.tsx
|
|
10
10
|
var ChartTooltip = ({ model, containerWidth, containerHeight, anchorHalfWidth, placeAwayFromX, verticalAlign, renderer }) => {
|
|
@@ -36,40 +36,22 @@ var ChartTooltip = ({ model, containerWidth, containerHeight, anchorHalfWidth, p
|
|
|
36
36
|
variant: TextVariant.TERTIARY,
|
|
37
37
|
isEllipsis: true,
|
|
38
38
|
children: displayed.label
|
|
39
|
-
}), /* @__PURE__ */ jsx(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
size: 8,
|
|
56
|
-
hex: row.color
|
|
57
|
-
})
|
|
58
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
59
|
-
size: TextSize.BODY_SM,
|
|
60
|
-
isEllipsis: true,
|
|
61
|
-
children: row.label
|
|
62
|
-
})]
|
|
63
|
-
}), /* @__PURE__ */ jsx(FlexItem, {
|
|
64
|
-
shrink: 0,
|
|
65
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
66
|
-
size: TextSize.BODY_SM,
|
|
67
|
-
weight: TextWeight.MEDIUM,
|
|
68
|
-
children: row.formattedValue
|
|
69
|
-
})
|
|
70
|
-
})]
|
|
71
|
-
}, row.key))
|
|
72
|
-
})]
|
|
39
|
+
}), /* @__PURE__ */ jsx(ChartTooltipGrid, { children: displayed.rows.map((row) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(ChartTooltipLabelCell, { children: [/* @__PURE__ */ jsx(FlexItem, {
|
|
40
|
+
shrink: 0,
|
|
41
|
+
children: /* @__PURE__ */ jsx(Circle, {
|
|
42
|
+
size: 8,
|
|
43
|
+
hex: row.color
|
|
44
|
+
})
|
|
45
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
46
|
+
size: TextSize.BODY_SM,
|
|
47
|
+
isEllipsis: true,
|
|
48
|
+
children: row.label
|
|
49
|
+
})] }), /* @__PURE__ */ jsx(ChartTooltipValueCell, { children: /* @__PURE__ */ jsx(Text, {
|
|
50
|
+
size: TextSize.BODY_SM,
|
|
51
|
+
weight: TextWeight.MEDIUM,
|
|
52
|
+
align: "right",
|
|
53
|
+
children: row.formattedValue
|
|
54
|
+
}) })] }, row.key)) })]
|
|
73
55
|
})
|
|
74
56
|
});
|
|
75
57
|
};
|
package/dist/charts/LineChart.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ChartKind, ChartTargetShape, LineChartCurve } from "./types.js";
|
|
2
|
-
import { LINE_AREA_OPACITY, LINE_POINT_RADIUS
|
|
2
|
+
import { LINE_AREA_OPACITY, LINE_POINT_RADIUS } from "./constants.js";
|
|
3
3
|
import { useSeriesColorResolver } from "./useSeriesColorResolver.js";
|
|
4
4
|
import { useChartInteraction } from "./useChartInteraction.js";
|
|
5
5
|
import { useCartesianChartLayout } from "./useCartesianChartLayout.js";
|
|
6
6
|
import { buildLineChartGeometry, getLineValueDomain } from "./lineChartGeometry.js";
|
|
7
|
-
import { ChartAreaPath, ChartCursorLine, ChartLinePath, ChartPointCircle
|
|
7
|
+
import { ChartAreaPath, ChartCursorLine, ChartLinePath, ChartPointCircle } from "./ChartPrimitives.js";
|
|
8
8
|
import ChartFrame from "./ChartFrame.js";
|
|
9
9
|
import { ChartCategoryAxis, ChartValueAxis } from "./ChartAxis.js";
|
|
10
10
|
import { useCallback, useMemo, useRef } from "react";
|
|
11
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
//#region src/charts/LineChart.tsx
|
|
13
13
|
/**
|
|
14
14
|
* Line chart over a categorical x-axis.
|
|
@@ -21,27 +21,9 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
21
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
|
-
/**
|
|
25
|
-
* The data actually rendered: the caller's, or ghost lines while loading.
|
|
26
|
-
*
|
|
27
|
-
* Loading replaces the chart wholesale with skeleton data pushed through the
|
|
28
|
-
* real geometry pipeline — offset lines drawn with their area fills, so the
|
|
29
|
-
* placeholder has the layered depth of a real multi-series chart. The cast is
|
|
30
|
-
* safe because nothing derived from it ever surfaces: labels are hidden,
|
|
31
|
-
* targets are off, the legend shows stubs, and the accessible name says
|
|
32
|
-
* "loading" instead of counting.
|
|
33
|
-
*/
|
|
34
|
-
const displayLines = useMemo(() => isLoading ? SKELETON_LINE_SERIES.map((values, lineIndex) => ({
|
|
35
|
-
metric: `skeleton-${lineIndex}`,
|
|
36
|
-
showArea: true,
|
|
37
|
-
points: values.map((value, index) => ({
|
|
38
|
-
x: `skeleton-${index}`,
|
|
39
|
-
y: value
|
|
40
|
-
}))
|
|
41
|
-
})) : lines, [isLoading, lines]);
|
|
42
24
|
const { dimensions, domain, valueTicks, formatValue, formatLabel } = useCartesianChartLayout({
|
|
43
25
|
containerRef,
|
|
44
|
-
rawDomain: useMemo(() => getLineValueDomain(
|
|
26
|
+
rawDomain: useMemo(() => getLineValueDomain(lines), [lines]),
|
|
45
27
|
valueDomain,
|
|
46
28
|
width,
|
|
47
29
|
height,
|
|
@@ -56,10 +38,10 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
|
|
|
56
38
|
categoryAxisTitle
|
|
57
39
|
});
|
|
58
40
|
const { plotWidth, plotHeight } = dimensions;
|
|
59
|
-
const resolveColor = useCallback(({ metric }) =>
|
|
41
|
+
const resolveColor = useCallback(({ metric }) => colors.resolve(metric), [colors]);
|
|
60
42
|
const geometry = useMemo(() => buildLineChartGeometry({
|
|
61
|
-
lines
|
|
62
|
-
categories
|
|
43
|
+
lines,
|
|
44
|
+
categories,
|
|
63
45
|
plotWidth,
|
|
64
46
|
plotHeight,
|
|
65
47
|
curve,
|
|
@@ -67,8 +49,7 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
|
|
|
67
49
|
strokeWidth,
|
|
68
50
|
resolveColor
|
|
69
51
|
}), [
|
|
70
|
-
|
|
71
|
-
isLoading,
|
|
52
|
+
lines,
|
|
72
53
|
categories,
|
|
73
54
|
plotWidth,
|
|
74
55
|
plotHeight,
|
|
@@ -77,7 +58,7 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
|
|
|
77
58
|
strokeWidth,
|
|
78
59
|
resolveColor
|
|
79
60
|
]);
|
|
80
|
-
const isEmpty = geometry.categories.length === 0 ||
|
|
61
|
+
const isEmpty = geometry.categories.length === 0 || lines.length === 0;
|
|
81
62
|
const legendItems = useMemo(() => colors.keys.map((metric) => ({
|
|
82
63
|
key: metric,
|
|
83
64
|
label: series[metric].label,
|
|
@@ -87,7 +68,8 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
|
|
|
87
68
|
const interaction = useChartInteraction({
|
|
88
69
|
categoryCount: geometry.columns.length,
|
|
89
70
|
seriesKeys: legendKeys,
|
|
90
|
-
disabled: noTooltip || isLoading || isEmpty
|
|
71
|
+
disabled: noTooltip || isLoading || isEmpty,
|
|
72
|
+
isLoading
|
|
91
73
|
});
|
|
92
74
|
const activeColumn = interaction.activeIndex === null ? null : geometry.columns[interaction.activeIndex];
|
|
93
75
|
const buildCategoryTooltip = useCallback((index) => {
|
|
@@ -121,42 +103,7 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
|
|
|
121
103
|
width: column.bandWidth,
|
|
122
104
|
height: plotHeight
|
|
123
105
|
})), [geometry.columns, plotHeight]);
|
|
124
|
-
|
|
125
|
-
geometry.paths.map((linePath) => linePath.areaPath ? /* @__PURE__ */ jsx(ChartAreaPath, {
|
|
126
|
-
d: linePath.areaPath,
|
|
127
|
-
fill: linePath.color,
|
|
128
|
-
fillOpacity: LINE_AREA_OPACITY,
|
|
129
|
-
"data-state": interaction.getMarkState({ seriesKey: linePath.metric })
|
|
130
|
-
}, `${linePath.id}:area`) : null),
|
|
131
|
-
showCursor && activeColumn && /* @__PURE__ */ jsx(ChartCursorLine, {
|
|
132
|
-
x1: activeColumn.x,
|
|
133
|
-
x2: activeColumn.x,
|
|
134
|
-
y1: 0,
|
|
135
|
-
y2: plotHeight
|
|
136
|
-
}),
|
|
137
|
-
geometry.paths.map((linePath) => /* @__PURE__ */ jsx(ChartLinePath, {
|
|
138
|
-
d: linePath.path,
|
|
139
|
-
stroke: linePath.color,
|
|
140
|
-
strokeWidth: linePath.strokeWidth,
|
|
141
|
-
strokeDasharray: linePath.dashArray,
|
|
142
|
-
"data-state": interaction.getMarkState({ seriesKey: linePath.metric })
|
|
143
|
-
}, linePath.id)),
|
|
144
|
-
geometry.isolatedPoints.map((point) => /* @__PURE__ */ jsx(ChartPointCircle, {
|
|
145
|
-
cx: point.x,
|
|
146
|
-
cy: point.y,
|
|
147
|
-
r: LINE_POINT_RADIUS,
|
|
148
|
-
fill: point.color,
|
|
149
|
-
"data-state": interaction.getMarkState({ seriesKey: point.metric })
|
|
150
|
-
}, `${point.id}:isolated`)),
|
|
151
|
-
activeColumn?.points.map((point) => /* @__PURE__ */ jsx(ChartPointCircle, {
|
|
152
|
-
cx: point.x,
|
|
153
|
-
cy: point.y,
|
|
154
|
-
r: LINE_POINT_RADIUS,
|
|
155
|
-
fill: point.color,
|
|
156
|
-
"data-state": interaction.getMarkState({ seriesKey: point.metric })
|
|
157
|
-
}, point.id))
|
|
158
|
-
] });
|
|
159
|
-
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
106
|
+
return /* @__PURE__ */ jsxs(ChartFrame, {
|
|
160
107
|
containerRef,
|
|
161
108
|
dimensions,
|
|
162
109
|
fillWidth,
|
|
@@ -166,7 +113,7 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
|
|
|
166
113
|
categoryCount: geometry.categories.length,
|
|
167
114
|
ariaLabel,
|
|
168
115
|
ariaDescription,
|
|
169
|
-
axes: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ChartValueAxis, {
|
|
116
|
+
axes: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ChartValueAxis, {
|
|
170
117
|
ticks: valueTicks,
|
|
171
118
|
scale: geometry.valueScale,
|
|
172
119
|
plotWidth,
|
|
@@ -174,7 +121,6 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
|
|
|
174
121
|
marginLeft: dimensions.margin.left,
|
|
175
122
|
formatter: formatValue,
|
|
176
123
|
showGrid,
|
|
177
|
-
showLabels: !isLoading,
|
|
178
124
|
title: valueAxisTitle
|
|
179
125
|
}), /* @__PURE__ */ jsx(ChartCategoryAxis, {
|
|
180
126
|
labels: geometry.categories,
|
|
@@ -184,7 +130,6 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
|
|
|
184
130
|
plotHeight,
|
|
185
131
|
formatter: formatLabel,
|
|
186
132
|
mode: categoryLabelMode,
|
|
187
|
-
showLabels: !isLoading,
|
|
188
133
|
title: categoryAxisTitle
|
|
189
134
|
})] }),
|
|
190
135
|
noTooltip,
|
|
@@ -197,7 +142,41 @@ var LineChart = ({ series, lines, categories, width, height, fillWidth, fillHeig
|
|
|
197
142
|
contentWhenEmpty,
|
|
198
143
|
showLegend,
|
|
199
144
|
legendItems,
|
|
200
|
-
children:
|
|
145
|
+
children: [
|
|
146
|
+
geometry.paths.map((linePath) => linePath.areaPath ? /* @__PURE__ */ jsx(ChartAreaPath, {
|
|
147
|
+
d: linePath.areaPath,
|
|
148
|
+
fill: linePath.color,
|
|
149
|
+
fillOpacity: LINE_AREA_OPACITY,
|
|
150
|
+
"data-state": interaction.getMarkState({ seriesKey: linePath.metric })
|
|
151
|
+
}, `${linePath.id}:area`) : null),
|
|
152
|
+
showCursor && activeColumn && /* @__PURE__ */ jsx(ChartCursorLine, {
|
|
153
|
+
x1: activeColumn.x,
|
|
154
|
+
x2: activeColumn.x,
|
|
155
|
+
y1: 0,
|
|
156
|
+
y2: plotHeight
|
|
157
|
+
}),
|
|
158
|
+
geometry.paths.map((linePath) => /* @__PURE__ */ jsx(ChartLinePath, {
|
|
159
|
+
d: linePath.path,
|
|
160
|
+
stroke: linePath.color,
|
|
161
|
+
strokeWidth: linePath.strokeWidth,
|
|
162
|
+
strokeDasharray: linePath.dashArray,
|
|
163
|
+
"data-state": interaction.getMarkState({ seriesKey: linePath.metric })
|
|
164
|
+
}, linePath.id)),
|
|
165
|
+
geometry.isolatedPoints.map((point) => /* @__PURE__ */ jsx(ChartPointCircle, {
|
|
166
|
+
cx: point.x,
|
|
167
|
+
cy: point.y,
|
|
168
|
+
r: LINE_POINT_RADIUS,
|
|
169
|
+
fill: point.color,
|
|
170
|
+
"data-state": interaction.getMarkState({ seriesKey: point.metric })
|
|
171
|
+
}, `${point.id}:isolated`)),
|
|
172
|
+
activeColumn?.points.map((point) => /* @__PURE__ */ jsx(ChartPointCircle, {
|
|
173
|
+
cx: point.x,
|
|
174
|
+
cy: point.y,
|
|
175
|
+
r: LINE_POINT_RADIUS,
|
|
176
|
+
fill: point.color,
|
|
177
|
+
"data-state": interaction.getMarkState({ seriesKey: point.metric })
|
|
178
|
+
}, point.id))
|
|
179
|
+
]
|
|
201
180
|
});
|
|
202
181
|
};
|
|
203
182
|
//#endregion
|
package/dist/charts/PieChart.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import FlexWrapper, { AlignItems, FlexDirection, JustifyContent } from "../containers/FlexWrapper.js";
|
|
2
2
|
import { ChartKind, ChartLegendPlacement, ChartTargetShape } from "./types.js";
|
|
3
|
-
import { PIE_CHART_MARGIN, PIE_MIN_SLICE_SHARE
|
|
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";
|
|
6
6
|
import { useChartInteraction } from "./useChartInteraction.js";
|
|
7
7
|
import { useChartFormatters } from "./useChartFormatters.js";
|
|
8
8
|
import { useChartDimensions } from "./useChartDimensions.js";
|
|
9
9
|
import { buildPieChartGeometry } from "./pieChartGeometry.js";
|
|
10
|
-
import { ChartArcPath, ChartCenterBox
|
|
10
|
+
import { ChartArcPath, ChartCenterBox } from "./ChartPrimitives.js";
|
|
11
11
|
import ChartFrame from "./ChartFrame.js";
|
|
12
12
|
import { useCallback, useMemo, useRef } from "react";
|
|
13
13
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -40,23 +40,9 @@ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRa
|
|
|
40
40
|
});
|
|
41
41
|
const getSliceLabel = useCallback((sliceKey) => series[sliceKey]?.label ?? sliceKey, [series]);
|
|
42
42
|
const getSliceColor = useCallback((sliceKey) => series[sliceKey]?.color, [series]);
|
|
43
|
-
|
|
44
|
-
* The slices actually rendered: the caller's, or three ghost arcs while
|
|
45
|
-
* loading, pushed through the real geometry so the skeleton donut gets the
|
|
46
|
-
* true pad angles and corner radii. The cast is safe because nothing derived
|
|
47
|
-
* from skeleton data ever surfaces: targets are off, the legend shows stubs,
|
|
48
|
-
* and the accessible name says "loading" instead of counting slices.
|
|
49
|
-
*/
|
|
50
|
-
const displaySlices = useMemo(() => isLoading ? SKELETON_PIE_VALUES.map((value, index) => ({
|
|
51
|
-
key: `skeleton-${index}`,
|
|
52
|
-
value
|
|
53
|
-
})) : slices, [isLoading, slices]);
|
|
54
|
-
const resolveColor = useCallback(({ sliceKey, explicit }) => {
|
|
55
|
-
if (isLoading) return colors.placeholder;
|
|
56
|
-
return sliceKey === null ? colors.neutral : colors.resolve(sliceKey, explicit);
|
|
57
|
-
}, [colors, isLoading]);
|
|
43
|
+
const resolveColor = useCallback(({ sliceKey, explicit }) => sliceKey === null ? colors.neutral : colors.resolve(sliceKey, explicit), [colors]);
|
|
58
44
|
const geometry = useMemo(() => buildPieChartGeometry({
|
|
59
|
-
slices
|
|
45
|
+
slices,
|
|
60
46
|
plotWidth,
|
|
61
47
|
plotHeight,
|
|
62
48
|
innerRadiusRatio,
|
|
@@ -68,7 +54,7 @@ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRa
|
|
|
68
54
|
getSliceColor,
|
|
69
55
|
getSliceLabel
|
|
70
56
|
}), [
|
|
71
|
-
|
|
57
|
+
slices,
|
|
72
58
|
plotWidth,
|
|
73
59
|
plotHeight,
|
|
74
60
|
innerRadiusRatio,
|
|
@@ -90,7 +76,8 @@ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRa
|
|
|
90
76
|
const interaction = useChartInteraction({
|
|
91
77
|
categoryCount: geometry.arcs.length,
|
|
92
78
|
seriesKeys: legendKeys,
|
|
93
|
-
disabled: noTooltip || isLoading || isEmpty
|
|
79
|
+
disabled: noTooltip || isLoading || isEmpty,
|
|
80
|
+
isLoading
|
|
94
81
|
});
|
|
95
82
|
const buildCategoryTooltip = useCallback((index) => {
|
|
96
83
|
const chartArc = geometry.arcs[index];
|
|
@@ -123,18 +110,7 @@ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRa
|
|
|
123
110
|
shape: ChartTargetShape.PATH,
|
|
124
111
|
d: chartArc.path
|
|
125
112
|
})), [geometry.arcs]);
|
|
126
|
-
const showCenter = centerContent &&
|
|
127
|
-
const marks = /* @__PURE__ */ jsx("g", {
|
|
128
|
-
transform: `translate(${geometry.centerX}, ${geometry.centerY})`,
|
|
129
|
-
children: geometry.arcs.map((chartArc, index) => /* @__PURE__ */ jsx(ChartArcPath, {
|
|
130
|
-
d: chartArc.path,
|
|
131
|
-
fill: chartArc.color,
|
|
132
|
-
"data-state": interaction.getMarkState({
|
|
133
|
-
categoryIndex: index,
|
|
134
|
-
seriesKey: chartArc.id
|
|
135
|
-
})
|
|
136
|
-
}, chartArc.id))
|
|
137
|
-
});
|
|
113
|
+
const showCenter = centerContent && (innerRadiusRatio ?? .62) > 0;
|
|
138
114
|
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
139
115
|
containerRef,
|
|
140
116
|
dimensions,
|
|
@@ -164,7 +140,17 @@ var PieChart = ({ series, slices, width, height, fillWidth, fillHeight, aspectRa
|
|
|
164
140
|
diameter: geometry.innerRadius * 2,
|
|
165
141
|
children: centerContent
|
|
166
142
|
}) : null,
|
|
167
|
-
children:
|
|
143
|
+
children: /* @__PURE__ */ jsx("g", {
|
|
144
|
+
transform: `translate(${geometry.centerX}, ${geometry.centerY})`,
|
|
145
|
+
children: geometry.arcs.map((chartArc, index) => /* @__PURE__ */ jsx(ChartArcPath, {
|
|
146
|
+
d: chartArc.path,
|
|
147
|
+
fill: chartArc.color,
|
|
148
|
+
"data-state": interaction.getMarkState({
|
|
149
|
+
categoryIndex: index,
|
|
150
|
+
seriesKey: chartArc.id
|
|
151
|
+
})
|
|
152
|
+
}, chartArc.id))
|
|
153
|
+
})
|
|
168
154
|
});
|
|
169
155
|
};
|
|
170
156
|
/** Positions arbitrary content inside the donut hole. */
|
|
@@ -203,25 +203,6 @@ export declare const CHART_TOOLTIP_MIN_WIDTH = 168;
|
|
|
203
203
|
export declare const CHART_TOOLTIP_MAX_WIDTH = 320;
|
|
204
204
|
/** Gap in px between the plot box and a side-placed legend. */
|
|
205
205
|
export declare const CHART_LEGEND_SIDE_GAP = 16;
|
|
206
|
-
/**
|
|
207
|
-
* Ghost bar heights, one inner array per group — three bars each, so the
|
|
208
|
-
* skeleton reads as the grouped chart it usually stands in for rather than a
|
|
209
|
-
* sparse row of lone bars.
|
|
210
|
-
*/
|
|
211
|
-
export declare const SKELETON_BAR_GROUPS: number[][];
|
|
212
|
-
/**
|
|
213
|
-
* Ghost lines, one inner array per line, offset from each other and drawn with
|
|
214
|
-
* their area fills so the skeleton has the layered depth of a real multi-series
|
|
215
|
-
* chart instead of a single bare stroke.
|
|
216
|
-
*/
|
|
217
|
-
export declare const SKELETON_LINE_SERIES: number[][];
|
|
218
|
-
/** Ghost donut shares — three arcs, halving. */
|
|
219
|
-
export declare const SKELETON_PIE_VALUES: number[];
|
|
220
|
-
/**
|
|
221
|
-
* Skeleton pulse period, matching the cadence of `TextShimmer` and
|
|
222
|
-
* `AvatarShimmer` so charts load in step with everything else on the page.
|
|
223
|
-
*/
|
|
224
|
-
export declare const CHART_SKELETON_PULSE_MS = 2500;
|
|
225
206
|
/**
|
|
226
207
|
* Approximate width of one CAPTION-size character.
|
|
227
208
|
*
|