derive-dashboards 0.8.0 → 0.9.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 (585) hide show
  1. package/CHANGELOG.md +513 -0
  2. package/README.md +8 -2
  3. package/dist/adapter/statement.mjs +9 -7
  4. package/dist/authorize.mjs +27 -6
  5. package/dist/body.mjs +28 -25
  6. package/dist/cache.d.mts +2 -2
  7. package/dist/charts/data/buckets.d.mts +25 -7
  8. package/dist/charts/data/buckets.mjs +92 -15
  9. package/dist/charts/data/clean.mjs +254 -12
  10. package/dist/charts/data/format.d.mts +7 -2
  11. package/dist/charts/data/format.mjs +68 -70
  12. package/dist/charts/data/input-error.d.mts +2 -0
  13. package/dist/charts/data/input-error.mjs +2 -0
  14. package/dist/charts/data/rows.d.mts +3 -1
  15. package/dist/charts/data/rows.mjs +4 -2
  16. package/dist/charts/data/types.d.mts +50 -7
  17. package/dist/charts/data/words.d.mts +13 -0
  18. package/dist/charts/data/words.mjs +8 -1
  19. package/dist/charts/describe.mjs +6 -6
  20. package/dist/charts/index.d.mts +14 -14
  21. package/dist/charts/index.mjs +4 -1
  22. package/dist/charts/kinds/area-marks.mjs +67 -26
  23. package/dist/charts/kinds/area.d.mts +3 -3
  24. package/dist/charts/kinds/area.mjs +32 -11
  25. package/dist/charts/kinds/bars-data.d.mts +3 -3
  26. package/dist/charts/kinds/bars-data.mjs +12 -6
  27. package/dist/charts/kinds/bars-layout.mjs +60 -6
  28. package/dist/charts/kinds/bars-marks.mjs +6 -6
  29. package/dist/charts/kinds/bars.d.mts +5 -3
  30. package/dist/charts/kinds/bars.mjs +39 -6
  31. package/dist/charts/kinds/columns-data.mjs +14 -5
  32. package/dist/charts/kinds/columns-marks.mjs +52 -23
  33. package/dist/charts/kinds/columns.d.mts +2 -2
  34. package/dist/charts/kinds/columns.mjs +36 -10
  35. package/dist/charts/kinds/course-data.mjs +44 -0
  36. package/dist/charts/kinds/course-layout.mjs +77 -0
  37. package/dist/charts/kinds/course-marks.mjs +52 -0
  38. package/dist/charts/kinds/course-words.mjs +64 -0
  39. package/dist/charts/kinds/course.d.mts +10 -0
  40. package/dist/charts/kinds/course.mjs +55 -0
  41. package/dist/charts/kinds/dumbbell-data.d.mts +4 -4
  42. package/dist/charts/kinds/dumbbell-data.mjs +3 -3
  43. package/dist/charts/kinds/dumbbell-layout.mjs +17 -8
  44. package/dist/charts/kinds/dumbbell.d.mts +5 -3
  45. package/dist/charts/kinds/dumbbell.mjs +35 -4
  46. package/dist/charts/kinds/funnel-data.d.mts +3 -3
  47. package/dist/charts/kinds/funnel-data.mjs +11 -16
  48. package/dist/charts/kinds/funnel-layout.mjs +7 -6
  49. package/dist/charts/kinds/funnel.d.mts +5 -4
  50. package/dist/charts/kinds/funnel.mjs +33 -6
  51. package/dist/charts/kinds/grid-data.d.mts +3 -3
  52. package/dist/charts/kinds/grid-data.mjs +55 -13
  53. package/dist/charts/kinds/grid-layout.mjs +88 -13
  54. package/dist/charts/kinds/grid-legend.mjs +60 -0
  55. package/dist/charts/kinds/grid-marks.mjs +81 -30
  56. package/dist/charts/kinds/grid-time.mjs +19 -5
  57. package/dist/charts/kinds/grid-words.mjs +57 -35
  58. package/dist/charts/kinds/grid.d.mts +7 -4
  59. package/dist/charts/kinds/grid.mjs +49 -8
  60. package/dist/charts/kinds/histogram-data.mjs +68 -26
  61. package/dist/charts/kinds/histogram-layout.mjs +4 -3
  62. package/dist/charts/kinds/histogram-words.mjs +2 -3
  63. package/dist/charts/kinds/histogram.d.mts +2 -2
  64. package/dist/charts/kinds/histogram.mjs +17 -1
  65. package/dist/charts/kinds/line-marks.mjs +19 -11
  66. package/dist/charts/kinds/line.d.mts +2 -2
  67. package/dist/charts/kinds/line.mjs +21 -3
  68. package/dist/charts/kinds/multiples-grid.mjs +57 -27
  69. package/dist/charts/kinds/multiples-head.mjs +52 -22
  70. package/dist/charts/kinds/multiples-layout.mjs +106 -52
  71. package/dist/charts/kinds/multiples-marks.mjs +6 -5
  72. package/dist/charts/kinds/multiples-words.mjs +53 -38
  73. package/dist/charts/kinds/multiples.d.mts +2 -2
  74. package/dist/charts/kinds/multiples.mjs +35 -7
  75. package/dist/charts/kinds/row-chart.d.mts +7 -0
  76. package/dist/charts/kinds/row-chart.mjs +47 -10
  77. package/dist/charts/kinds/row-marks.mjs +5 -5
  78. package/dist/charts/kinds/scatter-data.d.mts +5 -5
  79. package/dist/charts/kinds/scatter-data.mjs +6 -6
  80. package/dist/charts/kinds/scatter-marks.mjs +46 -19
  81. package/dist/charts/kinds/scatter-words.mjs +8 -8
  82. package/dist/charts/kinds/scatter.d.mts +5 -3
  83. package/dist/charts/kinds/scatter.mjs +18 -0
  84. package/dist/charts/kinds/stat-data.mjs +7 -7
  85. package/dist/charts/kinds/stat-marks.mjs +2 -2
  86. package/dist/charts/kinds/stat.d.mts +4 -4
  87. package/dist/charts/kinds/stat.mjs +19 -0
  88. package/dist/charts/kinds/time-chart.mjs +13 -4
  89. package/dist/charts/kinds/time-frame.mjs +50 -19
  90. package/dist/charts/kinds/time-plan.mjs +29 -2
  91. package/dist/charts/kinds/time-plot.mjs +1 -1
  92. package/dist/charts/kinds/time-stops.mjs +58 -29
  93. package/dist/charts/kinds/waterfall-data.d.mts +3 -3
  94. package/dist/charts/kinds/waterfall-data.mjs +2 -2
  95. package/dist/charts/kinds/waterfall.d.mts +5 -4
  96. package/dist/charts/kinds/waterfall.mjs +29 -2
  97. package/dist/charts/layout/frame.mjs +5 -3
  98. package/dist/charts/layout/stack.mjs +43 -22
  99. package/dist/charts/marks/axes.mjs +10 -5
  100. package/dist/charts/marks/budget.mjs +14 -0
  101. package/dist/charts/marks/end-labels.mjs +24 -10
  102. package/dist/charts/marks/legend.mjs +19 -8
  103. package/dist/charts/marks/lines.mjs +3 -3
  104. package/dist/charts/marks/more.mjs +79 -13
  105. package/dist/charts/marks/notes.mjs +12 -6
  106. package/dist/charts/marks/series-line.mjs +14 -10
  107. package/dist/charts/marks/thin.mjs +16 -33
  108. package/dist/charts/scale/calendar.mjs +41 -26
  109. package/dist/charts/scale/linear.mjs +58 -0
  110. package/dist/charts/scale/value.d.mts +21 -0
  111. package/dist/charts/scale/value.mjs +67 -9
  112. package/dist/charts/scene/lazy.mjs +27 -0
  113. package/dist/charts/scene/markup.mjs +2 -1
  114. package/dist/charts/scene/svg.mjs +20 -8
  115. package/dist/charts/scene/types.d.mts +34 -0
  116. package/dist/charts/text/measure.mjs +33 -3
  117. package/dist/charts/theme.mjs +13 -4
  118. package/dist/charts-react/Chart.d.mts +20 -0
  119. package/dist/charts-react/Chart.mjs +9 -67
  120. package/dist/charts-react/Reader.mjs +50 -96
  121. package/dist/charts-react/box.mjs +106 -0
  122. package/dist/charts-react/bucket-names.mjs +9 -24
  123. package/dist/charts-react/columns-picture.mjs +12 -0
  124. package/dist/charts-react/exact-sum.mjs +4 -7
  125. package/dist/charts-react/from-answer.mjs +9 -4
  126. package/dist/charts-react/index.d.mts +9 -2
  127. package/dist/charts-react/index.mjs +9 -2
  128. package/dist/charts-react/kinds/area.d.mts +4 -0
  129. package/dist/charts-react/kinds/area.mjs +38 -0
  130. package/dist/charts-react/kinds/bar.d.mts +4 -0
  131. package/dist/charts-react/kinds/bar.mjs +15 -0
  132. package/dist/charts-react/kinds/funnel.d.mts +4 -0
  133. package/dist/charts-react/kinds/funnel.mjs +13 -0
  134. package/dist/charts-react/kinds/heatmap.d.mts +4 -0
  135. package/dist/charts-react/kinds/heatmap.mjs +13 -0
  136. package/dist/charts-react/kinds/line.d.mts +4 -0
  137. package/dist/charts-react/kinds/line.mjs +20 -0
  138. package/dist/charts-react/kinds/multiples.d.mts +4 -0
  139. package/dist/charts-react/kinds/multiples.mjs +33 -0
  140. package/dist/charts-react/kinds/number.d.mts +5 -0
  141. package/dist/charts-react/kinds/number.mjs +86 -0
  142. package/dist/charts-react/plan-bars.mjs +15 -8
  143. package/dist/charts-react/plan-funnel.mjs +3 -1
  144. package/dist/charts-react/plan-grid.mjs +14 -5
  145. package/dist/charts-react/plan-of.mjs +17 -0
  146. package/dist/charts-react/plan-parts.mjs +16 -5
  147. package/dist/charts-react/plan-time.mjs +4 -53
  148. package/dist/charts-react/reader-page.d.mts +1 -1
  149. package/dist/charts-react/reader-page.mjs +19 -9
  150. package/dist/charts-react/renderers.d.mts +14 -0
  151. package/dist/charts-react/renderers.mjs +22 -0
  152. package/dist/charts-react/table.d.mts +1 -0
  153. package/dist/charts-react/table.mjs +108 -0
  154. package/dist/charts-react/tiles.mjs +21 -49
  155. package/dist/charts-react/useScene.mjs +45 -17
  156. package/dist/charts-react/words.mjs +19 -0
  157. package/dist/checks.mjs +97 -19
  158. package/dist/cli/add.mjs +4 -3
  159. package/dist/cli/doctor.mjs +2 -2
  160. package/dist/core/conformance/index.d.mts +5 -2
  161. package/dist/core/conformance/index.mjs +5 -2
  162. package/dist/core/conformance/memory/aggregate.mjs +11 -6
  163. package/dist/core/conformance/memory/rows.d.mts +7 -3
  164. package/dist/core/conformance/memory/rows.mjs +19 -13
  165. package/dist/core/conformance/memory/source.mjs +4 -4
  166. package/dist/core/document/control-fields.d.mts +20 -0
  167. package/dist/core/document/control-fields.mjs +117 -0
  168. package/dist/core/document/display-comparisons.d.mts +17 -0
  169. package/dist/core/document/display-comparisons.mjs +15 -4
  170. package/dist/core/document/display-entries.d.mts +14 -0
  171. package/dist/core/document/display-entries.mjs +25 -9
  172. package/dist/core/document/display-validation.d.mts +5 -1
  173. package/dist/core/document/display-validation.mjs +14 -7
  174. package/dist/core/document/display.d.mts +10 -8
  175. package/dist/core/document/display.mjs +25 -4
  176. package/dist/core/document/layout.d.mts +8 -9
  177. package/dist/core/document/layout.mjs +23 -6
  178. package/dist/core/document/stacked.d.mts +0 -7
  179. package/dist/core/document/types.mjs +8 -6
  180. package/dist/core/document/upgrade.d.mts +1 -0
  181. package/dist/core/document/upgrade.mjs +4 -2
  182. package/dist/core/engine/access.mjs +3 -3
  183. package/dist/core/engine/assert.mjs +4 -2
  184. package/dist/core/engine/bucket.mjs +2 -2
  185. package/dist/core/engine/checks.mjs +6 -7
  186. package/dist/core/engine/custom/ask.mjs +22 -2
  187. package/dist/core/engine/custom/cells.mjs +22 -22
  188. package/dist/core/engine/custom/level.mjs +12 -13
  189. package/dist/core/engine/custom/measures.mjs +12 -9
  190. package/dist/core/engine/custom/reader.mjs +3 -1
  191. package/dist/core/engine/custom/records.mjs +8 -7
  192. package/dist/core/engine/custom/unread.mjs +78 -0
  193. package/dist/core/engine/custom/where.mjs +15 -10
  194. package/dist/core/engine/index.d.mts +2 -13
  195. package/dist/core/engine/index.mjs +2 -12
  196. package/dist/core/engine/measure.mjs +1 -0
  197. package/dist/core/engine/members.mjs +7 -3
  198. package/dist/core/engine/nan.mjs +10 -1
  199. package/dist/core/engine/native.mjs +2 -20
  200. package/dist/core/engine/numbers.mjs +26 -14
  201. package/dist/core/engine/postgres.mjs +9 -5
  202. package/dist/core/engine/prepare.mjs +4 -4
  203. package/dist/core/engine/rank-sets.mjs +1 -1
  204. package/dist/core/engine/read.mjs +5 -4
  205. package/dist/core/engine/reader.d.mts +6 -0
  206. package/dist/core/engine/record-layout.mjs +3 -3
  207. package/dist/core/engine/run.mjs +77 -20
  208. package/dist/core/engine/segmented.d.mts +2 -1
  209. package/dist/core/engine/segmented.mjs +19 -12
  210. package/dist/core/engine/series.mjs +1 -1
  211. package/dist/core/engine/shape.mjs +8 -8
  212. package/dist/core/engine/sql-partition.mjs +2 -2
  213. package/dist/core/engine/sql-pass.mjs +3 -2
  214. package/dist/core/engine/sql-reader.mjs +13 -5
  215. package/dist/core/engine/sql-reads.mjs +2 -1
  216. package/dist/core/engine/sql-records.mjs +2 -2
  217. package/dist/core/engine/sql-split.mjs +1 -1
  218. package/dist/core/engine/sql-unread.mjs +70 -0
  219. package/dist/core/engine/time.mjs +2 -1
  220. package/dist/core/engine/types.d.mts +17 -0
  221. package/dist/core/engine/version.d.mts +1 -1
  222. package/dist/core/engine/version.mjs +1 -1
  223. package/dist/core/error/codes.d.mts +24 -1
  224. package/dist/core/error/codes.mjs +23 -3
  225. package/dist/core/error/refusal.d.mts +8 -3
  226. package/dist/core/error/refusal.mjs +6 -1
  227. package/dist/core/exact/decimal.d.mts +1 -14
  228. package/dist/core/exact/decimal.mjs +9 -19
  229. package/dist/core/exact/stored.d.mts +9 -0
  230. package/dist/core/exact/stored.mjs +38 -0
  231. package/dist/core/exact/text.d.mts +16 -1
  232. package/dist/core/exact/text.mjs +50 -1
  233. package/dist/core/format/digits.mjs +55 -0
  234. package/dist/core/format/index.d.mts +16 -0
  235. package/dist/core/format/index.mjs +27 -0
  236. package/dist/core/format/number.d.mts +27 -0
  237. package/dist/core/format/number.mjs +158 -0
  238. package/dist/core/format/write.d.mts +6 -0
  239. package/dist/core/format/write.mjs +57 -0
  240. package/dist/core/index.d.mts +43 -33
  241. package/dist/core/index.mjs +31 -28
  242. package/dist/core/model/defaults.d.mts +18 -1
  243. package/dist/core/model/defaults.mjs +19 -1
  244. package/dist/core/model/define.d.mts +17 -8
  245. package/dist/core/model/define.mjs +2 -0
  246. package/dist/core/model/member.d.mts +5 -3
  247. package/dist/core/model/member.mjs +33 -6
  248. package/dist/core/model/storage.mjs +40 -12
  249. package/dist/core/model/types.d.mts +17 -1
  250. package/dist/core/model/types.mjs +5 -0
  251. package/dist/core/model/validate/expr.d.mts +1 -7
  252. package/dist/core/model/validate/fields.d.mts +2 -0
  253. package/dist/core/model/validate/fields.mjs +14 -7
  254. package/dist/core/model/validate/issues.mjs +5 -1
  255. package/dist/core/model/validate/known-members.mjs +6 -5
  256. package/dist/core/model/validate/shape.mjs +36 -3
  257. package/dist/core/model/validate/source.mjs +2 -2
  258. package/dist/core/oracle/data.d.mts +4 -2
  259. package/dist/core/oracle/evaluate.d.mts +19 -1
  260. package/dist/core/oracle/evaluate.mjs +56 -10
  261. package/dist/core/oracle/expr.mjs +1 -1
  262. package/dist/core/oracle/facts.mjs +12 -5
  263. package/dist/core/oracle/measure.mjs +1 -1
  264. package/dist/core/oracle/request.mjs +39 -4
  265. package/dist/core/oracle/segmented.d.mts +3 -1
  266. package/dist/core/oracle/segmented.mjs +19 -13
  267. package/dist/core/oracle/unread.mjs +32 -0
  268. package/dist/core/oracle/visibility.mjs +4 -3
  269. package/dist/core/policy/bind.d.mts +2 -11
  270. package/dist/core/policy/bind.mjs +1 -1
  271. package/dist/core/policy/match.mjs +1 -1
  272. package/dist/core/query/closure.d.mts +7 -2
  273. package/dist/core/query/closure.mjs +29 -12
  274. package/dist/core/query/compose-tile.d.mts +3 -2
  275. package/dist/core/query/compose-tile.mjs +32 -13
  276. package/dist/core/query/compose.d.mts +0 -5
  277. package/dist/core/query/drill/internal.d.mts +5 -5
  278. package/dist/core/query/drill/internal.mjs +11 -0
  279. package/dist/core/query/drill/links.d.mts +2 -3
  280. package/dist/core/query/drill/links.mjs +18 -4
  281. package/dist/core/query/drill/selection.d.mts +8 -2
  282. package/dist/core/query/drill/selection.mjs +14 -3
  283. package/dist/core/query/drill/synthetic.mjs +1 -1
  284. package/dist/core/query/drill/time.mjs +11 -10
  285. package/dist/core/query/filter.d.mts +1 -6
  286. package/dist/core/query/filter.mjs +1 -4
  287. package/dist/core/query/fold.mjs +23 -0
  288. package/dist/core/query/segments.mjs +42 -3
  289. package/dist/core/query/to-wire.d.mts +7 -0
  290. package/dist/core/query/to-wire.mjs +14 -2
  291. package/dist/core/query/types.d.mts +30 -13
  292. package/dist/core/result/columns.mjs +23 -13
  293. package/dist/core/result/number.mjs +3 -3
  294. package/dist/core/result/status.d.mts +13 -0
  295. package/dist/core/result/status.mjs +18 -0
  296. package/dist/core/result/time-axis.d.mts +14 -13
  297. package/dist/core/result/time-axis.mjs +20 -2
  298. package/dist/core/result/types.d.mts +33 -3
  299. package/dist/core/result/whole.d.mts +23 -0
  300. package/dist/core/result/whole.mjs +27 -0
  301. package/dist/core/schema/agent-query.d.mts +89 -0
  302. package/dist/core/schema/agent-query.mjs +115 -0
  303. package/dist/core/schema/aliases.mjs +1 -52
  304. package/dist/core/schema/answer-parts.mjs +17 -13
  305. package/dist/core/schema/answers.d.mts +787 -319
  306. package/dist/core/schema/commands.d.mts +33 -23
  307. package/dist/core/schema/commands.mjs +26 -18
  308. package/dist/core/schema/custom.mjs +46 -45
  309. package/dist/core/schema/document.d.mts +32 -27
  310. package/dist/core/schema/document.mjs +61 -81
  311. package/dist/core/schema/drill-answers.mjs +4 -1
  312. package/dist/core/schema/drill.d.mts +14 -9
  313. package/dist/core/schema/drill.mjs +23 -22
  314. package/dist/core/schema/index.d.mts +5 -3
  315. package/dist/core/schema/index.mjs +5 -3
  316. package/dist/core/schema/options.d.mts +92 -0
  317. package/dist/core/schema/options.mjs +104 -0
  318. package/dist/core/schema/picks.d.mts +2 -2
  319. package/dist/core/schema/picks.mjs +7 -6
  320. package/dist/core/schema/query.d.mts +9 -83
  321. package/dist/core/schema/query.mjs +49 -73
  322. package/dist/core/schema/strict.d.mts +3 -0
  323. package/dist/core/schema/strict.mjs +91 -0
  324. package/dist/core/schema/union-error.mjs +30 -7
  325. package/dist/core/schema/view.d.mts +4 -3
  326. package/dist/core/schema/view.mjs +16 -11
  327. package/dist/core/store/ddl.d.mts +0 -2
  328. package/dist/core/store/ddl.mjs +1 -5
  329. package/dist/core/time/bucket.d.mts +1 -19
  330. package/dist/core/time/bucket.mjs +6 -6
  331. package/dist/core/time/compare.mjs +3 -2
  332. package/dist/core/time/index.d.mts +7 -8
  333. package/dist/core/time/instant.d.mts +15 -9
  334. package/dist/core/time/instant.mjs +23 -9
  335. package/dist/core/time/range.d.mts +3 -15
  336. package/dist/core/time/range.mjs +17 -7
  337. package/dist/core/time/stored.d.mts +8 -5
  338. package/dist/core/time/stored.mjs +51 -15
  339. package/dist/core/time/temporal.d.mts +1 -5
  340. package/dist/core/time/temporal.mjs +9 -4
  341. package/dist/core/time/text-time.d.mts +31 -2
  342. package/dist/core/time/text-time.mjs +139 -22
  343. package/dist/core/time/zone.mjs +2 -2
  344. package/dist/core/types/api.d.mts +1 -1
  345. package/dist/core/types/api.mjs +1 -1
  346. package/dist/core/types/dashboard.d.mts +185 -0
  347. package/dist/core/types/dashboard.mjs +26 -0
  348. package/dist/core/types/drill-api.d.mts +14 -2
  349. package/dist/core/types/infer.d.mts +0 -4
  350. package/dist/core/types/options-check.d.mts +42 -0
  351. package/dist/core/types/options-check.mjs +90 -0
  352. package/dist/core/types/options.d.mts +14 -8
  353. package/dist/core/value/casefold.d.mts +1 -3
  354. package/dist/core/value/stored.d.mts +26 -0
  355. package/dist/core/value/stored.mjs +28 -0
  356. package/dist/cursor-seal.mjs +37 -9
  357. package/dist/dashboard-documents.d.mts +14 -6
  358. package/dist/dashboard-documents.mjs +32 -12
  359. package/dist/dashboards.mjs +10 -9
  360. package/dist/drill-access.mjs +6 -6
  361. package/dist/drill-change.mjs +18 -20
  362. package/dist/drill-comparison.mjs +2 -1
  363. package/dist/drill-crumbs.mjs +63 -28
  364. package/dist/drill-distinct.mjs +2 -1
  365. package/dist/drill-explain.mjs +1 -1
  366. package/dist/drill-items.mjs +1 -1
  367. package/dist/drill-open.mjs +39 -23
  368. package/dist/drill-seal.mjs +41 -13
  369. package/dist/drill-share.mjs +1 -1
  370. package/dist/drill-summary.mjs +2 -1
  371. package/dist/drill-targets.mjs +4 -4
  372. package/dist/drill-views.mjs +4 -3
  373. package/dist/drill.mjs +1 -1
  374. package/dist/editing.mjs +5 -3
  375. package/dist/endpoints/index.d.mts +29 -8
  376. package/dist/endpoints/index.mjs +4 -1
  377. package/dist/endpoints/meta.mjs +4 -3
  378. package/dist/endpoints/query.mjs +5 -2
  379. package/dist/endpoints/read.mjs +7 -6
  380. package/dist/endpoints/versions.mjs +2 -1
  381. package/dist/execute.d.mts +3 -0
  382. package/dist/execute.mjs +23 -12
  383. package/dist/grant.d.mts +9 -0
  384. package/dist/grant.mjs +43 -0
  385. package/dist/handler.mjs +8 -13
  386. package/dist/http.d.mts +6 -2
  387. package/dist/http.mjs +6 -2
  388. package/dist/index.d.mts +25 -4
  389. package/dist/index.mjs +91 -40
  390. package/dist/llms.txt +3 -3
  391. package/dist/mcp/api.mjs +2 -1
  392. package/dist/mcp/query.mjs +3 -8
  393. package/dist/mcp/resolve.mjs +9 -2
  394. package/dist/node/index.d.mts +36 -0
  395. package/dist/node/index.mjs +89 -0
  396. package/dist/node/request.d.mts +12 -0
  397. package/dist/node/request.mjs +119 -0
  398. package/dist/node/response.mjs +58 -0
  399. package/dist/principal.mjs +15 -7
  400. package/dist/react/Canvas.mjs +88 -67
  401. package/dist/react/Cell.mjs +2 -1
  402. package/dist/react/Dashboard.d.mts +9 -1
  403. package/dist/react/Dashboard.mjs +42 -42
  404. package/dist/react/DashboardList.mjs +9 -4
  405. package/dist/react/Editing.d.mts +9 -0
  406. package/dist/react/Editing.mjs +8 -3
  407. package/dist/react/Grid.mjs +1 -1
  408. package/dist/react/Header.mjs +4 -35
  409. package/dist/react/History.mjs +3 -2
  410. package/dist/react/LoadFailed.mjs +59 -0
  411. package/dist/react/Panel.d.mts +1 -1
  412. package/dist/react/Panel.mjs +1 -1
  413. package/dist/react/Parts.d.mts +34 -0
  414. package/dist/react/Parts.mjs +9 -6
  415. package/dist/react/ReviewPanel.mjs +1 -1
  416. package/dist/react/RowBody.d.mts +2 -0
  417. package/dist/react/RowBody.mjs +5 -1
  418. package/dist/react/Share.mjs +153 -0
  419. package/dist/react/TabStrip.mjs +37 -0
  420. package/dist/react/Tile.d.mts +3 -1
  421. package/dist/react/Tile.mjs +89 -92
  422. package/dist/react/TileState.mjs +117 -0
  423. package/dist/react/ago.mjs +45 -0
  424. package/dist/react/arrange.mjs +1 -1
  425. package/dist/react/board.mjs +2 -2
  426. package/dist/react/bucket-name.d.mts +8 -0
  427. package/dist/react/bucket-name.mjs +13 -0
  428. package/dist/react/builder/DisplayOptions.mjs +219 -0
  429. package/dist/react/builder/Preview.mjs +13 -13
  430. package/dist/react/builder/RangeEditor.mjs +4 -3
  431. package/dist/react/builder/WidgetBuilder.d.mts +1 -7
  432. package/dist/react/builder/WidgetBuilder.mjs +12 -3
  433. package/dist/react/builder/base.d.mts +13 -2
  434. package/dist/react/builder/base.mjs +70 -12
  435. package/dist/react/builder/display.d.mts +3 -0
  436. package/dist/react/builder/display.mjs +256 -0
  437. package/dist/react/builder/labels.mjs +19 -5
  438. package/dist/react/builder/options.mjs +11 -6
  439. package/dist/react/builder/state.mjs +25 -3
  440. package/dist/react/builder/useBuilder.d.mts +7 -1
  441. package/dist/react/builder/useBuilder.mjs +6 -9
  442. package/dist/react/builder/usePreview.mjs +3 -2
  443. package/dist/react/builder/words.d.mts +16 -1
  444. package/dist/react/builder/words.mjs +41 -1
  445. package/dist/react/change-text.mjs +149 -0
  446. package/dist/react/client.d.mts +9 -0
  447. package/dist/react/client.mjs +105 -14
  448. package/dist/react/context.d.mts +24 -3
  449. package/dist/react/context.mjs +23 -7
  450. package/dist/react/dates-shown.mjs +76 -0
  451. package/dist/react/draft.mjs +3 -2
  452. package/dist/react/drill/Bars.mjs +12 -16
  453. package/dist/react/drill/Comparison.mjs +1 -1
  454. package/dist/react/drill/DrillPanel.d.mts +1 -1
  455. package/dist/react/drill/DrillPanel.mjs +2 -1
  456. package/dist/react/drill/Header.mjs +65 -12
  457. package/dist/react/drill/Items.d.mts +1 -1
  458. package/dist/react/drill/Notes.mjs +10 -7
  459. package/dist/react/drill/PanelStates.mjs +8 -1
  460. package/dist/react/drill/Trend.mjs +10 -5
  461. package/dist/react/drill/board.d.mts +1 -1
  462. package/dist/react/drill/host.mjs +4 -1
  463. package/dist/react/drill/lazy.mjs +2 -27
  464. package/dist/react/drill/props.d.mts +17 -7
  465. package/dist/react/drill/props.mjs +55 -14
  466. package/dist/react/drill/state.d.mts +15 -5
  467. package/dist/react/drill/state.mjs +12 -3
  468. package/dist/react/drill/words.d.mts +46 -3
  469. package/dist/react/drill/words.mjs +30 -5
  470. package/dist/react/english.mjs +33 -8
  471. package/dist/react/export/ExportButton.mjs +4 -1
  472. package/dist/react/export/csv.d.mts +7 -2
  473. package/dist/react/export/csv.mjs +24 -7
  474. package/dist/react/failure-words.mjs +60 -0
  475. package/dist/react/filters/bar.d.mts +1 -1
  476. package/dist/react/filters/bar.mjs +4 -1
  477. package/dist/react/filters/calendar.mjs +23 -8
  478. package/dist/react/filters/chip.mjs +7 -3
  479. package/dist/react/filters/context.d.mts +13 -1
  480. package/dist/react/filters/context.mjs +1 -1
  481. package/dist/react/filters/dates-said.mjs +57 -0
  482. package/dist/react/filters/days.d.mts +3 -4
  483. package/dist/react/filters/days.mjs +10 -17
  484. package/dist/react/filters/hooks.d.mts +11 -0
  485. package/dist/react/filters/hooks.mjs +10 -6
  486. package/dist/react/filters/menu-search.mjs +17 -9
  487. package/dist/react/filters/menu.mjs +10 -8
  488. package/dist/react/filters/phone.mjs +41 -16
  489. package/dist/react/filters/place.mjs +40 -0
  490. package/dist/react/filters/popover.mjs +18 -13
  491. package/dist/react/filters/rules.d.mts +4 -3
  492. package/dist/react/filters/rules.mjs +3 -3
  493. package/dist/react/filters/sheet.mjs +7 -3
  494. package/dist/react/filters/state.mjs +6 -1
  495. package/dist/react/filters/values.mjs +24 -7
  496. package/dist/react/filters/words.d.mts +13 -0
  497. package/dist/react/filters/words.mjs +5 -0
  498. package/dist/react/format-time.d.mts +17 -6
  499. package/dist/react/format-time.mjs +152 -33
  500. package/dist/react/format.d.mts +3 -3
  501. package/dist/react/format.mjs +27 -133
  502. package/dist/react/headline.d.mts +6 -3
  503. package/dist/react/headline.mjs +81 -25
  504. package/dist/react/index.d.mts +19 -17
  505. package/dist/react/index.mjs +12 -10
  506. package/dist/react/lazy.mjs +38 -0
  507. package/dist/react/messages.d.mts +78 -2
  508. package/dist/react/now.mjs +38 -0
  509. package/dist/react/read.d.mts +1 -0
  510. package/dist/react/read.mjs +140 -9
  511. package/dist/react/renderers/exact.mjs +31 -59
  512. package/dist/react/renderers/index.d.mts +27 -6
  513. package/dist/react/renderers/index.mjs +141 -102
  514. package/dist/react/renderers/list-parts.mjs +24 -0
  515. package/dist/react/renderers/list.d.mts +1 -0
  516. package/dist/react/renderers/list.mjs +99 -43
  517. package/dist/react/renderers/more-rows.mjs +75 -0
  518. package/dist/react/renderers/number-before.mjs +320 -0
  519. package/dist/react/renderers/number-period.mjs +54 -0
  520. package/dist/react/renderers/number-whole.mjs +29 -0
  521. package/dist/react/renderers/props.d.mts +24 -1
  522. package/dist/react/renderers/props.mjs +8 -0
  523. package/dist/react/renderers/table-cells.mjs +137 -31
  524. package/dist/react/renderers/table-fit.mjs +55 -10
  525. package/dist/react/renderers/table-measure.mjs +29 -9
  526. package/dist/react/renderers/table-row.mjs +14 -9
  527. package/dist/react/renderers/table-scale.mjs +2 -3
  528. package/dist/react/renderers/table-sort.mjs +3 -2
  529. package/dist/react/renderers/table-whole.mjs +37 -0
  530. package/dist/react/renderers/table.mjs +73 -53
  531. package/dist/react/review.d.mts +7 -0
  532. package/dist/react/review.mjs +35 -8
  533. package/dist/react/roving.d.mts +6 -0
  534. package/dist/react/roving.mjs +123 -0
  535. package/dist/react/says-dates.d.mts +7 -0
  536. package/dist/react/says-dates.mjs +51 -0
  537. package/dist/react/series.mjs +5 -6
  538. package/dist/react/stable.mjs +1 -1
  539. package/dist/react/tabs/EditTabs.mjs +125 -0
  540. package/dist/react/tabs/NameField.mjs +72 -0
  541. package/dist/react/tabs/TabMenu.mjs +175 -0
  542. package/dist/react/tabs/actions.mjs +37 -0
  543. package/dist/react/tabs/commands.mjs +76 -0
  544. package/dist/react/tabs/focus.mjs +22 -0
  545. package/dist/react/tabs/keys.mjs +28 -0
  546. package/dist/react/theme-unlayered.css +1 -1
  547. package/dist/react/theme.css +1 -1
  548. package/dist/react/tile-store.d.mts +4 -0
  549. package/dist/react/tile-store.mjs +93 -13
  550. package/dist/react/touch.d.mts +16 -0
  551. package/dist/react/touch.mjs +39 -0
  552. package/dist/react/useBoard.d.mts +6 -0
  553. package/dist/react/useBoard.mjs +1 -0
  554. package/dist/react/useDashboard.d.mts +2 -0
  555. package/dist/react/useDashboard.mjs +5 -2
  556. package/dist/react/useTiles.d.mts +3 -0
  557. package/dist/react/useTiles.mjs +73 -17
  558. package/dist/react/view-grid.mjs +2 -2
  559. package/dist/react/view.mjs +1 -1
  560. package/dist/recharts/axes.mjs +1 -1
  561. package/dist/recharts/axis.mjs +23 -73
  562. package/dist/recharts/bar.d.mts +2 -1
  563. package/dist/recharts/bar.mjs +140 -64
  564. package/dist/recharts/fit.mjs +33 -0
  565. package/dist/recharts/line.mjs +21 -15
  566. package/dist/recharts/marks.mjs +2 -1
  567. package/dist/recharts/parts.mjs +16 -13
  568. package/dist/recharts/table.mjs +8 -3
  569. package/dist/refusal.mjs +46 -0
  570. package/dist/registry/filter-bar.json +1 -1
  571. package/dist/skills/derive-dashboards/SKILL.md +23 -8
  572. package/dist/tile-doc.mjs +1 -1
  573. package/package.json +21 -6
  574. package/dist/charts-react/plan.d.mts +0 -3
  575. package/dist/charts-react/plan.mjs +0 -37
  576. package/dist/charts-react/tiles.d.mts +0 -24
  577. package/dist/core/policy/match.d.mts +0 -16
  578. package/dist/core/schema/aliases.d.mts +0 -7
  579. package/dist/core/time/compare.d.mts +0 -30
  580. package/dist/react/EditBar.d.mts +0 -16
  581. package/dist/react/History.d.mts +0 -30
  582. package/dist/react/ReviewPanel.d.mts +0 -15
  583. package/dist/react/digits.mjs +0 -46
  584. package/dist/react/drill/trend-touch.mjs +0 -33
  585. package/dist/react/renderers/exact.d.mts +0 -6
