derive-dashboards 0.7.1 → 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 (591) 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 +86 -44
  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 -32
  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 +51 -9
  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 +12 -6
  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/marks/x-axis.mjs +3 -2
  109. package/dist/charts/scale/calendar.mjs +41 -26
  110. package/dist/charts/scale/linear.mjs +58 -0
  111. package/dist/charts/scale/value.d.mts +21 -0
  112. package/dist/charts/scale/value.mjs +67 -9
  113. package/dist/charts/scene/lazy.mjs +27 -0
  114. package/dist/charts/scene/markup.mjs +2 -1
  115. package/dist/charts/scene/svg.mjs +20 -8
  116. package/dist/charts/scene/types.d.mts +34 -0
  117. package/dist/charts/text/measure.mjs +33 -3
  118. package/dist/charts/theme.d.mts +25 -25
  119. package/dist/charts/theme.mjs +47 -30
  120. package/dist/charts-react/Chart.d.mts +20 -0
  121. package/dist/charts-react/Chart.mjs +9 -67
  122. package/dist/charts-react/Reader.mjs +50 -96
  123. package/dist/charts-react/box.mjs +106 -0
  124. package/dist/charts-react/bucket-names.mjs +9 -24
  125. package/dist/charts-react/columns-picture.mjs +12 -0
  126. package/dist/charts-react/exact-sum.mjs +4 -7
  127. package/dist/charts-react/from-answer.mjs +9 -4
  128. package/dist/charts-react/index.d.mts +9 -2
  129. package/dist/charts-react/index.mjs +9 -2
  130. package/dist/charts-react/kinds/area.d.mts +4 -0
  131. package/dist/charts-react/kinds/area.mjs +38 -0
  132. package/dist/charts-react/kinds/bar.d.mts +4 -0
  133. package/dist/charts-react/kinds/bar.mjs +15 -0
  134. package/dist/charts-react/kinds/funnel.d.mts +4 -0
  135. package/dist/charts-react/kinds/funnel.mjs +13 -0
  136. package/dist/charts-react/kinds/heatmap.d.mts +4 -0
  137. package/dist/charts-react/kinds/heatmap.mjs +13 -0
  138. package/dist/charts-react/kinds/line.d.mts +4 -0
  139. package/dist/charts-react/kinds/line.mjs +20 -0
  140. package/dist/charts-react/kinds/multiples.d.mts +4 -0
  141. package/dist/charts-react/kinds/multiples.mjs +33 -0
  142. package/dist/charts-react/kinds/number.d.mts +5 -0
  143. package/dist/charts-react/kinds/number.mjs +86 -0
  144. package/dist/charts-react/plan-bars.mjs +15 -8
  145. package/dist/charts-react/plan-funnel.mjs +3 -1
  146. package/dist/charts-react/plan-grid.mjs +14 -5
  147. package/dist/charts-react/plan-of.mjs +17 -0
  148. package/dist/charts-react/plan-parts.mjs +16 -5
  149. package/dist/charts-react/plan-time.mjs +4 -53
  150. package/dist/charts-react/reader-page.d.mts +1 -1
  151. package/dist/charts-react/reader-page.mjs +19 -9
  152. package/dist/charts-react/renderers.d.mts +14 -0
  153. package/dist/charts-react/renderers.mjs +22 -0
  154. package/dist/charts-react/table.d.mts +1 -0
  155. package/dist/charts-react/table.mjs +108 -0
  156. package/dist/charts-react/tiles.mjs +21 -49
  157. package/dist/charts-react/useScene.mjs +45 -17
  158. package/dist/charts-react/words.mjs +19 -0
  159. package/dist/checks.mjs +97 -19
  160. package/dist/cli/add.mjs +4 -3
  161. package/dist/cli/doctor.mjs +2 -2
  162. package/dist/core/conformance/index.d.mts +5 -2
  163. package/dist/core/conformance/index.mjs +5 -2
  164. package/dist/core/conformance/memory/aggregate.mjs +11 -6
  165. package/dist/core/conformance/memory/rows.d.mts +7 -3
  166. package/dist/core/conformance/memory/rows.mjs +19 -13
  167. package/dist/core/conformance/memory/source.mjs +4 -4
  168. package/dist/core/document/control-fields.d.mts +20 -0
  169. package/dist/core/document/control-fields.mjs +117 -0
  170. package/dist/core/document/display-comparisons.d.mts +17 -0
  171. package/dist/core/document/display-comparisons.mjs +15 -4
  172. package/dist/core/document/display-entries.d.mts +14 -0
  173. package/dist/core/document/display-entries.mjs +25 -9
  174. package/dist/core/document/display-validation.d.mts +5 -1
  175. package/dist/core/document/display-validation.mjs +14 -7
  176. package/dist/core/document/display.d.mts +11 -8
  177. package/dist/core/document/display.mjs +26 -3
  178. package/dist/core/document/layout.d.mts +8 -9
  179. package/dist/core/document/layout.mjs +23 -6
  180. package/dist/core/document/stacked.d.mts +0 -7
  181. package/dist/core/document/types.mjs +8 -6
  182. package/dist/core/document/upgrade.d.mts +1 -0
  183. package/dist/core/document/upgrade.mjs +4 -2
  184. package/dist/core/engine/access.mjs +3 -3
  185. package/dist/core/engine/assert.mjs +4 -2
  186. package/dist/core/engine/bucket.mjs +2 -2
  187. package/dist/core/engine/checks.mjs +6 -7
  188. package/dist/core/engine/custom/ask.mjs +22 -2
  189. package/dist/core/engine/custom/cells.mjs +22 -22
  190. package/dist/core/engine/custom/level.mjs +12 -13
  191. package/dist/core/engine/custom/measures.mjs +12 -9
  192. package/dist/core/engine/custom/reader.mjs +3 -1
  193. package/dist/core/engine/custom/records.mjs +8 -7
  194. package/dist/core/engine/custom/unread.mjs +78 -0
  195. package/dist/core/engine/custom/where.mjs +15 -10
  196. package/dist/core/engine/index.d.mts +2 -13
  197. package/dist/core/engine/index.mjs +2 -12
  198. package/dist/core/engine/measure.mjs +1 -0
  199. package/dist/core/engine/members.mjs +7 -3
  200. package/dist/core/engine/nan.mjs +10 -1
  201. package/dist/core/engine/native.mjs +2 -20
  202. package/dist/core/engine/numbers.mjs +26 -14
  203. package/dist/core/engine/postgres.mjs +9 -5
  204. package/dist/core/engine/prepare.mjs +4 -4
  205. package/dist/core/engine/rank-sets.mjs +1 -1
  206. package/dist/core/engine/read.mjs +5 -4
  207. package/dist/core/engine/reader.d.mts +6 -0
  208. package/dist/core/engine/record-layout.mjs +3 -3
  209. package/dist/core/engine/run.mjs +77 -20
  210. package/dist/core/engine/segmented.d.mts +2 -1
  211. package/dist/core/engine/segmented.mjs +19 -12
  212. package/dist/core/engine/series.mjs +1 -1
  213. package/dist/core/engine/shape.mjs +8 -8
  214. package/dist/core/engine/sql-partition.mjs +2 -2
  215. package/dist/core/engine/sql-pass.mjs +3 -2
  216. package/dist/core/engine/sql-reader.mjs +13 -5
  217. package/dist/core/engine/sql-reads.mjs +2 -1
  218. package/dist/core/engine/sql-records.mjs +2 -2
  219. package/dist/core/engine/sql-split.mjs +1 -1
  220. package/dist/core/engine/sql-unread.mjs +70 -0
  221. package/dist/core/engine/time.mjs +2 -1
  222. package/dist/core/engine/types.d.mts +17 -0
  223. package/dist/core/engine/version.d.mts +1 -1
  224. package/dist/core/engine/version.mjs +1 -1
  225. package/dist/core/error/codes.d.mts +24 -1
  226. package/dist/core/error/codes.mjs +23 -3
  227. package/dist/core/error/refusal.d.mts +8 -3
  228. package/dist/core/error/refusal.mjs +6 -1
  229. package/dist/core/exact/decimal.d.mts +1 -14
  230. package/dist/core/exact/decimal.mjs +9 -19
  231. package/dist/core/exact/stored.d.mts +9 -0
  232. package/dist/core/exact/stored.mjs +38 -0
  233. package/dist/core/exact/text.d.mts +16 -1
  234. package/dist/core/exact/text.mjs +50 -1
  235. package/dist/core/format/digits.mjs +55 -0
  236. package/dist/core/format/index.d.mts +16 -0
  237. package/dist/core/format/index.mjs +27 -0
  238. package/dist/core/format/number.d.mts +27 -0
  239. package/dist/core/format/number.mjs +158 -0
  240. package/dist/core/format/write.d.mts +6 -0
  241. package/dist/core/format/write.mjs +57 -0
  242. package/dist/core/index.d.mts +43 -33
  243. package/dist/core/index.mjs +31 -28
  244. package/dist/core/model/defaults.d.mts +18 -1
  245. package/dist/core/model/defaults.mjs +19 -1
  246. package/dist/core/model/define.d.mts +17 -8
  247. package/dist/core/model/define.mjs +2 -0
  248. package/dist/core/model/member.d.mts +5 -3
  249. package/dist/core/model/member.mjs +33 -6
  250. package/dist/core/model/storage.mjs +40 -12
  251. package/dist/core/model/types.d.mts +17 -1
  252. package/dist/core/model/types.mjs +5 -0
  253. package/dist/core/model/validate/expr.d.mts +1 -7
  254. package/dist/core/model/validate/fields.d.mts +2 -0
  255. package/dist/core/model/validate/fields.mjs +14 -7
  256. package/dist/core/model/validate/issues.mjs +5 -1
  257. package/dist/core/model/validate/known-members.mjs +6 -5
  258. package/dist/core/model/validate/shape.mjs +36 -3
  259. package/dist/core/model/validate/source.mjs +2 -2
  260. package/dist/core/oracle/data.d.mts +4 -2
  261. package/dist/core/oracle/evaluate.d.mts +19 -1
  262. package/dist/core/oracle/evaluate.mjs +56 -10
  263. package/dist/core/oracle/expr.mjs +1 -1
  264. package/dist/core/oracle/facts.mjs +12 -5
  265. package/dist/core/oracle/measure.mjs +1 -1
  266. package/dist/core/oracle/request.mjs +39 -4
  267. package/dist/core/oracle/segmented.d.mts +3 -1
  268. package/dist/core/oracle/segmented.mjs +19 -13
  269. package/dist/core/oracle/unread.mjs +32 -0
  270. package/dist/core/oracle/visibility.mjs +4 -3
  271. package/dist/core/policy/bind.d.mts +2 -11
  272. package/dist/core/policy/bind.mjs +1 -1
  273. package/dist/core/policy/match.mjs +1 -1
  274. package/dist/core/query/closure.d.mts +7 -2
  275. package/dist/core/query/closure.mjs +29 -12
  276. package/dist/core/query/compose-tile.d.mts +3 -2
  277. package/dist/core/query/compose-tile.mjs +32 -13
  278. package/dist/core/query/compose.d.mts +0 -5
  279. package/dist/core/query/drill/internal.d.mts +5 -5
  280. package/dist/core/query/drill/internal.mjs +11 -0
  281. package/dist/core/query/drill/links.d.mts +2 -3
  282. package/dist/core/query/drill/links.mjs +18 -4
  283. package/dist/core/query/drill/selection.d.mts +8 -2
  284. package/dist/core/query/drill/selection.mjs +14 -3
  285. package/dist/core/query/drill/synthetic.mjs +1 -1
  286. package/dist/core/query/drill/time.mjs +11 -10
  287. package/dist/core/query/filter.d.mts +1 -6
  288. package/dist/core/query/filter.mjs +1 -4
  289. package/dist/core/query/fold.mjs +23 -0
  290. package/dist/core/query/segments.mjs +42 -3
  291. package/dist/core/query/to-wire.d.mts +7 -0
  292. package/dist/core/query/to-wire.mjs +14 -2
  293. package/dist/core/query/types.d.mts +30 -13
  294. package/dist/core/result/columns.mjs +23 -13
  295. package/dist/core/result/number.mjs +3 -3
  296. package/dist/core/result/status.d.mts +13 -0
  297. package/dist/core/result/status.mjs +18 -0
  298. package/dist/core/result/time-axis.d.mts +14 -13
  299. package/dist/core/result/time-axis.mjs +20 -2
  300. package/dist/core/result/types.d.mts +33 -3
  301. package/dist/core/result/whole.d.mts +23 -0
  302. package/dist/core/result/whole.mjs +27 -0
  303. package/dist/core/schema/agent-query.d.mts +89 -0
  304. package/dist/core/schema/agent-query.mjs +115 -0
  305. package/dist/core/schema/aliases.mjs +1 -52
  306. package/dist/core/schema/answer-parts.mjs +17 -13
  307. package/dist/core/schema/answers.d.mts +787 -319
  308. package/dist/core/schema/commands.d.mts +33 -23
  309. package/dist/core/schema/commands.mjs +26 -18
  310. package/dist/core/schema/custom.mjs +46 -45
  311. package/dist/core/schema/document.d.mts +32 -27
  312. package/dist/core/schema/document.mjs +61 -81
  313. package/dist/core/schema/drill-answers.mjs +4 -1
  314. package/dist/core/schema/drill.d.mts +14 -9
  315. package/dist/core/schema/drill.mjs +23 -22
  316. package/dist/core/schema/index.d.mts +5 -3
  317. package/dist/core/schema/index.mjs +5 -3
  318. package/dist/core/schema/options.d.mts +92 -0
  319. package/dist/core/schema/options.mjs +104 -0
  320. package/dist/core/schema/picks.d.mts +2 -2
  321. package/dist/core/schema/picks.mjs +7 -6
  322. package/dist/core/schema/query.d.mts +9 -83
  323. package/dist/core/schema/query.mjs +49 -73
  324. package/dist/core/schema/strict.d.mts +3 -0
  325. package/dist/core/schema/strict.mjs +91 -0
  326. package/dist/core/schema/union-error.mjs +30 -7
  327. package/dist/core/schema/view.d.mts +4 -3
  328. package/dist/core/schema/view.mjs +16 -11
  329. package/dist/core/store/ddl.d.mts +0 -2
  330. package/dist/core/store/ddl.mjs +1 -5
  331. package/dist/core/time/bucket.d.mts +1 -18
  332. package/dist/core/time/bucket.mjs +12 -8
  333. package/dist/core/time/compare.mjs +3 -2
  334. package/dist/core/time/index.d.mts +7 -8
  335. package/dist/core/time/instant.d.mts +15 -9
  336. package/dist/core/time/instant.mjs +23 -9
  337. package/dist/core/time/range.d.mts +3 -15
  338. package/dist/core/time/range.mjs +17 -7
  339. package/dist/core/time/stored.d.mts +8 -5
  340. package/dist/core/time/stored.mjs +51 -15
  341. package/dist/core/time/temporal.d.mts +1 -5
  342. package/dist/core/time/temporal.mjs +9 -4
  343. package/dist/core/time/text-time.d.mts +31 -2
  344. package/dist/core/time/text-time.mjs +139 -22
  345. package/dist/core/time/zone.d.mts +6 -1
  346. package/dist/core/time/zone.mjs +13 -4
  347. package/dist/core/types/api.d.mts +1 -1
  348. package/dist/core/types/api.mjs +1 -1
  349. package/dist/core/types/dashboard.d.mts +185 -0
  350. package/dist/core/types/dashboard.mjs +26 -0
  351. package/dist/core/types/drill-api.d.mts +14 -2
  352. package/dist/core/types/infer.d.mts +0 -4
  353. package/dist/core/types/options-check.d.mts +42 -0
  354. package/dist/core/types/options-check.mjs +90 -0
  355. package/dist/core/types/options.d.mts +14 -8
  356. package/dist/core/value/casefold.d.mts +1 -3
  357. package/dist/core/value/stored.d.mts +26 -0
  358. package/dist/core/value/stored.mjs +28 -0
  359. package/dist/cursor-seal.mjs +37 -9
  360. package/dist/dashboard-documents.d.mts +14 -6
  361. package/dist/dashboard-documents.mjs +32 -12
  362. package/dist/dashboards.mjs +10 -9
  363. package/dist/drill-access.mjs +6 -6
  364. package/dist/drill-change.mjs +18 -20
  365. package/dist/drill-comparison.mjs +2 -1
  366. package/dist/drill-crumbs.mjs +63 -28
  367. package/dist/drill-distinct.mjs +2 -1
  368. package/dist/drill-explain.mjs +1 -1
  369. package/dist/drill-items.mjs +1 -1
  370. package/dist/drill-open.mjs +39 -23
  371. package/dist/drill-seal.mjs +41 -13
  372. package/dist/drill-share.mjs +1 -1
  373. package/dist/drill-summary.mjs +2 -1
  374. package/dist/drill-targets.mjs +4 -4
  375. package/dist/drill-views.mjs +4 -3
  376. package/dist/drill.mjs +1 -1
  377. package/dist/editing.mjs +5 -3
  378. package/dist/endpoints/index.d.mts +29 -8
  379. package/dist/endpoints/index.mjs +4 -1
  380. package/dist/endpoints/meta.mjs +4 -3
  381. package/dist/endpoints/query.mjs +5 -2
  382. package/dist/endpoints/read.mjs +7 -6
  383. package/dist/endpoints/versions.mjs +2 -1
  384. package/dist/execute.d.mts +3 -0
  385. package/dist/execute.mjs +23 -12
  386. package/dist/grant.d.mts +9 -0
  387. package/dist/grant.mjs +43 -0
  388. package/dist/handler.mjs +8 -13
  389. package/dist/http.d.mts +6 -2
  390. package/dist/http.mjs +6 -2
  391. package/dist/index.d.mts +25 -4
  392. package/dist/index.mjs +91 -40
  393. package/dist/llms.txt +3 -3
  394. package/dist/mcp/api.mjs +2 -1
  395. package/dist/mcp/query.mjs +3 -8
  396. package/dist/mcp/resolve.mjs +9 -2
  397. package/dist/node/index.d.mts +36 -0
  398. package/dist/node/index.mjs +89 -0
  399. package/dist/node/request.d.mts +12 -0
  400. package/dist/node/request.mjs +119 -0
  401. package/dist/node/response.mjs +58 -0
  402. package/dist/principal.mjs +15 -7
  403. package/dist/react/Canvas.mjs +90 -69
  404. package/dist/react/Cell.mjs +2 -1
  405. package/dist/react/Dashboard.d.mts +15 -1
  406. package/dist/react/Dashboard.mjs +43 -42
  407. package/dist/react/DashboardList.mjs +9 -4
  408. package/dist/react/Editing.d.mts +9 -0
  409. package/dist/react/Editing.mjs +8 -3
  410. package/dist/react/Grid.mjs +1 -1
  411. package/dist/react/Header.mjs +25 -52
  412. package/dist/react/History.mjs +3 -2
  413. package/dist/react/LoadFailed.mjs +59 -0
  414. package/dist/react/Panel.d.mts +1 -1
  415. package/dist/react/Panel.mjs +1 -1
  416. package/dist/react/Parts.d.mts +34 -0
  417. package/dist/react/Parts.mjs +9 -6
  418. package/dist/react/ReviewPanel.mjs +1 -1
  419. package/dist/react/RowBody.d.mts +2 -0
  420. package/dist/react/RowBody.mjs +5 -1
  421. package/dist/react/Share.mjs +153 -0
  422. package/dist/react/TabStrip.mjs +37 -0
  423. package/dist/react/Tile.d.mts +3 -1
  424. package/dist/react/Tile.mjs +89 -92
  425. package/dist/react/TileState.mjs +117 -0
  426. package/dist/react/ago.mjs +45 -0
  427. package/dist/react/arrange.mjs +1 -1
  428. package/dist/react/board.mjs +2 -2
  429. package/dist/react/bucket-name.d.mts +8 -0
  430. package/dist/react/bucket-name.mjs +13 -0
  431. package/dist/react/builder/DisplayOptions.mjs +219 -0
  432. package/dist/react/builder/Preview.mjs +13 -13
  433. package/dist/react/builder/RangeEditor.mjs +4 -3
  434. package/dist/react/builder/WidgetBuilder.d.mts +1 -7
  435. package/dist/react/builder/WidgetBuilder.mjs +12 -3
  436. package/dist/react/builder/base.d.mts +13 -2
  437. package/dist/react/builder/base.mjs +70 -12
  438. package/dist/react/builder/display.d.mts +3 -0
  439. package/dist/react/builder/display.mjs +256 -0
  440. package/dist/react/builder/labels.mjs +19 -5
  441. package/dist/react/builder/options.mjs +11 -6
  442. package/dist/react/builder/state.mjs +25 -3
  443. package/dist/react/builder/useBuilder.d.mts +7 -1
  444. package/dist/react/builder/useBuilder.mjs +6 -9
  445. package/dist/react/builder/usePreview.mjs +3 -2
  446. package/dist/react/builder/words.d.mts +16 -1
  447. package/dist/react/builder/words.mjs +41 -1
  448. package/dist/react/change-text.mjs +149 -0
  449. package/dist/react/client.d.mts +9 -0
  450. package/dist/react/client.mjs +105 -14
  451. package/dist/react/columns.mjs +9 -1
  452. package/dist/react/context.d.mts +24 -3
  453. package/dist/react/context.mjs +23 -7
  454. package/dist/react/dates-shown.mjs +76 -0
  455. package/dist/react/draft.mjs +3 -2
  456. package/dist/react/drill/Bars.mjs +12 -16
  457. package/dist/react/drill/Comparison.mjs +1 -1
  458. package/dist/react/drill/DrillPanel.d.mts +1 -1
  459. package/dist/react/drill/DrillPanel.mjs +2 -1
  460. package/dist/react/drill/Header.mjs +65 -12
  461. package/dist/react/drill/Items.d.mts +1 -1
  462. package/dist/react/drill/Notes.mjs +10 -7
  463. package/dist/react/drill/PanelStates.mjs +8 -1
  464. package/dist/react/drill/Trend.mjs +10 -5
  465. package/dist/react/drill/board.d.mts +1 -1
  466. package/dist/react/drill/board.mjs +1 -0
  467. package/dist/react/drill/host.mjs +4 -1
  468. package/dist/react/drill/lazy.mjs +2 -27
  469. package/dist/react/drill/props.d.mts +19 -8
  470. package/dist/react/drill/props.mjs +62 -18
  471. package/dist/react/drill/state.d.mts +15 -5
  472. package/dist/react/drill/state.mjs +12 -3
  473. package/dist/react/drill/words.d.mts +46 -3
  474. package/dist/react/drill/words.mjs +30 -5
  475. package/dist/react/english.mjs +33 -8
  476. package/dist/react/export/ExportButton.mjs +4 -1
  477. package/dist/react/export/csv.d.mts +7 -2
  478. package/dist/react/export/csv.mjs +24 -7
  479. package/dist/react/failure-words.mjs +60 -0
  480. package/dist/react/filters/bar.d.mts +1 -1
  481. package/dist/react/filters/bar.mjs +4 -1
  482. package/dist/react/filters/calendar.mjs +23 -8
  483. package/dist/react/filters/chip.mjs +7 -3
  484. package/dist/react/filters/context.d.mts +13 -1
  485. package/dist/react/filters/context.mjs +1 -1
  486. package/dist/react/filters/dates-said.mjs +57 -0
  487. package/dist/react/filters/days.d.mts +3 -4
  488. package/dist/react/filters/days.mjs +10 -17
  489. package/dist/react/filters/hooks.d.mts +11 -0
  490. package/dist/react/filters/hooks.mjs +10 -6
  491. package/dist/react/filters/menu-search.mjs +17 -9
  492. package/dist/react/filters/menu.mjs +10 -8
  493. package/dist/react/filters/phone.mjs +41 -16
  494. package/dist/react/filters/place.mjs +40 -0
  495. package/dist/react/filters/popover.mjs +18 -13
  496. package/dist/react/filters/rules.d.mts +4 -3
  497. package/dist/react/filters/rules.mjs +3 -3
  498. package/dist/react/filters/sheet.mjs +7 -3
  499. package/dist/react/filters/state.mjs +6 -1
  500. package/dist/react/filters/values.mjs +24 -7
  501. package/dist/react/filters/words.d.mts +13 -0
  502. package/dist/react/filters/words.mjs +5 -0
  503. package/dist/react/format-time.d.mts +17 -6
  504. package/dist/react/format-time.mjs +152 -33
  505. package/dist/react/format.d.mts +3 -3
  506. package/dist/react/format.mjs +35 -122
  507. package/dist/react/headline.d.mts +12 -0
  508. package/dist/react/headline.mjs +107 -0
  509. package/dist/react/index.d.mts +20 -17
  510. package/dist/react/index.mjs +13 -10
  511. package/dist/react/lazy.mjs +38 -0
  512. package/dist/react/messages.d.mts +78 -2
  513. package/dist/react/now.mjs +38 -0
  514. package/dist/react/place.mjs +4 -2
  515. package/dist/react/read.d.mts +1 -0
  516. package/dist/react/read.mjs +140 -9
  517. package/dist/react/renderers/exact.mjs +31 -59
  518. package/dist/react/renderers/index.d.mts +27 -6
  519. package/dist/react/renderers/index.mjs +154 -92
  520. package/dist/react/renderers/list-parts.mjs +24 -0
  521. package/dist/react/renderers/list.d.mts +1 -0
  522. package/dist/react/renderers/list.mjs +99 -43
  523. package/dist/react/renderers/more-rows.mjs +75 -0
  524. package/dist/react/renderers/number-before.mjs +320 -0
  525. package/dist/react/renderers/number-period.mjs +54 -0
  526. package/dist/react/renderers/number-whole.mjs +29 -0
  527. package/dist/react/renderers/props.d.mts +24 -1
  528. package/dist/react/renderers/props.mjs +8 -0
  529. package/dist/react/renderers/table-cells.mjs +137 -31
  530. package/dist/react/renderers/table-fit.mjs +55 -10
  531. package/dist/react/renderers/table-measure.mjs +29 -9
  532. package/dist/react/renderers/table-row.mjs +14 -9
  533. package/dist/react/renderers/table-scale.mjs +2 -3
  534. package/dist/react/renderers/table-sort.mjs +3 -2
  535. package/dist/react/renderers/table-whole.mjs +37 -0
  536. package/dist/react/renderers/table.mjs +73 -53
  537. package/dist/react/review.d.mts +7 -0
  538. package/dist/react/review.mjs +35 -8
  539. package/dist/react/roving.d.mts +6 -0
  540. package/dist/react/roving.mjs +123 -0
  541. package/dist/react/says-dates.d.mts +7 -0
  542. package/dist/react/says-dates.mjs +51 -0
  543. package/dist/react/series.mjs +5 -6
  544. package/dist/react/stable.mjs +1 -1
  545. package/dist/react/tabs/EditTabs.mjs +125 -0
  546. package/dist/react/tabs/NameField.mjs +72 -0
  547. package/dist/react/tabs/TabMenu.mjs +175 -0
  548. package/dist/react/tabs/actions.mjs +37 -0
  549. package/dist/react/tabs/commands.mjs +76 -0
  550. package/dist/react/tabs/focus.mjs +22 -0
  551. package/dist/react/tabs/keys.mjs +28 -0
  552. package/dist/react/theme-unlayered.css +1 -1
  553. package/dist/react/theme.css +1 -1
  554. package/dist/react/tile-store.d.mts +4 -0
  555. package/dist/react/tile-store.mjs +93 -13
  556. package/dist/react/touch.d.mts +16 -0
  557. package/dist/react/touch.mjs +39 -0
  558. package/dist/react/useBoard.d.mts +6 -0
  559. package/dist/react/useBoard.mjs +1 -0
  560. package/dist/react/useDashboard.d.mts +2 -0
  561. package/dist/react/useDashboard.mjs +5 -2
  562. package/dist/react/useTiles.d.mts +3 -0
  563. package/dist/react/useTiles.mjs +73 -17
  564. package/dist/react/view-grid.mjs +2 -2
  565. package/dist/react/view.mjs +1 -1
  566. package/dist/recharts/axes.mjs +1 -1
  567. package/dist/recharts/axis.mjs +23 -73
  568. package/dist/recharts/bar.d.mts +2 -1
  569. package/dist/recharts/bar.mjs +140 -64
  570. package/dist/recharts/fit.mjs +33 -0
  571. package/dist/recharts/line.mjs +23 -17
  572. package/dist/recharts/marks.mjs +2 -1
  573. package/dist/recharts/parts.mjs +19 -14
  574. package/dist/recharts/table.mjs +8 -3
  575. package/dist/refusal.mjs +46 -0
  576. package/dist/registry/filter-bar.json +1 -1
  577. package/dist/skills/derive-dashboards/SKILL.md +25 -9
  578. package/dist/tile-doc.mjs +1 -1
  579. package/package.json +21 -6
  580. package/dist/charts-react/plan.d.mts +0 -3
  581. package/dist/charts-react/plan.mjs +0 -37
  582. package/dist/charts-react/tiles.d.mts +0 -24
  583. package/dist/core/policy/match.d.mts +0 -16
  584. package/dist/core/schema/aliases.d.mts +0 -7
  585. package/dist/core/time/compare.d.mts +0 -30
  586. package/dist/react/EditBar.d.mts +0 -16
  587. package/dist/react/History.d.mts +0 -30
  588. package/dist/react/ReviewPanel.d.mts +0 -15
  589. package/dist/react/digits.mjs +0 -46
  590. package/dist/react/drill/trend-touch.mjs +0 -33
  591. package/dist/react/renderers/exact.d.mts +0 -6
