derive-dashboards 0.5.1 → 0.7.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 (342) hide show
  1. package/README.md +4 -2
  2. package/dist/body.mjs +2 -2
  3. package/dist/charts/data/buckets.d.mts +11 -0
  4. package/dist/charts/data/buckets.mjs +66 -0
  5. package/dist/charts/data/clean.mjs +55 -0
  6. package/dist/charts/data/format.d.mts +19 -0
  7. package/dist/charts/data/format.mjs +174 -0
  8. package/dist/charts/data/input-error.d.mts +5 -0
  9. package/dist/charts/data/input-error.mjs +11 -0
  10. package/dist/charts/data/range.mjs +14 -0
  11. package/dist/charts/data/rows.d.mts +13 -0
  12. package/dist/charts/data/rows.mjs +31 -0
  13. package/dist/charts/data/shares.mjs +55 -0
  14. package/dist/charts/data/types.d.mts +106 -0
  15. package/dist/charts/data/words.d.mts +44 -0
  16. package/dist/charts/data/words.mjs +31 -0
  17. package/dist/charts/describe.mjs +110 -0
  18. package/dist/charts/index.d.mts +34 -0
  19. package/dist/charts/index.mjs +24 -0
  20. package/dist/charts/kinds/area-marks.mjs +120 -0
  21. package/dist/charts/kinds/area.d.mts +23 -0
  22. package/dist/charts/kinds/area.mjs +71 -0
  23. package/dist/charts/kinds/bars-data.d.mts +11 -0
  24. package/dist/charts/kinds/bars-data.mjs +30 -0
  25. package/dist/charts/kinds/bars-layout.mjs +30 -0
  26. package/dist/charts/kinds/bars-marks.mjs +93 -0
  27. package/dist/charts/kinds/bars-words.mjs +56 -0
  28. package/dist/charts/kinds/bars.d.mts +17 -0
  29. package/dist/charts/kinds/bars.mjs +68 -0
  30. package/dist/charts/kinds/columns-data.mjs +116 -0
  31. package/dist/charts/kinds/columns-layout.mjs +29 -0
  32. package/dist/charts/kinds/columns-marks.mjs +200 -0
  33. package/dist/charts/kinds/columns-words.mjs +26 -0
  34. package/dist/charts/kinds/columns.d.mts +13 -0
  35. package/dist/charts/kinds/columns.mjs +80 -0
  36. package/dist/charts/kinds/dumbbell-data.d.mts +22 -0
  37. package/dist/charts/kinds/dumbbell-data.mjs +59 -0
  38. package/dist/charts/kinds/dumbbell-layout.mjs +113 -0
  39. package/dist/charts/kinds/dumbbell-marks.mjs +119 -0
  40. package/dist/charts/kinds/dumbbell-words.d.mts +7 -0
  41. package/dist/charts/kinds/dumbbell-words.mjs +94 -0
  42. package/dist/charts/kinds/dumbbell.d.mts +14 -0
  43. package/dist/charts/kinds/dumbbell.mjs +67 -0
  44. package/dist/charts/kinds/funnel-data.d.mts +11 -0
  45. package/dist/charts/kinds/funnel-data.mjs +70 -0
  46. package/dist/charts/kinds/funnel-layout.mjs +32 -0
  47. package/dist/charts/kinds/funnel-marks.mjs +204 -0
  48. package/dist/charts/kinds/funnel-words.mjs +77 -0
  49. package/dist/charts/kinds/funnel.d.mts +11 -0
  50. package/dist/charts/kinds/funnel.mjs +75 -0
  51. package/dist/charts/kinds/grid-data.d.mts +18 -0
  52. package/dist/charts/kinds/grid-data.mjs +35 -0
  53. package/dist/charts/kinds/grid-layout.mjs +77 -0
  54. package/dist/charts/kinds/grid-marks.mjs +140 -0
  55. package/dist/charts/kinds/grid-time.mjs +41 -0
  56. package/dist/charts/kinds/grid-words.mjs +86 -0
  57. package/dist/charts/kinds/grid.d.mts +22 -0
  58. package/dist/charts/kinds/grid.mjs +55 -0
  59. package/dist/charts/kinds/histogram-data.mjs +142 -0
  60. package/dist/charts/kinds/histogram-layout.mjs +144 -0
  61. package/dist/charts/kinds/histogram-marks.mjs +110 -0
  62. package/dist/charts/kinds/histogram-words.mjs +104 -0
  63. package/dist/charts/kinds/histogram.d.mts +15 -0
  64. package/dist/charts/kinds/histogram.mjs +47 -0
  65. package/dist/charts/kinds/line-marks.mjs +36 -0
  66. package/dist/charts/kinds/line.d.mts +17 -0
  67. package/dist/charts/kinds/line.mjs +52 -0
  68. package/dist/charts/kinds/multiples-grid.mjs +107 -0
  69. package/dist/charts/kinds/multiples-head.mjs +44 -0
  70. package/dist/charts/kinds/multiples-layout.mjs +159 -0
  71. package/dist/charts/kinds/multiples-marks.mjs +95 -0
  72. package/dist/charts/kinds/multiples-words.mjs +110 -0
  73. package/dist/charts/kinds/multiples.d.mts +26 -0
  74. package/dist/charts/kinds/multiples.mjs +42 -0
  75. package/dist/charts/kinds/row-chart.mjs +112 -0
  76. package/dist/charts/kinds/row-marks.mjs +121 -0
  77. package/dist/charts/kinds/scatter-data.d.mts +18 -0
  78. package/dist/charts/kinds/scatter-data.mjs +123 -0
  79. package/dist/charts/kinds/scatter-layout.mjs +189 -0
  80. package/dist/charts/kinds/scatter-marks.mjs +149 -0
  81. package/dist/charts/kinds/scatter-words.mjs +80 -0
  82. package/dist/charts/kinds/scatter.d.mts +21 -0
  83. package/dist/charts/kinds/scatter.mjs +72 -0
  84. package/dist/charts/kinds/stat-data.mjs +91 -0
  85. package/dist/charts/kinds/stat-layout.mjs +108 -0
  86. package/dist/charts/kinds/stat-marks.mjs +85 -0
  87. package/dist/charts/kinds/stat-words.mjs +57 -0
  88. package/dist/charts/kinds/stat.d.mts +28 -0
  89. package/dist/charts/kinds/stat.mjs +35 -0
  90. package/dist/charts/kinds/time-chart.mjs +74 -0
  91. package/dist/charts/kinds/time-frame.mjs +113 -0
  92. package/dist/charts/kinds/time-notes.mjs +36 -0
  93. package/dist/charts/kinds/time-plan.d.mts +8 -0
  94. package/dist/charts/kinds/time-plan.mjs +57 -0
  95. package/dist/charts/kinds/time-plot.mjs +56 -0
  96. package/dist/charts/kinds/time-stops.mjs +56 -0
  97. package/dist/charts/kinds/value-plot.mjs +33 -0
  98. package/dist/charts/kinds/waterfall-data.d.mts +7 -0
  99. package/dist/charts/kinds/waterfall-data.mjs +71 -0
  100. package/dist/charts/kinds/waterfall-layout.mjs +38 -0
  101. package/dist/charts/kinds/waterfall-marks.mjs +82 -0
  102. package/dist/charts/kinds/waterfall-words.mjs +118 -0
  103. package/dist/charts/kinds/waterfall.d.mts +17 -0
  104. package/dist/charts/kinds/waterfall.mjs +66 -0
  105. package/dist/charts/layout/boxes.mjs +28 -0
  106. package/dist/charts/layout/dodge.mjs +75 -0
  107. package/dist/charts/layout/extent.mjs +25 -0
  108. package/dist/charts/layout/frame.mjs +97 -0
  109. package/dist/charts/layout/place-labels.mjs +101 -0
  110. package/dist/charts/layout/stack.mjs +31 -0
  111. package/dist/charts/marks/axes.mjs +137 -0
  112. package/dist/charts/marks/dot.mjs +31 -0
  113. package/dist/charts/marks/end-labels.mjs +124 -0
  114. package/dist/charts/marks/legend.mjs +141 -0
  115. package/dist/charts/marks/lines.d.mts +2 -0
  116. package/dist/charts/marks/lines.mjs +38 -0
  117. package/dist/charts/marks/lit.d.mts +3 -0
  118. package/dist/charts/marks/lit.mjs +63 -0
  119. package/dist/charts/marks/more.mjs +18 -0
  120. package/dist/charts/marks/notes.mjs +253 -0
  121. package/dist/charts/marks/series-line.mjs +110 -0
  122. package/dist/charts/marks/thin.mjs +138 -0
  123. package/dist/charts/marks/x-axis.mjs +32 -0
  124. package/dist/charts/scale/calendar.mjs +174 -0
  125. package/dist/charts/scale/time-ticks.mjs +154 -0
  126. package/dist/charts/scale/time.mjs +33 -0
  127. package/dist/charts/scale/value.mjs +161 -0
  128. package/dist/charts/scene/defs.mjs +33 -0
  129. package/dist/charts/scene/markup.mjs +35 -0
  130. package/dist/charts/scene/nearest.d.mts +11 -0
  131. package/dist/charts/scene/nearest.mjs +49 -0
  132. package/dist/charts/scene/paint.d.mts +12 -0
  133. package/dist/charts/scene/paint.mjs +13 -0
  134. package/dist/charts/scene/svg.d.mts +18 -0
  135. package/dist/charts/scene/svg.mjs +185 -0
  136. package/dist/charts/scene/types.d.mts +177 -0
  137. package/dist/charts/text/measure.d.mts +9 -0
  138. package/dist/charts/text/measure.mjs +123 -0
  139. package/dist/charts/theme.d.mts +47 -0
  140. package/dist/charts/theme.mjs +239 -0
  141. package/dist/charts-react/Chart.d.mts +91 -0
  142. package/dist/charts-react/Chart.mjs +166 -0
  143. package/dist/charts-react/Overlay.mjs +171 -0
  144. package/dist/charts-react/Picture.mjs +22 -0
  145. package/dist/charts-react/Reader.mjs +147 -0
  146. package/dist/charts-react/bucket-names.mjs +29 -0
  147. package/dist/charts-react/chart-unlayered.css +1 -0
  148. package/dist/charts-react/chart-unlayered.css.d.ts +1 -0
  149. package/dist/charts-react/chart.css +1 -0
  150. package/dist/charts-react/chart.css.d.ts +1 -0
  151. package/dist/charts-react/events.mjs +72 -0
  152. package/dist/charts-react/exact-sum.mjs +24 -0
  153. package/dist/charts-react/from-answer.mjs +185 -0
  154. package/dist/charts-react/index.d.mts +3 -0
  155. package/dist/charts-react/index.mjs +4 -0
  156. package/dist/charts-react/keys.mjs +117 -0
  157. package/dist/charts-react/opens.mjs +28 -0
  158. package/dist/charts-react/plan-bars.mjs +95 -0
  159. package/dist/charts-react/plan-funnel.mjs +120 -0
  160. package/dist/charts-react/plan-grid.mjs +121 -0
  161. package/dist/charts-react/plan-parts.d.mts +2 -0
  162. package/dist/charts-react/plan-parts.mjs +30 -0
  163. package/dist/charts-react/plan-time.mjs +84 -0
  164. package/dist/charts-react/plan.d.mts +3 -0
  165. package/dist/charts-react/plan.mjs +37 -0
  166. package/dist/charts-react/point-keys.mjs +22 -0
  167. package/dist/charts-react/pointer.mjs +99 -0
  168. package/dist/charts-react/reader-page.d.mts +8 -0
  169. package/dist/charts-react/reader-page.mjs +116 -0
  170. package/dist/charts-react/tiles.d.mts +24 -0
  171. package/dist/charts-react/tiles.mjs +142 -0
  172. package/dist/charts-react/tip-place.mjs +107 -0
  173. package/dist/charts-react/tip-room.mjs +31 -0
  174. package/dist/charts-react/useClientLayoutEffect.mjs +8 -0
  175. package/dist/charts-react/useScene.mjs +76 -0
  176. package/dist/charts-react/useSize.mjs +44 -0
  177. package/dist/charts-react/useStop.mjs +68 -0
  178. package/dist/core/conformance/memory/aggregate.mjs +2 -1
  179. package/dist/core/conformance/memory/rows.mjs +1 -1
  180. package/dist/core/conformance/memory/source.mjs +3 -2
  181. package/dist/core/document/display-comparisons.mjs +49 -0
  182. package/dist/core/document/display-entries.mjs +2 -1
  183. package/dist/core/document/display-validation.d.mts +12 -0
  184. package/dist/core/document/display-validation.mjs +56 -0
  185. package/dist/core/document/display.d.mts +27 -12
  186. package/dist/core/document/display.mjs +40 -49
  187. package/dist/core/document/view-layout.mjs +16 -0
  188. package/dist/core/engine/access.mjs +4 -2
  189. package/dist/core/engine/context.mjs +5 -7
  190. package/dist/core/engine/custom/cells.mjs +1 -1
  191. package/dist/core/engine/custom/records.mjs +2 -1
  192. package/dist/core/engine/dialect.d.mts +2 -0
  193. package/dist/core/engine/index.mjs +1 -1
  194. package/dist/core/engine/levels.mjs +33 -1
  195. package/dist/core/engine/plan.d.mts +2 -0
  196. package/dist/core/engine/postgres.mjs +1 -0
  197. package/dist/core/engine/rank.mjs +1 -1
  198. package/dist/core/engine/reader.d.mts +4 -0
  199. package/dist/core/engine/sql-partition.mjs +45 -0
  200. package/dist/core/engine/sql-reads.mjs +4 -1
  201. package/dist/core/engine/statement.mjs +4 -4
  202. package/dist/core/engine/version.d.mts +1 -1
  203. package/dist/core/engine/version.mjs +1 -1
  204. package/dist/core/error/codes.d.mts +1 -1
  205. package/dist/core/error/codes.mjs +1 -1
  206. package/dist/core/exact/decimal.d.mts +1 -4
  207. package/dist/core/exact/decimal.mjs +1 -14
  208. package/dist/core/exact/text.d.mts +5 -0
  209. package/dist/core/exact/text.mjs +19 -0
  210. package/dist/core/index.d.mts +9 -6
  211. package/dist/core/index.mjs +11 -8
  212. package/dist/core/model/types.d.mts +2 -0
  213. package/dist/core/model/validate/fields.mjs +1 -1
  214. package/dist/core/model/validate/known-members.mjs +2 -0
  215. package/dist/core/model/validate/shape.mjs +5 -1
  216. package/dist/core/oracle/visibility.mjs +2 -2
  217. package/dist/core/policy/bind.mjs +29 -1
  218. package/dist/core/query/drill/compose.d.mts +2 -0
  219. package/dist/core/query/drill/compose.mjs +1 -1
  220. package/dist/core/query/drill/synthetic.mjs +2 -1
  221. package/dist/core/query/drill/types.d.mts +7 -0
  222. package/dist/core/query/drill/types.mjs +3 -1
  223. package/dist/core/result/number.mjs +2 -1
  224. package/dist/core/result/time-axis.mjs +2 -1
  225. package/dist/core/schema/answers.d.mts +1176 -362
  226. package/dist/core/schema/commands.mjs +2 -1
  227. package/dist/core/schema/document.mjs +27 -2
  228. package/dist/core/schema/drill-answers.mjs +19 -1
  229. package/dist/core/schema/drill.d.mts +21 -6
  230. package/dist/core/schema/drill.mjs +7 -1
  231. package/dist/core/schema/index.d.mts +2 -1
  232. package/dist/core/schema/index.mjs +2 -1
  233. package/dist/core/schema/null-ops.d.mts +6 -0
  234. package/dist/core/schema/null-ops.mjs +18 -0
  235. package/dist/core/schema/query.mjs +30 -4
  236. package/dist/core/schema/tools.mjs +13 -0
  237. package/dist/core/schema/union-error.mjs +38 -0
  238. package/dist/core/time/bucket.mjs +2 -1
  239. package/dist/core/time/index.d.mts +3 -2
  240. package/dist/core/time/instant.d.mts +1 -2
  241. package/dist/core/time/instant.mjs +2 -30
  242. package/dist/core/time/range.mjs +2 -1
  243. package/dist/core/time/stored.mjs +2 -1
  244. package/dist/core/time/text-time.d.mts +10 -0
  245. package/dist/core/time/text-time.mjs +80 -0
  246. package/dist/core/types/api.d.mts +1 -1
  247. package/dist/core/types/api.mjs +1 -1
  248. package/dist/core/types/drill-api.d.mts +22 -2
  249. package/dist/dashboard-documents.d.mts +8 -0
  250. package/dist/dashboard-documents.mjs +52 -0
  251. package/dist/drill-access.mjs +40 -3
  252. package/dist/drill-comparison.mjs +71 -0
  253. package/dist/drill-crumbs.mjs +21 -2
  254. package/dist/drill-group-seal.mjs +13 -0
  255. package/dist/drill-open.mjs +7 -1
  256. package/dist/drill-seal.mjs +4 -6
  257. package/dist/drill-views.mjs +5 -13
  258. package/dist/drill.mjs +28 -58
  259. package/dist/editing.mjs +1 -1
  260. package/dist/endpoints/drill.mjs +2 -3
  261. package/dist/endpoints/index.d.mts +20 -0
  262. package/dist/index.d.mts +2 -1
  263. package/dist/index.mjs +6 -27
  264. package/dist/llms.txt +1 -1
  265. package/dist/react/Cell.mjs +2 -2
  266. package/dist/react/DashboardList.mjs +3 -3
  267. package/dist/react/Editing.mjs +3 -3
  268. package/dist/react/Header.mjs +2 -2
  269. package/dist/react/History.mjs +3 -3
  270. package/dist/react/Parts.mjs +2 -2
  271. package/dist/react/RowBody.d.mts +2 -4
  272. package/dist/react/RowBody.mjs +14 -39
  273. package/dist/react/Tile.mjs +4 -5
  274. package/dist/react/builder/FilterEditor.mjs +2 -2
  275. package/dist/react/builder/Picker.mjs +3 -3
  276. package/dist/react/builder/RangeEditor.mjs +3 -3
  277. package/dist/react/builder/Time.mjs +3 -3
  278. package/dist/react/builder/Values.mjs +2 -2
  279. package/dist/react/builder/WidgetBuilder.mjs +2 -2
  280. package/dist/react/digits.mjs +1 -1
  281. package/dist/react/drill/Bars.mjs +34 -38
  282. package/dist/react/drill/Comparison.mjs +204 -0
  283. package/dist/react/drill/Controls.mjs +8 -12
  284. package/dist/react/drill/DrillDrawer.mjs +42 -0
  285. package/dist/react/drill/DrillPanel.mjs +61 -41
  286. package/dist/react/drill/Header.mjs +65 -35
  287. package/dist/react/drill/ItemLink.mjs +40 -0
  288. package/dist/react/drill/Items.d.mts +2 -1
  289. package/dist/react/drill/Items.mjs +126 -99
  290. package/dist/react/drill/ItemsBody.mjs +38 -0
  291. package/dist/react/drill/ItemsFoot.mjs +24 -19
  292. package/dist/react/drill/Notes.mjs +23 -13
  293. package/dist/react/drill/PanelBody.mjs +7 -25
  294. package/dist/react/drill/RecordRow.mjs +47 -0
  295. package/dist/react/drill/Trend.mjs +186 -0
  296. package/dist/react/drill/board.mjs +21 -11
  297. package/dist/react/drill/drawer-context.mjs +5 -0
  298. package/dist/react/drill/item-parts.mjs +53 -35
  299. package/dist/react/drill/item-type.d.mts +2 -2
  300. package/dist/react/drill/lazy.d.mts +1 -4
  301. package/dist/react/drill/lazy.mjs +29 -11
  302. package/dist/react/drill/panel-focus.mjs +18 -7
  303. package/dist/react/drill/props.d.mts +7 -1
  304. package/dist/react/drill/props.mjs +39 -8
  305. package/dist/react/drill/record-page.mjs +61 -0
  306. package/dist/react/drill/state.mjs +17 -2
  307. package/dist/react/drill/trend-touch.mjs +33 -0
  308. package/dist/react/drill/useDrill.d.mts +3 -3
  309. package/dist/react/drill/useDrill.mjs +35 -15
  310. package/dist/react/drill/words.d.mts +14 -0
  311. package/dist/react/drill/words.mjs +20 -8
  312. package/dist/react/english.d.mts +4 -1
  313. package/dist/react/english.mjs +17 -2
  314. package/dist/react/filters/chip.mjs +2 -2
  315. package/dist/react/filters/menu-search.mjs +5 -5
  316. package/dist/react/filters/menu.mjs +2 -2
  317. package/dist/react/filters/number.mjs +2 -2
  318. package/dist/react/filters/operator.mjs +2 -2
  319. package/dist/react/filters/phone.mjs +2 -2
  320. package/dist/react/filters/values.mjs +4 -4
  321. package/dist/react/format-time.d.mts +2 -1
  322. package/dist/react/format-time.mjs +42 -34
  323. package/dist/react/format.mjs +15 -3
  324. package/dist/react/index.d.mts +4 -3
  325. package/dist/react/index.mjs +4 -3
  326. package/dist/react/messages.d.mts +23 -2
  327. package/dist/react/renderers/entries.d.mts +11 -0
  328. package/dist/react/renderers/list.mjs +8 -10
  329. package/dist/react/renderers/table-cells.mjs +38 -9
  330. package/dist/react/renderers/table-measure.mjs +2 -0
  331. package/dist/react/renderers/table-row.mjs +64 -7
  332. package/dist/react/renderers/table-sort.mjs +2 -8
  333. package/dist/react/renderers/table.mjs +16 -15
  334. package/dist/react/series.mjs +8 -3
  335. package/dist/react/theme-unlayered.css +1 -3144
  336. package/dist/react/theme.css +1 -3146
  337. package/dist/recharts/parts.mjs +1 -1
  338. package/dist/skills/derive-dashboards/SKILL.md +10 -5
  339. package/dist/store/apply.mjs +2 -2
  340. package/dist/store/editor.mjs +2 -2
  341. package/dist/store/writer.mjs +2 -2
  342. package/package.json +27 -2
