derive-dashboards 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/README.md +8 -5
  2. package/dist/adapter/sql-adapter.mjs +4 -4
  3. package/dist/body.mjs +11 -1
  4. package/dist/cache.d.mts +1 -1
  5. package/dist/cli/add.mjs +130 -0
  6. package/dist/cli/check.mjs +14 -1
  7. package/dist/cli/cli.mjs +14 -12
  8. package/dist/cli/config.mjs +12 -1
  9. package/dist/cli/doctor.mjs +147 -0
  10. package/dist/cli/import/dbt-schema.mjs +2 -2
  11. package/dist/cli/import/index.mjs +2 -2
  12. package/dist/cli/init.mjs +3 -2
  13. package/dist/cli/json.mjs +21 -0
  14. package/dist/cli/layers.mjs +33 -0
  15. package/dist/core/conformance/cases.d.mts +3 -0
  16. package/dist/core/conformance/cases.mjs +20 -4
  17. package/dist/core/conformance/check.mjs +6 -3
  18. package/dist/core/conformance/drill-cases.mjs +120 -0
  19. package/dist/core/document/layout.mjs +1 -1
  20. package/dist/core/document/view-layout.d.mts +14 -0
  21. package/dist/core/document/view-layout.mjs +157 -0
  22. package/dist/core/document/view.d.mts +26 -7
  23. package/dist/core/document/view.mjs +42 -11
  24. package/dist/core/engine/filter.mjs +2 -2
  25. package/dist/core/engine/index.d.mts +14 -2
  26. package/dist/core/engine/index.mjs +12 -1
  27. package/dist/core/engine/leaf.mjs +9 -4
  28. package/dist/core/engine/members.mjs +2 -2
  29. package/dist/core/engine/postgres.mjs +1 -1
  30. package/dist/core/engine/record-layout.d.mts +11 -0
  31. package/dist/core/engine/record-layout.mjs +7 -7
  32. package/dist/core/engine/records.d.mts +3 -2
  33. package/dist/core/engine/records.mjs +2 -1
  34. package/dist/core/engine/segmented.mjs +5 -2
  35. package/dist/core/engine/sql-records.mjs +2 -1
  36. package/dist/core/engine/statement.mjs +37 -3
  37. package/dist/core/engine/types.d.mts +3 -0
  38. package/dist/core/engine/version.d.mts +1 -1
  39. package/dist/core/engine/version.mjs +1 -1
  40. package/dist/core/error/codes.d.mts +33 -1
  41. package/dist/core/error/codes.mjs +30 -2
  42. package/dist/core/index.d.mts +13 -7
  43. package/dist/core/index.mjs +9 -5
  44. package/dist/core/model/catalog/check.mjs +1 -1
  45. package/dist/core/model/hints.d.mts +36 -0
  46. package/dist/core/model/member.d.mts +4 -2
  47. package/dist/core/model/member.mjs +19 -3
  48. package/dist/core/model/types.d.mts +21 -19
  49. package/dist/core/model/validate/drill.mjs +70 -0
  50. package/dist/core/model/validate/index.mjs +3 -0
  51. package/dist/core/model/validate/members.mjs +7 -4
  52. package/dist/core/model/validate/shape.mjs +150 -0
  53. package/dist/core/model/validate/source.mjs +5 -3
  54. package/dist/core/policy/bind-query.d.mts +12 -0
  55. package/dist/core/policy/bind-query.mjs +53 -0
  56. package/dist/core/query/alias.mjs +7 -1
  57. package/dist/core/query/drill/compose.d.mts +22 -0
  58. package/dist/core/query/drill/compose.mjs +85 -0
  59. package/dist/core/query/drill/fields.d.mts +21 -0
  60. package/dist/core/query/drill/fields.mjs +91 -0
  61. package/dist/core/query/drill/internal.d.mts +11 -0
  62. package/dist/core/query/drill/items.d.mts +29 -0
  63. package/dist/core/query/drill/items.mjs +98 -0
  64. package/dist/core/query/drill/line.d.mts +31 -0
  65. package/dist/core/query/drill/line.mjs +183 -0
  66. package/dist/core/query/drill/links.d.mts +33 -0
  67. package/dist/core/query/drill/links.mjs +31 -0
  68. package/dist/core/query/drill/operand.mjs +7 -0
  69. package/dist/core/query/drill/scopes.d.mts +22 -0
  70. package/dist/core/query/drill/scopes.mjs +58 -0
  71. package/dist/core/query/drill/selection.d.mts +37 -0
  72. package/dist/core/query/drill/selection.mjs +144 -0
  73. package/dist/core/query/drill/steps.d.mts +14 -0
  74. package/dist/core/query/drill/steps.mjs +35 -0
  75. package/dist/core/query/drill/synthetic-expr.mjs +85 -0
  76. package/dist/core/query/drill/synthetic.d.mts +22 -0
  77. package/dist/core/query/drill/synthetic.mjs +165 -0
  78. package/dist/core/query/drill/time.d.mts +11 -0
  79. package/dist/core/query/drill/time.mjs +71 -0
  80. package/dist/core/query/drill/types.d.mts +155 -0
  81. package/dist/core/query/drill/types.mjs +4 -0
  82. package/dist/core/query/drill/views.d.mts +62 -0
  83. package/dist/core/query/drill/views.mjs +257 -0
  84. package/dist/core/query/filter.d.mts +6 -0
  85. package/dist/core/query/picks.d.mts +8 -2
  86. package/dist/core/query/picks.mjs +11 -4
  87. package/dist/core/query/segments.d.mts +12 -2
  88. package/dist/core/query/segments.mjs +5 -2
  89. package/dist/core/result/columns.mjs +20 -4
  90. package/dist/core/result/types.d.mts +5 -1
  91. package/dist/core/schema/aliases.d.mts +7 -0
  92. package/dist/core/schema/aliases.mjs +77 -0
  93. package/dist/core/schema/answer-parts.mjs +117 -0
  94. package/dist/core/schema/answers.d.mts +2109 -128
  95. package/dist/core/schema/answers.mjs +11 -113
  96. package/dist/core/schema/commands.d.mts +2 -2
  97. package/dist/core/schema/document.d.mts +1 -1
  98. package/dist/core/schema/drill-answers.mjs +179 -0
  99. package/dist/core/schema/drill.d.mts +260 -0
  100. package/dist/core/schema/drill.mjs +107 -0
  101. package/dist/core/schema/index.d.mts +6 -3
  102. package/dist/core/schema/index.mjs +6 -3
  103. package/dist/core/schema/picks.d.mts +35 -0
  104. package/dist/core/schema/picks.mjs +23 -0
  105. package/dist/core/schema/query.d.mts +82 -1
  106. package/dist/core/schema/query.mjs +9 -5
  107. package/dist/core/schema/tools.mjs +1 -1
  108. package/dist/core/schema/view.d.mts +0 -35
  109. package/dist/core/schema/view.mjs +19 -24
  110. package/dist/core/store/schema.d.mts +5 -0
  111. package/dist/core/store/schema.mjs +10 -0
  112. package/dist/core/types/api.d.mts +21 -1
  113. package/dist/core/types/api.mjs +1 -1
  114. package/dist/core/types/drill-api.d.mts +210 -0
  115. package/dist/core/types/options.d.mts +21 -0
  116. package/dist/core/types/viewer.d.mts +5 -0
  117. package/dist/cursor-seal.d.mts +8 -0
  118. package/dist/cursor-seal.mjs +98 -0
  119. package/dist/dashboard-id.mjs +1 -1
  120. package/dist/dashboards.mjs +4 -0
  121. package/dist/drill-access.mjs +93 -0
  122. package/dist/drill-change.mjs +76 -0
  123. package/dist/drill-crumbs.mjs +113 -0
  124. package/dist/drill-distinct.mjs +130 -0
  125. package/dist/drill-explain.mjs +64 -0
  126. package/dist/drill-identity.mjs +35 -0
  127. package/dist/drill-item-id.mjs +35 -0
  128. package/dist/drill-items.mjs +132 -0
  129. package/dist/drill-open.mjs +169 -0
  130. package/dist/drill-seal.mjs +170 -0
  131. package/dist/drill-secret.mjs +14 -0
  132. package/dist/drill-share.mjs +53 -0
  133. package/dist/drill-summary.mjs +158 -0
  134. package/dist/drill-targets.mjs +53 -0
  135. package/dist/drill-totals.mjs +8 -0
  136. package/dist/drill-views.mjs +175 -0
  137. package/dist/drill.mjs +157 -0
  138. package/dist/editing.mjs +3 -3
  139. package/dist/endpoints/dashboards.mjs +28 -5
  140. package/dist/endpoints/drill.mjs +55 -0
  141. package/dist/endpoints/index.d.mts +245 -4
  142. package/dist/endpoints/index.mjs +5 -1
  143. package/dist/endpoints/meta.mjs +10 -1
  144. package/dist/endpoints/query.mjs +26 -4
  145. package/dist/execute.d.mts +19 -1
  146. package/dist/execute.mjs +34 -27
  147. package/dist/handler.mjs +5 -1
  148. package/dist/index.d.mts +3 -1
  149. package/dist/index.mjs +29 -2
  150. package/dist/llms.txt +22 -0
  151. package/dist/mcp/drill.mjs +61 -0
  152. package/dist/mcp/format.mjs +69 -11
  153. package/dist/mcp/index.d.mts +15 -4
  154. package/dist/mcp/index.mjs +13 -7
  155. package/dist/mcp/query.d.mts +7 -2
  156. package/dist/mcp/query.mjs +40 -6
  157. package/dist/node-postgres.d.mts +8 -4
  158. package/dist/node-postgres.mjs +29 -6
  159. package/dist/owner.mjs +3 -3
  160. package/dist/postgres-connection.d.mts +8 -2
  161. package/dist/postgres-connection.mjs +2 -1
  162. package/dist/postgres-store.mjs +1 -0
  163. package/dist/react/Canvas.mjs +28 -5
  164. package/dist/react/Cell.mjs +2 -1
  165. package/dist/react/Dashboard.d.mts +10 -5
  166. package/dist/react/Dashboard.mjs +62 -22
  167. package/dist/react/DashboardList.mjs +52 -24
  168. package/dist/react/DashboardListRow.mjs +49 -0
  169. package/dist/react/Discard.mjs +12 -4
  170. package/dist/react/Editing.mjs +19 -5
  171. package/dist/react/FilterBar.d.mts +7 -9
  172. package/dist/react/Grid.mjs +19 -24
  173. package/dist/react/Header.mjs +10 -1
  174. package/dist/react/History.mjs +5 -0
  175. package/dist/react/Parts.mjs +6 -2
  176. package/dist/react/ReadFailed.mjs +23 -0
  177. package/dist/react/ReviewPanel.mjs +13 -2
  178. package/dist/react/RowBody.d.mts +19 -0
  179. package/dist/react/RowBody.mjs +55 -0
  180. package/dist/react/Spaces.mjs +15 -1
  181. package/dist/react/Tile.d.mts +3 -1
  182. package/dist/react/Tile.mjs +84 -32
  183. package/dist/react/_virtual/_rolldown/runtime.mjs +12 -0
  184. package/dist/react/arrange-steps.mjs +16 -13
  185. package/dist/react/arrange.mjs +10 -3
  186. package/dist/react/builder/Calcs.mjs +35 -11
  187. package/dist/react/builder/FilterEditor.mjs +196 -0
  188. package/dist/react/builder/Filters.mjs +172 -116
  189. package/dist/react/builder/Formula.mjs +82 -0
  190. package/dist/react/builder/Groups.mjs +1 -0
  191. package/dist/react/builder/Preview.mjs +1 -1
  192. package/dist/react/builder/RangeEditor.mjs +184 -0
  193. package/dist/react/builder/Sections.mjs +41 -6
  194. package/dist/react/builder/Time.mjs +138 -60
  195. package/dist/react/builder/Values.mjs +85 -0
  196. package/dist/react/builder/WidgetBuilder.mjs +50 -49
  197. package/dist/react/builder/base.d.mts +5 -0
  198. package/dist/react/builder/base.mjs +33 -8
  199. package/dist/react/builder/calc.mjs +15 -1
  200. package/dist/react/builder/escape.d.mts +1 -0
  201. package/dist/react/builder/escape.mjs +62 -0
  202. package/dist/react/builder/filter-tree.d.mts +9 -0
  203. package/dist/react/builder/filter-tree.mjs +186 -0
  204. package/dist/react/builder/formula-parse.d.mts +18 -0
  205. package/dist/react/builder/formula-parse.mjs +136 -0
  206. package/dist/react/builder/labels.d.mts +1 -1
  207. package/dist/react/builder/state.d.mts +2 -1
  208. package/dist/react/builder/state.mjs +23 -37
  209. package/dist/react/builder/useBuilder.d.mts +12 -1
  210. package/dist/react/builder/useBuilder.mjs +6 -3
  211. package/dist/react/builder/words.d.mts +59 -0
  212. package/dist/react/builder/words.mjs +73 -0
  213. package/dist/react/client.d.mts +2 -0
  214. package/dist/react/client.mjs +1 -0
  215. package/dist/react/context.d.mts +28 -1
  216. package/dist/react/context.mjs +25 -4
  217. package/dist/react/drill/Bars.mjs +179 -0
  218. package/dist/react/drill/Controls.mjs +173 -0
  219. package/dist/react/drill/DashboardTile.d.mts +18 -0
  220. package/dist/react/drill/DashboardTile.mjs +107 -0
  221. package/dist/react/drill/DrillPanel.d.mts +31 -0
  222. package/dist/react/drill/DrillPanel.mjs +104 -0
  223. package/dist/react/drill/DrillTabs.mjs +52 -0
  224. package/dist/react/drill/Header.mjs +131 -0
  225. package/dist/react/drill/Items.d.mts +22 -0
  226. package/dist/react/drill/Items.mjs +164 -0
  227. package/dist/react/drill/ItemsFoot.mjs +60 -0
  228. package/dist/react/drill/Notes.mjs +58 -0
  229. package/dist/react/drill/PanelBody.mjs +74 -0
  230. package/dist/react/drill/PanelStates.mjs +37 -0
  231. package/dist/react/drill/board.d.mts +18 -0
  232. package/dist/react/drill/board.mjs +91 -0
  233. package/dist/react/drill/counts.mjs +14 -0
  234. package/dist/react/drill/host.mjs +26 -0
  235. package/dist/react/drill/item-parts.d.mts +5 -0
  236. package/dist/react/drill/item-parts.mjs +76 -0
  237. package/dist/react/drill/item-type.d.mts +26 -0
  238. package/dist/react/drill/item-type.mjs +7 -0
  239. package/dist/react/drill/lazy.d.mts +6 -0
  240. package/dist/react/drill/lazy.mjs +17 -0
  241. package/dist/react/drill/pages.mjs +48 -0
  242. package/dist/react/drill/panel-focus.mjs +51 -0
  243. package/dist/react/drill/props.d.mts +25 -0
  244. package/dist/react/drill/props.mjs +72 -0
  245. package/dist/react/drill/state.d.mts +18 -0
  246. package/dist/react/drill/state.mjs +68 -0
  247. package/dist/react/drill/useDrill.d.mts +46 -0
  248. package/dist/react/drill/useDrill.mjs +194 -0
  249. package/dist/react/drill/words.d.mts +101 -0
  250. package/dist/react/drill/words.mjs +79 -0
  251. package/dist/react/english.mjs +29 -6
  252. package/dist/react/filters/bar.d.mts +12 -0
  253. package/dist/react/filters/bar.mjs +135 -0
  254. package/dist/react/filters/calendar.mjs +193 -0
  255. package/dist/react/filters/chip.mjs +174 -0
  256. package/dist/react/filters/context.d.mts +22 -0
  257. package/dist/react/filters/context.mjs +78 -0
  258. package/dist/react/filters/dates.mjs +89 -0
  259. package/dist/react/filters/days.d.mts +36 -0
  260. package/dist/react/filters/days.mjs +87 -0
  261. package/dist/react/filters/field-step.mjs +81 -0
  262. package/dist/react/filters/hooks.d.mts +34 -0
  263. package/dist/react/filters/hooks.mjs +94 -0
  264. package/dist/react/filters/listbox.mjs +131 -0
  265. package/dist/react/filters/logic.d.mts +59 -0
  266. package/dist/react/filters/logic.mjs +109 -0
  267. package/dist/react/filters/menu-search.mjs +211 -0
  268. package/dist/react/filters/menu.mjs +85 -0
  269. package/dist/react/filters/number.mjs +127 -0
  270. package/dist/react/filters/numbers.d.mts +47 -0
  271. package/dist/react/filters/numbers.mjs +151 -0
  272. package/dist/react/filters/operator.mjs +104 -0
  273. package/dist/react/filters/phone.mjs +104 -0
  274. package/dist/react/filters/popover.d.mts +19 -0
  275. package/dist/react/filters/popover.mjs +153 -0
  276. package/dist/react/filters/rules.d.mts +8 -0
  277. package/dist/react/filters/rules.mjs +55 -0
  278. package/dist/react/filters/sheet.mjs +196 -0
  279. package/dist/react/filters/state.mjs +132 -0
  280. package/dist/react/filters/suggest.d.mts +47 -0
  281. package/dist/react/filters/suggest.mjs +97 -0
  282. package/dist/react/filters/values.mjs +166 -0
  283. package/dist/react/filters/words.d.mts +81 -0
  284. package/dist/react/filters/words.mjs +73 -0
  285. package/dist/react/format.d.mts +3 -3
  286. package/dist/react/format.mjs +45 -16
  287. package/dist/react/index.d.mts +34 -5
  288. package/dist/react/index.mjs +15 -4
  289. package/dist/react/messages.d.mts +47 -2
  290. package/dist/react/place.mjs +7 -3
  291. package/dist/react/renderers/index.d.mts +10 -2
  292. package/dist/react/renderers/index.mjs +116 -14
  293. package/dist/react/renderers/list.d.mts +22 -0
  294. package/dist/react/renderers/list.mjs +118 -0
  295. package/dist/react/review-words.mjs +1 -1
  296. package/dist/react/review.mjs +2 -2
  297. package/dist/react/scope.mjs +2 -7
  298. package/dist/react/series.d.mts +54 -0
  299. package/dist/react/series.mjs +191 -0
  300. package/dist/react/theme.css +2734 -1296
  301. package/dist/react/theme.css.d.ts +1 -0
  302. package/dist/react/tile-store.mjs +15 -3
  303. package/dist/react/useBoard.d.mts +7 -0
  304. package/dist/react/useBoard.mjs +4 -1
  305. package/dist/react/useDashboard.d.mts +4 -0
  306. package/dist/react/useDashboard.mjs +8 -1
  307. package/dist/react/useTiles.mjs +50 -15
  308. package/dist/react/view-grid.mjs +16 -0
  309. package/dist/react/view.d.mts +9 -0
  310. package/dist/react/view.mjs +22 -10
  311. package/dist/reading.d.mts +2 -0
  312. package/dist/reading.mjs +9 -1
  313. package/dist/recharts/axes.mjs +28 -0
  314. package/dist/recharts/axis.mjs +84 -0
  315. package/dist/recharts/bar.d.mts +7 -0
  316. package/dist/recharts/bar.mjs +140 -0
  317. package/dist/recharts/charts.d.mts +4 -6
  318. package/dist/recharts/charts.mjs +2 -114
  319. package/dist/recharts/index.d.mts +5 -3
  320. package/dist/recharts/index.mjs +6 -3
  321. package/dist/recharts/line.d.mts +2 -0
  322. package/dist/recharts/line.mjs +111 -0
  323. package/dist/recharts/marks.mjs +112 -0
  324. package/dist/recharts/parts.mjs +88 -0
  325. package/dist/recharts/series.d.mts +2 -22
  326. package/dist/recharts/series.mjs +1 -64
  327. package/dist/recharts/table.mjs +71 -0
  328. package/dist/records-read.mjs +44 -0
  329. package/dist/registry/filter-bar.json +26 -0
  330. package/dist/skills/derive-dashboards/SKILL.md +69 -0
  331. package/dist/store/apply.mjs +5 -5
  332. package/dist/store/commands.mjs +4 -4
  333. package/dist/store/discard.mjs +7 -7
  334. package/dist/store/drafts.mjs +5 -5
  335. package/dist/store/editor.mjs +1 -1
  336. package/dist/store/publish.mjs +12 -12
  337. package/dist/store/reader.mjs +41 -22
  338. package/dist/store/review.mjs +16 -16
  339. package/dist/store/rows.mjs +20 -20
  340. package/dist/store/undo.mjs +3 -3
  341. package/dist/store/unpublished.mjs +4 -4
  342. package/dist/store/versions.mjs +14 -14
  343. package/dist/testing/adapter-suite.mjs +4 -4
  344. package/dist/tiles.mjs +37 -3
  345. package/package.json +12 -10
  346. package/dist/react/FilterBar.mjs +0 -119
  347. package/dist/react/Records.d.mts +0 -12
  348. package/dist/react/Records.mjs +0 -97
  349. package/src/adapter/sql-adapter.ts +0 -95
  350. package/src/adapter/statement.ts +0 -185
  351. package/src/authorize.ts +0 -73
  352. package/src/body.ts +0 -169
  353. package/src/bounded.ts +0 -43
  354. package/src/cache.ts +0 -192
  355. package/src/checks.ts +0 -170
  356. package/src/custom-source.ts +0 -59
  357. package/src/dashboard-id.ts +0 -36
  358. package/src/dashboards.ts +0 -132
  359. package/src/editing.ts +0 -148
  360. package/src/endpoints/access.ts +0 -41
  361. package/src/endpoints/dashboards.ts +0 -92
  362. package/src/endpoints/drafts.ts +0 -138
  363. package/src/endpoints/index.ts +0 -21
  364. package/src/endpoints/meta.ts +0 -137
  365. package/src/endpoints/query.ts +0 -86
  366. package/src/endpoints/read.ts +0 -92
  367. package/src/endpoints/review.ts +0 -89
  368. package/src/endpoints/values.ts +0 -62
  369. package/src/endpoints/versions.ts +0 -104
  370. package/src/execute.ts +0 -207
  371. package/src/handler.ts +0 -232
  372. package/src/http.ts +0 -66
  373. package/src/index.ts +0 -163
  374. package/src/introspect.ts +0 -205
  375. package/src/mcp/api.ts +0 -59
  376. package/src/mcp/format.ts +0 -67
  377. package/src/mcp/index.ts +0 -151
  378. package/src/mcp/query.ts +0 -153
  379. package/src/mcp/resolve.ts +0 -114
  380. package/src/node-postgres.ts +0 -81
  381. package/src/owner.ts +0 -36
  382. package/src/postgres-connection.ts +0 -143
  383. package/src/postgres-store.ts +0 -82
  384. package/src/principal.ts +0 -39
  385. package/src/reading.ts +0 -56
  386. package/src/request-rows.ts +0 -23
  387. package/src/request.ts +0 -22
  388. package/src/storage.ts +0 -63
  389. package/src/store/apply.ts +0 -129
  390. package/src/store/commands.ts +0 -75
  391. package/src/store/conflicts.ts +0 -98
  392. package/src/store/create-tables.ts +0 -104
  393. package/src/store/discard.ts +0 -42
  394. package/src/store/drafts.ts +0 -133
  395. package/src/store/editor.ts +0 -28
  396. package/src/store/log.ts +0 -28
  397. package/src/store/publish.ts +0 -199
  398. package/src/store/publisher.ts +0 -21
  399. package/src/store/reader.ts +0 -139
  400. package/src/store/review.ts +0 -239
  401. package/src/store/rows.ts +0 -250
  402. package/src/store/tenant.ts +0 -28
  403. package/src/store/undo.ts +0 -56
  404. package/src/store/unpublished.ts +0 -33
  405. package/src/store/versions.ts +0 -106
  406. package/src/store/writer.ts +0 -19
  407. package/src/testing/adapter-suite.ts +0 -239
  408. package/src/testing/index.ts +0 -2
  409. package/src/tile-doc.ts +0 -46
  410. package/src/tiles.ts +0 -120
