@altertable/data-app 0.68.0 → 0.70.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 (203) hide show
  1. package/AGENTS.md +10 -0
  2. package/CONTRIBUTING.md +27 -1
  3. package/README.md +18 -21
  4. package/THIRD_PARTY_NOTICES +18 -0
  5. package/dist/chunks/index-22d576sn.js +153 -0
  6. package/dist/chunks/index-22d576sn.js.map +11 -0
  7. package/dist/chunks/index-2ajhmsc4.js +355 -0
  8. package/dist/chunks/index-2ajhmsc4.js.map +13 -0
  9. package/dist/chunks/{index-ktmvs916.js → index-58kks6a8.js} +37 -21
  10. package/dist/chunks/index-58kks6a8.js.map +13 -0
  11. package/dist/chunks/{index-23dktynd.js → index-7q99hf1z.js} +19 -12
  12. package/dist/chunks/index-7q99hf1z.js.map +10 -0
  13. package/dist/chunks/{index-mt93ff2b.js → index-9zqbrv2z.js} +7 -3
  14. package/dist/chunks/index-9zqbrv2z.js.map +10 -0
  15. package/dist/chunks/{index-m6n8ctfc.js → index-cv36cyna.js} +4 -4
  16. package/dist/chunks/index-cv36cyna.js.map +10 -0
  17. package/dist/chunks/{index-ag0cgnvq.js → index-q1w84fv9.js} +178 -31
  18. package/dist/chunks/index-q1w84fv9.js.map +15 -0
  19. package/dist/chunks/{index-qd5xgx6y.js → index-rew95tbg.js} +89 -21
  20. package/dist/chunks/index-rew95tbg.js.map +13 -0
  21. package/dist/chunks/{index-gvers8jw.js → index-vtpygsbq.js} +5651 -2711
  22. package/dist/chunks/index-vtpygsbq.js.map +126 -0
  23. package/dist/chunks/{index-x69p7cv7.js → index-wjt6cavj.js} +6 -4
  24. package/dist/chunks/index-wjt6cavj.js.map +10 -0
  25. package/dist/chunks/{index-f5cnbrjz.js → index-wss3gd3h.js} +39 -9
  26. package/dist/chunks/index-wss3gd3h.js.map +13 -0
  27. package/dist/chunks/{index-ev2b5aaf.js → index-xzb7sx6g.js} +4 -4
  28. package/dist/client/index.js +6 -6
  29. package/dist/core/appearance.js +1 -1
  30. package/dist/core/config.js +3 -3
  31. package/dist/core/contract.js +7 -7
  32. package/dist/core/contract.js.map +1 -1
  33. package/dist/core/format.js +10 -2
  34. package/dist/core/format.js.map +1 -1
  35. package/dist/embed/index.js +26 -25
  36. package/dist/embed/index.js.map +4 -4
  37. package/dist/index.js +3 -3
  38. package/dist/local.js +200 -145
  39. package/dist/local.js.map +10 -7
  40. package/dist/preview.js +1456 -0
  41. package/dist/preview.js.map +17 -0
  42. package/dist/react/embed/index.js +1 -1
  43. package/dist/react/index.js +500 -401
  44. package/dist/react/index.js.map +10 -13
  45. package/dist/react/ui/index.js +1851 -1476
  46. package/dist/react/ui/index.js.map +24 -21
  47. package/dist/server.js +102 -58
  48. package/dist/server.js.map +9 -6
  49. package/dist/types/client/data-client.d.ts +21 -10
  50. package/dist/types/client/download.d.ts +5 -0
  51. package/dist/types/client/iframe.d.ts +4 -2
  52. package/dist/types/client/logger.d.ts +10 -2
  53. package/dist/types/core/annotations.d.ts +5 -0
  54. package/dist/types/core/appearance.d.ts +2 -0
  55. package/dist/types/core/bridge-endpoint.d.ts +2 -2
  56. package/dist/types/core/bridge.d.ts +22 -0
  57. package/dist/types/core/config.d.ts +25 -17
  58. package/dist/types/core/contract.d.ts +26 -14
  59. package/dist/types/core/date-format.d.ts +24 -0
  60. package/dist/types/core/dimension-source.d.ts +64 -0
  61. package/dist/types/core/dimension.d.ts +33 -24
  62. package/dist/types/core/facets.d.ts +13 -0
  63. package/dist/types/core/filters.d.ts +4 -3
  64. package/dist/types/core/format.d.ts +5 -3
  65. package/dist/types/core/keys.d.ts +2 -0
  66. package/dist/types/core/messages.d.ts +3 -1
  67. package/dist/types/core/operation-types.d.ts +12 -11
  68. package/dist/types/core/queries.d.ts +75 -7
  69. package/dist/types/core/time-interval.d.ts +96 -0
  70. package/dist/types/core/variables.d.ts +49 -14
  71. package/dist/types/embed/host.d.ts +4 -4
  72. package/dist/types/embed/sql.d.ts +1 -1
  73. package/dist/types/index.d.ts +1 -1
  74. package/dist/types/react/actions.d.ts +53 -0
  75. package/dist/types/react/annotations/annotation-editor-state.d.ts +2 -0
  76. package/dist/types/react/annotations/annotation-targets.d.ts +1 -0
  77. package/dist/types/react/annotations/getAnnotationProps.d.ts +5 -3
  78. package/dist/types/react/annotations/useAnnotationGeometry.d.ts +2 -2
  79. package/dist/types/react/bindings.d.ts +62 -3
  80. package/dist/types/react/date-formatting.d.ts +12 -0
  81. package/dist/types/react/details.d.ts +46 -0
  82. package/dist/types/react/exploration.d.ts +44 -0
  83. package/dist/types/react/hooks.d.ts +82 -43
  84. package/dist/types/react/index.d.ts +10 -2
  85. package/dist/types/react/search-suggestions.d.ts +8 -0
  86. package/dist/types/react/style-contract.d.ts +1 -5
  87. package/dist/types/react/ui/AboutData.d.ts +9 -4
  88. package/dist/types/react/ui/AreaChart.d.ts +2 -2
  89. package/dist/types/react/ui/BarChart.d.ts +2 -2
  90. package/dist/types/react/ui/Button.d.ts +2 -1
  91. package/dist/types/react/ui/ChartLegend.d.ts +3 -2
  92. package/dist/types/react/ui/ChoicePicker.d.ts +2 -0
  93. package/dist/types/react/ui/ComposedChartLegend.d.ts +2 -1
  94. package/dist/types/react/ui/DataApp.d.ts +8 -4
  95. package/dist/types/react/ui/DataAppFrame.d.ts +14 -3
  96. package/dist/types/react/ui/DataTable.d.ts +6 -4
  97. package/dist/types/react/ui/DataWidget.d.ts +7 -0
  98. package/dist/types/react/ui/DateDisplay.d.ts +9 -0
  99. package/dist/types/react/ui/DateRangePicker.d.ts +3 -1
  100. package/dist/types/react/ui/DateTimeTooltip.d.ts +3 -2
  101. package/dist/types/react/ui/DimensionPicker.d.ts +5 -3
  102. package/dist/types/react/ui/EmptyState.d.ts +1 -1
  103. package/dist/types/react/ui/ExplorationActionControl.d.ts +60 -0
  104. package/dist/types/react/ui/GradientScroll.d.ts +8 -0
  105. package/dist/types/react/ui/Grid.d.ts +1 -1
  106. package/dist/types/react/ui/InspectionProvider.d.ts +2 -2
  107. package/dist/types/react/ui/LineChart.d.ts +2 -2
  108. package/dist/types/react/ui/Menu.d.ts +3 -2
  109. package/dist/types/react/ui/MetricWidget.d.ts +4 -0
  110. package/dist/types/react/ui/NumberFilterPicker.d.ts +3 -1
  111. package/dist/types/react/ui/PeriodSummary.d.ts +2 -1
  112. package/dist/types/react/ui/PickerField.d.ts +23 -0
  113. package/dist/types/react/ui/PieChart.d.ts +2 -2
  114. package/dist/types/react/ui/PopoverSurface.d.ts +5 -0
  115. package/dist/types/react/ui/RequestHint.d.ts +2 -2
  116. package/dist/types/react/ui/SearchField.d.ts +3 -1
  117. package/dist/types/react/ui/SearchTypeahead.d.ts +15 -0
  118. package/dist/types/react/ui/SectionHeading.d.ts +8 -0
  119. package/dist/types/react/ui/Select.d.ts +9 -1
  120. package/dist/types/react/ui/Sheet.d.ts +4 -2
  121. package/dist/types/react/ui/TableWidget.d.ts +8 -0
  122. package/dist/types/react/ui/Tabs.d.ts +4 -3
  123. package/dist/types/react/ui/TrendChart.d.ts +3 -3
  124. package/dist/types/react/ui/VariableBar.d.ts +1 -1
  125. package/dist/types/react/ui/VisualizationWidget.d.ts +1 -1
  126. package/dist/types/react/ui/chart-data.d.ts +8 -6
  127. package/dist/types/react/ui/chart-date-axis.d.ts +15 -0
  128. package/dist/types/react/ui/chart-interaction.d.ts +27 -0
  129. package/dist/types/react/ui/chart-primitives.d.ts +4 -4
  130. package/dist/types/react/ui/chart-time.d.ts +19 -0
  131. package/dist/types/react/ui/chartColor.d.ts +1 -1
  132. package/dist/types/react/ui/icons.d.ts +5 -1
  133. package/dist/types/react/ui/index.d.ts +10 -4
  134. package/dist/types/react/ui/metric-comparison.d.ts +2 -2
  135. package/dist/types/react/ui/metric.d.ts +2 -2
  136. package/dist/types/react/ui/presentation.d.ts +2 -0
  137. package/dist/types/react/ui/searchItems.d.ts +2 -0
  138. package/dist/types/react/ui/use-chart-scroll-to-end.d.ts +2 -0
  139. package/dist/types/react/ui/variables.d.ts +1 -1
  140. package/dist/types/react/view-control-bar.d.ts +18 -0
  141. package/dist/types/react/view-controls.d.ts +3 -2
  142. package/dist/types/react/view-runtime.d.ts +8 -3
  143. package/dist/types/react/view.d.ts +28 -7
  144. package/dist/types/react/widgets.d.ts +22 -11
  145. package/dist/types/server/local.d.ts +3 -1
  146. package/dist/types/server/preview/host.d.ts +1 -0
  147. package/dist/types/server/preview/index.d.ts +16 -0
  148. package/dist/types/server/reload-channel.d.ts +6 -0
  149. package/dist/types/server/request-body.d.ts +4 -0
  150. package/dist/worker.js +1 -1
  151. package/docs/app-authoring.md +27 -12
  152. package/docs/client.md +6 -7
  153. package/docs/composition.md +84 -0
  154. package/docs/contract.md +45 -26
  155. package/docs/data-context.md +2 -0
  156. package/docs/embed.md +11 -3
  157. package/docs/formatting-and-appearance.md +36 -5
  158. package/docs/layout.md +31 -8
  159. package/docs/react-embed.md +4 -4
  160. package/docs/react.md +1 -1
  161. package/docs/server-bun.md +25 -0
  162. package/docs/server.md +2 -2
  163. package/docs/styling.md +10 -27
  164. package/docs/ui.md +32 -18
  165. package/docs/variables.md +174 -25
  166. package/docs/views.md +60 -29
  167. package/docs/widgets.md +131 -26
  168. package/examples/starter-data-app/index.tsx +10 -23
  169. package/examples/starter-local-data-app/.bun-version +1 -0
  170. package/examples/starter-local-data-app/.node-version +1 -0
  171. package/examples/starter-local-data-app/.oxfmtrc.json +4 -0
  172. package/examples/starter-local-data-app/.oxlintrc.json +33 -0
  173. package/examples/starter-local-data-app/AGENTS.md +22 -0
  174. package/examples/starter-local-data-app/README.md +54 -0
  175. package/examples/starter-local-data-app/app.ts +28 -0
  176. package/examples/starter-local-data-app/bunfig.toml +2 -0
  177. package/examples/starter-local-data-app/package.json +33 -0
  178. package/examples/starter-local-data-app/src/App.tsx +8 -0
  179. package/examples/starter-local-data-app/src/assets.d.ts +1 -0
  180. package/examples/starter-local-data-app/src/data-context.ts +21 -0
  181. package/examples/starter-local-data-app/src/favicon.svg +13 -0
  182. package/examples/starter-local-data-app/src/index.html +14 -0
  183. package/examples/starter-local-data-app/src/main.tsx +7 -0
  184. package/examples/starter-local-data-app/src/operations.ts +6 -0
  185. package/examples/starter-local-data-app/src/server.ts +6 -0
  186. package/examples/starter-local-data-app/tsconfig.json +21 -0
  187. package/package.json +13 -3
  188. package/dist/chunks/index-23dktynd.js.map +0 -10
  189. package/dist/chunks/index-ag0cgnvq.js.map +0 -13
  190. package/dist/chunks/index-dq7b35fn.js +0 -307
  191. package/dist/chunks/index-dq7b35fn.js.map +0 -13
  192. package/dist/chunks/index-f5cnbrjz.js.map +0 -13
  193. package/dist/chunks/index-gvers8jw.js.map +0 -109
  194. package/dist/chunks/index-ktmvs916.js.map +0 -13
  195. package/dist/chunks/index-m6n8ctfc.js.map +0 -10
  196. package/dist/chunks/index-mev09s5v.js +0 -77
  197. package/dist/chunks/index-mev09s5v.js.map +0 -10
  198. package/dist/chunks/index-mt93ff2b.js.map +0 -10
  199. package/dist/chunks/index-qd5xgx6y.js.map +0 -13
  200. package/dist/chunks/index-x69p7cv7.js.map +0 -10
  201. package/dist/types/react/shellStyles.d.ts +0 -3
  202. package/dist/types/react/ui/DataAppSkeleton.d.ts +0 -7
  203. /package/dist/chunks/{index-ev2b5aaf.js.map → index-xzb7sx6g.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
- injectStyles,
3
2
  injectDataAppStyles2,
3
+ useDateFormatting2,
4
4
  AppIcon2,
5
5
  classNames,
6
6
  Button2,
@@ -10,8 +10,8 @@ import {
10
10
  Tooltip2,
11
11
  GradientScroll2,
12
12
  Sheet2,
13
- TabList2,
14
13
  TabPanels2,
14
+ TabList2,
15
15
  Tab2,
16
16
  TabPanel2,
17
17
  Tabs2,
@@ -19,17 +19,21 @@ import {
19
19
  AboutData2,
20
20
  DataAppProvider2,
21
21
  useDeclaredResult,
22
+ HelpPopover2,
23
+ DateDisplay2,
22
24
  validateChoiceOptions,
23
25
  useAppVariables2,
26
+ SearchField2,
27
+ SearchMatch2,
28
+ matchSearchText2,
29
+ searchItems2,
30
+ SearchTypeahead2,
24
31
  Select2,
25
32
  FilterActions2,
33
+ VariableBar2,
26
34
  NumberField2,
27
35
  NumberRangeField2,
28
36
  NumberFilterPicker2,
29
- SearchField2,
30
- Skeleton2,
31
- SearchMatch2,
32
- searchItems2,
33
37
  ChoicePicker2,
34
38
  CheckboxGroupContext,
35
39
  Checkbox2,
@@ -46,13 +50,16 @@ import {
46
50
  MenuSeparator2,
47
51
  LiveControl2,
48
52
  PresentStory2,
49
- VariableBar2,
50
53
  DataAppFrame,
51
- Grid2,
54
+ ExplorationActionControl2,
55
+ ExplorationActionMenu,
56
+ useChartActions,
57
+ openExplorationMenu,
58
+ explorationMenuEvents,
59
+ getPrimaryExplorationAction,
52
60
  DataWidget2,
53
61
  VisualizationWidget2,
54
62
  MetricWidget2,
55
- HelpPopover2,
56
63
  DataTable2,
57
64
  DataTableShare2,
58
65
  DataTableEmptyRow2,
@@ -61,758 +68,29 @@ import {
61
68
  TextWidget2,
62
69
  DataValue2,
63
70
  chartBarFill,
64
- createDataContext2
65
- } from "../../chunks/index-gvers8jw.js";
71
+ createDataContext2,
72
+ SectionHeading2
73
+ } from "../../chunks/index-vtpygsbq.js";
66
74
  import {
75
+ formatDate2,
76
+ parseDateTime2,
77
+ formatDateTime2,
67
78
  formatNumber2,
68
79
  formatPercent2
69
- } from "../../chunks/index-mev09s5v.js";
70
- import"../../chunks/index-ag0cgnvq.js";
71
- import"../../chunks/index-mt93ff2b.js";
72
- import"../../chunks/index-m6n8ctfc.js";
80
+ } from "../../chunks/index-22d576sn.js";
81
+ import {
82
+ KEY_SEPARATOR
83
+ } from "../../chunks/index-q1w84fv9.js";
84
+ import"../../chunks/index-9zqbrv2z.js";
85
+ import"../../chunks/index-cv36cyna.js";
73
86
  import {
74
87
  createDataClient2
75
- } from "../../chunks/index-23dktynd.js";
76
- import"../../chunks/index-x69p7cv7.js";
77
- import"../../chunks/index-ev2b5aaf.js";
88
+ } from "../../chunks/index-7q99hf1z.js";
89
+ import"../../chunks/index-wjt6cavj.js";
90
+ import"../../chunks/index-xzb7sx6g.js";
78
91
  import {
79
92
  invariant
80
- } from "../../chunks/index-qd5xgx6y.js";
81
-
82
- // src/react/shellStyles.ts
83
- function injectDataAppShellStyles(options = {}) {
84
- return injectStyles({
85
- name: "injectDataAppShellStyles",
86
- attribute: "data-altertable-shell-styles",
87
- css: `/* src/react/tokens.css */
88
- @layer atbl.tokens {
89
- :root {
90
- --atbl-control-text-size: var(--atbl-type-body-size);
91
- --atbl-background: var(--atbl-palette-background);
92
- --atbl-surface: var(--atbl-palette-surface);
93
- --atbl-subtle: var(--atbl-palette-subtle);
94
- --atbl-backdrop: #0f171e38;
95
- --atbl-text: var(--atbl-palette-text);
96
- --atbl-muted: var(--atbl-palette-muted);
97
- --atbl-border: var(--atbl-palette-border);
98
- --atbl-accent: var(--atbl-input-accent, #405d47);
99
- --atbl-on-accent: var(--atbl-input-on-accent, #fff);
100
- --atbl-danger: #b42318;
101
- --atbl-danger-subtle: color-mix(in srgb, var(--atbl-danger) 9%, var(--atbl-surface));
102
- --atbl-code-surface: #f4f6f9;
103
- --atbl-code-text: #273242;
104
- --atbl-mono-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
105
- --atbl-focus-ring-offset: 2px;
106
- --atbl-focus-ring-inset: -1px;
107
- --atbl-font: var(--atbl-input-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif);
108
- --atbl-space-xs: 5px;
109
- --atbl-space-sm: 10px;
110
- --atbl-space-md: 16px;
111
- --atbl-space-lg: 24px;
112
- --atbl-space-xl: 32px;
113
- --atbl-content-width: 960px;
114
- --atbl-control-height: 2.375rem;
115
- --atbl-control-compact-height: 1.875rem;
116
- --atbl-control-icon-size: 1rem;
117
- --atbl-control-padding-inline: .75rem;
118
- --atbl-control-padding-block: .375rem;
119
- --atbl-control-gap: .5rem;
120
- --atbl-control-disabled-opacity: .5;
121
- --atbl-radius-control: 7px;
122
- --atbl-radius-surface: 12px;
123
- --atbl-radius-overlay: 16px;
124
- --atbl-shadow-surface: 0 3px 16px #141c280d;
125
- --atbl-shadow-overlay: 0 18px 50px #00000029;
126
- --atbl-shadow-control: 0 1px 3px #0000001a;
127
- --atbl-cursor-action: pointer;
128
- --atbl-cursor-disabled: default;
129
- --atbl-cursor-help: help;
130
- --atbl-cursor-busy: progress;
131
- --atbl-duration-fast: .12s;
132
- --atbl-duration-normal: .18s;
133
- --atbl-duration-slow: .24s;
134
- --atbl-ease-standard: ease;
135
- --atbl-ease-enter: cubic-bezier(.2, .7, .2, 1);
136
- --atbl-chart-1: color-mix(in srgb, var(--atbl-input-chart-1, #285fc0) var(--atbl-chart-strength), white);
137
- --atbl-chart-2: color-mix(in srgb, var(--atbl-input-chart-2, #a95319) var(--atbl-chart-strength), white);
138
- --atbl-chart-3: color-mix(in srgb, var(--atbl-input-chart-3, #147862) var(--atbl-chart-strength), white);
139
- --atbl-chart-4: color-mix(in srgb, var(--atbl-input-chart-4, #7243aa) var(--atbl-chart-strength), white);
140
- --atbl-chart-5: color-mix(in srgb, var(--atbl-input-chart-5, #aa3958) var(--atbl-chart-strength), white);
141
- --atbl-chart-6: color-mix(in srgb, var(--atbl-input-chart-6, #475569) var(--atbl-chart-strength), white);
142
- --atbl-chart-7: color-mix(in srgb, var(--atbl-input-chart-7, #285fc0) var(--atbl-chart-strength), white);
143
- --atbl-chart-8: color-mix(in srgb, var(--atbl-input-chart-8, #a95319) var(--atbl-chart-strength), white);
144
- --atbl-type-emphasis-weight: 680;
145
- --atbl-type-meta-weight: 500;
146
- --atbl-type-page-size: clamp(1.375rem, 2.4vw, 1.75rem);
147
- --atbl-type-section-size: 1.25rem;
148
- --atbl-type-widget-size: 1.0625rem;
149
- --atbl-type-body-size: .875rem;
150
- --atbl-type-label-size: .8125rem;
151
- --atbl-type-meta-size: .75rem;
152
- --atbl-type-metric-size: clamp(1.625rem, 3vw, 2.125rem);
153
- --atbl-type-heading-weight: 650;
154
- --atbl-type-label-weight: 600;
155
- --atbl-type-body-leading: 1.65;
156
- --atbl-type-label-leading: 1.4;
157
- --atbl-type-heading-leading: 1.3;
158
- --atbl-type-metric-leading: 1.08;
159
- --atbl-text-measure: 70ch;
160
- }
161
- }
162
-
163
- /* src/react/appearance.css */
164
- @layer atbl.tokens {
165
- :root {
166
- --atbl-palette-background: #fff;
167
- --atbl-palette-surface: #fff;
168
- --atbl-palette-subtle: #f6f7f7;
169
- --atbl-palette-text: #202124;
170
- --atbl-palette-muted: #687078;
171
- --atbl-palette-border: #e3e6e8;
172
- --atbl-chart-strength: 100%;
173
- --atbl-accent-subtle-strength: 12%;
174
- }
175
-
176
- :root[data-atbl-theme="dark"] {
177
- --atbl-palette-background: #151719;
178
- --atbl-palette-surface: #202326;
179
- --atbl-palette-subtle: #292d31;
180
- --atbl-palette-text: #f2f3f4;
181
- --atbl-palette-muted: #aeb5bc;
182
- --atbl-palette-border: #3b4248;
183
- }
184
-
185
- :root[data-atbl-base-color="slate"] {
186
- --atbl-palette-background: #f8fafc;
187
- --atbl-palette-surface: #fff;
188
- --atbl-palette-subtle: #f1f5f9;
189
- --atbl-palette-text: #17212f;
190
- --atbl-palette-muted: #607083;
191
- --atbl-palette-border: #dce3ea;
192
- }
193
-
194
- :root[data-atbl-base-color="slate"][data-atbl-theme="dark"] {
195
- --atbl-palette-background: #111820;
196
- --atbl-palette-surface: #1b2530;
197
- --atbl-palette-subtle: #263340;
198
- --atbl-palette-text: #f0f4f8;
199
- --atbl-palette-muted: #a8b5c3;
200
- --atbl-palette-border: #3a4857;
201
- }
202
-
203
- :root[data-atbl-base-color="warm"] {
204
- --atbl-palette-background: #fbfaf8;
205
- --atbl-palette-surface: #fff;
206
- --atbl-palette-subtle: #f5f2ed;
207
- --atbl-palette-text: #292723;
208
- --atbl-palette-muted: #736e66;
209
- --atbl-palette-border: #e8e2da;
210
- }
211
-
212
- :root[data-atbl-base-color="warm"][data-atbl-theme="dark"] {
213
- --atbl-palette-background: #1b1916;
214
- --atbl-palette-surface: #25221e;
215
- --atbl-palette-subtle: #302c27;
216
- --atbl-palette-text: #f5f1eb;
217
- --atbl-palette-muted: #bcb3a8;
218
- --atbl-palette-border: #494239;
219
- }
220
-
221
- :root[data-atbl-theme="dark"] {
222
- --atbl-accent: var(--atbl-input-dark-accent, color-mix(in srgb, var(--atbl-input-accent, #405d47) 50%, white));
223
- --atbl-accent-subtle-strength: 22%;
224
- --atbl-on-accent: var(--atbl-input-on-accent, var(--atbl-background));
225
- --atbl-danger: #f97066;
226
- --atbl-backdrop: #0000008c;
227
- --atbl-code-surface: #242a31;
228
- --atbl-code-text: #e5e9ef;
229
- --atbl-chart-strength: 60%;
230
- }
231
-
232
- :root[data-atbl-density="compact"] {
233
- --atbl-control-height: 2.125rem;
234
- --atbl-control-padding-inline: .625rem;
235
- --atbl-control-padding-block: .25rem;
236
- --atbl-space-xs: 4px;
237
- --atbl-space-sm: 8px;
238
- --atbl-space-md: 12px;
239
- --atbl-space-lg: 18px;
240
- --atbl-space-xl: 24px;
241
- }
242
-
243
- :root[data-atbl-density="spacious"] {
244
- --atbl-control-height: 2.625rem;
245
- --atbl-control-padding-inline: 1rem;
246
- --atbl-control-padding-block: .5rem;
247
- --atbl-space-xs: 6px;
248
- --atbl-space-sm: 12px;
249
- --atbl-space-md: 20px;
250
- --atbl-space-lg: 30px;
251
- --atbl-space-xl: 40px;
252
- }
253
-
254
- :root[data-atbl-radius="none"] {
255
- --atbl-radius-control: 0px;
256
- --atbl-radius-surface: 0px;
257
- --atbl-radius-overlay: 0px;
258
- }
259
-
260
- :root[data-atbl-radius="small"] {
261
- --atbl-radius-control: 4px;
262
- --atbl-radius-surface: 7px;
263
- --atbl-radius-overlay: 9px;
264
- }
265
-
266
- :root[data-atbl-radius="large"] {
267
- --atbl-radius-control: 10px;
268
- --atbl-radius-surface: 18px;
269
- --atbl-radius-overlay: 24px;
270
- }
271
-
272
- :root[data-atbl-elevation="flat"] {
273
- --atbl-shadow-surface: none;
274
- --atbl-shadow-overlay: none;
275
- --atbl-shadow-control: none;
276
- }
277
-
278
- :root[data-atbl-elevation="raised"] {
279
- --atbl-shadow-surface: 0 8px 28px #141c281a;
280
- --atbl-shadow-overlay: 0 24px 72px #0000003d;
281
- }
282
-
283
- @media (forced-colors: active) {
284
- :root {
285
- --atbl-focus-color: Highlight !important;
286
- --atbl-on-accent: HighlightText !important;
287
- }
288
- }
289
- }
290
-
291
- /* src/react/base.css */
292
- @layer atbl.base {
293
- :where([class^="altertable-"], [class*=" altertable-"]) {
294
- box-sizing: border-box;
295
- }
296
-
297
- :where([class^="altertable-"], [class*=" altertable-"]) * {
298
- box-sizing: border-box;
299
- }
300
-
301
- :where([class^="starter-"], [class*=" starter-"]) * {
302
- box-sizing: border-box;
303
- }
304
-
305
- :where([class^="altertable-"], [class*=" altertable-"]) button {
306
- font: inherit;
307
- }
308
-
309
- :root[data-atbl-appearance] {
310
- scrollbar-gutter: stable;
311
- font-family: var(--atbl-font);
312
- color: var(--atbl-text);
313
- background: var(--atbl-background);
314
- font-synthesis: none;
315
- -webkit-font-smoothing: antialiased;
316
- text-rendering: optimizeLegibility;
317
- }
318
-
319
- :root[data-atbl-theme="light"] {
320
- --buncss-light: initial;
321
- --buncss-dark: ;
322
- color-scheme: light;
323
- }
324
-
325
- :root[data-atbl-theme="dark"] {
326
- --buncss-light: ;
327
- --buncss-dark: initial;
328
- color-scheme: dark;
329
- }
330
-
331
- :root[data-atbl-appearance] body, :root[data-atbl-appearance] #root {
332
- margin: 0;
333
- }
334
-
335
- .altertable-sr-only {
336
- position: fixed;
337
- overflow: hidden;
338
- clip: rect(0, 0, 0, 0);
339
- clip-path: inset(50%);
340
- white-space: nowrap;
341
- border: 0;
342
- width: 1px;
343
- height: 1px;
344
- margin: -1px;
345
- padding: 0;
346
- }
347
- }
348
-
349
- /* src/react/ui/Skeleton.css */
350
- @layer atbl.components {
351
- .altertable-skeleton {
352
- display: block;
353
- border-radius: var(--atbl-radius-control);
354
- background: var(--atbl-subtle);
355
- opacity: 0;
356
- animation: altertable-skeleton-in .2s var(--atbl-ease-standard) .2s forwards, altertable-skeleton-pulse 1.4s ease-in-out .4s infinite alternate;
357
- }
358
-
359
- .altertable-skeleton[data-inline] {
360
- display: inline-block;
361
- vertical-align: middle;
362
- width: 8ch;
363
- height: 1em;
364
- }
365
-
366
- @keyframes altertable-skeleton-in {
367
- to {
368
- opacity: 1;
369
- }
370
- }
371
-
372
- @keyframes altertable-skeleton-pulse {
373
- to {
374
- opacity: .5;
375
- }
376
- }
377
-
378
- @media (prefers-reduced-motion: reduce) {
379
- .altertable-skeleton {
380
- animation: 1ms .2s forwards altertable-skeleton-in;
381
- }
382
- }
383
- }
384
-
385
- /* src/react/ui/Grid.css */
386
- @layer atbl.components {
387
- .altertable-grid {
388
- display: grid;
389
- container: altertable-grid / inline-size;
390
- --atbl-grid-gap: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
391
- --atbl-grid-min-item-width: 240px;
392
- --atbl-grid-column-width: 100%;
393
- --atbl-grid-max-columns: 1;
394
- align-content: start;
395
- align-items: start;
396
- gap: var(--atbl-grid-gap);
397
- grid-template-columns: repeat(auto-fit, minmax(min(100%, max(var(--atbl-grid-min-item-width), var(--atbl-grid-column-width))), 1fr));
398
- min-width: 0;
399
- }
400
-
401
- .altertable-grid > * {
402
- min-width: 0;
403
- min-height: 0;
404
- margin: 0;
405
- }
406
-
407
- .altertable-grid[data-align="stretch"] {
408
- align-items: stretch;
409
- }
410
-
411
- .altertable-grid[data-gap="sm"] {
412
- --atbl-grid-gap: var(--atbl-space-sm);
413
- }
414
-
415
- .altertable-grid[data-gap="md"] {
416
- --atbl-grid-gap: var(--atbl-space-md);
417
- }
418
-
419
- .altertable-grid[data-gap="lg"] {
420
- --atbl-grid-gap: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
421
- }
422
-
423
- .altertable-grid[data-min-item-width="compact"] {
424
- --atbl-grid-min-item-width: 192px;
425
- }
426
-
427
- .altertable-grid[data-min-item-width="wide"] {
428
- --atbl-grid-min-item-width: 320px;
429
- }
430
-
431
- .altertable-grid[data-columns="2"] {
432
- --atbl-grid-max-columns: 2;
433
- --atbl-grid-column-width: calc((100% - var(--atbl-grid-gap)) / 2);
434
- }
435
-
436
- .altertable-grid[data-columns="3"] {
437
- --atbl-grid-max-columns: 3;
438
- --atbl-grid-column-width: calc((100% - var(--atbl-grid-gap) - var(--atbl-grid-gap)) / 3);
439
- }
440
-
441
- .altertable-grid[data-columns="4"] {
442
- --atbl-grid-max-columns: 4;
443
- --atbl-grid-column-width: calc((100% - var(--atbl-grid-gap) - var(--atbl-grid-gap) - var(--atbl-grid-gap)) / 4);
444
- }
445
-
446
- .altertable-grid-item {
447
- min-width: 0;
448
- min-height: 0;
449
- }
450
-
451
- .altertable-grid > * {
452
- --atbl-grid-fitting-columns: clamp(1, round(down, tan(atan2(100cqw + var(--atbl-grid-gap) + .001px, var(--atbl-grid-min-item-width) + var(--atbl-grid-gap))), 1), var(--atbl-grid-max-columns));
453
- }
454
-
455
- .altertable-grid > .altertable-grid-item[data-span="2"] {
456
- grid-column: span min(2, var(--atbl-grid-fitting-columns));
457
- }
458
-
459
- .altertable-grid[data-columns="3"]:has( > .altertable-grid-item[data-span="2"]) > :not(.altertable-grid-item[data-span="2"]) {
460
- grid-column: span clamp(1, (3 - var(--atbl-grid-fitting-columns)) * 2, var(--atbl-grid-fitting-columns));
461
- }
462
-
463
- .altertable-grid[data-columns="3"]:not(:has( > .altertable-grid-item[data-span="2"])) > :last-child:nth-child(odd) {
464
- grid-column: span clamp(1, (3 - var(--atbl-grid-fitting-columns)) * 2, var(--atbl-grid-fitting-columns));
465
- }
466
- }
467
-
468
- /* src/react/ui/DataWidget.css */
469
- @layer atbl.components {
470
- .altertable-data-widget {
471
- border: 1px solid var(--atbl-border);
472
- border-radius: calc(var(--atbl-radius-surface) * 1.5);
473
- corner-shape: squircle;
474
- background: var(--atbl-surface);
475
- box-shadow: var(--atbl-shadow-surface);
476
- min-width: 0;
477
- }
478
-
479
- .altertable-data-widget-header {
480
- display: flex;
481
- justify-content: space-between;
482
- align-items: flex-start;
483
- gap: var(--atbl-space-md);
484
- padding: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg))) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg))) 0;
485
- min-height: 30px;
486
- }
487
-
488
- .altertable-data-widget-header > div:first-child {
489
- flex: 1;
490
- min-width: 0;
491
- }
492
-
493
- .altertable-data-widget-help {
494
- display: flex;
495
- flex: none;
496
- align-items: flex-start;
497
- }
498
-
499
- .altertable-data-widget-header h2 {
500
- color: var(--atbl-text);
501
- font-family: var(--atbl-font-heading, var(--atbl-input-font-heading, var(--atbl-font)));
502
- font-size: var(--atbl-type-widget-size);
503
- font-weight: var(--atbl-type-heading-weight);
504
- line-height: var(--atbl-type-heading-leading);
505
- letter-spacing: -.02em;
506
- margin: 0;
507
- }
508
-
509
- .altertable-data-widget-count {
510
- color: var(--atbl-muted);
511
- font-size: var(--atbl-type-meta-size);
512
- font-weight: var(--atbl-type-meta-weight);
513
- letter-spacing: 0;
514
- white-space: nowrap;
515
- margin-left: 8px;
516
- }
517
-
518
- .altertable-data-widget-header p {
519
- color: var(--atbl-muted);
520
- font-size: var(--atbl-type-meta-size);
521
- margin: 4px 0 0;
522
- line-height: 1.45;
523
- }
524
-
525
- .altertable-data-widget-body {
526
- padding: var(--atbl-space-md) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg))) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
527
- min-width: 0;
528
- }
529
-
530
- .altertable-data-widget-body[data-padding="flush"] {
531
- padding: 0;
532
- }
533
-
534
- .altertable-data-widget-footer {
535
- padding: var(--atbl-space-md) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
536
- }
537
-
538
- .altertable-data-widget-body > .altertable-status-panel {
539
- background: none;
540
- border: 0;
541
- border-radius: 0;
542
- margin: 0;
543
- padding: 0;
544
- }
545
- }
546
-
547
- /* src/react/ui/MetricWidget.css */
548
- @layer atbl.components {
549
- .altertable-metric-widget {
550
- display: flex;
551
- padding: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
552
- border: 1px solid var(--atbl-border);
553
- border-radius: calc(var(--atbl-radius-surface) * 1.5);
554
- corner-shape: squircle;
555
- background: var(--atbl-surface);
556
- box-shadow: var(--atbl-shadow-surface);
557
- flex-direction: column;
558
- min-width: 0;
559
- }
560
-
561
- .altertable-metric-widget.altertable-data-widget {
562
- padding: 0;
563
- }
564
-
565
- .altertable-metric-widget > .altertable-data-widget-header {
566
- min-height: 0;
567
- }
568
-
569
- .altertable-metric-widget > .altertable-data-widget-header h2 {
570
- color: var(--atbl-muted);
571
- font-family: inherit;
572
- font-size: var(--atbl-type-label-size);
573
- font-weight: var(--atbl-type-label-weight);
574
- letter-spacing: normal;
575
- }
576
-
577
- .altertable-metric-widget > .altertable-data-widget-body {
578
- padding-top: 0;
579
- }
580
-
581
- .altertable-metric-widget > .altertable-data-widget-body:has( + footer) {
582
- padding-bottom: 0;
583
- }
584
-
585
- .altertable-metric-widget > .altertable-data-widget-footer {
586
- padding-top: 0;
587
- padding-bottom: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
588
- }
589
-
590
- .altertable-metric-value {
591
- margin: var(--atbl-space-sm) 0 2px;
592
- color: var(--atbl-text);
593
- font-family: var(--atbl-font-heading, var(--atbl-input-font-heading, var(--atbl-font)));
594
- font-size: var(--atbl-type-metric-size);
595
- font-weight: var(--atbl-type-emphasis-weight);
596
- line-height: var(--atbl-type-metric-leading);
597
- letter-spacing: -.04em;
598
- overflow-wrap: anywhere;
599
- font-variant-numeric: tabular-nums;
600
- max-inline-size: 100%;
601
- }
602
-
603
- .altertable-metric-reading {
604
- display: flex;
605
- flex-direction: column;
606
- justify-content: flex-start;
607
- align-items: flex-start;
608
- gap: 4px;
609
- }
610
-
611
- .altertable-metric-trend {
612
- font-size: var(--atbl-type-meta-size);
613
- }
614
-
615
- .altertable-metric-change {
616
- display: inline-flex;
617
- color: var(--atbl-muted);
618
- font-variant-numeric: tabular-nums;
619
- align-items: center;
620
- gap: 3px;
621
- }
622
-
623
- .altertable-metric-change[data-tone="good"] {
624
- color: var(--atbl-positive, var(--atbl-accent));
625
- }
626
-
627
- .altertable-metric-change[data-tone="bad"] {
628
- color: var(--atbl-negative, var(--atbl-danger));
629
- }
630
-
631
- .altertable-metric-description {
632
- color: var(--atbl-muted);
633
- font-size: var(--atbl-type-meta-size);
634
- line-height: 1.45;
635
- }
636
-
637
- .altertable-metric-visual {
638
- margin-top: var(--atbl-space-sm);
639
- min-width: 0;
640
- }
641
-
642
- .altertable-metric-value[data-unavailable] {
643
- opacity: .6;
644
- }
645
-
646
- .altertable-metric-value > .altertable-skeleton {
647
- width: 6ch;
648
- height: 1em;
649
- }
650
- }
651
-
652
- /* src/react/ui/VisualizationWidget.css */
653
- @layer atbl.components {
654
- .altertable-visualization-widget-content {
655
- padding: var(--atbl-space-md) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg))) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
656
- min-width: 0;
657
- }
658
-
659
- :where(.altertable-data-widget-body) > .altertable-visualization-widget-content {
660
- padding: 0;
661
- }
662
- }
663
-
664
- /* src/react/ui/ContentSkeleton.css */
665
- @layer atbl.components {
666
- .altertable-content-skeleton {
667
- display: grid;
668
- padding: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
669
- align-content: start;
670
- gap: 14px;
671
- min-width: 0;
672
- }
673
-
674
- .altertable-content-skeleton-label {
675
- width: 38%;
676
- height: 15px;
677
- }
678
-
679
- .altertable-content-skeleton-value {
680
- width: 56%;
681
- height: 38px;
682
- }
683
-
684
- .altertable-content-skeleton-chart {
685
- width: 100%;
686
- height: 180px;
687
- }
688
-
689
- .altertable-content-skeleton-foot {
690
- width: 70%;
691
- height: 12px;
692
- }
693
-
694
- .altertable-content-skeleton-subtitle {
695
- width: 52%;
696
- height: 12px;
697
- }
698
-
699
- .altertable-content-skeleton-rows {
700
- display: grid;
701
- gap: 18px;
702
- margin-top: 12px;
703
- }
704
-
705
- .altertable-content-skeleton-row {
706
- display: grid;
707
- gap: 8px;
708
- }
709
-
710
- .altertable-content-skeleton-row-label {
711
- width: 56%;
712
- height: 14px;
713
- }
714
-
715
- .altertable-content-skeleton-row-track {
716
- width: 100%;
717
- height: 8px;
718
- }
719
-
720
- .altertable-content-skeleton-row:nth-child(2) .altertable-content-skeleton-row-track {
721
- width: 72%;
722
- }
723
-
724
- .altertable-content-skeleton-row:nth-child(3) .altertable-content-skeleton-row-track {
725
- width: 48%;
726
- }
727
-
728
- .altertable-content-skeleton-row:nth-child(4) .altertable-content-skeleton-row-track {
729
- width: 30%;
730
- }
731
-
732
- .altertable-content-skeleton-body {
733
- display: grid;
734
- gap: 14px;
735
- min-width: 0;
736
- }
737
- }
738
-
739
- /* src/react/shared.css */
740
-
741
-
742
- /* src/react/ui/DataAppSkeleton.css */
743
- @layer atbl.components {
744
- .altertable-data-app-skeleton {
745
- display: flex;
746
- overflow: hidden;
747
- padding: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
748
- background: var(--atbl-background);
749
- flex: 1;
750
- min-width: 0;
751
- min-height: 0;
752
- }
753
-
754
- .altertable-data-app-skeleton-content {
755
- display: flex;
756
- gap: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
757
- max-width: var(--atbl-content-width);
758
- flex-direction: column;
759
- width: 100%;
760
- min-width: 0;
761
- margin-inline-start: auto;
762
- margin-inline-end: auto;
763
- }
764
-
765
- .altertable-data-app-skeleton-body {
766
- display: flex;
767
- gap: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
768
- flex-direction: column;
769
- min-width: 0;
770
- }
771
-
772
- .altertable-data-app-skeleton-header, .altertable-data-app-skeleton-footer {
773
- min-width: 0;
774
- }
775
-
776
- .altertable-data-app-skeleton-widget-title {
777
- width: 144px;
778
- max-width: 100%;
779
- height: 16px;
780
- }
781
-
782
- .altertable-data-app-skeleton-chart {
783
- display: flex;
784
- align-items: flex-end;
785
- gap: var(--atbl-space-sm);
786
- height: 180px;
787
- }
788
-
789
- .altertable-data-app-skeleton-chart > * {
790
- flex: 1;
791
- min-width: 0;
792
- }
793
-
794
- .altertable-data-app-skeleton-rows {
795
- display: grid;
796
- gap: 20px;
797
- }
798
-
799
- .altertable-data-app-skeleton-row {
800
- display: grid;
801
- grid-template-columns: 2fr 1fr 1fr;
802
- gap: var(--atbl-space-md);
803
- }
804
-
805
- .altertable-data-app-skeleton-row > * {
806
- height: 16px;
807
- }
808
- }
809
-
810
- /* src/react/shellStyles.css */
811
- @layer atbl.tokens, atbl.base, atbl.components, atbl.interaction;
812
- `,
813
- options
814
- });
815
- }
93
+ } from "../../chunks/index-rew95tbg.js";
816
94
  // src/react/ui/StaticDataApp.tsx