@@ -1,47 +1,14 @@
1
1
  import { isNumberType } from "../columns.mjs";
2
2
  import { useDashboards } from "../context.mjs";
3
3
  import { formatCell } from "../format.mjs";
4
- import { RowBody } from "../RowBody.mjs";
5
- import { columnShape, itemParts, readMode, writeMode } from "./item-parts.mjs";
4
+ import { Opener, hrefOf } from "./ItemLink.mjs";
5
+ import { columnShape, itemParts, itemTitle, recordField, recordParts, sortDate } from "./item-parts.mjs";
6
6
  import { asItem } from "./item-type.mjs";
7
- import { useEffect, useRef, useState } from "react";
8
- import { itemLink } from "derive-dashboards/core";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { RecordHeading, RecordRow } from "./RecordRow.mjs";
8
+ import { RecordPager, useRecordPage } from "./record-page.mjs";
9
+ import { useEffect, useRef } from "react";
10
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
11
  // src/drill/Items.tsx
11
- const plainClick = (event) => event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
12
- /**
13
- * An item's link: the host's `itemHref` when it gives one (its `undefined` turns the link off),
14
- * else its source's `itemLinks` template, else the server's. A hidden key never has one.
15
- */
16
- const hrefOf = (options, item) => options.itemHref === void 0 ? itemLink(options.itemLinks, item) ?? item.link : options.itemHref(asItem(item));
17
- /** How an item opens: as a link, a button, or not at all. */
18
- function Opener(props) {
19
- const { link: Link = "a" } = useDashboards();
20
- const { item, options } = props;
21
- const href = hrefOf(options, item);
22
- const onItem = options.onItem;
23
- if (href === void 0 && onItem === void 0) return /* @__PURE__ */ jsx("div", {
24
- className: props.className,
25
- children: props.children
26
- });
27
- if (href === void 0) return /* @__PURE__ */ jsx("button", {
28
- type: "button",
29
- className: props.className,
30
- onClick: (event) => onItem?.(asItem(item), { event }),
31
- children: props.children
32
- });
33
- const onClick = (event) => {
34
- if (onItem === void 0 || !plainClick(event)) return;
35
- event.preventDefault();
36
- onItem(asItem(item), { event });
37
- };
38
- return /* @__PURE__ */ jsx(Link, {
39
- href,
40
- className: props.className,
41
- onClick,
42
- children: props.children
43
- });
44
- }
45
12
  /** A noun as a column heading: "task" reads "Task". */