@@ -35,11 +35,11 @@ async function dashboardRow(db, tenant, by) {
35
35
  }
36
36
  ]
37
37
  });
38
- return row !== null && sameTenant(row["tenant"], tenant) ? row : null;
38
+ return row !== null && sameTenant(row.tenant, tenant) ? row : null;
39
39
  }
40
40
  /** A dashboard's document at its current version; a built-in or new one has none yet. */
41
41
  async function headDoc(db, row) {
42
- const version = row["current_version"] === null ? 0 : Number(row["current_version"]);
42
+ const version = row.current_version === null ? 0 : Number(row.current_version);
43
43
  if (version === 0) return { version };
44
44
  return {
45
45
  version,
@@ -47,12 +47,12 @@ async function headDoc(db, row) {
47
47
  table: "dd_dashboard_version",
48
48
  where: [{
49
49
  field: "dashboard_id",
50
- value: row["id"]
50
+ value: row.id
51
51
  }, {
52
52
  field: "n",
53
53
  value: version
54
54
  }]
55
- }))?.["spec"], `dashboard "${String(row["id"])}"`)
55
+ }))?.spec, `dashboard "${String(row.id)}"`)
56
56
  };
57
57
  }
58
58
  /** A document's hash, by its canonical JSON. */
@@ -95,9 +95,9 @@ function draftAuthorId(author) {
95
95
  }
