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
@@ -10,11 +10,14 @@ export type PgQueryable = {
10
10
  rows: unknown[];
11
11
  }>;
12
12
  };
13
+ /** A pooled client: node-postgres gives its backend's `processID`, which a cancel names. */
14
+ type PgClient = PgQueryable & {
15
+ release(destroy?: boolean | Error): void;
16
+ processID?: number;
17
+ };
13
18
  /** What `nodePostgres` uses of a node-postgres `Pool`: `query`, and `connect` for a transaction. */
14
19
  export type PgPool = PgQueryable & {
15
- connect(): Promise<PgQueryable & {
16
- release(destroy?: boolean | Error): void;
17
- }>;
20
+ connect(): Promise<PgClient>;
18
21
  };
19
22
  /**
20
23
  * The query connection and the store for a node-postgres `Pool`, set up the safe way: each
@@ -30,4 +33,5 @@ export declare function nodePostgres(pool: PgPool, options?: {
30
33
  }): {
31
34
  connection: IntrospectingConnection;
32
35
  store: ReturnType<typeof postgresStore>;
33
- };
36
+ };
37
+ export {};
@@ -1,12 +1,35 @@
1
1
  import { postgresConnection } from "./postgres-connection.mjs";
2
2
  import { postgresStore } from "./postgres-store.mjs";
3
3
  // src/node-postgres.ts
4
+ /**
5
+ * Cancels the client's running statement from another connection when the request aborts, so
6
+ * a statement nobody waits for stops in the database and gives its connection back.
7
+ */
8
+ async function cancelling(pool, client, signal, work) {
9
+ const pid = "processID" in client && typeof client.processID === "number" ? client.processID : void 0;
10
+ if (signal === void 0 || pid === void 0) return work;
11
+ const cancel = () => {
12
+ pool.query({
13
+ text: "SELECT pg_cancel_backend($1)",
14
+ values: [pid]
15
+ }).catch(() => null);
16
+ };
17
+ signal.addEventListener("abort", cancel, { once: true });
18
+ try {
19
+ return await work;
20
+ } finally {
21
+ signal.removeEventListener("abort", cancel);
22
+ }
23
+ }
4
24
  /** Rows as arrays in select order, for queries; as objects by column, for the store. */