46
13
  const headOf = (noun) => noun === void 0 ? void 0 : `${noun.charAt(0).toLocaleUpperCase()}${noun.slice(1)}`;
47
14
  /**
@@ -52,14 +19,18 @@ const headOf = (noun) => noun === void 0 ? void 0 : `${noun.charAt(0).toLocaleUp
52
19
  function Table(props) {
53
20
  const format = useDashboards();
54
21
  const { view } = props;
22
+ const body = useAppendedRow(props);
55
23
  const cell = {
56
24
  ...format,
57
25
  timeZone: props.timeZone
58
26
  };
59
- const rest = view.columns.filter((c) => c.member !== view.title);
27
+ const priority = (member) => member === view.sorted?.member ? 0 : view.fixed?.includes(member) === true ? 2 : 1;
28
+ const rest = view.columns.filter((c) => c.member !== view.title).toSorted((a, b) => priority(a.member) - priority(b.member));
60
29
  const named = view.columns.find((c) => c.member === view.title);
61
- return /* @__PURE__ */ jsx("div", {
30
+ return /* @__PURE__ */ jsx("section", {
62
31
  className: "dd-records-scroll",
32
+ tabIndex: 0,
33
+ "aria-label": format.messages.drillViews.items,
63
34
  children: /* @__PURE__ */ jsxs("table", {
64
35
  className: "dd-table",
65
36
  children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
@@ -69,21 +40,28 @@ function Table(props) {
69
40
  scope: "col",
70
41
  "data-numeric": isNumberType(c.type),
71
42
  children: c.label
72
- }, c.member))] }) }), /* @__PURE__ */ jsx("tbody", { children: props.items.map((item, i) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
73
- scope: "row",
74
- children: /* @__PURE__ */ jsx(Opener, {
75
- item,
76
- options: props.options,
77
- className: "dd-item-cell",
78
- children: itemParts(view, item, {
79
- n: i + 1,
80
- noun: props.noun
81
- }, cell).title
82
- })
83
- }), rest.map((c) => /* @__PURE__ */ jsx("td", {
84
- "data-numeric": isNumberType(c.type),
85
- children: formatCell(item.values[c.member] ?? null, columnShape(c), cell)
86
- }, c.member))] }, item.id)) })]
43
+ }, c.member))] }) }), /* @__PURE__ */ jsx("tbody", {
44
+ ref: body,
45
+ children: props.items.map((item, i) => /* @__PURE__ */ jsxs("tr", {
46
+ tabIndex: -1,
47
+ children: [/* @__PURE__ */ jsx("th", {
48
+ scope: "row",
49
+ children: /* @__PURE__ */ jsx(Opener, {
50
+ item,
51
+ options: props.options,
52
+ className: "dd-item-cell",
53
+ children: itemTitle(named, item, {
54
+ n: props.start + i + 1,
55
+ noun: props.noun
56
+ }, cell)
57
+ })
58
+ }), rest.map((c) => /* @__PURE__ */ jsx("td", {
59
+ "data-numeric": isNumberType(c.type),
60
+ "data-type": c.type,
61
+ children: formatCell(item.values[c.member] ?? null, columnShape(c), cell)
62
+ }, c.member))]
63
+ }, item.id))
64
+ })]
87
65
  })