@@ -1,4 +1,5 @@
1
1
  import { TileSource } from "./tile-keys.mjs";
2
+ import { Stale } from "./tile-store.mjs";
2
3
  import { Doc, Picks, Tab, TileResult } from "derive-dashboards/core";
3
4
  /**
4
5
  * The answers for one tab's tiles under the current picks, filled in as each tile finishes and
@@ -17,4 +18,6 @@ export declare function useTiles(a: {
17
18
  }): {
18
19
  results: Map<string, TileResult>;
19
20
  pending: Set<string>;
21
+ notUpdated: ReadonlyMap<string, Stale>;
22
+ signedOut: boolean;
20
23
  };
@@ -1,8 +1,8 @@
1
1
  import { useDashboards } from "./context.mjs";
2
2
  import { tileKeys } from "./tile-keys.mjs";
3
- import { createTileStore, launch } from "./tile-store.mjs";
4
- import { useEffect, useMemo, useReducer, useRef, useState } from "react";
3
+ import { RETRY, createTileStore, launch } from "./tile-store.mjs";
5
4
  import { canonical } from "derive-dashboards/core";
5
+ import { createContext, useEffect, useMemo, useReducer, useRef, useState } from "react";
6
6
  // src/useTiles.ts
7
7
  const NO_KEYS = /* @__PURE__ */ new Map();