817
95
  import { jsx } from "react/jsx-runtime";
818
96
  function DataApp(props) {
@@ -955,78 +233,8 @@ function GettingStarted({ dataContext }) {
955
233
  ]
956
234
  });
957
235
  }
958
- // src/react/ui/DataAppSkeleton.tsx
959
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
960
- var chartHeights = [40, 60, 50, 80, 60, 100, 80, 60];
961
- function DataAppSkeleton({
962
- header,
963
- footer,
964
- className,
965
- ...props
966
- }) {
967
- return /* @__PURE__ */ jsx3("output", {
968
- "aria-label": "Loading data app",
969
- ...props,
970
- "aria-busy": "true",
971
- className: classNames("altertable-data-app-skeleton", className),
972
- children: /* @__PURE__ */ jsxs2("div", {
973
- className: "altertable-data-app-skeleton-content",
974
- children: [
975
- header != null && header !== false && /* @__PURE__ */ jsx3("div", {
976
- className: "altertable-data-app-skeleton-header",
977
- children: header
978
- }),
979
- /* @__PURE__ */ jsxs2("div", {
980
- className: "altertable-data-app-skeleton-body",
981
- "aria-hidden": "true",
982
- children: [
983
- /* @__PURE__ */ jsx3(Grid2, {
984
- columns: 3,
985
- gap: "md",
986
- children: [0, 1, 2].map((item) => /* @__PURE__ */ jsx3(MetricWidget2, {
987
- label: "",
988
- loading: true
989
- }, item))
990
- }),
991
- /* @__PURE__ */ jsx3(VisualizationWidget2, {
992
- title: /* @__PURE__ */ jsx3(Skeleton2, {
993
- className: "altertable-data-app-skeleton-widget-title"
994
- }),
995
- visual: /* @__PURE__ */ jsx3("div", {
996
- className: "altertable-data-app-skeleton-chart",
997
- children: chartHeights.map((height, index) => /* @__PURE__ */ jsx3(Skeleton2, {
998
- style: { height: `${height}%` }
999
- }, index))
1000
- })
1001
- }),
1002
- /* @__PURE__ */ jsx3(DataWidget2, {
1003
- title: /* @__PURE__ */ jsx3(Skeleton2, {
1004
- className: "altertable-data-app-skeleton-widget-title"
1005
- }),
1006
- children: /* @__PURE__ */ jsx3("div", {
1007
- className: "altertable-data-app-skeleton-rows",
1008
- children: [0, 1, 2].map((row) => /* @__PURE__ */ jsxs2("div", {
1009
- className: "altertable-data-app-skeleton-row",
1010
- children: [
1011
- /* @__PURE__ */ jsx3(Skeleton2, {}),
1012
- /* @__PURE__ */ jsx3(Skeleton2, {}),
1013
- /* @__PURE__ */ jsx3(Skeleton2, {})
1014
- ]
1015
- }, row))
1016
- })
1017
- })
1018
- ]
1019
- }),
1020
- footer != null && footer !== false && /* @__PURE__ */ jsx3("div", {
1021
- className: "altertable-data-app-skeleton-footer",
1022
- children: footer
1023
- })
1024
- ]
1025
- })
1026
- });
1027
- }
1028
236
  // src/react/ui/GlossaryExplanation.tsx