88
66
  });
89
67
  }
@@ -99,71 +77,120 @@ function helpersOf(options, item, base) {
99
77
  } }
100
78
  };
101
79
  }
102
- /** The items as a list: the default row, or the host's own (`renderItem`). After Show more, the first new row takes focus. */
103
- function List(props) {
104
- const format = useDashboards();
105
- const { view, options } = props;
80
+ /** Reveal the first new record for keyboard and pointer users, including read-only records. */
81
+ function useAppendedRow({ loaded, start }) {
106
82
  const list = useRef(null);
107
- const seen = useRef(props.items.length);
83
+ const seen = useRef(loaded);
108
84
  useEffect(() => {
109
85
  const before = seen.current;
110
- seen.current = props.items.length;
111
- if (props.items.length <= before || before === 0) return;
112
- list.current?.children[before]?.querySelector("a, button, [tabindex]")?.focus();
113
- }, [props.items.length]);
86
+ seen.current = loaded;
87
+ if (loaded <= before || before === 0 || before < start) return;
88
+ const row = list.current?.children[before - start];
89
+ if (!(row instanceof HTMLElement)) return;
90
+ const target = row.querySelector("a[href], button:not(:disabled), [tabindex]") ?? row;
91
+ target.focus({ preventScroll: true });
92
+ target.scrollIntoView({
93
+ block: "nearest",
94
+ inline: "nearest"
95
+ });
96
+ }, [loaded, start]);
97
+ return list;
98
+ }
99
+ function List(props) {
100
+ const format = useDashboards();
101
+ const { view, options } = props;
102
+ const list = useAppendedRow(props);
114
103
  const cell = {
115
104
  ...format,
116
105
  timeZone: props.timeZone
117
106
  };
107
+ const field = recordField(view);
108
+ const sorted = sortDate(view);
118
109
  return /* @__PURE__ */ jsx("ul", {
119
110
  className: "dd-items",
120
111
  ref: list,
121
112
  children: props.items.map((item, i) => {
122
- const parts = itemParts(view, item, {
123
- n: i + 1,
124
- noun: props.noun
125
- }, cell);
126
113
  const render = options.renderItem;
114
+ const row = {
115
+ n: props.start + i + 1,
116
+ noun: props.noun
117
+ };
127
118
  const opens = hrefOf(options, item) !== void 0 || options.onItem !== void 0;
128
- return /* @__PURE__ */ jsx("li", { children: render === void 0 ? /* @__PURE__ */ jsx(Opener, {
129
- item,
130
- options,
131
- className: "dd-item",
132
- children: /* @__PURE__ */ jsx(RowBody, {
133
- row: {
134
- ...parts,
135
- opens
136
- },
137
- family: "item"
138
- })
139
- }) : render(asItem(item), helpersOf(options, item, {
140
- ...parts,
141
- view
142
- })) }, item.id);
119
+ return /* @__PURE__ */ jsx("li", {
120
+ tabIndex: -1,
121
+ children: render === void 0 ? /* @__PURE__ */ jsx(Opener, {
122
+ item,
123
+ options,
124
+ className: "dd-item",
125
+ children: /* @__PURE__ */ jsx(RecordRow, {
126
+ parts: recordParts(view, item, {
127
+ ...row,
128
+ date: sorted?.member
129
+ }, cell),
130
+ opens,
131
+ date: sorted?.label,
132
+ field,
133
+ value: field && formatCell(item.values[field.member] ?? null, columnShape(field), cell)
134
+ })
135
+ }) : render(asItem(item), helpersOf(options, item, {
136
+ ...itemParts(view, item, row, cell),
137
+ view
138
+ }))
139
+ }, item.id);
143
140
  })
144
141
  });
145
142
  }
