@redvars/peacock 3.16.0 → 3.17.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.
Files changed (147) hide show
  1. package/dist/assets/styles.css +1 -1
  2. package/dist/assets/styles.css.map +1 -1
  3. package/dist/assets/theme.js +19 -19
  4. package/dist/assets/tokens.css +1 -1
  5. package/dist/assets/tokens.css.map +1 -1
  6. package/dist/card-content.js +8 -7
  7. package/dist/card-content.js.map +1 -1
  8. package/dist/card.js +142 -98
  9. package/dist/card.js.map +1 -1
  10. package/dist/{chart-bar-D5dGFJfK.js → cartesian-chart-DgE4USyC.js} +529 -312
  11. package/dist/cartesian-chart-DgE4USyC.js.map +1 -0
  12. package/dist/chart-area.js +78 -0
  13. package/dist/chart-area.js.map +1 -0
  14. package/dist/chart-bar.js +283 -213
  15. package/dist/chart-bar.js.map +1 -1
  16. package/dist/{transform-DSwFSqzD.js → chart-base-C2qRMF48.js} +771 -102
  17. package/dist/chart-base-C2qRMF48.js.map +1 -0
  18. package/dist/chart-doughnut.js +55 -287
  19. package/dist/chart-doughnut.js.map +1 -1
  20. package/dist/chart-line.js +626 -0
  21. package/dist/chart-line.js.map +1 -0
  22. package/dist/chart-pie.js +637 -195
  23. package/dist/chart-pie.js.map +1 -1
  24. package/dist/code-editor.js +704 -131
  25. package/dist/code-editor.js.map +1 -1
  26. package/dist/code-group.js +188 -0
  27. package/dist/code-group.js.map +1 -0
  28. package/dist/code-highlighter.js +895 -257
  29. package/dist/code-highlighter.js.map +1 -1
  30. package/dist/custom-elements-jsdocs.json +1675 -222
  31. package/dist/custom-elements.json +13351 -3970
  32. package/dist/image.js +5 -1
  33. package/dist/image.js.map +1 -1
  34. package/dist/index.js +8 -7
  35. package/dist/index.js.map +1 -1
  36. package/dist/loader-full.js +1 -1
  37. package/dist/loader.js +9 -3
  38. package/dist/loader.js.map +1 -1
  39. package/dist/{is-dark-mode-DOcaw4Yq.js → observe-theme-change-DCifz1uv.js} +2 -6
  40. package/dist/observe-theme-change-DCifz1uv.js.map +1 -0
  41. package/dist/path-CJ0Arqcy.js +166 -0
  42. package/dist/path-CJ0Arqcy.js.map +1 -0
  43. package/dist/snackbar.js +89 -34
  44. package/dist/snackbar.js.map +1 -1
  45. package/dist/src/__internal/chart/cartesian-chart.d.ts +80 -0
  46. package/dist/src/__internal/chart/chart-base.d.ts +113 -0
  47. package/dist/src/__internal/chart/paths.d.ts +5 -0
  48. package/dist/src/__internal/chart/types.d.ts +42 -0
  49. package/dist/src/card/card-content.d.ts +2 -3
  50. package/dist/src/card/card.d.ts +31 -17
  51. package/dist/src/chart-area/chart-area.d.ts +54 -0
  52. package/dist/src/chart-area/index.d.ts +1 -0
  53. package/dist/src/chart-bar/chart-bar.d.ts +44 -33
  54. package/dist/src/chart-bar/index.d.ts +0 -1
  55. package/dist/src/chart-doughnut/chart-doughnut.d.ts +33 -39
  56. package/dist/src/chart-line/chart-line.d.ts +69 -0
  57. package/dist/src/chart-line/index.d.ts +1 -0
  58. package/dist/src/chart-pie/chart-pie.d.ts +63 -28
  59. package/dist/src/code-editor/code-editor.d.ts +52 -13
  60. package/dist/src/code-editor/editor-theme.d.ts +60 -0
  61. package/dist/src/code-highlighter/code-group.d.ts +52 -0
  62. package/dist/src/code-highlighter/code-highlighter.d.ts +122 -15
  63. package/dist/src/code-highlighter/index.d.ts +1 -0
  64. package/dist/src/code-highlighter/line-ranges.d.ts +24 -0
  65. package/dist/src/code-highlighter/local.d.ts +4 -1
  66. package/dist/src/code-highlighter/token-colors.d.ts +8 -0
  67. package/dist/src/index.d.ts +4 -2
  68. package/dist/src/snackbar/snackbar.d.ts +13 -1
  69. package/dist/src/toolbar/toolbar.d.ts +56 -51
  70. package/dist/table.js +9 -4
  71. package/dist/table.js.map +1 -1
  72. package/dist/test/chart.test.d.ts +1 -0
  73. package/dist/test/code-highlighter.test.d.ts +1 -0
  74. package/dist/token-colors-0TFHWbcq.js +81 -0
  75. package/dist/token-colors-0TFHWbcq.js.map +1 -0
  76. package/dist/toolbar.js +195 -184
  77. package/dist/toolbar.js.map +1 -1
  78. package/dist/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +1 -2
  80. package/readme.md +7 -6
  81. package/scss/_code-block.scss +139 -0
  82. package/scss/tokens.css +24 -0
  83. package/src/__internal/chart/cartesian-chart.ts +404 -0
  84. package/src/__internal/chart/chart-base.scss +252 -0
  85. package/src/__internal/chart/chart-base.ts +474 -0
  86. package/src/__internal/chart/paths.ts +28 -0
  87. package/src/__internal/chart/types.ts +49 -0
  88. package/src/card/card-content.ts +12 -9
  89. package/src/card/card.scss +66 -54
  90. package/src/card/card.ts +109 -73
  91. package/src/chart-area/chart-area.ts +82 -0
  92. package/src/chart-area/index.ts +1 -0
  93. package/src/chart-bar/chart-bar.ts +336 -250
  94. package/src/chart-bar/index.ts +0 -1
  95. package/src/chart-doughnut/chart-doughnut.ts +62 -262
  96. package/src/chart-doughnut/demo/index.html +14 -22
  97. package/src/chart-line/chart-line.scss +25 -0
  98. package/src/chart-line/chart-line.ts +346 -0
  99. package/src/chart-line/index.ts +1 -0
  100. package/src/chart-pie/chart-pie.scss +35 -16
  101. package/src/chart-pie/chart-pie.ts +282 -188
  102. package/src/chart-pie/demo/index.html +13 -21
  103. package/src/code-editor/code-editor.scss +132 -36
  104. package/src/code-editor/code-editor.ts +308 -88
  105. package/src/code-editor/demo/index.html +39 -12
  106. package/src/code-editor/editor-theme.ts +213 -0
  107. package/src/code-highlighter/code-group.scss +34 -0
  108. package/src/code-highlighter/code-group.ts +173 -0
  109. package/src/code-highlighter/code-highlighter.scss +226 -111
  110. package/src/code-highlighter/code-highlighter.ts +554 -199
  111. package/src/code-highlighter/demo/index.html +68 -4
  112. package/src/code-highlighter/index.ts +1 -0
  113. package/src/code-highlighter/line-ranges.ts +81 -0
  114. package/src/code-highlighter/local.ts +9 -3
  115. package/src/code-highlighter/token-colors.ts +42 -0
  116. package/src/index.ts +4 -2
  117. package/src/loader.ts +8 -2
  118. package/src/snackbar/demo/index.html +39 -4
  119. package/src/snackbar/snackbar.scss +27 -10
  120. package/src/snackbar/snackbar.ts +80 -37
  121. package/src/table/table.scss +7 -1
  122. package/src/table/table.ts +4 -3
  123. package/src/toolbar/toolbar-colors.scss +6 -7
  124. package/src/toolbar/toolbar.scss +35 -106
  125. package/src/toolbar/toolbar.ts +180 -80
  126. package/dist/array-D5vjT2Xm.js +0 -14
  127. package/dist/array-D5vjT2Xm.js.map +0 -1
  128. package/dist/chart-bar-D5dGFJfK.js.map +0 -1
  129. package/dist/chart-stacked-bar.js +0 -403
  130. package/dist/chart-stacked-bar.js.map +0 -1
  131. package/dist/copy-to-clipboard-upGx-Ueo.js +0 -39
  132. package/dist/copy-to-clipboard-upGx-Ueo.js.map +0 -1
  133. package/dist/is-dark-mode-DOcaw4Yq.js.map +0 -1
  134. package/dist/pie-Dz0IDiPt.js +0 -537
  135. package/dist/pie-Dz0IDiPt.js.map +0 -1
  136. package/dist/pierre-dark-DFWl0m-C.js +0 -4
  137. package/dist/pierre-dark-DFWl0m-C.js.map +0 -1
  138. package/dist/pierre-light-BEkAPImt.js +0 -4
  139. package/dist/pierre-light-BEkAPImt.js.map +0 -1
  140. package/dist/src/chart-bar/chart-stacked-bar.d.ts +0 -78
  141. package/dist/src/code-highlighter/constants.d.ts +0 -1
  142. package/dist/transform-DSwFSqzD.js.map +0 -1
  143. package/src/chart-bar/chart-bar.scss +0 -58
  144. package/src/chart-bar/chart-stacked-bar.ts +0 -398
  145. package/src/chart-doughnut/chart-donut.scss +0 -37
  146. package/src/code-highlighter/constants.ts +0 -117
  147. /package/dist/test/{chart-bar.test.d.ts → card.test.d.ts} +0 -0