5
- const arrays = (client) => async (text, params) => (await client.query({
6
- text,
7
- values: [...params],
8
- rowMode: "array"
9
- })).rows;
25
+ const arrays = (client, pool) => async (text, params, options) => {
26
+ const work = client.query({
27
+ text,
28
+ values: [...params],
29
+ rowMode: "array"
30
+ });
31
+ return (pool === void 0 ? await work : await cancelling(pool, client, options?.signal, work)).rows;
32
+ };
10
33
  const objects = (client) => async (text, params) => (await client.query({
11
34
  text,
12
35
  values: [...params]
@@ -48,7 +71,7 @@ function nodePostgres(pool, options = {}) {
48
71
  ...options.id === void 0 ? {} : { id: options.id },
49
72
  run: arrays(pool),
50
73
  sendsBegin: true,
51
- transaction: (fn, begin) => inTransaction(pool, begin, (client) => fn(arrays(client)))
74
+ transaction: (fn, begin) => inTransaction(pool, begin, (client) => fn(arrays(client, pool)))
52
75
  }),
53
76
  store: postgresStore({
54
77
  run: objects(pool),
package/dist/owner.mjs CHANGED
@@ -5,8 +5,8 @@ import { principalTenant } from "derive-dashboards/core";
5
5
  // src/owner.ts
6
6
  /** Who made a stored dashboard, as `can` receives it. */
7
7
  const ownerOf = (row) => ({
8
- id: String(row["owner_id"]),
9
- kind: row["owner_kind"] === "agent" ? "agent" : "user"
8
+ id: String(row.owner_id),
9
+ kind: row.owner_kind === "agent" ? "agent" : "user"
10
10
  });
11
11
  /**
12
12
  * A dashboard as `can` sees it: its id, and who made it when it is stored, so a host's rule
@@ -21,7 +21,7 @@ async function dashboardResource(options, request, principal, id) {
21
21
  };
22
22
  const tenant = principalTenant(principal);
23
23
  const row = await requestDashboardRow(request, adapter, tenant, parseDashboardId(id));
24
- if (row === null || row["default_of"] !== null) return {
24
+ if (row === null || row.default_of !== null) return {
25
25
  kind: "dashboard",
26
26
  id
27
27
  };
@@ -1,6 +1,12 @@
1
1
  import { IntrospectingConnection } from "derive-dashboards/core";
2
- /** Runs one statement with its parameters and returns its rows as arrays, in select order. */
3
- export type RunSql = (text: string, params: readonly unknown[]) => Promise<readonly (readonly unknown[])[]>;
2
+ /**
3
+ * Runs one statement with its parameters and returns its rows as arrays, in select order.
4
+ * `signal` aborts when the request no longer wants the answer (the person moved on): a driver
5
+ * that can should cancel the statement in the database then (`nodePostgres` does).
6
+ */
7
+ export type RunSql = (text: string, params: readonly unknown[], options?: {
8
+ signal?: AbortSignal;
9
+ }) => Promise<readonly (readonly unknown[])[]>;
4
10
  export type PostgresConnectionOptions = {
5
11
  /** Defaults to "main". */
6
12
  id?: string;
@@ -40,7 +40,8 @@ function sessionOf(run, options, concurrent) {
40
40
  options.signal.throwIfAborted();
41
41
  if (Date.now() >= options.deadline) throw pastDeadline();
42
42
  try {
43
- return { rows: arrayRows(await bounded(run(sql.text, sql.params), options)) };
43
+ const rows = run(sql.text, sql.params, { signal: options.signal });
44
+ return { rows: arrayRows(await bounded(rows, options)) };
44
45
  } catch (error) {
45
46
  if (timedOut(error)) throw pastDeadline();
46
47
  if (badValue(error)) throw new HttpError(400, "QUERY_INVALID", "A value does not fit its column's type in the database. Check the viewer's tenant values against the tenant columns, and the query's filter values.", { cause: error });
@@ -55,6 +55,7 @@ function runner(options, run, depth) {
55
55
  * Its `dd_` tables come from `generate` in your own schema, or from `createTables`.
56
56
  */
57
57
  function postgresStore(options) {
58
+ for (const name of ["run", "transaction"]) if (typeof options[name] !== "function") throw new TypeError(`postgresStore needs ${name === "run" ? "a run (a statement to rows as objects)" : "a transaction (fn) => Promise, so every store write is one transaction"}. See docs/quick-start.md, step 4, or use nodePostgres(pool).`);
58
59
  return sqlAdapter("postgres", runner(options, options.run, 0));
59
60
  }
60
61
  export { postgresStore };
@@ -1,7 +1,7 @@
1
1
  import { useDashboards } from "./context.mjs";
2
- import { FilterBar } from "./FilterBar.mjs";
3
2
  import { Grid } from "./Grid.mjs";
4
3
  import { Header } from "./Header.mjs";
4
+ import { Span, sharedSpan, spanKey } from "./Tile.mjs";
5
5
  import { linkTo } from "./view.mjs";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  // src/Canvas.tsx
@@ -45,6 +45,29 @@ function EmptyTab({ onAdd }) {
45
45
  })]
46
46
  });
47
47
  }
48
+ /** The zone the server read the tiles in, from any answer's receipt: the host's default included. */
49
+ function answeredZone(results) {
50
+ for (const result of results.values()) if (!("error" in result)) return result.receipt.calendar.timezone;
51
+ }
52
+ /** The host's filter bar (the built-in one by default), told the zone dates are read in. */
53
+ function Filters({ board, doc }) {
54
+ const Bar = useDashboards().components.FilterBar;
55
+ return /* @__PURE__ */ jsx(Bar, {
56
+ controls: doc.controls,
57
+ picks: board.view.picks,
58
+ onChange: board.view.setPicks,
59
+ timezone: doc.scope.timezone ?? answeredZone(board.tiles.results)
60
+ });
61
+ }
62
+ /** The span most tiles cover, said once under the filters; the tiles that cover it leave it out. */
63
+ function DashboardSpan({ results }) {
64
+ const shared = sharedSpan(results);
65
+ const one = [...results.values()].find((result) => spanKey(result) === shared);
66
+ return shared === void 0 || one === void 0 ? null : /* @__PURE__ */ jsx("div", {
67
+ className: "dd-span-all",
68
+ children: /* @__PURE__ */ jsx(Span, { result: one })
69
+ });
70
+ }
48
71
  /** The canvas: header, tabs, filters, and the grid with its marks. */
49
72
  function Canvas(props) {
50
73
  const { board, shown } = props;
@@ -71,11 +94,11 @@ function Canvas(props) {
71
94
  current: shown.tab,
72
95
  onSelect: view.setTab
73
96
  }),
74
- /* @__PURE__ */ jsx(FilterBar, {
75
- controls: shown.doc.controls,
76
- picks: view.picks,
77
- onChange: view.setPicks
97
+ /* @__PURE__ */ jsx(Filters, {
98
+ board,
99
+ doc: shown.doc
78
100
  }),
101
+ /* @__PURE__ */ jsx(DashboardSpan, { results: board.tiles.results }),
79
102
  edit.draft === void 0 || !emptyTab(shown) ? null : /* @__PURE__ */ jsx(EmptyTab, { onAdd: add }),
80
103
  /* @__PURE__ */ jsx(Grid, {
81
104
  doc: shown.doc,
@@ -99,7 +99,8 @@ const Cell = memo(function Cell(props) {
99
99
  loading: props.loading,
100
100
  controlLabels: props.controlLabels,
101
101
  actions,
102
- badge
102
+ badge,
103
+ sharedSpan: props.sharedSpan
103
104
  })]
104
105
  });
105
106
  }, sameCell);
@@ -1,3 +1,5 @@
1
+ import { ViewChange } from "./view.mjs";
2
+ import { DashboardDrillProps } from "./drill/board.mjs";
1
3
  import { DashboardEvents } from "./useDashboard.mjs";
2
4
  import { ViewState } from "derive-dashboards/core";
3
5
  /**
@@ -7,10 +9,12 @@ import { ViewState } from "derive-dashboards/core";
7
9
  * changed tiles are marked in place. Review and publish opens the review beside the canvas:
8
10
  * every change, and over a newer version the merged result, then Publish. History opens the
9
11
  * timeline in the same panel; any version can be looked at in place, restored or copied.
10
- * Share copies a link with the tab and filters. An agent's proposal waits in a violet bar.
12
+ * Share copies a link with the tab, filters and drill. A click on a bar, a point, a table row
13
+ * or a number opens what is behind it beside the dashboard (`drill={false}` turns it off).
11
14
  *
12
- * `view` and `onViewChange` let the host keep the tab and filters in its URL (`encodeView`,
13
- * `decodeView`); `linkFor` makes the link Share copies. `editable={false}` shows it read-only.
15
+ * `view` and `onViewChange` let the host keep the tab, filters and drill in its URL
16
+ * (`encodeView`, `decodeView`); `linkFor` makes the link Share copies. `editable={false}` shows
17
+ * it read-only.
14
18
  */
15
19
  export type DashboardProps = {
16
20
  id: string;
@@ -18,10 +22,11 @@ export type DashboardProps = {
18
22
  editable?: boolean;
19
23
  /** The tab and filters to show, when the host keeps them (from a link, say). */
20
24
  view?: ViewState;
21
- onViewChange?: (view: ViewState) => void;
25
+ /** The view changed: `history` says whether Back should undo it (`push`, a drill step) or not. */
26
+ onViewChange?: (view: ViewState, change: ViewChange) => void;
22
27
  /** What the host's `decodeView` could not read from a link, so the page says it was left out. */
23
28
  linkDropped?: readonly string[];
24
29
  /** The link Share copies for a view; by default, this page's address with the view in it. */
25
30
  linkFor?: (view: ViewState) => string;
26
- } & DashboardEvents;
31
+ } & DashboardEvents & DashboardDrillProps;
27
32
  export declare function Dashboard(props: DashboardProps): import("react").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { Canvas } from "./Canvas.mjs";
2
2
  import { useDashboards } from "./context.mjs";
3
+ import { DrillScope } from "./drill/board.mjs";
3
4
  import { BuildPage } from "./Editing.mjs";
4
5
  import { Bars, Side } from "./Parts.mjs";
5
6
  import { ScopeContext } from "./scope.mjs";
@@ -13,20 +14,55 @@ function focusOpener(widgetId) {
13
14
  ((widgetId === void 0 ? null : document.querySelector(`.dd-cell[data-widget="${CSS.escape(widgetId)}"] .dd-tile-edit`)) ?? document.querySelector("[data-focus-after]"))?.focus();
14
15
  });
15
16
  }