146
- /** The items as a list (the default) or a table, the choice kept in this browser. */
143
+ /** The toggle survives both layouts and takes focus back when the wide table closes. */
144
+ function useReturnToSummary(fields) {
145
+ const toggle = useRef(null);
146
+ const previous = useRef(fields);
147
+ useEffect(() => {
148
+ if (previous.current && !fields) toggle.current?.focus({ preventScroll: true });
149
+ previous.current = fields;
150
+ }, [fields]);
151
+ return toggle;
152
+ }
153
+ /** The same page of records as a summary list or a full table. */
147
154
  function Items(props) {
148
155
  const format = useDashboards();
149
156
  const { view, Empty } = props;
150
- const [mode, setMode] = useState(() => readMode(view.source));
157
+ const toggle = useReturnToSummary(props.fields);
158
+ const page = useRecordPage(props.items);
159
+ const visible = {
160
+ ...props,
161
+ start: page.start,
162
+ items: page.items,
163
+ loaded: props.items.length
164
+ };
151
165
  if (props.items.length === 0) return Empty === void 0 ? /* @__PURE__ */ jsx("p", {
152
166
  className: "dd-tile-state",
153
167
  children: format.messages.drillNoItems
154
168
  }) : /* @__PURE__ */ jsx(Empty, {});
155
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("fieldset", {
156
- className: "dd-drill-modes",
157
- "aria-label": format.messages.drillViews.items,
158
- children: ["list", "table"].map((m) => /* @__PURE__ */ jsx("button", {
159
- type: "button",
160
- "aria-pressed": mode === m,
161
- onClick: () => {
162
- setMode(m);
163
- writeMode(view.source, m);
164
- },
165
- children: m === "list" ? format.messages.drillList : format.messages.drillTable
166
- }, m))
167
- }), mode === "table" ? /* @__PURE__ */ jsx(Table, { ...props }) : /* @__PURE__ */ jsx(List, { ...props })] });
169
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
170
+ /* @__PURE__ */ jsxs("div", {
171
+ className: "dd-drill-records-head",
172
+ children: [props.count(page.paged ? {
173
+ first: page.start + 1,
174
+ last: page.end
175
+ } : void 0), /* @__PURE__ */ jsx("button", {
176
+ className: "dd-records-switch",
177
+ ref: toggle,
178
+ type: "button",
179
+ onClick: props.switchMode,
180
+ "aria-expanded": props.fields,
181
+ children: props.fields ? format.messages.drillList : format.messages.drillTable
182
+ })]
183
+ }),
184
+ page.paged && /* @__PURE__ */ jsx(RecordPager, {
185
+ page,
186
+ loaded: props.items.length
187
+ }),
188
+ !props.fields && props.options.renderItem === void 0 ? /* @__PURE__ */ jsx(RecordHeading, {
189
+ view,
190
+ noun: props.noun,
191
+ field: recordField(view)
192
+ }) : null,
193
+ props.fields ? /* @__PURE__ */ jsx(Table, { ...visible }) : /* @__PURE__ */ jsx(List, { ...visible })
194
+ ] });
168
195
  }
