@dcs-tech/ui 0.9.0 → 0.11.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 (235) hide show
  1. package/CHANGELOG.md +488 -0
  2. package/README.md +43 -7
  3. package/THIRD_PARTY_NOTICES.md +23 -0
  4. package/dist/ChartImageMenu-sB2QNQzd.js +9673 -0
  5. package/dist/ChartView-BstZkP1g.js +1942 -0
  6. package/dist/{SummaryChart-CxRjK_HU.js → SummaryChart-B5ibDNOZ.js} +11 -10
  7. package/dist/{SummaryImage-Crf1R-3a.js → SummaryImage-CRP7X2Nl.js} +2 -2
  8. package/dist/SummarySeeAll-CtYRGV4G.js +101 -0
  9. package/dist/assets/fileTask.worker-D97s2vRV.js +1 -0
  10. package/dist/columnValue-BOn9NC8X.js +644 -0
  11. package/dist/exportContext-CMzuzRjc.js +274 -0
  12. package/dist/{exportEngine-BFZD6djX.js → exportEngine-CYDN8Ty-.js} +167 -137
  13. package/dist/file-worker.js +1 -1
  14. package/dist/{fileActions-CFNO14Aj.js → fileActions-DkPEWE-t.js} +1 -1
  15. package/dist/{geometry-yZmKN662.js → geometry-CFS5If1N.js} +848 -439
  16. package/dist/index.js +24208 -12603
  17. package/dist/{labels-CnqqTrne.js → labels-mukFhYkc.js} +126 -1
  18. package/dist/{runFileTask-BIZTFnZP.js → runFileTask-DI_39TjR.js} +17 -0
  19. package/dist/scrollArea-B52kugL1.js +291 -0
  20. package/dist/style.css +1 -1
  21. package/dist/{summaryChartData-CARqGRUl.js → summaryChartData-D15kw64n.js} +10 -3
  22. package/dist/types/components/Alert/Alert.d.ts +16 -0
  23. package/dist/types/components/Alert/index.d.ts +2 -0
  24. package/dist/types/components/Card/Card.d.ts +4 -3
  25. package/dist/types/components/Card/index.d.ts +1 -1
  26. package/dist/types/components/Charts/BarList.d.ts +4 -3
  27. package/dist/types/components/Charts/CalendarHeatmap.d.ts +4 -2
  28. package/dist/types/components/Charts/Chart.d.ts +3 -2
  29. package/dist/types/components/Charts/ChartView.d.ts +3 -2
  30. package/dist/types/components/Charts/ColumnChart.d.ts +4 -3
  31. package/dist/types/components/Charts/Donut.d.ts +3 -2
  32. package/dist/types/components/Charts/Funnel.d.ts +4 -2
  33. package/dist/types/components/Charts/Gauge.d.ts +3 -2
  34. package/dist/types/components/Charts/LineChart.d.ts +4 -3
  35. package/dist/types/components/Charts/NumberTrend.d.ts +4 -3
  36. package/dist/types/components/Charts/Progress.d.ts +3 -2
  37. package/dist/types/components/Charts/StackedBar.d.ts +3 -2
  38. package/dist/types/components/Charts/Treemap.d.ts +3 -2
  39. package/dist/types/components/Charts/chartData.d.ts +6 -0
  40. package/dist/types/components/Charts/chartImage.d.ts +3 -0
  41. package/dist/types/components/Charts/geometry.d.ts +3 -0
  42. package/dist/types/components/Charts/index.d.ts +2 -0
  43. package/dist/types/components/Charts/palette.d.ts +1 -0
  44. package/dist/types/components/Charts/parts.d.ts +14 -0
  45. package/dist/types/components/Charts/useChartMotion.d.ts +8 -0
  46. package/dist/types/components/ChipInput/ChipTags.d.ts +3 -0
  47. package/dist/types/components/CommandPalette/CommandPaletteTrigger.d.ts +9 -0
  48. package/dist/types/components/CommandPalette/index.d.ts +2 -0
  49. package/dist/types/components/DataTable/DataTable.d.ts +3 -1
  50. package/dist/types/components/DataTable/DisplayPopover.d.ts +1 -0
  51. package/dist/types/components/DataTable/HeaderMenu.d.ts +1 -0
  52. package/dist/types/components/DataTable/TableColumnModal.d.ts +4 -1
  53. package/dist/types/components/DataTable/TablePagination.d.ts +1 -1
  54. package/dist/types/components/DataTable/TableToolbar.d.ts +21 -1
  55. package/dist/types/components/DataTable/TableView.d.ts +19 -2
  56. package/dist/types/components/DataTable/cards/CardView.d.ts +25 -5
  57. package/dist/types/components/DataTable/cards/cardFields.d.ts +1 -0
  58. package/dist/types/components/DataTable/cards/rowParts.d.ts +1 -0
  59. package/dist/types/components/DataTable/cellSelection/CellRangeBar.d.ts +16 -0
  60. package/dist/types/components/DataTable/cellSelection/cellRangeStore.d.ts +18 -0
  61. package/dist/types/components/DataTable/cellSelection/paintRanges.d.ts +2 -0
  62. package/dist/types/components/DataTable/cellSelection/useCellSelection.d.ts +63 -0
  63. package/dist/types/components/DataTable/data/listDelta.d.ts +27 -0
  64. package/dist/types/components/DataTable/data/rowLineage.d.ts +3 -0
  65. package/dist/types/components/DataTable/data/rowModels.d.ts +9 -0
  66. package/dist/types/components/DataTable/data/rowTransaction.d.ts +9 -0
  67. package/dist/types/components/DataTable/data/useServerData.d.ts +3 -1
  68. package/dist/types/components/DataTable/defaults.d.ts +4 -0
  69. package/dist/types/components/DataTable/export/exportCells.d.ts +5 -2
  70. package/dist/types/components/DataTable/export/exportEngine.d.ts +7 -2
  71. package/dist/types/components/DataTable/export/useTableExport.d.ts +17 -1
  72. package/dist/types/components/DataTable/filters/filterRowModel.d.ts +1 -0
  73. package/dist/types/components/DataTable/grouping/groupModel.d.ts +11 -0
  74. package/dist/types/components/DataTable/index.d.ts +1 -1
  75. package/dist/types/components/DataTable/keyboard/ShortcutsDialog.d.ts +4 -1
  76. package/dist/types/components/DataTable/keyboard/useGridKeyboard.d.ts +8 -0
  77. package/dist/types/components/DataTable/labels.d.ts +130 -0
  78. package/dist/types/components/DataTable/layout/LayoutSwitcher.d.ts +10 -2
  79. package/dist/types/components/DataTable/layout/useFitWidths.d.ts +7 -0
  80. package/dist/types/components/DataTable/menu/RowMenu.d.ts +1 -0
  81. package/dist/types/components/DataTable/menu/buildRowMenu.d.ts +6 -3
  82. package/dist/types/components/DataTable/motion/RowChangeNotice.d.ts +19 -0
  83. package/dist/types/components/DataTable/motion/rowChanges.d.ts +25 -0
  84. package/dist/types/components/DataTable/motion/useNoticeInsets.d.ts +2 -0
  85. package/dist/types/components/DataTable/motion/useRowChangeNotices.d.ts +35 -0
  86. package/dist/types/components/DataTable/motion/useRowMotion.d.ts +29 -3
  87. package/dist/types/components/DataTable/persistence/reconcile.d.ts +4 -0
  88. package/dist/types/components/DataTable/persistence/useColumnPersistence.d.ts +5 -1
  89. package/dist/types/components/DataTable/pivot/PivotPanel.d.ts +11 -0
  90. package/dist/types/components/DataTable/pivot/PivotView.d.ts +22 -0
  91. package/dist/types/components/DataTable/pivot/pivotModel.d.ts +54 -0
  92. package/dist/types/components/DataTable/pivot/usePivot.d.ts +44 -0
  93. package/dist/types/components/DataTable/rows/PressRow.d.ts +1 -0
  94. package/dist/types/components/DataTable/rows/RowLead.d.ts +23 -0
  95. package/dist/types/components/DataTable/rows/rowPress.d.ts +2 -0
  96. package/dist/types/components/DataTable/rows/usePinnedRows.d.ts +34 -0
  97. package/dist/types/components/DataTable/rows/useRowDrag.d.ts +44 -0
  98. package/dist/types/components/DataTable/split/SplitView.d.ts +4 -2
  99. package/dist/types/components/DataTable/summary/SummaryChart.d.ts +2 -1
  100. package/dist/types/components/DataTable/summary/TableSummary.d.ts +2 -1
  101. package/dist/types/components/DataTable/summary/summaryModel.d.ts +28 -6
  102. package/dist/types/components/DataTable/summary/useTableSummary.d.ts +3 -0
  103. package/dist/types/components/DataTable/toolbar/ToolbarMore.d.ts +14 -0
  104. package/dist/types/components/DataTable/toolbar/useToolbarFit.d.ts +10 -0
  105. package/dist/types/components/DataTable/tree/TreeChips.d.ts +5 -0
  106. package/dist/types/components/DataTable/tree/treeExport.d.ts +54 -0
  107. package/dist/types/components/DataTable/tree/treeMove.d.ts +1 -0
  108. package/dist/types/components/DataTable/tree/useTreeChildren.d.ts +15 -0
  109. package/dist/types/components/DataTable/tree/useTreeData.d.ts +60 -0
  110. package/dist/types/components/DataTable/types.d.ts +290 -6
  111. package/dist/types/components/DataTable/ui-local/TableReorderList.d.ts +13 -0
  112. package/dist/types/components/DataTable/ui.d.ts +2 -1
  113. package/dist/types/components/DataTable/useDataChangeTracker.d.ts +11 -4
  114. package/dist/types/components/DataTable/useTable.d.ts +14 -1
  115. package/dist/types/components/DataTable/virtual/useVirtualLines.d.ts +1 -0
  116. package/dist/types/components/DatePicker/PeriodGrid.d.ts +13 -0
  117. package/dist/types/components/DatePicker/PeriodPicker.d.ts +19 -0
  118. package/dist/types/components/DatePicker/index.d.ts +1 -1
  119. package/dist/types/components/Dialog/dialogSlots.d.ts +9 -0
  120. package/dist/types/components/DropdownMenu/DropdownMenu.d.ts +8 -0
  121. package/dist/types/components/EventCalendar/EventCalendar.d.ts +46 -0
  122. package/dist/types/components/EventCalendar/eventParts.d.ts +10 -0
  123. package/dist/types/components/EventCalendar/index.d.ts +3 -0
  124. package/dist/types/components/EventCalendar/useCalendarEdit.d.ts +40 -0
  125. package/dist/types/components/FieldWrapper/index.d.ts +1 -1
  126. package/dist/types/components/Fields/index.d.ts +1 -1
  127. package/dist/types/components/Icon/Icon.d.ts +36 -0
  128. package/dist/types/components/Icon/Icon.storyData.d.ts +6 -0
  129. package/dist/types/components/Icon/IconContext.d.ts +7 -0
  130. package/dist/types/components/Icon/icons.d.ts +223 -0
  131. package/dist/types/components/Icon/index.d.ts +7 -0
  132. package/dist/types/components/Icon/useIconDone.d.ts +5 -0
  133. package/dist/types/components/Image/ImageEditor.d.ts +21 -0
  134. package/dist/types/components/Image/ImagePicker.d.ts +10 -1
  135. package/dist/types/components/Image/imageRender.d.ts +33 -0
  136. package/dist/types/components/Image/index.d.ts +3 -1
  137. package/dist/types/components/Image/prepareImage.d.ts +4 -3
  138. package/dist/types/components/Link/Link.d.ts +22 -0
  139. package/dist/types/components/Link/index.d.ts +2 -0
  140. package/dist/types/components/NavList/NavList.d.ts +13 -0
  141. package/dist/types/components/NavList/index.d.ts +2 -0
  142. package/dist/types/components/PageProgress/PageProgress.d.ts +10 -0
  143. package/dist/types/components/PageProgress/index.d.ts +2 -0
  144. package/dist/types/components/Pagination/Pagination.d.ts +19 -0
  145. package/dist/types/components/Pagination/index.d.ts +2 -0
  146. package/dist/types/components/Popover/Popover.d.ts +2 -1
  147. package/dist/types/components/Popover/floatingPosition.d.ts +26 -2
  148. package/dist/types/components/ReorderList/ReorderGroup.d.ts +16 -0
  149. package/dist/types/components/ReorderList/ReorderList.d.ts +56 -0
  150. package/dist/types/components/ReorderList/crossListDrag.d.ts +61 -0
  151. package/dist/types/components/ReorderList/index.d.ts +5 -0
  152. package/dist/types/components/ReorderList/useReorderDrag.d.ts +28 -0
  153. package/dist/types/components/Scroll/ui.d.ts +1 -0
  154. package/dist/types/components/SlidingHighlight/index.d.ts +2 -0
  155. package/dist/types/components/SlidingHighlight/useSlidingHighlight.d.ts +20 -0
  156. package/dist/types/components/Suggest/SuggestionList.d.ts +1 -0
  157. package/dist/types/components/Tooltip/useTooltip.d.ts +4 -0
  158. package/dist/types/components/UIProvider/UILabelsContext.d.ts +120 -0
  159. package/dist/types/components/UIProvider/UIProvider.d.ts +2 -0
  160. package/dist/types/core/hooks/index.d.ts +2 -1
  161. package/dist/types/core/hooks/useMeasuredState.d.ts +1 -0
  162. package/dist/types/core/hooks/usePresence.d.ts +1 -0
  163. package/dist/types/core/icons/actions.icons.d.ts +37 -0
  164. package/dist/types/core/icons/commerce.icons.d.ts +16 -0
  165. package/dist/types/core/icons/communication.icons.d.ts +10 -0
  166. package/dist/types/core/icons/delivery.icons.d.ts +13 -0
  167. package/dist/types/core/icons/devices.icons.d.ts +16 -0
  168. package/dist/types/core/icons/files.icons.d.ts +13 -0
  169. package/dist/types/core/icons/general.icons.d.ts +24 -0
  170. package/dist/types/core/icons/index.d.ts +14 -0
  171. package/dist/types/core/icons/media.icons.d.ts +11 -0
  172. package/dist/types/core/icons/navigation.icons.d.ts +25 -0
  173. package/dist/types/core/icons/people.icons.d.ts +13 -0
  174. package/dist/types/core/icons/registry.d.ts +2 -0
  175. package/dist/types/core/icons/state.icons.d.ts +14 -0
  176. package/dist/types/core/icons/status.icons.d.ts +10 -0
  177. package/dist/types/core/icons/table.icons.d.ts +22 -0
  178. package/dist/types/core/icons/text.icons.d.ts +13 -0
  179. package/dist/types/core/logic/alert.logic.d.ts +3 -0
  180. package/dist/types/core/logic/cellRange.logic.d.ts +66 -0
  181. package/dist/types/core/logic/cellTouch.logic.d.ts +16 -0
  182. package/dist/types/core/logic/columnGroups.logic.d.ts +31 -0
  183. package/dist/types/core/logic/commandPalette.logic.d.ts +2 -0
  184. package/dist/types/core/logic/datePicker.logic.d.ts +12 -0
  185. package/dist/types/core/logic/dropdownSide.logic.d.ts +19 -0
  186. package/dist/types/core/logic/eventCalendar.logic.d.ts +225 -0
  187. package/dist/types/core/logic/fieldWrapper.logic.d.ts +6 -1
  188. package/dist/types/core/logic/fitColumns.logic.d.ts +7 -0
  189. package/dist/types/core/logic/icon.logic.d.ts +24 -0
  190. package/dist/types/core/logic/imageEditor.logic.d.ts +132 -0
  191. package/dist/types/core/logic/imageTransform.logic.d.ts +57 -0
  192. package/dist/types/core/logic/index.d.ts +25 -0
  193. package/dist/types/core/logic/inertProps.d.ts +3 -0
  194. package/dist/types/core/logic/pageProgress.logic.d.ts +3 -0
  195. package/dist/types/core/logic/pagination.logic.d.ts +7 -0
  196. package/dist/types/core/logic/periodPicker.logic.d.ts +86 -0
  197. package/dist/types/core/logic/pivot.logic.d.ts +100 -0
  198. package/dist/types/core/logic/reorder.logic.d.ts +49 -0
  199. package/dist/types/core/logic/rowActions.logic.d.ts +7 -0
  200. package/dist/types/core/logic/rowDrag.logic.d.ts +36 -0
  201. package/dist/types/core/logic/rowPinning.logic.d.ts +12 -0
  202. package/dist/types/core/logic/slidingHighlight.logic.d.ts +20 -0
  203. package/dist/types/core/logic/toolbarOverflow.logic.d.ts +21 -0
  204. package/dist/types/core/logic/treeData.logic.d.ts +44 -0
  205. package/dist/types/core/logic/treeDrag.logic.d.ts +63 -0
  206. package/dist/types/core/logic/tween.logic.d.ts +33 -0
  207. package/dist/types/core/logic/visualViewport.logic.d.ts +13 -0
  208. package/dist/types/core/types/chipinput.types.d.ts +3 -1
  209. package/dist/types/core/types/collapsible.types.d.ts +3 -0
  210. package/dist/types/core/types/datePicker.types.d.ts +7 -0
  211. package/dist/types/core/types/eventCalendar.types.d.ts +18 -0
  212. package/dist/types/core/types/field.types.d.ts +6 -3
  213. package/dist/types/core/types/fieldWrapper.types.d.ts +2 -0
  214. package/dist/types/core/types/fields.types.d.ts +6 -1
  215. package/dist/types/core/types/fileEngine.types.d.ts +6 -0
  216. package/dist/types/core/types/form.types.d.ts +1 -0
  217. package/dist/types/core/types/format.types.d.ts +2 -0
  218. package/dist/types/core/types/icon.types.d.ts +109 -0
  219. package/dist/types/core/types/index.d.ts +2 -0
  220. package/dist/types/core/types/input.types.d.ts +2 -0
  221. package/dist/types/core/types/navigation.types.d.ts +1 -0
  222. package/dist/types/core/types/select.types.d.ts +2 -6
  223. package/dist/types/core/types/suggest.types.d.ts +2 -0
  224. package/dist/types/index.d.ts +31 -6
  225. package/package.json +4 -4
  226. package/dist/ChartImageMenu-DDVNJNc6.js +0 -1499
  227. package/dist/ChartView-CW3m4Z_1.js +0 -1703
  228. package/dist/SummarySeeAll-BRHOMQRA.js +0 -101
  229. package/dist/assets/fileTask.worker--Q3rI3Bn.js +0 -1
  230. package/dist/columnValue-DwUqueZ6.js +0 -610
  231. package/dist/exportContext-BKFnNQ0q.js +0 -166
  232. package/dist/scrollArea-DbYFqbIH.js +0 -269
  233. package/dist/types/components/DataTable/ui-local/DragAndDropList/DragAndDropList.d.ts +0 -4
  234. package/dist/types/components/DataTable/ui-local/DragAndDropList/index.d.ts +0 -3
  235. package/dist/types/components/DataTable/ui-local/DragAndDropList/types.d.ts +0 -70