96
96
  /** The id an author is known by, from the id their draft row is kept under. */
97
97
  function authorIdOf(row) {
98
- const key = String(row["author_id"]);
99
- const person = row["for_id"];
100
- if (row["author_kind"] !== "agent" || typeof person !== "string") return key;
98
+ const key = String(row.author_id);
99
+ const person = row.for_id;
100
+ if (row.author_kind !== "agent" || typeof person !== "string") return key;
101
101
  return key.slice(`${String(person.length)}:${person}:`.length);
102
102
  }
103
103
  /** The author's draft row of a dashboard, open or closed; null when there has never been one. */
@@ -121,11 +121,11 @@ function draftRow(db, dashboardId, author) {
121
121
  });
122
122
  }
123
123
  /** The document a draft holds now. */
124
- const draftDoc = (row) => documentOf(row["spec"], `the draft of "${String(row["dashboard_id"])}"`);
124
+ const draftDoc = (row) => documentOf(row.spec, `the draft of "${String(row.dashboard_id)}"`);
125
125
  /** The document a draft started from: the draft is this with its commands applied. */
126
- const baseDoc = (row) => documentOf(row["base_spec"], `the start of the draft of "${String(row["dashboard_id"])}"`);
126
+ const baseDoc = (row) => documentOf(row.base_spec, `the start of the draft of "${String(row.dashboard_id)}"`);
127
127
  /** The document a draft first started from, once review moved it onto a newer version; else none. */