169
196
  export { Items };
@@ -0,0 +1,38 @@
1
+ import { useDashboards } from "../context.mjs";
2
+ import { formatCell } from "../format.mjs";
3
+ import { OnlyToggle } from "./Controls.mjs";
4
+ import { Items } from "./Items.mjs";
5
+ import { RecordCount } from "./ItemsFoot.mjs";
6
+ import { itemFields, showsFields } from "./state.mjs";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ // src/drill/ItemsBody.tsx
9
+ /** Items: the Only filter, a percentile's marker row, then the rows. */
10
+ function ItemsBody(a) {
11
+ const format = useDashboards();
12
+ const { d, view, props } = a;
13
+ const p = view.percentile;
14
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
15
+ /* @__PURE__ */ jsx(OnlyToggle, { d }),
16
+ p === void 0 || d.summary === void 0 ? null : /* @__PURE__ */ jsx("p", {
17
+ className: "dd-drill-marker",
18
+ children: format.messages.drillPercentile(p, formatCell(d.summary.value, d.summary.column, format))
19
+ }),
20
+ /* @__PURE__ */ jsx(Items, {
21
+ count: (range) => /* @__PURE__ */ jsx(RecordCount, {
22
+ d,
23
+ range
24
+ }),
25
+ fields: showsFields(d.state),
26
+ switchMode: () => {
27
+ if (d.state) d.setView(itemFields(d.state, !showsFields(d.state)).view, "push");
28
+ },
29
+ view,
30
+ items: d.items.items,
31
+ options: props,
32
+ noun: d.summary?.noun?.one,
33
+ timeZone: d.summary?.receipt.calendar.timezone,
34
+ Empty: props.components?.Empty
35
+ })
36
+ ] });
37
+ }
38
+ export { ItemsBody };
@@ -1,5 +1,7 @@
1
1
  import { useDashboards } from "../context.mjs";
