derive-dashboards 0.1.0 → 0.2.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 (410) hide show
  1. package/README.md +8 -5
  2. package/dist/adapter/sql-adapter.mjs +4 -4
  3. package/dist/body.mjs +11 -1
  4. package/dist/cache.d.mts +1 -1
  5. package/dist/cli/add.mjs +130 -0
  6. package/dist/cli/check.mjs +14 -1
  7. package/dist/cli/cli.mjs +14 -12
  8. package/dist/cli/config.mjs +12 -1
  9. package/dist/cli/doctor.mjs +147 -0
  10. package/dist/cli/import/dbt-schema.mjs +2 -2
  11. package/dist/cli/import/index.mjs +2 -2
  12. package/dist/cli/init.mjs +3 -2
  13. package/dist/cli/json.mjs +21 -0
  14. package/dist/cli/layers.mjs +33 -0
  15. package/dist/core/conformance/cases.d.mts +3 -0
  16. package/dist/core/conformance/cases.mjs +20 -4
  17. package/dist/core/conformance/check.mjs +6 -3
  18. package/dist/core/conformance/drill-cases.mjs +120 -0
  19. package/dist/core/document/layout.mjs +1 -1
  20. package/dist/core/document/view-layout.d.mts +14 -0
  21. package/dist/core/document/view-layout.mjs +157 -0
  22. package/dist/core/document/view.d.mts +26 -7
  23. package/dist/core/document/view.mjs +42 -11
  24. package/dist/core/engine/filter.mjs +2 -2
  25. package/dist/core/engine/index.d.mts +14 -2
  26. package/dist/core/engine/index.mjs +12 -1
  27. package/dist/core/engine/leaf.mjs +9 -4
  28. package/dist/core/engine/members.mjs +2 -2
  29. package/dist/core/engine/postgres.mjs +1 -1
  30. package/dist/core/engine/record-layout.d.mts +11 -0
  31. package/dist/core/engine/record-layout.mjs +7 -7
  32. package/dist/core/engine/records.d.mts +3 -2
  33. package/dist/core/engine/records.mjs +2 -1
  34. package/dist/core/engine/segmented.mjs +5 -2
  35. package/dist/core/engine/sql-records.mjs +2 -1
  36. package/dist/core/engine/statement.mjs +37 -3
  37. package/dist/core/engine/types.d.mts +3 -0
  38. package/dist/core/engine/version.d.mts +1 -1
  39. package/dist/core/engine/version.mjs +1 -1
  40. package/dist/core/error/codes.d.mts +33 -1
  41. package/dist/core/error/codes.mjs +30 -2
  42. package/dist/core/index.d.mts +13 -7
  43. package/dist/core/index.mjs +9 -5
  44. package/dist/core/model/catalog/check.mjs +1 -1
  45. package/dist/core/model/hints.d.mts +36 -0
  46. package/dist/core/model/member.d.mts +4 -2
  47. package/dist/core/model/member.mjs +19 -3
  48. package/dist/core/model/types.d.mts +21 -19
  49. package/dist/core/model/validate/drill.mjs +70 -0
  50. package/dist/core/model/validate/index.mjs +3 -0
  51. package/dist/core/model/validate/members.mjs +7 -4
  52. package/dist/core/model/validate/shape.mjs +150 -0
  53. package/dist/core/model/validate/source.mjs +5 -3
  54. package/dist/core/policy/bind-query.d.mts +12 -0
  55. package/dist/core/policy/bind-query.mjs +53 -0
  56. package/dist/core/query/alias.mjs +7 -1
  57. package/dist/core/query/drill/compose.d.mts +22 -0
  58. package/dist/core/query/drill/compose.mjs +85 -0
  59. package/dist/core/query/drill/fields.d.mts +21 -0
  60. package/dist/core/query/drill/fields.mjs +91 -0
  61. package/dist/core/query/drill/internal.d.mts +11 -0
  62. package/dist/core/query/drill/items.d.mts +29 -0
  63. package/dist/core/query/drill/items.mjs +98 -0
  64. package/dist/core/query/drill/line.d.mts +31 -0
  65. package/dist/core/query/drill/line.mjs +183 -0
  66. package/dist/core/query/drill/links.d.mts +33 -0
  67. package/dist/core/query/drill/links.mjs +31 -0
  68. package/dist/core/query/drill/operand.mjs +7 -0
  69. package/dist/core/query/drill/scopes.d.mts +22 -0
  70. package/dist/core/query/drill/scopes.mjs +58 -0
  71. package/dist/core/query/drill/selection.d.mts +37 -0
  72. package/dist/core/query/drill/selection.mjs +144 -0
  73. package/dist/core/query/drill/steps.d.mts +14 -0
  74. package/dist/core/query/drill/steps.mjs +35 -0
  75. package/dist/core/query/drill/synthetic-expr.mjs +85 -0
  76. package/dist/core/query/drill/synthetic.d.mts +22 -0
  77. package/dist/core/query/drill/synthetic.mjs +165 -0
  78. package/dist/core/query/drill/time.d.mts +11 -0
  79. package/dist/core/query/drill/time.mjs +71 -0
  80. package/dist/core/query/drill/types.d.mts +155 -0
  81. package/dist/core/query/drill/types.mjs +4 -0
  82. package/dist/core/query/drill/views.d.mts +62 -0
  83. package/dist/core/query/drill/views.mjs +257 -0
  84. package/dist/core/query/filter.d.mts +6 -0
  85. package/dist/core/query/picks.d.mts +8 -2
  86. package/dist/core/query/picks.mjs +11 -4
  87. package/dist/core/query/segments.d.mts +12 -2
  88. package/dist/core/query/segments.mjs +5 -2
  89. package/dist/core/result/columns.mjs +20 -4
  90. package/dist/core/result/types.d.mts +5 -1
  91. package/dist/core/schema/aliases.d.mts +7 -0
  92. package/dist/core/schema/aliases.mjs +77 -0
  93. package/dist/core/schema/answer-parts.mjs +117 -0
  94. package/dist/core/schema/answers.d.mts +2109 -128
  95. package/dist/core/schema/answers.mjs +11 -113
  96. package/dist/core/schema/commands.d.mts +2 -2
  97. package/dist/core/schema/document.d.mts +1 -1
  98. package/dist/core/schema/drill-answers.mjs +179 -0
  99. package/dist/core/schema/drill.d.mts +260 -0
  100. package/dist/core/schema/drill.mjs +107 -0
  101. package/dist/core/schema/index.d.mts +6 -3
  102. package/dist/core/schema/index.mjs +6 -3
  103. package/dist/core/schema/picks.d.mts +35 -0
  104. package/dist/core/schema/picks.mjs +23 -0
  105. package/dist/core/schema/query.d.mts +82 -1
  106. package/dist/core/schema/query.mjs +9 -5
  107. package/dist/core/schema/tools.mjs +1 -1
  108. package/dist/core/schema/view.d.mts +0 -35
  109. package/dist/core/schema/view.mjs +19 -24
  110. package/dist/core/store/schema.d.mts +5 -0
  111. package/dist/core/store/schema.mjs +10 -0
  112. package/dist/core/types/api.d.mts +21 -1
  113. package/dist/core/types/api.mjs +1 -1
  114. package/dist/core/types/drill-api.d.mts +210 -0
  115. package/dist/core/types/options.d.mts +21 -0
  116. package/dist/core/types/viewer.d.mts +5 -0
  117. package/dist/cursor-seal.d.mts +8 -0
  118. package/dist/cursor-seal.mjs +98 -0
  119. package/dist/dashboard-id.mjs +1 -1
  120. package/dist/dashboards.mjs +4 -0
  121. package/dist/drill-access.mjs +93 -0
  122. package/dist/drill-change.mjs +76 -0
  123. package/dist/drill-crumbs.mjs +113 -0
  124. package/dist/drill-distinct.mjs +130 -0
  125. package/dist/drill-explain.mjs +64 -0
  126. package/dist/drill-identity.mjs +35 -0
  127. package/dist/drill-item-id.mjs +35 -0
  128. package/dist/drill-items.mjs +132 -0
  129. package/dist/drill-open.mjs +169 -0
  130. package/dist/drill-seal.mjs +170 -0
  131. package/dist/drill-secret.mjs +14 -0
  132. package/dist/drill-share.mjs +53 -0
  133. package/dist/drill-summary.mjs +158 -0
  134. package/dist/drill-targets.mjs +53 -0
  135. package/dist/drill-totals.mjs +8 -0
  136. package/dist/drill-views.mjs +175 -0
  137. package/dist/drill.mjs +157 -0
  138. package/dist/editing.mjs +3 -3
  139. package/dist/endpoints/dashboards.mjs +28 -5
  140. package/dist/endpoints/drill.mjs +55 -0
  141. package/dist/endpoints/index.d.mts +245 -4
  142. package/dist/endpoints/index.mjs +5 -1
  143. package/dist/endpoints/meta.mjs +10 -1
  144. package/dist/endpoints/query.mjs +26 -4
  145. package/dist/execute.d.mts +19 -1
  146. package/dist/execute.mjs +34 -27
  147. package/dist/handler.mjs +5 -1
  148. package/dist/index.d.mts +3 -1
  149. package/dist/index.mjs +29 -2
  150. package/dist/llms.txt +22 -0
  151. package/dist/mcp/drill.mjs +61 -0
  152. package/dist/mcp/format.mjs +69 -11
  153. package/dist/mcp/index.d.mts +15 -4
  154. package/dist/mcp/index.mjs +13 -7
  155. package/dist/mcp/query.d.mts +7 -2
  156. package/dist/mcp/query.mjs +40 -6
  157. package/dist/node-postgres.d.mts +8 -4
  158. package/dist/node-postgres.mjs +29 -6
  159. package/dist/owner.mjs +3 -3
  160. package/dist/postgres-connection.d.mts +8 -2
  161. package/dist/postgres-connection.mjs +2 -1
  162. package/dist/postgres-store.mjs +1 -0
  163. package/dist/react/Canvas.mjs +28 -5
  164. package/dist/react/Cell.mjs +2 -1
  165. package/dist/react/Dashboard.d.mts +10 -5
  166. package/dist/react/Dashboard.mjs +62 -22
  167. package/dist/react/DashboardList.mjs +52 -24
  168. package/dist/react/DashboardListRow.mjs +49 -0
  169. package/dist/react/Discard.mjs +12 -4
  170. package/dist/react/Editing.mjs +19 -5
  171. package/dist/react/FilterBar.d.mts +7 -9
  172. package/dist/react/Grid.mjs +19 -24
  173. package/dist/react/Header.mjs +10 -1
  174. package/dist/react/History.mjs +5 -0
  175. package/dist/react/Parts.mjs +6 -2
  176. package/dist/react/ReadFailed.mjs +23 -0
  177. package/dist/react/ReviewPanel.mjs +13 -2
  178. package/dist/react/RowBody.d.mts +19 -0
  179. package/dist/react/RowBody.mjs +55 -0
  180. package/dist/react/Spaces.mjs +15 -1
  181. package/dist/react/Tile.d.mts +3 -1
  182. package/dist/react/Tile.mjs +84 -32
  183. package/dist/react/_virtual/_rolldown/runtime.mjs +12 -0
  184. package/dist/react/arrange-steps.mjs +16 -13
  185. package/dist/react/arrange.mjs +10 -3
  186. package/dist/react/builder/Calcs.mjs +35 -11
  187. package/dist/react/builder/FilterEditor.mjs +196 -0
  188. package/dist/react/builder/Filters.mjs +172 -116
  189. package/dist/react/builder/Formula.mjs +82 -0
  190. package/dist/react/builder/Groups.mjs +1 -0
  191. package/dist/react/builder/Preview.mjs +1 -1
  192. package/dist/react/builder/RangeEditor.mjs +184 -0
  193. package/dist/react/builder/Sections.mjs +41 -6
  194. package/dist/react/builder/Time.mjs +138 -60
  195. package/dist/react/builder/Values.mjs +85 -0
  196. package/dist/react/builder/WidgetBuilder.mjs +50 -49
  197. package/dist/react/builder/base.d.mts +5 -0
  198. package/dist/react/builder/base.mjs +33 -8
  199. package/dist/react/builder/calc.mjs +15 -1
  200. package/dist/react/builder/escape.d.mts +1 -0
  201. package/dist/react/builder/escape.mjs +62 -0
  202. package/dist/react/builder/filter-tree.d.mts +9 -0
  203. package/dist/react/builder/filter-tree.mjs +186 -0
  204. package/dist/react/builder/formula-parse.d.mts +18 -0
  205. package/dist/react/builder/formula-parse.mjs +136 -0
  206. package/dist/react/builder/labels.d.mts +1 -1
  207. package/dist/react/builder/state.d.mts +2 -1
  208. package/dist/react/builder/state.mjs +23 -37
  209. package/dist/react/builder/useBuilder.d.mts +12 -1
  210. package/dist/react/builder/useBuilder.mjs +6 -3
  211. package/dist/react/builder/words.d.mts +59 -0
  212. package/dist/react/builder/words.mjs +73 -0
  213. package/dist/react/client.d.mts +2 -0
  214. package/dist/react/client.mjs +1 -0
  215. package/dist/react/context.d.mts +28 -1
  216. package/dist/react/context.mjs +25 -4
  217. package/dist/react/drill/Bars.mjs +179 -0
  218. package/dist/react/drill/Controls.mjs +173 -0
  219. package/dist/react/drill/DashboardTile.d.mts +18 -0
  220. package/dist/react/drill/DashboardTile.mjs +107 -0
  221. package/dist/react/drill/DrillPanel.d.mts +31 -0
  222. package/dist/react/drill/DrillPanel.mjs +104 -0
  223. package/dist/react/drill/DrillTabs.mjs +52 -0
  224. package/dist/react/drill/Header.mjs +131 -0
  225. package/dist/react/drill/Items.d.mts +22 -0
  226. package/dist/react/drill/Items.mjs +164 -0
  227. package/dist/react/drill/ItemsFoot.mjs +60 -0
  228. package/dist/react/drill/Notes.mjs +58 -0
  229. package/dist/react/drill/PanelBody.mjs +74 -0
  230. package/dist/react/drill/PanelStates.mjs +37 -0
  231. package/dist/react/drill/board.d.mts +18 -0
  232. package/dist/react/drill/board.mjs +91 -0
  233. package/dist/react/drill/counts.mjs +14 -0
  234. package/dist/react/drill/host.mjs +26 -0
  235. package/dist/react/drill/item-parts.d.mts +5 -0
  236. package/dist/react/drill/item-parts.mjs +76 -0
  237. package/dist/react/drill/item-type.d.mts +26 -0
  238. package/dist/react/drill/item-type.mjs +7 -0
  239. package/dist/react/drill/lazy.d.mts +6 -0
  240. package/dist/react/drill/lazy.mjs +17 -0
  241. package/dist/react/drill/pages.mjs +48 -0
  242. package/dist/react/drill/panel-focus.mjs +51 -0
  243. package/dist/react/drill/props.d.mts +25 -0
  244. package/dist/react/drill/props.mjs +72 -0
  245. package/dist/react/drill/state.d.mts +18 -0
  246. package/dist/react/drill/state.mjs +68 -0
  247. package/dist/react/drill/useDrill.d.mts +46 -0
  248. package/dist/react/drill/useDrill.mjs +194 -0
  249. package/dist/react/drill/words.d.mts +101 -0
  250. package/dist/react/drill/words.mjs +79 -0
  251. package/dist/react/english.mjs +29 -6
  252. package/dist/react/filters/bar.d.mts +12 -0
  253. package/dist/react/filters/bar.mjs +135 -0
  254. package/dist/react/filters/calendar.mjs +193 -0
  255. package/dist/react/filters/chip.mjs +174 -0
  256. package/dist/react/filters/context.d.mts +22 -0
  257. package/dist/react/filters/context.mjs +78 -0
  258. package/dist/react/filters/dates.mjs +89 -0
  259. package/dist/react/filters/days.d.mts +36 -0
  260. package/dist/react/filters/days.mjs +87 -0
  261. package/dist/react/filters/field-step.mjs +81 -0
  262. package/dist/react/filters/hooks.d.mts +34 -0
  263. package/dist/react/filters/hooks.mjs +94 -0
  264. package/dist/react/filters/listbox.mjs +131 -0
  265. package/dist/react/filters/logic.d.mts +59 -0
  266. package/dist/react/filters/logic.mjs +109 -0
  267. package/dist/react/filters/menu-search.mjs +211 -0
  268. package/dist/react/filters/menu.mjs +85 -0
  269. package/dist/react/filters/number.mjs +127 -0
  270. package/dist/react/filters/numbers.d.mts +47 -0
  271. package/dist/react/filters/numbers.mjs +151 -0
  272. package/dist/react/filters/operator.mjs +104 -0
  273. package/dist/react/filters/phone.mjs +104 -0
  274. package/dist/react/filters/popover.d.mts +19 -0
  275. package/dist/react/filters/popover.mjs +153 -0
  276. package/dist/react/filters/rules.d.mts +8 -0
  277. package/dist/react/filters/rules.mjs +55 -0
  278. package/dist/react/filters/sheet.mjs +196 -0
  279. package/dist/react/filters/state.mjs +132 -0
  280. package/dist/react/filters/suggest.d.mts +47 -0
  281. package/dist/react/filters/suggest.mjs +97 -0
  282. package/dist/react/filters/values.mjs +166 -0
  283. package/dist/react/filters/words.d.mts +81 -0
  284. package/dist/react/filters/words.mjs +73 -0
  285. package/dist/react/format.d.mts +3 -3
  286. package/dist/react/format.mjs +45 -16
  287. package/dist/react/index.d.mts +34 -5
  288. package/dist/react/index.mjs +15 -4
  289. package/dist/react/messages.d.mts +47 -2
  290. package/dist/react/place.mjs +7 -3
  291. package/dist/react/renderers/index.d.mts +10 -2
  292. package/dist/react/renderers/index.mjs +116 -14
  293. package/dist/react/renderers/list.d.mts +22 -0
  294. package/dist/react/renderers/list.mjs +118 -0
  295. package/dist/react/review-words.mjs +1 -1
  296. package/dist/react/review.mjs +2 -2
  297. package/dist/react/scope.mjs +2 -7
  298. package/dist/react/series.d.mts +54 -0
  299. package/dist/react/series.mjs +191 -0
  300. package/dist/react/theme.css +2734 -1296
  301. package/dist/react/theme.css.d.ts +1 -0
  302. package/dist/react/tile-store.mjs +15 -3
  303. package/dist/react/useBoard.d.mts +7 -0
  304. package/dist/react/useBoard.mjs +4 -1
  305. package/dist/react/useDashboard.d.mts +4 -0
  306. package/dist/react/useDashboard.mjs +8 -1
  307. package/dist/react/useTiles.mjs +50 -15
  308. package/dist/react/view-grid.mjs +16 -0
  309. package/dist/react/view.d.mts +9 -0
  310. package/dist/react/view.mjs +22 -10
  311. package/dist/reading.d.mts +2 -0
  312. package/dist/reading.mjs +9 -1
  313. package/dist/recharts/axes.mjs +28 -0
  314. package/dist/recharts/axis.mjs +84 -0
  315. package/dist/recharts/bar.d.mts +7 -0
  316. package/dist/recharts/bar.mjs +140 -0
  317. package/dist/recharts/charts.d.mts +4 -6
  318. package/dist/recharts/charts.mjs +2 -114
  319. package/dist/recharts/index.d.mts +5 -3
  320. package/dist/recharts/index.mjs +6 -3
  321. package/dist/recharts/line.d.mts +2 -0
  322. package/dist/recharts/line.mjs +111 -0
  323. package/dist/recharts/marks.mjs +112 -0
  324. package/dist/recharts/parts.mjs +88 -0
  325. package/dist/recharts/series.d.mts +2 -22
  326. package/dist/recharts/series.mjs +1 -64
  327. package/dist/recharts/table.mjs +71 -0
  328. package/dist/records-read.mjs +44 -0
  329. package/dist/registry/filter-bar.json +26 -0
  330. package/dist/skills/derive-dashboards/SKILL.md +69 -0
  331. package/dist/store/apply.mjs +5 -5
  332. package/dist/store/commands.mjs +4 -4
  333. package/dist/store/discard.mjs +7 -7
  334. package/dist/store/drafts.mjs +5 -5
  335. package/dist/store/editor.mjs +1 -1
  336. package/dist/store/publish.mjs +12 -12
  337. package/dist/store/reader.mjs +41 -22
  338. package/dist/store/review.mjs +16 -16
  339. package/dist/store/rows.mjs +20 -20
  340. package/dist/store/undo.mjs +3 -3
  341. package/dist/store/unpublished.mjs +4 -4
  342. package/dist/store/versions.mjs +14 -14
  343. package/dist/testing/adapter-suite.mjs +4 -4
  344. package/dist/tiles.mjs +37 -3
  345. package/package.json +12 -10
  346. package/dist/react/FilterBar.mjs +0 -119
  347. package/dist/react/Records.d.mts +0 -12
  348. package/dist/react/Records.mjs +0 -97
  349. package/src/adapter/sql-adapter.ts +0 -95
  350. package/src/adapter/statement.ts +0 -185
  351. package/src/authorize.ts +0 -73
  352. package/src/body.ts +0 -169
  353. package/src/bounded.ts +0 -43
  354. package/src/cache.ts +0 -192
  355. package/src/checks.ts +0 -170
  356. package/src/custom-source.ts +0 -59
  357. package/src/dashboard-id.ts +0 -36
  358. package/src/dashboards.ts +0 -132
  359. package/src/editing.ts +0 -148
  360. package/src/endpoints/access.ts +0 -41
  361. package/src/endpoints/dashboards.ts +0 -92
  362. package/src/endpoints/drafts.ts +0 -138
  363. package/src/endpoints/index.ts +0 -21
  364. package/src/endpoints/meta.ts +0 -137
  365. package/src/endpoints/query.ts +0 -86
  366. package/src/endpoints/read.ts +0 -92
  367. package/src/endpoints/review.ts +0 -89
  368. package/src/endpoints/values.ts +0 -62
  369. package/src/endpoints/versions.ts +0 -104
  370. package/src/execute.ts +0 -207
  371. package/src/handler.ts +0 -232
  372. package/src/http.ts +0 -66
  373. package/src/index.ts +0 -163
  374. package/src/introspect.ts +0 -205
  375. package/src/mcp/api.ts +0 -59
  376. package/src/mcp/format.ts +0 -67
  377. package/src/mcp/index.ts +0 -151
  378. package/src/mcp/query.ts +0 -153
  379. package/src/mcp/resolve.ts +0 -114
  380. package/src/node-postgres.ts +0 -81
  381. package/src/owner.ts +0 -36
  382. package/src/postgres-connection.ts +0 -143
  383. package/src/postgres-store.ts +0 -82
  384. package/src/principal.ts +0 -39
  385. package/src/reading.ts +0 -56
  386. package/src/request-rows.ts +0 -23
  387. package/src/request.ts +0 -22
  388. package/src/storage.ts +0 -63
  389. package/src/store/apply.ts +0 -129
  390. package/src/store/commands.ts +0 -75
  391. package/src/store/conflicts.ts +0 -98
  392. package/src/store/create-tables.ts +0 -104
  393. package/src/store/discard.ts +0 -42
  394. package/src/store/drafts.ts +0 -133
  395. package/src/store/editor.ts +0 -28
  396. package/src/store/log.ts +0 -28
  397. package/src/store/publish.ts +0 -199
  398. package/src/store/publisher.ts +0 -21
  399. package/src/store/reader.ts +0 -139
  400. package/src/store/review.ts +0 -239
  401. package/src/store/rows.ts +0 -250
  402. package/src/store/tenant.ts +0 -28
  403. package/src/store/undo.ts +0 -56
  404. package/src/store/unpublished.ts +0 -33
  405. package/src/store/versions.ts +0 -106
  406. package/src/store/writer.ts +0 -19
  407. package/src/testing/adapter-suite.ts +0 -239
  408. package/src/testing/index.ts +0 -2
  409. package/src/tile-doc.ts +0 -46
  410. package/src/tiles.ts +0 -120