@@ -1,47 +1,9 @@
1
- class InternMap extends Map {
2
- constructor(entries, key = keyof) {
3
- super();
4
- Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
5
- if (entries != null) for (const [key, value] of entries) this.set(key, value);
6
- }
7
- get(key) {
8
- return super.get(intern_get(this, key));
9
- }
10
- has(key) {
11
- return super.has(intern_get(this, key));
12
- }
13
- set(key, value) {
14
- return super.set(intern_set(this, key), value);
15
- }
16
- delete(key) {
17
- return super.delete(intern_delete(this, key));
18
- }
19
- }
20
-
21
- function intern_get({_intern, _key}, value) {
22
- const key = _key(value);
23
- return _intern.has(key) ? _intern.get(key) : value;
24
- }
25
-
26
- function intern_set({_intern, _key}, value) {
27
- const key = _key(value);
28
- if (_intern.has(key)) return _intern.get(key);
29
- _intern.set(key, value);
30
- return value;
31
- }
32
-
33
- function intern_delete({_intern, _key}, value) {
34
- const key = _key(value);
35
- if (_intern.has(key)) {
36
- value = _intern.get(key);
37
- _intern.delete(key);
38
- }
39
- return value;
40
- }
41
-
42
- function keyof(value) {
43
- return value !== null && typeof value === "object" ? value.valueOf() : value;
44
- }
1
+ import { _ as __decorate, a as i, A, b, i as i$1 } from './IndividualComponent-Bdwyrvd6.js';
2
+ import { n } from './property-B49QQ8pS.js';
3
+ import { r } from './state-DkTK9EGF.js';
4
+ import { e } from './query-CHb9Ft_d.js';
5
+ import { e as e$1 } from './class-map-DG7CA1et.js';
6
+ import { o } from './style-map-BQD5Et1D.js';
45
7
 
46
8
  var noop = {value: () => {}};
47
9
 