2
+ import { formatCell } from "../format.mjs";
2
3
  import { countText } from "./counts.mjs";
4
+ import { RECORD_PAGES } from "./words.mjs";
3
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
6
  // src/drill/ItemsFoot.tsx
5
7
  /**
@@ -11,7 +13,7 @@ function listCount(view, summary) {
11
13
  return summary.semantics === "distinct" ? summary.value : summary.itemCount;
12
14
  }
13
15
  /** Items' count and sort, then Show more while there are more, with a retry when a page fails. */
14
- function ItemsFoot({ d }) {
16
+ function RecordCount({ d, range }) {
15
17
  const format = useDashboards();
16
18
  const { messages } = format;
17
19
  const view = d.items.view;
@@ -19,23 +21,26 @@ function ItemsFoot({ d }) {
19
21
  const count = listCount(view, d.summary);
20
22
  const total = count === void 0 ? void 0 : countText(count, format);
21
23
  const sort = sortText(view, messages);
22
- return /* @__PURE__ */ jsxs(Fragment, { children: [
23
- /* @__PURE__ */ jsxs("p", {
24
- className: "dd-records-count",
25
- "aria-live": "polite",
26
- children: [
27
- messages.drillShowing(d.items.items.length, total),
28
- " · ",
29
- sort
30
- ]
31
- }),
32
- d.items.moreError === void 0 ? null : /* @__PURE__ */ jsx("p", {
33
- className: "dd-tile-error",
34
- role: "alert",
35
- children: messages.drillFailed
36
- }),
37
- d.items.hasMore ? /* @__PURE__ */ jsx(More, { d }) : null
38
- ] });
24
+ const number = (n) => formatCell(n, { type: "int" }, format);
25
+ return /* @__PURE__ */ jsxs("p", {
26
+ className: "dd-records-count",
27
+ "aria-live": "polite",
28
+ children: [
29
+ range === void 0 ? messages.drillShowing(d.items.items.length, total) : (messages.drillRecordPages ?? RECORD_PAGES).range(number(range.first), number(range.last), number(d.items.items.length), total),
30
+ " ",
31
+ "· ",
32
+ sort
33
+ ]
34
+ });
35
+ }
36
+ function ItemsFoot({ d }) {
37
+ const { messages } = useDashboards();
38
+ if (d.items.view === void 0) return null;
39
+ return /* @__PURE__ */ jsxs(Fragment, { children: [d.items.moreError === void 0 ? null : /* @__PURE__ */ jsx("p", {
40
+ className: "dd-tile-error",
41
+ role: "alert",
42
+ children: messages.drillFailed
43
+ }), d.items.hasMore ? /* @__PURE__ */ jsx(More, { d }) : null] });
39
44
  }
40
45
  /** How the Items are sorted, in words: the declared order, or by the value. */
41
46
  function sortText(view, messages) {
@@ -57,4 +62,4 @@ function More({ d }) {
57
62
  children: label
58
63
  });
59
64
  }
60
- export { ItemsFoot };
65
+ export { ItemsFoot, RecordCount };
@@ -1,6 +1,7 @@
1
- import { formatInstantAt } from "../format-time.mjs";
2
1
  import { useDashboards } from "../context.mjs";
3
2
  import { formatCell } from "../format.mjs";
3
+ import { formatPeriod } from "../format-time.mjs";
4
+ import { trendWindowLabel } from "./words.mjs";
4
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
6
  // src/drill/Notes.tsx
6
7
  /** The value as the line reads it: a ratio as a percent when its column says so. */
@@ -10,17 +11,26 @@ const valueColumn = (summary) => summary.semantics === "ratio" && summary.column
10
11
  fraction: true,
11
12
  type: "float"
12
13
  } : summary.column;