@@ -1,118 +1,6 @@
1
- import { toSeries } from "./series.mjs";
2
- import { formatCell, formatTick } from "derive-dashboards/react";
3
- import { Bar, BarChart, CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
4
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { BarTile } from "./bar.mjs";
2
+ import { LineTile } from "./line.mjs";
5
3
  // src/charts.tsx
6
- /** A series' colour: the palette in order, and Other always the quiet grey. */
7
- const color = (s, i) => s.key === "other" ? "var(--dd-other)" : `var(--dd-series-${i % 6 + 1})`;
8
- function axisFormat(series, locale) {
9
- const column = series[0]?.column;
10
- return (value) => formatTick(value, column, locale);
11
- }
12
- function tooltipFormat(series, format) {
13
- const column = series[0]?.column;
14
- return (value) => typeof value === "number" ? formatCell(value, column, format) : String(value);
15
- }
16
- /** A line per series over the x axis, usually time buckets. */
17
- function LineTile(props) {
18
- const { answer, locale } = props;
19
- const { points, series } = toSeries(answer, props);
20
- return /* @__PURE__ */ jsx("div", {
21
- className: "dd-chart",
22
- children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxs(LineChart, {
23
- data: points,
24
- margin: {
25
- top: 4,
26
- right: 8,
27
- bottom: 0,
28
- left: 0
29
- },
30
- children: [
31
- /* @__PURE__ */ jsx(CartesianGrid, {
32
- stroke: "var(--dd-line)",
33
- vertical: false
34
- }),
35
- /* @__PURE__ */ jsx(XAxis, {
36
- dataKey: "x",
37
- tickLine: false,
38
- axisLine: false,
39
- stroke: "var(--dd-muted)",
40
- minTickGap: 16
41
- }),
42
- /* @__PURE__ */ jsx(YAxis, {
43
- tickLine: false,
44
- axisLine: false,
45
- stroke: "var(--dd-muted)",
46
- width: 56,
47
- tickFormatter: axisFormat(series, locale)
48
- }),
49
- /* @__PURE__ */ jsx(Tooltip, { formatter: tooltipFormat(series, props) }),
50
- series.length > 1 ? /* @__PURE__ */ jsx(Legend, { itemSorter: null }) : null,
51
- series.map((s, i) => /* @__PURE__ */ jsx(Line, {
52
- dataKey: s.key,
53
- name: s.label,
54
- stroke: color(s, i),
55
- strokeWidth: 2,
56
- dot: false,
57
- isAnimationActive: false
58
- }, s.key))
59
- ]
60
- }) })
61
- });
62
- }
63
- /** Bars per x value; when a second field splits them, its values stack, Other on top. */
64
- function BarTile(props) {
65
- const { answer, locale } = props;
66
- const { points, series, split } = toSeries(answer, props);
67
- return /* @__PURE__ */ jsx("div", {
68
- className: "dd-chart",
69
- children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxs(BarChart, {
70
- data: points,
71
- margin: {
72
- top: 4,
73
- right: 8,
74
- bottom: 0,
75
- left: 0
76
- },
77
- children: [
78
- /* @__PURE__ */ jsx(CartesianGrid, {
79
- stroke: "var(--dd-line)",
80
- vertical: false
81
- }),
82
- /* @__PURE__ */ jsx(XAxis, {
83
- dataKey: "x",
84
- tickLine: false,
85
- axisLine: false,
86
- stroke: "var(--dd-muted)",
87
- interval: "preserveStartEnd",
88
- minTickGap: 12
89
- }),
90
- /* @__PURE__ */ jsx(YAxis, {
91
- tickLine: false,
92
- axisLine: false,
93
- stroke: "var(--dd-muted)",
94
- width: 56,
95
- tickFormatter: axisFormat(series, locale)
96
- }),
97
- /* @__PURE__ */ jsx(Tooltip, { formatter: tooltipFormat(series, props) }),
98
- series.length > 1 ? /* @__PURE__ */ jsx(Legend, { itemSorter: null }) : null,
99
- series.map((s, i) => /* @__PURE__ */ jsx(Bar, {
100
- dataKey: s.key,
101
- name: s.label,
102
- fill: color(s, i),
103
- ...split ? { stackId: "split" } : {},
104
- radius: split && i < series.length - 1 ? 0 : [
105
- 4,
106
- 4,
107
- 0,
108
- 0
109
- ],
110
- isAnimationActive: false
111
- }, s.key))
112
- ]
113
- }) })
114
- });
115
- }
116
4
  /** Register with `<DashboardsProvider renderers={RECHARTS_RENDERERS}>`. */