@@ -1,32 +1,274 @@
1
1
  import { ChartInputError } from "./input-error.mjs";
2
2
  import { otherLast } from "./rows.mjs";
3
+ import { cellDigits, didYouMean } from "derive-dashboards/core";
3
4
  // src/data/clean.ts
4
- /** The value when it can be drawn, else none. */
5
- function drawable(value) {
6
- if (value === null || value === void 0) return null;
7
- if (typeof value !== "number") throw new ChartInputError("value", "Expected a number or null. Convert database strings before drawing.");
8
- return Number.isFinite(value) ? value : null;
5
+ /**
6
+ * A path from where a value was given: the field as the caller wrote it, with a `#` for each
7
+ * index, each replaced by the next index (`rows[#].value` and 3 is `rows[3].value`).
8
+ */
9
+ const pathOf = (field, indices) => {
10
+ let next = 0;
11
+ return field.replaceAll("#", () => String(indices[next++] ?? "#"));
12
+ };
13
+ const at = (field, key) => typeof key === "number" ? `${field}[${String(key)}]` : field === "" ? key : `${field}.${key}`;
14
+ const is = (test, what) => (value, field) => {
15
+ if (!test(value)) throw new ChartInputError(field, `Expected ${what}.`);
16
+ };
17
+ const ANY = () => {};
18
+ const FUNCTION = is((v) => typeof v === "function", "a function");
19
+ const TEXT = is((v) => typeof v === "string", "text");
20
+ const NUMBER = is((v) => typeof v === "number", "a number");
21
+ const FLAG = is((v) => typeof v === "boolean", "true or false");
22
+ /** A picture is drawn a pixel column at a time: one past this is no screen's, and no page's. */
23
+ const LARGEST = 1e5;
24
+ const SIZE = is((v) => typeof v === "number" && v > 0 && v <= LARGEST, `a size in pixels above zero and at most ${String(LARGEST)}`);
25
+ const oneOf = (...values) => is((v) => typeof v === "string" && values.includes(v), values.join(", "));
26
+ const listOf = (item) => (value, field) => {
27
+ if (!Array.isArray(value)) throw new ChartInputError(field, "Expected a list.");
28
+ if (item !== ANY) for (const [i, one] of value.entries()) item(one, at(field, i));
29
+ };
30
+ const shape = (needs, may = {}) => (value, field) => {
31
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new ChartInputError(field, "Expected an object.");
32
+ for (const [key, check] of Object.entries(needs)) check(Reflect.get(value, key), at(field, key));
33
+ for (const [key, check] of Object.entries(may)) {
34
+ const one = Reflect.get(value, key);
35
+ if (one !== void 0) check(one, at(field, key));
36
+ }
37
+ };
38
+ /** A check at the root of an input, an object there named by what it is (a list names itself). */
39
+ const rooted = (check, name) => (value, field) => {
40
+ if (field === "" && (typeof value !== "object" || value === null || Array.isArray(value))) throw new ChartInputError(name, "Expected an object.");
41
+ check(value, field);
42
+ };
43
+ const TINT = {
44
+ slot: NUMBER,
45
+ color: TEXT,
46
+ other: FLAG
47
+ };
48
+ const NAMED = shape({ label: TEXT }, {
49
+ key: TEXT,
50
+ ...TINT
51
+ });
52
+ const MEASURE = shape({
53
+ label: TEXT,
54
+ tick: FUNCTION,
55
+ text: FUNCTION
56
+ }, {
57
+ whole: FLAG,
58
+ additive: FLAG,
59
+ share: FLAG,
60
+ better: oneOf("up", "down"),
61
+ unit: TEXT
62
+ });
63
+ const LEVELS = listOf(shape({
64
+ value: NUMBER,
65
+ label: TEXT
66
+ }));
67
+ const TABLE = shape({
68
+ x: shape({
69
+ grain: oneOf("hour", "day", "week", "month", "quarter", "year"),
70
+ buckets: listOf(shape({
71
+ label: TEXT,
72
+ from: NUMBER,
73
+ to: NUMBER
74
+ }))
75
+ }),
76
+ series: listOf(shape({
77
+ key: TEXT,
78
+ label: TEXT,
79
+ values: listOf(ANY),
80
+ measure: MEASURE
81
+ }, {
82
+ previous: listOf(ANY),
83
+ ...TINT
84
+ }))
85
+ });
86
+ /** What every public entry takes, by what it is given: rows, steps, points, values, a table or a grid. */
87
+ const SHAPES = {
88
+ rows: listOf(NAMED),
89
+ steps: listOf(NAMED),
90
+ points: listOf(NAMED),
91
+ values: listOf(ANY),
92
+ table: rooted(TABLE, "table"),
93
+ course: (value, field) => {
94
+ if (value !== void 0) rooted(TABLE, "course")(value, field);
95
+ },
96
+ grid: rooted(shape({
97
+ rows: listOf(NAMED),
98
+ columns: listOf(NAMED),
99
+ values: listOf(listOf(ANY))
100
+ }), "grid")
101
+ };
102
+ /** The options every kind may take, checked when given. */
103
+ const OPTIONS = {
104
+ title: TEXT,
105
+ subtitle: TEXT,
106
+ source: TEXT,
107
+ fromLabel: TEXT,
108
+ toLabel: TEXT,
109
+ againstLabel: TEXT,
110
+ rowTitle: TEXT,
111
+ columnTitle: TEXT,
112
+ sizeTitle: TEXT,
113
+ measure: MEASURE,
114
+ x: MEASURE,
115
+ y: MEASURE,
116
+ size: MEASURE,
117
+ focus: listOf(TEXT),
118
+ sort: oneOf("value", "given", "change"),
119
+ arrange: oneOf("stacked", "grouped", "share"),
120
+ curve: oneOf("straight", "smooth", "step"),
121
+ naming: oneOf("end", "legend", "none"),
122
+ references: (v, f) => {
123
+ (Array.isArray(v) ? LEVELS : shape({}, {
124
+ x: LEVELS,
125
+ y: LEVELS
126
+ }))(v, f);
127
+ },
128
+ events: listOf(shape({
129
+ at: NUMBER,
130
+ label: TEXT
131
+ }))
132
+ };
133
+ /** Every key of an options type, each once: a key the type gains that this lacks does not compile. */
134
+ const keysOf = (all) => Object.keys(all);
135
+ /** The keys of what a chart says of itself (`Header`) and of the marks on a time axis (`TimeNotes`). */
136
+ const HEADER = {
137
+ title: true,
138
+ subtitle: true,
139
+ source: true
140
+ };
141
+ const NOTES = {
142
+ references: true,
143
+ events: true
144
+ };
145
+ /**
146
+ * Refuses a key an options object has that its entry does not take, by name, with the key it
147
+ * most likely meant (core's `didYouMean`, as the server says it): from JavaScript a misspelt
148
+ * `fokus` would otherwise be read as no option at all.
149
+ */
150
+ function knownKeys(given, known) {
151
+ if (typeof given !== "object" || given === null) return;
152
+ const unknown = Object.keys(given).find((key) => !known.includes(key));
153
+ if (unknown !== void 0) throw new ChartInputError(`options.${unknown}`, `Unknown key "${unknown}".${didYouMean(unknown, known)} The keys here are ${known.join(", ")}.`);
154
+ }
155
+ /**
156
+ * The input of a public entry checked: what it is given (by the name it is given under, which is
157
+ * the root of its paths: `rows[2].label`, or for a table `x.grain`), the options (measures named
158
+ * by their own field: `measure.tick`; only the keys the entry takes, `known`, and those it
159
+ * `needs`), and where it is drawn (`width`).
160
+ */
161
+ function checkInput(given, options, env, keys) {
162
+ const root = [
163
+ "table",
164
+ "course",
165
+ "grid"
166
+ ].includes(given.what) ? "" : given.what;
167
+ SHAPES[given.what](given.data, root);
168
+ const needed = (keys.needs ?? []).map((field) => [field, OPTIONS[field] ?? MEASURE]);
169
+ rooted(shape(Object.fromEntries(needed), OPTIONS), "options")(options, "");
170
+ knownKeys(options, keys.known);
171
+ rooted(shape({
172
+ width: SIZE,
173
+ height: SIZE,
174
+ measure: FUNCTION
175
+ }), "env")(env, "");
176
+ }
177
+ /** A picture's size checked before it is written: SVG of no size, or of NaN, is not a picture. */
178
+ function checkSize(scene) {
179
+ rooted(shape({
180
+ width: SIZE,
181
+ height: SIZE
182
+ }), "scene")(scene, "");
183
+ }
184
+ /** A number worked out from drawn values when it can be drawn, else none: a quotient may be infinite. */
185
+ const finiteOrNone = (value) => Number.isFinite(value) ? value : null;
186
+ /**
187
+ * Decimal text as a driver sends a numeric ("412", "31900.50"): its plain digits, by core's one
188
+ * reader of them, as the dashboards read a driver's text; none for a number or other text.
189
+ */
190
+ const digitsOf = (value) => typeof value === "string" ? cellDigits(value) : void 0;
191
+ /** Why a value that is not a finite number is refused, by what it is. */
192
+ const refusal = (value) => typeof value === "number" ? "Expected a finite number or null." : typeof value === "bigint" ? "Expected a number or null. Convert a bigint with Number() before drawing." : "Expected a number, decimal text such as 12.50, or null.";
193
+ /**
194
+ * A value as given: none for null, undefined or NaN (a failed parse upstream); decimal text (a
195
+ * driver's numeric) as its number. Anything else that is not a finite number (other text, an
196
+ * infinity) is refused with a `ChartInputError` whose `field` is the value's own path, so the
197
+ * caller can find it (`series[1].values[0]`): `field` names where it was given, a `#` for each
198
+ * index, and the path is written only when a value is refused, never for the millions that are
199
+ * fine.
200
+ */
201
+ function drawable(value, field, i = -1, j = -1) {
202
+ if (value === null || value === void 0 || Number.isNaN(value)) return null;
203
+ const digits = digitsOf(value);
204
+ const number = digits === void 0 ? value : Number(digits);
205
+ if (typeof number !== "number" || !Number.isFinite(number)) throw new ChartInputError(pathOf(field, [i, j]), refusal(value));
206
+ return number;
207
+ }
208
+ /**
209
+ * A value's own text when it was given as decimal text: every digit, by its measure's `exact`
210
+ * (core's writer, as a dashboard tile writes an exact cell); none for a number, which its
211
+ * measure writes.
212
+ */
213
+ function writtenOf(value, reads) {
214
+ const digits = digitsOf(value);
215
+ return digits === void 0 ? void 0 : reads.exact?.(digits);
9
216
  }
10
- /** A series can omit trailing values. An extra value cannot be placed on the time axis. */
217
+ /**
218
+ * Values as given, each drawn by `read` (which knows its path); when some were given as decimal
219
+ * text, their texts too, each written with every digit, a host's own text for a place first.
220
+ */
221
+ function readValues(given, read, how) {
222
+ const values = given.map((value, i) => read(value, i));
223
+ if (!given.some((value) => typeof value === "string")) return { values };
224
+ return {
225
+ values,
226
+ texts: given.map((value, i) => how.texts?.[i] ?? writtenOf(value, how.measure))
227
+ };
228
+ }
229
+ /** A series has one value per bucket, `null` where there is none, so every value has its place. */
11
230
  function cleanSeries(series, index, buckets) {
12
231
  const { previous, ...rest } = series;
13
232
  for (const field of ["values", "previous"]) {
14
- const length = series[field]?.length ?? 0;
15
- if (length > buckets) throw new ChartInputError(`series[${String(index)}].${field}`, `Series "${series.key}" has ${String(length)} values for ${String(buckets)} time buckets.`);
233
+ const length = series[field]?.length ?? buckets;
234
+ if (length !== buckets) throw new ChartInputError(`series[${String(index)}].${field}`, `Series "${series.key}" has ${String(length)} values for ${String(buckets)} time buckets.`);
16
235
  }
17
236
  return {
18
237
  ...rest,
19
- values: series.values.map((value) => drawable(value)),
20
- ...previous === void 0 ? {} : { previous: previous.map((value) => drawable(value)) }
238
+ ...readValues(series.values, (value, i) => drawable(value, "series[#].values[#]", index, i), {
239
+ measure: series.measure,
240
+ texts: series.texts
241
+ }),
242
+ ...previous === void 0 ? {} : { previous: previous.map((value, i) => drawable(value, "series[#].previous[#]", index, i)) }
21
243
  };
22
244
  }
23
- /** Each bucket must cover a finite interval and follow the previous one. Calendar gaps are valid. */
245
+ /** Each table cleaned once: a chart drawn again for a new size (a resize) reads it again as it was. */
246
+ const CLEANED = /* @__PURE__ */ new WeakMap();
247
+ /**
248
+ * Each bucket must cover a finite interval and follow the previous one. Calendar gaps are valid.
249
+ * A table is read as it was given, once: new data is a new table.
250
+ */
24
251
  function cleanTable(table) {
252
+ const known = CLEANED.get(table);
253
+ if (known !== void 0) return known;
254
+ const cleaned = cleanedOf(table);
255
+ CLEANED.set(table, cleaned);
256
+ CLEANED.set(cleaned, cleaned);
257
+ return cleaned;
258
+ }
259
+ /** The table cleaned. */
260
+ function cleanedOf(table) {
25
261
  let end = -Infinity;
26
262
  for (const [i, bucket] of table.x.buckets.entries()) {
27
263
  if (!Number.isFinite(bucket.from) || !Number.isFinite(bucket.to) || bucket.from < end || bucket.to <= bucket.from) throw new ChartInputError(`x.buckets[${String(i)}]`, "Expected a non-overlapping time interval in chronological order.");
28
264
  end = bucket.to;
29
265
  }
266
+ const first = /* @__PURE__ */ new Map();
267
+ for (const [i, { key }] of table.series.entries()) {
268
+ const before = first.get(key);
269
+ if (before !== void 0) throw new ChartInputError(`series[${String(i)}].key`, `Expected a key no other series has; series[${String(before)}] has "${key}".`);
270
+ first.set(key, i);
271
+ }
30
272
  return {
31
273
  x: table.x,
32
274
  series: table.series.map((s, index) => cleanSeries(s, index, table.x.buckets.length))
@@ -52,4 +294,4 @@ function panelTable(table) {
52
294
  series: otherLast(cleaned.series)
53
295
  };
54
296
  }
55
- export { cleanTable, drawable, finiteRange, panelTable };
297
+ export { HEADER, NOTES, checkInput, checkSize, cleanTable, drawable, finiteOrNone, finiteRange, keysOf, knownKeys, panelTable, readValues, writtenOf };
@@ -1,6 +1,6 @@
1
1
  import { Measure } from "./types.mjs";
2
2
  export type MeasureStyle = {
3
- /** An ISO 4217 code: the values are money. */
3
+ /** An ISO 4217 code, in any case: the values are money. */
4
4
  currency?: string;
5
5
  /** The values are fractions of one, read as percents. */
6
6
  percent?: boolean;
@@ -9,7 +9,12 @@ export type MeasureStyle = {
9
9
  better?: "up" | "down";
10
10
  locale?: string;
11
11
  };
12
- /** A measure whose values are plain numbers, money or percents, formatted by the locale's rules. */
12
+ /**
13
+ * A measure whose values are plain numbers, money or percents, written by core's one writer of
14
+ * numbers, as the React kit writes a cell and a tick: to its places (two, or its currency's own)
15
+ * while they hold the value within a tenth of itself, else by its first figures, so nothing that
16
+ * is not zero reads as zero; every negative with a true minus; a tick in three figures, short.
17
+ */
13
18
  export declare function measure(label: string, style?: MeasureStyle): Measure;
14
19
  /**
15
20
  * How a host writes a number of points: "4 pts" for 4. It is given a size, never below zero:
@@ -1,86 +1,71 @@
1
+ import { keysOf, knownKeys } from "./clean.mjs";
2
+ import { ChartInputError } from "./input-error.mjs";
3
+ import { MINUS, numberWriters } from "derive-dashboards/core";
1
4
  // src/data/format.ts
2
- /** The minus sign a number is written with: the true one, as wide as a plus, not a hyphen. */
3
- const typeset = (text) => text.replace("-", "−");
4
- /** What every form of a measure's numbers shares: its unit, and how nothing and whole numbers are written. */
5
- function unitOf(style) {
6
- return {
7
- ...style.currency === void 0 ? style.percent === true ? { style: "percent" } : {} : {
8
- style: "currency",
9
- currency: style.currency
10
- },
11
- signDisplay: "negative",
12
- minimumFractionDigits: 0
13
- };
5
+ /** The keys a measure's style takes: any other is refused, with the one it most likely meant. */
6
+ const STYLE = keysOf({
7
+ currency: true,
8
+ percent: true,
9
+ whole: true,
10
+ additive: true,
11
+ better: true,
12
+ locale: true
13
+ });
14
+ /** The ISO 4217 codes Intl writes. */
15
+ const CURRENCIES = new Set(Intl.supportedValuesOf("currency"));
16
+ /** A currency code as Intl writes it, given in any case ("usd"); refused when it names no currency. */
17
+ function currencyOf(code) {
18
+ const upper = code.toUpperCase();
19
+ if (!CURRENCIES.has(upper)) throw new ChartInputError("currency", `Expected an ISO 4217 code such as USD, not "${code}".`);
20
+ return upper;
21
+ }
22
+ /** A locale as given, refused with its field when it is not one, never the platform's RangeError. */
23
+ function localeOf(locale) {
24
+ if (locale === void 0) return void 0;
25
+ try {
26
+ Intl.getCanonicalLocales(locale);
27
+ } catch {
28
+ throw new ChartInputError("locale", `Expected a locale such as en-US, not "${locale}".`);
29
+ }
30
+ return locale;
14
31
  }
15
- /** How a measure's numbers are written in full: money keeps its cents when it has any ($4.99), and drops them when it has none ($1,200). */
16
- function fullOf(style) {
17
- if (style.currency !== void 0) return {
18
- minimumFractionDigits: 2,
19
- maximumFractionDigits: 2,
20
- trailingZeroDisplay: "stripIfInteger"
32
+ /** What a measure's style says of how its numbers are written, as core's writer reads a column. */
33
+ function shapeOf(style) {
34
+ if (style.percent === true) return {
35
+ format: "percent",
36
+ fraction: true
21
37
  };
22
- return { maximumFractionDigits: style.percent === true ? 1 : 2 };
38
+ return style.currency === void 0 ? {} : { unit: currencyOf(style.currency) };
23
39
  }
24
- /** Below this a plain number has no figure left in two decimals: 0.0031 would be written "0". */
25
- const FINE = .1;
26
- /** Below this a number's leading zeros run long, and it is written by its power of ten. */
27
- const MINUTE = 1e-6;
40
+ /** The charts' number writer for each locale, made once: every chart of a page writes by one. */
41
+ const writerIn = numberWriters();
28
42
  /**
29
- * How a plain number too small for two decimals is written: by its first two figures (0.0031,
30
- * never "0"), and by its power of ten when even those sit past a run of zeros (5E−324), so a
31
- * value that is not zero is never written as zero and a fall from 0.0042 to 0.0031 is not
32
- * called no change. Money keeps its cents and a percent its tenths, by their own conventions,
33
- * and whole things have no fractions: for those, and for any number a tenth or more, nothing.
43
+ * A measure whose values are plain numbers, money or percents, written by core's one writer of
44
+ * numbers, as the React kit writes a cell and a tick: to its places (two, or its currency's own)
45
+ * while they hold the value within a tenth of itself, else by its first figures, so nothing that
46
+ * is not zero reads as zero; every negative with a true minus; a tick in three figures, short.
34
47
  */
35
- function fineOf(style, unit) {
36
- const plain = style.currency === void 0 && style.percent !== true && style.whole !== true;
37
- const figures = {
38
- ...unit,
39
- maximumSignificantDigits: 2
40
- };
41
- const small = new Intl.NumberFormat(style.locale, figures);
42
- const minute = new Intl.NumberFormat(style.locale, {
43
- ...figures,
44
- notation: "scientific"
45
- });
46
- return (value) => {
47
- const size = Math.abs(value);
48
- if (!plain || !(size > 0) || size >= FINE) return void 0;
49
- return (size < MINUTE ? minute : small).format(value);
50
- };
51
- }
52
- /** A measure whose values are plain numbers, money or percents, formatted by the locale's rules. */
53
48
  function measure(label, style = {}) {
54
- const unit = unitOf(style);
49
+ knownKeys(style, STYLE);
55
50
  const percent = style.percent === true;
56
- const compact = new Intl.NumberFormat(style.locale, {
57
- ...unit,
58
- ...percent ? {} : { notation: "compact" },
59
- maximumFractionDigits: 1
60
- });
61
- const whole = new Intl.NumberFormat(style.locale, {
62
- ...unit,
63
- maximumFractionDigits: 0
64
- });
65
- const short = (value) => percent && Math.abs(value) >= .1 ? whole.format(value) : compact.format(value);
66
- const full = new Intl.NumberFormat(style.locale, {
67
- ...unit,
68
- ...fullOf(style)
69
- });
70
- const fine = fineOf(style, unit);
51
+ const shape = shapeOf(style);
52
+ const writer = writerIn(localeOf(style.locale));
71
53
  return {
72
54
  label,
73
55
  ...percent ? { share: true } : {},
74
- tick: (value) => typeset(fine(value) ?? short(value)),
75
- text: (value) => typeset(fine(value) ?? full.format(value)),
56
+ tick: (value) => writer.tick(value, shape),
57
+ text: (value) => writer.text(value, shape),
58
+ exact: (digits) => writer.text({ v: digits }, shape),
76
59
  ...style.whole === void 0 ? {} : { whole: style.whole },
77
60
  additive: style.additive ?? !percent,
78
- ...style.better === void 0 ? {} : { better: style.better }
61
+ ...style.better === void 0 ? {} : { better: style.better },
62
+ ...percent ? { unit: "%" } : shape.unit === void 0 ? {} : { unit: shape.unit }
79
63
  };
80
64
  }
81
65
  /**
82
66
  * How a share of a whole is written wherever a chart says one (a step's share of the first, a
83
- * bin's share of all values, a change): the full form of a percent, 66.7%.
67
+ * bin's share of all values, a change): a percent in full, as every percent is written (67%,
68
+ * 4.5%, 0.06%).
84
69
  */
85
70
  function percentText(locale) {
86
71
  return measure("", {
@@ -98,7 +83,7 @@ function textAt(series, index) {
98
83
  return said(series.texts?.[index]) ?? series.measure.text(value);
99
84
  }
100
85
  /** A size with the sign of the way it went: "+4 pts", "−4 pts", and as it is for no change. */
101
- const signed = (sign, size) => sign > 0 ? `+${size}` : sign < 0 ? `−${size}` : size;
86
+ const signed = (sign, size) => sign > 0 ? `+${size}` : sign < 0 ? `${MINUS}${size}` : size;
102
87
  /**
103
88
  * How far something changed between two values, as it may be written, and which way it reads
104
89
  * as having gone: the one rule every kind that writes a change goes by. A change in a share is
@@ -158,9 +143,22 @@ function movedAsWritten(from, to, text) {
158
143
  */
159
144
  function topAsWritten(things, value, text, counts = () => true) {
160
145
  if (things.length < 2) return void 0;
161
- const [first, second] = things.filter((thing) => counts(thing)).toSorted((a, b) => value(b) - value(a));
146
+ const [first, second] = topTwo(things.filter((thing) => counts(thing)).map((t) => [t, value(t)]));
162
147
  if (first === void 0) return void 0;
163
- return second !== void 0 && orderAsWritten(value(first), value(second), text) === 0 ? void 0 : first;
148
+ return second !== void 0 && orderAsWritten(first[1], second[1], text) === 0 ? void 0 : first[0];
149
+ }
150
+ /**
151
+ * The two largest of some valued things in one pass, each value read once: the first of equals
152
+ * first, as a stable sort from the largest down would put them.
153
+ */
154
+ function topTwo(valued) {
155
+ let first;
156
+ let second;
157
+ for (const one of valued) if (first === void 0 || one[1] > first[1]) {
158
+ second = first;
159
+ first = one;
160
+ } else if (second === void 0 || one[1] > second[1]) second = one;
161
+ return [first, second];
164
162
  }
165
163
  /**
166
164
  * Whether a change went its measure's better way: 1 the better way, -1 the worse, 0 for a change
@@ -171,4 +169,4 @@ function betterWay(sign, reads) {
171
169
  if (reads.better === void 0 || sign === 0) return 0;
172
170
  return sign > 0 === (reads.better === "up") ? 1 : -1;
173
171
  }
174
- export { arrowOf, arrowed, betterWay, changeWritten, measure, movedAsWritten, orderAsWritten, percentText, said, signAsWritten, signed, textAt, topAsWritten };
172
+ export { arrowOf, arrowed, betterWay, changeWritten, measure, movedAsWritten, orderAsWritten, percentText, said, signAsWritten, signed, textAt, topAsWritten, writerIn };
@@ -1,5 +1,7 @@
1
1
  /** A standalone chart received an input it cannot represent, with the field the caller can fix. */
2
2
  export declare class ChartInputError extends TypeError {
3
+ /** One code for every chart refusal, as each typed error of the library carries one. */
4
+ readonly code = "CHART_INPUT";
3
5
  readonly field: string;
4
6
  constructor(field: string, message: string);
5
7
  }
@@ -1,6 +1,8 @@
1
1
  // src/data/input-error.ts
2
2
  /** A standalone chart received an input it cannot represent, with the field the caller can fix. */
3
3
  var ChartInputError = class extends TypeError {
4
+ /** One code for every chart refusal, as each typed error of the library carries one. */
5
+ code = "CHART_INPUT";
4
6
  field;
5
7
  constructor(field, message) {
6
8
  super(`${field}: ${message}`);
@@ -8,6 +8,8 @@ export type Named = {
8
8
  export declare const keyOf: (thing: Named) => string;
9
9
  /**
10
10
  * The identity of a thing in two parts: a series and a bucket, a row and a column. Written so
11
- * no two pairs can read alike, whatever is in their parts: a label may hold any character.
11
+ * no two pairs can read alike, whatever is in their parts: a label may hold any character. The
12
+ * first part's length leads ("2:r0c19"), so where it ends is known, and nothing is escaped: a
13
+ * picture writes the key on every cell.
12
14
  */
13
15
  export declare const pairKey: (first: string, second: string) => string;
@@ -5,9 +5,11 @@ const keyOf = (thing) => thing.key ?? thing.label;
5
5
  const lastAt = (values) => values.findLastIndex((v) => v !== null);
6
6
  /**
7
7
  * The identity of a thing in two parts: a series and a bucket, a row and a column. Written so
8
- * no two pairs can read alike, whatever is in their parts: a label may hold any character.
8
+ * no two pairs can read alike, whatever is in their parts: a label may hold any character. The
9
+ * first part's length leads ("2:r0c19"), so where it ends is known, and nothing is escaped: a
10
+ * picture writes the key on every cell.
9
11
  */
10
- const pairKey = (first, second) => JSON.stringify([first, second]);
12
+ const pairKey = (first, second) => `${String(first.length)}:${first}${second}`;
11
13
  /**
12
14
  * Rows in ranked order: those with a value to rank by first, largest first, then those with
13
15
  * none, then those `last` names (Other); ties, and every row when the order is given, keep the
@@ -2,13 +2,33 @@ import { TextMeasurer } from "../text/measure.mjs";
2
2
  import { Words } from "./words.mjs";
3
3
  /** A value to draw; null where there is none, which leaves a gap and is never drawn as zero. */
4
4
  export type Value = number | null;
5
+ /**
6
+ * A value as a host gives it: a number, decimal text as a driver sends a numeric ("31900.50"),
7
+ * drawn as its number and written with every digit, or null. Every row and table a chart takes
8
+ * reads its values as this; what it draws is `Value`.
9
+ */
10
+ export type ValueIn = number | string | null;
5
11
  /** How a measure's values read and what they mean. */
6
12
  export type Measure = {
7
13
  label: string;
8
- /** A short form for an axis: 12K, $1.2M. */
9
- tick: (value: number) => string;
14
+ /**
15
+ * A short form for an axis: 12K, $1.2M. `beside`, for values counted in `units`: a value
16
+ * counted alike whose unit it is written in, so an axis's ticks all read in the unit it steps in.
17
+ */
18
+ tick: (value: number, beside?: number) => string;
19
+ /**
20
+ * For values counted in several units (a duration: a day, an hour, a minute, a second), the
21
+ * size of each, largest first, counted as the values are. An axis steps in whole numbers of
22
+ * one of them and writes every tick in it: 2, 4, 6 days, never 2.31 days.
23
+ */
24
+ units?: readonly number[];
10
25
  /** The full form, for a label or a tooltip. */
11
26
  text: (value: number) => string;
27
+ /**
28
+ * The full form of a value given as decimal text (a driver's numeric), every digit kept.
29
+ * Left out, such a value is written as its number.
30
+ */
31
+ exact?: (digits: string) => string;
12
32
  /** Counts: the axis steps in whole numbers. */
13
33
  whole?: boolean;
14
34
  /** False for a rate or an average: its values are never stacked or summed. */
@@ -20,7 +40,18 @@ export type Measure = {
20
40
  share?: boolean;
21
41
  /** Which way is good, so a change can be read as better or worse. */
22
42
  better?: "up" | "down";
43
+ /**
44
+ * What its values are counted in, when it is not a plain number: a currency's code, or "%".
45
+ * A chart over time reads every series on its first series' axis, so a series in another
46
+ * unit is not drawn there and is named under the chart (`Scene.left`).
47
+ */
48
+ unit?: string;
23
49
  };
50
+ /**
51
+ * How a measure's numbers read, for whatever writes them along an axis: the short form, the
52
+ * full form, and whether they step in whole numbers.
53
+ */
54
+ export type Reads = Pick<Measure, "tick" | "text" | "whole" | "units">;
24
55
  /**
25
56
  * The colour a thing asks for, in every kind that colours things one by one (a series, a
26
57
  * ranked bar, a scatter's point): its place in the palette, which follows the thing so a
@@ -34,11 +65,12 @@ export type Tint = {
34
65
  export type Toned = Tint & {
35
66
  other?: boolean;
36
67
  };
37
- export type Series = Toned & {
68
+ /** A series of a time chart: its values as given (`ValueIn`, decimal text too) or as drawn (`Value`). */
69
+ export type Series<V extends ValueIn = Value> = Toned & {
38
70
  key: string;
39
71
  label: string;
40
72
  /** One value per place on the x axis. */
41
- values: readonly Value[];
73
+ values: readonly V[];
42
74
  /**
43
75
  * Each value as the host writes it, place for place, when it has a more exact way than the
44
76
  * measure's (a decimal a float cannot hold). The picture is still placed by `values`.
@@ -46,7 +78,7 @@ export type Series = Toned & {
46
78
  texts?: readonly (string | undefined)[];
47
79
  measure: Measure;
48
80
  /** The same series over the comparison period, place for place. */
49
- previous?: readonly Value[];
81
+ previous?: readonly V[];
50
82
  };
51
83
  export type Grain = "hour" | "day" | "week" | "month" | "quarter" | "year";
52
84
  /**
@@ -76,9 +108,9 @@ export type TimeX = {
76
108
  * but they are read in one unit. Measures in different units belong in different charts, or in
77
109
  * small multiples with a scale each.
78
110
  */
79
- export type TimeTable = {
111
+ export type TimeTable<V extends ValueIn = Value> = {
80
112
  x: TimeX;
81
- series: readonly Series[];
113
+ series: readonly Series<V>[];
82
114
  };
83
115
  /** Where a chart is drawn: its size, how wide a text is, the reader's locale and words. */
84
116
  export type Env = {
@@ -87,6 +119,17 @@ export type Env = {
87
119
  measure: TextMeasurer;
88
120
  locale?: string;
89
121
  words?: Words;
122
+ /**
123
+ * Only the height the picture asks for is wanted (`Scene.natural`), to size a box that cannot
124
+ * be measured yet. A chart of rows lying down then lays no row out: it answers with its
125
+ * header alone and that height, and says nothing of its rows. It is the height the chart asks
126
+ * for laid out wherever it has room across for its rows; whether a width has that room is
127
+ * known only by laying it out, so a chart too narrow to draw a row is still asked for its
128
+ * rows' height here. A grid's answer turns on the width asked at, since its width sets how
129
+ * many rows its cells allow, and so does small multiples', since their width sets how many
130
+ * panels stand across. A chart that fills any height asks for none, and is laid out as ever.
131
+ */
132
+ sizing?: boolean;
90
133
  };
91
134
  /** What a chart says of itself, drawn inside it so a saved picture stands alone. */
92
135
  export type Header = {