17
+ /** The dashboard could not be read and there is nothing to show: say so, and offer to try again. */
18
+ function LoadFailed({ onRetry, failure }) {
19
+ const { messages } = useDashboards();
20
+ const refused = failure !== void 0 && failure.status >= 400 && failure.status < 500;
21
+ return /* @__PURE__ */ jsxs("div", {
22
+ className: "dd-tile-error",
23
+ role: "alert",
24
+ children: [
25
+ messages.dashboardFailed,
26
+ " ",
27
+ refused ? /* @__PURE__ */ jsxs("span", {
28
+ className: "dd-tile-note",
29
+ children: [
30
+ failure.message,
31
+ " (",
32
+ failure.code,
33
+ ")"
34
+ ]
35
+ }) : /* @__PURE__ */ jsx("button", {
36
+ type: "button",
37
+ className: "dd-button dd-quiet",
38
+ onClick: onRetry,
39
+ children: messages.drillRetry
40
+ })
41
+ ]
42
+ });
43
+ }
44
+ /** The dashboard stays while the server cannot be reached, and says so quietly. */
45
+ function Unreachable() {
46
+ const { messages } = useDashboards();
47
+ return /* @__PURE__ */ jsx("p", {
48
+ className: "dd-tile-note",
49
+ role: "status",
50
+ children: messages.dashboardUnreachable
51
+ });
52
+ }
16
53
  function Dashboard(props) {
17
54
  const { messages } = useDashboards();
18
55
  const board = useBoard(props);
19
56
  const [building, setBuilding] = useState();
20
57
  const [fresh, setFresh] = useState();
21
- const { error, edit, shown, panels, view } = board;
58
+ const { error, edit, shown, view } = board;
22
59
  if (board.missing) return /* @__PURE__ */ jsx("div", {
23
60
  className: "dd-tile-state",
24
61
  children: messages.dashboardMissing
25
62
  });
26
- if (error) return /* @__PURE__ */ jsx("div", {
27
- className: "dd-tile-error",
28
- role: "alert",
29
- children: messages.dashboardFailed
63
+ if (error) return /* @__PURE__ */ jsx(LoadFailed, {
64
+ onRetry: board.refresh,
65
+ failure: board.failure
30
66
  });
31
67
  if (shown?.tab === void 0) return /* @__PURE__ */ jsx("div", {
32
68
  className: "dd-dashboard",
@@ -51,25 +87,29 @@ function Dashboard(props) {
51
87
  picks: view.picks,
52
88
  ...editing ? { draft: true } : {}
53
89
  },
54
- children: /* @__PURE__ */ jsxs("div", {
55
- className: "dd-dashboard",
56
- "data-editing": editing,
57
- "data-panel": panels.panel !== void 0,
90
+ children: /* @__PURE__ */ jsxs(DrillScope, {
91
+ id: props.id,
92
+ board,
93
+ drill: props,
58
94
  children: [/* @__PURE__ */ jsxs("div", {
59
95
  className: "dd-board",
60
- children: [/* @__PURE__ */ jsx(Bars, {
61
- board,
62
- props
63
- }), /* @__PURE__ */ jsx(Canvas, {
64
- board,
65
- shown: {
66
- ...shown,
67
- tab
68
- },
69
- fresh,
70
- onBuild: setBuilding,
71
- dashboard: props
72
- })]
96
+ children: [
97
+ /* @__PURE__ */ jsx(Bars, {
98
+ board,
99
+ props
100
+ }),
101
+ board.unreachable ? /* @__PURE__ */ jsx(Unreachable, {}) : null,
102
+ /* @__PURE__ */ jsx(Canvas, {
103
+ board,
104
+ shown: {
105
+ ...shown,
106
+ tab
107
+ },
108
+ fresh,
109
+ onBuild: setBuilding,
110
+ dashboard: props
111
+ })
112
+ ]
73
113
  }), /* @__PURE__ */ jsx(Side, {
74
114
  board,
75
115
  props
@@ -1,4 +1,5 @@
1
1
  import { useDashboards } from "./context.mjs";
2
+ import { Row } from "./DashboardListRow.mjs";
2
3
  import { useId, useState } from "react";
3
4
  import useSWR from "swr";
4
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -73,32 +74,59 @@ function Search(props) {
73
74
  }) : null] });
74
75
  }
75
76
  /**
76
- * The dashboards, each a button named for the dashboard that opens it; the viewer's unpublished
77
- * ones say so, as the button's description rather than its name.
77
+ * The dashboards, each named for itself, its description and Draft as its description rather
78
+ * than its name. With `linkFor` each is a link and a published one has Copy link beside it.
78
79
  */
79
80
  function Items({ items, current, onOpen, linkFor }) {
80
81
  const { messages } = useDashboards();
81
82
  const base = useId();
82
- return /* @__PURE__ */ jsx("ul", { children: items.map((d, i) => /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsxs("button", {
83
- type: "button",
84
- "aria-label": d.title,
85
- "aria-describedby": d.unpublished === true ? `${base}-${String(i)}` : void 0,
86
- "aria-current": d.id === current ? "page" : void 0,
87
- onClick: () => {
88
- onOpen(d.id);
89
- },
90
- children: [/* @__PURE__ */ jsx("span", {
91
- className: "dd-list-name",
92
- children: d.title
93
- }), d.unpublished === true ? /* @__PURE__ */ jsx("em", {
83
+ return /* @__PURE__ */ jsx("ul", { children: items.map((d, i) => /* @__PURE__ */ jsxs("li", { children: [
84
+ /* @__PURE__ */ jsx(Row, {
85
+ d,
86
+ href: linkFor?.(d.id),
87
+ current: d.id === current,
88
+ describedBy: `${base}-${String(i)}`,
89
+ onOpen
90
+ }),
91
+ /* @__PURE__ */ jsx("span", {
92
+ hidden: true,
94
93
  id: `${base}-${String(i)}`,
95
- children: messages.unpublished
96
- }) : null]
97
- }), linkFor === void 0 || d.unpublished === true ? null : /* @__PURE__ */ jsx(CopyLink, {
98
- id: d.id,
99
- title: d.title,
100
- linkFor
101
- })] }, d.id)) });
94
+ children: [d.unpublished === true ? messages.unpublished : void 0, d.description].filter((part) => part !== void 0).join(". ")
95
+ }),
96
+ linkFor === void 0 || d.unpublished === true ? null : /* @__PURE__ */ jsx(CopyLink, {
97
+ id: d.id,
98
+ title: d.title,
99
+ linkFor
100
+ })
101
+ ] }, d.id)) });
102
+ }
103
+ /**
104
+ * The built-in dashboards (`default:` ids) first, under a heading, then the ones made here, when
105
+ * the list has both; otherwise one plain list.
106
+ */
107
+ function Groups(props) {
108
+ const { messages } = useDashboards();
109
+ const builtIn = props.items.filter((d) => d.id.startsWith("default:"));
110
+ const made = props.items.filter((d) => !d.id.startsWith("default:"));
111
+ if (builtIn.length === 0 || made.length === 0) return /* @__PURE__ */ jsx(Items, { ...props });
112
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
113
+ /* @__PURE__ */ jsx("h3", {
114
+ className: "dd-list-group",
115
+ children: messages.builtIn
116
+ }),
117
+ /* @__PURE__ */ jsx(Items, {
118
+ ...props,
119
+ items: builtIn
120
+ }),
121
+ /* @__PURE__ */ jsx("h3", {
122
+ className: "dd-list-group",
123
+ children: messages.madeHere
124
+ }),
125
+ /* @__PURE__ */ jsx(Items, {
126
+ ...props,
127
+ items: made
128
+ })
129
+ ] });
102
130
  }
103
131
  /**
104
132
  * Every dashboard the viewer can open, theirs not yet published marked as drafts, and
@@ -112,7 +140,7 @@ function DashboardList({ current, onOpen, linkFor }) {
112
140
  const [search, setSearch] = useState("");
113
141
  const all = list.data?.dashboards ?? [];
114
142
  const words = search.trim().toLocaleLowerCase();
115
- const shown = words === "" ? all : all.filter((d) => d.title.toLocaleLowerCase().includes(words));
143
+ const shown = words === "" ? all : all.filter((d) => `${d.title} ${d.description ?? ""}`.toLocaleLowerCase().includes(words));
116
144
  const { making, error, create } = useCreate(onOpen, async () => {
117
145
  await list.mutate();
118
146
  });
@@ -132,7 +160,7 @@ function DashboardList({ current, onOpen, linkFor }) {
132
160
  role: "alert",
133
161
  children: error
134
162
  }),
135
- list.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
163
+ list.error === void 0 || list.data !== void 0 ? null : /* @__PURE__ */ jsx("p", {
136
164
  className: "dd-draft-error",
137
165
  role: "alert",
138
166
  children: messages.listFailed
@@ -143,7 +171,7 @@ function DashboardList({ current, onOpen, linkFor }) {
143
171
  setSearch,
144
172
  shown: shown.length
145
173
  }),
146
- /* @__PURE__ */ jsx(Items, {
174
+ /* @__PURE__ */ jsx(Groups, {
147
175
  items: shown,
148
176
  current,
149
177
  onOpen,
@@ -0,0 +1,49 @@
1
+ import { useDashboards } from "./context.mjs";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ // src/DashboardListRow.tsx
4
+ /** A click a link would follow itself: a modified or middle click opens a new tab as usual. */
5
+ const plainClick = (event) => event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
6
+ /**
7
+ * One row: the dashboard's name, Draft for the viewer's unpublished one, and its description.
8
+ * With `href` it is a link, so Cmd-click and middle-click open a new tab while a plain click
9
+ * still goes to `onOpen`; without one it is a button. Draft and the description describe the
10
+ * row; its name stays the dashboard's.
11
+ */
12
+ function Row(props) {
13
+ const { d, href, describedBy, onOpen } = props;
14
+ const { messages } = useDashboards();
15
+ const shared = {
16
+ className: "dd-list-open",
17
+ "aria-label": d.title,
18
+ "aria-describedby": d.unpublished === true || d.description !== void 0 ? describedBy : void 0,
19
+ "aria-current": props.current ? "page" : void 0
20
+ };
21
+ const body = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
22
+ className: "dd-list-name",
23
+ children: [/* @__PURE__ */ jsx("span", {
24
+ className: "dd-list-title",
25
+ children: d.title
26
+ }), d.unpublished === true ? /* @__PURE__ */ jsx("em", { children: messages.unpublished }) : null]
27
+ }), d.description === void 0 ? null : /* @__PURE__ */ jsx("span", {
28
+ className: "dd-list-desc",
29
+ children: d.description
30
+ })] });
31
+ return href === void 0 ? /* @__PURE__ */ jsx("button", {
32
+ type: "button",
33
+ ...shared,
34
+ onClick: () => {
35
+ onOpen(d.id);
36
+ },
37
+ children: body
38
+ }) : /* @__PURE__ */ jsx("a", {
39
+ href,
40
+ ...shared,
41
+ onClick: (event) => {
42
+ if (event.defaultPrevented || !plainClick(event)) return;
43
+ event.preventDefault();
44
+ onOpen(d.id);
45
+ },
46
+ children: body
47
+ });
48
+ }
49
+ export { Row };
@@ -1,6 +1,6 @@
1
1
  import { useDashboards } from "./context.mjs";
2
2
  import { isShifted } from "./marks.mjs";
3
- import { useEffect, useRef, useState } from "react";
3
+ import { useEffect, useId, useRef, useState } from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  // src/Discard.tsx
6
6
  /**
@@ -21,15 +21,18 @@ function DiscardButton({ edit, isNew = false }) {
21
21
  answered.current = !on;
22
22
  setAsking(on);
23
23
  };
24
+ const untouched = !isNew && (edit.draft?.changes.filter((c) => !isShifted(c)).length ?? 0) === 0;
24
25
  if (!asking) return /* @__PURE__ */ jsx("button", {
25
26
  ref: discard,
26
27
  type: "button",
27
28
  className: "dd-button dd-quiet",
28
29
  "aria-disabled": edit.busy,
29
30
  onClick: () => {
30
- if (!edit.busy) ask(true);
31
+ if (edit.busy) return;
32
+ if (untouched) edit.discard();
33
+ else ask(true);
31
34
  },
32
- children: messages.discard
35
+ children: untouched ? messages.doneEditing : messages.discard
33
36
  });
34
37
  return /* @__PURE__ */ jsx(DiscardAsk, {
35
38
  edit,
@@ -69,14 +72,19 @@ function DiscardAsk(props) {
69
72
  const { messages } = useDashboards();
70
73
  const { edit, isNew, onKeep } = props;
71
74
  useEscape(onKeep);
75
+ const question = useId();
72
76
  return /* @__PURE__ */ jsxs("span", {
73
77
  className: "dd-row",
74
78
  children: [
75
- /* @__PURE__ */ jsx("span", { children: isNew ? messages.deleteNewAsk : messages.discardAsk(edit.draft?.changes.filter((c) => !isShifted(c)).length ?? 0) }),
79
+ /* @__PURE__ */ jsx("span", {
80
+ id: question,
81
+ children: isNew ? messages.deleteNewAsk : messages.discardAsk(edit.draft?.changes.filter((c) => !isShifted(c)).length ?? 0)
82
+ }),
76
83
  /* @__PURE__ */ jsx("button", {
77
84
  ref: props.keep,
78
85
  type: "button",
79
86
  className: "dd-button dd-quiet",
87
+ "aria-describedby": question,
80
88
  onClick: props.onKeep,
81
89
  children: messages.keepEditing
82
90
  }),
@@ -81,14 +81,14 @@ function saveCommands(doc, tab, widget, widgetId) {
81
81
  at: placeFor(tab, widget)
82
82
  }];
83
83
  const before = doc.widgets[widgetId];
84
- const query = widget.queries["main"];
84
+ const query = widget.queries.main;
85
85
  return [{
86
86
  type: "widget.update",
87
87
  id: widgetId,
88
88
  title: widget.title,
89
89
  kind: widget.kind,
90
90
  ...widget.display === void 0 ? {} : { display: widget.display }
91
- }, ...query === void 0 || before?.queries["main"] === query ? [] : [{
91
+ }, ...query === void 0 || before?.queries.main === query ? [] : [{
92
92
  type: "widget.setQuery",
93
93
  id: widgetId,
94
94
  name: "main",
@@ -103,6 +103,22 @@ function BuildPage({ doc, tab, edit, widgetId, onDone }) {
103
103
  const { messages } = useDashboards();
104
104
  const [id] = useState(() => widgetId ?? `w${crypto.randomUUID().slice(0, 8)}`);
105
105
  const initial = widgetId === void 0 ? void 0 : doc.widgets[widgetId];
106
+ const cancel = () => {
107
+ onDone();
108
+ };
109
+ if (initial !== void 0 && initial.queries["main"] === void 0) return /* @__PURE__ */ jsxs("div", {
110
+ className: "dd-builder",
111
+ children: [/* @__PURE__ */ jsxs("button", {
112
+ type: "button",
113
+ className: "dd-back",
114
+ onClick: cancel,
115
+ children: ["‹ ", doc.meta.title]
116
+ }), /* @__PURE__ */ jsx("p", {
117
+ className: "dd-builder-error",
118
+ role: "alert",
119
+ children: messages.noMainQuery(initial.title)
120
+ })]
121
+ });
106
122
  return /* @__PURE__ */ jsx(WidgetBuilder, {
107
123
  ...initial === void 0 ? {} : { initial },
108
124
  backLabel: doc.meta.title,
@@ -110,9 +126,7 @@ function BuildPage({ doc, tab, edit, widgetId, onDone }) {
110
126
  saveLabel: widgetId === void 0 ? messages.addToDashboard : messages.save,
111
127
  saving: edit.busy,
112
128
  ...edit.error === void 0 ? {} : { error: edit.error },
113
- onCancel: () => {
114
- onDone();
115
- },
129
+ onCancel: cancel,
116
130
  onSave: (widget) => {
117
131
  const save = async () => {
118
132
  if (await edit.apply(saveCommands(doc, tab, widget, id))) onDone(id);
@@ -1,9 +1,7 @@
1
- import { Control, Picks } from "derive-dashboards/core";
2
- type Props = {
3
- controls: readonly Control[];
4
- picks: Picks;
5
- onChange: (picks: Picks) => void;
6
- };
7
- /** The dashboard's controls as toggles. A viewer's choices are picks; the server checks each one. */
8
- export declare function FilterBar({ controls, picks, onChange }: Props): import("react").JSX.Element | null;
9
- export {};
1
+ import { ENGLISH_FILTERS, FilterWords } from "./filters/words.mjs";
2
+ import { FilterBar } from "./filters/bar.mjs";
3
+ import { FilterBarOptions, FilterIcon } from "./filters/context.mjs";
4
+ import { FilterBarProps, fieldOf, useControlValues, useFilterFields } from "./filters/hooks.mjs";
5
+ import { Popover } from "./filters/popover.mjs";
6
+ import { rules_d_exports } from "./filters/rules.mjs";
7
+ export { ENGLISH_FILTERS, FilterBar, type FilterBarOptions, type FilterBarProps, type FilterIcon, type FilterWords, Popover, fieldOf, rules_d_exports as filterRules, useControlValues, useFilterFields };