13
- /** For the period before: the note that these are its rows, with its dates. */
14
- function Earlier({ summary }) {
14
+ /** Show a trend's window separately only when it differs from the selection. */
15
+ function TrendPeriod({ range, summary }) {
16
+ const format = useDashboards();
17
+ const selected = summary?.range;
18
+ if (range === void 0 || range.from === selected?.from && range.to === selected.to) return null;
19
+ const period = formatPeriod(range, format, summary?.receipt.calendar.timezone);
20
+ const window = format.messages.drillTrendWindow ?? trendWindowLabel;
21
+ return /* @__PURE__ */ jsx("span", {
22
+ className: "dd-drill-range",
23
+ children: summary && !selected ? window(period) : period
24
+ });
25
+ }
26
+ function Period({ summary }) {
15
27
  const format = useDashboards();
16
28
  const { messages } = format;
17
- const { range } = summary;
18
- if (summary.previous !== true || range === void 0) return null;
19
- const zone = summary.receipt.calendar.timezone;
20
- const day = (at) => formatInstantAt(at, "day", format.locale, zone);
29
+ if (summary.range === void 0) return null;
30
+ const period = formatPeriod(summary.range, format, summary.receipt.calendar.timezone);
21
31
  return /* @__PURE__ */ jsx("p", {
22
32
  className: "dd-drill-period",
23
- children: messages.drillEarlier(messages.drillRange(day(range.from), day(range.to)))
33
+ children: summary.previous === true ? messages.drillEarlier(period) : period
24
34
  });
25
35
  }
26
36
  /** The notes under the value: the period before, a moved value (the viewer's own link only), a shared link's limits. */
@@ -28,14 +38,14 @@ function Notes({ summary, value, onRefresh }) {
28
38
  const format = useDashboards();
29
39
  const { messages } = format;
30
40
  const clicked = summary.clicked;
31
- const moved = summary.foreign !== true && clicked !== void 0 && JSON.stringify(clicked) !== JSON.stringify(summary.value);
41
+ const previous = clicked === void 0 || summary.foreign === true ? void 0 : formatCell(clicked, valueColumn(summary), format);
32
42
  return /* @__PURE__ */ jsxs(Fragment, { children: [
33
- /* @__PURE__ */ jsx(Earlier, { summary }),
34
- moved ? /* @__PURE__ */ jsxs("p", {
43
+ /* @__PURE__ */ jsx(Period, { summary }),
44
+ previous !== void 0 && previous !== value ? /* @__PURE__ */ jsxs("p", {
35
45
  className: "dd-tile-note",
36
46
  role: "status",
37
47
  children: [
38
- messages.drillMoved(value, formatCell(clicked, valueColumn(summary), format)),
48
+ messages.drillMoved(value, previous),
39
49
  " ",
40
50
  /* @__PURE__ */ jsx("button", {
41
51
  type: "button",
@@ -56,4 +66,4 @@ function Notes({ summary, value, onRefresh }) {
56
66
  }) : null
57
67
  ] });
58
68
  }
59
- export { Notes, valueColumn };
69
+ export { Notes, TrendPeriod, valueColumn };
@@ -1,8 +1,7 @@
1
- import { useDashboards } from "../context.mjs";
2
- import { formatCell } from "../format.mjs";
3
1
  import { Bars } from "./Bars.mjs";
4
- import { FieldPicker, OnlyToggle, Operands } from "./Controls.mjs";
5
- import { Items } from "./Items.mjs";
2
+ import { Comparison } from "./Comparison.mjs";
3
+ import { FieldPicker, Operands } from "./Controls.mjs";
4
+ import { ItemsBody } from "./ItemsBody.mjs";
6
5
  import { ItemsFoot } from "./ItemsFoot.mjs";
7
6
  import { Failed, SeeRows } from "./PanelStates.mjs";
8
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -11,6 +10,10 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
10
  function Body({ d, props }) {
12
11
  const shown = d.shown;
13
12
  if (shown === void 0) return null;
13
+ if (shown.by === "comparison") return d.answer && /* @__PURE__ */ jsx(Comparison, {
14
+ answer: d.answer,
15
+ view: shown
16
+ });
14
17
  if (shown.by === "items") return /* @__PURE__ */ jsx(ItemsBody, {
15
18
  d,
16
19
  view: shown,
@@ -23,27 +26,6 @@ function Body({ d, props }) {
23
26
  onOpen: d.open
24
27
  });
25
28
  }
26
- /** Items: the Only filter, a percentile's marker row, then the rows. */
27
- function ItemsBody(a) {
28
- const format = useDashboards();
29
- const { d, view, props } = a;
30
- const p = view.percentile;
31
- return /* @__PURE__ */ jsxs(Fragment, { children: [
32
- /* @__PURE__ */ jsx(OnlyToggle, { d }),
33
- p === void 0 || d.summary === void 0 ? null : /* @__PURE__ */ jsx("p", {
34
- className: "dd-drill-marker",
35
- children: format.messages.drillPercentile(p, formatCell(d.summary.value, d.summary.column, format))
36
- }),
37
- /* @__PURE__ */ jsx(Items, {
38
- view,
39
- items: d.items.items,
40
- options: props,
41
- noun: d.summary?.noun?.one,
42
- timeZone: d.summary?.receipt.calendar.timezone,
43
- Empty: props.components?.Empty
44
- })
45
- ] });
46
- }
47
29
  /** A failed read, or the panel loading, or its body. */
48
30
  function Main({ d, props, close }) {
49
31
  if (d.status === "error") return /* @__PURE__ */ jsx(Failed, {
@@ -0,0 +1,47 @@
1
+ import { isNumberType } from "../columns.mjs";
2
+ import { useDashboards } from "../context.mjs";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ // src/drill/RecordRow.tsx
5
+ function RecordRow(props) {
6
+ const { parts, field } = props;
7
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
8
+ className: "dd-record-name",
9
+ children: [
10
+ /* @__PURE__ */ jsx("strong", { children: parts.title }),
11
+ props.opens ? /* @__PURE__ */ jsxs("span", {
12
+ className: "dd-direction",
13
+ "aria-hidden": "true",
14
+ children: [" ", "›"]
15
+ }) : null,
16
+ parts.value === void 0 ? null : /* @__PURE__ */ jsxs("small", { children: [/* @__PURE__ */ jsxs("span", {
17
+ className: "dd-sr-only",
18
+ children: [props.date, " "]
19
+ }), parts.value] }),
20
+ parts.badge === void 0 ? null : /* @__PURE__ */ jsx("span", {
21
+ className: "dd-item-badge",
22
+ "data-tone": parts.badge.tone,
23
+ children: parts.badge.text
24
+ })
25
+ ]
26
+ }), field === void 0 ? null : /* @__PURE__ */ jsxs("span", {
27
+ className: "dd-record-field",
28
+ "data-numeric": isNumberType(field.type),
29
+ children: [/* @__PURE__ */ jsxs("span", {
30
+ className: "dd-sr-only",
31
+ children: [field.label, " "]
32
+ }), props.value]
33
+ })] });
34
+ }
35
+ function RecordHeading(props) {
36
+ const { messages } = useDashboards();
37
+ const name = props.view.columns.find((c) => c.member === props.view.title)?.label ?? props.noun ?? messages.drillItem;
38
+ return /* @__PURE__ */ jsxs("div", {
39
+ className: "dd-record-heading",
40
+ "aria-hidden": "true",
41
+ children: [/* @__PURE__ */ jsx("span", { children: name }), props.field === void 0 ? null : /* @__PURE__ */ jsx("span", {
42
+ "data-numeric": isNumberType(props.field.type),
43
+ children: props.field.label
44
+ })]
45
+ });
46
+ }
47
+ export { RecordHeading, RecordRow };