@@ -1,1703 +0,0 @@
1
- "use client";
2
- import { A as e, C as t, Cn as n, D as r, E as i, En as a, F as o, G as s, J as c, K as l, L as u, M as d, N as f, O as p, R as m, S as h, T as g, Tn as _, W as v, X as y, Y as b, Z as x, _ as S, b as C, c as w, ct as T, d as E, f as D, ft as O, g as k, h as A, i as j, j as M, k as N, l as P, m as F, o as I, ot as L, p as R, q as z, r as B, s as V, t as H, u as ee, v as U, vt as te, w as ne, y as re, z as ie } from "./geometry-yZmKN662.js";
3
- import { useCallback as W, useEffect as ae, useLayoutEffect as G, useMemo as oe, useRef as K, useState as q } from "react";
4
- import { Fragment as se, jsx as J, jsxs as Y } from "react/jsx-runtime";
5
- import { createPortal as ce } from "react-dom";
6
- // src/core/logic/uiScale.logic.ts
7
- function le(e) {
8
- let t = parseFloat(e ?? "");
9
- return Number.isFinite(t) && t > 0 ? t : 1;
10
- }
11
- // src/components/Charts/useUiScale.ts
12
- function X() {
13
- let [e, t] = q(null), [n, r] = q(1);
14
- return G(() => {
15
- e && r(le(getComputedStyle(e).getPropertyValue("--ui-scale")));
16
- }), G(() => {
17
- if (!e || typeof ResizeObserver > "u") return;
18
- let t = new ResizeObserver(() => r(le(getComputedStyle(e).getPropertyValue("--ui-scale"))));
19
- return t.observe(e), () => t.disconnect();
20
- }, [e]), [W((e) => t(e), []), n];
21
- }
22
- // src/components/Charts/pointer.ts
23
- function ue(e, t, n) {
24
- return n <= 0 || t <= 0 ? null : Math.max(0, Math.min(n - 1, Math.floor(e / t * n)));
25
- }
26
- function de(e, t) {
27
- let n = null, r = Infinity;
28
- return t.forEach((t, i) => {
29
- let a = e < t.start ? t.start - e : e > t.end ? e - t.end : 0;
30
- a < r && (n = i, r = a);
31
- }), n;
32
- }
33
- function fe(e, t, n) {
34
- let r = null, i = Infinity;
35
- return n.forEach((n, a) => {
36
- if (!n) return;
37
- let o = e < n.left ? n.left - e : e > n.left + n.width ? e - n.left - n.width : 0, s = t < n.top ? n.top - t : t > n.top + n.height ? t - n.top - n.height : 0, c = o * o + s * s;
38
- c < i && (r = a, i = c);
39
- }), r;
40
- }
41
- function pe(e, t) {
42
- let n = Math.atan2(e, -t);
43
- return n < 0 ? n + 2 * Math.PI : n;
44
- }
45
- var me = -1;
46
- function he(e, t, n, r, i) {
47
- let a = Math.hypot(e, t);
48
- if (a > n || !i.length) return null;
49
- if (a < r) return -1;
50
- let o = pe(e, t), s = 2 * Math.PI, c = (e, t) => ((t - e) % s + s) % s, l = 0, u = Infinity;
51
- return i.forEach((e, t) => {
52
- if (o >= e.a0 && o <= e.a1) {
53
- l = t, u = -1;
54
- return;
55
- }
56
- if (u < 0) return;
57
- let n = Math.min(c(o, e.a0), c(e.a1, o));
58
- n < u && (l = t, u = n);
59
- }), l;
60
- }
61
- var ge = {
62
- x: 12,
63
- y: 4
64
- };
65
- function _e(e, t, n, r = ge, i = 8) {
66
- let a = (e, t, n) => Math.min(Math.max(e, t), Math.max(t, n)), o = e.x + r.x, s = "right";
67
- o + t.width > n.width - i && (o = e.x - r.x - t.width, s = "left");
68
- let c = e.y + r.y, l = "below";
69
- return c + t.height > n.height - i && (c = e.y - r.y - t.height, l = "above"), {
70
- left: a(o, i, n.width - t.width - i),
71
- top: a(c, i, n.height - t.height - i),
72
- x: s,
73
- y: l
74
- };
75
- }
76
- // src/components/Charts/ChartTooltip.tsx
77
- var Z = null, ve = 8, ye = () => ({
78
- width: document.documentElement.clientWidth || window.innerWidth,
79
- height: document.documentElement.clientHeight || window.innerHeight
80
- });
81
- function Q(e) {
82
- let t = K(e);
83
- t.current = e;
84
- let [n] = q(() => ({})), r = K(null), i = K(null), o = _(), [s, c] = q(null), l = K(null), u = K(null), [d, f] = q(null), p = !!e.onPick, m = (e) => e >= 0 && e < t.current.count && (t.current.focusable?.(e) ?? !0), h = W((e) => {
85
- r.current = e;
86
- }, []), g = W(() => {
87
- l.current = null, c(null);
88
- }, []), v = W((e, t) => {
89
- Z && Z.id !== n && Z.clear(), Z = {
90
- id: n,
91
- clear: g
92
- }, c((n) => n && n.index === e && n.via === t ? n : {
93
- index: e,
94
- via: t
95
- });
96
- }, [n, g]);
97
- ae(() => () => {
98
- Z?.id === n && (Z = null);
99
- }, [n]);
100
- let b = W(() => {
101
- let e = i.current, n = r.current;
102
- if (!e || !n || !s) return;
103
- let o = {
104
- width: e.offsetWidth,
105
- height: e.offsetHeight
106
- }, c;
107
- if (l.current) c = _e(l.current, o, ye());
108
- else {
109
- let e = t.current.anchor?.(s.index, n) ?? be(n, s.index) ?? n.getBoundingClientRect();
110
- c = a({
111
- anchor: e,
112
- tooltip: o,
113
- viewport: ye(),
114
- placement: "top",
115
- offset: 8,
116
- margin: 8
117
- });
118
- }
119
- let u = e.parentElement?.getBoundingClientRect() ?? {
120
- left: 0,
121
- top: 0
122
- };
123
- e.style.transform = `translate(${Math.round(c.left - u.left)}px, ${Math.round(c.top - u.top)}px)`, e.style.visibility = "visible";
124
- }, [s]);
125
- G(b), ae(() => {
126
- if (s?.via !== "touch") return;
127
- let e = (e) => {
128
- r.current?.contains(e.target) || g();
129
- };
130
- return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
131
- }, [s?.via, g]);
132
- let x = (e, n) => {
133
- let i = r.current;
134
- if (!i) return null;
135
- let a = i.getBoundingClientRect();
136
- return t.current.pick(e - a.left, n - a.top, a, i);
137
- }, S = (e) => {
138
- l.current = {
139
- x: e.clientX,
140
- y: e.clientY
141
- };
142
- let t = x(e.clientX, e.clientY);
143
- if (t === null) return g();
144
- v(t, e.pointerType === "touch" ? "touch" : "pointer"), b();
145
- }, C = [
146
- d,
147
- s?.index ?? null,
148
- e.start ?? null
149
- ].find((e) => e !== null && m(e)) ?? null;
150
- for (let t = 0; t < e.count && C === null; t++) m(t) && (C = t);
151
- let w = (e) => {
152
- let t = e instanceof Element && e !== r.current ? e.closest("[data-hit]") : null;
153
- return t && r.current?.contains(t) ? Number(t.getAttribute("data-hit")) : null;
154
- };
155
- return {
156
- active: s?.index ?? null,
157
- pickable: p,
158
- item: (e, t = {}) => p && m(e) ? {
159
- "data-hit": e,
160
- role: "button",
161
- tabIndex: e === C ? 0 : -1,
162
- "aria-pressed": t.disabled ? void 0 : !!t.pressed,
163
- "aria-disabled": t.disabled ? !0 : void 0
164
- } : { "data-hit": e },
165
- plotProps: {
166
- ref: h,
167
- tabIndex: p ? void 0 : 0,
168
- "data-chart-plot": "",
169
- onPointerDown: (e) => {
170
- e.pointerType === "touch" && (u.current = {
171
- x: e.clientX,
172
- y: e.clientY,
173
- moved: !1
174
- }, S(e));
175
- },
176
- onPointerMove: (e) => {
177
- if (e.pointerType === "touch") {
178
- if (!u.current) return;
179
- Math.hypot(e.clientX - u.current.x, e.clientY - u.current.y) > ve && (u.current.moved = !0);
180
- }
181
- S(e);
182
- },
183
- onPointerUp: () => {
184
- u.current && setTimeout(() => u.current = null, 0);
185
- },
186
- onPointerLeave: (e) => {
187
- e.pointerType !== "touch" && g();
188
- },
189
- onClick: (e) => {
190
- if (u.current?.moved) return;
191
- let n = x(e.clientX, e.clientY);
192
- n !== null && n >= 0 && t.current.onPick?.(n);
193
- },
194
- onKeyDown: (e) => {
195
- let n = t.current, i = w(e.target);
196
- if (n.onPick && i !== null && !m(i)) return;
197
- let a = i ?? (s && s.index >= 0 ? s.index : null);
198
- if ((e.key === "Enter" || e.key === " ") && a !== null && n.onPick) {
199
- e.preventDefault(), n.onPick(a);
200
- return;
201
- }
202
- if (e.key === "Escape") return s && e.stopPropagation(), g();
203
- let o = s && s.index >= 0 ? s.index : n.start ?? null, c = y(e.key, o, n.count, n.keys, n.onPick ? m : void 0);
204
- c !== null && (e.preventDefault(), l.current = null, v(c, "key"), n.onPick && r.current?.querySelector(`[data-hit="${c}"]`)?.focus());
205
- },
206
- onFocus: (e) => {
207
- let t = w(e.target);
208
- p && t !== null && (f(t), s?.index !== t && (l.current = null, v(t, "key")));
209
- },
210
- onBlur: (e) => {
211
- e.relatedTarget instanceof Node && r.current?.contains(e.relatedTarget) || s?.via === "key" && g();
212
- }
213
- },
214
- tooltip: (e) => {
215
- if (!s || e == null || !o) return null;
216
- let t = r.current?.closest("[data-theme]")?.getAttribute("data-theme") ?? void 0;
217
- return ce(/* @__PURE__ */ J("div", {
218
- className: "chart-tooltip-layer",
219
- "data-theme": t,
220
- children: /* @__PURE__ */ J("div", {
221
- ref: i,
222
- className: "chart-root chart-tooltip",
223
- role: "presentation",
224
- "aria-hidden": !0,
225
- style: { visibility: "hidden" },
226
- children: e
227
- })
228
- }), o);
229
- }
230
- };
231
- }
232
- function be(e, t) {
233
- let n = e.querySelector(`[data-hit="${t}"]`);
234
- return n ? n.getBoundingClientRect() : null;
235
- }
236
- function xe(e) {
237
- let t = e.getBoundingClientRect(), n = [];
238
- return e.querySelectorAll("[data-hit]").forEach((e) => {
239
- let r = e.getBoundingClientRect();
240
- n[Number(e.dataset.hit)] = {
241
- left: r.left - t.left,
242
- top: r.top - t.top,
243
- width: r.width,
244
- height: r.height
245
- };
246
- }), n;
247
- }
248
- function $({ title: e, rows: t = [], note: n }) {
249
- return /* @__PURE__ */ Y(se, { children: [
250
- e != null && e !== "" && /* @__PURE__ */ J("p", {
251
- className: "chart-tooltip-title",
252
- children: e
253
- }),
254
- t.map((e) => /* @__PURE__ */ Y("p", {
255
- className: "chart-tooltip-series",
256
- children: [
257
- e.color && /* @__PURE__ */ J("span", {
258
- className: "chart-swatch chart-swatch--small",
259
- style: { background: e.color }
260
- }),
261
- /* @__PURE__ */ J("span", {
262
- className: "chart-tooltip-label",
263
- children: e.label
264
- }),
265
- /* @__PURE__ */ J("strong", {
266
- className: "chart-tooltip-value",
267
- children: e.value
268
- })
269
- ]
270
- }, e.key)),
271
- n != null && n !== "" && /* @__PURE__ */ J("p", {
272
- className: "chart-tooltip-note",
273
- children: n
274
- })
275
- ] });
276
- }
277
- // src/components/Charts/BarList.tsx
278
- function Se({ href: e, className: t, title: n, children: r }) {
279
- return /* @__PURE__ */ J("a", {
280
- href: e,
281
- className: t,
282
- title: n,
283
- children: r
284
- });
285
- }
286
- function Ce({ data: e, series: t, ariaLabel: n, title: r, linkAs: i = Se, compact: a = !1, onSelect: o, selected: u = null, ...d }) {
287
- let { nf: p, L: m } = x(d), h = (t) => !!o && !e[t]?.href && e[t]?.selectable !== !1, g = Q({
288
- count: e.length,
289
- pick: (e, t, n, r) => de(t, xe(r).map((e) => e ? {
290
- start: e.top,
291
- end: e.top + e.height
292
- } : {
293
- start: Infinity,
294
- end: Infinity
295
- })),
296
- keys: {
297
- ArrowLeft: 0,
298
- ArrowRight: 0
299
- },
300
- start: u === null ? null : e.findIndex((e) => U(e) === u),
301
- onPick: o ? (t) => h(t) && o(e[t]) : void 0,
302
- focusable: (t) => !e[t]?.href
303
- }), _ = e.map((e) => re(e, t));
304
- if (_.every((e) => e === 0)) return /* @__PURE__ */ J(l, {
305
- title: r,
306
- children: /* @__PURE__ */ J(v, {
307
- ariaLabel: n,
308
- text: m.empty,
309
- compact: a
310
- })
311
- });
312
- let y = P(_), b = _.reduce((e, t) => e + t, 0), S = g.active, C = S === null ? u : U(e[S]), w = S === null ? null : e[S], T = (e, t) => `${e.fullLabel ?? e.label}: ${p(_[t])}`;
313
- return /* @__PURE__ */ Y(l, {
314
- title: r,
315
- children: [
316
- /* @__PURE__ */ J("div", {
317
- className: z(`chart-bars chart-plot chart-plot--rows${o ? " chart-plot--pick" : ""}`, a),
318
- role: o ? "group" : "img",
319
- "aria-label": !o && w ? T(w, S) : n,
320
- ...g.plotProps,
321
- children: e.map((e, n) => {
322
- let r = U(e), a = e.fullLabel ?? e.label, o = g.pickable && !e.href;
323
- return /* @__PURE__ */ Y("div", {
324
- ...g.item(n, {
325
- pressed: u === r,
326
- disabled: !h(n)
327
- }),
328
- "aria-label": o ? `${e.label}: ${p(_[n])}` : void 0,
329
- "aria-description": o && a !== e.label ? a : void 0,
330
- className: `chart-bars-item${n === S ? " chart-bars-item--active" : ""}${u === r ? " chart-bars-item--on" : ""}`,
331
- children: [
332
- e.href ? /* @__PURE__ */ J(i, {
333
- href: e.href,
334
- className: "chart-bars-label chart-bars-link",
335
- title: a,
336
- children: e.label
337
- }) : /* @__PURE__ */ J("span", {
338
- className: "chart-bars-label",
339
- title: a,
340
- children: e.label
341
- }),
342
- " ",
343
- /* @__PURE__ */ J("span", {
344
- className: `chart-bars-bar${C !== null && C !== r ? " chart-faded" : ""}`,
345
- "aria-hidden": !0,
346
- children: t.map((n, r) => {
347
- let i = e.values[n.key] ?? 0;
348
- if (!i) return null;
349
- let a = t.slice(r + 1).every((t) => !(e.values[t.key] ?? 0));
350
- return /* @__PURE__ */ J("span", {
351
- className: `chart-bars-segment${a ? " chart-bars-segment--end" : ""}`,
352
- style: {
353
- width: `${i / y * 100}%`,
354
- background: L(t.length === 1 && e.slot ? e.slot : n.slot)
355
- }
356
- }, n.key);
357
- })
358
- }),
359
- /* @__PURE__ */ J("span", {
360
- className: "chart-bars-value",
361
- children: p(_[n])
362
- })
363
- ]
364
- }, r);
365
- })
366
- }),
367
- /* @__PURE__ */ J(s, { text: w ? T(w, S) : "" }),
368
- g.tooltip(w && /* @__PURE__ */ J($, {
369
- title: w.fullLabel ?? w.label,
370
- rows: t.map((e) => ({
371
- key: e.key,
372
- color: L(t.length === 1 && w.slot ? w.slot : e.slot),
373
- label: e.label,
374
- value: p(w.values[e.key] ?? 0)
375
- })),
376
- note: m.shareOf(c(f(_[S], b)), p(b))
377
- }))
378
- ]
379
- });
380
- }
381
- // src/components/Charts/useBoxSize.ts
382
- function we() {
383
- let [e, t] = q(null), [n, r] = q({
384
- width: 0,
385
- height: 0
386
- });
387
- return G(() => {
388
- if (!e) return;
389
- let t = () => {
390
- let t = e.getBoundingClientRect();
391
- r((e) => e.width === Math.round(t.width) && e.height === Math.round(t.height) ? e : {
392
- width: Math.round(t.width),
393
- height: Math.round(t.height)
394
- });
395
- };
396
- if (t(), typeof ResizeObserver > "u") return;
397
- let n = new ResizeObserver(t);
398
- return n.observe(e), () => n.disconnect();
399
- }, [e]), [W((e) => t(e), []), n];
400
- }
401
- function Te() {
402
- let [e, t] = we();
403
- return [e, t.width];
404
- }
405
- // src/components/Charts/CalendarHeatmap.tsx
406
- function Ee(e) {
407
- let t = (t) => {
408
- try {
409
- return new Intl.DateTimeFormat(e, {
410
- ...t,
411
- timeZone: "UTC"
412
- });
413
- } catch {
414
- return new Intl.DateTimeFormat(void 0, {
415
- ...t,
416
- timeZone: "UTC"
417
- });
418
- }
419
- };
420
- return {
421
- day: t({ dateStyle: "medium" }),
422
- month: t({ month: "short" }),
423
- weekday: t({ weekday: "short" })
424
- };
425
- }
426
- var De = (e) => Array.from({ length: 7 }, (t, n) => Ee(e).weekday.format(Date.UTC(2024, 0, 1 + n)));
427
- function Oe({ days: e, ariaLabel: t, title: r, onSelect: i, selected: a = null, compact: o = !1, ...c }) {
428
- let { nf: u, L: d } = x(c), f = n().locale, p = c.locale ?? f, m = oe(() => Ee(p), [p]), h = oe(() => De(p), [p]), g = oe(() => E(e), [e]), [_, y] = Te(), [b, S] = X(), w = ee(y, g.weeks, o ? H.compactMax : H.max, S), O = w.cell + w.gap, k = w.weekdays ? F(S) : 0, A = a === null ? -1 : g.cells.findIndex((e) => e.day === a), j = Q({
429
- count: g.cells.length,
430
- pick: (e, t) => fe(e, t, g.cells.map((e) => ({
431
- left: k + e.week * O,
432
- top: e.weekday * O,
433
- width: w.cell,
434
- height: w.cell
435
- }))),
436
- keys: {
437
- ArrowLeft: -7,
438
- ArrowRight: 7,
439
- ArrowUp: -1,
440
- ArrowDown: 1
441
- },
442
- start: A >= 0 ? A : null,
443
- onPick: i ? (e) => i({
444
- day: g.cells[e].day,
445
- count: g.cells[e].count
446
- }) : void 0
447
- });
448
- if (!g.cells.length || g.total === 0) return /* @__PURE__ */ J(l, {
449
- title: r,
450
- children: /* @__PURE__ */ J(v, {
451
- ariaLabel: t,
452
- text: d.empty,
453
- compact: o
454
- })
455
- });
456
- let M = (e) => `${m.day.format(C(e.day))}: ${u(e.count)}`, N = j.active, P = N === null ? null : g.cells[N] ?? null, I = `${w.weekdays ? `${k}px ` : ""}repeat(${g.weeks}, ${w.cell}px)`, L = w.weekdays ? 2 : 1;
457
- return /* @__PURE__ */ J(l, {
458
- title: r,
459
- children: /* @__PURE__ */ Y("div", {
460
- ref: _,
461
- className: z("chart-calendar", o),
462
- role: "group",
463
- "aria-label": `${t}: ${d.total} ${u(g.total)}`,
464
- children: [
465
- /* @__PURE__ */ J("div", {
466
- ref: b,
467
- className: "chart-calendar-months",
468
- style: {
469
- gridTemplateColumns: I,
470
- columnGap: w.gap
471
- },
472
- "aria-hidden": !0,
473
- children: D(g.months, O, S).map((e) => /* @__PURE__ */ J("span", {
474
- style: {
475
- gridRow: 1,
476
- gridColumn: `${e.week + L} / span ${Math.max(1, Math.ceil(R(S) / O))}`
477
- },
478
- children: m.month.format(C(`${e.month}-01`))
479
- }, e.month))
480
- }),
481
- /* @__PURE__ */ Y("div", {
482
- className: `chart-calendar-grid chart-plot${i ? " chart-plot--pick" : ""}`,
483
- style: {
484
- gridTemplateColumns: I,
485
- gridTemplateRows: `repeat(7, ${w.cell}px)`,
486
- gap: w.gap
487
- },
488
- role: i ? void 0 : "img",
489
- "aria-label": i ? void 0 : P ? M(P) : t,
490
- ...j.plotProps,
491
- children: [w.weekdays && h.map((e, t) => /* @__PURE__ */ J("span", {
492
- className: "chart-calendar-weekday",
493
- style: {
494
- gridRow: t + 1,
495
- gridColumn: 1
496
- },
497
- "aria-hidden": !0,
498
- children: t % 2 == 0 ? e : ""
499
- }, e)), g.cells.map((e, t) => /* @__PURE__ */ J("span", {
500
- ...j.item(t, { pressed: t === A }),
501
- "aria-label": j.pickable ? M(e) : void 0,
502
- className: `chart-calendar-day${t === A ? " chart-calendar-day--on" : ""}${t === N ? " chart-calendar-day--active" : ""}${A >= 0 && t !== A ? " chart-calendar-day--faded" : ""}`,
503
- style: {
504
- gridRow: e.weekday + 1,
505
- gridColumn: e.week + L,
506
- background: T(e.level),
507
- borderRadius: w.cell < 8 ? 1 : 2
508
- },
509
- "data-level": e.level,
510
- "aria-hidden": !j.pickable || void 0
511
- }, e.day))]
512
- }),
513
- /* @__PURE__ */ Y("div", {
514
- className: "chart-calendar-legend",
515
- "aria-hidden": !0,
516
- children: [
517
- /* @__PURE__ */ J("span", { children: d.less }),
518
- Array.from({ length: 5 }, (e, t) => /* @__PURE__ */ J("span", {
519
- className: "chart-calendar-swatch",
520
- style: { background: T(t) }
521
- }, t)),
522
- /* @__PURE__ */ J("span", { children: d.more })
523
- ]
524
- }),
525
- /* @__PURE__ */ J(s, { text: P ? M(P) : "" }),
526
- j.tooltip(P && /* @__PURE__ */ J($, {
527
- title: m.day.format(C(P.day)),
528
- rows: [{
529
- key: "n",
530
- color: T(Math.max(1, P.level)),
531
- label: t,
532
- value: u(P.count)
533
- }]
534
- }))
535
- ]
536
- })
537
- });
538
- }
539
- // src/components/Charts/Legend.tsx
540
- function ke({ series: e, labels: t }) {
541
- let { L: n } = x({ labels: t });
542
- return e.length < 2 ? null : /* @__PURE__ */ J("ul", {
543
- className: z("chart-legend"),
544
- "aria-label": n.legend,
545
- children: e.map((e) => /* @__PURE__ */ Y("li", {
546
- className: "chart-legend-item",
547
- children: [/* @__PURE__ */ J("span", {
548
- className: "chart-swatch",
549
- style: { background: L(e.slot) },
550
- "aria-hidden": !0
551
- }), e.label]
552
- }, e.key))
553
- });
554
- }
555
- // src/components/Charts/ColumnChart.tsx
556
- var Ae = 6, je = 2, Me = 6, Ne = 44;
557
- function Pe({ data: e, series: t, ariaLabel: n, title: r, height: a, compact: o = !1, mode: c = "stacked", legend: u = !1, onSelect: d, selected: f = null, ...p }) {
558
- let { nf: m, L: h } = x(p), [g, _] = Te(), [y, b] = X(), C = e.length, T = (t) => !!d && e[t]?.selectable !== !1, E = Q({
559
- count: C,
560
- pick: (e, t, n) => ue(e, n.width, C),
561
- anchor: (e, t) => {
562
- let n = t.getBoundingClientRect();
563
- return {
564
- left: n.left + n.width * e / C,
565
- top: n.top,
566
- width: n.width / C,
567
- height: n.height
568
- };
569
- },
570
- keys: {
571
- ArrowUp: 0,
572
- ArrowDown: 0
573
- },
574
- start: f === null ? null : e.findIndex((e) => U(e) === f),
575
- onPick: d ? (t) => T(t) && d(e[t]) : void 0
576
- }), D = e.map((e) => re(e, t));
577
- if (D.every((e) => e === 0)) return /* @__PURE__ */ J(l, {
578
- title: r,
579
- children: /* @__PURE__ */ J(v, {
580
- ariaLabel: n,
581
- text: h.empty,
582
- compact: o
583
- })
584
- });
585
- let O = (a ?? (o ? 96 : 220)) * b, A = c === "grouped" && t.length > 1, { max: j, ticks: M } = k(S(e, t, A ? "grouped" : "stacked")), N = A ? i(t.length, 100, Ae) : [], P = E.active, F = (P === null ? null : U(e[P])) ?? f, I = _ && _ / Math.max(1, C) < Me ? 0 : je, R = new Set(w(C, Math.max(2, Math.min(12, Math.floor((_ || 600) / (Ne * b)))))), B = (e, n) => `${e.fullLabel ?? e.label}: ${t.length > 1 ? t.map((t) => `${t.label} ${m(e.values[t.key] ?? 0)}`).join(", ") : m(D[n])}`, V = P === null ? null : e[P];
586
- return /* @__PURE__ */ J(l, {
587
- title: r,
588
- children: /* @__PURE__ */ Y("div", {
589
- ref: g,
590
- className: z(`chart-columns${A ? " chart-columns--grouped" : ""}`, o),
591
- role: "group",
592
- "aria-label": n,
593
- children: [
594
- /* @__PURE__ */ Y("div", {
595
- className: "chart-columns-plot",
596
- style: { height: O },
597
- children: [!o && /* @__PURE__ */ J("div", {
598
- className: "chart-axis-y",
599
- "aria-hidden": !0,
600
- children: [...M].reverse().map((e) => /* @__PURE__ */ J("span", { children: m(e) }, e))
601
- }), /* @__PURE__ */ Y("div", {
602
- className: `chart-columns-area chart-plot chart-plot--x${d ? " chart-plot--pick" : ""}`,
603
- role: d ? void 0 : "img",
604
- "aria-label": d ? void 0 : V ? B(V, P) : n,
605
- ...E.plotProps,
606
- children: [!o && M.slice(1).map((e) => /* @__PURE__ */ J("div", {
607
- className: "chart-gridline",
608
- style: { bottom: `${e / j * 100}%` },
609
- "aria-hidden": !0
610
- }, e)), /* @__PURE__ */ J("div", {
611
- className: "chart-columns-bars",
612
- style: { gap: I },
613
- "aria-hidden": !E.pickable || void 0,
614
- children: e.map((e, n) => {
615
- let r = U(e), i = F !== null && F !== r ? " chart-faded" : "";
616
- return /* @__PURE__ */ J("div", {
617
- ...E.item(n, {
618
- pressed: f === r,
619
- disabled: !T(n)
620
- }),
621
- "aria-label": E.pickable ? B(e, n) : void 0,
622
- className: `chart-column${n === P ? " chart-column--active" : ""}${f === r ? " chart-column--on" : ""}`,
623
- children: A ? /* @__PURE__ */ J("span", {
624
- className: `chart-column-group${i}`,
625
- children: t.map((t, n) => /* @__PURE__ */ J("span", {
626
- className: "chart-column-segment chart-column-segment--top chart-column-bar",
627
- style: {
628
- left: `${N[n].x}%`,
629
- width: `${N[n].width}%`,
630
- height: `${(e.values[t.key] ?? 0) / j * O}px`,
631
- background: L(t.slot)
632
- }
633
- }, t.key))
634
- }) : /* @__PURE__ */ J("span", {
635
- className: `chart-column-stack${i}`,
636
- children: t.map((n, r) => {
637
- let i = e.values[n.key] ?? 0;
638
- if (!i) return null;
639
- let a = t.slice(r + 1).every((t) => !(e.values[t.key] ?? 0));
640
- return /* @__PURE__ */ J("span", {
641
- className: `chart-column-segment${a ? " chart-column-segment--top" : ""}`,
642
- style: {
643
- height: `${i / j * O}px`,
644
- background: L(n.slot)
645
- }
646
- }, n.key);
647
- })
648
- })
649
- }, r);
650
- })
651
- })]
652
- })]
653
- }),
654
- /* @__PURE__ */ J("div", {
655
- ref: y,
656
- className: `chart-axis-x${o ? " chart-axis-x--compact" : ""}`,
657
- style: { gap: I },
658
- "aria-hidden": !0,
659
- children: e.map((e, t) => /* @__PURE__ */ J("span", {
660
- className: f !== null && f !== U(e) ? "chart-faded" : void 0,
661
- children: R.has(t) ? e.label : ""
662
- }, U(e)))
663
- }),
664
- u && /* @__PURE__ */ J("div", {
665
- className: "chart-columns-legend",
666
- children: /* @__PURE__ */ J(ke, {
667
- series: t,
668
- labels: p.labels
669
- })
670
- }),
671
- /* @__PURE__ */ J(s, { text: V ? B(V, P) : "" }),
672
- E.tooltip(V && /* @__PURE__ */ J($, {
673
- title: V.fullLabel ?? V.label,
674
- rows: t.map((e) => ({
675
- key: e.key,
676
- color: L(e.slot),
677
- label: e.label,
678
- value: m(V.values[e.key] ?? 0)
679
- })),
680
- note: t.length > 1 ? `${h.total}: ${m(D[P])}` : void 0
681
- }))
682
- ]
683
- })
684
- });
685
- }
686
- // src/components/Charts/useLegendFit.ts
687
- function Fe(e, t) {
688
- let [n, r] = q(null), [i, a] = q(e), [o, s] = q(e);
689
- return G(() => {
690
- if (!t || !n) {
691
- a(e), s(e);
692
- return;
693
- }
694
- let r = 0, i = () => {
695
- let t = n.clientHeight, r = Array.from(n.children).filter((e) => !e.hasAttribute("data-legend-more")), i = e;
696
- if (t && r.length >= e) {
697
- let a = n.getBoundingClientRect().top, o = r.filter((e) => e.getBoundingClientRect().bottom - a <= t + .5).length;
698
- i = o >= e ? e : Math.max(0, o - 1);
699
- }
700
- a(i), s(i);
701
- }, o = () => {
702
- cancelAnimationFrame(r), a(e), r = requestAnimationFrame(i);
703
- };
704
- if (o(), typeof ResizeObserver > "u") return () => cancelAnimationFrame(r);
705
- let c = n.parentElement ?? n, l = c.clientWidth, u = new ResizeObserver(() => {
706
- c.clientWidth !== l && (l = c.clientWidth, o());
707
- });
708
- return u.observe(c), () => {
709
- cancelAnimationFrame(r), u.disconnect();
710
- };
711
- }, [
712
- n,
713
- e,
714
- t
715
- ]), [
716
- W((e) => r(e), []),
717
- t ? i : e,
718
- t ? o : e
719
- ];
720
- }
721
- // src/components/Charts/Donut.tsx
722
- var Ie = 2.5;
723
- function Le({ slices: n, ariaLabel: r, title: i, size: a, compact: o = !1, variant: l = "donut", onLegendCut: u, legend: p = !0, onSelect: m, selected: h = null, ...g }) {
724
- let { nf: _, L: v } = x(g), [y, b] = q(null), [S, C, w] = Fe(n.length, o);
725
- ae(() => u?.(n.length - w), [
726
- u,
727
- n.length,
728
- w
729
- ]);
730
- let [T, E] = X(), D = (a ?? (o ? 112 : 168)) * E, O = n.reduce((e, t) => e + t.value, 0), k = l === "pie", A = k ? e(n).map((e) => ({
731
- slice: e.slice,
732
- a0: e.a0,
733
- a1: e.a1
734
- })) : t(n).map((e) => ({
735
- slice: e.slice,
736
- a0: e.start / B * 2 * Math.PI,
737
- a1: (e.start + e.length) / B * 2 * Math.PI
738
- })), j = (e) => !!m && n[e].value > 0 && n[e].selectable !== !1, M = Q({
739
- count: n.length,
740
- pick: (e, t, r) => {
741
- let i = r.width / 100, a = 48 * i, o = k ? 0 : 32 * i, s = he(e - r.width / 2, t - r.height / 2, a, o, A);
742
- return s === null || s === -1 ? s : n.indexOf(A[s].slice);
743
- },
744
- anchor: (e, t) => {
745
- let r = t.getBoundingClientRect(), i = A.find((t) => t.slice === n[e]), a = i ? d(r.left + r.width / 2, r.top + r.height / 2, r.width / 100 * (k ? 36 : 40), (i.a0 + i.a1) / 2) : {
746
- x: r.left + r.width / 2,
747
- y: r.top + r.height / 2
748
- };
749
- return {
750
- left: a.x - 1,
751
- top: a.y - 1,
752
- width: 2,
753
- height: 2
754
- };
755
- },
756
- start: h === null ? null : n.findIndex((e) => e.key === h),
757
- onPick: m ? (e) => j(e) && m(n[e]) : void 0,
758
- focusable: (e) => n[e].value > 0
759
- }), N = (e) => {
760
- let t = n.indexOf(e);
761
- return {
762
- ...M.item(t, {
763
- pressed: h === e.key,
764
- disabled: !j(t)
765
- }),
766
- "aria-label": M.pickable ? F(e) : void 0
767
- };
768
- }, P = (e) => f(e, O), F = (e) => `${e.label} ${_(e.value)} (${c(P(e.value))})`, I = M.active === -1, R = M.active !== null && M.active >= 0 ? n[M.active] : void 0, V = R?.key ?? y ?? h, H = n.find((e) => e.key === V) ?? n[0], ee = (e) => V !== null && V !== e ? .55 : 1, U = k ? e(n) : [];
769
- return /* @__PURE__ */ Y("figure", {
770
- ref: T,
771
- className: z(k ? "chart-donut chart-pie" : "chart-donut", o),
772
- "aria-label": r,
773
- children: [
774
- i && /* @__PURE__ */ J("figcaption", {
775
- className: "chart-donut-title",
776
- children: i
777
- }),
778
- /* @__PURE__ */ Y("div", {
779
- className: `chart-donut-ring chart-plot${m ? " chart-plot--pick" : ""}`,
780
- style: {
781
- width: D,
782
- height: D
783
- },
784
- role: m ? void 0 : "img",
785
- "aria-label": m ? void 0 : R ? F(R) : `${r}: ${n.map(F).join(", ")}`,
786
- ...M.plotProps,
787
- children: [/* @__PURE__ */ J("svg", {
788
- viewBox: "0 0 100 100",
789
- width: D,
790
- height: D,
791
- className: "chart-donut-svg",
792
- overflow: "visible",
793
- "aria-hidden": !M.pickable || void 0,
794
- children: k ? O === 0 ? /* @__PURE__ */ J("circle", {
795
- cx: "50",
796
- cy: "50",
797
- r: 48,
798
- fill: L("rest"),
799
- opacity: .5,
800
- "aria-hidden": !0
801
- }) : U.map((e) => {
802
- let t = e.slice, n = V === t.key && U.length > 1 ? d(0, 0, Ie, (e.a0 + e.a1) / 2) : null;
803
- return /* @__PURE__ */ Y("g", {
804
- transform: n ? `translate(${n.x} ${n.y})` : void 0,
805
- opacity: ee(t.key),
806
- className: "chart-pie-slice-group",
807
- children: [/* @__PURE__ */ J("path", {
808
- ...N(t),
809
- d: ie(50, 50, 48, e.a0, e.a1),
810
- fill: L(t.slot),
811
- stroke: "var(--chart-surface)",
812
- strokeWidth: +(U.length > 1),
813
- strokeLinejoin: "round",
814
- className: "chart-donut-slice chart-pie-slice"
815
- }), e.label && /* @__PURE__ */ J("text", {
816
- x: e.label.x,
817
- y: e.label.y,
818
- className: "chart-pie-share",
819
- fill: te(t.slot),
820
- textAnchor: "middle",
821
- dominantBaseline: "central",
822
- "aria-hidden": !0,
823
- children: c(e.share)
824
- })]
825
- }, t.key);
826
- }) : /* @__PURE__ */ J("g", {
827
- transform: "rotate(-90 50 50)",
828
- children: O === 0 ? /* @__PURE__ */ J("circle", {
829
- cx: "50",
830
- cy: "50",
831
- r: 40,
832
- fill: "none",
833
- stroke: L("rest"),
834
- strokeWidth: 16,
835
- opacity: .5,
836
- "aria-hidden": !0
837
- }) : t(n).map(({ slice: e, start: t, length: n }) => /* @__PURE__ */ J("circle", {
838
- ...N(e),
839
- cx: "50",
840
- cy: "50",
841
- r: 40,
842
- fill: "none",
843
- stroke: L(e.slot),
844
- strokeWidth: V === e.key ? 18 : 16,
845
- strokeDasharray: `${n} ${B}`,
846
- strokeDashoffset: -t,
847
- className: "chart-donut-slice",
848
- opacity: I ? 1 : ee(e.key)
849
- }, e.key))
850
- })
851
- }), k ? O === 0 && /* @__PURE__ */ J("div", {
852
- className: "chart-donut-centre",
853
- "aria-hidden": !0,
854
- children: /* @__PURE__ */ J("span", {
855
- className: "chart-donut-empty",
856
- children: v.empty
857
- })
858
- }) : /* @__PURE__ */ J("div", {
859
- className: "chart-donut-centre",
860
- "aria-hidden": !0,
861
- children: O > 0 && I ? /* @__PURE__ */ Y(se, { children: [/* @__PURE__ */ J("span", {
862
- className: "chart-donut-share",
863
- children: _(O)
864
- }), /* @__PURE__ */ J("span", {
865
- className: "chart-donut-share-label",
866
- children: v.total.toLowerCase()
867
- })] }) : O > 0 && H ? /* @__PURE__ */ Y(se, { children: [/* @__PURE__ */ J("span", {
868
- className: "chart-donut-share",
869
- children: c(P(H.value))
870
- }), /* @__PURE__ */ J("span", {
871
- className: "chart-donut-share-label",
872
- children: H.label.toLowerCase()
873
- })] }) : /* @__PURE__ */ J("span", {
874
- className: "chart-donut-empty",
875
- children: v.empty
876
- })
877
- })]
878
- }),
879
- p && /* @__PURE__ */ Y("ul", {
880
- ref: S,
881
- className: "chart-donut-legend",
882
- "aria-label": v.legend,
883
- children: [n.slice(0, C).map((e, t) => /* @__PURE__ */ Y("li", {
884
- className: `chart-donut-legend-item${j(t) ? " chart-donut-legend-item--hit" : ""}${h === e.key ? " chart-donut-legend-item--on" : ""}${h !== null && h !== e.key ? " chart-faded" : ""}`,
885
- onMouseEnter: () => b(e.key),
886
- onMouseLeave: () => b(null),
887
- onClick: j(t) ? () => m(e) : void 0,
888
- children: [
889
- /* @__PURE__ */ J("span", {
890
- className: "chart-swatch",
891
- style: { background: L(e.slot) },
892
- "aria-hidden": !0
893
- }),
894
- /* @__PURE__ */ J("span", {
895
- className: "chart-donut-legend-label",
896
- children: e.label
897
- }),
898
- /* @__PURE__ */ Y("span", {
899
- className: "chart-donut-legend-value",
900
- children: [
901
- _(e.value),
902
- " · ",
903
- c(P(e.value))
904
- ]
905
- })
906
- ]
907
- }, e.key)), C < n.length && /* @__PURE__ */ J("li", {
908
- className: "chart-donut-legend-more",
909
- "data-legend-more": "",
910
- children: v.moreValues(_(n.length - C))
911
- })]
912
- }),
913
- /* @__PURE__ */ J(s, { text: R ? F(R) : I ? `${v.total} ${_(O)}` : "" }),
914
- M.tooltip(I ? /* @__PURE__ */ J($, {
915
- title: r,
916
- rows: n.map((e) => ({
917
- key: e.key,
918
- color: L(e.slot),
919
- label: e.label,
920
- value: _(e.value)
921
- })),
922
- note: `${v.total}: ${_(O)}`
923
- }) : R && /* @__PURE__ */ J($, {
924
- rows: [{
925
- key: R.key,
926
- color: L(R.slot),
927
- label: R.label,
928
- value: _(R.value)
929
- }],
930
- note: v.shareOf(c(P(R.value)), _(O))
931
- }))
932
- ]
933
- });
934
- }
935
- // src/components/Charts/Funnel.tsx
936
- function Re({ steps: e, ariaLabel: t, title: n, compact: r = !1, onSelect: i, selected: a = null, ...o }) {
937
- let { nf: u, L: d } = x(o), f = (t) => !!i && e[t].selectable !== !1, p = Q({
938
- count: e.length,
939
- pick: (e, t, n, r) => de(t, xe(r).map((e) => e ? {
940
- start: e.top,
941
- end: e.top + e.height
942
- } : {
943
- start: Infinity,
944
- end: Infinity
945
- })),
946
- keys: {
947
- ArrowLeft: 0,
948
- ArrowRight: 0
949
- },
950
- start: a === null ? null : e.findIndex((e) => e.key === a),
951
- onPick: i ? (t) => f(t) && i(e[t]) : void 0
952
- });
953
- if (!e.some((e) => e.value > 0)) return /* @__PURE__ */ J(l, {
954
- title: n,
955
- children: /* @__PURE__ */ J(v, {
956
- ariaLabel: t,
957
- text: d.empty,
958
- compact: r
959
- })
960
- });
961
- let m = ne(e), h = p.active === null ? null : m[p.active] ?? null, g = h?.step.key ?? a, _ = (e) => `${e.step.label}: ${u(e.step.value)}${e.drop === null ? "" : `, ${d.funnelDrop} ${b(e.drop)}`}`;
962
- return /* @__PURE__ */ Y(l, {
963
- title: n,
964
- children: [
965
- /* @__PURE__ */ J("ol", {
966
- className: z(`chart-funnel chart-plot chart-plot--rows${i ? " chart-plot--pick" : ""}`, r),
967
- role: i ? void 0 : "img",
968
- "aria-label": !i && h ? _(h) : t,
969
- ...p.plotProps,
970
- children: m.map(({ step: e, width: t, drop: n }, r) => /* @__PURE__ */ J("li", {
971
- "data-hit": p.pickable ? void 0 : r,
972
- className: `chart-funnel-item${r === p.active ? " chart-funnel-item--active" : ""}`,
973
- "aria-hidden": !p.pickable || void 0,
974
- children: /* @__PURE__ */ Y("span", {
975
- ...p.pickable ? p.item(r, {
976
- pressed: a === e.key,
977
- disabled: !f(r)
978
- }) : {},
979
- "aria-label": p.pickable ? `${e.label}: ${u(e.value)}${n === null ? "" : `, ${b(n)}`}` : void 0,
980
- "aria-description": p.pickable && n !== null ? d.funnelDrop : void 0,
981
- className: `chart-funnel-row${g !== null && g !== e.key ? " chart-faded" : ""}`,
982
- children: [
983
- /* @__PURE__ */ J("span", {
984
- className: "chart-funnel-label",
985
- title: e.label,
986
- children: e.label
987
- }),
988
- " ",
989
- /* @__PURE__ */ Y("span", {
990
- className: "chart-funnel-track",
991
- children: [/* @__PURE__ */ J("span", {
992
- className: "chart-funnel-bar",
993
- style: {
994
- width: `${t * 100}%`,
995
- background: L(e.slot),
996
- color: te(e.slot)
997
- },
998
- children: t >= .18 ? u(e.value) : ""
999
- }), t < .18 && /* @__PURE__ */ J("span", {
1000
- className: "chart-funnel-outside",
1001
- children: u(e.value)
1002
- })]
1003
- }),
1004
- " ",
1005
- /* @__PURE__ */ J("span", {
1006
- className: "chart-funnel-drop",
1007
- "data-change": n === null ? void 0 : n > 0 ? "drop" : n < 0 ? "rise" : "flat",
1008
- children: n === null ? "" : b(n)
1009
- })
1010
- ]
1011
- })
1012
- }, e.key))
1013
- }),
1014
- /* @__PURE__ */ J(s, { text: h ? _(h) : "" }),
1015
- p.tooltip(h && /* @__PURE__ */ J($, {
1016
- rows: [{
1017
- key: h.step.key,
1018
- color: L(h.step.slot),
1019
- label: h.step.label,
1020
- value: u(h.step.value)
1021
- }],
1022
- note: [p.active > 0 ? `${d.funnelOfFirst}: ${c(h.ofFirst)}` : "", h.drop === null ? "" : `${d.funnelDrop}: ${b(h.drop)}`].filter(Boolean).join(" · ") || void 0
1023
- }))
1024
- ]
1025
- });
1026
- }
1027
- // src/components/Charts/Gauge.tsx
1028
- function ze({ value: e, total: t, ariaLabel: n, label: r, variant: i = "half", color: a = 1, size: o, compact: l = !1, ...u }) {
1029
- let { nf: d, L: p } = x(u), m = j[i], h = f(e, t), { a0: _, a1: v, end: y } = g(i, h), [b, S] = X(), C = (o ?? (i === "half" ? l ? 120 : 168 : l ? 88 : 128)) * S, w = Q({
1030
- count: 1,
1031
- pick: (e, t, n) => {
1032
- let r = n.width / m.width;
1033
- return he(e - m.cx * r, t - m.cy * r, (m.r + 6) * r, 0, [{
1034
- a0: _,
1035
- a1: v
1036
- }]) === null ? null : 0;
1037
- }
1038
- }), T = p.ofTotal(d(e), d(t)), E = L(O(a, h));
1039
- return /* @__PURE__ */ Y("div", {
1040
- ref: b,
1041
- className: z(`chart-gauge chart-gauge--${i}`, l),
1042
- role: "meter",
1043
- "aria-label": n,
1044
- "aria-valuemin": 0,
1045
- "aria-valuemax": 100,
1046
- "aria-valuenow": Math.round(h * 10) / 10,
1047
- "aria-valuetext": `${T} (${c(h)})`,
1048
- children: [
1049
- /* @__PURE__ */ Y("div", {
1050
- className: "chart-gauge-dial chart-plot",
1051
- style: { width: C },
1052
- ...w.plotProps,
1053
- children: [/* @__PURE__ */ Y("svg", {
1054
- viewBox: `0 0 ${m.width} ${m.height}`,
1055
- width: C,
1056
- height: C * m.height / m.width,
1057
- "aria-hidden": !0,
1058
- children: [/* @__PURE__ */ J("path", {
1059
- d: I(m.cx, m.cy, m.r, _, v),
1060
- className: "chart-gauge-track",
1061
- fill: "none",
1062
- strokeWidth: 12,
1063
- strokeLinecap: "round"
1064
- }), h > 0 && /* @__PURE__ */ J("path", {
1065
- d: I(m.cx, m.cy, m.r, _, Math.max(y, _ + .01)),
1066
- className: "chart-gauge-value",
1067
- fill: "none",
1068
- stroke: E,
1069
- strokeWidth: 12,
1070
- strokeLinecap: "round"
1071
- })]
1072
- }), /* @__PURE__ */ J("span", {
1073
- className: "chart-gauge-share",
1074
- "aria-hidden": !0,
1075
- children: c(h)
1076
- })]
1077
- }),
1078
- r !== void 0 && /* @__PURE__ */ J("span", {
1079
- className: "chart-gauge-label",
1080
- children: r
1081
- }),
1082
- /* @__PURE__ */ J("span", {
1083
- className: "chart-gauge-of",
1084
- "aria-hidden": !0,
1085
- children: T
1086
- }),
1087
- /* @__PURE__ */ J(s, { text: w.active === null ? "" : `${T} (${c(h)})` }),
1088
- w.tooltip(w.active !== null && /* @__PURE__ */ J($, {
1089
- title: r ?? n,
1090
- rows: [{
1091
- key: "v",
1092
- color: E,
1093
- label: T,
1094
- value: c(h)
1095
- }]
1096
- }))
1097
- ]
1098
- });
1099
- }
1100
- // src/components/Charts/LineChart.tsx
1101
- var Be = 64;
1102
- function Ve({ data: e, series: t, ariaLabel: n, title: i, area: a = !1, height: o, compact: c = !1, onSelect: u, selected: d = null, ...f }) {
1103
- let { nf: m, L: h } = x(f), [g, _] = Te(), [y, b] = X(), S = e.length, C = d === null ? -1 : e.findIndex((e) => U(e) === d), T = Q({
1104
- count: S,
1105
- pick: (e, t, n) => N(e, n.width, S),
1106
- anchor: (e, t) => {
1107
- let n = t.getBoundingClientRect();
1108
- return {
1109
- left: n.left + M(e, S, 100) / 100 * n.width - 1,
1110
- top: n.top,
1111
- width: 2,
1112
- height: n.height
1113
- };
1114
- },
1115
- keys: {
1116
- ArrowUp: 0,
1117
- ArrowDown: 0
1118
- },
1119
- start: C >= 0 ? C : null,
1120
- onPick: u ? (t) => e[t].selectable !== !1 && u(e[t]) : void 0
1121
- }), E = e.flatMap((e) => t.map((t) => e.values[t.key] ?? 0));
1122
- if (!E.some((e) => e > 0)) return /* @__PURE__ */ J(l, {
1123
- title: i,
1124
- children: /* @__PURE__ */ J(v, {
1125
- ariaLabel: n,
1126
- text: h.empty,
1127
- compact: c
1128
- })
1129
- });
1130
- let D = (o ?? (c ? 96 : 220)) * b, { max: O, ticks: A } = k(E), j = t.map((t) => ({
1131
- s: t,
1132
- points: p(e.map((e) => e.values[t.key] ?? 0), 100, 100, O)
1133
- })), P = T.active, F = (e) => `${e.fullLabel ?? e.label}: ${t.map((n) => t.length > 1 ? `${n.label} ${m(e.values[n.key] ?? 0)}` : m(e.values[n.key] ?? 0)).join(", ")}`, I = P === null ? null : e[P] ?? null, R = w(S, Math.max(2, Math.min(c ? 4 : 6, Math.floor((_ || 400) / (Be * b))))), B = (e) => `${M(e, S, 100)}%`;
1134
- return /* @__PURE__ */ J(l, {
1135
- title: i,
1136
- children: /* @__PURE__ */ Y("div", {
1137
- ref: g,
1138
- className: z(`chart-line${a ? " chart-line--area" : ""}`, c),
1139
- role: "group",
1140
- "aria-label": n,
1141
- children: [
1142
- /* @__PURE__ */ Y("div", {
1143
- className: "chart-columns-plot",
1144
- style: { height: D },
1145
- children: [!c && /* @__PURE__ */ J("div", {
1146
- className: "chart-axis-y",
1147
- "aria-hidden": !0,
1148
- children: [...A].reverse().map((e) => /* @__PURE__ */ J("span", { children: m(e) }, e))
1149
- }), /* @__PURE__ */ Y("div", {
1150
- className: `chart-line-area chart-plot chart-plot--x${u ? " chart-plot--pick" : ""}`,
1151
- role: u ? void 0 : "img",
1152
- "aria-label": u ? void 0 : I ? F(I) : n,
1153
- ...T.plotProps,
1154
- children: [
1155
- T.pickable && e.map((e, t) => /* @__PURE__ */ J("span", {
1156
- ...T.item(t, {
1157
- pressed: t === C,
1158
- disabled: e.selectable === !1
1159
- }),
1160
- "aria-label": F(e),
1161
- className: "chart-line-slot",
1162
- style: { left: B(t) }
1163
- }, U(e))),
1164
- !c && A.slice(1).map((e) => /* @__PURE__ */ J("div", {
1165
- className: "chart-gridline",
1166
- style: { bottom: `${e / O * 100}%` },
1167
- "aria-hidden": !0
1168
- }, e)),
1169
- /* @__PURE__ */ Y("svg", {
1170
- className: "chart-line-svg",
1171
- viewBox: "0 0 100 100",
1172
- preserveAspectRatio: "none",
1173
- width: "100%",
1174
- height: "100%",
1175
- "aria-hidden": !0,
1176
- children: [
1177
- a && j.map(({ s: e, points: t }) => /* @__PURE__ */ J("path", {
1178
- d: V(t, 100),
1179
- fill: L(e.slot),
1180
- className: "chart-line-fill"
1181
- }, `a-${e.key}`)),
1182
- j.map(({ s: e, points: t }) => /* @__PURE__ */ J("path", {
1183
- d: r(t),
1184
- fill: "none",
1185
- stroke: L(e.slot),
1186
- className: "chart-line-path",
1187
- vectorEffect: "non-scaling-stroke"
1188
- }, e.key)),
1189
- C >= 0 && /* @__PURE__ */ J("line", {
1190
- className: "chart-line-selected",
1191
- x1: M(C, S, 100),
1192
- x2: M(C, S, 100),
1193
- y1: 0,
1194
- y2: 100,
1195
- vectorEffect: "non-scaling-stroke"
1196
- }),
1197
- P !== null && /* @__PURE__ */ J("line", {
1198
- className: "chart-line-crosshair",
1199
- x1: M(P, S, 100),
1200
- x2: M(P, S, 100),
1201
- y1: 0,
1202
- y2: 100,
1203
- vectorEffect: "non-scaling-stroke"
1204
- })
1205
- ]
1206
- }),
1207
- [P, C >= 0 ? C : null].map((e, t) => e === null || t === 1 && e === P ? null : j.map(({ s: n, points: r }) => /* @__PURE__ */ J("span", {
1208
- className: "chart-line-dot",
1209
- style: {
1210
- left: B(e),
1211
- top: `${r[e].y}%`,
1212
- background: L(n.slot)
1213
- },
1214
- "aria-hidden": !0
1215
- }, `${t}-${n.key}`)))
1216
- ]
1217
- })]
1218
- }),
1219
- /* @__PURE__ */ J("div", {
1220
- ref: y,
1221
- className: `chart-line-axis-x${c ? " chart-line-axis-x--compact" : ""}`,
1222
- "aria-hidden": !0,
1223
- children: R.map((t) => /* @__PURE__ */ J("span", {
1224
- style: { left: B(t) },
1225
- className: t === 0 ? "chart-line-axis-first" : t === S - 1 ? "chart-line-axis-last" : void 0,
1226
- children: e[t].label
1227
- }, t))
1228
- }),
1229
- /* @__PURE__ */ J(s, { text: I ? F(I) : "" }),
1230
- T.tooltip(I && /* @__PURE__ */ J($, {
1231
- title: I.fullLabel ?? I.label,
1232
- rows: t.map((e) => ({
1233
- key: e.key,
1234
- color: L(e.slot),
1235
- label: e.label,
1236
- value: m(I.values[e.key] ?? 0)
1237
- })),
1238
- note: t.length > 1 ? `${h.total}: ${m(re(I, t))}` : void 0
1239
- }))
1240
- ]
1241
- })
1242
- });
1243
- }
1244
- // src/components/Charts/NumberTrend.tsx
1245
- function He({ value: e, ariaLabel: t, title: n, points: i = [], current: a, previous: l, good: u = "up", slot: d = 1, compact: f = !1, ...p }) {
1246
- let { nf: g, L: _ } = x(p), v = Q({
1247
- count: i.length,
1248
- pick: (e, t, n) => N(e, n.width, i.length),
1249
- anchor: (e, t) => {
1250
- let n = t.getBoundingClientRect();
1251
- return {
1252
- left: n.left + M(e, i.length, 100) / 100 * n.width - 1,
1253
- top: n.top,
1254
- width: 2,
1255
- height: n.height
1256
- };
1257
- },
1258
- keys: {
1259
- ArrowUp: 0,
1260
- ArrowDown: 0
1261
- }
1262
- }), y = a ?? i.reduce((e, t) => e + t.value, 0), b = l === void 0 ? null : m(y, l), S = b ? h(b.direction, u) : "neutral", C = b ? b.direction === "up" ? "▲" : b.direction === "down" ? "▼" : "=" : "", w = b ? b.percent === null ? _.deltaNew : c(Math.abs(b.percent)) : "", T = b ? `${b.direction === "up" ? _.deltaUp : b.direction === "down" ? _.deltaDown : _.deltaSame}${b.direction === "same" ? "" : ` ${w}`} ${_.vsPrevious}` : "", E = o(i.map((e) => e.value), 100, 100), D = v.active, O = D === null ? null : i[D] ?? null;
1263
- return /* @__PURE__ */ Y("div", {
1264
- className: z("chart-number", f),
1265
- role: "group",
1266
- "aria-label": `${t}: ${g(e)}${T ? `, ${T}` : ""}`,
1267
- children: [
1268
- n != null && n !== "" && /* @__PURE__ */ J("div", {
1269
- className: "chart-title",
1270
- children: n
1271
- }),
1272
- /* @__PURE__ */ Y("div", {
1273
- className: "chart-number-line",
1274
- "aria-hidden": !0,
1275
- children: [/* @__PURE__ */ J("span", {
1276
- className: "chart-number-value",
1277
- children: g(e)
1278
- }), b && /* @__PURE__ */ Y("span", {
1279
- className: "chart-number-delta",
1280
- "data-tone": S,
1281
- style: { color: L(S) },
1282
- children: [
1283
- C,
1284
- " ",
1285
- b.direction === "same" ? c(0) : w
1286
- ]
1287
- })]
1288
- }),
1289
- E.length > 1 && /* @__PURE__ */ Y("div", {
1290
- className: "chart-number-spark chart-plot chart-plot--x",
1291
- role: "img",
1292
- "aria-label": O ? `${O.label}: ${g(O.value)}` : t,
1293
- ...v.plotProps,
1294
- children: [/* @__PURE__ */ Y("svg", {
1295
- viewBox: "0 0 100 100",
1296
- preserveAspectRatio: "none",
1297
- width: "100%",
1298
- height: "100%",
1299
- "aria-hidden": !0,
1300
- children: [
1301
- /* @__PURE__ */ J("path", {
1302
- d: V(E, 100),
1303
- fill: L(d),
1304
- className: "chart-line-fill"
1305
- }),
1306
- /* @__PURE__ */ J("path", {
1307
- d: r(E),
1308
- fill: "none",
1309
- stroke: L(d),
1310
- className: "chart-line-path",
1311
- vectorEffect: "non-scaling-stroke"
1312
- }),
1313
- D !== null && /* @__PURE__ */ J("line", {
1314
- className: "chart-line-crosshair",
1315
- x1: M(D, i.length, 100),
1316
- x2: M(D, i.length, 100),
1317
- y1: 0,
1318
- y2: 100,
1319
- vectorEffect: "non-scaling-stroke"
1320
- })
1321
- ]
1322
- }), D !== null && E[D] && /* @__PURE__ */ J("span", {
1323
- className: "chart-line-dot",
1324
- style: {
1325
- left: `${E[D].x}%`,
1326
- top: `${E[D].y}%`,
1327
- background: L(d)
1328
- },
1329
- "aria-hidden": !0
1330
- })]
1331
- }),
1332
- b && /* @__PURE__ */ J("div", {
1333
- className: "chart-number-note",
1334
- "aria-hidden": !0,
1335
- children: _.vsPrevious
1336
- }),
1337
- /* @__PURE__ */ J(s, { text: O ? `${O.label}: ${g(O.value)}` : "" }),
1338
- v.tooltip(O && /* @__PURE__ */ J($, {
1339
- title: O.label,
1340
- rows: [{
1341
- key: "v",
1342
- color: L(d),
1343
- label: t,
1344
- value: g(O.value)
1345
- }]
1346
- }))
1347
- ]
1348
- });
1349
- }
1350
- // src/components/Charts/Progress.tsx
1351
- function Ue({ value: e, total: t, ariaLabel: n, label: r, color: i = 1, compact: a = !1, ...o }) {
1352
- let { nf: l, L: u } = x(o), d = Q({
1353
- count: 1,
1354
- pick: () => 0
1355
- }), f = t > 0 ? e / t * 100 : 0, p = L(O(i, f)), m = u.ofTotal(l(e), l(t));
1356
- return /* @__PURE__ */ Y("div", {
1357
- className: z("chart-progress chart-plot", a),
1358
- role: "progressbar",
1359
- "aria-label": n,
1360
- "aria-valuemin": 0,
1361
- "aria-valuemax": 100,
1362
- "aria-valuenow": Math.round(f * 10) / 10,
1363
- "aria-valuetext": `${l(e)} / ${l(t)} (${c(f)})`,
1364
- ...d.plotProps,
1365
- children: [
1366
- r !== void 0 && /* @__PURE__ */ Y("div", {
1367
- className: "chart-progress-head",
1368
- children: [/* @__PURE__ */ J("span", {
1369
- className: "chart-progress-label",
1370
- children: r
1371
- }), /* @__PURE__ */ J("span", {
1372
- className: "chart-progress-share",
1373
- children: c(f)
1374
- })]
1375
- }),
1376
- /* @__PURE__ */ J("div", {
1377
- className: "chart-progress-track",
1378
- children: /* @__PURE__ */ J("div", {
1379
- className: "chart-progress-fill",
1380
- style: {
1381
- width: `${Math.min(100, f)}%`,
1382
- background: p
1383
- }
1384
- })
1385
- }),
1386
- /* @__PURE__ */ J(s, { text: d.active === null ? "" : `${m} (${c(f)})` }),
1387
- d.tooltip(d.active !== null && /* @__PURE__ */ J($, {
1388
- title: r ?? n,
1389
- rows: [{
1390
- key: "v",
1391
- color: p,
1392
- label: m,
1393
- value: c(f)
1394
- }]
1395
- }))
1396
- ]
1397
- });
1398
- }
1399
- // src/components/Charts/StackedBar.tsx
1400
- function We({ slices: e, ariaLabel: t, title: n, compact: r = !1, onLegendCut: i, onSelect: a, selected: o = null, ...u }) {
1401
- let { nf: d, L: p } = x(u), [m, h] = q(null), [g, _, y] = Fe(e.length, r);
1402
- ae(() => i?.(e.length - y), [
1403
- i,
1404
- e.length,
1405
- y
1406
- ]);
1407
- let b = e.filter((e) => e.value > 0), S = (e) => !!a && e.value > 0 && e.selectable !== !1, C = Q({
1408
- count: b.length,
1409
- pick: (e, t, n, r) => de(e, xe(r).map((e) => e ? {
1410
- start: e.left,
1411
- end: e.left + e.width
1412
- } : {
1413
- start: Infinity,
1414
- end: Infinity
1415
- })),
1416
- keys: {
1417
- ArrowUp: 0,
1418
- ArrowDown: 0
1419
- },
1420
- start: o === null ? null : b.findIndex((e) => e.key === o),
1421
- onPick: a ? (e) => S(b[e]) && a(b[e]) : void 0
1422
- }), w = e.reduce((e, t) => e + t.value, 0);
1423
- if (w === 0) return /* @__PURE__ */ J(l, {
1424
- title: n,
1425
- children: /* @__PURE__ */ J(v, {
1426
- ariaLabel: t,
1427
- text: p.empty,
1428
- compact: r
1429
- })
1430
- });
1431
- let T = (e) => f(e, w), E = (e) => `${e.label} ${d(e.value)} (${c(T(e.value))})`, D = C.active === null ? null : b[C.active] ?? null, O = D?.key ?? m ?? o, k = (e) => O !== null && O !== e ? " chart-faded" : "";
1432
- return /* @__PURE__ */ Y("figure", {
1433
- className: z("chart-stacked", r),
1434
- "aria-label": t,
1435
- children: [
1436
- n && /* @__PURE__ */ J("figcaption", {
1437
- className: "chart-title",
1438
- children: n
1439
- }),
1440
- /* @__PURE__ */ J("div", {
1441
- className: `chart-stacked-bar chart-plot chart-plot--x${a ? " chart-plot--pick" : ""}`,
1442
- role: a ? void 0 : "img",
1443
- "aria-label": a ? void 0 : D ? E(D) : `${t}: ${e.map(E).join(", ")}`,
1444
- ...C.plotProps,
1445
- children: b.map((e, t) => /* @__PURE__ */ J("span", {
1446
- ...C.item(t, {
1447
- pressed: o === e.key,
1448
- disabled: !S(e)
1449
- }),
1450
- "aria-label": C.pickable ? E(e) : void 0,
1451
- "aria-hidden": !C.pickable || void 0,
1452
- className: `chart-stacked-segment${k(e.key)}`,
1453
- style: {
1454
- flexGrow: e.value,
1455
- background: L(e.slot)
1456
- }
1457
- }, e.key))
1458
- }),
1459
- /* @__PURE__ */ Y("ul", {
1460
- ref: g,
1461
- className: "chart-donut-legend chart-stacked-legend",
1462
- "aria-label": p.legend,
1463
- children: [e.slice(0, _).map((e) => /* @__PURE__ */ Y("li", {
1464
- className: `chart-donut-legend-item${S(e) ? " chart-donut-legend-item--hit" : ""}${o === e.key ? " chart-donut-legend-item--on" : ""}${k(e.key)}`,
1465
- onMouseEnter: () => h(e.key),
1466
- onMouseLeave: () => h(null),
1467
- onClick: S(e) ? () => a(e) : void 0,
1468
- children: [
1469
- /* @__PURE__ */ J("span", {
1470
- className: "chart-swatch",
1471
- style: { background: L(e.slot) },
1472
- "aria-hidden": !0
1473
- }),
1474
- /* @__PURE__ */ J("span", {
1475
- className: "chart-donut-legend-label",
1476
- children: e.label
1477
- }),
1478
- /* @__PURE__ */ Y("span", {
1479
- className: "chart-donut-legend-value",
1480
- children: [
1481
- d(e.value),
1482
- " · ",
1483
- c(T(e.value))
1484
- ]
1485
- })
1486
- ]
1487
- }, e.key)), _ < e.length && /* @__PURE__ */ J("li", {
1488
- className: "chart-donut-legend-more",
1489
- "data-legend-more": "",
1490
- children: p.moreValues(d(e.length - _))
1491
- })]
1492
- }),
1493
- /* @__PURE__ */ J(s, { text: D ? E(D) : "" }),
1494
- C.tooltip(D && /* @__PURE__ */ J($, {
1495
- rows: [{
1496
- key: D.key,
1497
- color: L(D.slot),
1498
- label: D.label,
1499
- value: d(D.value)
1500
- }],
1501
- note: p.shareOf(c(T(D.value)), d(w))
1502
- }))
1503
- ]
1504
- });
1505
- }
1506
- // src/components/Charts/Treemap.tsx
1507
- var Ge = 400;
1508
- function Ke({ nodes: e, ariaLabel: t, title: n, height: r, compact: i = !1, onSelect: a, selected: o = null, ...d }) {
1509
- let { nf: p, L: m } = x(d), [h, g] = Te(), _ = g || Ge, [y, b] = X(), S = (r ?? (i ? 120 : 220)) * b, C = e.reduce((e, t) => e + Math.max(0, t.value), 0), w = C > 0 ? u(e, _, S, b) : [], T = w.filter((e) => !e.node.children?.some((e) => e.value > 0)), E = (e) => e.parent ?? e.node, D = (e) => !!a && E(e).selectable !== !1, O = Q({
1510
- count: T.length,
1511
- pick: (e, t, n) => fe(e / n.width * _, t / n.height * S, T.map((e) => ({
1512
- left: e.rect.x,
1513
- top: e.rect.y,
1514
- width: e.rect.w,
1515
- height: e.rect.h
1516
- }))),
1517
- start: o === null ? null : T.findIndex((e) => E(e).key === o),
1518
- onPick: a ? (e) => D(T[e]) && a(E(T[e])) : void 0
1519
- }), k = O.plotProps.ref, j = W((e) => {
1520
- h(e), k(e);
1521
- }, [h, k]);
1522
- if (C <= 0) return /* @__PURE__ */ J(l, {
1523
- title: n,
1524
- children: /* @__PURE__ */ J(v, {
1525
- ariaLabel: t,
1526
- text: m.empty,
1527
- compact: i
1528
- })
1529
- });
1530
- let M = (e) => `${e.parent ? `${e.parent.label} › ` : ""}${e.node.label} ${p(e.node.value)} (${c(f(e.node.value, C))})`, N = (e) => e.parent ? `${e.parent.key}\u0000${e.node.key}` : e.node.key, P = O.active === null ? null : T[O.active] ?? null, F = (e) => ({
1531
- left: `${e.rect.x / _ * 100}%`,
1532
- top: `${e.rect.y / S * 100}%`,
1533
- width: `${e.rect.w / _ * 100}%`,
1534
- height: `${e.rect.h / S * 100}%`
1535
- });
1536
- return /* @__PURE__ */ J(l, {
1537
- title: n,
1538
- children: /* @__PURE__ */ Y("div", {
1539
- ref: y,
1540
- className: z("chart-treemap", i),
1541
- role: "group",
1542
- "aria-label": t,
1543
- children: [
1544
- /* @__PURE__ */ J("div", {
1545
- className: `chart-treemap-box chart-plot${a ? " chart-plot--pick" : ""}`,
1546
- style: { height: S },
1547
- role: a ? void 0 : "img",
1548
- "aria-label": a ? void 0 : P ? M(P) : `${t}: ${T.map(M).join(", ")}`,
1549
- ...O.plotProps,
1550
- ref: j,
1551
- children: w.map((e) => {
1552
- let t = E(e), n = !!e.node.children?.some((e) => e.value > 0), r = e.parent ? e.parent.children.filter((e) => e.value > 0).indexOf(e.node) : 0, i = o !== null && o !== t.key || P !== null && E(P).key !== t.key, a = T.indexOf(e);
1553
- return /* @__PURE__ */ J("div", {
1554
- ...a >= 0 ? O.item(a, {
1555
- pressed: o === t.key,
1556
- disabled: !D(e)
1557
- }) : {},
1558
- "aria-label": O.pickable && a >= 0 ? M(e) : void 0,
1559
- className: `chart-treemap-tile${n ? " chart-treemap-tile--group" : ""}${e.parent ? " chart-treemap-tile--child" : ""}${i ? " chart-faded" : ""}${o === t.key ? " chart-treemap-tile--on" : ""}${P === e ? " chart-treemap-tile--active" : ""}`,
1560
- style: {
1561
- ...F(e),
1562
- background: L(t.slot),
1563
- color: te(t.slot),
1564
- opacity: e.parent ? A(r) : void 0
1565
- },
1566
- "aria-hidden": O.pickable && a >= 0 ? void 0 : !0,
1567
- children: e.label && /* @__PURE__ */ Y("span", {
1568
- className: "chart-treemap-label",
1569
- children: [
1570
- /* @__PURE__ */ J("span", {
1571
- className: "chart-treemap-name",
1572
- children: e.node.label
1573
- }),
1574
- " ",
1575
- !n && /* @__PURE__ */ J("span", {
1576
- className: "chart-treemap-count",
1577
- children: p(e.node.value)
1578
- })
1579
- ]
1580
- })
1581
- }, N(e));
1582
- })
1583
- }),
1584
- /* @__PURE__ */ J(s, { text: P ? M(P) : "" }),
1585
- O.tooltip(P && /* @__PURE__ */ J($, {
1586
- title: P.parent ? `${P.parent.label} › ${P.node.label}` : P.node.label,
1587
- rows: [{
1588
- key: "n",
1589
- color: L(E(P).slot),
1590
- label: t,
1591
- value: p(P.node.value)
1592
- }],
1593
- note: m.shareOf(c(f(P.node.value, C)), p(C))
1594
- }))
1595
- ]
1596
- })
1597
- });
1598
- }
1599
- // src/components/Charts/ChartView.tsx
1600
- function qe({ chart: e, ariaLabel: t, compact: n = !1, height: r, size: i, onSelect: a, selected: o = null, linkAs: s, onLegendCut: c, legend: l = !0, ...u }) {
1601
- let d = {
1602
- ariaLabel: t,
1603
- compact: n,
1604
- ...u
1605
- }, f = a ? (e) => a(e.key ?? e.label) : void 0;
1606
- switch (e.kind) {
1607
- case "columns": return /* @__PURE__ */ J(Pe, {
1608
- data: e.data,
1609
- series: e.series,
1610
- mode: e.mode,
1611
- legend: l && e.series.length > 1,
1612
- height: r,
1613
- onSelect: f,
1614
- selected: o,
1615
- ...d
1616
- });
1617
- case "line": return /* @__PURE__ */ J(Ve, {
1618
- data: e.data,
1619
- series: e.series,
1620
- area: e.area,
1621
- height: r,
1622
- onSelect: f,
1623
- selected: o,
1624
- ...d
1625
- });
1626
- case "bars": return /* @__PURE__ */ J(Ce, {
1627
- data: e.data,
1628
- series: e.series,
1629
- linkAs: s,
1630
- onSelect: f,
1631
- selected: o,
1632
- ...d
1633
- });
1634
- case "stacked": return /* @__PURE__ */ J(We, {
1635
- slices: e.slices,
1636
- onLegendCut: c,
1637
- onSelect: f,
1638
- selected: o,
1639
- ...d
1640
- });
1641
- case "donut":
1642
- case "pie": return /* @__PURE__ */ J(Le, {
1643
- variant: e.kind,
1644
- slices: e.slices,
1645
- size: i,
1646
- legend: l,
1647
- onLegendCut: c,
1648
- onSelect: f,
1649
- selected: o,
1650
- ...d
1651
- });
1652
- case "treemap": return /* @__PURE__ */ J(Ke, {
1653
- nodes: e.nodes,
1654
- height: r,
1655
- onSelect: f,
1656
- selected: o,
1657
- ...d
1658
- });
1659
- case "calendar": return /* @__PURE__ */ J(Oe, {
1660
- days: e.days,
1661
- onSelect: a ? (e) => a(e.day) : void 0,
1662
- selected: o,
1663
- ...d
1664
- });
1665
- case "funnel": return /* @__PURE__ */ J(Re, {
1666
- steps: e.steps,
1667
- onSelect: f,
1668
- selected: o,
1669
- ...d
1670
- });
1671
- case "gauge": {
1672
- let t = e.rows[0];
1673
- return /* @__PURE__ */ J(ze, {
1674
- value: t.value,
1675
- total: t.total,
1676
- color: t.color,
1677
- variant: e.variant,
1678
- label: n ? void 0 : t.label,
1679
- ...d
1680
- });
1681
- }
1682
- case "progress": {
1683
- let t = e.rows[0];
1684
- return /* @__PURE__ */ J(Ue, {
1685
- value: t.value,
1686
- total: t.total,
1687
- color: t.color,
1688
- label: n ? void 0 : t.label,
1689
- ...d
1690
- });
1691
- }
1692
- case "number": return /* @__PURE__ */ J(He, {
1693
- value: e.value,
1694
- points: e.points,
1695
- current: e.current,
1696
- previous: e.previous,
1697
- good: e.good,
1698
- slot: e.slot,
1699
- ...d
1700
- });
1701
- }
1702
- }
1703
- export { pe as C, he as D, fe as E, de as O, ge as S, _e as T, $ as _, He as a, Q as b, Re as c, ke as d, Oe as f, Ce as g, Te as h, Ue as i, X as k, Le as l, we as m, Ke as n, Ve as o, De as p, We as r, ze as s, qe as t, Pe as u, be as v, ue as w, me as x, xe as y };