@@ -194,7 +156,7 @@ function selection_select(select) {
194
156
  // selection; we don’t ever want to create a selection backed by a live
195
157
  // HTMLCollection or NodeList. However, note that selection.selectAll will use a
196
158
  // static NodeList as a group, since it safely derived from querySelectorAll.
197
- function array(x) {
159
+ function array$1(x) {
198
160
  return x == null ? [] : Array.isArray(x) ? x : Array.from(x);
199
161
  }
200
162
 
@@ -210,7 +172,7 @@ function selectorAll(selector) {
210
172
 
211
173
  function arrayAll(select) {
212
174
  return function() {
213
- return array(select.apply(this, arguments));
175
+ return array$1(select.apply(this, arguments));
214
176
  };
215
177
  }
216
178
 
@@ -314,7 +276,7 @@ EnterNode.prototype = {
314
276
  querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); }
315
277
  };
316
278
 
317
- function constant$1(x) {
279
+ function constant$2(x) {
318
280
  return function() {
319
281
  return x;
320
282
  };
@@ -401,7 +363,7 @@ function selection_data(value, key) {
401
363
  parents = this._parents,
402
364
  groups = this._groups;
403
365
 
404
- if (typeof value !== "function") value = constant$1(value);
366
+ if (typeof value !== "function") value = constant$2(value);
405
367
 
406
368
  for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) {
407
369
  var parent = parents[j],
@@ -1456,7 +1418,7 @@ function hsl2rgb(h, m1, m2) {
1456
1418
  : m1) * 255;
1457
1419
  }
1458
1420
 
1459
- var constant = x => () => x;
1421
+ var constant$1 = x => () => x;
1460
1422
 
1461
1423
  function linear(a, d) {
1462
1424
  return function(t) {
@@ -1472,13 +1434,13 @@ function exponential(a, b, y) {
1472
1434
 
1473
1435
  function gamma(y) {
1474
1436
  return (y = +y) === 1 ? nogamma : function(a, b) {
1475
- return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
1437
+ return b - a ? exponential(a, b, y) : constant$1(isNaN(a) ? b : a);
1476
1438
  };
1477
1439
  }
1478
1440
 
1479
1441
  function nogamma(a, b) {
1480
1442
  var d = b - a;
1481
- return d ? linear(a, d) : constant(isNaN(a) ? b : a);
1443
+ return d ? linear(a, d) : constant$1(isNaN(a) ? b : a);
1482
1444
  }
1483
1445
 
1484
1446
  var interpolateRgb = (function rgbGamma(y) {
@@ -1503,12 +1465,72 @@ var interpolateRgb = (function rgbGamma(y) {
1503
1465
  return rgb$1;
1504
1466
  })(1);
1505
1467
 
1468
+ function numberArray(a, b) {
1469
+ if (!b) b = [];
1470
+ var n = a ? Math.min(b.length, a.length) : 0,
1471
+ c = b.slice(),
1472
+ i;
1473
+ return function(t) {
1474
+ for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
1475
+ return c;
1476
+ };
1477
+ }
1478
+
1479
+ function isNumberArray(x) {
1480
+ return ArrayBuffer.isView(x) && !(x instanceof DataView);
1481
+ }
1482
+
1483
+ function genericArray(a, b) {
1484
+ var nb = b ? b.length : 0,
1485
+ na = a ? Math.min(nb, a.length) : 0,
1486
+ x = new Array(na),
1487
+ c = new Array(nb),
1488
+ i;
1489
+
1490
+ for (i = 0; i < na; ++i) x[i] = interpolate$1(a[i], b[i]);
1491
+ for (; i < nb; ++i) c[i] = b[i];
1492
+
1493
+ return function(t) {
1494
+ for (i = 0; i < na; ++i) c[i] = x[i](t);
1495
+ return c;
1496
+ };
1497
+ }
1498
+
1499
+ function date(a, b) {
1500
+ var d = new Date;
1501
+ return a = +a, b = +b, function(t) {
1502
+ return d.setTime(a * (1 - t) + b * t), d;
1503
+ };
1504
+ }
1505
+
1506
1506
  function interpolateNumber(a, b) {
1507
1507
  return a = +a, b = +b, function(t) {
1508
1508
  return a * (1 - t) + b * t;
1509
1509
  };
1510
1510
  }
1511
1511
 
1512
+ function object(a, b) {
1513
+ var i = {},
1514
+ c = {},
1515
+ k;
1516
+
1517
+ if (a === null || typeof a !== "object") a = {};
1518
+ if (b === null || typeof b !== "object") b = {};
1519
+
1520
+ for (k in b) {
1521
+ if (k in a) {
1522
+ i[k] = interpolate$1(a[k], b[k]);
1523
+ } else {
1524
+ c[k] = b[k];
1525
+ }
1526
+ }
1527
+
1528
+ return function(t) {
1529
+ for (k in i) c[k] = i[k](t);
1530
+ return c;
1531
+ };
1532
+ }
1533
+
1512
1534
  var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
1513
1535
  reB = new RegExp(reA.source, "g");
1514
1536
 
@@ -1572,6 +1594,19 @@ function interpolateString(a, b) {
1572
1594
  });
1573
1595
  }
1574
1596
 
1597
+ function interpolate$1(a, b) {
1598
+ var t = typeof b, c;
1599
+ return b == null || t === "boolean" ? constant$1(b)
1600
+ : (t === "number" ? interpolateNumber
1601
+ : t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString)
1602
+ : b instanceof color ? interpolateRgb
1603
+ : b instanceof Date ? date
1604
+ : isNumberArray(b) ? numberArray
1605
+ : Array.isArray(b) ? genericArray
1606
+ : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
1607
+ : interpolateNumber)(a, b);
1608
+ }
1609
+
1575
1610
  var degrees = 180 / Math.PI;
1576
1611
 
1577
1612
  var identity = {
@@ -2620,6 +2655,10 @@ Transition.prototype = {
2620
2655
  [Symbol.iterator]: selection_prototype[Symbol.iterator]
2621
2656
  };
2622
2657
 
2658
+ function cubicOut(t) {
2659
+ return --t * t * t + 1;
2660
+ }
2661
+
2623
2662
  function cubicInOut(t) {
2624
2663
  return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
2625
2664
  }
@@ -2665,57 +2704,16 @@ function selection_transition(name) {
2665
2704
  selection.prototype.interrupt = selection_interrupt;
2666
2705
  selection.prototype.transition = selection_transition;
2667
2706
 
2668
- function initRange(domain, range) {
2669
- switch (arguments.length) {
2670
- case 0: break;
2671
- case 1: this.range(domain); break;
2672
- default: this.range(range).domain(domain); break;
2673
- }
2674
- return this;
2675
- }
2676
-
2677
- const implicit = Symbol("implicit");
2678
-
2679
- function ordinal() {
2680
- var index = new InternMap(),
2681
- domain = [],
2682
- range = [],
2683
- unknown = implicit;
2684
-
2685
- function scale(d) {
2686
- let i = index.get(d);
2687
- if (i === undefined) {
2688
- if (unknown !== implicit) return unknown;
2689
- index.set(d, i = domain.push(d) - 1);
2690
- }
2691
- return range[i % range.length];
2692
- }
2693
-
2694
- scale.domain = function(_) {
2695
- if (!arguments.length) return domain.slice();
2696
- domain = [], index = new InternMap();
2697
- for (const value of _) {
2698
- if (index.has(value)) continue;
2699
- index.set(value, domain.push(value) - 1);
2700
- }
2701
- return scale;
2702
- };
2703
-
2704
- scale.range = function(_) {
2705
- return arguments.length ? (range = Array.from(_), scale) : range.slice();
2706
- };
2707
-
2708
- scale.unknown = function(_) {
2709
- return arguments.length ? (unknown = _, scale) : unknown;
2710
- };
2711
-
2712
- scale.copy = function() {
2713
- return ordinal(domain, range).unknown(unknown);
2707
+ function constant(x) {
2708
+ return function constant() {
2709
+ return x;
2714
2710
  };
2711
+ }
2715
2712
 
2716
- initRange.apply(scale, arguments);
2717
-
2718
- return scale;
2713
+ function array(x) {
2714
+ return typeof x === "object" && "length" in x
2715
+ ? x // Array, TypedArray, NodeList, array-like
2716
+ : Array.from(x); // Map, Set, iterable, string, or anything else
2719
2717
  }
2720
2718
 
2721
2719
  function Transform(k, x, y) {
@@ -2763,5 +2761,676 @@ Transform.prototype = {
2763
2761
 
2764
2762
  Transform.prototype;
2765
2763
 
2766
- export { constant as a, color as b, cubicInOut as c, interpolateRgb as d, interpolateString as e, initRange as f, interpolateNumber as i, ordinal as o, select as s };
2767
- //# sourceMappingURL=transform-DSwFSqzD.js.map
2764
+ /** Number of `--color-chart-n` tokens series cycle through. */
2765
+ const CHART_PALETTE_SIZE = 8;
2766
+ /** Default motion duration for enter and data-change animations. */
2767
+ const DURATION = 450;
2768
+ /** Tooltip offset from the pointer or anchor. */
2769
+ const TOOLTIP_OFFSET = 12;
2770
+ /** The palette color for the series or slice at `index`. */
2771
+ function chartColor(index) {
2772
+ return `var(--color-chart-${(index % CHART_PALETTE_SIZE) + 1})`;
2773
+ }
2774
+ const compactFormat = new Intl.NumberFormat(undefined, {
2775
+ notation: 'compact',
2776
+ maximumFractionDigits: 1,
2777
+ });
2778
+ /**
2779
+ * Shared behaviour for every Peacock chart: container sizing, palette, value formatting,
2780
+ * tooltip, legend, keyboard navigation, the accessible data table, and loading and empty states.
2781
+ * Subclasses draw the marks with d3 into the SVG returned by `renderSvgContent()`.
2782
+ */
2783
+ class ChartBase extends i {
2784
+ constructor() {
2785
+ // ── Properties
2786
+ super(...arguments);
2787
+ /** Height of the plot in pixels. The width follows the container. */
2788
+ this.height = 300;
2789
+ /** Accessible name of the chart, read by screen readers. */
2790
+ this.label = '';
2791
+ /** Shows a skeleton while data loads. */
2792
+ this.loading = false;
2793
+ /** Shows the legend even for a single series. */
2794
+ this.showLegend = false;
2795
+ /** Hides the legend. */
2796
+ this.hideLegend = false;
2797
+ /** Hides the tooltip. */
2798
+ this.hideTooltip = false;
2799
+ /** Turns off enter and update animations. They are also off when the user prefers reduced motion. */
2800
+ this.disableAnimation = false;
2801
+ // ── State
2802
+ /** Keys of series or slices switched off in the legend. */
2803
+ this.hiddenKeys = new Set();
2804
+ /** Index of the hovered or focused category or slice, -1 for none. */
2805
+ this.activeIndex = -1;
2806
+ /** Width of the plot, measured from the container. */
2807
+ this.plotWidth = 0;
2808
+ /** Text for the polite live region, set during keyboard navigation. */
2809
+ this.announcement = '';
2810
+ /** Whether the marks have been drawn once. */
2811
+ this.hasDrawn = false;
2812
+ this.handlePointerMove = (event) => {
2813
+ const point = this.pointFromEvent(event);
2814
+ if (!point)
2815
+ return;
2816
+ const index = this.itemAtPoint(point.x, point.y);
2817
+ this.activeIndex = index;
2818
+ this.pointer = index >= 0 ? point : undefined;
2819
+ };
2820
+ this.handlePointerLeave = () => {
2821
+ this.activeIndex = -1;
2822
+ this.pointer = undefined;
2823
+ };
2824
+ this.handleClick = (event) => {
2825
+ const point = this.pointFromEvent(event);
2826
+ if (!point)
2827
+ return;
2828
+ const index = this.itemAtPoint(point.x, point.y);
2829
+ if (index >= 0)
2830
+ this.select(index);
2831
+ };
2832
+ this.handleKeyDown = (event) => {
2833
+ const count = this.getItemCount();
2834
+ if (!count)
2835
+ return;
2836
+ let next = this.activeIndex;
2837
+ switch (event.key) {
2838
+ case 'ArrowRight':
2839
+ case 'ArrowDown':
2840
+ next = next < 0 ? 0 : Math.min(next + 1, count - 1);
2841
+ break;
2842
+ case 'ArrowLeft':
2843
+ case 'ArrowUp':
2844
+ next = next < 0 ? count - 1 : Math.max(next - 1, 0);
2845
+ break;
2846
+ case 'Home':
2847
+ next = 0;
2848
+ break;
2849
+ case 'End':
2850
+ next = count - 1;
2851
+ break;
2852
+ case 'Escape':
2853
+ next = -1;
2854
+ break;
2855
+ case 'Enter':
2856
+ case ' ':
2857
+ if (this.activeIndex >= 0) {
2858
+ event.preventDefault();
2859
+ this.select(this.activeIndex);
2860
+ }
2861
+ return;
2862
+ default:
2863
+ return;
2864
+ }
2865
+ event.preventDefault();
2866
+ this.pointer = undefined;
2867
+ this.activeIndex = next;
2868
+ this.announce(next);
2869
+ };
2870
+ this.handleBlur = () => {
2871
+ this.activeIndex = -1;
2872
+ this.pointer = undefined;
2873
+ };
2874
+ }
2875
+ // ── Lifecycle
2876
+ connectedCallback() {
2877
+ super.connectedCallback();
2878
+ this.resizeObserver = new ResizeObserver(entries => {
2879
+ const width = Math.floor(entries[0]?.contentRect.width ?? 0);
2880
+ if (width !== this.plotWidth)
2881
+ this.plotWidth = width;
2882
+ });
2883
+ this.resizeObserver.observe(this);
2884
+ }
2885
+ disconnectedCallback() {
2886
+ super.disconnectedCallback();
2887
+ this.resizeObserver?.disconnect();
2888
+ this.resizeObserver = undefined;
2889
+ }
2890
+ updated(changed) {
2891
+ super.updated(changed);
2892
+ if (!this.svgElement || this.plotWidth <= 0)
2893
+ return;
2894
+ const drawKeys = this.drawProperties();
2895
+ const needsDraw = drawKeys.some(key => changed.has(key));
2896
+ if (needsDraw) {
2897
+ const resizeOnly = [...changed.keys()].every(key => key === 'plotWidth' || !drawKeys.includes(key));
2898
+ // The first draw animates the marks in; later resizes snap.
2899
+ this.draw((!resizeOnly || !this.hasDrawn) && this.motionEnabled());
2900
+ this.hasDrawn = true;
2901
+ this.drawHighlight();
2902
+ }
2903
+ else if (changed.has('activeIndex') || changed.has('activeSeries')) {
2904
+ this.drawHighlight();
2905
+ }
2906
+ }
2907
+ /** Property names that trigger a redraw when they change. */
2908
+ drawProperties() {
2909
+ return ['height', 'plotWidth', 'hiddenKeys', 'loading', 'valueFormatter'];
2910
+ }
2911
+ /** Whether the legend shows. */
2912
+ legendVisible() {
2913
+ if (this.hideLegend)
2914
+ return false;
2915
+ return this.showLegend || this.getSeries().length > 1;
2916
+ }
2917
+ /** Width and height of the SVG. */
2918
+ svgSize() {
2919
+ return { width: this.plotWidth, height: this.height };
2920
+ }
2921
+ /** Motion duration in ms, 0 when animation is off. */
2922
+ motionEnabled() {
2923
+ if (this.disableAnimation)
2924
+ return false;
2925
+ return !window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
2926
+ }
2927
+ /**
2928
+ * Returns a transition of `selection` when `animate` is true, else the selection itself, so
2929
+ * callers set end values once. Transitions share the attr/style API used here.
2930
+ */
2931
+ motion(selection, animate) {
2932
+ if (!animate) {
2933
+ selection.interrupt();
2934
+ return selection;
2935
+ }
2936
+ return selection
2937
+ .transition()
2938
+ .duration(DURATION)
2939
+ .ease(cubicOut);
2940
+ }
2941
+ /** Formats a value for tooltips and value labels. */
2942
+ formatValue(value) {
2943
+ return this.valueFormatter
2944
+ ? this.valueFormatter(value)
2945
+ : value.toLocaleString();
2946
+ }
2947
+ /** Formats an axis tick. */
2948
+ formatTick(value) {
2949
+ return this.valueFormatter
2950
+ ? this.valueFormatter(value)
2951
+ : compactFormat.format(value);
2952
+ }
2953
+ /** Whether a series or slice is switched off in the legend. */
2954
+ isHidden(key) {
2955
+ return this.hiddenKeys.has(key);
2956
+ }
2957
+ /** Extra content layered over the plot, such as the doughnut centre. */
2958
+ renderOverlay() {
2959
+ return A;
2960
+ }
2961
+ /** Skeleton shown while `loading`. */
2962
+ renderSkeleton() {
2963
+ const bars = [55, 80, 40, 95, 65, 75, 50];
2964
+ return b `<div
2965
+ class="skeleton skeleton-bars"
2966
+ style=${o({ height: `${this.height}px` })}
2967
+ aria-hidden="true"
2968
+ >
2969
+ ${bars.map(h => b `<span style=${o({ height: `${h}%` })}></span>`)}
2970
+ </div>`;
2971
+ }
2972
+ // ── Private methods
2973
+ pointFromEvent(event) {
2974
+ const rect = this.plotElement?.getBoundingClientRect();
2975
+ if (!rect)
2976
+ return undefined;
2977
+ return { x: event.clientX - rect.left, y: event.clientY - rect.top };
2978
+ }
2979
+ announce(index) {
2980
+ const model = index >= 0 ? this.getTooltip(index) : undefined;
2981
+ this.announcement = model
2982
+ ? `${model.title}. ${model.rows.map(row => `${row.label} ${row.value}`).join(', ')}`
2983
+ : '';
2984
+ }
2985
+ select(index) {
2986
+ this.dispatchEvent(new CustomEvent('chart-select', {
2987
+ bubbles: true,
2988
+ composed: true,
2989
+ detail: this.getSelectDetail(index),
2990
+ }));
2991
+ }
2992
+ toggleSeries(key) {
2993
+ const next = new Set(this.hiddenKeys);
2994
+ if (next.has(key))
2995
+ next.delete(key);
2996
+ else
2997
+ next.add(key);
2998
+ this.hiddenKeys = next;
2999
+ }
3000
+ // ── Render helpers
3001
+ renderTooltip() {
3002
+ if (this.hideTooltip || this.activeIndex < 0)
3003
+ return A;
3004
+ const model = this.getTooltip(this.activeIndex);
3005
+ if (!model || !model.rows.length)
3006
+ return A;
3007
+ const x = this.pointer?.x ?? model.x;
3008
+ const y = this.pointer?.y ?? model.y;
3009
+ const flip = x > this.plotWidth * 0.6;
3010
+ return b `<div
3011
+ class=${e$1({ tooltip: true, flip })}
3012
+ part="tooltip"
3013
+ aria-hidden="true"
3014
+ style=${o({
3015
+ left: `${flip ? x - TOOLTIP_OFFSET : x + TOOLTIP_OFFSET}px`,
3016
+ top: `${y}px`,
3017
+ })}
3018
+ >
3019
+ ${model.title
3020
+ ? b `<div class="tooltip-title">${model.title}</div>`
3021
+ : A}
3022
+ ${model.rows.map(row => b `<div class="tooltip-row">
3023
+ <span
3024
+ class="swatch"
3025
+ style=${o({ background: row.color })}
3026
+ ></span>
3027
+ <span class="tooltip-label">${row.label}</span>
3028
+ <span class="tooltip-value">${row.value}</span>
3029
+ </div>`)}
3030
+ </div>`;
3031
+ }
3032
+ renderLegend() {
3033
+ if (!this.legendVisible())
3034
+ return A;
3035
+ return b `<div class="legend" part="legend">
3036
+ ${this.getSeries().map(series => b `<button
3037
+ type="button"
3038
+ class=${e$1({
3039
+ 'legend-item': true,
3040
+ 'is-hidden': this.isHidden(series.key),
3041
+ })}
3042
+ aria-pressed=${this.isHidden(series.key) ? 'false' : 'true'}
3043
+ @click=${() => this.toggleSeries(series.key)}
3044
+ @pointerenter=${() => {
3045
+ this.activeSeries = series.key;
3046
+ }}
3047
+ @pointerleave=${() => {
3048
+ this.activeSeries = undefined;
3049
+ }}
3050
+ >
3051
+ <span
3052
+ class="swatch"
3053
+ style=${o({ background: series.color })}
3054
+ ></span>
3055
+ <span>${series.label}</span>
3056
+ </button>`)}
3057
+ </div>`;
3058
+ }
3059
+ renderPlot() {
3060
+ const { width, height } = this.svgSize();
3061
+ const name = this.label || 'Chart';
3062
+ return b `<div
3063
+ class="plot"
3064
+ part="plot"
3065
+ style=${o({ height: `${this.height}px` })}
3066
+ tabindex="0"
3067
+ role="group"
3068
+ aria-roledescription="chart"
3069
+ aria-label="${name}. Use the arrow keys to explore the data."
3070
+ @pointermove=${this.handlePointerMove}
3071
+ @pointerleave=${this.handlePointerLeave}
3072
+ @click=${this.handleClick}
3073
+ @keydown=${this.handleKeyDown}
3074
+ @blur=${this.handleBlur}
3075
+ >
3076
+ <svg class="chart-svg" aria-hidden="true" width=${width} height=${height}>
3077
+ ${this.renderSvgContent()}
3078
+ </svg>
3079
+ ${this.renderOverlay()} ${this.renderTooltip()}
3080
+ </div>`;
3081
+ }
3082
+ // ── Render
3083
+ render() {
3084
+ let body;
3085
+ if (this.loading) {
3086
+ body = this.renderSkeleton();
3087
+ }
3088
+ else if (!this.hasData()) {
3089
+ body = b `<div
3090
+ class="empty"
3091
+ style=${o({ height: `${this.height}px` })}
3092
+ >
3093
+ <slot name="empty">No data</slot>
3094
+ </div>`;
3095
+ }
3096
+ else {
3097
+ body = this.renderPlot();
3098
+ }
3099
+ const hasContent = !this.loading && this.hasData();
3100
+ return b `<div
3101
+ class="chart"
3102
+ part="container"
3103
+ aria-busy=${this.loading ? 'true' : 'false'}
3104
+ >
3105
+ ${body} ${hasContent ? this.renderLegend() : A}
3106
+ ${hasContent
3107
+ ? b `<table class="sr-only">
3108
+ <caption>
3109
+ ${this.label || 'Chart data'}
3110
+ </caption>
3111
+ ${this.renderTable()}
3112
+ </table>`
3113
+ : A}
3114
+ <div class="sr-only" aria-live="polite">${this.announcement}</div>
3115
+ </div>`;
3116
+ }
3117
+ }
3118
+ __decorate([
3119
+ n({ type: Number, reflect: true })
3120
+ ], ChartBase.prototype, "height", void 0);
3121
+ __decorate([
3122
+ n({ type: String })
3123
+ ], ChartBase.prototype, "label", void 0);
3124
+ __decorate([
3125
+ n({ type: Boolean, reflect: true })
3126
+ ], ChartBase.prototype, "loading", void 0);
3127
+ __decorate([
3128
+ n({ type: Boolean, attribute: 'show-legend' })
3129
+ ], ChartBase.prototype, "showLegend", void 0);
3130
+ __decorate([
3131
+ n({ type: Boolean, attribute: 'hide-legend' })
3132
+ ], ChartBase.prototype, "hideLegend", void 0);
3133
+ __decorate([
3134
+ n({ type: Boolean, attribute: 'hide-tooltip' })
3135
+ ], ChartBase.prototype, "hideTooltip", void 0);
3136
+ __decorate([
3137
+ n({ type: Boolean, attribute: 'disable-animation' })
3138
+ ], ChartBase.prototype, "disableAnimation", void 0);
3139
+ __decorate([
3140
+ n({ attribute: false })
3141
+ ], ChartBase.prototype, "valueFormatter", void 0);
3142
+ __decorate([
3143
+ r()
3144
+ ], ChartBase.prototype, "hiddenKeys", void 0);
3145
+ __decorate([
3146
+ r()
3147
+ ], ChartBase.prototype, "activeIndex", void 0);
3148
+ __decorate([
3149
+ r()
3150
+ ], ChartBase.prototype, "activeSeries", void 0);
3151
+ __decorate([
3152
+ r()
3153
+ ], ChartBase.prototype, "pointer", void 0);
3154
+ __decorate([
3155
+ r()
3156
+ ], ChartBase.prototype, "plotWidth", void 0);
3157
+ __decorate([
3158
+ r()
3159
+ ], ChartBase.prototype, "announcement", void 0);
3160
+ __decorate([
3161
+ e('svg.chart-svg')
3162
+ ], ChartBase.prototype, "svgElement", void 0);
3163
+ __decorate([
3164
+ e('.plot')
3165
+ ], ChartBase.prototype, "plotElement", void 0);
3166
+
3167
+ var css_248z = i$1`* {
3168
+ box-sizing: border-box;
3169
+ -webkit-tap-highlight-color: transparent;
3170
+ }
3171
+
3172
+ .screen-reader-only {
3173
+ display: none !important;
3174
+ }
3175
+
3176
+ [hidden] {
3177
+ display: none !important;
3178
+ }
3179
+
3180
+ :host {
3181
+ display: block;
3182
+ width: 100%;
3183
+ min-width: 0;
3184
+ color: var(--color-on-surface);
3185
+ --_chart-grid-color: var(--chart-grid-color, var(--color-outline-variant));
3186
+ --_chart-axis-color: var(--chart-axis-color, var(--color-on-surface-variant));
3187
+ --_chart-dim-opacity: var(--chart-dim-opacity, 0.4);
3188
+ --_chart-cursor-color: var(--chart-cursor-color, var(--color-on-surface));
3189
+ }
3190
+
3191
+ .chart {
3192
+ display: flex;
3193
+ flex-direction: column;
3194
+ gap: var(--spacing-200);
3195
+ width: 100%;
3196
+ }
3197
+
3198
+ .plot {
3199
+ position: relative;
3200
+ width: 100%;
3201
+ outline: none;
3202
+ touch-action: pan-y;
3203
+ border-radius: var(--shape-corner-small);
3204
+ }
3205
+ .plot:focus-visible {
3206
+ outline: 2px solid var(--color-primary);
3207
+ }
3208
+
3209
+ .chart-svg {
3210
+ display: block;
3211
+ overflow: visible;
3212
+ }
3213
+
3214
+ .gridline {
3215
+ stroke: var(--_chart-grid-color);
3216
+ stroke-dasharray: 3 3;
3217
+ shape-rendering: crispEdges;
3218
+ }
3219
+
3220
+ .baseline {
3221
+ stroke: var(--_chart-grid-color);
3222
+ shape-rendering: crispEdges;
3223
+ }
3224
+
3225
+ .axis-label {
3226
+ font-family: var(--typography-label-medium-font-family) !important;
3227
+ font-size: var(--typography-label-medium-font-size) !important;
3228
+ font-weight: var(--typography-label-medium-font-weight) !important;
3229
+ line-height: var(--typography-label-medium-line-height) !important;
3230
+ letter-spacing: var(--typography-label-medium-letter-spacing) !important;
3231
+ fill: var(--_chart-axis-color);
3232
+ }
3233
+
3234
+ .value-label {
3235
+ font-family: var(--typography-label-small-font-family) !important;
3236
+ font-size: var(--typography-label-small-font-size) !important;
3237
+ font-weight: var(--typography-label-small-font-weight) !important;
3238
+ line-height: var(--typography-label-small-line-height) !important;
3239
+ letter-spacing: var(--typography-label-small-letter-spacing) !important;
3240
+ fill: var(--color-on-surface);
3241
+ }
3242
+
3243
+ .cursor {
3244
+ fill: var(--_chart-cursor-color);
3245
+ stroke: var(--_chart-cursor-color);
3246
+ opacity: 0;
3247
+ pointer-events: none;
3248
+ transition: opacity var(--duration-short2) var(--easing-standard);
3249
+ }
3250
+ .cursor.is-visible {
3251
+ opacity: 0.08;
3252
+ }
3253
+
3254
+ .cursor-line.is-visible {
3255
+ opacity: 0.4;
3256
+ }
3257
+
3258
+ .mark {
3259
+ transition: opacity var(--duration-short3) var(--easing-standard);
3260
+ }
3261
+ .mark.is-dimmed {
3262
+ opacity: var(--_chart-dim-opacity);
3263
+ }
3264
+
3265
+ .tooltip {
3266
+ position: absolute;
3267
+ z-index: 1;
3268
+ min-width: 8rem;
3269
+ padding: var(--spacing-150) var(--spacing-200);
3270
+ border-radius: var(--shape-corner-small);
3271
+ background: var(--color-surface-container-high);
3272
+ color: var(--color-on-surface);
3273
+ box-shadow: var(--elevation-level2);
3274
+ pointer-events: none;
3275
+ transform: translateY(-50%);
3276
+ white-space: nowrap;
3277
+ }
3278
+ .tooltip.flip {
3279
+ transform: translate(-100%, -50%);
3280
+ }
3281
+
3282
+ .tooltip-title {
3283
+ font-family: var(--typography-label-large-font-family) !important;
3284
+ font-size: var(--typography-label-large-font-size) !important;
3285
+ font-weight: var(--typography-label-large-font-weight) !important;
3286
+ line-height: var(--typography-label-large-line-height) !important;
3287
+ letter-spacing: var(--typography-label-large-letter-spacing) !important;
3288
+ margin-bottom: var(--spacing-100);
3289
+ }
3290
+
3291
+ .tooltip-row {
3292
+ display: flex;
3293
+ align-items: center;
3294
+ gap: var(--spacing-150);
3295
+ font-family: var(--typography-body-small-font-family) !important;
3296
+ font-size: var(--typography-body-small-font-size) !important;
3297
+ font-weight: var(--typography-body-small-font-weight) !important;
3298
+ line-height: var(--typography-body-small-line-height) !important;
3299
+ letter-spacing: var(--typography-body-small-letter-spacing) !important;
3300
+ }
3301
+ .tooltip-row + .tooltip-row {
3302
+ margin-top: var(--spacing-050);
3303
+ }
3304
+
3305
+ .tooltip-label {
3306
+ flex: 1;
3307
+ color: var(--color-on-surface-variant);
3308
+ }
3309
+
3310
+ .tooltip-value {
3311
+ font-variant-numeric: tabular-nums;
3312
+ font-weight: 500;
3313
+ }
3314
+
3315
+ .swatch {
3316
+ flex: none;
3317
+ width: 0.625rem;
3318
+ height: 0.625rem;
3319
+ border-radius: var(--shape-corner-full);
3320
+ }
3321
+
3322
+ .legend {
3323
+ display: flex;
3324
+ flex-wrap: wrap;
3325
+ justify-content: center;
3326
+ gap: var(--spacing-050) var(--spacing-200);
3327
+ }
3328
+
3329
+ .legend-item {
3330
+ background: transparent;
3331
+ border: none;
3332
+ appearance: none;
3333
+ margin: 0;
3334
+ outline: none;
3335
+ padding: 0;
3336
+ font-family: var(--typography-label-medium-font-family) !important;
3337
+ font-size: var(--typography-label-medium-font-size) !important;
3338
+ font-weight: var(--typography-label-medium-font-weight) !important;
3339
+ line-height: var(--typography-label-medium-line-height) !important;
3340
+ letter-spacing: var(--typography-label-medium-letter-spacing) !important;
3341
+ display: inline-flex;
3342
+ align-items: center;
3343
+ gap: var(--spacing-100);
3344
+ padding: var(--spacing-050) var(--spacing-100);
3345
+ border-radius: var(--shape-corner-small);
3346
+ color: var(--color-on-surface);
3347
+ cursor: pointer;
3348
+ }
3349
+ .legend-item:hover {
3350
+ background: var(--color-surface-container-high);
3351
+ }
3352
+ .legend-item:focus-visible {
3353
+ outline: 2px solid var(--color-primary);
3354
+ }
3355
+ .legend-item.is-hidden {
3356
+ color: var(--color-on-surface-variant);
3357
+ text-decoration: line-through;
3358
+ }
3359
+ .legend-item.is-hidden .swatch {
3360
+ opacity: var(--_chart-dim-opacity);
3361
+ }
3362
+
3363
+ .empty {
3364
+ display: flex;
3365
+ align-items: center;
3366
+ justify-content: center;
3367
+ font-family: var(--typography-body-medium-font-family) !important;
3368
+ font-size: var(--typography-body-medium-font-size) !important;
3369
+ font-weight: var(--typography-body-medium-font-weight) !important;
3370
+ line-height: var(--typography-body-medium-line-height) !important;
3371
+ letter-spacing: var(--typography-body-medium-letter-spacing) !important;
3372
+ color: var(--color-on-surface-variant);
3373
+ border: 1px dashed var(--color-outline-variant);
3374
+ border-radius: var(--shape-corner-medium);
3375
+ }
3376
+
3377
+ .skeleton {
3378
+ position: relative;
3379
+ overflow: hidden;
3380
+ }
3381
+
3382
+ .skeleton-bars {
3383
+ display: flex;
3384
+ align-items: flex-end;
3385
+ gap: var(--spacing-200);
3386
+ padding: var(--spacing-200) 0 0;
3387
+ border-bottom: 1px solid var(--color-outline-variant);
3388
+ }
3389
+ .skeleton-bars span {
3390
+ flex: 1;
3391
+ border-radius: var(--shape-corner-extra-small) var(--shape-corner-extra-small) 0 0;
3392
+ background: var(--color-surface-container-highest);
3393
+ animation: chart-pulse 1.6s var(--easing-standard) infinite;
3394
+ }
3395
+
3396
+ .skeleton-circle {
3397
+ display: flex;
3398
+ align-items: center;
3399
+ justify-content: center;
3400
+ }
3401
+ .skeleton-circle span {
3402
+ height: 100%;
3403
+ aspect-ratio: 1;
3404
+ border-radius: 50%;
3405
+ background: var(--color-surface-container-highest);
3406
+ animation: chart-pulse 1.6s var(--easing-standard) infinite;
3407
+ }
3408
+
3409
+ @keyframes chart-pulse {
3410
+ 50% {
3411
+ opacity: 0.5;
3412
+ }
3413
+ }
3414
+ .sr-only {
3415
+ position: absolute;
3416
+ width: 1px;
3417
+ height: 1px;
3418
+ margin: -1px;
3419
+ padding: 0;
3420
+ overflow: hidden;
3421
+ clip: rect(0 0 0 0);
3422
+ white-space: nowrap;
3423
+ border: 0;
3424
+ }
3425
+
3426
+ @media (prefers-reduced-motion: reduce) {
3427
+ .skeleton span,
3428
+ .mark,
3429
+ .cursor {
3430
+ animation: none;
3431
+ transition: none;
3432
+ }
3433
+ }`;
3434
+
3435
+ export { ChartBase as C, constant as a, array as b, css_248z as c, chartColor as d, cubicOut as e, interpolateNumber as f, interpolate$1 as i, select as s };
3436
+ //# sourceMappingURL=chart-base-C2qRMF48.js.map