117
5
  const RECHARTS_RENDERERS = {
118
6
  line: LineTile,
@@ -1,3 +1,5 @@
1
- import { BarTile, LineTile, RECHARTS_RENDERERS } from "./charts.mjs";
2
- import { Point, Series, toSeries } from "./series.mjs";
3
- export { BarTile, LineTile, type Point, RECHARTS_RENDERERS, type Series, toSeries };
1
+ import { BarTile } from "./bar.mjs";
2
+ import { LineTile } from "./line.mjs";
3
+ import { RECHARTS_RENDERERS } from "./charts.mjs";
4
+ import { Drawn, Point, Series, rowAt, toSeries } from "./series.mjs";
5
+ export { BarTile, type Drawn, LineTile, type Point, RECHARTS_RENDERERS, type Series, rowAt, toSeries };
@@ -1,3 +1,6 @@
1
- import { BarTile, LineTile, RECHARTS_RENDERERS } from "./charts.mjs";
2
- import { toSeries } from "./series.mjs";
3
- export { BarTile, LineTile, RECHARTS_RENDERERS, toSeries };
1
+ "use client";
2
+ import { RECHARTS_RENDERERS } from "./charts.mjs";
3
+ import { BarTile } from "./bar.mjs";
4
+ import { LineTile } from "./line.mjs";
5
+ import { rowAt, toSeries } from "./series.mjs";
6
+ export { BarTile, LineTile, RECHARTS_RENDERERS, rowAt, toSeries };
@@ -0,0 +1,2 @@
1
+ import { TileRendererProps } from "derive-dashboards/react";
2
+ export declare function LineTile(props: TileRendererProps): import("react").JSX.Element;
@@ -0,0 +1,111 @@
1
+ import { yAxes } from "./axes.mjs";
2
+ import { openPoint } from "./marks.mjs";
3
+ import { CHART, TOOLTIP, color, dashOf, legendText, runningLabel, tooltipFormat, tooltipLabel } from "./parts.mjs";
4
+ import { toSeries } from "./series.mjs";
5
+ import { Beside } from "./table.mjs";
6
+ import { useState } from "react";
7
+ import { CartesianGrid, Legend, Line, LineChart, ReferenceArea, ResponsiveContainer, Tooltip, XAxis } from "recharts";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ // src/line.tsx
10
+ /** A line's dots: only the one the keyboard is on, ringed. */
11
+ const lineDot = (focused, key) => focused?.key === key ? (dot) => dot.index === focused.point ? /* @__PURE__ */ jsx("circle", {
12
+ className: "dd-chart-focus",
13
+ cx: dot.cx,
14
+ cy: dot.cy,
15
+ r: 5
16
+ }, dot.index) : /* @__PURE__ */ jsx("g", {}, dot.index) : false;
17
+ /** A click on a single line opens the point under it; with several, each opens from its own list. */
18
+ function lineClick(drill, drawn) {
19
+ const [only] = drawn.series;
20
+ return (state) => {
21
+ const point = Number(state.activeTooltipIndex);
22
+ if (only !== void 0 && drawn.series.length === 1 && Number.isInteger(point)) openPoint(drill, drawn, {
23
+ point,
24
+ series: only
25
+ });
26
+ };
27
+ }
28
+ /**
29
+ * The bucket still running, shaded and saying so, so its low value reads as unfinished, not as
30
+ * a fall.
31
+ */
32
+ function runningArea(props, points) {
33
+ const running = runningLabel(props, points);
34
+ const before = points.at(-2)?.x;
35
+ return running === void 0 || before === void 0 ? null : /* @__PURE__ */ jsx(ReferenceArea, {
36
+ yAxisId: "left",
37
+ x1: before,
38
+ x2: running,
39
+ fill: "var(--dd-line)",
40
+ fillOpacity: .35,
41
+ stroke: "none",
42
+ label: {
43
+ value: props.messages.soFar,
44
+ position: "insideTopRight",
45
+ fill: "var(--dd-muted)",
46
+ fontSize: 11
47
+ }
48
+ });
49
+ }
50
+ function LineTile(props) {
51
+ const { answer, locale, drill } = props;
52
+ const [focused, setFocused] = useState(null);
53
+ const drawn = toSeries(answer, props);
54
+ const { points, series } = drawn;
55
+ const onClick = lineClick(drill, drawn);
56
+ const running = runningLabel(props, points);
57
+ return /* @__PURE__ */ jsxs("div", {
58
+ className: "dd-chart",
59
+ "data-drillable": drill !== void 0,
60
+ children: [/* @__PURE__ */ jsx("div", {
61
+ className: "dd-chart-picture",
62
+ "aria-hidden": "true",
63
+ children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxs(LineChart, {
64
+ ...CHART,
65
+ data: points,
66
+ ...drill === void 0 ? {} : { onClick },
67
+ children: [
68
+ /* @__PURE__ */ jsx(CartesianGrid, {
69
+ stroke: "var(--dd-line)",
70
+ vertical: false
71
+ }),
72
+ /* @__PURE__ */ jsx(XAxis, {
73
+ dataKey: "x",
74
+ tickLine: false,
75
+ axisLine: false,
76
+ stroke: "var(--dd-muted)",
77
+ minTickGap: 16
78
+ }),
79
+ yAxes(drawn, locale),
80
+ /* @__PURE__ */ jsx(Tooltip, {
81
+ ...TOOLTIP,
82
+ formatter: tooltipFormat(props, drawn),
83
+ labelFormatter: tooltipLabel(props, running)
84
+ }),
85
+ runningArea(props, points),
86
+ series.length > 1 ? /* @__PURE__ */ jsx(Legend, {
87
+ itemSorter: null,
88
+ formatter: legendText
89
+ }) : null,
90
+ series.map((s, i) => /* @__PURE__ */ jsx(Line, {
91
+ dataKey: s.key,
92
+ name: s.label,
93
+ yAxisId: s.axis,
94
+ stroke: color(props, s, i),
95
+ strokeWidth: 2,
96
+ ...dashOf(i),
97
+ legendType: "plainline",
98
+ dot: lineDot(focused, s.key),
99
+ isAnimationActive: false
100
+ }, s.key))
101
+ ]
102
+ }) })
103
+ }), /* @__PURE__ */ jsx(Beside, {
104
+ drawn,
105
+ props,
106
+ kind: "line",
107
+ onFocusMark: setFocused
108
+ })]
109
+ });
110
+ }
111
+ export { LineTile };
@@ -0,0 +1,112 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ // src/marks.tsx
4
+ /** The line a series draws: its own column, or for a split chart the value it splits. */
5
+ const entryOf = (s) => s.column.id;
6
+ /** Opens the drill of the row behind a point of a series, if a row stands behind it. */
7
+ function openPoint(drill, drawn, at) {
8
+ const row = drawn.rowAt(at.point, at.series.key);
9
+ if (drill !== void 0 && row !== void 0) drill.open(row, entryOf(at.series));
10
+ }
11
+ /**
12
+ * Whether a pointer is down, read when a mark loses focus: a blur from a press waits for the
13
+ * click to land before the chart redraws, since a redraw between press and release would swallow
14
+ * the click on the bar pressed. A blur from the keyboard clears at once.
15
+ */
16
+ function usePressing() {
17
+ const pressing = useRef(false);
18
+ useEffect(() => {
19
+ const down = () => {
20
+ pressing.current = true;
21
+ };
22
+ const up = () => {
23
+ queueMicrotask(() => {
24
+ pressing.current = false;
25
+ });
26
+ };
27
+ globalThis.addEventListener("pointerdown", down, true);
28
+ globalThis.addEventListener("pointerup", up, true);
29
+ return () => {
30
+ globalThis.removeEventListener("pointerdown", down, true);
31
+ globalThis.removeEventListener("pointerup", up, true);
32
+ };
33
+ }, []);
34
+ return (clear) => {
35
+ if (!pressing.current) {
36
+ clear();
37
+ return;
38
+ }
39
+ globalThis.addEventListener("click", clear, { once: true });
40
+ globalThis.addEventListener("pointercancel", clear, { once: true });
41
+ };
42
+ }
43
+ /** Where an arrow key moves along `count` marks from `at`; undefined for any other key. */
44
+ function nextMark(key, at, count) {
45
+ if (key === "ArrowRight" || key === "ArrowDown") return Math.min(at + 1, count - 1);
46
+ if (key === "ArrowLeft" || key === "ArrowUp") return Math.max(at - 1, 0);
47
+ if (key === "Home") return 0;
48
+ return key === "End" ? count - 1 : void 0;
49
+ }
50
+ /** The marks that open a row, in reading order: by point, then by series. */
51
+ function marksOf(drill, drawn, rows) {
52
+ return drawn.points.flatMap((_p, i) => drawn.series.flatMap((s) => {
53
+ const row = drawn.rowAt(i, s.key);
54
+ const props = row === void 0 || row >= rows ? void 0 : drill.props(row, entryOf(s));
55
+ if (props === void 0) return [];
56
+ const { role: _role, tabIndex: _tab, ...rest } = props;
57
+ return [{
58
+ key: `${String(i)}-${s.key}`,
59
+ point: i,
60
+ series: s.key,
61
+ props: rest
62
+ }];
63
+ }));
64
+ }
65
+ /** Arrow keys move focus along the list from the mark that has it, so the chart is one tab stop. */
66
+ function moveFocus(event) {
67
+ const buttons = [...event.currentTarget.querySelectorAll("button")];
68
+ const at = buttons.findIndex((b) => b === event.target);
69
+ const next = at < 0 ? void 0 : nextMark(event.key, at, buttons.length);
70
+ if (next === void 0) return;
71
+ event.preventDefault();
72
+ buttons[next]?.focus();
73
+ }
74
+ /**
75
+ * Every mark that opens, as a list of buttons a keyboard reaches, so the chart opens without a
76
+ * pointer. The list is one tab stop: arrow keys, Home and End move along it, however many marks
77
+ * there are. It stays visually hidden and out of the chart's layout; the chart outlines the mark
78
+ * that has focus (`onFocusMark`). Each says its group and value, as a screen reader reads it.
79
+ * Nothing when drilling is off: the chart's data table carries its values then.
80
+ */
81
+ function Marks(at) {
82
+ const clearAfterClick = usePressing();
83
+ const [current, setCurrent] = useState(0);
84
+ if (at.drill === void 0) return null;
85
+ const marks = marksOf(at.drill, at.drawn, at.rows);
86
+ if (marks.length === 0) return null;
87
+ const stop = Math.min(current, marks.length - 1);
88
+ return /* @__PURE__ */ jsx("ul", {
89
+ className: "dd-chart-marks",
90
+ "aria-label": at.label,
91
+ onKeyDown: moveFocus,
92
+ children: marks.map(({ key, point, series, props }, i) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
93
+ type: "button",
94
+ ...props,
95
+ tabIndex: i === stop ? 0 : -1,
96
+ onFocus: () => {
97
+ setCurrent(i);
98
+ at.onFocusMark({
99
+ point,
100
+ key: series
101
+ });
102
+ },
103
+ onBlur: () => {
104
+ clearAfterClick(() => {
105
+ at.onFocusMark(null);
106
+ });
107
+ },
108
+ children: String(props["aria-label"])
109
+ }) }, key))
110
+ });
111
+ }
112
+ export { Marks, nextMark, openPoint };
@@ -0,0 +1,88 @@
1
+ import { OTHER_KEY } from "./series.mjs";
2
+ import { cellText } from "./table.mjs";
3
+ import { lastBucketOpen } from "derive-dashboards/react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/parts.tsx
6
+ /** A series' colour: the palette in order, and Other always the quiet grey. */
7
+ /** Legend words in the text color: a series' hue marks its swatch, never its name. */
8
+ const legendText = (value) => /* @__PURE__ */ jsx("span", {
9
+ className: "dd-chart-legend",
10
+ children: value
11
+ });
12
+ /** A widget's own colors by series label (`display.colors`), else the palette in order. */
13
+ const colorsOf = (props) => {
14
+ const colors = props.widget.display?.["colors"];
15
+ return typeof colors === "object" && colors !== null ? new Map(Object.entries(colors)) : /* @__PURE__ */ new Map();
16
+ };
17
+ const color = (props, s, i) => {
18
+ const own = colorsOf(props).get(s.label);
19
+ if (typeof own === "string") return own;
20
+ return s.key === OTHER_KEY ? "var(--dd-other)" : `var(--dd-series-${i % 6 + 1})`;
21
+ };
22
+ /**
23
+ * A tooltip's value: the answer's own cell behind the point, in its own series' column, so an
24
+ * exact amount reads exactly and each series keeps its unit. Only the pixels use the float.
25
+ */
26
+ function tooltipFormat(props, drawn) {
27
+ return (value, _name, item) => {
28
+ const s = drawn.series.find((x) => x.key === item.dataKey);
29
+ if (s === void 0) return String(value);
30
+ const payload = item.payload;
31
+ const place = typeof payload === "object" && payload !== null && "#" in payload ? payload["#"] : void 0;
32
+ return cellText(props, drawn, {
33
+ place,
34
+ series: s,
35
+ value
36
+ });
37
+ };
38
+ }
39
+ /** Each line's own stroke, so series part by shape as well as by color. */
40
+ const DASHES = [
41
+ void 0,
42
+ "6 4",
43
+ "2 3",
44
+ "10 3 2 3"
45
+ ];
46
+ /** The i-th line's dash, or none for the first: a solid line takes no dash at all. */
47
+ const dashOf = (i) => {
48
+ const dash = DASHES[i % DASHES.length];
49
+ return dash === void 0 ? {} : { strokeDasharray: dash };
50
+ };
51
+ /**
52
+ * A tooltip's title: the point's name, "so far" on a time bucket still running, and what a
53
+ * click does when the chart drills.
54
+ */
55
+ const tooltipLabel = (props, running) => (label) => [
56
+ String(label),
57
+ running !== void 0 && String(label) === running ? props.messages.soFar : void 0,
58
+ props.drill === void 0 ? void 0 : props.messages.drillHint
59
+ ].filter((part) => part !== void 0).join(" · ");
60
+ /** The x label of the last point when its time bucket is still running. */
61
+ const runningLabel = (props, points) => lastBucketOpen(props.answer) ? points.at(-1)?.x : void 0;
62
+ /** The tooltip in the theme's colors, light and dark; the hover band a soft wash, not a gray slab. */
63
+ const TOOLTIP = {
64
+ separator: ": ",
65
+ contentStyle: {
66
+ background: "var(--dd-surface)",
67
+ border: "1px solid var(--dd-line)",
68
+ borderRadius: "var(--dd-radius)",
69
+ color: "var(--dd-ink)"
70
+ },
71
+ labelStyle: { color: "var(--dd-muted)" },
72
+ itemStyle: { color: "var(--dd-ink)" },
73
+ cursor: {
74
+ fill: "var(--dd-line)",
75
+ fillOpacity: .4,
76
+ stroke: "var(--dd-line)"
77
+ }
78
+ };
79
+ const CHART = {
80
+ accessibilityLayer: false,
81
+ margin: {
82
+ top: 4,
83
+ right: 8,
84
+ bottom: 0,
85
+ left: 0
86
+ }
87
+ };
88
+ export { CHART, TOOLTIP, color, dashOf, legendText, runningLabel, tooltipFormat, tooltipLabel };
@@ -1,22 +1,2 @@
1
- import { CellFormat } from "derive-dashboards/react";
2
- import { ResultColumn, TileAnswer } from "derive-dashboards/core";
3
- /** One point of a chart: its x label and a number per series key. */
4
- export type Point = {
5
- x: string;
6
- } & Record<string, number | string | null>;
7
- export type Series = {
8
- key: string;
9
- label: string;
10
- column: ResultColumn;
11
- };
12
- /**
13
- * Chart data from an answer. The first non-value column is the x axis (the time bucket when
14
- * there is one). With a second key column, the first value is split into one series per
15
- * value of it, and Other in that column is one more series; otherwise every value column is
16
- * its own series. Other on the x axis is one more point; totals are not drawn.
17
- */
18
- export declare function toSeries(answer: Pick<TileAnswer, "columns" | "rows">, format?: CellFormat): {
19
- points: Point[];
20
- series: Series[];
21
- split: boolean;
22
- };
1
+ import { Drawn, Point, Series, rowAt, toSeries } from "derive-dashboards/react";
2
+ export { type Drawn, type Point, type Series, rowAt, toSeries };
@@ -1,64 +1 @@
1
- import { ENGLISH, formatCell, plotValue } from "derive-dashboards/react";
2
- import { isMark } from "derive-dashboards/core";
3
- // src/series.ts
4
- const isValue = (c) => c.id.startsWith("m") || c.id.startsWith("c");
5
- /** The series key a dimension's Other draws as. */
6
- const OTHER_KEY = "other";
7
- const isAll = (cell) => isMark(cell) && cell.mark === "all";
8
- /**
9
- * Chart data from an answer. The first non-value column is the x axis (the time bucket when
10
- * there is one). With a second key column, the first value is split into one series per
11
- * value of it, and Other in that column is one more series; otherwise every value column is
12
- * its own series. Other on the x axis is one more point; totals are not drawn.
13
- */
14
- function toSeries(answer, format = {}) {
15
- const keyCount = answer.columns.filter((c) => !isValue(c)).length;
16
- const all = answer.columns.slice(keyCount);
17
- const calcs = all.filter((c) => c.id.startsWith("c"));
18
- const values = calcs.length > 0 ? calcs : all;
19
- const rows = answer.rows.filter((row) => !row.some((cell) => isAll(cell)));
20
- const keyText = (cell, column) => cell === null || cell === "" ? (format.messages ?? ENGLISH).empty : formatCell(cell, column, format);
21
- const xOf = (row) => keyText(row[0] ?? null, answer.columns[0]);
22
- if (keyCount < 2) {
23
- const series = values.map((column) => ({
24
- key: column.id,
25
- label: column.label,
26
- column
27
- }));
28
- return {
29
- points: rows.map((row) => ({
30
- x: keyCount === 0 ? "" : xOf(row),
31
- ...Object.fromEntries(values.map((c) => [c.id, plotValue(row[answer.columns.indexOf(c)] ?? null)]))
32
- })),
33
- series,
34
- split: false
35
- };
36
- }
37
- const first = values[0];
38
- if (first === void 0) return {
39
- points: [],
40
- series: [],
41
- split: true
42
- };
43
- const byX = /* @__PURE__ */ new Map();
44
- const names = /* @__PURE__ */ new Map();
45
- for (const row of rows) {
46
- const split = row[1] ?? null;
47
- const key = isMark(split) ? split.mark : `s${JSON.stringify(split)}`;
48
- names.set(key, keyText(split, answer.columns[1]));
49
- const point = byX.get(xOf(row)) ?? { x: xOf(row) };
50
- point[key] = plotValue(row[keyCount] ?? null);
51
- byX.set(xOf(row), point);
52
- }
53
- const series = [...names].map(([key, label]) => ({
54
- key,
55
- label,
56
- column: first
57
- })).toSorted((a, b) => Number(a.key === OTHER_KEY) - Number(b.key === OTHER_KEY));
58
- return {
59
- points: [...byX.values()],
60
- series,
61
- split: true
62
- };
63
- }
64
- export { OTHER_KEY, toSeries };
1
+ export { OTHER_KEY, rowAt, toSeries } from "derive-dashboards/react";
@@ -0,0 +1,71 @@
1
+ import { NotDrawn } from "./axes.mjs";
2
+ import { Marks } from "./marks.mjs";
3
+ import { formatCell } from "derive-dashboards/react";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ // src/table.tsx
6
+ /**
7
+ * The answer's own cell behind a point of a series, formatted in its column, so an exact amount
8
+ * reads exactly and each series keeps its unit; the drawn number when no row stands behind it.
9
+ */
10
+ function cellText(props, drawn, at) {
11
+ const { answer } = props;
12
+ const row = typeof at.place === "number" ? drawn.rowAt(at.place, at.series.key) : void 0;
13
+ const cell = row === void 0 ? void 0 : answer.rows[row]?.[answer.columns.indexOf(at.series.column)];
14
+ if (cell !== void 0) return formatCell(cell, at.series.column, props);
15
+ if (typeof at.value === "number") return formatCell(at.value, at.series.column, props);
16
+ const v = at.value;
17
+ return typeof v === "string" || typeof v === "boolean" || typeof v === "bigint" ? String(v) : "";
18
+ }
19
+ /**
20
+ * The chart as a table, for screen readers: what a sighted reader gets from the picture and its
21
+ * tooltips, read with a screen reader's table keys. Visually hidden and out of the tab order, so
22
+ * a keyboard is never walked through every value; the picture itself is hidden from them.
23
+ */
24
+ function ChartTable({ drawn, props, kind }) {
25
+ const { points, series } = drawn;
26
+ return /* @__PURE__ */ jsxs("table", {
27
+ className: "dd-sr-only",
28
+ children: [
29
+ /* @__PURE__ */ jsx("caption", { children: props.messages.chartTable({
30
+ title: props.widget.title,
31
+ kind,
32
+ points: points.length
33
+ }) }),
34
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("td", {}), series.map((s) => /* @__PURE__ */ jsx("th", {
35
+ scope: "col",
36
+ children: s.label
37
+ }, s.key))] }) }),
38
+ /* @__PURE__ */ jsx("tbody", { children: points.map((point, place) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
39
+ scope: "row",
40
+ children: point.x
41
+ }), series.map((s) => /* @__PURE__ */ jsx("td", { children: cellText(props, drawn, {
42
+ place,
43
+ series: s,
44
+ value: point[s.key]
45
+ }) }, s.key))] }, point.x)) })
46
+ ]
47
+ });
48
+ }
49
+ /** What sits beside every chart: its keyboard path, what it does not draw, and its data table. */
50
+ function Beside(at) {
51
+ const { drawn, props } = at;
52
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
53
+ /* @__PURE__ */ jsx(Marks, {
54
+ drill: props.drill,
55
+ drawn,
56
+ rows: props.answer.rows.length,
57
+ label: props.messages.chartPoints,
58
+ onFocusMark: at.onFocusMark
59
+ }),
60
+ /* @__PURE__ */ jsx(NotDrawn, {
61
+ drawn,
62
+ props
63
+ }),
64
+ /* @__PURE__ */ jsx(ChartTable, {
65
+ drawn,
66
+ props,
67
+ kind: at.kind
68
+ })
69
+ ] });
70
+ }
71
+ export { Beside, cellText };
@@ -0,0 +1,44 @@
1
+ import { openCursor, sealCursor } from "./cursor-seal.mjs";
2
+ import { bind, reading } from "./execute.mjs";
3
+ import { recordColumns } from "derive-dashboards/core";
4
+ import { readRecords } from "derive-dashboards/core/engine";
5
+ // src/records-read.ts
6
+ /**
7
+ * A page of rows, its cursor sealed to the viewer's tenant and to everything that decides which
8
+ * rows come next: the query (a drill's filters in it), the columns and order read, the lock and
9
+ * required filters, and who asks (`by`), so a cursor never continues another population.
10
+ */
11
+ async function readPage(x, page) {
12
+ const bound = bind(x);
13
+ const key = await x.rt.cursorKey;
14
+ const on = {
15
+ query: bound.input.query,
16
+ shape: page.shape ?? null,
17
+ lock: bound.lock,
18
+ required: bound.required,
19
+ by: page.by ?? null
20
+ };
21
+ const at = {
22
+ principal: x.principal,
23
+ on
24
+ };
25
+ const after = page.after === void 0 ? {} : { after: await openCursor(key, page.after, at) };
26
+ const shape = page.shape === void 0 ? {} : { shape: page.shape };
27
+ const { value } = await reading(x, page.limit, (reader) => readRecords(bound.input, {
28
+ limit: page.limit,
29
+ ...after,
30
+ ...shape
31
+ }, reader));
32
+ const next = value.next === void 0 ? {} : { next: await sealCursor(key, value.next, at) };
33
+ return {
34
+ ...value,
35
+ ...next,
36
+ columns: recordColumns(x.rt.options.model, x.query.source, value.columns)
37
+ };
38
+ }
39
+ /** A page of the rows behind a query, under the same access, filters and range as its answer. */
40
+ async function executeRecords(x, page) {
41
+ const { keys: _keys, ...records } = await readPage(x, page);
42
+ return records;
43
+ }
44
+ export { executeRecords, readPage };