8
8
  /**
@@ -39,24 +39,69 @@ function refreshNow(a) {
39
39
  })
40
40
  });
41
41
  }
42
- /** Each widget's answer to show, and which are still on their way. */
42
+ /**
43
+ * The widgets whose answer shown is not the one for the filters picked now, and why: the viewer
44
+ * is signed out, or the request failed and is asked again. A tile reads it here, so the
45
+ * dashboard's grid passes nothing new down to it.
46
+ */
47
+ const NotUpdatedContext = createContext(/* @__PURE__ */ new Map());
48
+ /** No tile is stale: one map for every render. */
49
+ const NOTHING_STALE = /* @__PURE__ */ new Map();
50
+ /**
51
+ * The same map as the render before while it holds the same widgets for the same reasons, so a
52
+ * tile that reads it draws again only when what it says changes, not each time the board draws.
53
+ */
54
+ function useSameStale(stale) {
55
+ const held = useRef({
56
+ text: "",
57
+ stale: NOTHING_STALE
58
+ });
59
+ const text = [...stale].map(([id, why]) => `${id}\u0000${why}`).toSorted().join("");
60
+ if (held.current.text !== text) held.current = {
61
+ text,
62
+ stale: stale.size === 0 ? NOTHING_STALE : stale
63
+ };
64
+ return held.current.stale;
65
+ }
66
+ /**
67
+ * The answers read on the server for the tiles first shown, each under its key: only for the
68
+ * live dashboard, which is what they were read for.
69
+ */
70
+ function servedFor(keys, served, source) {
71
+ if (served === void 0 || source === void 0 || !("version" in source)) return [];
72
+ const byWidget = new Map(served.map((result) => [result.widgetId, result]));
73
+ return [...keys].flatMap(([widgetId, key]) => {
74
+ const result = byWidget.get(widgetId);
75
+ return result === void 0 ? [] : [[
76
+ widgetId,
77
+ key,
78
+ result
79
+ ]];
80
+ });
81
+ }
82
+ /** Each widget's answer to show, which are still on their way, and which are not updated. */
43
83
  function collect(keys, store) {
44
84
  const results = /* @__PURE__ */ new Map();
45
85
  const pending = /* @__PURE__ */ new Set();
86
+ const notUpdated = /* @__PURE__ */ new Map();
46
87
  for (const [widgetId, key] of keys) {
47
88
  const shown = store.shown(widgetId, key);
48
89
  if (shown !== void 0) results.set(widgetId, shown);
49
90
  if (!store.answered(key)) pending.add(widgetId);
91
+ const stale = store.stale(widgetId, key);
92
+ if (stale !== void 0) notUpdated.set(widgetId, stale);
50
93
  }
51
94
  return {
52
95
  results,
53
- pending
96
+ pending,
97
+ notUpdated
54
98
  };
55
99
  }