1029
- import { jsx as jsx4 } from "react/jsx-runtime";
237
+ import { jsx as jsx3 } from "react/jsx-runtime";
1030
238
  function GlossaryExplanation({
1031
239
  entry,
1032
240
  empty,
@@ -1038,7 +246,7 @@ function GlossaryExplanation({
1038
246
  className,
1039
247
  ...props
1040
248
  }) {
1041
- return /* @__PURE__ */ jsx4(AboutData2, {
249
+ return /* @__PURE__ */ jsx3(AboutData2, {
1042
250
  ...props,
1043
251
  shortcut: false,
1044
252
  iconOnly: true,
@@ -1053,18 +261,18 @@ function GlossaryExplanation({
1053
261
  className: className ?? "altertable-inspect-trigger",
1054
262
  tooltip: "Explore this term",
1055
263
  "aria-label": props["aria-label"] ?? `Explore ${entry.term}`,
1056
- children: /* @__PURE__ */ jsx4(AppIcon2, {
264
+ children: /* @__PURE__ */ jsx3(AppIcon2, {
1057
265
  name: "openDetails"
1058
266
  })
1059
267
  });
1060
268
  }
1061
269
  // src/react/ui/GlossaryDefinition.tsx
1062
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
270
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
1063
271
  function GlossaryDefinition({
1064
272
  entry,
1065
273
  children
1066
274
  }) {
1067
- return /* @__PURE__ */ jsxs3(HelpPopover2, {
275
+ return /* @__PURE__ */ jsxs2(HelpPopover2, {
1068
276
  trigger: children ?? entry.term,
1069
277
  triggerLabel: `Explain ${entry.term}`,
1070
278
  label: entry.term,
@@ -1074,23 +282,721 @@ function GlossaryDefinition({
1074
282
  },
1075
283
  panelProps: { className: "altertable-glossary-definition-popover" },
1076
284
  children: [
1077
- /* @__PURE__ */ jsx5("strong", {
285
+ /* @__PURE__ */ jsx4("strong", {
1078
286
  children: entry.term
1079
287
  }),
1080
- /* @__PURE__ */ jsx5("div", {
288
+ /* @__PURE__ */ jsx4("div", {
1081
289
  children: entry.definition
1082
290
  })
1083
291
  ]
1084
292
  });
1085
293
  }
294
+ // src/react/ui/use-chart-scroll-to-end.ts
295
+ import { useLayoutEffect, useRef } from "react";
296
+ function useChartScrollToEnd(items) {
297
+ const scrollport = useRef(null);
298
+ useLayoutEffect(() => {
299
+ const element = scrollport.current;
300
+ if (element)
301
+ element.scrollLeft = element.scrollWidth - element.clientWidth;
302
+ }, [items]);
303
+ return scrollport;
304
+ }
305
+
1086
306
  // src/react/ui/TrendChart.tsx
1087
- import { useLayoutEffect, useRef, useState as useState2 } from "react";
307
+ import {
308
+ Fragment as Fragment2,
309
+ useRef as useRef3,
310
+ useState as useState3
311
+ } from "react";
1088
312
  import {
1089
313
  AreaChart as RechartsAreaChart,
1090
314
  LineChart as RechartsLineChart,
1091
315
  ReferenceLine
1092
316
  } from "recharts";
1093
317
 
318
+ // src/react/ui/chart-date-axis.tsx
319
+ import {
320
+ createContext,
321
+ useCallback,
322
+ useContext,
323
+ useEffect,
324
+ useMemo,
325
+ useState
326
+ } from "react";
327
+ import { XAxis, usePlotArea } from "recharts";
328
+
329
+ // src/core/time-interval.ts
330
+ /*!
331
+ * TypeScript port of d3-time 3.1.0 (ISC), https://github.com/d3/d3-time/tree/v3.1.0
332
+ * Numeric tick-step helpers adapted from d3-array 3.2.4 (ISC).
333
+ *
334
+ * Copyright 2010-2022 Mike Bostock (d3-time)
335
+ * Copyright 2010-2023 Mike Bostock (d3-array tick-step helpers)
336
+ *
337
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
338
+ * with or without fee is hereby granted, provided that the above copyright notice
339
+ * and this permission notice appear in all copies.
340
+ *
341
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
342
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
343
+ * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
344
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
345
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
346
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
347
+ * THIS SOFTWARE.
348
+ */
349
+ function timeInterval(floor, offset, count, field) {
350
+ function interval(value) {
351
+ const date = arguments.length === 0 ? new Date : new Date(+value);
352
+ floor(date);
353
+ return date;
354
+ }
355
+ interval.floor = (value) => {
356
+ const date = new Date(+value);
357
+ floor(date);
358
+ return date;
359
+ };
360
+ interval.ceil = (value) => {
361
+ const date = new Date(+value - 1);
362
+ floor(date);
363
+ offset(date, 1);
364
+ floor(date);
365
+ return date;
366
+ };
367
+ interval.round = (value) => {
368
+ const before = interval(value);
369
+ const after = interval.ceil(value);
370
+ return +value - +before < +after - +value ? before : after;
371
+ };
372
+ interval.offset = (value, step) => {
373
+ const date = new Date(+value);
374
+ offset(date, step == null ? 1 : Math.floor(step));
375
+ return date;
376
+ };
377
+ interval.range = (start, stop, step) => {
378
+ const range = [];
379
+ const date = interval.ceil(start);
380
+ const stride = step == null ? 1 : Math.floor(step);
381
+ if (!(+date < +stop) || !(stride > 0))
382
+ return range;
383
+ let previous;
384
+ do {
385
+ previous = new Date(+date);
386
+ range.push(previous);
387
+ offset(date, stride);
388
+ floor(date);
389
+ } while (+previous < +date && +date < +stop);
390
+ return range;
391
+ };
392
+ interval.filter = (test) => timeInterval((date) => {
393
+ if (!Number.isNaN(+date)) {
394
+ floor(date);
395
+ while (!test(date)) {
396
+ date.setTime(+date - 1);
397
+ floor(date);
398
+ }
399
+ }
400
+ }, (date, step) => {
401
+ if (!Number.isNaN(+date)) {
402
+ const direction = step < 0 ? -1 : 1;
403
+ for (let remaining = Math.abs(step);remaining > 0; --remaining) {
404
+ do {
405
+ offset(date, direction);
406
+ } while (!test(date));
407
+ }
408
+ }
409
+ });
410
+ if (count) {
411
+ interval.count = (start, end) => {
412
+ countStart.setTime(+start);
413
+ countEnd.setTime(+end);
414
+ floor(countStart);
415
+ floor(countEnd);
416
+ return Math.floor(count(countStart, countEnd));
417
+ };
418
+ interval.every = (step) => {
419
+ step = Math.floor(step);
420
+ if (!Number.isFinite(step) || !(step > 0))
421
+ return null;
422
+ if (step === 1)
423
+ return interval;
424
+ return interval.filter(field ? (date) => field(date) % step === 0 : (date) => interval.count(0, date) % step === 0);
425
+ };
426
+ }
427
+ return interval;
428
+ }
429
+ var countStart = new Date;
430
+ var countEnd = new Date;
431
+ var durationSecond = 1000;
432
+ var durationMinute = durationSecond * 60;
433
+ var durationHour = durationMinute * 60;
434
+ var durationDay = durationHour * 24;
435
+ var durationWeek = durationDay * 7;
436
+ var durationMonth = durationDay * 30;
437
+ var durationYear = durationDay * 365;
438
+ var millisecond = timeInterval(() => {}, (date, step) => {
439
+ date.setTime(+date + step);
440
+ }, (start, end) => {
441
+ return +end - +start;
442
+ });
443
+ millisecond.every = (k) => {
444
+ k = Math.floor(k);
445
+ if (!isFinite(k) || !(k > 0))
446
+ return null;
447
+ if (!(k > 1))
448
+ return millisecond;
449
+ return timeInterval((date) => {
450
+ date.setTime(Math.floor(+date / k) * k);
451
+ }, (date, step) => {
452
+ date.setTime(+date + step * k);
453
+ }, (start, end) => {
454
+ return (+end - +start) / k;
455
+ });
456
+ };
457
+ var milliseconds = millisecond.range;
458
+ var second = timeInterval((date) => {
459
+ date.setTime(+date - date.getMilliseconds());
460
+ }, (date, step) => {
461
+ date.setTime(+date + step * durationSecond);
462
+ }, (start, end) => {
463
+ return (+end - +start) / durationSecond;
464
+ }, (date) => {
465
+ return date.getUTCSeconds();
466
+ });
467
+ var seconds = second.range;
468
+ var timeMinute = timeInterval((date) => {
469
+ date.setTime(+date - date.getMilliseconds() - date.getSeconds() * durationSecond);
470
+ }, (date, step) => {
471
+ date.setTime(+date + step * durationMinute);
472
+ }, (start, end) => {
473
+ return (+end - +start) / durationMinute;
474
+ }, (date) => {
475
+ return date.getMinutes();
476
+ });
477
+ var timeMinutes = timeMinute.range;
478
+ var utcMinute = timeInterval((date) => {
479
+ date.setUTCSeconds(0, 0);
480
+ }, (date, step) => {
481
+ date.setTime(+date + step * durationMinute);
482
+ }, (start, end) => {
483
+ return (+end - +start) / durationMinute;
484
+ }, (date) => {
485
+ return date.getUTCMinutes();
486
+ });
487
+ var utcMinutes = utcMinute.range;
488
+ var timeHour = timeInterval((date) => {
489
+ date.setTime(+date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute);
490
+ }, (date, step) => {
491
+ date.setTime(+date + step * durationHour);
492
+ }, (start, end) => {
493
+ return (+end - +start) / durationHour;
494
+ }, (date) => {
495
+ return date.getHours();
496
+ });
497
+ var timeHours = timeHour.range;
498
+ var utcHour = timeInterval((date) => {
499
+ date.setUTCMinutes(0, 0, 0);
500
+ }, (date, step) => {
501
+ date.setTime(+date + step * durationHour);
502
+ }, (start, end) => {
503
+ return (+end - +start) / durationHour;
504
+ }, (date) => {
505
+ return date.getUTCHours();
506
+ });
507
+ var utcHours = utcHour.range;
508
+ var timeDay = timeInterval((date) => date.setHours(0, 0, 0, 0), (date, step) => date.setDate(date.getDate() + step), (start, end) => (+end - +start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay, (date) => date.getDate() - 1);
509
+ var timeDays = timeDay.range;
510
+ var utcDay = timeInterval((date) => {
511
+ date.setUTCHours(0, 0, 0, 0);
512
+ }, (date, step) => {
513
+ date.setUTCDate(date.getUTCDate() + step);
514
+ }, (start, end) => {
515
+ return (+end - +start) / durationDay;
516
+ }, (date) => {
517
+ return date.getUTCDate() - 1;
518
+ });
519
+ var utcDays = utcDay.range;
520
+ var unixDay = timeInterval((date) => {
521
+ date.setUTCHours(0, 0, 0, 0);
522
+ }, (date, step) => {
523
+ date.setUTCDate(date.getUTCDate() + step);
524
+ }, (start, end) => {
525
+ return (+end - +start) / durationDay;
526
+ }, (date) => {
527
+ return Math.floor(+date / durationDay);
528
+ });
529
+ var unixDays = unixDay.range;
530
+ function timeWeekday(i) {
531
+ return timeInterval((date) => {
532
+ date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7);
533
+ date.setHours(0, 0, 0, 0);
534
+ }, (date, step) => {
535
+ date.setDate(date.getDate() + step * 7);
536
+ }, (start, end) => {
537
+ return (+end - +start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek;
538
+ });
539
+ }
540
+ var timeSunday = timeWeekday(0);
541
+ var timeMonday = timeWeekday(1);
542
+ var timeTuesday = timeWeekday(2);
543
+ var timeWednesday = timeWeekday(3);
544
+ var timeThursday = timeWeekday(4);
545
+ var timeFriday = timeWeekday(5);
546
+ var timeSaturday = timeWeekday(6);
547
+ var timeSundays = timeSunday.range;
548
+ var timeMondays = timeMonday.range;
549
+ var timeTuesdays = timeTuesday.range;
550
+ var timeWednesdays = timeWednesday.range;
551
+ var timeThursdays = timeThursday.range;
552
+ var timeFridays = timeFriday.range;
553
+ var timeSaturdays = timeSaturday.range;
554
+ function utcWeekday(i) {
555
+ return timeInterval((date) => {
556
+ date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7);
557
+ date.setUTCHours(0, 0, 0, 0);
558
+ }, (date, step) => {
559
+ date.setUTCDate(date.getUTCDate() + step * 7);
560
+ }, (start, end) => {
561
+ return (+end - +start) / durationWeek;
562
+ });
563
+ }
564
+ var utcSunday = utcWeekday(0);
565
+ var utcMonday = utcWeekday(1);
566
+ var utcTuesday = utcWeekday(2);
567
+ var utcWednesday = utcWeekday(3);
568
+ var utcThursday = utcWeekday(4);
569
+ var utcFriday = utcWeekday(5);
570
+ var utcSaturday = utcWeekday(6);
571
+ var utcSundays = utcSunday.range;
572
+ var utcMondays = utcMonday.range;
573
+ var utcTuesdays = utcTuesday.range;
574
+ var utcWednesdays = utcWednesday.range;
575
+ var utcThursdays = utcThursday.range;
576
+ var utcFridays = utcFriday.range;
577
+ var utcSaturdays = utcSaturday.range;
578
+ var timeMonth = timeInterval((date) => {
579
+ date.setDate(1);
580
+ date.setHours(0, 0, 0, 0);
581
+ }, (date, step) => {
582
+ date.setMonth(date.getMonth() + step);
583
+ }, (start, end) => {
584
+ return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12;
585
+ }, (date) => {
586
+ return date.getMonth();
587
+ });
588
+ var timeMonths = timeMonth.range;
589
+ var utcMonth = timeInterval((date) => {
590
+ date.setUTCDate(1);
591
+ date.setUTCHours(0, 0, 0, 0);
592
+ }, (date, step) => {
593
+ date.setUTCMonth(date.getUTCMonth() + step);
594
+ }, (start, end) => {
595
+ return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12;
596
+ }, (date) => {
597
+ return date.getUTCMonth();
598
+ });
599
+ var utcMonths = utcMonth.range;
600
+ var timeYear = timeInterval((date) => {
601
+ date.setMonth(0, 1);
602
+ date.setHours(0, 0, 0, 0);
603
+ }, (date, step) => {
604
+ date.setFullYear(date.getFullYear() + step);
605
+ }, (start, end) => {
606
+ return end.getFullYear() - start.getFullYear();
607
+ }, (date) => {
608
+ return date.getFullYear();
609
+ });
610
+ timeYear.every = (k) => {
611
+ return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => {
612
+ date.setFullYear(Math.floor(date.getFullYear() / k) * k);
613
+ date.setMonth(0, 1);
614
+ date.setHours(0, 0, 0, 0);
615
+ }, (date, step) => {
616
+ date.setFullYear(date.getFullYear() + step * k);
617
+ });
618
+ };
619
+ var timeYears = timeYear.range;
620
+ var utcYear = timeInterval((date) => {
621
+ date.setUTCMonth(0, 1);
622
+ date.setUTCHours(0, 0, 0, 0);
623
+ }, (date, step) => {
624
+ date.setUTCFullYear(date.getUTCFullYear() + step);
625
+ }, (start, end) => {
626
+ return end.getUTCFullYear() - start.getUTCFullYear();
627
+ }, (date) => {
628
+ return date.getUTCFullYear();
629
+ });
630
+ utcYear.every = (k) => {
631
+ return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => {
632
+ date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k);
633
+ date.setUTCMonth(0, 1);
634
+ date.setUTCHours(0, 0, 0, 0);
635
+ }, (date, step) => {
636
+ date.setUTCFullYear(date.getUTCFullYear() + step * k);
637
+ });
638
+ };
639
+ var utcYears = utcYear.range;
640
+ var e10 = Math.sqrt(50);
641
+ var e5 = Math.sqrt(10);
642
+ var e2 = Math.sqrt(2);
643
+ function tickSpec(start, stop, count) {
644
+ const step = (stop - start) / Math.max(0, count), power = Math.floor(Math.log10(step)), error = step / Math.pow(10, power), factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1;
645
+ let i1, i2, inc;
646
+ if (power < 0) {
647
+ inc = Math.pow(10, -power) / factor;
648
+ i1 = Math.round(start * inc);
649
+ i2 = Math.round(stop * inc);
650
+ if (i1 / inc < start)
651
+ ++i1;
652
+ if (i2 / inc > stop)
653
+ --i2;
654
+ inc = -inc;
655
+ } else {
656
+ inc = Math.pow(10, power) * factor;
657
+ i1 = Math.round(start / inc);
658
+ i2 = Math.round(stop / inc);
659
+ if (i1 * inc < start)
660
+ ++i1;
661
+ if (i2 * inc > stop)
662
+ --i2;
663
+ }
664
+ if (i2 < i1 && 0.5 <= count && count < 2)
665
+ return tickSpec(start, stop, count * 2);
666
+ return [i1, i2, inc];
667
+ }
668
+ function tickIncrement(start, stop, count) {
669
+ return tickSpec(start, stop, count)[2];
670
+ }
671
+ function tickStep(start, stop, count) {
672
+ const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count);
673
+ return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc);
674
+ }
675
+ function ticker(year, month, week, day, hour, minute) {
676
+ const tickIntervals = [
677
+ [second, 1, durationSecond],
678
+ [second, 5, 5 * durationSecond],
679
+ [second, 15, 15 * durationSecond],
680
+ [second, 30, 30 * durationSecond],
681
+ [minute, 1, durationMinute],
682
+ [minute, 5, 5 * durationMinute],
683
+ [minute, 15, 15 * durationMinute],
684
+ [minute, 30, 30 * durationMinute],
685
+ [hour, 1, durationHour],
686
+ [hour, 3, 3 * durationHour],
687
+ [hour, 6, 6 * durationHour],
688
+ [hour, 12, 12 * durationHour],
689
+ [day, 1, durationDay],
690
+ [day, 2, 2 * durationDay],
691
+ [week, 1, durationWeek],
692
+ [month, 1, durationMonth],
693
+ [month, 3, 3 * durationMonth],
694
+ [year, 1, durationYear]
695
+ ];
696
+ function ticks(start, stop, count) {
697
+ const reverse = +stop < +start;
698
+ if (reverse)
699
+ [start, stop] = [stop, start];
700
+ const interval = typeof count !== "number" ? count : tickInterval(start, stop, count);
701
+ const ticks = interval ? interval.range(start, +stop + 1) : [];
702
+ return reverse ? ticks.reverse() : ticks;
703
+ }
704
+ function tickInterval(start, stop, count) {
705
+ const target = Math.abs(+stop - +start) / count;
706
+ let low = 0;
707
+ let high = tickIntervals.length;
708
+ if (Number.isNaN(target))
709
+ low = high;
710
+ while (low < high) {
711
+ const middle = low + high >>> 1;
712
+ if (tickIntervals[middle][2] <= target)
713
+ low = middle + 1;
714
+ else
715
+ high = middle;
716
+ }
717
+ const i = low;
718
+ if (i === tickIntervals.length)
719
+ return year.every(tickStep(+start / durationYear, +stop / durationYear, count));
720
+ if (i === 0)
721
+ return millisecond.every(Math.max(tickStep(+start, +stop, count), 1));
722
+ const previous = tickIntervals[i - 1];
723
+ const next = tickIntervals[i];
724
+ const [t, step] = target / previous[2] < next[2] / target ? previous : next;
725
+ return t.every(step);
726
+ }
727
+ return [ticks, tickInterval];
728
+ }
729
+ var [utcTicks, utcTickInterval] = ticker(utcYear, utcMonth, utcSunday, unixDay, utcHour, utcMinute);
730
+ var [timeTicks, timeTickInterval] = ticker(timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute);
731
+
732
+ // src/react/ui/chart-time.ts
733
+ var day = 86400000;
734
+ var calendarDatePattern = /^\d{4}-\d{2}-\d{2}$/;
735
+ function isCalendarDate(value) {
736
+ return typeof value === "string" && calendarDatePattern.test(value);
737
+ }
738
+ function chartTimestamp(value, numeric = false) {
739
+ if (isCalendarDate(value)) {
740
+ return parseDateTime2(`${value}T00:00:00Z`)?.getTime() ?? null;
741
+ }
742
+ if (value instanceof Date || typeof value === "string" || numeric && typeof value === "number") {
743
+ return parseDateTime2(value)?.getTime() ?? null;
744
+ }
745
+ return null;
746
+ }
747
+ function timeModel(values, numeric = false) {
748
+ const timestamps = new Set;
749
+ for (const value of values) {
750
+ const timestamp = chartTimestamp(value, numeric);
751
+ if (timestamp == null)
752
+ return null;
753
+ timestamps.add(timestamp);
754
+ }
755
+ const times = [...timestamps].sort((a, b) => a - b);
756
+ const start = times[0];
757
+ const end = times.at(-1);
758
+ if (start == null || end == null)
759
+ return null;
760
+ let minimumInterval = Infinity;
761
+ for (let index = 1;index < times.length; index++) {
762
+ minimumInterval = Math.min(minimumInterval, times[index] - times[index - 1]);
763
+ }
764
+ if (times.length === 1)
765
+ minimumInterval = day;
766
+ const dateOnly = values.every(isCalendarDate);
767
+ const seconds = times.some((value) => value % 60000 !== 0) || minimumInterval < 60000;
768
+ const milliseconds = times.some((value) => value % 1000 !== 0) || minimumInterval < 1000;
769
+ function tooltip(value) {
770
+ const time = chartTimestamp(value, true);
771
+ if (time == null)
772
+ return typeof value === "string" || typeof value === "number" ? String(value) : "";
773
+ if (dateOnly)
774
+ return formatDate2(new Date(time).toISOString().slice(0, 10));
775
+ if (milliseconds) {
776
+ return new Intl.DateTimeFormat("en-US", {
777
+ timeZone: "UTC",
778
+ year: "numeric",
779
+ month: "short",
780
+ day: "numeric",
781
+ hour: "2-digit",
782
+ minute: "2-digit",
783
+ second: "2-digit",
784
+ fractionalSecondDigits: 3,
785
+ hourCycle: "h23"
786
+ }).format(time);
787
+ }
788
+ return formatDateTime2(time, {
789
+ precision: seconds ? "second" : "minute",
790
+ timeZone: "UTC"
791
+ });
792
+ }
793
+ return {
794
+ start,
795
+ end,
796
+ times,
797
+ minimumInterval,
798
+ tooltip
799
+ };
800
+ }
801
+ function datePart(value, options) {
802
+ return new Intl.DateTimeFormat("en-US", {
803
+ ...options,
804
+ timeZone: "UTC"
805
+ }).format(value);
806
+ }
807
+ function timeTicks2(model, width) {
808
+ const { start, end } = model;
809
+ const firstDate = new Date(start);
810
+ const lastDate = new Date(end);
811
+ const spansYears = firstDate.getUTCFullYear() !== lastDate.getUTCFullYear();
812
+ const spansDates = firstDate.toISOString().slice(0, 10) !== lastDate.toISOString().slice(0, 10);
813
+ const count = Math.max(2, Math.min(12, Math.floor(width / 80), model.times.length));
814
+ let ticks = start === end ? [start] : utcTicks(new Date(start), new Date(end), Math.min(count, (end - start) / model.minimumInterval)).map(Number);
815
+ const step = ticks.length > 1 ? ticks[1] - ticks[0] : Math.max(end - start, model.minimumInterval);
816
+ const candidates = [...new Set([start, ...ticks, end])].sort((a, b) => a - b);
817
+ ticks = [start];
818
+ const gap = step < 1000 ? 110 : 80;
819
+ for (const value of candidates.slice(1)) {
820
+ if ((value - ticks.at(-1)) / (end - start) * width >= gap)
821
+ ticks.push(value);
822
+ }
823
+ if (end !== start && ticks.at(-1) !== end) {
824
+ if (ticks.length > 1 && (end - ticks.at(-1)) / (end - start) * width < gap)
825
+ ticks.pop();
826
+ ticks.push(end);
827
+ }
828
+ function label(value, index) {
829
+ const previous = index > 0 ? new Date(ticks[index - 1]) : undefined;
830
+ const date = new Date(value);
831
+ const yearChanged = !previous || previous.getUTCFullYear() !== date.getUTCFullYear();
832
+ const dateChanged = !previous || previous.toISOString().slice(0, 10) !== date.toISOString().slice(0, 10);
833
+ if (step >= 300 * day)
834
+ return { main: String(date.getUTCFullYear()), context: "" };
835
+ if (step >= 28 * day && (model.minimumInterval >= 28 * day || end - start >= 180 * day))
836
+ return {
837
+ main: datePart(value, { month: "short" }),
838
+ context: spansYears && yearChanged ? String(date.getUTCFullYear()) : ""
839
+ };
840
+ if (step >= day && !(model.minimumInterval < day && end - start <= 3 * day))
841
+ return {
842
+ main: datePart(value, { month: "short", day: "numeric" }),
843
+ context: spansYears && yearChanged ? String(date.getUTCFullYear()) : ""
844
+ };
845
+ return {
846
+ main: datePart(value, {
847
+ hour: "2-digit",
848
+ minute: "2-digit",
849
+ ...step < 60000 ? { second: "2-digit" } : {},
850
+ ...step < 1000 ? { fractionalSecondDigits: 3 } : {},
851
+ hourCycle: "h23"
852
+ }),
853
+ context: spansDates && dateChanged ? datePart(value, {
854
+ month: "short",
855
+ day: "numeric",
856
+ ...spansYears && yearChanged ? { year: "numeric" } : {}
857
+ }) : ""
858
+ };
859
+ }
860
+ return { ticks, label };
861
+ }
862
+
863
+ // src/react/ui/chart-date-axis.tsx
864
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
865
+ var ChartDateAxesContext = createContext(null);
866
+ function ChartDateAxes({
867
+ data,
868
+ children
869
+ }) {
870
+ const [formatters, setFormatters] = useState(() => new Map);
871
+ const register = useCallback((id, formatter) => {
872
+ setFormatters((current) => new Map(current).set(id, formatter));
873
+ return () => setFormatters((current) => {
874
+ const next = new Map(current);
875
+ next.delete(id);
876
+ return next;
877
+ });
878
+ }, []);
879
+ return /* @__PURE__ */ jsx5(ChartDateAxesContext.Provider, {
880
+ value: { data, formatters, register },
881
+ children
882
+ });
883
+ }
884
+ function useDateAxisLabel(id = 0) {
885
+ return useContext(ChartDateAxesContext)?.formatters.get(id);
886
+ }
887
+ function field(row, key) {
888
+ if (row == null || typeof row !== "object")
889
+ return;
890
+ if (key in row)
891
+ return row[key];
892
+ return String(key).replace(/\[(\d+)\]/g, ".$1").split(".").reduce((value, part) => value != null && typeof value === "object" ? value[part] : undefined, row);
893
+ }
894
+ var xAxisDefaults = {
895
+ stroke: "var(--atbl-muted)",
896
+ tickFormatter: (value) => typeof value === "number" ? formatNumber2(value) : String(value),
897
+ tickLine: false,
898
+ axisLine: { stroke: "var(--atbl-border)" },
899
+ tick: { fontSize: "var(--atbl-type-meta-size)" }
900
+ };
901
+ function ChartXAxis(props) {
902
+ const context = useContext(ChartDateAxesContext);
903
+ const plot = usePlotArea();
904
+ const data = context?.data;
905
+ const { dataKey, ...axisProps } = props;
906
+ const numeric = props.scale === "utc";
907
+ const enabled = numeric || props.type == null && props.scale == null && props.tickFormatter == null && props.ticks == null;
908
+ const model = useMemo(() => {
909
+ if (!enabled || !data?.length || dataKey == null)
910
+ return null;
911
+ return timeModel(data.map((row) => typeof dataKey === "function" ? dataKey(row) : field(row, dataKey)), numeric);
912
+ }, [data, dataKey, enabled, numeric]);
913
+ const register = context?.register;
914
+ const id = props.xAxisId ?? 0;
915
+ useEffect(() => model ? register?.(id, model.tooltip) : undefined, [register, id, model]);
916
+ if (!model || dataKey == null) {
917
+ return /* @__PURE__ */ jsx5(XAxis, {
918
+ ...xAxisDefaults,
919
+ ...props
920
+ });
921
+ }
922
+ const automaticTicks = props.ticks == null && props.tickFormatter == null ? timeTicks2(model, plot?.width ?? 400) : null;
923
+ return /* @__PURE__ */ jsx5(XAxis, {
924
+ ...xAxisDefaults,
925
+ scale: "utc",
926
+ domain: model.start === model.end ? [
927
+ model.start - model.minimumInterval / 2,
928
+ model.end + model.minimumInterval / 2
929
+ ] : [model.start, model.end],
930
+ ticks: automaticTicks?.ticks,
931
+ interval: automaticTicks ? 0 : undefined,
932
+ height: 48,
933
+ tickFormatter: model.tooltip,
934
+ tick: automaticTicks ? ({ x, y, payload, index }) => {
935
+ const label = automaticTicks.label(Number(payload.value), index);
936
+ return /* @__PURE__ */ jsxs3("text", {
937
+ x,
938
+ y: Number(y) + 5,
939
+ fill: "var(--atbl-muted)",
940
+ fontSize: "var(--atbl-type-meta-size)",
941
+ textAnchor: index === 0 ? "start" : index === automaticTicks.ticks.length - 1 ? "end" : "middle",
942
+ children: [
943
+ /* @__PURE__ */ jsx5("tspan", {
944
+ x,
945
+ dy: "0.8em",
946
+ children: label.main
947
+ }),
948
+ label.context && /* @__PURE__ */ jsx5("tspan", {
949
+ x,
950
+ dy: "1.4em",
951
+ children: label.context
952
+ })
953
+ ]
954
+ });
955
+ } : xAxisDefaults.tick,
956
+ ...axisProps,
957
+ type: "number",
958
+ dataKey: (row) => chartTimestamp(typeof dataKey === "function" ? dataKey(row) : field(row, dataKey), numeric)
959
+ });
960
+ }
961
+
962
+ // src/react/ui/chart-primitives.tsx
963
+ import { useContext as useContext3, useLayoutEffect as useLayoutEffect2 } from "react";
964
+
965
+ // src/react/ui/chart-interaction.tsx
966
+ import {
967
+ createContext as createContext2,
968
+ useContext as useContext2,
969
+ useId,
970
+ useEffect as useEffect2
971
+ } from "react";
972
+ import { jsx as jsx6 } from "react/jsx-runtime";
973
+ var ChartInteractionContext = createContext2(null);
974
+ function isChartSeriesActive(interaction, seriesId) {
975
+ return !interaction?.isPointerInspection || interaction.seriesCount === 1 || interaction.activeSeriesId === seriesId;
976
+ }
977
+ function useChartSeries(id) {
978
+ const generatedId = useId();
979
+ const interaction = useContext2(ChartInteractionContext);
980
+ const seriesId = id ?? generatedId;
981
+ const registerSeries = interaction?.registerSeries;
982
+ useEffect2(() => registerSeries?.(seriesId), [registerSeries, seriesId]);
983
+ return {
984
+ id: seriesId,
985
+ active: isChartSeriesActive(interaction, seriesId)
986
+ };
987
+ }
988
+ function ChartSeries({
989
+ id,
990
+ children
991
+ }) {
992
+ const interaction = useContext2(ChartInteractionContext);
993
+ return /* @__PURE__ */ jsx6("g", {
994
+ onPointerOver: () => interaction?.setHoveredSeriesId(id),
995
+ onPointerDown: () => interaction?.setHoveredSeriesId(id),
996
+ children
997
+ });
998
+ }
999
+
1094
1000
  // src/react/ui/chart-primitives.tsx
1095
1001
  import {
1096
1002
  Area,
@@ -1098,7 +1004,6 @@ import {
1098
1004
  Bar,
1099
1005
  Line,
1100
1006
  Scatter,
1101
- XAxis,
1102
1007
  YAxis,
1103
1008
  CartesianGrid,
1104
1009
  Tooltip,
@@ -1108,26 +1013,49 @@ import {
1108
1013
  // src/react/ui/ChartLegend.tsx
1109
1014
  import {
1110
1015
  Children,
1111
- useId,
1112
- useState
1016
+ useId as useId2,
1017
+ useEffect as useEffect3,
1018
+ useRef as useRef2,
1019
+ useState as useState2
1113
1020
  } from "react";
1114
- import { jsx as jsx6, jsxs as jsxs4, Fragment } from "react/jsx-runtime";
1021
+ import { jsx as jsx7, jsxs as jsxs4, Fragment } from "react/jsx-runtime";
1115
1022
  function ChartLegendRoot({
1116
1023
  children,
1117
1024
  layout = "horizontal",
1118
1025
  align = "start",
1119
- maxVisibleItems = 6,
1026
+ maxVisibleItems,
1120
1027
  className,
1121
1028
  "aria-label": ariaLabel = "Chart legend",
1122
1029
  ...props
1123
1030
  }) {
1124
- const [expanded, setExpanded] = useState(false);
1125
- const listId = useId();
1031
+ const [expanded, setExpanded] = useState2(false);
1032
+ const listId = useId2();
1033
+ const containerRef = useRef2(null);
1034
+ const [columns, setColumns] = useState2(2);
1035
+ useEffect3(() => {
1036
+ const container = containerRef.current;
1037
+ if (!container)
1038
+ return;
1039
+ function measure() {
1040
+ const list = containerRef.current?.firstElementChild;
1041
+ if (list) {
1042
+ setColumns(getComputedStyle(list).gridTemplateColumns.split(" ").length);
1043
+ }
1044
+ }
1045
+ const observer = new ResizeObserver(measure);
1046
+ observer.observe(container);
1047
+ measure();
1048
+ return () => observer.disconnect();
1049
+ }, [layout]);
1126
1050
  const items = Children.toArray(children);
1127
- const limit = Number.isFinite(maxVisibleItems) ? Math.max(1, Math.floor(maxVisibleItems)) : 6;
1051
+ const rowCapacity = layout === "vertical" ? 6 : columns * (layout === "single-row" ? 1 : 2);
1052
+ const configuredLimit = typeof maxVisibleItems === "number" && Number.isFinite(maxVisibleItems) ? Math.max(1, Math.floor(maxVisibleItems)) : rowCapacity;
1053
+ const cappedLimit = Math.min(configuredLimit, rowCapacity);
1054
+ const limit = layout === "vertical" ? configuredLimit : cappedLimit >= columns ? Math.floor(cappedLimit / columns) * columns : cappedLimit;
1128
1055
  const visibleCount = items.length > limit ? limit - 1 : limit;
1129
1056
  const hiddenCount = Math.max(0, items.length - visibleCount);
1130
- return /* @__PURE__ */ jsx6("div", {
1057
+ return /* @__PURE__ */ jsx7("div", {
1058
+ ref: containerRef,
1131
1059
  className: "altertable-chart-legend-container",
1132
1060
  children: /* @__PURE__ */ jsxs4("ul", {
1133
1061
  id: listId,
@@ -1138,9 +1066,9 @@ function ChartLegendRoot({
1138
1066
  className: classNames("altertable-chart-legend", className),
1139
1067
  children: [
1140
1068
  expanded ? items : items.slice(0, visibleCount),
1141
- hiddenCount > 0 && /* @__PURE__ */ jsx6("li", {
1069
+ hiddenCount > 0 && /* @__PURE__ */ jsx7("li", {
1142
1070
  className: "altertable-chart-legend-overflow",
1143
- children: /* @__PURE__ */ jsx6("button", {
1071
+ children: /* @__PURE__ */ jsx7("button", {
1144
1072
  type: "button",
1145
1073
  "data-atbl-control": "action",
1146
1074
  "data-atbl-focus": "ring",
@@ -1160,7 +1088,7 @@ function ChartLegendItem({
1160
1088
  className,
1161
1089
  ...props
1162
1090
  }) {
1163
- return /* @__PURE__ */ jsx6("li", {
1091
+ return /* @__PURE__ */ jsx7("li", {
1164
1092
  ...props,
1165
1093
  "data-inactive": inactive || undefined,
1166
1094
  className: classNames("altertable-chart-legend-item", className)
@@ -1168,7 +1096,7 @@ function ChartLegendItem({
1168
1096
  }
1169
1097
  function ChartLegendMarker({
1170
1098
  kind,
1171
- color = kind === "bar" ? chartBarFill : "var(--atbl-accent)",
1099
+ color = kind === "bar" ? chartBarFill : "var(--atbl-chart-1)",
1172
1100
  className,
1173
1101
  style,
1174
1102
  ...props
@@ -1182,16 +1110,16 @@ function ChartLegendMarker({
1182
1110
  className: classNames("altertable-chart-legend-marker", className),
1183
1111
  style: { color, ...style },
1184
1112
  children: [
1185
- kind === "square" && /* @__PURE__ */ jsx6("rect", {
1113
+ kind === "square" && /* @__PURE__ */ jsx7("rect", {
1186
1114
  width: "8",
1187
1115
  height: "8",
1188
1116
  fill: "currentColor"
1189
1117
  }),
1190
- kind === "bar" && /* @__PURE__ */ jsx6("path", {
1118
+ kind === "bar" && /* @__PURE__ */ jsx7("path", {
1191
1119
  d: "M6 11V3Q6 1 8 1H12Q14 1 14 3V11Z",
1192
1120
  fill: "currentColor"
1193
1121
  }),
1194
- kind === "slice" && /* @__PURE__ */ jsx6("rect", {
1122
+ kind === "slice" && /* @__PURE__ */ jsx7("rect", {
1195
1123
  x: "5",
1196
1124
  y: "1",
1197
1125
  width: "10",
@@ -1199,7 +1127,7 @@ function ChartLegendMarker({
1199
1127
  rx: "2",
1200
1128
  fill: "currentColor"
1201
1129
  }),
1202
- kind === "point" && /* @__PURE__ */ jsx6("circle", {
1130
+ kind === "point" && /* @__PURE__ */ jsx7("circle", {
1203
1131
  cx: "10",
1204
1132
  cy: "6",
1205
1133
  r: "3",
@@ -1207,14 +1135,14 @@ function ChartLegendMarker({
1207
1135
  }),
1208
1136
  kind === "line" && /* @__PURE__ */ jsxs4(Fragment, {
1209
1137
  children: [
1210
- /* @__PURE__ */ jsx6("path", {
1138
+ /* @__PURE__ */ jsx7("path", {
1211
1139
  d: "M1 6H19",
1212
1140
  fill: "none",
1213
1141
  stroke: "currentColor",
1214
1142
  strokeWidth: "2",
1215
1143
  strokeLinecap: "round"
1216
1144
  }),
1217
- /* @__PURE__ */ jsx6("circle", {
1145
+ /* @__PURE__ */ jsx7("circle", {
1218
1146
  cx: "10",
1219
1147
  cy: "6",
1220
1148
  r: "2.5",
@@ -1226,12 +1154,12 @@ function ChartLegendMarker({
1226
1154
  }),
1227
1155
  kind === "area" && /* @__PURE__ */ jsxs4(Fragment, {
1228
1156
  children: [
1229
- /* @__PURE__ */ jsx6("path", {
1157
+ /* @__PURE__ */ jsx7("path", {
1230
1158
  d: "M1 10L7 5L13 7L19 2V11H1Z",
1231
1159
  fill: "currentColor",
1232
1160
  fillOpacity: "0.14"
1233
1161
  }),
1234
- /* @__PURE__ */ jsx6("path", {
1162
+ /* @__PURE__ */ jsx7("path", {
1235
1163
  d: "M1 10L7 5L13 7L19 2",
1236
1164
  fill: "none",
1237
1165
  stroke: "currentColor",
@@ -1250,7 +1178,7 @@ function ChartLegendLabel({
1250
1178
  title,
1251
1179
  ...props
1252
1180
  }) {
1253
- return /* @__PURE__ */ jsx6("span", {
1181
+ return /* @__PURE__ */ jsx7("span", {
1254
1182
  ...props,
1255
1183
  title: title ?? (typeof children === "string" ? children : undefined),
1256
1184
  className: classNames("altertable-chart-legend-label", className),
@@ -1264,16 +1192,16 @@ var ChartLegend = Object.assign(ChartLegendRoot, {
1264
1192
  });
1265
1193
 
1266
1194
  // src/react/ui/chart-primitives.tsx
1267
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1268
- var accent = "var(--atbl-accent)";
1195
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1196
+ var seriesColor = "var(--atbl-chart-1)";
1269
1197
  function ChartDot({
1270
1198
  active = false,
1271
- stroke = accent,
1199
+ stroke = seriesColor,
1272
1200
  fill = active ? stroke : "var(--atbl-surface)",
1273
1201
  r = active ? 4.5 : 3,
1274
1202
  ...props
1275
1203
  }) {
1276
- return /* @__PURE__ */ jsx7(Dot, {
1204
+ return /* @__PURE__ */ jsx8(Dot, {
1277
1205
  stroke,
1278
1206
  fill,
1279
1207
  r,
@@ -1281,92 +1209,126 @@ function ChartDot({
1281
1209
  ...props
1282
1210
  });
1283
1211
  }
1212
+ function NearestChartDot({
1213
+ seriesId,
1214
+ cx,
1215
+ cy,
1216
+ stroke
1217
+ }) {
1218
+ const interaction = useContext3(ChartInteractionContext);
1219
+ const registerPoint = interaction?.registerPoint;
1220
+ useLayoutEffect2(() => {
1221
+ if (cx == null || cy == null)
1222
+ return;
1223
+ return registerPoint?.(seriesId, cx, cy);
1224
+ }, [registerPoint, seriesId, cx, cy]);
1225
+ const active = isChartSeriesActive(interaction, seriesId);
1226
+ return active ? /* @__PURE__ */ jsx8(ChartDot, {
1227
+ cx,
1228
+ cy,
1229
+ stroke,
1230
+ active: true,
1231
+ style: { pointerEvents: "none" }
1232
+ }) : null;
1233
+ }
1284
1234
  function ChartBar(props) {
1285
- return /* @__PURE__ */ jsx7(Bar, {
1286
- fill: chartBarFill,
1287
- radius: [5, 5, 0, 0],
1288
- maxBarSize: 30,
1289
- activeBar: { fill: accent },
1290
- isAnimationActive: false,
1291
- ...props
1235
+ const series = useChartSeries(props.id);
1236
+ return /* @__PURE__ */ jsx8(ChartSeries, {
1237
+ id: series.id,
1238
+ children: /* @__PURE__ */ jsx8(Bar, {
1239
+ fill: chartBarFill,
1240
+ radius: props.stackId == null ? [5, 5, 0, 0] : 0,
1241
+ maxBarSize: 30,
1242
+ activeBar: series.active ? { opacity: 0.75 } : false,
1243
+ isAnimationActive: false,
1244
+ ...props,
1245
+ id: series.id
1246
+ })
1292
1247
  });
1293
1248
  }
1294
1249
  function ChartLine({
1295
- stroke = accent,
1296
- dot,
1250
+ stroke = seriesColor,
1251
+ dot = false,
1297
1252
  activeDot,
1298
1253
  ...props
1299
1254
  }) {
1300
- return /* @__PURE__ */ jsx7(Line, {
1301
- type: "linear",
1302
- stroke,
1303
- strokeWidth: 2,
1304
- strokeLinecap: "round",
1305
- strokeLinejoin: "round",
1306
- dot: dot === undefined || dot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx7(ChartDot, {
1307
- cx,
1308
- cy,
1309
- stroke
1310
- }) : dot,
1311
- activeDot: activeDot === undefined || activeDot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx7(ChartDot, {
1312
- cx,
1313
- cy,
1255
+ const series = useChartSeries(props.id);
1256
+ return /* @__PURE__ */ jsx8(ChartSeries, {
1257
+ id: series.id,
1258
+ children: /* @__PURE__ */ jsx8(Line, {
1259
+ type: "linear",
1314
1260
  stroke,
1315
- active: true
1316
- }) : activeDot,
1317
- isAnimationActive: false,
1318
- ...props
1261
+ strokeWidth: 2,
1262
+ strokeLinecap: "round",
1263
+ strokeLinejoin: "round",
1264
+ dot: dot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx8(ChartDot, {
1265
+ cx,
1266
+ cy,
1267
+ stroke
1268
+ }) : dot,
1269
+ activeDot: activeDot === undefined || activeDot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx8(NearestChartDot, {
1270
+ seriesId: series.id,
1271
+ cx,
1272
+ cy,
1273
+ stroke
1274
+ }) : activeDot,
1275
+ isAnimationActive: false,
1276
+ ...props,
1277
+ id: series.id
1278
+ })
1319
1279
  });
1320
1280
  }
1321
1281
  function ChartArea({
1322
- stroke = accent,
1323
- dot,
1282
+ stroke = seriesColor,
1283
+ dot = false,
1324
1284
  activeDot,
1325
1285
  ...props
1326
1286
  }) {
1327
- return /* @__PURE__ */ jsx7(Area, {
1328
- legendType: "square",
1329
- type: "linear",
1330
- stroke,
1331
- strokeWidth: 2,
1332
- strokeLinecap: "round",
1333
- strokeLinejoin: "round",
1334
- fill: stroke,
1335
- fillOpacity: 0.14,
1336
- dot: dot === undefined || dot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx7(ChartDot, {
1337
- cx,
1338
- cy,
1339
- stroke
1340
- }) : dot,
1341
- activeDot: activeDot === undefined || activeDot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx7(ChartDot, {
1342
- cx,
1343
- cy,
1287
+ const series = useChartSeries(props.id);
1288
+ return /* @__PURE__ */ jsx8(ChartSeries, {
1289
+ id: series.id,
1290
+ children: /* @__PURE__ */ jsx8(Area, {
1291
+ legendType: "square",
1292
+ type: "linear",
1344
1293
  stroke,
1345
- active: true
1346
- }) : activeDot,
1347
- isAnimationActive: false,
1348
- ...props
1294
+ strokeWidth: 2,
1295
+ strokeLinecap: "round",
1296
+ strokeLinejoin: "round",
1297
+ fill: stroke,
1298
+ fillOpacity: 0.14,
1299
+ dot: dot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx8(ChartDot, {
1300
+ cx,
1301
+ cy,
1302
+ stroke
1303
+ }) : dot,
1304
+ activeDot: activeDot === undefined || activeDot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx8(NearestChartDot, {
1305
+ seriesId: series.id,
1306
+ cx,
1307
+ cy,
1308
+ stroke
1309
+ }) : activeDot,
1310
+ isAnimationActive: false,
1311
+ ...props,
1312
+ id: series.id
1313
+ })
1349
1314
  });
1350
1315
  }
1351
1316
  function ChartScatter(props) {
1352
- return /* @__PURE__ */ jsx7(Scatter, {
1353
- fill: accent,
1354
- isAnimationActive: false,
1355
- ...props
1356
- });
1357
- }
1358
- function ChartXAxis(props) {
1359
- return /* @__PURE__ */ jsx7(XAxis, {
1360
- stroke: "var(--atbl-muted)",
1361
- tickLine: false,
1362
- axisLine: { stroke: "var(--atbl-border)" },
1363
- tick: { fontSize: "var(--atbl-type-meta-size)" },
1364
- ...props
1317
+ const series = useChartSeries(props.id);
1318
+ return /* @__PURE__ */ jsx8(ChartSeries, {
1319
+ id: series.id,
1320
+ children: /* @__PURE__ */ jsx8(Scatter, {
1321
+ fill: seriesColor,
1322
+ isAnimationActive: false,
1323
+ ...props,
1324
+ id: series.id
1325
+ })
1365
1326
  });
1366
1327
  }
1367
1328
  function ChartYAxis(props) {
1368
- return /* @__PURE__ */ jsx7(YAxis, {
1329
+ return /* @__PURE__ */ jsx8(YAxis, {
1369
1330
  stroke: "var(--atbl-muted)",
1331
+ tickFormatter: (value) => typeof value === "number" ? formatNumber2(value) : String(value),
1370
1332
  tickLine: false,
1371
1333
  axisLine: false,
1372
1334
  tick: { fontSize: "var(--atbl-type-meta-size)" },
@@ -1374,19 +1336,19 @@ function ChartYAxis(props) {
1374
1336
  });
1375
1337
  }
1376
1338
  function ChartGrid(props) {
1377
- return /* @__PURE__ */ jsx7(CartesianGrid, {
1339
+ return /* @__PURE__ */ jsx8(CartesianGrid, {
1378
1340
  stroke: "var(--atbl-border)",
1379
1341
  vertical: false,
1380
1342
  ...props
1381
1343
  });
1382
1344
  }
1383
1345
  function ChartTooltipContent(props) {
1384
- if (!props.active)
1346
+ if (!props.active || !props.payload?.length)
1385
1347
  return null;
1386
- return /* @__PURE__ */ jsx7(TooltipSurface, {
1348
+ return /* @__PURE__ */ jsx8(TooltipSurface, {
1387
1349
  "data-variant": "chart",
1388
1350
  role: "tooltip",
1389
- children: /* @__PURE__ */ jsx7(DefaultTooltipContent, {
1351
+ children: /* @__PURE__ */ jsx8(DefaultTooltipContent, {
1390
1352
  ...props,
1391
1353
  separator: "",
1392
1354
  payload: props.payload?.map((entry) => ({
@@ -1394,7 +1356,7 @@ function ChartTooltipContent(props) {
1394
1356
  unit: undefined,
1395
1357
  formatter: (value, name, _item, index, payload) => {
1396
1358
  const formatter = entry.formatter ?? props.formatter;
1397
- const formatted = formatter ? formatter(value, name, entry, index, props.payload ?? payload) : Array.isArray(value) ? value.join(" ~ ") : value;
1359
+ const formatted = formatter ? formatter(value, name, entry, index, props.payload ?? payload) : Array.isArray(value) ? value.map((item) => typeof item === "number" ? formatNumber2(item) : item).join(" ~ ") : typeof value === "number" ? formatNumber2(value) : value;
1398
1360
  if (formatted == null)
1399
1361
  return null;
1400
1362
  const [displayValue, displayName] = Array.isArray(formatted) ? formatted : [formatted, name];
@@ -1402,10 +1364,10 @@ function ChartTooltipContent(props) {
1402
1364
  /* @__PURE__ */ jsxs5("span", {
1403
1365
  className: "altertable-chart-tooltip-row",
1404
1366
  children: [
1405
- /* @__PURE__ */ jsx7(ChartLegend.Marker, {
1367
+ /* @__PURE__ */ jsx8(ChartLegend.Marker, {
1406
1368
  kind: "square",
1407
1369
  className: "altertable-chart-tooltip-marker",
1408
- color: entry.color ?? entry.stroke ?? entry.fill ?? "var(--atbl-accent)"
1370
+ color: entry.color ?? entry.stroke ?? entry.fill ?? "var(--atbl-chart-1)"
1409
1371
  }),
1410
1372
  /* @__PURE__ */ jsxs5("span", {
1411
1373
  className: "altertable-chart-tooltip-reading",
@@ -1447,8 +1409,15 @@ function ChartTooltipContent(props) {
1447
1409
  });
1448
1410
  }
1449
1411
  function ChartTooltip(props) {
1450
- return /* @__PURE__ */ jsx7(Tooltip, {
1451
- content: /* @__PURE__ */ jsx7(ChartTooltipContent, {}),
1412
+ const dateLabel = useDateAxisLabel(props.axisId);
1413
+ const interaction = useContext3(ChartInteractionContext);
1414
+ return /* @__PURE__ */ jsx8(Tooltip, {
1415
+ labelFormatter: dateLabel,
1416
+ content: (content) => /* @__PURE__ */ jsx8(ChartTooltipContent, {
1417
+ ...content,
1418
+ payload: interaction?.isPointerInspection && interaction.seriesCount !== 1 && props.shared !== true ? content.payload.filter((entry) => entry.graphicalItemId === interaction.activeSeriesId) : content.payload
1419
+ }),
1420
+ position: interaction?.isPointerInspection && interaction.activePoint ? { y: interaction.activePoint.y } : undefined,
1452
1421
  cursor: false,
1453
1422
  isAnimationActive: false,
1454
1423
  ...props
@@ -1456,41 +1425,44 @@ function ChartTooltip(props) {
1456
1425
  }
1457
1426
 
1458
1427
  // src/react/ui/chart-data.ts
1459
- function validateChartItems(kind, items) {
1428
+ function validateChartIds(kind, items) {
1460
1429
  const ids = new Set;
1461
1430
  for (const item of items) {
1462
1431
  invariant(item.id.trim().length > 0, `${kind} chart IDs must be nonempty and unique: blank ID.`);
1463
1432
  invariant(!ids.has(item.id), `${kind} chart IDs must be nonempty and unique: duplicate "${item.id}".`);
1464
1433
  ids.add(item.id);
1465
- if (kind === "scatter") {
1466
- const point = item;
1467
- invariant(Number.isFinite(point.x) && Number.isFinite(point.y), `scatter chart "${item.id}" requires finite values for x and y.`);
1468
- } else {
1469
- const point = item;
1470
- invariant(Number.isFinite(point.value), `${kind} chart "${item.id}" requires finite values.`);
1471
- invariant(kind !== "bar" && kind !== "pie" || point.value >= 0, `${kind} chart "${item.id}" requires nonnegative values.`);
1472
- }
1434
+ }
1435
+ }
1436
+ function validateValueChartItems(kind, items) {
1437
+ validateChartIds(kind, items);
1438
+ for (const item of items) {
1439
+ invariant(Number.isFinite(item.value), `${kind} chart "${item.id}" requires finite values.`);
1440
+ invariant(kind !== "bar" && kind !== "pie" || item.value >= 0, `${kind} chart "${item.id}" requires nonnegative values.`);
1441
+ }
1442
+ }
1443
+ function validateScatterChartItems(items) {
1444
+ validateChartIds("scatter", items);
1445
+ for (const item of items) {
1446
+ invariant(Number.isFinite(item.x) && Number.isFinite(item.y), `scatter chart "${item.id}" requires finite values for x and y.`);
1473
1447
  }
1474
1448
  }
1475
1449
 
1476
1450
  // src/react/ui/TrendChart.tsx
1477
- import { jsx as jsx8, jsxs as jsxs6, Fragment as Fragment2 } from "react/jsx-runtime";
1451
+ import { jsx as jsx9, jsxs as jsxs6, Fragment as Fragment3 } from "react/jsx-runtime";
1478
1452
  function TrendChart({
1479
1453
  items,
1480
1454
  unit,
1481
1455
  ariaLabel,
1482
- formatValue = (value) => new Intl.NumberFormat().format(value),
1483
- area = false
1456
+ formatValue = formatNumber2,
1457
+ kind,
1458
+ itemActions
1484
1459
  }) {
1485
- validateChartItems(area ? "area" : "line", items);
1486
- const Plot = area ? RechartsAreaChart : RechartsLineChart;
1487
- const [activeIndex, setActiveIndex] = useState2();
1488
- const scrollport = useRef(null);
1489
- useLayoutEffect(() => {
1490
- const element = scrollport.current;
1491
- if (element)
1492
- element.scrollLeft = element.scrollWidth - element.clientWidth;
1493
- }, [items]);
1460
+ validateValueChartItems(kind, items);
1461
+ const Plot = kind === "area" ? RechartsAreaChart : RechartsLineChart;
1462
+ const chartActions = useChartActions();
1463
+ const [activeIndex, setActiveIndex] = useState3();
1464
+ const scrollport = useChartScrollToEnd(items);
1465
+ const menuTriggers = useRef3(new Map);
1494
1466
  const magnitude = items.reduce((max, item) => Math.max(max, Math.abs(item.value)), 1);
1495
1467
  const low = items.reduce((min, item) => Math.min(min, item.value / magnitude), 0);
1496
1468
  const high = items.reduce((max, item) => Math.max(max, item.value / magnitude), 0);
@@ -1498,18 +1470,18 @@ function TrendChart({
1498
1470
  className: "altertable-trend-chart",
1499
1471
  "aria-label": ariaLabel,
1500
1472
  children: [
1501
- items.length === 0 && /* @__PURE__ */ jsx8("span", {
1473
+ items.length === 0 && /* @__PURE__ */ jsx9("span", {
1502
1474
  children: "No data"
1503
1475
  }),
1504
- items.length > 0 && /* @__PURE__ */ jsx8(Fragment2, {
1505
- children: /* @__PURE__ */ jsx8("div", {
1476
+ items.length > 0 && /* @__PURE__ */ jsx9(Fragment3, {
1477
+ children: /* @__PURE__ */ jsx9("div", {
1506
1478
  className: "altertable-trend-scroll",
1507
1479
  ref: scrollport,
1508
1480
  children: /* @__PURE__ */ jsxs6("div", {
1509
1481
  className: "altertable-trend-plot",
1510
1482
  style: { minWidth: items.length * 40 },
1511
1483
  children: [
1512
- /* @__PURE__ */ jsx8("div", {
1484
+ /* @__PURE__ */ jsx9("div", {
1513
1485
  className: "altertable-chart-canvas",
1514
1486
  "aria-hidden": "true",
1515
1487
  children: /* @__PURE__ */ jsxs6(Plot, {
@@ -1517,7 +1489,6 @@ function TrendChart({
1517
1489
  ...item,
1518
1490
  plotValue: item.value / magnitude
1519
1491
  })),
1520
- title: ariaLabel,
1521
1492
  responsive: true,
1522
1493
  width: "100%",
1523
1494
  height: 220,
@@ -1525,114 +1496,195 @@ function TrendChart({
1525
1496
  accessibilityLayer: false,
1526
1497
  tabIndex: -1,
1527
1498
  children: [
1528
- /* @__PURE__ */ jsx8(ChartXAxis, {
1499
+ /* @__PURE__ */ jsx9(ChartXAxis, {
1529
1500
  hide: true,
1530
1501
  dataKey: "id",
1531
1502
  scale: "band"
1532
1503
  }),
1533
- /* @__PURE__ */ jsx8(ChartYAxis, {
1504
+ /* @__PURE__ */ jsx9(ChartYAxis, {
1534
1505
  hide: true,
1535
1506
  domain: [low, high === low ? low + 1 : high]
1536
1507
  }),
1537
- /* @__PURE__ */ jsx8(ReferenceLine, {
1508
+ /* @__PURE__ */ jsx9(ReferenceLine, {
1538
1509
  y: 0,
1539
1510
  stroke: "var(--atbl-border)"
1540
1511
  }),
1541
- area && /* @__PURE__ */ jsx8(ChartArea, {
1512
+ kind === "area" && /* @__PURE__ */ jsx9(ChartArea, {
1542
1513
  dataKey: "plotValue",
1543
1514
  stroke: "none",
1544
- fill: "var(--atbl-accent)",
1515
+ fill: "var(--atbl-chart-1)",
1545
1516
  dot: false,
1546
1517
  activeDot: false
1547
1518
  }),
1548
- /* @__PURE__ */ jsx8(ChartLine, {
1519
+ /* @__PURE__ */ jsx9(ChartLine, {
1549
1520
  dataKey: "plotValue",
1550
- dot: ({ cx, cy, index }) => /* @__PURE__ */ jsx8(ChartDot, {
1521
+ dot: ({ cx, cy, index }) => index === activeIndex ? /* @__PURE__ */ jsx9(ChartDot, {
1551
1522
  cx,
1552
1523
  cy,
1553
1524
  active: index === activeIndex
1554
- }),
1525
+ }) : /* @__PURE__ */ jsx9("g", {}),
1555
1526
  activeDot: false
1556
1527
  })
1557
1528
  ]
1558
1529
  })
1559
1530
  }),
1560
- /* @__PURE__ */ jsx8("div", {
1531
+ /* @__PURE__ */ jsx9("div", {
1561
1532
  className: "altertable-trend-points",
1562
- children: items.map((item, index) => /* @__PURE__ */ jsx8(Tooltip2, {
1563
- variant: "chart",
1564
- onOpenChange: (open) => setActiveIndex((current) => open ? index : current === index ? undefined : current),
1565
- content: /* @__PURE__ */ jsxs6(Fragment2, {
1566
- children: [
1567
- /* @__PURE__ */ jsx8("strong", {
1568
- children: item.label
1569
- }),
1570
- /* @__PURE__ */ jsxs6("span", {
1571
- children: [
1572
- formatValue(item.value),
1573
- " ",
1574
- unit
1575
- ]
1576
- })
1577
- ]
1578
- }),
1579
- className: "altertable-chart-column",
1580
- children: /* @__PURE__ */ jsxs6("button", {
1581
- "data-atbl-focus": "ring",
1582
- "data-atbl-control": "default",
1583
- type: "button",
1584
- tabIndex: -1,
1585
- className: "altertable-trend-point",
1586
- "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
1587
- children: [
1588
- /* @__PURE__ */ jsx8("span", {
1589
- className: "altertable-trend-hit"
1590
- }),
1591
- /* @__PURE__ */ jsx8("span", {
1592
- className: "altertable-trend-label",
1593
- children: item.label
1594
- })
1595
- ]
1596
- })
1597
- }, item.id))
1533
+ children: items.map((item, index) => {
1534
+ const declaredActions = itemActions?.(item) ?? [];
1535
+ const actions = chartActions.actions(declaredActions, item.label, `${formatValue(item.value)} ${unit}`);
1536
+ const action = getPrimaryExplorationAction(actions);
1537
+ const menuTrigger = {
1538
+ get current() {
1539
+ return menuTriggers.current.get(item.id) ?? null;
1540
+ }
1541
+ };
1542
+ return /* @__PURE__ */ jsx9(Fragment2, {
1543
+ children: /* @__PURE__ */ jsxs6("div", {
1544
+ className: "altertable-chart-item-actions",
1545
+ children: [
1546
+ /* @__PURE__ */ jsx9(Tooltip2, {
1547
+ variant: "chart",
1548
+ onOpenChange: (open) => setActiveIndex((current) => open ? index : current === index ? undefined : current),
1549
+ content: /* @__PURE__ */ jsxs6(Fragment3, {
1550
+ children: [
1551
+ /* @__PURE__ */ jsx9("strong", {
1552
+ children: item.label
1553
+ }),
1554
+ /* @__PURE__ */ jsxs6("span", {
1555
+ children: [
1556
+ formatValue(item.value),
1557
+ " ",
1558
+ unit
1559
+ ]
1560
+ })
1561
+ ]
1562
+ }),
1563
+ className: "altertable-chart-column",
1564
+ children: action ? /* @__PURE__ */ jsxs6("button", {
1565
+ "data-atbl-focus": "ring",
1566
+ "data-atbl-control": "action",
1567
+ type: "button",
1568
+ className: "altertable-trend-point",
1569
+ "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. ${action.label}`,
1570
+ ...explorationMenuEvents(menuTrigger),
1571
+ onClick: (event) => action.onSelect(event.currentTarget),
1572
+ children: [
1573
+ /* @__PURE__ */ jsx9("span", {
1574
+ className: "altertable-trend-hit"
1575
+ }),
1576
+ /* @__PURE__ */ jsx9("span", {
1577
+ className: "altertable-trend-label",
1578
+ children: item.label
1579
+ })
1580
+ ]
1581
+ }) : actions.length > 1 ? /* @__PURE__ */ jsxs6(MenuTrigger2, {
1582
+ children: [
1583
+ /* @__PURE__ */ jsxs6(PressButton, {
1584
+ ...explorationMenuEvents(menuTrigger),
1585
+ ref: (element) => {
1586
+ if (element)
1587
+ menuTriggers.current.set(item.id, element);
1588
+ else
1589
+ menuTriggers.current.delete(item.id);
1590
+ },
1591
+ className: "altertable-trend-point",
1592
+ "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. Actions`,
1593
+ children: [
1594
+ /* @__PURE__ */ jsx9("span", {
1595
+ className: "altertable-trend-hit"
1596
+ }),
1597
+ /* @__PURE__ */ jsx9("span", {
1598
+ className: "altertable-trend-label",
1599
+ children: item.label
1600
+ })
1601
+ ]
1602
+ }),
1603
+ /* @__PURE__ */ jsx9(ExplorationActionMenu, {
1604
+ actions,
1605
+ ariaLabel: `${item.label} actions`,
1606
+ triggerRef: menuTrigger
1607
+ })
1608
+ ]
1609
+ }) : /* @__PURE__ */ jsxs6("button", {
1610
+ "data-atbl-focus": "ring",
1611
+ "data-atbl-control": "default",
1612
+ type: "button",
1613
+ tabIndex: -1,
1614
+ className: "altertable-trend-point",
1615
+ "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
1616
+ children: [
1617
+ /* @__PURE__ */ jsx9("span", {
1618
+ className: "altertable-trend-hit"
1619
+ }),
1620
+ /* @__PURE__ */ jsx9("span", {
1621
+ className: "altertable-trend-label",
1622
+ children: item.label
1623
+ })
1624
+ ]
1625
+ })
1626
+ }),
1627
+ action && /* @__PURE__ */ jsx9(ExplorationActionControl2, {
1628
+ contextOnly: declaredActions.length === 1,
1629
+ indicator: "chevron",
1630
+ ref: (element) => {
1631
+ if (element)
1632
+ menuTriggers.current.set(item.id, element);
1633
+ else
1634
+ menuTriggers.current.delete(item.id);
1635
+ },
1636
+ actions,
1637
+ ariaLabel: `${item.label} actions`,
1638
+ hidePrimary: Boolean(action)
1639
+ })
1640
+ ]
1641
+ })
1642
+ }, item.id);
1643
+ })
1598
1644
  })
1599
1645
  ]
1600
1646
  })
1601
1647
  })
1602
- })
1648
+ }),
1649
+ chartActions.feedback
1603
1650
  ]
1604
1651
  });
1605
1652
  }
1606
1653
 
1607
1654
  // src/react/ui/LineChart.tsx
1608
- import { jsx as jsx9 } from "react/jsx-runtime";
1655
+ import { jsx as jsx10 } from "react/jsx-runtime";
1609
1656
  function LineChart(props) {
1610
- return /* @__PURE__ */ jsx9(TrendChart, {
1611
- ...props
1657
+ return /* @__PURE__ */ jsx10(TrendChart, {
1658
+ ...props,
1659
+ kind: "line"
1612
1660
  });
1613
1661
  }
1614
1662
  // src/react/ui/AreaChart.tsx
1615
- import { jsx as jsx10 } from "react/jsx-runtime";
1663
+ import { jsx as jsx11 } from "react/jsx-runtime";
1616
1664
  function AreaChart(props) {
1617
- return /* @__PURE__ */ jsx10(TrendChart, {
1665
+ return /* @__PURE__ */ jsx11(TrendChart, {
1618
1666
  ...props,
1619
- area: true
1667
+ kind: "area"
1620
1668
  });
1621
1669
  }
1622
1670
  // src/react/ui/PieChart.tsx
1623
- import { useState as useState3 } from "react";
1624
- import { jsx as jsx11, jsxs as jsxs7, Fragment as Fragment3 } from "react/jsx-runtime";
1671
+ import { useRef as useRef4, useState as useState4 } from "react";
1672
+ import { jsx as jsx12, jsxs as jsxs7, Fragment as Fragment4 } from "react/jsx-runtime";
1625
1673
  function PieChart({
1626
1674
  items,
1627
1675
  unit,
1628
1676
  ariaLabel,
1629
1677
  showLegend = true,
1630
- formatValue = (value) => new Intl.NumberFormat().format(value)
1678
+ formatValue = (value) => new Intl.NumberFormat().format(value),
1679
+ itemActions
1631
1680
  }) {
1632
- validateChartItems("pie", items);
1633
- const [previewId, setPreviewId] = useState3(null);
1634
- const [plotOpen, setPlotOpen] = useState3(false);
1635
- const [legendId, setLegendId] = useState3(null);
1681
+ validateValueChartItems("pie", items);
1682
+ const chartActions = useChartActions();
1683
+ const [previewId, setPreviewId] = useState4(null);
1684
+ const [plotOpen, setPlotOpen] = useState4(false);
1685
+ const [legendId, setLegendId] = useState4(null);
1686
+ const menuTriggers = useRef4(new Map);
1687
+ const plotMenuTriggers = useRef4(new Map);
1636
1688
  const maximum = items.reduce((max, item) => Math.max(max, item.value), 0);
1637
1689
  const total = maximum ? items.reduce((sum, item) => sum + item.value / maximum, 0) : 0;
1638
1690
  let cursor = -Math.PI / 2;
@@ -1646,7 +1698,7 @@ function PieChart({
1646
1698
  cursor += share * Math.PI * 2;
1647
1699
  const middle = (start + cursor) / 2;
1648
1700
  slices.push({
1649
- ...item,
1701
+ row: item,
1650
1702
  share,
1651
1703
  color: `var(--atbl-chart-${index % 8 + 1})`,
1652
1704
  path: `${share === 1 ? "M" : "M110,110 L"}${point(start)} A100,100 0 0 1 ${point(middle)} A100,100 0 0 1 ${point(cursor)} Z`
@@ -1658,10 +1710,11 @@ function PieChart({
1658
1710
  maximumFractionDigits: 1
1659
1711
  }).format(share);
1660
1712
  }
1661
- function detail(item) {
1662
- return /* @__PURE__ */ jsxs7(Fragment3, {
1713
+ function detail(slice) {
1714
+ const item = slice.row;
1715
+ return /* @__PURE__ */ jsxs7(Fragment4, {
1663
1716
  children: [
1664
- /* @__PURE__ */ jsx11("strong", {
1717
+ /* @__PURE__ */ jsx12("strong", {
1665
1718
  children: item.label
1666
1719
  }),
1667
1720
  /* @__PURE__ */ jsxs7("span", {
@@ -1670,108 +1723,207 @@ function PieChart({
1670
1723
  " ",
1671
1724
  unit,
1672
1725
  " · ",
1673
- percent(item.share)
1726
+ percent(slice.share)
1674
1727
  ]
1675
1728
  })
1676
1729
  ]
1677
1730
  });
1678
1731
  }
1679
- const preview = slices.find((item) => item.id === previewId);
1732
+ function actionsFor(slice) {
1733
+ const item = slice.row;
1734
+ return chartActions.actions(itemActions?.(item) ?? [], item.label, `${formatValue(item.value)} ${unit} · ${percent(slice.share)}`);
1735
+ }
1736
+ const preview = slices.find((slice) => slice.row.id === previewId);
1680
1737
  return /* @__PURE__ */ jsxs7("section", {
1681
1738
  className: "altertable-pie-chart",
1682
1739
  "aria-label": ariaLabel,
1683
1740
  children: [
1684
- items.length === 0 && /* @__PURE__ */ jsx11("span", {
1741
+ items.length === 0 && /* @__PURE__ */ jsx12("span", {
1685
1742
  children: "No data"
1686
1743
  }),
1687
- items.length > 0 && /* @__PURE__ */ jsxs7(Fragment3, {
1744
+ items.length > 0 && /* @__PURE__ */ jsxs7(Fragment4, {
1688
1745
  children: [
1689
1746
  /* @__PURE__ */ jsxs7("div", {
1690
1747
  className: "altertable-pie-plot",
1691
1748
  children: [
1692
- /* @__PURE__ */ jsx11(Tooltip2, {
1749
+ /* @__PURE__ */ jsx12(Tooltip2, {
1693
1750
  variant: "chart",
1694
1751
  className: "altertable-pie-tooltip",
1695
1752
  onOpenChange: setPlotOpen,
1696
1753
  content: preview ? detail(preview) : null,
1697
- children: /* @__PURE__ */ jsx11("svg", {
1754
+ children: /* @__PURE__ */ jsx12("svg", {
1698
1755
  viewBox: "0 0 220 220",
1699
- "aria-hidden": "true",
1700
- focusable: "false",
1701
- children: total === 0 ? /* @__PURE__ */ jsx11("circle", {
1756
+ "aria-hidden": itemActions ? undefined : true,
1757
+ "aria-label": itemActions ? ariaLabel : undefined,
1758
+ focusable: itemActions ? undefined : false,
1759
+ role: itemActions ? "group" : undefined,
1760
+ children: total === 0 ? /* @__PURE__ */ jsx12("circle", {
1702
1761
  cx: "110",
1703
1762
  cy: "110",
1704
1763
  r: "100",
1705
1764
  className: "altertable-pie-empty"
1706
- }) : slices.filter((item) => item.share > 0).map((item) => /* @__PURE__ */ jsx11("path", {
1707
- d: item.path,
1708
- fill: item.color,
1709
- className: "altertable-pie-slice",
1710
- "data-active": item.id === (plotOpen && previewId ? previewId : showLegend ? legendId : null) || undefined,
1711
- onPointerDown: (event) => {
1712
- if (plotOpen && previewId !== item.id)
1713
- event.preventDefault();
1714
- setPreviewId(item.id);
1715
- },
1716
- onPointerEnter: (event) => {
1717
- if (event.pointerType === "mouse")
1765
+ }) : slices.filter((slice) => slice.share > 0).map((slice) => {
1766
+ const item = slice.row;
1767
+ const menuTrigger = {
1768
+ get current() {
1769
+ return menuTriggers.current.get(item.id) ?? plotMenuTriggers.current.get(item.id) ?? null;
1770
+ }
1771
+ };
1772
+ const action = getPrimaryExplorationAction(actionsFor(slice));
1773
+ const opensMenu = !action && (itemActions?.(item).length ?? 0) > 1;
1774
+ return /* @__PURE__ */ jsx12("path", {
1775
+ d: slice.path,
1776
+ fill: slice.color,
1777
+ className: "altertable-pie-slice",
1778
+ "data-active": item.id === (plotOpen && previewId ? previewId : showLegend ? legendId : null) || undefined,
1779
+ onPointerDown: (event) => {
1780
+ if (plotOpen && previewId !== item.id)
1781
+ event.preventDefault();
1718
1782
  setPreviewId(item.id);
1719
- },
1720
- onPointerLeave: (event) => {
1721
- if (event.pointerType === "mouse")
1722
- setPreviewId(null);
1723
- }
1724
- }, item.id))
1783
+ },
1784
+ onClick: (event) => {
1785
+ if (action)
1786
+ action.onSelect(event.currentTarget);
1787
+ else if (opensMenu)
1788
+ menuTrigger.current?.click();
1789
+ },
1790
+ onContextMenu: explorationMenuEvents(menuTrigger).onContextMenu,
1791
+ onKeyDown: (event) => {
1792
+ explorationMenuEvents(menuTrigger).onKeyDown(event);
1793
+ if ((action || opensMenu) && (event.key === "Enter" || event.key === " ")) {
1794
+ event.preventDefault();
1795
+ if (action)
1796
+ action.onSelect(event.currentTarget);
1797
+ else
1798
+ menuTrigger.current?.click();
1799
+ }
1800
+ },
1801
+ "aria-label": action ? `${item.label}: ${formatValue(item.value)} ${unit}. ${action.label}` : opensMenu ? `${item.label}: ${formatValue(item.value)} ${unit}. Actions` : undefined,
1802
+ role: action || opensMenu ? "button" : undefined,
1803
+ "data-atbl-control": action || opensMenu ? "action" : undefined,
1804
+ tabIndex: action || opensMenu ? 0 : undefined,
1805
+ onPointerEnter: (event) => {
1806
+ if (event.pointerType === "mouse")
1807
+ setPreviewId(item.id);
1808
+ },
1809
+ onPointerLeave: (event) => {
1810
+ if (event.pointerType === "mouse")
1811
+ setPreviewId(null);
1812
+ }
1813
+ }, item.id);
1814
+ })
1725
1815
  })
1726
1816
  }),
1727
- total === 0 && /* @__PURE__ */ jsx11("span", {
1817
+ slices.map((slice) => {
1818
+ const item = slice.row;
1819
+ const actions = actionsFor(slice);
1820
+ if (actions.length === 0)
1821
+ return null;
1822
+ return /* @__PURE__ */ jsx12("span", {
1823
+ className: "altertable-sr-only",
1824
+ children: /* @__PURE__ */ jsx12(ExplorationActionControl2, {
1825
+ ref: (element) => {
1826
+ if (element)
1827
+ plotMenuTriggers.current.set(item.id, element);
1828
+ else
1829
+ plotMenuTriggers.current.delete(item.id);
1830
+ },
1831
+ actions,
1832
+ ariaLabel: `${item.label} actions`,
1833
+ contextOnly: true,
1834
+ hidePrimary: true
1835
+ })
1836
+ }, item.id);
1837
+ }),
1838
+ total === 0 && /* @__PURE__ */ jsx12("span", {
1728
1839
  className: "altertable-pie-empty-label",
1729
1840
  children: "No nonzero values"
1730
1841
  })
1731
1842
  ]
1732
1843
  }),
1733
- showLegend && /* @__PURE__ */ jsx11(ChartLegend, {
1844
+ showLegend && /* @__PURE__ */ jsx12(ChartLegend, {
1734
1845
  layout: "vertical",
1735
1846
  "aria-label": `${ariaLabel} legend`,
1736
1847
  className: "altertable-pie-legend",
1737
- children: slices.map((item) => /* @__PURE__ */ jsx11(ChartLegend.Item, {
1738
- children: /* @__PURE__ */ jsx11(Tooltip2, {
1739
- variant: "chart",
1740
- content: detail(item),
1741
- onOpenChange: (open) => setLegendId((current) => open ? item.id : current === item.id ? null : current),
1742
- children: /* @__PURE__ */ jsxs7("button", {
1743
- "data-atbl-focus": "ring",
1744
- "data-atbl-control": "default",
1745
- type: "button",
1746
- tabIndex: -1,
1747
- "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}, ${percent(item.share)}`,
1748
- children: [
1749
- /* @__PURE__ */ jsx11(ChartLegend.Marker, {
1750
- kind: "square",
1751
- color: item.color
1752
- }),
1753
- /* @__PURE__ */ jsx11(ChartLegend.Label, {
1754
- className: "altertable-pie-label",
1755
- children: item.label
1756
- }),
1757
- /* @__PURE__ */ jsx11("strong", {
1758
- children: formatValue(item.value)
1759
- }),
1760
- /* @__PURE__ */ jsx11("span", {
1761
- children: percent(item.share)
1762
- })
1763
- ]
1848
+ children: slices.map((slice) => {
1849
+ const item = slice.row;
1850
+ const actions = actionsFor(slice);
1851
+ const menuTrigger = {
1852
+ get current() {
1853
+ return menuTriggers.current.get(item.id) ?? null;
1854
+ }
1855
+ };
1856
+ const label = `${item.label}: ${formatValue(item.value)} ${unit}, ${percent(slice.share)}${actions.length ? ". Actions" : ""}`;
1857
+ const contents = /* @__PURE__ */ jsxs7(Fragment4, {
1858
+ children: [
1859
+ /* @__PURE__ */ jsx12(ChartLegend.Marker, {
1860
+ kind: "square",
1861
+ color: slice.color
1862
+ }),
1863
+ /* @__PURE__ */ jsx12(ChartLegend.Label, {
1864
+ className: "altertable-pie-label",
1865
+ children: item.label
1866
+ }),
1867
+ actions.length > 0 && /* @__PURE__ */ jsx12(AppIcon2, {
1868
+ name: "moreActions",
1869
+ size: 14,
1870
+ className: "altertable-pie-menu-indicator"
1871
+ }),
1872
+ /* @__PURE__ */ jsx12("strong", {
1873
+ className: "altertable-pie-value",
1874
+ children: formatValue(item.value)
1875
+ }),
1876
+ /* @__PURE__ */ jsx12("span", {
1877
+ className: "altertable-pie-share",
1878
+ children: percent(slice.share)
1879
+ })
1880
+ ]
1881
+ });
1882
+ return /* @__PURE__ */ jsx12(ChartLegend.Item, {
1883
+ children: /* @__PURE__ */ jsx12(Tooltip2, {
1884
+ variant: "chart",
1885
+ content: detail(slice),
1886
+ onOpenChange: (open) => setLegendId((current) => open ? item.id : current === item.id ? null : current),
1887
+ children: actions.length ? /* @__PURE__ */ jsxs7(MenuTrigger2, {
1888
+ children: [
1889
+ /* @__PURE__ */ jsx12(PressButton, {
1890
+ ...explorationMenuEvents(menuTrigger),
1891
+ ref: (element) => {
1892
+ if (element)
1893
+ menuTriggers.current.set(item.id, element);
1894
+ else
1895
+ menuTriggers.current.delete(item.id);
1896
+ },
1897
+ "aria-label": label,
1898
+ children: contents
1899
+ }),
1900
+ /* @__PURE__ */ jsx12(ExplorationActionMenu, {
1901
+ actions,
1902
+ ariaLabel: item.label,
1903
+ triggerRef: menuTrigger,
1904
+ placement: "bottom start"
1905
+ })
1906
+ ]
1907
+ }) : /* @__PURE__ */ jsx12("button", {
1908
+ type: "button",
1909
+ "data-atbl-focus": "ring",
1910
+ "data-atbl-control": "default",
1911
+ tabIndex: -1,
1912
+ "aria-label": label,
1913
+ children: contents
1914
+ })
1764
1915
  })
1765
- })
1766
- }, item.id))
1916
+ }, item.id);
1917
+ })
1767
1918
  })
1768
1919
  ]
1769
- })
1920
+ }),
1921
+ chartActions.feedback
1770
1922
  ]
1771
1923
  });
1772
1924
  }
1773
1925
  // src/react/ui/ScatterChart.tsx
1774
- import { jsx as jsx12, jsxs as jsxs8, Fragment as Fragment4 } from "react/jsx-runtime";
1926
+ import { jsx as jsx13, jsxs as jsxs8, Fragment as Fragment5 } from "react/jsx-runtime";
1775
1927
  function formatNumber(value) {
1776
1928
  return new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 }).format(value);
1777
1929
  }
@@ -1797,17 +1949,17 @@ function ScatterChart({
1797
1949
  formatX = formatNumber,
1798
1950
  formatY = formatNumber
1799
1951
  }) {
1800
- validateChartItems("scatter", items);
1952
+ validateScatterChartItems(items);
1801
1953
  const xScale = scale(items.map((item) => item.x));
1802
1954
  const yScale = scale(items.map((item) => item.y));
1803
1955
  return /* @__PURE__ */ jsxs8("section", {
1804
1956
  className: "altertable-scatter-chart",
1805
1957
  "aria-label": ariaLabel,
1806
1958
  children: [
1807
- items.length === 0 && /* @__PURE__ */ jsx12("span", {
1959
+ items.length === 0 && /* @__PURE__ */ jsx13("span", {
1808
1960
  children: "No data"
1809
1961
  }),
1810
- items.length > 0 && /* @__PURE__ */ jsxs8(Fragment4, {
1962
+ items.length > 0 && /* @__PURE__ */ jsxs8(Fragment5, {
1811
1963
  children: [
1812
1964
  /* @__PURE__ */ jsxs8("p", {
1813
1965
  className: "altertable-scatter-axis-title",
@@ -1816,21 +1968,21 @@ function ScatterChart({
1816
1968
  yUnit && ` (${yUnit})`
1817
1969
  ]
1818
1970
  }),
1819
- /* @__PURE__ */ jsx12("div", {
1971
+ /* @__PURE__ */ jsx13("div", {
1820
1972
  className: "altertable-scatter-axes",
1821
1973
  children: /* @__PURE__ */ jsxs8("div", {
1822
1974
  className: "altertable-scatter-plot",
1823
1975
  children: [
1824
- yScale.ticks.map((value, index) => /* @__PURE__ */ jsx12("div", {
1976
+ yScale.ticks.map((value, index) => /* @__PURE__ */ jsx13("div", {
1825
1977
  className: "altertable-scatter-gridline",
1826
1978
  style: { bottom: `${index * 50}%` },
1827
1979
  "aria-hidden": "true",
1828
- children: /* @__PURE__ */ jsx12("span", {
1980
+ children: /* @__PURE__ */ jsx13("span", {
1829
1981
  title: formatY(value),
1830
1982
  children: formatY(value)
1831
1983
  })
1832
1984
  }, index)),
1833
- xScale.ticks.map((value, index) => /* @__PURE__ */ jsx12("span", {
1985
+ xScale.ticks.map((value, index) => /* @__PURE__ */ jsx13("span", {
1834
1986
  className: "altertable-scatter-x-tick",
1835
1987
  "data-edge": index,
1836
1988
  style: { left: `${index * 50}%` },
@@ -1838,11 +1990,11 @@ function ScatterChart({
1838
1990
  title: formatX(value),
1839
1991
  children: formatX(value)
1840
1992
  }, index)),
1841
- items.map((item) => /* @__PURE__ */ jsx12(Tooltip2, {
1993
+ items.map((item) => /* @__PURE__ */ jsx13(Tooltip2, {
1842
1994
  variant: "chart",
1843
- content: /* @__PURE__ */ jsxs8(Fragment4, {
1995
+ content: /* @__PURE__ */ jsxs8(Fragment5, {
1844
1996
  children: [
1845
- /* @__PURE__ */ jsx12("strong", {
1997
+ /* @__PURE__ */ jsx13("strong", {
1846
1998
  children: item.label
1847
1999
  }),
1848
2000
  /* @__PURE__ */ jsxs8("span", {
@@ -1870,14 +2022,14 @@ function ScatterChart({
1870
2022
  left: `${xScale.position(item.x)}%`,
1871
2023
  bottom: `${yScale.position(item.y)}%`
1872
2024
  },
1873
- children: /* @__PURE__ */ jsx12("button", {
2025
+ children: /* @__PURE__ */ jsx13("button", {
1874
2026
  "data-atbl-focus": "ring",
1875
2027
  "data-atbl-control": "default",
1876
2028
  type: "button",
1877
2029
  tabIndex: -1,
1878
2030
  className: "altertable-scatter-point",
1879
2031
  "aria-label": `${item.label}: ${xLabel} ${formatX(item.x)} ${xUnit}, ${yLabel} ${formatY(item.y)} ${yUnit}`,
1880
- children: /* @__PURE__ */ jsx12("span", {})
2032
+ children: /* @__PURE__ */ jsx13("span", {})
1881
2033
  })
1882
2034
  }, item.id))
1883
2035
  ]
@@ -1896,39 +2048,41 @@ function ScatterChart({
1896
2048
  });
1897
2049
  }
1898
2050
  // src/react/ui/BarChart.tsx
1899
- import { useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState4 } from "react";
2051
+ import {
2052
+ Fragment as Fragment6,
2053
+ useRef as useRef5,
2054
+ useState as useState5
2055
+ } from "react";
1900
2056
  import { BarChart as RechartsBarChart, Cell } from "recharts";
1901
- import { jsx as jsx13, jsxs as jsxs9, Fragment as Fragment5 } from "react/jsx-runtime";
2057
+ import { jsx as jsx14, jsxs as jsxs9, Fragment as Fragment7 } from "react/jsx-runtime";
1902
2058
  function BarChart({
1903
2059
  items,
1904
2060
  unit,
1905
2061
  ariaLabel,
1906
- formatValue = (value) => new Intl.NumberFormat().format(value)
2062
+ formatValue = formatNumber2,
2063
+ itemActions
1907
2064
  }) {
1908
- validateChartItems("bar", items);
1909
- const [activeId, setActiveId] = useState4();
1910
- const scrollport = useRef2(null);
1911
- useLayoutEffect2(() => {
1912
- const element = scrollport.current;
1913
- if (element)
1914
- element.scrollLeft = element.scrollWidth - element.clientWidth;
1915
- }, [items]);
2065
+ validateValueChartItems("bar", items);
2066
+ const chartActions = useChartActions();
2067
+ const [activeId, setActiveId] = useState5();
2068
+ const scrollport = useChartScrollToEnd(items);
2069
+ const menuTriggers = useRef5(new Map);
1916
2070
  const maximum = items.reduce((max, item) => Math.max(max, item.value), 1);
1917
2071
  return /* @__PURE__ */ jsxs9("section", {
1918
2072
  className: "altertable-selectable-bars",
1919
2073
  "aria-label": ariaLabel,
1920
2074
  children: [
1921
- items.length === 0 && /* @__PURE__ */ jsx13("span", {
2075
+ items.length === 0 && /* @__PURE__ */ jsx14("span", {
1922
2076
  children: "No data"
1923
2077
  }),
1924
- /* @__PURE__ */ jsx13("div", {
2078
+ /* @__PURE__ */ jsx14("div", {
1925
2079
  className: "altertable-selectable-bars-scroll",
1926
2080
  ref: scrollport,
1927
2081
  children: /* @__PURE__ */ jsxs9("div", {
1928
2082
  className: "altertable-selectable-bars-plot",
1929
2083
  style: { minWidth: items.length * 45 },
1930
2084
  children: [
1931
- /* @__PURE__ */ jsx13("div", {
2085
+ /* @__PURE__ */ jsx14("div", {
1932
2086
  className: "altertable-chart-canvas",
1933
2087
  "aria-hidden": "true",
1934
2088
  children: /* @__PURE__ */ jsxs9(RechartsBarChart, {
@@ -1936,7 +2090,6 @@ function BarChart({
1936
2090
  ...item,
1937
2091
  plotValue: item.value / maximum
1938
2092
  })),
1939
- title: ariaLabel,
1940
2093
  responsive: true,
1941
2094
  width: "100%",
1942
2095
  height: 220,
@@ -1945,68 +2098,138 @@ function BarChart({
1945
2098
  tabIndex: -1,
1946
2099
  barCategoryGap: "24%",
1947
2100
  children: [
1948
- /* @__PURE__ */ jsx13(ChartXAxis, {
2101
+ /* @__PURE__ */ jsx14(ChartXAxis, {
1949
2102
  hide: true,
1950
2103
  dataKey: "id",
1951
2104
  scale: "band"
1952
2105
  }),
1953
- /* @__PURE__ */ jsx13(ChartYAxis, {
2106
+ /* @__PURE__ */ jsx14(ChartYAxis, {
1954
2107
  hide: true,
1955
2108
  domain: [0, 1],
1956
2109
  allowDataOverflow: true
1957
2110
  }),
1958
- /* @__PURE__ */ jsx13(ChartBar, {
2111
+ /* @__PURE__ */ jsx14(ChartBar, {
1959
2112
  dataKey: "plotValue",
1960
2113
  minPointSize: (value) => (value ?? 0) > 0 ? 7 : 0,
1961
- children: items.map((item) => /* @__PURE__ */ jsx13(Cell, {
1962
- fill: activeId === item.id ? "var(--atbl-accent)" : chartBarFill
2114
+ children: items.map((item) => /* @__PURE__ */ jsx14(Cell, {
2115
+ fill: chartBarFill,
2116
+ opacity: activeId === item.id ? 0.75 : 1
1963
2117
  }, item.id))
1964
2118
  })
1965
2119
  ]
1966
2120
  })
1967
2121
  }),
1968
- /* @__PURE__ */ jsx13("div", {
2122
+ /* @__PURE__ */ jsx14("div", {
1969
2123
  className: "altertable-selectable-bars-items",
1970
- children: items.map((item) => /* @__PURE__ */ jsx13(Tooltip2, {
1971
- variant: "chart",
1972
- onOpenChange: (open) => setActiveId((current) => open ? item.id : current === item.id ? undefined : current),
1973
- content: /* @__PURE__ */ jsxs9(Fragment5, {
1974
- children: [
1975
- /* @__PURE__ */ jsx13("strong", {
1976
- children: item.label
1977
- }),
1978
- /* @__PURE__ */ jsxs9("span", {
1979
- children: [
1980
- formatValue(item.value),
1981
- " ",
1982
- unit
1983
- ]
1984
- })
1985
- ]
1986
- }),
1987
- className: "altertable-chart-column",
1988
- children: /* @__PURE__ */ jsxs9("button", {
1989
- "data-atbl-focus": "ring",
1990
- "data-atbl-control": "default",
1991
- type: "button",
1992
- tabIndex: -1,
1993
- className: "altertable-selectable-bars-item",
1994
- "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
1995
- children: [
1996
- /* @__PURE__ */ jsx13("span", {
1997
- className: "altertable-selectable-bars-area"
1998
- }),
1999
- /* @__PURE__ */ jsx13("span", {
2000
- className: "altertable-selectable-bars-label",
2001
- children: item.label
2002
- })
2003
- ]
2004
- })
2005
- }, item.id))
2124
+ children: items.map((item) => {
2125
+ const actions = chartActions.actions(itemActions?.(item) ?? [], item.label, `${formatValue(item.value)} ${unit}`);
2126
+ const action = getPrimaryExplorationAction(actions);
2127
+ const menuTrigger = {
2128
+ get current() {
2129
+ return menuTriggers.current.get(item.id) ?? null;
2130
+ }
2131
+ };
2132
+ return /* @__PURE__ */ jsx14(Fragment6, {
2133
+ children: /* @__PURE__ */ jsxs9("div", {
2134
+ className: "altertable-chart-item-actions",
2135
+ children: [
2136
+ /* @__PURE__ */ jsx14(Tooltip2, {
2137
+ variant: "chart",
2138
+ onOpenChange: (open) => setActiveId((current) => open ? item.id : current === item.id ? undefined : current),
2139
+ content: /* @__PURE__ */ jsxs9(Fragment7, {
2140
+ children: [
2141
+ /* @__PURE__ */ jsx14("strong", {
2142
+ children: item.label
2143
+ }),
2144
+ /* @__PURE__ */ jsxs9("span", {
2145
+ children: [
2146
+ formatValue(item.value),
2147
+ " ",
2148
+ unit
2149
+ ]
2150
+ })
2151
+ ]
2152
+ }),
2153
+ className: "altertable-chart-column",
2154
+ children: action ? /* @__PURE__ */ jsx14("button", {
2155
+ "data-atbl-focus": "ring",
2156
+ "data-atbl-control": "action",
2157
+ type: "button",
2158
+ className: "altertable-selectable-bars-item",
2159
+ "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. ${action.label}`,
2160
+ ...explorationMenuEvents(menuTrigger),
2161
+ onClick: (event) => action.onSelect(event.currentTarget),
2162
+ children: /* @__PURE__ */ jsx14("span", {
2163
+ className: "altertable-selectable-bars-area"
2164
+ })
2165
+ }) : actions.length ? /* @__PURE__ */ jsx14("button", {
2166
+ type: "button",
2167
+ "data-atbl-focus": "ring",
2168
+ "data-atbl-control": "action",
2169
+ className: "altertable-selectable-bars-item",
2170
+ "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. Actions`,
2171
+ ...explorationMenuEvents(menuTrigger),
2172
+ onClick: (event) => openExplorationMenu(menuTrigger, event),
2173
+ children: /* @__PURE__ */ jsx14("span", {
2174
+ className: "altertable-selectable-bars-area"
2175
+ })
2176
+ }) : /* @__PURE__ */ jsx14("button", {
2177
+ "data-atbl-focus": "ring",
2178
+ "data-atbl-control": "default",
2179
+ type: "button",
2180
+ tabIndex: -1,
2181
+ className: "altertable-selectable-bars-item",
2182
+ "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
2183
+ children: /* @__PURE__ */ jsx14("span", {
2184
+ className: "altertable-selectable-bars-area"
2185
+ })
2186
+ })
2187
+ }),
2188
+ /* @__PURE__ */ jsx14("div", {
2189
+ className: "altertable-chart-item-label-row",
2190
+ children: actions.length ? /* @__PURE__ */ jsxs9(MenuTrigger2, {
2191
+ children: [
2192
+ /* @__PURE__ */ jsxs9(PressButton, {
2193
+ className: "altertable-selectable-bars-label",
2194
+ variant: "ghost",
2195
+ size: "compact",
2196
+ ...explorationMenuEvents(menuTrigger),
2197
+ ref: (element) => {
2198
+ if (element)
2199
+ menuTriggers.current.set(item.id, element);
2200
+ else
2201
+ menuTriggers.current.delete(item.id);
2202
+ },
2203
+ "aria-label": `${item.label}: Actions`,
2204
+ children: [
2205
+ item.label,
2206
+ /* @__PURE__ */ jsx14(AppIcon2, {
2207
+ name: "disclosure",
2208
+ size: 12
2209
+ })
2210
+ ]
2211
+ }),
2212
+ /* @__PURE__ */ jsx14(ExplorationActionMenu, {
2213
+ actions,
2214
+ ariaLabel: item.label,
2215
+ triggerRef: menuTrigger,
2216
+ placement: "bottom"
2217
+ })
2218
+ ]
2219
+ }) : /* @__PURE__ */ jsx14("span", {
2220
+ className: "altertable-selectable-bars-label",
2221
+ children: item.label
2222
+ })
2223
+ })
2224
+ ]
2225
+ })
2226
+ }, item.id);
2227
+ })
2006
2228
  })
2007
2229
  ]
2008
2230
  })
2009
- })
2231
+ }),
2232
+ chartActions.feedback
2010
2233
  ]
2011
2234
  });
2012
2235
  }
@@ -2016,7 +2239,7 @@ import {
2016
2239
  Radio as AriaRadio,
2017
2240
  Label
2018
2241
  } from "react-aria-components";
2019
- import { jsx as jsx14, jsxs as jsxs10, Fragment as Fragment6 } from "react/jsx-runtime";
2242
+ import { jsx as jsx15, jsxs as jsxs10, Fragment as Fragment8 } from "react/jsx-runtime";
2020
2243
  function RadioGroup({
2021
2244
  label,
2022
2245
  className,
@@ -2027,7 +2250,7 @@ function RadioGroup({
2027
2250
  ...props,
2028
2251
  className: classNames("altertable-radio-group", className),
2029
2252
  children: [
2030
- /* @__PURE__ */ jsx14(Label, {
2253
+ /* @__PURE__ */ jsx15(Label, {
2031
2254
  className: "altertable-control-label",
2032
2255
  children: label
2033
2256
  }),
@@ -2036,14 +2259,14 @@ function RadioGroup({
2036
2259
  });
2037
2260
  }
2038
2261
  function Radio({ className, children, ...props }) {
2039
- return /* @__PURE__ */ jsx14(AriaRadio, {
2262
+ return /* @__PURE__ */ jsx15(AriaRadio, {
2040
2263
  ...props,
2041
2264
  "data-atbl-control": "action",
2042
2265
  "data-atbl-focus": "ring",
2043
2266
  className: classNames("altertable-radio", className),
2044
- children: (state) => /* @__PURE__ */ jsxs10(Fragment6, {
2267
+ children: (state) => /* @__PURE__ */ jsxs10(Fragment8, {
2045
2268
  children: [
2046
- /* @__PURE__ */ jsx14("span", {
2269
+ /* @__PURE__ */ jsx15("span", {
2047
2270
  className: "altertable-radio-mark",
2048
2271
  "aria-hidden": "true"
2049
2272
  }),
@@ -2058,13 +2281,13 @@ function SegmentedControl({
2058
2281
  ...props
2059
2282
  }) {
2060
2283
  validateChoiceOptions(options);
2061
- return /* @__PURE__ */ jsx14(RadioGroup, {
2284
+ return /* @__PURE__ */ jsx15(RadioGroup, {
2062
2285
  ...props,
2063
2286
  orientation: "horizontal",
2064
2287
  className: classNames("altertable-segmented-control", className),
2065
- children: /* @__PURE__ */ jsx14("div", {
2288
+ children: /* @__PURE__ */ jsx15("div", {
2066
2289
  className: "altertable-segmented-options",
2067
- children: options.map((option) => /* @__PURE__ */ jsx14(Radio, {
2290
+ children: options.map((option) => /* @__PURE__ */ jsx15(Radio, {
2068
2291
  value: option.id,
2069
2292
  "data-atbl-internal-surface": "option",
2070
2293
  children: option.label
@@ -2073,7 +2296,7 @@ function SegmentedControl({
2073
2296
  });
2074
2297
  }
2075
2298
  // src/react/ui/CheckboxGroup.tsx
2076
- import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
2299
+ import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
2077
2300
  function CheckboxGroup({
2078
2301
  label,
2079
2302
  values,
@@ -2089,10 +2312,10 @@ function CheckboxGroup({
2089
2312
  disabled,
2090
2313
  className: classNames("altertable-checkbox-group", className),
2091
2314
  children: [
2092
- /* @__PURE__ */ jsx15("legend", {
2315
+ /* @__PURE__ */ jsx16("legend", {
2093
2316
  children: label
2094
2317
  }),
2095
- /* @__PURE__ */ jsx15(CheckboxGroupContext, {
2318
+ /* @__PURE__ */ jsx16(CheckboxGroupContext, {
2096
2319
  value: {
2097
2320
  values,
2098
2321
  disabled,
@@ -2106,17 +2329,59 @@ function CheckboxGroup({
2106
2329
  });
2107
2330
  }
2108
2331
  // src/react/ui/ComposedChart.tsx
2109
- import { useState as useState5 } from "react";
2332
+ import {
2333
+ useState as useState7,
2334
+ useCallback as useCallback2
2335
+ } from "react";
2110
2336
 
2111
2337
  // src/react/ui/ComposedChartLegend.tsx
2338
+ import { useState as useState6 } from "react";
2112
2339
  import { Legend } from "recharts";
2113
- import { jsx as jsx16, jsxs as jsxs12, Fragment as Fragment7 } from "react/jsx-runtime";
2340
+ import { jsx as jsx17, jsxs as jsxs12, Fragment as Fragment9 } from "react/jsx-runtime";
2114
2341
  var legendMarkerKinds = {
2115
2342
  square: "area",
2116
2343
  rect: "bar",
2117
2344
  line: "line",
2118
2345
  plainline: "line"
2119
2346
  };
2347
+ function createLegendItemKeys() {
2348
+ const identities = new WeakMap;
2349
+ let nextIdentity = 0;
2350
+ function identity(value) {
2351
+ let id = identities.get(value);
2352
+ if (id === undefined) {
2353
+ id = nextIdentity++;
2354
+ identities.set(value, id);
2355
+ }
2356
+ return id;
2357
+ }
2358
+ return (payload) => {
2359
+ const keys = payload.map((entry) => {
2360
+ const source = entry.payload;
2361
+ const id = source && typeof source === "object" && "id" in source ? source.id : undefined;
2362
+ if (typeof id === "string" || typeof id === "number")
2363
+ return ["series", typeof id, id].join(KEY_SEPARATOR);
2364
+ const key = entry.dataKey;
2365
+ if (typeof key === "string" || typeof key === "number")
2366
+ return ["data", typeof key, key].join(KEY_SEPARATOR);
2367
+ return ["object", identity(typeof key === "function" ? key : entry)].join(KEY_SEPARATOR);
2368
+ });
2369
+ const counts = new Map;
2370
+ for (const key of keys)
2371
+ counts.set(key, (counts.get(key) ?? 0) + 1);
2372
+ return keys.map((key, index) => {
2373
+ if (counts.get(key) === 1)
2374
+ return key;
2375
+ const entry = payload[index];
2376
+ const source = entry.payload;
2377
+ return [
2378
+ key,
2379
+ "object",
2380
+ identity(source && typeof source === "object" ? source : entry)
2381
+ ].join(KEY_SEPARATOR);
2382
+ });
2383
+ };
2384
+ }
2120
2385
  function LegendContent({
2121
2386
  payload = [],
2122
2387
  maxVisibleItems,
@@ -2134,10 +2399,12 @@ function LegendContent({
2134
2399
  onMouseLeave,
2135
2400
  "aria-label": ariaLabel
2136
2401
  }) {
2402
+ const [getItemKeys] = useState6(createLegendItemKeys);
2403
+ const itemKeys = getItemKeys(payload);
2137
2404
  if (!payload.some((entry) => entry.type !== "none"))
2138
2405
  return null;
2139
2406
  const vertical = layout === "vertical" || layout === "auto" && (position === "left" || position === "right");
2140
- return /* @__PURE__ */ jsx16(ChartLegend, {
2407
+ return /* @__PURE__ */ jsx17(ChartLegend, {
2141
2408
  "aria-label": ariaLabel,
2142
2409
  className: position === "top" || position == null && verticalAlign === "top" ? "altertable-composed-chart-legend-above" : position === "bottom" || position == null && verticalAlign !== "middle" && !vertical ? "altertable-composed-chart-legend-below" : undefined,
2143
2410
  maxVisibleItems,
@@ -2150,9 +2417,9 @@ function LegendContent({
2150
2417
  const kind = iconType ? legendMarkerKinds[type ?? "none"] ?? "point" : "square";
2151
2418
  const formatLabel = entry.formatter ?? formatter;
2152
2419
  const label = formatLabel ? formatLabel(entry.value, entry, index) : entry.value;
2153
- const content = /* @__PURE__ */ jsxs12(Fragment7, {
2420
+ const content = /* @__PURE__ */ jsxs12(Fragment9, {
2154
2421
  children: [
2155
- type !== "none" && (entry.legendIcon ?? /* @__PURE__ */ jsx16(ChartLegend.Marker, {
2422
+ type !== "none" && (entry.legendIcon ?? /* @__PURE__ */ jsx17(ChartLegend.Marker, {
2156
2423
  kind,
2157
2424
  color: entry.inactive ? inactiveColor : entry.color,
2158
2425
  style: {
@@ -2160,17 +2427,17 @@ function LegendContent({
2160
2427
  height: kind === "square" ? iconSize : iconSize * 0.6
2161
2428
  }
2162
2429
  })),
2163
- /* @__PURE__ */ jsx16(ChartLegend.Label, {
2430
+ /* @__PURE__ */ jsx17(ChartLegend.Label, {
2164
2431
  style: labelStyle,
2165
2432
  children: label
2166
2433
  })
2167
2434
  ]
2168
2435
  });
2169
- return /* @__PURE__ */ jsx16(ChartLegend.Item, {
2436
+ return /* @__PURE__ */ jsx17(ChartLegend.Item, {
2170
2437
  inactive: entry.inactive,
2171
2438
  onMouseEnter: onMouseEnter ? (event) => onMouseEnter(entry, index, event) : undefined,
2172
2439
  onMouseLeave: onMouseLeave ? (event) => onMouseLeave(entry, index, event) : undefined,
2173
- children: onClick ? /* @__PURE__ */ jsx16("button", {
2440
+ children: onClick ? /* @__PURE__ */ jsx17("button", {
2174
2441
  type: "button",
2175
2442
  "data-atbl-control": "action",
2176
2443
  "data-atbl-focus": "ring",
@@ -2178,7 +2445,7 @@ function LegendContent({
2178
2445
  onClick: (event) => onClick(entry, index, event),
2179
2446
  children: content
2180
2447
  }) : content
2181
- }, index);
2448
+ }, itemKeys[index]);
2182
2449
  })
2183
2450
  });
2184
2451
  }
@@ -2186,10 +2453,10 @@ function ComposedChartLegend({
2186
2453
  maxVisibleItems,
2187
2454
  ...props
2188
2455
  }) {
2189
- return /* @__PURE__ */ jsx16(Legend, {
2456
+ return /* @__PURE__ */ jsx17(Legend, {
2190
2457
  iconSize: 8,
2191
2458
  inactiveColor: "var(--atbl-muted)",
2192
- content: /* @__PURE__ */ jsx16(LegendContent, {
2459
+ content: /* @__PURE__ */ jsx17(LegendContent, {
2193
2460
  maxVisibleItems
2194
2461
  }),
2195
2462
  ...props
@@ -2209,7 +2476,21 @@ import {
2209
2476
  LabelList,
2210
2477
  ErrorBar
2211
2478
  } from "recharts";
2212
- import { jsx as jsx17 } from "react/jsx-runtime";
2479
+ import { jsx as jsx18 } from "react/jsx-runtime";
2480
+ function findNearestSeriesId(hoveredSeriesId, points, position) {
2481
+ if (!position || hoveredSeriesId != null && !points.has(hoveredSeriesId))
2482
+ return hoveredSeriesId;
2483
+ let selected = hoveredSeriesId;
2484
+ let distance = Infinity;
2485
+ for (const [id, point] of points) {
2486
+ const candidate = Math.hypot(point.x - position.x, point.y - position.y);
2487
+ if (candidate < distance) {
2488
+ distance = candidate;
2489
+ selected = id;
2490
+ }
2491
+ }
2492
+ return selected;
2493
+ }
2213
2494
  function ComposedChartRoot({
2214
2495
  data,
2215
2496
  ariaLabel,
@@ -2219,25 +2500,100 @@ function ComposedChartRoot({
2219
2500
  className,
2220
2501
  ...props
2221
2502
  }) {
2222
- const [pointerFocus, setPointerFocus] = useState5(false);
2223
- return /* @__PURE__ */ jsx17("section", {
2224
- className: ["altertable-composed-chart", className].filter(Boolean).join(" "),
2225
- "aria-label": ariaLabel,
2226
- "data-atbl-internal-pointer-focus": pointerFocus || undefined,
2227
- onPointerDownCapture: () => setPointerFocus(true),
2228
- onKeyDownCapture: () => setPointerFocus(false),
2229
- onBlurCapture: (event) => {
2230
- if (!event.currentTarget.contains(event.relatedTarget))
2231
- setPointerFocus(false);
2503
+ const [hasPointerFocus, setHasPointerFocus] = useState7(false);
2504
+ const [isPointerInspection, setIsPointerInspection] = useState7(false);
2505
+ const [hoveredSeriesId, setHoveredSeriesId] = useState7(null);
2506
+ const [pointerPosition, setPointerPosition] = useState7(null);
2507
+ const [points, setPoints] = useState7(() => new Map);
2508
+ const registerPoint = useCallback2((id, x, y) => {
2509
+ setPoints((current) => new Map(current).set(id, { x, y }));
2510
+ return () => setPoints((current) => {
2511
+ const next = new Map(current);
2512
+ next.delete(id);
2513
+ return next;
2514
+ });
2515
+ }, []);
2516
+ function trackPointer(event) {
2517
+ const svg = event.currentTarget.querySelector('svg[role="application"]');
2518
+ if (!(svg instanceof SVGSVGElement) || !(event.target instanceof Node) || !svg.contains(event.target)) {
2519
+ resetPointerInspection();
2520
+ return false;
2521
+ }
2522
+ setIsPointerInspection(true);
2523
+ if (hoveredSeriesId != null && !points.has(hoveredSeriesId)) {
2524
+ setPointerPosition(null);
2525
+ return true;
2526
+ }
2527
+ const matrix = svg.getScreenCTM();
2528
+ if (!matrix)
2529
+ return true;
2530
+ const point = new DOMPoint(event.clientX, event.clientY).matrixTransform(matrix.inverse());
2531
+ setPointerPosition({ x: point.x, y: point.y });
2532
+ return true;
2533
+ }
2534
+ function resetPointerInspection() {
2535
+ setIsPointerInspection(false);
2536
+ setHoveredSeriesId(null);
2537
+ setPointerPosition(null);
2538
+ }
2539
+ const activeSeriesId = findNearestSeriesId(hoveredSeriesId, points, pointerPosition);
2540
+ const [seriesIds, setSeriesIds] = useState7(() => new Set);
2541
+ const registerSeries = useCallback2((id) => {
2542
+ setSeriesIds((current) => new Set(current).add(id));
2543
+ return () => {
2544
+ setSeriesIds((current) => {
2545
+ const next = new Set(current);
2546
+ next.delete(id);
2547
+ return next;
2548
+ });
2549
+ };
2550
+ }, []);
2551
+ return /* @__PURE__ */ jsx18(ChartInteractionContext.Provider, {
2552
+ value: {
2553
+ isPointerInspection,
2554
+ activeSeriesId,
2555
+ activePoint: activeSeriesId == null ? undefined : points.get(activeSeriesId),
2556
+ registerPoint,
2557
+ setHoveredSeriesId,
2558
+ seriesCount: seriesIds.size,
2559
+ registerSeries
2232
2560
  },
2233
- children: /* @__PURE__ */ jsx17(RechartsComposedChart, {
2234
- "data-atbl-focus": "inset",
2235
- ...props,
2236
- data,
2237
- width,
2238
- height,
2239
- responsive,
2240
- title: ariaLabel
2561
+ children: /* @__PURE__ */ jsx18("section", {
2562
+ className: classNames("altertable-composed-chart", className),
2563
+ "aria-label": ariaLabel,
2564
+ "data-atbl-internal-pointer-focus": hasPointerFocus || undefined,
2565
+ onPointerDownCapture: (event) => {
2566
+ setHasPointerFocus(trackPointer(event));
2567
+ },
2568
+ onPointerOverCapture: trackPointer,
2569
+ onPointerMoveCapture: trackPointer,
2570
+ onPointerLeave: (event) => {
2571
+ if (event.pointerType !== "touch") {
2572
+ resetPointerInspection();
2573
+ }
2574
+ },
2575
+ onKeyDownCapture: () => {
2576
+ setHasPointerFocus(false);
2577
+ resetPointerInspection();
2578
+ },
2579
+ onBlurCapture: (event) => {
2580
+ if (!event.currentTarget.contains(event.relatedTarget)) {
2581
+ setHasPointerFocus(false);
2582
+ resetPointerInspection();
2583
+ }
2584
+ },
2585
+ children: /* @__PURE__ */ jsx18(ChartDateAxes, {
2586
+ data,
2587
+ children: /* @__PURE__ */ jsx18(RechartsComposedChart, {
2588
+ "data-atbl-focus": "inset",
2589
+ ...props,
2590
+ data,
2591
+ width,
2592
+ height,
2593
+ responsive,
2594
+ "aria-label": ariaLabel
2595
+ })
2596
+ })
2241
2597
  })
2242
2598
  });
2243
2599
  }
@@ -2263,17 +2619,71 @@ var ComposedChart = Object.assign(ComposedChartRoot, {
2263
2619
  ErrorBar
2264
2620
  });
2265
2621
  // src/react/ui/FunnelChart.tsx
2266
- import { Fragment as Fragment8, useEffect, useRef as useRef3, useState as useState6 } from "react";
2622
+ import { Fragment as Fragment10, useEffect as useEffect4, useRef as useRef6, useState as useState8 } from "react";
2267
2623
 
2268
2624
  // src/react/ui/useSvgId.ts
2269
- import { useId as useId2 } from "react";
2625
+ import { useId as useId3 } from "react";
2626
+ var svgIdCharacterPattern = /[a-zA-Z0-9-]/;
2270
2627
  function useSvgId() {
2271
- const id = useId2();
2272
- return `svg-${Array.from(id, (character) => /[a-zA-Z0-9-]/.test(character) ? character : `_${character.codePointAt(0).toString(16)}_`).join("")}`;
2628
+ const id = useId3();
2629
+ const encodedId = Array.from(id, (character) => svgIdCharacterPattern.test(character) ? character : `_${character.codePointAt(0).toString(16)}_`).join("");
2630
+ return ["svg", encodedId].join("-");
2273
2631
  }
2274
2632
 
2275
2633
  // src/react/ui/FunnelChart.tsx
2276
- import { jsx as jsx18, jsxs as jsxs13, Fragment as Fragment9 } from "react/jsx-runtime";
2634
+ import { jsx as jsx19, jsxs as jsxs13, Fragment as Fragment11 } from "react/jsx-runtime";
2635
+ function createFunnelModel(steps, series, chartId) {
2636
+ for (const [kind, items] of [
2637
+ ["funnel step", steps],
2638
+ ["funnel series", series]
2639
+ ]) {
2640
+ const ids = new Set;
2641
+ for (const item of items) {
2642
+ invariant(item.id.trim().length > 0 && !ids.has(item.id), `${kind} chart IDs must be nonblank and unique.`);
2643
+ ids.add(item.id);
2644
+ }
2645
+ }
2646
+ for (const item of series) {
2647
+ invariant(item.values.length === steps.length, "funnel chart counts must align with steps.");
2648
+ item.values.forEach((value, index) => {
2649
+ invariant(Number.isFinite(value) && value >= 0, "funnel chart counts must be finite and nonnegative.");
2650
+ invariant(index === 0 || value <= item.values[index - 1], "funnel chart counts must be nonincreasing.");
2651
+ });
2652
+ }
2653
+ const populations = series.map((item, index) => ({
2654
+ id: item.id,
2655
+ label: item.label,
2656
+ color: `var(--atbl-chart-${index % 8 + 1})`,
2657
+ hatchId: [chartId, "hatch", index].join("-")
2658
+ }));
2659
+ const rows = steps.map((step, index) => ({
2660
+ id: step.id,
2661
+ label: step.label,
2662
+ index,
2663
+ readings: new Map(series.map((item, seriesIndex) => {
2664
+ const first = item.values[0] ?? 0;
2665
+ const current = item.values[index];
2666
+ const previous = item.values[Math.max(0, index - 1)];
2667
+ const dropped = previous - current;
2668
+ const conversion = first > 0 ? current / first : null;
2669
+ const dropOff = first > 0 ? dropped / first : null;
2670
+ return [
2671
+ item.id,
2672
+ {
2673
+ population: populations[seriesIndex],
2674
+ current,
2675
+ previous,
2676
+ dropped,
2677
+ conversion,
2678
+ dropOff,
2679
+ conversionPercent: (conversion ?? 0) * 100,
2680
+ dropOffPercent: (dropOff ?? (index === 0 ? 1 : 0)) * 100
2681
+ }
2682
+ ];
2683
+ }))
2684
+ }));
2685
+ return { populations, rows };
2686
+ }
2277
2687
  function FunnelChart({
2278
2688
  steps,
2279
2689
  series,
@@ -2283,14 +2693,14 @@ function FunnelChart({
2283
2693
  formatValue = formatNumber2
2284
2694
  }) {
2285
2695
  const chartId = useSvgId();
2286
- const [highlighted, setHighlighted] = useState6(null);
2287
- const clearTimer = useRef3(null);
2696
+ const [highlighted, setHighlighted] = useState8(null);
2697
+ const clearTimer = useRef6(null);
2288
2698
  function cancelClear() {
2289
2699
  if (clearTimer.current !== null)
2290
2700
  clearTimeout(clearTimer.current);
2291
2701
  clearTimer.current = null;
2292
2702
  }
2293
- useEffect(() => cancelClear, []);
2703
+ useEffect4(() => cancelClear, []);
2294
2704
  function highlight(id, conversion, step) {
2295
2705
  cancelClear();
2296
2706
  setHighlighted({ id, conversion, step });
@@ -2303,165 +2713,111 @@ function FunnelChart({
2303
2713
  cancelClear();
2304
2714
  clearTimer.current = setTimeout(() => setHighlighted(null), 100);
2305
2715
  }
2306
- for (const [kind, items] of [
2307
- ["funnel step", steps],
2308
- ["funnel series", series]
2309
- ]) {
2310
- const ids = new Set;
2311
- for (const item of items) {
2312
- invariant(item.id.trim().length > 0 && !ids.has(item.id), `${kind} chart IDs must be nonblank and unique.`);
2313
- ids.add(item.id);
2314
- }
2315
- }
2316
- for (const item of series) {
2317
- invariant(item.values.length === steps.length, "funnel chart counts must align with steps.");
2318
- item.values.forEach((value, index) => {
2319
- invariant(Number.isFinite(value) && value >= 0, "funnel chart counts must be finite and nonnegative.");
2320
- invariant(index === 0 || value <= item.values[index - 1], "funnel chart counts must be nonincreasing.");
2321
- });
2322
- }
2323
- function reading(item, index) {
2324
- const first = item.values[0] ?? 0;
2325
- const current = item.values[index];
2326
- const previous = item.values[Math.max(0, index - 1)];
2327
- return {
2328
- current,
2329
- previous,
2330
- dropped: previous - current,
2331
- conversion: first > 0 ? current / first : null,
2332
- dropOff: first > 0 ? (previous - current) / first : null
2333
- };
2334
- }
2335
- const data = steps.map((step, index) => ({
2336
- label: step.label,
2337
- index,
2338
- ...Object.fromEntries(series.flatMap((item, seriesIndex) => {
2339
- const value = reading(item, index);
2340
- return [
2341
- [`conversion${seriesIndex}`, (value.conversion ?? 0) * 100],
2342
- [
2343
- `drop${seriesIndex}`,
2344
- (value.dropOff ?? (index === 0 ? 1 : 0)) * 100
2345
- ]
2346
- ];
2347
- }))
2348
- }));
2349
- return /* @__PURE__ */ jsx18("section", {
2716
+ const { populations, rows } = createFunnelModel(steps, series, chartId);
2717
+ return /* @__PURE__ */ jsx19("section", {
2350
2718
  className: classNames("altertable-funnel-chart", className),
2351
2719
  "aria-label": ariaLabel,
2352
2720
  onKeyDownCapture: clearHighlight,
2353
- children: steps.length === 0 || series.length === 0 ? /* @__PURE__ */ jsx18("span", {
2721
+ children: steps.length === 0 || series.length === 0 ? /* @__PURE__ */ jsx19("span", {
2354
2722
  children: "No data"
2355
- }) : /* @__PURE__ */ jsxs13(Fragment9, {
2723
+ }) : /* @__PURE__ */ jsxs13(Fragment11, {
2356
2724
  children: [
2357
- /* @__PURE__ */ jsx18("div", {
2358
- className: "altertable-funnel-summary",
2359
- children: series.map((item, index) => /* @__PURE__ */ jsxs13("div", {
2360
- children: [
2361
- /* @__PURE__ */ jsxs13("span", {
2725
+ /* @__PURE__ */ jsxs13("div", {
2726
+ className: "altertable-funnel-header",
2727
+ children: [
2728
+ /* @__PURE__ */ jsx19(ChartLegend, {
2729
+ "aria-label": "Funnel series",
2730
+ layout: "single-row",
2731
+ children: populations.map((item) => /* @__PURE__ */ jsxs13(ChartLegend.Item, {
2732
+ className: "altertable-funnel-summary-item",
2362
2733
  children: [
2363
- /* @__PURE__ */ jsx18(ChartLegend.Marker, {
2364
- kind: "square",
2365
- color: `var(--atbl-chart-${index % 8 + 1})`
2734
+ /* @__PURE__ */ jsxs13("span", {
2735
+ className: "altertable-funnel-series-label",
2736
+ children: [
2737
+ /* @__PURE__ */ jsx19(ChartLegend.Marker, {
2738
+ kind: "square",
2739
+ color: item.color
2740
+ }),
2741
+ /* @__PURE__ */ jsx19(ChartLegend.Label, {
2742
+ children: item.label
2743
+ })
2744
+ ]
2366
2745
  }),
2367
- item.label
2746
+ /* @__PURE__ */ jsx19("strong", {
2747
+ className: "altertable-funnel-series-value",
2748
+ children: formatPercent2(rows.at(-1)?.readings.get(item.id)?.conversion ?? null)
2749
+ })
2368
2750
  ]
2369
- }),
2370
- /* @__PURE__ */ jsx18("strong", {
2371
- children: formatPercent2(reading(item, steps.length - 1).conversion)
2372
- })
2373
- ]
2374
- }, item.id))
2375
- }),
2376
- /* @__PURE__ */ jsxs13("p", {
2377
- className: "altertable-analytics-note",
2378
- children: [
2379
- steps[0].label,
2380
- " → ",
2381
- steps.at(-1).label
2751
+ }, item.id))
2752
+ }),
2753
+ /* @__PURE__ */ jsxs13("p", {
2754
+ className: "altertable-funnel-path",
2755
+ children: [
2756
+ steps[0].label,
2757
+ " → ",
2758
+ steps.at(-1).label
2759
+ ]
2760
+ })
2382
2761
  ]
2383
2762
  }),
2384
- /* @__PURE__ */ jsx18("div", {
2763
+ /* @__PURE__ */ jsx19("div", {
2385
2764
  className: "altertable-funnel-scroll",
2386
- children: /* @__PURE__ */ jsx18("div", {
2765
+ children: /* @__PURE__ */ jsx19("div", {
2387
2766
  style: {
2388
2767
  minWidth: steps.length * Math.max(96, series.length * 40)
2389
2768
  },
2390
2769
  children: /* @__PURE__ */ jsxs13(ComposedChart, {
2391
- data,
2770
+ data: rows,
2392
2771
  ariaLabel: `${ariaLabel} plot`,
2393
2772
  height: 300,
2394
2773
  barCategoryGap: "4%",
2395
2774
  barGap: 1,
2396
2775
  onMouseLeave: clearHighlight,
2397
2776
  children: [
2398
- /* @__PURE__ */ jsx18(ComposedChart.CartesianGrid, {}),
2399
- /* @__PURE__ */ jsx18(ComposedChart.XAxis, {
2777
+ /* @__PURE__ */ jsx19(ComposedChart.CartesianGrid, {}),
2778
+ /* @__PURE__ */ jsx19(ComposedChart.XAxis, {
2400
2779
  dataKey: "label",
2401
2780
  interval: 0,
2402
2781
  height: 48
2403
2782
  }),
2404
- /* @__PURE__ */ jsx18(ComposedChart.YAxis, {
2783
+ /* @__PURE__ */ jsx19(ComposedChart.YAxis, {
2405
2784
  domain: [0, 100],
2406
2785
  width: 42,
2407
- tickFormatter: (value) => `${value}%`
2786
+ tickFormatter: (value) => formatPercent2(value / 100)
2408
2787
  }),
2409
- /* @__PURE__ */ jsx18("defs", {
2410
- children: series.map((item, index) => /* @__PURE__ */ jsxs13(Fragment8, {
2788
+ /* @__PURE__ */ jsx19("defs", {
2789
+ children: populations.map((item) => /* @__PURE__ */ jsxs13("pattern", {
2790
+ id: item.hatchId,
2791
+ patternUnits: "userSpaceOnUse",
2792
+ width: "6",
2793
+ height: "6",
2794
+ patternTransform: "rotate(45)",
2411
2795
  children: [
2412
- /* @__PURE__ */ jsxs13("linearGradient", {
2413
- id: `${chartId}-gradient-${index}`,
2796
+ /* @__PURE__ */ jsx19("rect", {
2797
+ width: "8",
2798
+ height: "8",
2799
+ fill: item.color,
2800
+ fillOpacity: 0.16
2801
+ }),
2802
+ /* @__PURE__ */ jsx19("line", {
2414
2803
  x1: "0",
2804
+ y1: "0",
2415
2805
  x2: "0",
2416
- y1: "1",
2417
- y2: "0",
2418
- children: [
2419
- /* @__PURE__ */ jsx18("stop", {
2420
- offset: "0%",
2421
- stopColor: `var(--atbl-chart-${index % 8 + 1})`,
2422
- stopOpacity: 0.5
2423
- }),
2424
- /* @__PURE__ */ jsx18("stop", {
2425
- offset: "100%",
2426
- stopColor: `var(--atbl-chart-${index % 8 + 1})`,
2427
- stopOpacity: 0.7
2428
- })
2429
- ]
2430
- }),
2431
- /* @__PURE__ */ jsxs13("pattern", {
2432
- id: `${chartId}-hatch-${index}`,
2433
- patternUnits: "userSpaceOnUse",
2434
- width: "6",
2435
- height: "6",
2436
- patternTransform: "rotate(45)",
2437
- children: [
2438
- /* @__PURE__ */ jsx18("rect", {
2439
- width: "8",
2440
- height: "8",
2441
- fill: `var(--atbl-chart-${index % 8 + 1})`,
2442
- fillOpacity: 0.16
2443
- }),
2444
- /* @__PURE__ */ jsx18("line", {
2445
- x1: "0",
2446
- y1: "0",
2447
- x2: "0",
2448
- y2: "8",
2449
- stroke: `var(--atbl-chart-${index % 8 + 1})`,
2450
- strokeOpacity: 0.4,
2451
- strokeWidth: "2"
2452
- })
2453
- ]
2806
+ y2: "8",
2807
+ stroke: item.color,
2808
+ strokeOpacity: 0.4,
2809
+ strokeWidth: "2"
2454
2810
  })
2455
2811
  ]
2456
2812
  }, item.id))
2457
2813
  }),
2458
- series.map((item, index) => /* @__PURE__ */ jsxs13(Fragment8, {
2814
+ populations.map((item) => /* @__PURE__ */ jsxs13(Fragment10, {
2459
2815
  children: [
2460
- /* @__PURE__ */ jsx18(ComposedChart.Bar, {
2461
- dataKey: `conversion${index}`,
2816
+ /* @__PURE__ */ jsx19(ComposedChart.Bar, {
2817
+ dataKey: (row) => row.readings.get(item.id)?.conversionPercent ?? 0,
2462
2818
  name: item.label,
2463
2819
  stackId: item.id,
2464
- fill: `url(#${chartId}-gradient-${index})`,
2820
+ fill: item.color,
2465
2821
  radius: 0,
2466
2822
  maxBarSize: undefined,
2467
2823
  activeBar: false,
@@ -2471,11 +2827,11 @@ function FunnelChart({
2471
2827
  onMouseLeave: scheduleClear,
2472
2828
  onClick: (bar) => highlight(item.id, true, bar.payload.index)
2473
2829
  }),
2474
- /* @__PURE__ */ jsx18(ComposedChart.Bar, {
2475
- dataKey: `drop${index}`,
2830
+ /* @__PURE__ */ jsx19(ComposedChart.Bar, {
2831
+ dataKey: (row) => row.readings.get(item.id)?.dropOffPercent ?? 0,
2476
2832
  name: `${item.label} drop-off`,
2477
2833
  stackId: item.id,
2478
- fill: `url(#${chartId}-hatch-${index})`,
2834
+ fill: `url(#${item.hatchId})`,
2479
2835
  opacity: !highlighted || highlighted.id === item.id ? 1 : 0.2,
2480
2836
  onMouseEnter: (bar) => highlight(item.id, false, bar.payload.index),
2481
2837
  onMouseLeave: scheduleClear,
@@ -2486,45 +2842,50 @@ function FunnelChart({
2486
2842
  })
2487
2843
  ]
2488
2844
  }, item.id)),
2489
- /* @__PURE__ */ jsx18(ComposedChart.Tooltip, {
2490
- content: ({ active, payload }) => {
2491
- const index = payload?.[0]?.payload.index;
2492
- if (!active || typeof index !== "number")
2845
+ /* @__PURE__ */ jsx19(ComposedChart.Tooltip, {
2846
+ content: ({ active, activeIndex }) => {
2847
+ const row = activeIndex == null ? undefined : rows[Number(activeIndex)];
2848
+ if (!active || !row)
2493
2849
  return null;
2494
- const tooltipItems = series.filter((item) => !highlighted || highlighted.step !== index || item.id === highlighted.id).flatMap((item) => {
2495
- const value = reading(item, index);
2496
- const selected = highlighted?.step === index;
2850
+ const tooltipItems = [...row.readings.values()].filter((value) => !highlighted || highlighted.step !== row.index || value.population.id === highlighted.id).flatMap((value) => {
2851
+ const item = value.population;
2852
+ const selected = highlighted?.step === row.index;
2497
2853
  const readings = selected ? [highlighted.conversion] : [true, false];
2498
- const seriesIndex = series.indexOf(item);
2499
- return readings.map((conversion) => ({
2500
- name: item.label,
2501
- graphicalItemId: `${item.id}-${conversion ? "conversion" : "drop-off"}`,
2502
- dataKey: `${item.id}-${conversion ? "conversion" : "drop-off"}`,
2503
- color: `var(--atbl-chart-${seriesIndex % 8 + 1})`,
2504
- value: (conversion ? value.conversion : value.dropOff) ?? 0,
2505
- formatter: () => /* @__PURE__ */ jsxs13(Fragment9, {
2506
- children: [
2507
- formatPercent2(conversion ? value.conversion : value.dropOff),
2508
- " ",
2509
- conversion ? "conversion" : "drop-off",
2510
- /* @__PURE__ */ jsxs13("span", {
2511
- className: "altertable-funnel-tooltip-detail",
2512
- children: [
2513
- formatValue(conversion ? value.current : value.dropped),
2514
- " ",
2515
- "of ",
2516
- formatValue(value.previous),
2517
- " ",
2518
- unit
2519
- ]
2520
- })
2521
- ]
2522
- })
2523
- }));
2854
+ return readings.map((conversion) => {
2855
+ const key = [
2856
+ item.id,
2857
+ conversion ? "conversion" : "drop-off"
2858
+ ].join(KEY_SEPARATOR);
2859
+ return {
2860
+ name: item.label,
2861
+ graphicalItemId: key,
2862
+ dataKey: key,
2863
+ color: item.color,
2864
+ value: (conversion ? value.conversion : value.dropOff) ?? 0,
2865
+ formatter: () => /* @__PURE__ */ jsxs13(Fragment11, {
2866
+ children: [
2867
+ formatPercent2(conversion ? value.conversion : value.dropOff),
2868
+ " ",
2869
+ conversion ? "conversion" : "drop-off",
2870
+ /* @__PURE__ */ jsxs13("span", {
2871
+ className: "altertable-funnel-tooltip-detail",
2872
+ children: [
2873
+ formatValue(conversion ? value.current : value.dropped),
2874
+ " ",
2875
+ "of ",
2876
+ formatValue(value.previous),
2877
+ " ",
2878
+ unit
2879
+ ]
2880
+ })
2881
+ ]
2882
+ })
2883
+ };
2884
+ });
2524
2885
  });
2525
- return /* @__PURE__ */ jsx18(ChartTooltipContent, {
2886
+ return /* @__PURE__ */ jsx19(ChartTooltipContent, {
2526
2887
  active: true,
2527
- label: steps[index].label,
2888
+ label: row.label,
2528
2889
  payload: tooltipItems
2529
2890
  });
2530
2891
  }
@@ -2533,57 +2894,48 @@ function FunnelChart({
2533
2894
  })
2534
2895
  })
2535
2896
  }),
2536
- /* @__PURE__ */ jsx18("ul", {
2897
+ /* @__PURE__ */ jsx19("ul", {
2537
2898
  className: "altertable-sr-only",
2538
- children: steps.map((step, index) => /* @__PURE__ */ jsxs13("li", {
2899
+ children: rows.map((row) => /* @__PURE__ */ jsxs13("li", {
2539
2900
  children: [
2540
- step.label,
2541
- series.map((item) => {
2542
- const value = reading(item, index);
2543
- return /* @__PURE__ */ jsxs13("span", {
2544
- children: [
2545
- " ",
2546
- "· ",
2547
- item.label,
2548
- ": ",
2549
- formatValue(value.current),
2550
- " ",
2551
- unit,
2552
- ",",
2553
- " ",
2554
- formatPercent2(value.conversion),
2555
- " conversion,",
2556
- " ",
2557
- formatValue(value.dropped),
2558
- " dropped off"
2559
- ]
2560
- }, item.id);
2561
- })
2901
+ row.label,
2902
+ [...row.readings.values()].map((value) => /* @__PURE__ */ jsxs13("span", {
2903
+ children: [
2904
+ " ",
2905
+ "· ",
2906
+ value.population.label,
2907
+ ": ",
2908
+ formatValue(value.current),
2909
+ " ",
2910
+ unit,
2911
+ ", ",
2912
+ formatPercent2(value.conversion),
2913
+ " conversion,",
2914
+ " ",
2915
+ formatValue(value.dropped),
2916
+ " dropped off"
2917
+ ]
2918
+ }, value.population.id))
2562
2919
  ]
2563
- }, step.id))
2920
+ }, row.id))
2564
2921
  })
2565
2922
  ]
2566
2923
  })
2567
2924
  });
2568
2925
  }
2569
2926
  // src/react/ui/RetentionChart.tsx
2570
- import { Fragment as Fragment10 } from "react";
2571
- import { jsx as jsx19, jsxs as jsxs14, Fragment as Fragment11 } from "react/jsx-runtime";
2572
- function RetentionChart({
2573
- series,
2574
- unit,
2575
- ariaLabel,
2576
- className,
2577
- formatValue = formatNumber2
2578
- }) {
2927
+ import { Fragment as Fragment12 } from "react";
2928
+ import { jsx as jsx20, jsxs as jsxs14, Fragment as Fragment13 } from "react/jsx-runtime";
2929
+ function createRetentionModel(series, unit, formatValue) {
2579
2930
  const ids = new Set;
2580
- const offsets = new Map;
2581
- for (const item of series) {
2931
+ const rowsByOffset = new Map;
2932
+ const cohorts = series.map((item, index) => {
2582
2933
  invariant(item.id.trim().length > 0 && !ids.has(item.id), "retention series chart IDs must be nonblank and unique.");
2583
2934
  ids.add(item.id);
2584
2935
  invariant(Number.isFinite(item.cohortSize) && item.cohortSize >= 0, "retention chart counts must be finite and nonnegative.");
2585
2936
  const seen = new Set;
2586
- for (const point of item.points) {
2937
+ let previous;
2938
+ const readings = [...item.points].sort((a, b) => a.offset - b.offset).map((point) => {
2587
2939
  invariant(Number.isSafeInteger(point.offset) && point.offset >= 0 && !seen.has(point.offset), "retention chart offsets must be unique nonnegative integers within each series.");
2588
2940
  seen.add(point.offset);
2589
2941
  invariant(point.rate === null || Number.isFinite(point.rate) && point.rate >= 0 && point.rate <= 1, "retention chart rates must be finite fractions between 0 and 1, or null.");
@@ -2592,64 +2944,84 @@ function RetentionChart({
2592
2944
  invariant(Number.isFinite(point.retainedCount) && point.retainedCount >= 0, "retention chart counts must be finite and nonnegative.");
2593
2945
  invariant(point.retainedCount <= item.cohortSize, "retention chart retained counts cannot exceed cohort size.");
2594
2946
  }
2595
- invariant(!offsets.has(point.offset) || offsets.get(point.offset) === point.label, "retention chart labels must agree for the same offset.");
2596
- offsets.set(point.offset, point.label);
2597
- }
2598
- }
2599
- const data = [...offsets].sort(([a], [b]) => a - b).map(([offset, label]) => ({
2600
- offset,
2601
- label,
2602
- ...Object.fromEntries(series.flatMap((_, index) => [
2603
- [`rate${index}`, null],
2604
- [`tail${index}`, null]
2605
- ]))
2606
- }));
2607
- series.forEach((item, index) => {
2608
- const points = [...item.points].sort((a, b) => a.offset - b.offset);
2609
- points.forEach((point, pointIndex) => {
2610
- const row = data.find((row) => row.offset === point.offset);
2611
- row[point.incomplete ? `tail${index}` : `rate${index}`] = point.rate === null ? null : point.rate * 100;
2612
- if (point.incomplete && pointIndex > 0) {
2613
- const previous = points[pointIndex - 1];
2614
- data.find((row) => row.offset === previous.offset)[`tail${index}`] = previous.rate === null ? null : previous.rate * 100;
2947
+ let row = rowsByOffset.get(point.offset);
2948
+ invariant(!row || row.label === point.label, "retention chart labels must agree for the same offset.");
2949
+ if (!row) {
2950
+ row = {
2951
+ offset: point.offset,
2952
+ label: point.label,
2953
+ readings: new Map
2954
+ };
2955
+ rowsByOffset.set(point.offset, row);
2956
+ }
2957
+ const percent = point.rate === null ? null : point.rate * 100;
2958
+ const reading = {
2959
+ point,
2960
+ completePercent: point.incomplete ? null : percent,
2961
+ incompletePercent: point.incomplete ? percent : null,
2962
+ description: point.rate === null || point.retainedCount === null ? "Not observed" : `${formatPercent2(point.rate)} · ${formatValue(point.retainedCount)} / ${formatValue(item.cohortSize)} ${unit}${point.incomplete ? " · Incomplete period" : ""}`
2963
+ };
2964
+ if (point.incomplete && previous) {
2965
+ previous.incompletePercent = previous.completePercent ?? previous.incompletePercent;
2615
2966
  }
2967
+ row.readings.set(item.id, reading);
2968
+ previous = reading;
2969
+ return reading;
2616
2970
  });
2971
+ return {
2972
+ id: item.id,
2973
+ label: item.label,
2974
+ color: `var(--atbl-chart-${index % 8 + 1})`,
2975
+ readings
2976
+ };
2617
2977
  });
2618
- return /* @__PURE__ */ jsx19("section", {
2978
+ const rows = [...rowsByOffset.values()].sort((a, b) => a.offset - b.offset);
2979
+ return { rows, rowsByOffset, cohorts };
2980
+ }
2981
+ function RetentionChart({
2982
+ series,
2983
+ unit,
2984
+ ariaLabel,
2985
+ className,
2986
+ formatValue = formatNumber2
2987
+ }) {
2988
+ const { rows, rowsByOffset, cohorts } = createRetentionModel(series, unit, formatValue);
2989
+ return /* @__PURE__ */ jsx20("section", {
2619
2990
  className: classNames("altertable-retention-chart", className),
2620
2991
  "aria-label": ariaLabel,
2621
- children: data.length === 0 ? /* @__PURE__ */ jsx19("span", {
2992
+ children: rows.length === 0 ? /* @__PURE__ */ jsx20("span", {
2622
2993
  children: "No data"
2623
- }) : /* @__PURE__ */ jsxs14(Fragment11, {
2994
+ }) : /* @__PURE__ */ jsxs14(Fragment13, {
2624
2995
  children: [
2625
2996
  /* @__PURE__ */ jsxs14(ComposedChart, {
2626
- data,
2997
+ data: rows,
2627
2998
  ariaLabel: `${ariaLabel} plot`,
2628
2999
  children: [
2629
- /* @__PURE__ */ jsx19(ComposedChart.CartesianGrid, {}),
2630
- /* @__PURE__ */ jsx19(ComposedChart.XAxis, {
3000
+ /* @__PURE__ */ jsx20(ComposedChart.CartesianGrid, {}),
3001
+ /* @__PURE__ */ jsx20(ComposedChart.XAxis, {
2631
3002
  dataKey: "offset",
2632
3003
  type: "number",
2633
- domain: [0, Math.max(1, ...offsets.keys())],
2634
- tickFormatter: (value) => offsets.get(Number(value)) ?? (data[0]?.label.replace(/\d+(?:\.\d+)?/, String(value)) || String(value))
3004
+ domain: [0, Math.max(1, rows.at(-1)?.offset ?? 0)],
3005
+ ticks: rows.map((row) => row.offset),
3006
+ tickFormatter: (value) => rowsByOffset.get(Number(value))?.label ?? ""
2635
3007
  }),
2636
- /* @__PURE__ */ jsx19(ComposedChart.YAxis, {
3008
+ /* @__PURE__ */ jsx20(ComposedChart.YAxis, {
2637
3009
  domain: [0, 100],
2638
3010
  width: 42,
2639
3011
  tickFormatter: (value) => `${value}%`
2640
3012
  }),
2641
- series.map((item, index) => /* @__PURE__ */ jsxs14(Fragment10, {
3013
+ cohorts.map((item) => /* @__PURE__ */ jsxs14(Fragment12, {
2642
3014
  children: [
2643
- /* @__PURE__ */ jsx19(ComposedChart.Line, {
2644
- dataKey: `rate${index}`,
3015
+ /* @__PURE__ */ jsx20(ComposedChart.Line, {
3016
+ dataKey: (row) => row.readings.get(item.id)?.completePercent ?? null,
2645
3017
  name: item.label,
2646
- stroke: `var(--atbl-chart-${index % 8 + 1})`,
3018
+ stroke: item.color,
2647
3019
  connectNulls: false
2648
3020
  }),
2649
- /* @__PURE__ */ jsx19(ComposedChart.Line, {
2650
- dataKey: `tail${index}`,
3021
+ /* @__PURE__ */ jsx20(ComposedChart.Line, {
3022
+ dataKey: (row) => row.readings.get(item.id)?.incompletePercent ?? null,
2651
3023
  name: item.label,
2652
- stroke: `var(--atbl-chart-${index % 8 + 1})`,
3024
+ stroke: item.color,
2653
3025
  strokeDasharray: "3 3",
2654
3026
  dot: false,
2655
3027
  activeDot: false,
@@ -2657,29 +3029,28 @@ function RetentionChart({
2657
3029
  })
2658
3030
  ]
2659
3031
  }, item.id)),
2660
- /* @__PURE__ */ jsx19(ComposedChart.Tooltip, {
3032
+ /* @__PURE__ */ jsx20(ComposedChart.Tooltip, {
2661
3033
  filterNull: false,
2662
- content: ({ active, payload }) => {
2663
- const offset = payload?.[0]?.payload.offset;
2664
- if (!active || typeof offset !== "number")
3034
+ content: ({ active, label }) => {
3035
+ const row = typeof label === "number" ? rowsByOffset.get(label) : undefined;
3036
+ if (!active || !row)
2665
3037
  return null;
2666
3038
  return /* @__PURE__ */ jsxs14(TooltipSurface, {
2667
3039
  "data-variant": "chart",
2668
3040
  role: "tooltip",
2669
3041
  children: [
2670
- /* @__PURE__ */ jsx19("strong", {
2671
- children: offsets.get(offset)
3042
+ /* @__PURE__ */ jsx20("strong", {
3043
+ children: row.label
2672
3044
  }),
2673
- series.map((item) => {
2674
- const point = item.points.find((point) => point.offset === offset);
2675
- if (!point)
3045
+ cohorts.map((item) => {
3046
+ const reading = row.readings.get(item.id);
3047
+ if (!reading)
2676
3048
  return null;
2677
3049
  return /* @__PURE__ */ jsxs14("span", {
2678
3050
  children: [
2679
3051
  item.label,
2680
- ":",
2681
- " ",
2682
- point.rate === null ? "Not observed" : `${formatPercent2(point.rate)} · ${formatValue(point.retainedCount)} / ${formatValue(item.cohortSize)} ${unit}${point.incomplete ? " · Incomplete period" : ""}`
3052
+ ": ",
3053
+ reading.description
2683
3054
  ]
2684
3055
  }, item.id);
2685
3056
  })
@@ -2689,35 +3060,35 @@ function RetentionChart({
2689
3060
  })
2690
3061
  ]
2691
3062
  }),
2692
- /* @__PURE__ */ jsx19(ChartLegend, {
3063
+ /* @__PURE__ */ jsx20(ChartLegend, {
2693
3064
  "aria-label": `${ariaLabel} cohorts`,
2694
- children: series.map((item, index) => /* @__PURE__ */ jsxs14(ChartLegend.Item, {
3065
+ children: cohorts.map((item) => /* @__PURE__ */ jsxs14(ChartLegend.Item, {
2695
3066
  children: [
2696
- /* @__PURE__ */ jsx19(ChartLegend.Marker, {
3067
+ /* @__PURE__ */ jsx20(ChartLegend.Marker, {
2697
3068
  kind: "square",
2698
- color: `var(--atbl-chart-${index % 8 + 1})`
3069
+ color: item.color
2699
3070
  }),
2700
- /* @__PURE__ */ jsx19(ChartLegend.Label, {
3071
+ /* @__PURE__ */ jsx20(ChartLegend.Label, {
2701
3072
  children: item.label
2702
3073
  })
2703
3074
  ]
2704
3075
  }, item.id))
2705
3076
  }),
2706
- /* @__PURE__ */ jsx19("ul", {
3077
+ /* @__PURE__ */ jsx20("ul", {
2707
3078
  className: "altertable-sr-only",
2708
- children: series.map((item) => /* @__PURE__ */ jsxs14("li", {
3079
+ "aria-label": `${ariaLabel} readings`,
3080
+ children: cohorts.map((item) => /* @__PURE__ */ jsxs14("li", {
2709
3081
  children: [
2710
3082
  item.label,
2711
- item.points.map((point) => /* @__PURE__ */ jsxs14("span", {
3083
+ item.readings.map((reading) => /* @__PURE__ */ jsxs14("span", {
2712
3084
  children: [
2713
3085
  " ",
2714
3086
  "· ",
2715
- point.label,
2716
- ":",
2717
- " ",
2718
- point.rate === null ? "Not observed" : `${formatPercent2(point.rate)} · ${formatValue(point.retainedCount)} / ${formatValue(item.cohortSize)} ${unit}${point.incomplete ? " · Incomplete period" : ""}`
3087
+ reading.point.label,
3088
+ ": ",
3089
+ reading.description
2719
3090
  ]
2720
- }, point.offset))
3091
+ }, reading.point.offset))
2721
3092
  ]
2722
3093
  }, item.id))
2723
3094
  })
@@ -2726,7 +3097,7 @@ function RetentionChart({
2726
3097
  });
2727
3098
  }
2728
3099
  // src/react/ui/JourneyChart.tsx
2729
- import { useLayoutEffect as useLayoutEffect3, useRef as useRef4, useState as useState7 } from "react";
3100
+ import { useLayoutEffect as useLayoutEffect3, useRef as useRef7, useState as useState9 } from "react";
2730
3101
 
2731
3102
  // src/react/ui/journey-flow.ts
2732
3103
  var journeyOutcomeLabels = {
@@ -2851,7 +3222,7 @@ function limitJourneyFlow(graph, visibleEventsByDepth = {}) {
2851
3222
  }
2852
3223
 
2853
3224
  // src/react/ui/JourneyChart.tsx
2854
- import { jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
3225
+ import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
2855
3226
  function JourneyChart({
2856
3227
  paths,
2857
3228
  unit,
@@ -2869,12 +3240,12 @@ function JourneyChart({
2869
3240
  invariant(path.steps.length > 0 && path.steps.every((step) => step.event.trim().length > 0), "journey chart paths require nonblank events.");
2870
3241
  }
2871
3242
  invariant(Number.isFinite(total), "journey chart total count must be finite.");
2872
- return /* @__PURE__ */ jsx20("section", {
3243
+ return /* @__PURE__ */ jsx21("section", {
2873
3244
  className: classNames("altertable-journey-chart", className),
2874
3245
  "aria-label": ariaLabel,
2875
- children: paths.length === 0 ? /* @__PURE__ */ jsx20("span", {
3246
+ children: paths.length === 0 ? /* @__PURE__ */ jsx21("span", {
2876
3247
  children: "No data"
2877
- }) : /* @__PURE__ */ jsx20(JourneyFlow, {
3248
+ }) : /* @__PURE__ */ jsx21(JourneyFlow, {
2878
3249
  paths,
2879
3250
  unit,
2880
3251
  formatValue
@@ -2886,11 +3257,11 @@ function JourneyFlow({
2886
3257
  unit,
2887
3258
  formatValue
2888
3259
  }) {
2889
- const [expandedBranch, setExpandedBranch] = useState7([]);
2890
- const [visibleEventsByDepth, setVisibleEventsByDepth] = useState7({});
3260
+ const [expandedBranch, setExpandedBranch] = useState9([]);
3261
+ const [visibleEventsByDepth, setVisibleEventsByDepth] = useState9({});
2891
3262
  const graph = limitJourneyFlow(buildJourneyFlow(paths, expandedBranch), visibleEventsByDepth);
2892
- const scrollRef = useRef4(null);
2893
- const pendingDepth = useRef4(null);
3263
+ const scrollRef = useRef7(null);
3264
+ const pendingDepth = useRef7(null);
2894
3265
  const depthCount = Math.max(0, ...graph.nodes.map((node) => node.depth)) + 1;
2895
3266
  const startingCount = graph.nodes.filter((node) => node.depth === 0).reduce((sum, node) => sum + node.count, 0);
2896
3267
  function percent(count) {
@@ -2961,7 +3332,7 @@ function JourneyFlow({
2961
3332
  }
2962
3333
  ];
2963
3334
  });
2964
- return /* @__PURE__ */ jsx20("div", {
3335
+ return /* @__PURE__ */ jsx21("div", {
2965
3336
  ref: scrollRef,
2966
3337
  className: "altertable-journey-scroll",
2967
3338
  children: /* @__PURE__ */ jsxs15("div", {
@@ -2974,17 +3345,17 @@ function JourneyFlow({
2974
3345
  "aria-hidden": "true",
2975
3346
  focusable: "false",
2976
3347
  children: [
2977
- /* @__PURE__ */ jsx20("path", {
3348
+ /* @__PURE__ */ jsx21("path", {
2978
3349
  d: links.filter((link) => !link.muted).map((link) => link.d).join(" "),
2979
3350
  fill: "color-mix(in srgb, var(--atbl-chart-5) 22%, var(--atbl-surface))"
2980
3351
  }),
2981
- /* @__PURE__ */ jsx20("path", {
3352
+ /* @__PURE__ */ jsx21("path", {
2982
3353
  d: links.filter((link) => link.muted).map((link) => link.d).join(" "),
2983
3354
  fill: "color-mix(in srgb, var(--atbl-muted) 22%, var(--atbl-surface))"
2984
3355
  })
2985
3356
  ]
2986
3357
  }),
2987
- columns.map((column, depth) => /* @__PURE__ */ jsx20("span", {
3358
+ columns.map((column, depth) => /* @__PURE__ */ jsx21("span", {
2988
3359
  className: "altertable-journey-stage",
2989
3360
  style: { left: columnX(depth) },
2990
3361
  children: column.length > 0 && column.every((node) => node.outcome !== "event" && node.outcome !== "other") ? "Outcome" : `Step ${depth + 1}`
@@ -2998,7 +3369,7 @@ function JourneyFlow({
2998
3369
  height: startingCount > 0 ? node.count / startingCount * nodeHeight : 0
2999
3370
  },
3000
3371
  children: [
3001
- /* @__PURE__ */ jsx20("div", {
3372
+ /* @__PURE__ */ jsx21("div", {
3002
3373
  className: "altertable-journey-bar",
3003
3374
  "data-event": node.outcome === "event" || undefined,
3004
3375
  "aria-hidden": "true",
@@ -3008,7 +3379,7 @@ function JourneyFlow({
3008
3379
  "aria-label": `${node.label}, step ${node.depth + 1}, ${formatValue(node.count)} ${unit}`,
3009
3380
  className: "altertable-journey-label",
3010
3381
  children: [
3011
- /* @__PURE__ */ jsx20("span", {
3382
+ /* @__PURE__ */ jsx21("span", {
3012
3383
  className: "altertable-journey-name",
3013
3384
  title: node.label,
3014
3385
  children: node.label
@@ -3032,7 +3403,7 @@ function JourneyFlow({
3032
3403
  }) : null
3033
3404
  ]
3034
3405
  }),
3035
- node.expandable && /* @__PURE__ */ jsx20(Button2, {
3406
+ node.expandable && /* @__PURE__ */ jsx21(Button2, {
3036
3407
  variant: "outline",
3037
3408
  size: "icon-compact",
3038
3409
  className: "altertable-journey-expand",
@@ -3045,7 +3416,7 @@ function JourneyFlow({
3045
3416
  },
3046
3417
  children: node.expanded ? "−" : "›"
3047
3418
  }),
3048
- node.outcome === "other" && /* @__PURE__ */ jsx20(Button2, {
3419
+ node.outcome === "other" && /* @__PURE__ */ jsx21(Button2, {
3049
3420
  size: "compact",
3050
3421
  variant: "ghost",
3051
3422
  className: "altertable-journey-more",
@@ -3074,15 +3445,16 @@ export {
3074
3445
  ComposedChart,
3075
3446
  DataApp,
3076
3447
  DataAppProvider2 as DataAppProvider,
3077
- DataAppSkeleton,
3078
3448
  DataTable2 as DataTable,
3079
3449
  DataTableEmptyRow2 as DataTableEmptyRow,
3080
3450
  DataTableShare2 as DataTableShare,
3081
3451
  DataTableTimestamp2 as DataTableTimestamp,
3082
3452
  DataValue2 as DataValue,
3083
3453
  DataWidget2 as DataWidget,
3454
+ DateDisplay2 as DateDisplay,
3084
3455
  DateRangePicker2 as DateRangePicker,
3085
3456
  DimensionPicker2 as DimensionPicker,
3457
+ ExplorationActionControl2 as ExplorationActionControl,
3086
3458
  FilterActions2 as FilterActions,
3087
3459
  FilterBar2 as FilterBar,
3088
3460
  FunnelChart,
@@ -3113,6 +3485,8 @@ export {
3113
3485
  ScatterChart,
3114
3486
  SearchField2 as SearchField,
3115
3487
  SearchMatch2 as SearchMatch,
3488
+ SearchTypeahead2 as SearchTypeahead,
3489
+ SectionHeading2 as SectionHeading,
3116
3490
  SegmentedControl,
3117
3491
  Select2 as Select,
3118
3492
  Sheet2 as Sheet,
@@ -3127,13 +3501,14 @@ export {
3127
3501
  TooltipProvider2 as TooltipProvider,
3128
3502
  VariableBar2 as VariableBar,
3129
3503
  VisualizationWidget2 as VisualizationWidget,
3130
- injectDataAppShellStyles,
3131
3504
  injectDataAppStyles2 as injectDataAppStyles,
3132
3505
  isPlainKeyEvent2 as isPlainKeyEvent,
3506
+ matchSearchText2 as matchSearchText,
3133
3507
  searchItems2 as searchItems,
3134
3508
  useAppVariables2 as useAppVariables,
3509
+ useDateFormatting2 as useDateFormatting,
3135
3510
  useSvgId,
3136
3511
  useViewTab2 as useViewTab
3137
3512
  };
3138
3513
 
3139
- //# debugId=6CFD84691873BB8C64756E2164756E21
3514
+ //# debugId=7CD02365D10882B064756E2164756E21