128
- const originDoc = (row) => row["origin_spec"] === null || row["origin_spec"] === void 0 ? void 0 : documentOf(row["origin_spec"], `the first start of the draft of "${String(row["dashboard_id"])}"`);
128
+ const originDoc = (row) => row.origin_spec === null || row.origin_spec === void 0 ? void 0 : documentOf(row.origin_spec, `the first start of the draft of "${String(row.dashboard_id)}"`);
129
129
  /** Who a draft row names in a column pair, if anyone. */
130
130
  function authorIn(row, prefix) {
131
131
  const id = row[`${prefix}_id`];
@@ -136,19 +136,19 @@ function authorIn(row, prefix) {
136
136
  };
137
137
  }
138
138
  /** The widgets a draft row says its commands name. */
139
- const namedOf = (row) => new Set(Array.isArray(row["named"]) ? row["named"].map(String) : []);
139
+ const namedOf = (row) => new Set(Array.isArray(row.named) ? row.named.map(String) : []);
140
140
  /** A draft row as the client reads it: its document, changes and undo steps, from the row alone. */
141
141
  function draftOf(row) {
142
142
  const doc = draftDoc(row);
143
143
  return {
144
- dashboardId: String(row["dashboard_id"]),
144
+ dashboardId: String(row.dashboard_id),
145
145
  authorId: authorIdOf(row),
146
- generation: Number(row["generation"]),
147
- revision: Number(row["revision"]),
148
- baseVersion: Number(row["base_version"]),
146
+ generation: Number(row.generation),
147
+ revision: Number(row.revision),
148
+ baseVersion: Number(row.base_version),
149
149
  doc,
150
150
  changes: markShifted(diffDocs(baseDoc(row), doc), namedOf(row)),
151
- steps: Number(row["steps"])
151
+ steps: Number(row.steps)
152
152
  };
153
153
  }