56
100
  /**
57
- * Tiles whose request never reached the server ask again when the browser is back online, when
58
- * the window is focused, and every 15 seconds while any is still failing: a dropped connection
59
- * heals without a reload.
101
+ * Tiles whose request got no answer ask again when the browser is back online, when the window
102
+ * is focused, on a tile's Try again, and every 15 seconds while any failure may heal by waiting.
103
+ * The timer asks again only for those: a sign-in layer's refusal waits for the viewer to come
104
+ * back, signed in again, however many other tiles the timer asks for.
60
105
  */
61
106
  function useRetry(store, again) {
62
107
  const latest = useRef(again);
@@ -64,15 +109,21 @@ function useRetry(store, again) {
64
109
  useEffect(() => {
65
110
  const retry = () => {
66
111
  if (!store.hasFailed()) return;
67
- store.retry();
112
+ store.forgetFailed();
68
113
  latest.current();
69
114
  };
70
- globalThis.addEventListener("online", retry);
71
- globalThis.addEventListener("focus", retry);
72
- const timer = setInterval(retry, 15e3);
115
+ const tick = () => {
116
+ if (store.forgetHealing()) latest.current();
117
+ };
118
+ const events = [
119
+ "online",
120
+ "focus",
121
+ RETRY
122
+ ];
123
+ for (const name of events) globalThis.addEventListener(name, retry);
124
+ const timer = setInterval(tick, 15e3);
73
125
  return () => {
74
- globalThis.removeEventListener("online", retry);
75
- globalThis.removeEventListener("focus", retry);
126
+ for (const name of events) globalThis.removeEventListener(name, retry);
76
127
  clearInterval(timer);
77
128
  };
78
129
  }, [store]);
@@ -98,7 +149,7 @@ function useStaleCheck(results, signature, onStale) {
98
149
  * nothing. While a tile's new answer loads, it keeps its last one.
99
150
  */
100
151
  function useTiles(a) {
101
- const { client } = useDashboards();
152
+ const { client, served } = useDashboards();
102
153
  const { dashboardId, doc, tab, picks } = a;
103
154
  const sourceText = canonical(a.source ?? null);
104
155
  const keys = useMemo(() => doc === void 0 || tab === void 0 ? NO_KEYS : tileKeys({
@@ -116,6 +167,7 @@ function useTiles(a) {
116
167
  ]);
117
168
  const [, redraw] = useReducer((n) => n + 1, 0);
118
169
  const [store] = useState(() => createTileStore(redraw));
170
+ if (keys.size > 0) store.seed(servedFor(keys, served?.[dashboardId], a.source));
119
171
  const flights = useRef(/* @__PURE__ */ new Set());
120
172
  const latest = useRef({
121
173
  keys,
@@ -158,11 +210,15 @@ function useTiles(a) {
158
210
  };
159
211
  }, [store]);
160
212
  useRetry(store, again);
161
- const { results, pending } = collect(keys, store);
213
+ const { results, pending, notUpdated } = collect(keys, store);
214
+ const sameNotUpdated = useSameStale(notUpdated);
162
215
  useStaleCheck(results, signature, a.onStale);
216
+ /** A sign-in layer turned away some tile's request: the viewer's session may have ended. */
163
217
  return {
164
218
  results,
165
- pending
219
+ pending,
220
+ notUpdated: sameNotUpdated,
221
+ signedOut: store.signedOut()
166
222
  };
167
223
  }
168
- export { useTiles };
224
+ export { NotUpdatedContext, useTiles };
@@ -1,6 +1,6 @@
1
- import { sharedSpan } from "./Tile.mjs";
2
- import { useMemo } from "react";
1
+ import { sharedSpan } from "./dates-shown.mjs";
3
2
  import { viewLayout } from "derive-dashboards/core";
3
+ import { useMemo } from "react";
4
4
  // src/view-grid.ts
5
5
  /**
6
6
  * The grid as a viewer sees it. The layout holds only the tiles there are widgets for, each at
@@ -1,5 +1,5 @@
1
- import { useState } from "react";
2
1
  import { VIEW_PREFIX, encodeView, viewFor } from "derive-dashboards/core";
2
+ import { useState } from "react";
3
3
  // src/view.ts
4
4
  /**
5
5
  * The tab open, the filters set and the drill open: the host's, when it passes `view` and
@@ -8,7 +8,7 @@ import { jsx } from "react/jsx-runtime";
8
8
  */
9
9
  function yAxes(drawn, locale) {
10
10
  return ["left", "right"].filter((side) => drawn.series.some((s) => s.axis === side)).map((side) => {
11
- const axis = yAxis(drawn.series.filter((s) => s.axis === side), drawn.points, locale);
11
+ const axis = yAxis(drawn.series.filter((s) => s.axis === side), drawn.points, locale, { zero: "near" });
12
12
  return /* @__PURE__ */ jsx(YAxis, {
13
13
  yAxisId: side,
14
14
  orientation: side,
@@ -1,75 +1,31 @@
1
1
  import { formatTick } from "derive-dashboards/react";
2
+ import { valueAxis } from "derive-dashboards/charts";
2
3
  // src/axis.ts
4
+ /** About how many ticks a tile's plot has room for: what the chart kit asks for one 220 pixels tall. */
5
+ const TICKS = 5;
3
6
  /**
4
- * A percent axis's ticks: from 0 up past the data in a step a person reads (5%, 10%, 25%...),
5
- * so it reads 0, 10, 20, 30% and never 6.5%. All zero reaches 100%, not 400% of nothing.
7
+ * A value axis by the chart kit's own rule (`valueAxis`), so both kits draw the same one: round
8
+ * steps past the data, counts in whole numbers (no 2.5 tasks), a stacked chart reaching its
9
+ * tallest stack, and data below zero reached both ways.
6
10
  */
7
- function percentTicks(max, full) {
8
- const top = max > 0 ? max : full;
9
- const step = [
10
- .05,
11
- .1,
12
- .2,
13
- .25,
14
- .5,
15
- 1
16
- ].map((s) => s * full).find((s) => top / s <= 5) ?? full;
17
- const count = Math.ceil(top / step - 1e-9);
18
- return Array.from({ length: count + 1 }, (_v, i) => Number((i * step).toFixed(6)));
19
- }
20
- /**
21
- * A value axis's ticks: from 0 up past the data in a step a person reads (1, 2, 2.5 or 5 times
22
- * a power of ten), four or five steps, so it reads 0, 50, 100, 150 and never 35, 70, 105. A
23
- * count steps in whole numbers only.
24
- */
25
- function niceTicks(max, whole) {
26
- if (!(max > 0)) return [0, 1];
27
- const rough = max / 4;
28
- const power = 10 ** Math.floor(Math.log10(rough));
29
- const step = [
30
- 1,
31
- 2,
32
- 2.5,
33
- 5,
34
- 10
35
- ].map((m) => m * power).filter((s) => !whole || Number.isInteger(s)).find((s) => max / s <= 5) ?? Math.max(1, Math.ceil(rough));
36
- const count = Math.ceil(max / step - 1e-9);
37
- return Array.from({ length: count + 1 }, (_v, i) => Number((i * step).toPrecision(12)));
38
- }
39
- /**
40
- * A value axis that reads at a glance: counts tick in whole numbers (no 2.5 tasks), percents on
41
- * round steps of the whole, anything else on round steps from 0; a stacked chart reaches its
42
- * tallest stack. Data below zero keeps the kit's own ticks, which reach both ways.
43
- */
44
- function yAxis(series, points, locale, stacked = false) {
45
- const { whole, percentOf } = shapeOf(series[0]?.column);
11
+ function yAxis(series, points, locale, shape) {
12
+ const column = series[0]?.column;
46
13
  const values = points.flatMap((p) => series.map((s) => p[s.key]).filter((v) => typeof v === "number"));
47
- const top = Math.max(0, ...stacked ? stackedTops(series, points) : [], ...values);
48
- const ticks = values.some((v) => v < 0) ? void 0 : ticksFor(top, percentOf, whole);
14
+ const tops = shape.stacked === true ? stackedTops(series, points) : [];
15
+ const whole = column?.type === "int";
16
+ const axis = valueAxis([...values, ...tops], {
17
+ zero: shape.zero,
18
+ reads: { whole },
19
+ count: TICKS
20
+ });
49
21
  return {
50
22
  allowDecimals: !whole,
51
23
  interval: 0,
52
- tickFormatter: axisFormat(series, locale),
53
- ...ticks === void 0 ? {} : {
54
- ticks,
55
- domain: [0, ticks.at(-1) ?? 1]
56
- }
24
+ tickFormatter: (value) => formatTick(value, column, locale),
25
+ ticks: [...axis.ticks],
26
+ domain: [axis.min, axis.max]
57
27
  };
58
28
  }
59
- /** What an axis reads of its column: whole counts, and a percent's whole (1 or 100). */
60
- function shapeOf(column) {
61
- if (column === void 0) return {
62
- whole: false,
63
- percentOf: void 0
64
- };
65
- const percentOf = column.format === "percent" ? column.fraction === true ? 1 : 100 : void 0;
66
- return {
67
- whole: column.type === "int",
68
- percentOf
69
- };
70
- }
71
- /** A percent axis ticks on steps of its whole; any other on round steps from 0. */
72
- const ticksFor = (top, percentOf, whole) => percentOf === void 0 ? niceTicks(top, whole) : percentTicks(top, percentOf);
73
29
  /** Each point's total over its series: a stacked bar reaches its sum, not its tallest part. */
74
30
  function stackedTops(series, points) {
75
31
  return points.map((p) => series.reduce((sum, s) => {
@@ -77,10 +33,6 @@ function stackedTops(series, points) {
77
33
  return typeof v === "number" && v > 0 ? sum + v : sum;
78
34
  }, 0));
79
35
  }
80
- function axisFormat(series, locale) {
81
- const column = series[0]?.column;
82
- return (value) => formatTick(value, column, locale);
83
- }
84
36
  /** About how wide a character of a tick's text is drawn, in pixels. */
85
37
  const TICK_CHAR = 7;
86
38
  /** The width a value axis is given when its ticks are short. */
@@ -91,18 +43,16 @@ const AXIS_WIDTH = 56;
91
43
  * broke over two and lost its end.
92
44
  */
93
45
  function axisWidth(axis) {
94
- const ticks = "ticks" in axis ? axis.ticks : [];
95
- const longest = Math.max(0, ...ticks.map((tick) => axis.tickFormatter(tick).length));
46
+ const longest = Math.max(0, ...axis.ticks.map((tick) => axis.tickFormatter(tick).length));
96
47
  return Math.max(AXIS_WIDTH, longest * TICK_CHAR + 12);
97
48
  }
98
49
  /**
99
50
  * The room a chart whose bars lie down keeps past the end of its value axis. The last tick's
100
51
  * text is centred on the end of the axis, so half of it stands past the end: with no room
101
- * there it is cut ("6 se" for "6 sec"). `top` is the largest value, for an axis whose ticks
102
- * are the kit's own.
52
+ * there it is cut ("6 se" for "6 sec").
103
53
  */
104
- function endRoom(axis, top) {
105
- const last = "ticks" in axis ? axis.ticks.at(-1) ?? top : top;
54
+ function endRoom(axis) {
55
+ const last = axis.ticks.at(-1) ?? 0;
106
56
  return Math.max(8, Math.ceil(axis.tickFormatter(last).length * TICK_CHAR / 2));
107
57
  }
108
- export { axisWidth, endRoom, niceTicks, percentTicks, yAxis };
58
+ export { axisWidth, endRoom, yAxis };
@@ -3,6 +3,7 @@ import { TileRendererProps } from "derive-dashboards/react";
3
3
  * Bars per x value; when a second field splits them, its values stack where the measure adds
4
4
  * up (Other on top) and stand side by side where it does not. Bars over
5
5
  * time stand up, the bucket still running drawn faint; bars by category lie down, so every
6
- * name has room to be read and none is skipped.
6
+ * name has room to be read and none is skipped. Told to fit, bars by category are as tall as
7
+ * their rows ask; bars over time keep the box they were given.
7
8
  */
8
9
  export declare function BarTile(props: TileRendererProps): import("react").JSX.Element;
@@ -1,9 +1,11 @@
1
1
  import { axisWidth, endRoom, yAxis } from "./axis.mjs";
2
- import { openPoint } from "./marks.mjs";
3
- import { CHART, GRID, TOOLTIP, legendText, runningLabel, seriesColors, tooltipFormat, tooltipLabel } from "./parts.mjs";
2
+ import { FIT_MOST, lyingHeight } from "./fit.mjs";
3
+ import { openPoint, sameMark } from "./marks.mjs";
4
+ import { CHART, GRID, TOOLTIP, legendText, seriesColors, tooltipFormat, tooltipLabel } from "./parts.mjs";
4
5
  import { toSeries } from "./series.mjs";
5
6
  import { Beside } from "./table.mjs";
6
- import { addsUp } from "derive-dashboards/core";
7
+ import { addsUp, isRunning } from "derive-dashboards/core";
8
+ import { fitted, useTapPreview } from "derive-dashboards/react";
7
9
  import { useState } from "react";
8
10
  import { Bar, BarChart, CartesianGrid, Legend, Rectangle, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
9
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -16,18 +18,32 @@ const cut = (label) => {
16
18
  };
17
19
  /** Room for the longest category label, in pixels, between a floor and a ceiling. */
18
20
  const labelWidth = (points) => Math.min(180, Math.max(48, 12 + 7 * Math.max(0, ...points.map((p) => cut(p.x).length))));
19
- /** A click on a bar opens the row behind it, with its series' line. */
20
- const barClick = (drill, drawn, s) => drill === void 0 ? {} : { onClick: (_bar, point) => {
21
- openPoint(drill, drawn, {
21
+ /** A tap or click on a bar opens the row behind it, with its series' line, by the touch model. */
22
+ const barClick = (drill, drawn, s, tap) => drill === void 0 ? {} : { onClick: (_bar, point) => {
23
+ tap({
22
24
  point,
23
- series: s
25
+ key: s.key
26
+ }, () => {
27
+ openPoint(drill, drawn, {
28
+ point,
29
+ series: s
30
+ });
24
31
  });
25
32
  } };
26
- /** A bar's shape: outlined when the keyboard is on it, faint when its bucket is still running. */
27
- const barShape = (focused, key, running) => (props) => /* @__PURE__ */ jsx(Rectangle, {
33
+ /** A bucket still running: faint, and outlined in its own colour, dashed, so it stands at 3:1. */
34
+ const RUNNING = {
35
+ fillOpacity: .45,
36
+ strokeWidth: 1.5,
37
+ strokeDasharray: "4 3"
38
+ };
39
+ /** A bar's shape: ringed when the keyboard or a finger is on it, faint and dashed while its bucket runs. */
40
+ const barShape = (ringed, key, drawn) => (props) => /* @__PURE__ */ jsx(Rectangle, {
28
41
  ...props,
29
- ...props.index === running ? { fillOpacity: .45 } : {},
30
- ...focused?.key === key && focused.point === props.index ? {
42
+ ...isRunning(drawn.buckets?.[props.index]) ? {
43
+ ...RUNNING,
44
+ stroke: props.fill
45
+ } : {},
46
+ ...ringed?.key === key && ringed.point === props.index ? {
31
47
  className: "dd-chart-focus",
32
48
  stroke: "var(--dd-ink)",
33
49
  strokeWidth: 2
@@ -74,17 +90,59 @@ function barAxes(overTime, values, points) {
74
90
  tickFormatter: cut
75
91
  })] });
76
92
  }
77
- /** The largest value drawn, whichever series holds it. */
78
- const top = ({ points, series }) => Math.max(0, ...points.flatMap((point) => series.map((s) => point[s.key]).filter((v) => typeof v === "number")));
79
93
  /** The chart's own settings, with room past the end of the value axis where the bars lie down along it. */
80
- const chartOf = (overTime, axis, drawn) => overTime ? CHART : {
94
+ const chartOf = (overTime, axis) => overTime ? CHART : {
81
95
  ...CHART,
82
96
  margin: {
83
97
  ...CHART.margin,
84
- right: endRoom(axis, top(drawn))
98
+ right: endRoom(axis)
85
99
  }
86
100
  };
87
101
  /**
102
+ * What the tile and its picture are given to be as tall as their rows ask: only bars by
103
+ * category told to fit. The picture, which Recharts measures, is of that height and does not
104
+ * stretch, up to the most a tile grows; the tile is as tall as it and says so (`data-fit`), so
105
+ * its row on the grid follows. Otherwise both fill the box they were given.
106
+ */
107
+ function sizeOf(fits, drawn) {
108
+ if (!fits) return {
109
+ root: {},
110
+ picture: void 0
111
+ };
112
+ const beside = stacksSplit(drawn) ? 1 : drawn.series.length;
113
+ const height = lyingHeight(drawn.points.length, beside);
114
+ return {
115
+ root: {
116
+ ...fitted(true),
117
+ style: { height: "auto" }
118
+ },
119
+ picture: {
120
+ flex: "none",
121
+ height,
122
+ maxHeight: FIT_MOST
123
+ }
124
+ };
125
+ }
126
+ /**
127
+ * A split's legend under a picture that is as tall as its rows, outside it: however many lines
128
+ * its names wrap to, they add to the tile's height and take none of the bars'. Inside the
129
+ * picture, ten names on a phone left Recharts no plot at all. It is for the eye, as the
130
+ * picture is: the chart's table names every series.
131
+ */
132
+ function SplitKey({ painted, shown }) {
133
+ if (!shown || painted.length < 2) return null;
134
+ return /* @__PURE__ */ jsx("ul", {
135
+ className: "dd-chart-key",
136
+ "aria-hidden": "true",
137
+ children: painted.map(({ series, color }) => /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("span", {
138
+ className: "dd-chart-key-swatch",
139
+ style: { background: color }
140
+ }), series.label] }, series.key))
141
+ });
142
+ }
143
+ /** Whether a legend is drawn in the picture: for several series, unless it is drawn under it (`SplitKey`). */
144
+ const legendInside = (series, fits) => series > 1 && !fits;
145
+ /**
88
146
  * Whether a split's parts stack into a whole: only where the answer says its measure adds up,
89
147
  * which core's `addsUp` reads. The parts of an average or a rate stand side by side, since a
90
148
  * column of one on another would reach a total that means nothing; so do the parts of an
@@ -98,67 +156,85 @@ function stacksSplit(drawn) {
98
156
  * Bars per x value; when a second field splits them, its values stack where the measure adds
99
157
  * up (Other on top) and stand side by side where it does not. Bars over
100
158
  * time stand up, the bucket still running drawn faint; bars by category lie down, so every
101
- * name has room to be read and none is skipped.
159
+ * name has room to be read and none is skipped. Told to fit, bars by category are as tall as
160
+ * their rows ask; bars over time keep the box they were given.
102
161
  */
103
162
  function BarTile(props) {
104
163
  const { answer, locale, drill } = props;
105
164
  const [focused, setFocused] = useState(null);
165
+ const tap = useTapPreview(sameMark);
106
166
  const drawn = toSeries(answer, props, props.slots);
107
167
  const { points, series } = drawn;
108
168
  const split = stacksSplit(drawn);
109
169
  const painted = seriesColors(props, series);
110
170
  const overTime = answer.columns[0]?.type === "time" || answer.columns[0]?.grain !== void 0;
111
- const running = overTime ? runningLabel(props, points) : void 0;
112
- const values = yAxis(series, points, locale, split);
171
+ const values = yAxis(series, points, locale, {
172
+ zero: "always",
173
+ stacked: split
174
+ });
175
+ const fits = props.fit === true && !overTime;
176
+ const size = sizeOf(fits, drawn);
177
+ const legend = legendInside(series.length, fits);
113
178
  return /* @__PURE__ */ jsxs("div", {
114
179
  className: "dd-chart",
115
180
  "data-drillable": drill !== void 0,
116
- children: [/* @__PURE__ */ jsx("div", {
117
- className: "dd-chart-picture",
118
- "aria-hidden": "true",
119
- children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxs(BarChart, {
120
- ...chartOf(overTime, values, drawn),
121
- data: points,
122
- maxBarSize: overTime ? 56 : 28,
123
- layout: overTime ? "horizontal" : "vertical",
124
- children: [
125
- /* @__PURE__ */ jsx(CartesianGrid, {
126
- stroke: GRID,
127
- vertical: !overTime,
128
- horizontal: overTime
129
- }),
130
- barAxes(overTime, values, points),
131
- /* @__PURE__ */ jsx(Tooltip, {
132
- ...TOOLTIP,
133
- formatter: tooltipFormat(props, drawn),
134
- labelFormatter: tooltipLabel(props, running)
135
- }),
136
- series.length > 1 ? /* @__PURE__ */ jsx(Legend, {
137
- itemSorter: null,
138
- formatter: legendText
139
- }) : null,
140
- painted.map(({ series: s, color }, i) => /* @__PURE__ */ jsx(Bar, {
141
- dataKey: s.key,
142
- name: s.label,
143
- fill: color,
144
- ...split ? {
145
- stackId: "split",
146
- stroke: "var(--dd-surface)",
147
- strokeWidth: 2
148
- } : {},
149
- radius: barRadius(split && i < series.length - 1, overTime),
150
- isAnimationActive: false,
151
- ...barClick(drill, drawn, s),
152
- shape: barShape(focused, s.key, running === void 0 ? -1 : points.length - 1)
153
- }, s.key))
154
- ]
155
- }) })
156
- }), /* @__PURE__ */ jsx(Beside, {
157
- drawn,
158
- props,
159
- kind: "bar",
160
- onFocusMark: setFocused
161
- })]
181
+ ...size.root,
182
+ ...tap.handlers,
183
+ children: [
184
+ /* @__PURE__ */ jsx("div", {
185
+ className: "dd-chart-picture",
186
+ "aria-hidden": "true",
187
+ style: size.picture,
188
+ children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxs(BarChart, {
189
+ ...chartOf(overTime, values),
190
+ data: points,
191
+ maxBarSize: overTime ? 56 : 28,
192
+ barGap: overTime ? 4 : 2,
193
+ layout: overTime ? "horizontal" : "vertical",
194
+ children: [
195
+ /* @__PURE__ */ jsx(CartesianGrid, {
196
+ stroke: GRID,
197
+ vertical: !overTime,
198
+ horizontal: overTime
199
+ }),
200
+ barAxes(overTime, values, points),
201
+ /* @__PURE__ */ jsx(Tooltip, {
202
+ ...TOOLTIP,
203
+ formatter: tooltipFormat(props, drawn),
204
+ labelFormatter: tooltipLabel(props, drawn)
205
+ }),
206
+ legend ? /* @__PURE__ */ jsx(Legend, {
207
+ itemSorter: null,
208
+ formatter: legendText
209
+ }) : null,
210
+ painted.map(({ series: s, color }, i) => /* @__PURE__ */ jsx(Bar, {
211
+ dataKey: s.key,
212
+ name: s.label,
213
+ fill: color,
214
+ ...split ? {
215
+ stackId: "split",
216
+ stroke: "var(--dd-surface)",
217
+ strokeWidth: 2
218
+ } : {},
219
+ radius: barRadius(split && i < series.length - 1, overTime),
220
+ isAnimationActive: false,
221
+ ...barClick(drill, drawn, s, tap.tap),
222
+ shape: barShape(focused ?? tap.shown, s.key, drawn)
223
+ }, s.key))
224
+ ]
225
+ }) })
226
+ }),
227
+ /* @__PURE__ */ jsx(SplitKey, {
228
+ painted,
229
+ shown: fits
230
+ }),
231
+ /* @__PURE__ */ jsx(Beside, {
232
+ drawn,
233
+ props,
234
+ kind: "bar",
235
+ onFocusMark: setFocused
236
+ })
237
+ ]
162
238
  });
163
239
  }
164
240
  export { BarTile, stacksSplit };
@@ -0,0 +1,33 @@
1
+ import { CHART } from "./parts.mjs";
2
+ import { ROW_SIZES } from "derive-dashboards/charts";
3
+ // src/fit.ts
4
+ /** A row of bars lying down at its tallest: the charts kit's own, so the two kits cannot drift apart. */
5
+ const ROW = ROW_SIZES.most;
6
+ /** The value axis under bars lying down: Recharts' own height for an axis along the bottom. */
7
+ const VALUE_AXIS = 30;
8
+ /** The most a chart that fits its rows grows, where no theme says: about sixteen rows. */
9
+ const FIT_MOST = "var(--dd-fit-most, 560px)";
10
+ /**
11
+ * The room one bar takes of a row where several stand side by side: six pixels of bar, two
12
+ * between it and the next (`BAR_GAP`), and its share of the tenth of the row Recharts leaves
13
+ * at each end.
14
+ */
15
+ const BESIDE = 10;
16
+ /**
17
+ * How tall a row is for so many bars side by side: the row every chart of rows has, which
18
+ * holds up to three, or more where the bars need it. Ten in a row of 34 pixels were hairlines.
19
+ */
20
+ const rowFor = (beside) => Math.max(ROW, beside * BESIDE);
21
+ /**
22
+ * How tall the picture of bars by category asks to be when the tile is told to fit: a row for
23
+ * each category, as tall as the bars side by side in it need (`beside`; one where a split
24
+ * stacks), with the room above the plot and the value axis under it. Three rows of one bar are
25
+ * 4 + 3 × 34 + 30 = 136 pixels. A split's legend is no part of it: it is drawn under the
26
+ * picture (`SplitKey`), since its names wrap to as many lines as the width leaves them, and
27
+ * lines counted here as one took the rows' room when they were ten. Past the most a tile
28
+ * grows, the theme's cap holds the picture, and Recharts draws the rows thinner.
29
+ */
30
+ function lyingHeight(rows, beside = 1) {
31
+ return CHART.margin.top + CHART.margin.bottom + rows * rowFor(beside) + VALUE_AXIS;
32
+ }
33
+ export { FIT_MOST, lyingHeight };