154
154
  /** The refusal for an edit made against another revision of the draft: the one wording of it. */
@@ -159,7 +159,7 @@ const draftClosed = () => new HttpError(409, "DRAFT_CLOSED", "There is no open d
159
159
  async function openDraft(db, a) {
160
160
  const dashboard = await dashboardRow(db, a.tenant, { id: a.id });
161
161
  const row = dashboard === null ? null : await draftRow(db, a.id, a.author);
162
- if (dashboard === null || row === null || row["state"] !== "open") throw draftClosed();
162
+ if (dashboard === null || row === null || row.state !== "open") throw draftClosed();
163
163
  return {
164
164
  row,
165
165
  dashboard
@@ -167,7 +167,7 @@ async function openDraft(db, a) {
167
167
  }
168
168
  /** Refuses an edit made against another revision of the draft than the current one. */
169
169
  function expectRevision(row, expected) {
170
- expectDraftRevision(Number(row["revision"]), expected);
170
+ expectDraftRevision(Number(row.revision), expected);
171
171
  }
172
172
  /** Refuses an edit made against another revision than `current`, with the one message for it. */
173
173
  function expectDraftRevision(current, expected) {
@@ -194,10 +194,10 @@ async function advanceDraft(tx, row, set) {
194
194
  table: "dd_dashboard_draft",
195
195
  where: [{
196
196
  field: "id",
197
- value: row["id"]
197
+ value: row.id
198
198
  }, {
199
199
  field: "revision",
200
- value: row["revision"]
200
+ value: row.revision
201
201
  }],
202
202
  set
203
203
  }) !== 1) throw draftConflict();
@@ -13,13 +13,13 @@ function undo(db, a) {
13
13
  const { row } = await openDraft(tx, a);
14
14
  expectRevision(row, a.expectedRevision);
15
15
  const base = baseDoc(row);
16
- const kept = await keptCommands(tx, row["id"]);
16
+ const kept = await keptCommands(tx, row.id);
17
17
  if (kept.length === 0) throw new HttpError(409, "NOTHING_TO_UNDO", "The draft has no edits left to undo.");
18
18
  const last = Math.max(...kept.map((k) => k.revision));
19
19
  const remaining = kept.filter((k) => k.revision !== last);
20
20
  const outcome = reduceAll(base, remaining.map((k) => k.body));
21
21
  if (!outcome.ok) throw new HttpError(409, "EDIT_REFUSED", outcome.issue.message, { issues: [outcome.issue] });
22
- const revision = Number(row["revision"]) + 1;
22
+ const revision = Number(row.revision) + 1;
23
23
  const set = {
24
24
  spec: outcome.doc,
25
25
  revision,
@@ -31,7 +31,7 @@ function undo(db, a) {
31
31
  table: "dd_dashboard_draft_command",
32
32
  where: [{
33
33
  field: "draft_id",
34
- value: row["id"]
34
+ value: row.id
35
35
  }, {
36
36
  field: "revision",
37
37
  value: last
@@ -33,13 +33,13 @@ async function unpublished(db, a) {
33
33
  }],
34
34
  limit: 100
35
35
  });
36
- const rows = await Promise.all(drafts.map((d) => dashboardRow(db, a.tenant, { id: String(d["dashboard_id"]) })));
36
+ const rows = await Promise.all(drafts.map((d) => dashboardRow(db, a.tenant, { id: String(d.dashboard_id) })));
37
37
  return drafts.flatMap((d, i) => {
38
38
  const row = rows[i];
39
- if (row === null || row === void 0 || row["current_version"] !== null) return [];
40
- if (row["default_of"] !== null) return [];
39
+ if (row === null || row === void 0 || row.current_version !== null) return [];
40
+ if (row.default_of !== null) return [];
41
41
  return [{
42
- dashboardId: String(row["id"]),
42
+ dashboardId: String(row.id),
43
43
  title: draftDoc(d).meta.title
44
44
  }];
45
45
  });
@@ -16,12 +16,12 @@ const optional = (value) => value === null || value === void 0 ? void 0 : Number
16
16
  */
17
17
  async function versions(db, a) {
18
18
  const row = await existing(db, a.tenant, a.id);
19
- if (row["current_version"] === null) throw new HttpError(404, "NOT_FOUND", `There is no dashboard "${a.id}".`);
19
+ if (row.current_version === null) throw new HttpError(404, "NOT_FOUND", `There is no dashboard "${a.id}".`);
20
20
  return (await db.findMany({
21
21
  table: "dd_dashboard_version",
22
22
  where: [{
23
23
  field: "dashboard_id",
24
- value: row["id"]
24
+ value: row.id
25
25
  }, ...a.before === void 0 ? [] : [{
26
26
  field: "n",
27
27
  op: "lt",
@@ -33,16 +33,16 @@ async function versions(db, a) {
33
33
  }],
34
34
  limit: Math.min(a.limit ?? PAGE, PAGE)
35
35
  })).map((v) => {
36
- const basedOn = optional(v["based_on"]);
37
- const restoredFrom = optional(v["restored_from"]);
38
- const kind = v["author_kind"] === "agent" ? "agent" : "user";
36
+ const basedOn = optional(v.based_on);
37
+ const restoredFrom = optional(v.restored_from);
38
+ const kind = v.author_kind === "agent" ? "agent" : "user";
39
39
  return {
40
- version: Number(v["n"]),
40
+ version: Number(v.n),
41
41
  author: {
42
- id: String(v["author_id"]),
42
+ id: String(v.author_id),
43
43
  kind
44
44
  },
45
- createdAt: String(v["created_at"]),
45
+ createdAt: String(v.created_at),
46
46
  ...basedOn === void 0 ? {} : { basedOn },
47
47
  ...restoredFrom === void 0 ? {} : { restoredFrom }
48
48
  };
@@ -55,16 +55,16 @@ async function versions(db, a) {
55
55
  function restore(db, a) {
56
56
  return inTransaction(db, async (tx) => {
57
57
  const row = await existing(tx, a.tenant, a.id);
58
- const done = await earlier(tx, row["id"], a.requestId, a.author);
58
+ const done = await earlier(tx, row.id, a.requestId, a.author);
59
59
  if (done !== null) return {
60
60
  dashboardId: a.id,
61
- version: Number(done["n"])
61
+ version: Number(done.n)
62
62
  };
63
63
  const old = await tx.findOne({
64
64
  table: "dd_dashboard_version",
65
65
  where: [{
66
66
  field: "dashboard_id",
67
- value: row["id"]
67
+ value: row.id
68
68
  }, {
69
69
  field: "n",
70
70
  value: a.version
@@ -74,16 +74,16 @@ function restore(db, a) {
74
74
  const head = await headDoc(tx, row);
75
75
  if (head.version !== a.expectedHead) throw new HttpError(409, "VERSION_CONFLICT", "The dashboard changed. Reload its history.");
76
76
  if (head.version === a.version) throw new HttpError(409, "VERSION_CONFLICT", `Version ${a.version} is already current.`);
77
- const doc = documentOf(old["spec"], `version ${a.version} of "${a.id}"`);
77
+ const doc = documentOf(old.spec, `version ${a.version} of "${a.id}"`);
78
78
  await insertVersion(tx, {
79
79
  ...a,
80
- dashboardId: row["id"],
80
+ dashboardId: row.id,
81
81
  n: head.version + 1,
82
82
  doc,
83
83
  basedOn: head.version,
84
84
  restoredFrom: a.version
85
85
  });
86
- await advanceHead(tx, row["id"], head.version, doc);
86
+ await advanceHead(tx, row.id, head.version, doc);
87
87
  return {
88
88
  dashboardId: a.id,
89
89
  version: head.version + 1
@@ -119,7 +119,7 @@ function rowCases(get) {
119
119
  limit: 1,
120
120
  offset: 1
121
121
  });
122
- expect(ids.map((r) => r["id"])).toEqual(["d1"]);
122
+ expect(ids.map((r) => r.id)).toEqual(["d1"]);
123
123
  expect(await get().count({
124
124
  table: "dd_dashboard",
125
125
  where: [{
@@ -181,9 +181,9 @@ function batchCases(get) {
181
181
  }]
182
182
  });
183
183
  expect(read.map((r) => [
184
- r["command_id"],
185
- r["body"],
186
- r["seq"]
184
+ r.command_id,
185
+ r.body,
186
+ r.seq
187
187
  ])).toEqual(rows.map((r) => [
188
188
  r.command_id,
189
189
  r.body,
package/dist/tiles.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { execute } from "./execute.mjs";
1
+ import { issueDrill } from "./drill-seal.mjs";
2
+ import { execute, wire } from "./execute.mjs";
2
3
  import { HttpError } from "./http.mjs";
3
4
  import { calendarOf } from "./request.mjs";
4
5
  import { composeTile } from "derive-dashboards/core";
@@ -27,11 +28,44 @@ function tileExecution(ctx, tile) {
27
28
  dashboardId: ctx.dashboardId
28
29
  };
29
30
  }
30
- /** One tile by reference: composed from the document, planned under the viewer's access, run. */
31
+ /** Where a drill into one of these tiles starts. */
32
+ function originOf(ctx, tile, document) {
33
+ return {
34
+ kind: "dashboard",
35
+ dashboardId: ctx.dashboardId,
36
+ widgetId: tile.widgetId,
37
+ ...tile.query === void 0 ? {} : { query: tile.query },
38
+ picks: ctx.picks,
39
+ ...document === void 0 ? {} : { document }
40
+ };
41
+ }
42
+ /**
43
+ * One tile by reference: composed from the document, planned under the viewer's access, run,
44
+ * with what a click on each of its rows drills into.
45
+ */
31
46
  async function runTile(ctx, tile) {
47
+ const x = tileExecution(ctx, tile);
48
+ const answer = await execute(x);
49
+ const { document } = ctx;
50
+ if (document === "merged") return {
51
+ widgetId: tile.widgetId,
52
+ ...wire(answer)
53
+ };
54
+ const scope = {
55
+ rt: ctx.rt,
56
+ principal: ctx.principal,
57
+ origin: originOf(ctx, tile, document)
58
+ };
59
+ const version = document !== void 0 && "version" in document ? document.version : ctx.version;
60
+ const drill = await issueDrill(scope, answer, {
61
+ query: x.query,
62
+ now: x.now,
63
+ ...version === void 0 ? {} : { version }
64
+ });
32
65
  return {
33
66
  widgetId: tile.widgetId,
34
- ...await execute(tileExecution(ctx, tile))
67
+ ...wire(answer),
68
+ ...drill === void 0 ? {} : { drill }
35
69
  };
36
70
  }
37
71
  /** An error a client can act on, as a line; anything else ends the stream. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "derive-dashboards",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Open-source embedded dashboards for your product: the server, the engine, React components, charts and the CLI, in one package.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -13,26 +13,21 @@
13
13
  "**/*.css"
14
14
  ],
15
15
  "files": [
16
- "dist",
17
- "src",
18
- "!src/**/*.test.ts"
16
+ "dist"
19
17
  ],
20
18
  "main": "./dist/index.mjs",
21
19
  "module": "./dist/index.mjs",
22
20
  "types": "./dist/index.d.mts",
23
21
  "exports": {
24
22
  ".": {
25
- "dev-source": "./src/index.ts",
26
23
  "types": "./dist/index.d.mts",
27
24
  "default": "./dist/index.mjs"
28
25
  },
29
26
  "./testing": {
30
- "dev-source": "./src/testing/index.ts",
31
27
  "types": "./dist/testing/index.d.mts",
32
28
  "default": "./dist/testing/index.mjs"
33
29
  },
34
30
  "./mcp": {
35
- "dev-source": "./src/mcp/index.ts",
36
31
  "types": "./dist/mcp/index.d.mts",
37
32
  "default": "./dist/mcp/index.mjs"
38
33
  },
@@ -60,7 +55,10 @@
60
55
  "types": "./dist/react/index.d.mts",
61
56
  "default": "./dist/react/index.mjs"
62
57
  },
63
- "./react/theme.css": "./dist/react/theme.css",
58
+ "./react/theme.css": {
59
+ "types": "./dist/react/theme.css.d.ts",
60
+ "default": "./dist/react/theme.css"
61
+ },
64
62
  "./recharts": {
65
63
  "types": "./dist/recharts/index.d.mts",
66
64
  "default": "./dist/recharts/index.mjs"
@@ -90,13 +88,17 @@
90
88
  },
91
89
  "peerDependencies": {
92
90
  "react": "^19.0.0",
91
+ "react-dom": "^19.0.0",
93
92
  "recharts": "^3.0.0",
94
- "vitest": "^5.0.0"
93
+ "vitest": "^4.0.0 || ^5.0.0"
95
94
  },
96
95
  "peerDependenciesMeta": {
97
96
  "react": {
98
97
  "optional": true
99
98
  },
99
+ "react-dom": {
100
+ "optional": true
101
+ },
100
102
  "recharts": {
101
103
  "optional": true
102
104
  },
@@ -108,7 +110,7 @@
108
110
  "derive-dashboards": "./dist/cli/bin.mjs"
109
111
  },
110
112
  "engines": {
111
- "node": ">=20"
113
+ "node": ">=24"
112
114
  },
113
115
  "keywords": [
114
116
  "dashboards",
@@ -1,119 +0,0 @@
1
- import { useDashboards } from "./context.mjs";
2
- import { ScopeContext } from "./scope.mjs";
3
- import { useContext } from "react";
4
- import useSWR from "swr";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- // src/FilterBar.tsx
7
- const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
8
- function without(picks, id) {
9
- return Object.fromEntries(Object.entries(picks).filter(([key]) => key !== id));
10
- }
11
- function DateRangeControl({ control, picks, onChange }) {
12
- const { messages } = useDashboards();
13
- return /* @__PURE__ */ jsxs("fieldset", {
14
- className: "dd-control",
15
- children: [/* @__PURE__ */ jsx("legend", {
16
- className: "dd-control-label",
17
- children: control.label
18
- }), control.presets.map((preset) => {
19
- const active = same(picks[control.id], preset);
20
- return /* @__PURE__ */ jsx("button", {
21
- type: "button",
22
- className: "dd-chip",
23
- "aria-pressed": active,
24
- onClick: () => {
25
- onChange(active ? without(picks, control.id) : {
26
- ...picks,
27
- [control.id]: preset
28
- });
29
- },
30
- children: messages.range(preset)
31
- }, messages.range(preset));
32
- })]
33
- });
34
- }
35
- function selected(picks, id) {
36
- const pick = picks[id];
37
- return typeof pick === "object" && pick !== null && "values" in pick ? pick.values : [];
38
- }
39
- const LOOKUP_LIMIT = 24;
40
- /** A control's own values, or for "lookup" the values its member has that this viewer can see. */
41
- function useValues(control) {
42
- const { client } = useDashboards();
43
- const scope = useContext(ScopeContext);
44
- const own = control.values;
45
- const draft = scope?.draft === true;
46
- const lookup = typeof own === "object" || scope === null ? null : [
47
- "dd-values",
48
- scope.dashboardId,
49
- control.id,
50
- draft
51
- ];
52
- const fetched = useSWR(lookup, () => client.controlValues({
53
- dashboardId: scope?.dashboardId ?? "",
54
- controlId: control.id,
55
- limit: LOOKUP_LIMIT,
56
- ...draft ? { draft: true } : {}
57
- }));
58
- return typeof own === "object" ? own : fetched.data?.values ?? [];
59
- }
60
- function FilterControl({ control, picks, onChange }) {
61
- const values = useValues(control);
62
- if (values.length === 0) return null;
63
- const chosen = selected(picks, control.id);
64
- const toggle = (value) => {
65
- const next = chosen.includes(value) ? chosen.filter((v) => v !== value) : control.multi ? [...chosen, value] : [value];
66
- const op = next.length > 1 ? "in" : "equals";
67
- onChange(next.length === 0 ? without(picks, control.id) : {
68
- ...picks,
69
- [control.id]: {
70
- op,
71
- values: next
72
- }
73
- });
74
- };
75
- return /* @__PURE__ */ jsxs("fieldset", {
76
- className: "dd-control",
77
- children: [/* @__PURE__ */ jsx("legend", {
78
- className: "dd-control-label",
79
- children: control.label
80
- }), values.map((value) => /* @__PURE__ */ jsx("button", {
81
- type: "button",
82
- className: "dd-chip",
83
- "aria-pressed": chosen.includes(value),
84
- onClick: () => {
85
- toggle(value);
86
- },
87
- children: String(value)
88
- }, String(value)))]
89
- });
90
- }
91
- /** The dashboard's controls as toggles. A viewer's choices are picks; the server checks each one. */
92
- function FilterBar({ controls, picks, onChange }) {
93
- const { messages } = useDashboards();
94
- if (controls.length === 0) return null;
95
- return /* @__PURE__ */ jsxs("div", {
96
- className: "dd-filters",
97
- children: [controls.map((control) => {
98
- if (control.kind === "date_range") return /* @__PURE__ */ jsx(DateRangeControl, {
99
- control,
100
- picks,
101
- onChange
102
- }, control.id);
103
- if (control.kind === "filter") return /* @__PURE__ */ jsx(FilterControl, {
104
- control,
105
- picks,
106
- onChange
107
- }, control.id);
108
- return null;
109
- }), Object.keys(picks).length === 0 ? null : /* @__PURE__ */ jsx("button", {
110
- type: "button",
111
- className: "dd-reset",
112
- onClick: () => {
113
- onChange({});
114
- },
115
- children: messages.reset
116
- })]
117
- });
118
- }
119
- export { FilterBar };
@@ -1,12 +0,0 @@
1
- import { Widget } from "derive-dashboards/core";
2
- type Props = {
3
- widgetId: string;
4
- widget: Widget;
5
- onClose: () => void;
6
- };
7
- /**
8
- * The rows behind a tile, in a modal dialog: the same tenant, policy, lock and filters as the
9
- * tile, a page at a time. Escape or Close closes it.
10
- */
11
- export declare function RecordsPanel({ widgetId, widget, onClose }: Props): import("react").JSX.Element;
12
- export {};
@@ -1,97 +0,0 @@
1
- import { useDashboards } from "./context.mjs";
2
- import { formatCell } from "./format.mjs";
3
- import { useDashboardScope } from "./scope.mjs";
4
- import { useEffect, useRef } from "react";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- import useSWRInfinite from "swr/infinite";
7
- // src/Records.tsx
8
- const PAGE = 50;
9
- /**
10
- * Pages of the rows behind a tile, fetched as the viewer asks for more: each after the last row
11
- * of the page before (its `next` cursor), so a deep page costs what the first does.
12
- */
13
- function usePages(widgetId) {
14
- const { client } = useDashboards();
15
- const { dashboardId, picks, draft } = useDashboardScope();
16
- return useSWRInfinite((index, previous) => index > 0 && previous?.next === void 0 ? null : [
17
- "dd-records",
18
- dashboardId,
19
- widgetId,
20
- picks,
21
- previous?.next ?? null,
22
- draft
23
- ], ([, , , , after]) => client.records({
24
- dashboardId,
25
- widgetId,
26
- picks,
27
- ...after === null ? {} : { after },
28
- limit: PAGE,
29
- ...draft === void 0 ? {} : { draft }
30
- }));
31
- }
32
- function RowsTable({ page, rows }) {
33
- const format = useDashboards();
34
- if (rows.length === 0) return /* @__PURE__ */ jsx("p", {
35
- className: "dd-tile-state",
36
- children: format.messages.noRows
37
- });
38
- return /* @__PURE__ */ jsx("div", {
39
- className: "dd-records-scroll",
40
- children: /* @__PURE__ */ jsxs("table", {
41
- className: "dd-table",
42
- children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: page.columns.map((c) => /* @__PURE__ */ jsx("th", {
43
- scope: "col",
44
- children: c.label
45
- }, c.member)) }) }), /* @__PURE__ */ jsx("tbody", { children: rows.map((row, i) => /* @__PURE__ */ jsx("tr", { children: row.map((cell, j) => /* @__PURE__ */ jsx("td", { children: formatCell(cell, page.columns[j], format) }, page.columns[j]?.member ?? j)) }, i)) })]
46
- })
47
- });
48
- }
49
- /**
50
- * The rows behind a tile, in a modal dialog: the same tenant, policy, lock and filters as the
51
- * tile, a page at a time. Escape or Close closes it.
52
- */
53
- function RecordsPanel({ widgetId, widget, onClose }) {
54
- const dialog = useRef(null);
55
- const pages = usePages(widgetId);
56
- const { messages } = useDashboards();
57
- useEffect(() => {
58
- dialog.current?.showModal();
59
- }, []);
60
- const first = pages.data?.[0];
61
- const more = pages.data?.at(-1)?.next !== void 0;
62
- return /* @__PURE__ */ jsxs("dialog", {
63
- ref: dialog,
64
- className: "dd-records",
65
- "aria-label": messages.rowsBehind(widget.title),
66
- onClose,
67
- children: [
68
- /* @__PURE__ */ jsxs("header", {
69
- className: "dd-records-header",
70
- children: [/* @__PURE__ */ jsx("h3", { children: widget.title }), /* @__PURE__ */ jsx("button", {
71
- type: "button",
72
- onClick: () => dialog.current?.close(),
73
- children: messages.close
74
- })]
75
- }),
76
- pages.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
77
- role: "alert",
78
- className: "dd-tile-error",
79
- children: messages.rowsFailed
80
- }),
81
- first === void 0 ? /* @__PURE__ */ jsx("p", {
82
- "aria-busy": "true",
83
- children: messages.loading
84
- }) : /* @__PURE__ */ jsx(RowsTable, {
85
- page: first,
86
- rows: (pages.data ?? []).flatMap((p) => p.rows)
87
- }),
88
- more ? /* @__PURE__ */ jsx("button", {
89
- type: "button",
90
- className: "dd-records-more",
91
- onClick: () => void pages.setSize(pages.size + 1),
92
- children: messages.showMore
93
- }) : null
94
- ]
95
- });
96
- }
97
- export { RecordsPanel };