derive-dashboards 0.0.0-stage → 0.1.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 (530) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -2
  3. package/dist/adapter/sql-adapter.mjs +80 -0
  4. package/dist/adapter/statement.mjs +140 -0
  5. package/dist/authorize.mjs +55 -0
  6. package/dist/body.mjs +164 -0
  7. package/dist/bounded.mjs +31 -0
  8. package/dist/cache.d.mts +21 -0
  9. package/dist/cache.mjs +138 -0
  10. package/dist/checks.mjs +98 -0
  11. package/dist/cli/bin.d.mts +1 -0
  12. package/dist/cli/bin.mjs +13 -0
  13. package/dist/cli/check.mjs +52 -0
  14. package/dist/cli/cli.d.mts +5 -0
  15. package/dist/cli/cli.mjs +144 -0
  16. package/dist/cli/config.d.mts +21 -0
  17. package/dist/cli/config.mjs +14 -0
  18. package/dist/cli/conformance.mjs +34 -0
  19. package/dist/cli/import/build.mjs +118 -0
  20. package/dist/cli/import/catalog.mjs +42 -0
  21. package/dist/cli/import/cube-schema.mjs +51 -0
  22. package/dist/cli/import/cube-sql.mjs +52 -0
  23. package/dist/cli/import/cube.mjs +172 -0
  24. package/dist/cli/import/dbt-metrics.mjs +76 -0
  25. package/dist/cli/import/dbt-schema.mjs +82 -0
  26. package/dist/cli/import/dbt.mjs +154 -0
  27. package/dist/cli/import/draft.mjs +46 -0
  28. package/dist/cli/import/index.mjs +71 -0
  29. package/dist/cli/import/storage.mjs +92 -0
  30. package/dist/cli/import/tenancy.mjs +76 -0
  31. package/dist/cli/index.d.mts +6 -0
  32. package/dist/cli/index.mjs +5 -0
  33. package/dist/cli/init.mjs +72 -0
  34. package/dist/cli/io.d.mts +6 -0
  35. package/dist/cli/load.mjs +18 -0
  36. package/dist/cli/propose.d.mts +13 -0
  37. package/dist/cli/propose.mjs +215 -0
  38. package/dist/cli/render.d.mts +14 -0
  39. package/dist/cli/render.mjs +106 -0
  40. package/dist/core/conformance/cases.d.mts +12 -0
  41. package/dist/core/conformance/cases.mjs +82 -0
  42. package/dist/core/conformance/check.d.mts +33 -0
  43. package/dist/core/conformance/check.mjs +81 -0
  44. package/dist/core/conformance/dataset-model.mjs +306 -0
  45. package/dist/core/conformance/dataset-rows.mjs +246 -0
  46. package/dist/core/conformance/dataset.d.mts +381 -0
  47. package/dist/core/conformance/dataset.mjs +58 -0
  48. package/dist/core/conformance/index.d.mts +10 -0
  49. package/dist/core/conformance/index.mjs +9 -0
  50. package/dist/core/conformance/memory/aggregate.mjs +76 -0
  51. package/dist/core/conformance/memory/rows.d.mts +10 -0
  52. package/dist/core/conformance/memory/rows.mjs +98 -0
  53. package/dist/core/conformance/memory/source.d.mts +4 -0
  54. package/dist/core/conformance/memory/source.mjs +129 -0
  55. package/dist/core/conformance/queries.mjs +108 -0
  56. package/dist/core/conformance/records-cases.mjs +68 -0
  57. package/dist/core/document/diff.d.mts +68 -0
  58. package/dist/core/document/diff.mjs +155 -0
  59. package/dist/core/document/layout.d.mts +51 -0
  60. package/dist/core/document/layout.mjs +228 -0
  61. package/dist/core/document/outcome.d.mts +10 -0
  62. package/dist/core/document/outcome.mjs +14 -0
  63. package/dist/core/document/reduce.d.mts +16 -0
  64. package/dist/core/document/reduce.mjs +191 -0
  65. package/dist/core/document/replay.d.mts +28 -0
  66. package/dist/core/document/replay.mjs +38 -0
  67. package/dist/core/document/stacked.d.mts +14 -0
  68. package/dist/core/document/stacked.mjs +70 -0
  69. package/dist/core/document/tabs.mjs +70 -0
  70. package/dist/core/document/types.d.mts +138 -0
  71. package/dist/core/document/types.mjs +16 -0
  72. package/dist/core/document/upgrade.d.mts +25 -0
  73. package/dist/core/document/upgrade.mjs +49 -0
  74. package/dist/core/document/view.d.mts +30 -0
  75. package/dist/core/document/view.mjs +50 -0
  76. package/dist/core/engine/access.mjs +113 -0
  77. package/dist/core/engine/assert.d.mts +21 -0
  78. package/dist/core/engine/assert.mjs +132 -0
  79. package/dist/core/engine/bucket.mjs +52 -0
  80. package/dist/core/engine/build.mjs +71 -0
  81. package/dist/core/engine/checks.mjs +29 -0
  82. package/dist/core/engine/context.mjs +46 -0
  83. package/dist/core/engine/cursor.mjs +30 -0
  84. package/dist/core/engine/custom/ask.mjs +13 -0
  85. package/dist/core/engine/custom/cells.mjs +80 -0
  86. package/dist/core/engine/custom/fields.mjs +130 -0
  87. package/dist/core/engine/custom/level.mjs +136 -0
  88. package/dist/core/engine/custom/measures.mjs +146 -0
  89. package/dist/core/engine/custom/query.mjs +37 -0
  90. package/dist/core/engine/custom/reader.d.mts +7 -0
  91. package/dist/core/engine/custom/reader.mjs +67 -0
  92. package/dist/core/engine/custom/records.mjs +51 -0
  93. package/dist/core/engine/custom/request.d.mts +283 -0
  94. package/dist/core/engine/custom/seen.mjs +79 -0
  95. package/dist/core/engine/custom/where.mjs +34 -0
  96. package/dist/core/engine/dialect.d.mts +54 -0
  97. package/dist/core/engine/filter.mjs +129 -0
  98. package/dist/core/engine/index.d.mts +16 -0
  99. package/dist/core/engine/index.mjs +9 -0
  100. package/dist/core/engine/leaf.mjs +141 -0
  101. package/dist/core/engine/levels.mjs +175 -0
  102. package/dist/core/engine/measure.mjs +81 -0
  103. package/dist/core/engine/members.mjs +149 -0
  104. package/dist/core/engine/nan.mjs +9 -0
  105. package/dist/core/engine/native.mjs +59 -0
  106. package/dist/core/engine/numbers.mjs +191 -0
  107. package/dist/core/engine/other.mjs +45 -0
  108. package/dist/core/engine/plan.d.mts +54 -0
  109. package/dist/core/engine/postgres.d.mts +6 -0
  110. package/dist/core/engine/postgres.mjs +136 -0
  111. package/dist/core/engine/prepare.mjs +133 -0
  112. package/dist/core/engine/rank-sets.mjs +119 -0
  113. package/dist/core/engine/rank.mjs +149 -0
  114. package/dist/core/engine/read.mjs +74 -0
  115. package/dist/core/engine/reader.d.mts +128 -0
  116. package/dist/core/engine/reader.mjs +18 -0
  117. package/dist/core/engine/record-layout.d.mts +10 -0
  118. package/dist/core/engine/record-layout.mjs +37 -0
  119. package/dist/core/engine/records.d.mts +14 -0
  120. package/dist/core/engine/records.mjs +51 -0
  121. package/dist/core/engine/refs.mjs +58 -0
  122. package/dist/core/engine/run.d.mts +3 -0
  123. package/dist/core/engine/run.mjs +102 -0
  124. package/dist/core/engine/segmented.d.mts +11 -0
  125. package/dist/core/engine/segmented.mjs +80 -0
  126. package/dist/core/engine/series.mjs +95 -0
  127. package/dist/core/engine/shape.d.mts +12 -0
  128. package/dist/core/engine/shape.mjs +92 -0
  129. package/dist/core/engine/sql-marked.mjs +77 -0
  130. package/dist/core/engine/sql-pass.mjs +24 -0
  131. package/dist/core/engine/sql-reader.d.mts +10 -0
  132. package/dist/core/engine/sql-reader.mjs +51 -0
  133. package/dist/core/engine/sql-reads.mjs +28 -0
  134. package/dist/core/engine/sql-records.mjs +100 -0
  135. package/dist/core/engine/sql-split.mjs +158 -0
  136. package/dist/core/engine/sql.d.mts +8 -0
  137. package/dist/core/engine/sql.mjs +33 -0
  138. package/dist/core/engine/statement.mjs +78 -0
  139. package/dist/core/engine/time.mjs +52 -0
  140. package/dist/core/engine/two-step.mjs +104 -0
  141. package/dist/core/engine/types.d.mts +55 -0
  142. package/dist/core/engine/version.d.mts +7 -0
  143. package/dist/core/engine/version.mjs +9 -0
  144. package/dist/core/error/codes.d.mts +154 -0
  145. package/dist/core/error/codes.mjs +127 -0
  146. package/dist/core/error/refusal.d.mts +8 -0
  147. package/dist/core/error/refusal.mjs +11 -0
  148. package/dist/core/exact/decimal.d.mts +22 -0
  149. package/dist/core/exact/decimal.mjs +51 -0
  150. package/dist/core/exact/sum.d.mts +17 -0
  151. package/dist/core/exact/sum.mjs +31 -0
  152. package/dist/core/index.d.mts +56 -0
  153. package/dist/core/index.mjs +45 -0
  154. package/dist/core/model/catalog/check.d.mts +10 -0
  155. package/dist/core/model/catalog/check.mjs +141 -0
  156. package/dist/core/model/catalog/columns.mjs +34 -0
  157. package/dist/core/model/catalog/queries.d.mts +12 -0
  158. package/dist/core/model/catalog/queries.mjs +50 -0
  159. package/dist/core/model/defaults.d.mts +3 -0
  160. package/dist/core/model/defaults.mjs +24 -0
  161. package/dist/core/model/define.d.mts +32 -0
  162. package/dist/core/model/define.mjs +21 -0
  163. package/dist/core/model/member.d.mts +26 -0
  164. package/dist/core/model/member.mjs +58 -0
  165. package/dist/core/model/storage.mjs +28 -0
  166. package/dist/core/model/types.d.mts +270 -0
  167. package/dist/core/model/types.mjs +9 -0
  168. package/dist/core/model/validate/expr.d.mts +10 -0
  169. package/dist/core/model/validate/expr.mjs +56 -0
  170. package/dist/core/model/validate/filter.mjs +28 -0
  171. package/dist/core/model/validate/index.d.mts +10 -0
  172. package/dist/core/model/validate/index.mjs +36 -0
  173. package/dist/core/model/validate/issues.mjs +17 -0
  174. package/dist/core/model/validate/members.mjs +98 -0
  175. package/dist/core/model/validate/policy.mjs +76 -0
  176. package/dist/core/model/validate/source.mjs +143 -0
  177. package/dist/core/model/validate/via.d.mts +4 -0
  178. package/dist/core/model/validate/via.mjs +47 -0
  179. package/dist/core/oracle/data.d.mts +37 -0
  180. package/dist/core/oracle/data.mjs +30 -0
  181. package/dist/core/oracle/evaluate.d.mts +23 -0
  182. package/dist/core/oracle/evaluate.mjs +117 -0
  183. package/dist/core/oracle/expr.mjs +74 -0
  184. package/dist/core/oracle/facts.mjs +72 -0
  185. package/dist/core/oracle/filter.d.mts +6 -0
  186. package/dist/core/oracle/filter.mjs +25 -0
  187. package/dist/core/oracle/groups.mjs +33 -0
  188. package/dist/core/oracle/index.d.mts +4 -0
  189. package/dist/core/oracle/index.mjs +3 -0
  190. package/dist/core/oracle/levels.mjs +46 -0
  191. package/dist/core/oracle/logic.mjs +38 -0
  192. package/dist/core/oracle/measure.mjs +85 -0
  193. package/dist/core/oracle/members.mjs +80 -0
  194. package/dist/core/oracle/request.mjs +38 -0
  195. package/dist/core/oracle/segmented.d.mts +7 -0
  196. package/dist/core/oracle/segmented.mjs +35 -0
  197. package/dist/core/oracle/split.mjs +84 -0
  198. package/dist/core/oracle/time-axis.mjs +37 -0
  199. package/dist/core/oracle/time-value.mjs +28 -0
  200. package/dist/core/oracle/tree.mjs +24 -0
  201. package/dist/core/oracle/values.mjs +41 -0
  202. package/dist/core/oracle/visibility.mjs +49 -0
  203. package/dist/core/policy/bind.d.mts +25 -0
  204. package/dist/core/policy/bind.mjs +64 -0
  205. package/dist/core/policy/match.d.mts +16 -0
  206. package/dist/core/policy/match.mjs +44 -0
  207. package/dist/core/query/alias.mjs +14 -0
  208. package/dist/core/query/closure.d.mts +17 -0
  209. package/dist/core/query/closure.mjs +131 -0
  210. package/dist/core/query/compose-tile.d.mts +50 -0
  211. package/dist/core/query/compose-tile.mjs +140 -0
  212. package/dist/core/query/compose.d.mts +105 -0
  213. package/dist/core/query/compose.mjs +12 -0
  214. package/dist/core/query/derived-rules.mjs +56 -0
  215. package/dist/core/query/effective.d.mts +32 -0
  216. package/dist/core/query/effective.mjs +22 -0
  217. package/dist/core/query/filter.d.mts +99 -0
  218. package/dist/core/query/filter.mjs +79 -0
  219. package/dist/core/query/formulas.d.mts +17 -0
  220. package/dist/core/query/formulas.mjs +52 -0
  221. package/dist/core/query/picks.d.mts +10 -0
  222. package/dist/core/query/picks.mjs +25 -0
  223. package/dist/core/query/segments.d.mts +6 -0
  224. package/dist/core/query/segments.mjs +182 -0
  225. package/dist/core/query/to-wire.d.mts +21 -0
  226. package/dist/core/query/to-wire.mjs +124 -0
  227. package/dist/core/query/types.d.mts +238 -0
  228. package/dist/core/result/calc.mjs +95 -0
  229. package/dist/core/result/columns.d.mts +13 -0
  230. package/dist/core/result/columns.mjs +118 -0
  231. package/dist/core/result/marks.d.mts +20 -0
  232. package/dist/core/result/marks.mjs +35 -0
  233. package/dist/core/result/number.mjs +78 -0
  234. package/dist/core/result/order.d.mts +2 -0
  235. package/dist/core/result/order.mjs +57 -0
  236. package/dist/core/result/types.d.mts +66 -0
  237. package/dist/core/result/zero.mjs +18 -0
  238. package/dist/core/schema/answers.d.mts +2071 -0
  239. package/dist/core/schema/answers.mjs +217 -0
  240. package/dist/core/schema/commands.d.mts +273 -0
  241. package/dist/core/schema/commands.mjs +129 -0
  242. package/dist/core/schema/custom.d.mts +13 -0
  243. package/dist/core/schema/custom.mjs +250 -0
  244. package/dist/core/schema/document.d.mts +149 -0
  245. package/dist/core/schema/document.mjs +216 -0
  246. package/dist/core/schema/editing.mjs +166 -0
  247. package/dist/core/schema/index.d.mts +9 -0
  248. package/dist/core/schema/index.mjs +9 -0
  249. package/dist/core/schema/issue.mjs +18 -0
  250. package/dist/core/schema/query.d.mts +92 -0
  251. package/dist/core/schema/query.mjs +174 -0
  252. package/dist/core/schema/tools.d.mts +17 -0
  253. package/dist/core/schema/tools.mjs +62 -0
  254. package/dist/core/schema/view.d.mts +47 -0
  255. package/dist/core/schema/view.mjs +71 -0
  256. package/dist/core/store/ddl.d.mts +38 -0
  257. package/dist/core/store/ddl.mjs +79 -0
  258. package/dist/core/store/schema.d.mts +315 -0
  259. package/dist/core/store/schema.mjs +181 -0
  260. package/dist/core/time/bucket.d.mts +25 -0
  261. package/dist/core/time/bucket.mjs +103 -0
  262. package/dist/core/time/compare.d.mts +30 -0
  263. package/dist/core/time/compare.mjs +73 -0
  264. package/dist/core/time/index.d.mts +7 -0
  265. package/dist/core/time/instant.d.mts +14 -0
  266. package/dist/core/time/instant.mjs +58 -0
  267. package/dist/core/time/range.d.mts +21 -0
  268. package/dist/core/time/range.mjs +41 -0
  269. package/dist/core/time/stored.d.mts +10 -0
  270. package/dist/core/time/stored.mjs +29 -0
  271. package/dist/core/time/temporal.d.mts +14 -0
  272. package/dist/core/time/temporal.mjs +27 -0
  273. package/dist/core/time/zone.d.mts +27 -0
  274. package/dist/core/time/zone.mjs +55 -0
  275. package/dist/core/types/api.d.mts +327 -0
  276. package/dist/core/types/api.mjs +9 -0
  277. package/dist/core/types/infer.d.mts +91 -0
  278. package/dist/core/types/options.d.mts +94 -0
  279. package/dist/core/types/plugin.d.mts +82 -0
  280. package/dist/core/types/plugin.mjs +12 -0
  281. package/dist/core/types/primitives.d.mts +26 -0
  282. package/dist/core/types/provider.d.mts +74 -0
  283. package/dist/core/types/source.d.mts +73 -0
  284. package/dist/core/types/store.d.mts +327 -0
  285. package/dist/core/types/viewer.d.mts +74 -0
  286. package/dist/core/types/viewer.mjs +6 -0
  287. package/dist/core/value/canonical.d.mts +5 -0
  288. package/dist/core/value/canonical.mjs +10 -0
  289. package/dist/core/value/casefold-data.mjs +3 -0
  290. package/dist/core/value/casefold.d.mts +8 -0
  291. package/dist/core/value/casefold.mjs +36 -0
  292. package/dist/core/value/compare.d.mts +3 -0
  293. package/dist/core/value/compare.mjs +18 -0
  294. package/dist/custom-source.d.mts +21 -0
  295. package/dist/custom-source.mjs +30 -0
  296. package/dist/dashboard-id.mjs +31 -0
  297. package/dist/dashboards.mjs +84 -0
  298. package/dist/editing.mjs +114 -0
  299. package/dist/endpoints/access.mjs +44 -0
  300. package/dist/endpoints/dashboards.mjs +109 -0
  301. package/dist/endpoints/drafts.mjs +138 -0
  302. package/dist/endpoints/index.d.mts +453 -0
  303. package/dist/endpoints/index.mjs +39 -0
  304. package/dist/endpoints/meta.mjs +123 -0
  305. package/dist/endpoints/query.mjs +72 -0
  306. package/dist/endpoints/read.mjs +79 -0
  307. package/dist/endpoints/review.mjs +91 -0
  308. package/dist/endpoints/values.mjs +58 -0
  309. package/dist/endpoints/versions.mjs +103 -0
  310. package/dist/execute.d.mts +10 -0
  311. package/dist/execute.mjs +152 -0
  312. package/dist/handler.mjs +189 -0
  313. package/dist/http.d.mts +16 -0
  314. package/dist/http.mjs +67 -0
  315. package/dist/index.d.mts +24 -0
  316. package/dist/index.mjs +115 -0
  317. package/dist/introspect.mjs +180 -0
  318. package/dist/mcp/api.d.mts +10 -0
  319. package/dist/mcp/api.mjs +34 -0
  320. package/dist/mcp/format.d.mts +10 -0
  321. package/dist/mcp/format.mjs +59 -0
  322. package/dist/mcp/index.d.mts +61 -0
  323. package/dist/mcp/index.mjs +88 -0
  324. package/dist/mcp/query.d.mts +6 -0
  325. package/dist/mcp/query.mjs +123 -0
  326. package/dist/mcp/resolve.mjs +67 -0
  327. package/dist/node-postgres.d.mts +33 -0
  328. package/dist/node-postgres.mjs +59 -0
  329. package/dist/owner.mjs +34 -0
  330. package/dist/postgres-connection.d.mts +33 -0
  331. package/dist/postgres-connection.mjs +84 -0
  332. package/dist/postgres-store.d.mts +38 -0
  333. package/dist/postgres-store.mjs +60 -0
  334. package/dist/principal.mjs +28 -0
  335. package/dist/react/CancelRestore.mjs +21 -0
  336. package/dist/react/Canvas.mjs +97 -0
  337. package/dist/react/Cell.mjs +106 -0
  338. package/dist/react/ConfirmButton.mjs +31 -0
  339. package/dist/react/Dashboard.d.mts +27 -0
  340. package/dist/react/Dashboard.mjs +80 -0
  341. package/dist/react/DashboardList.d.mts +12 -0
  342. package/dist/react/DashboardList.mjs +155 -0
  343. package/dist/react/Discard.mjs +99 -0
  344. package/dist/react/EditBar.d.mts +16 -0
  345. package/dist/react/EditBar.mjs +141 -0
  346. package/dist/react/Editing.mjs +124 -0
  347. package/dist/react/FilterBar.d.mts +9 -0
  348. package/dist/react/FilterBar.mjs +119 -0
  349. package/dist/react/Grid.mjs +133 -0
  350. package/dist/react/Header.mjs +107 -0
  351. package/dist/react/History.d.mts +30 -0
  352. package/dist/react/History.mjs +202 -0
  353. package/dist/react/Notice.d.mts +8 -0
  354. package/dist/react/Notice.mjs +51 -0
  355. package/dist/react/Overlaps.mjs +54 -0
  356. package/dist/react/Panel.d.mts +16 -0
  357. package/dist/react/Panel.mjs +93 -0
  358. package/dist/react/Parts.mjs +98 -0
  359. package/dist/react/Records.d.mts +12 -0
  360. package/dist/react/Records.mjs +97 -0
  361. package/dist/react/ReviewPanel.d.mts +15 -0
  362. package/dist/react/ReviewPanel.mjs +200 -0
  363. package/dist/react/Spaces.mjs +108 -0
  364. package/dist/react/Tile.d.mts +20 -0
  365. package/dist/react/Tile.mjs +123 -0
  366. package/dist/react/arrange-steps.mjs +108 -0
  367. package/dist/react/arrange.mjs +135 -0
  368. package/dist/react/board.d.mts +16 -0
  369. package/dist/react/board.mjs +156 -0
  370. package/dist/react/builder/Calcs.mjs +87 -0
  371. package/dist/react/builder/Filters.mjs +165 -0
  372. package/dist/react/builder/Groups.mjs +189 -0
  373. package/dist/react/builder/Picker.mjs +154 -0
  374. package/dist/react/builder/Preview.d.mts +6 -0
  375. package/dist/react/builder/Preview.mjs +102 -0
  376. package/dist/react/builder/Sections.mjs +85 -0
  377. package/dist/react/builder/Time.mjs +119 -0
  378. package/dist/react/builder/WidgetBuilder.d.mts +23 -0
  379. package/dist/react/builder/WidgetBuilder.mjs +202 -0
  380. package/dist/react/builder/base.d.mts +19 -0
  381. package/dist/react/builder/base.mjs +111 -0
  382. package/dist/react/builder/calc.d.mts +5 -0
  383. package/dist/react/builder/calc.mjs +110 -0
  384. package/dist/react/builder/labels.d.mts +1 -0
  385. package/dist/react/builder/labels.mjs +55 -0
  386. package/dist/react/builder/options.mjs +55 -0
  387. package/dist/react/builder/state.d.mts +12 -0
  388. package/dist/react/builder/state.mjs +201 -0
  389. package/dist/react/builder/useBuilder.d.mts +46 -0
  390. package/dist/react/builder/useBuilder.mjs +60 -0
  391. package/dist/react/builder/usePreview.mjs +56 -0
  392. package/dist/react/client.d.mts +93 -0
  393. package/dist/react/client.mjs +107 -0
  394. package/dist/react/context.d.mts +32 -0
  395. package/dist/react/context.mjs +44 -0
  396. package/dist/react/debounce.mjs +19 -0
  397. package/dist/react/draft.d.mts +55 -0
  398. package/dist/react/draft.mjs +230 -0
  399. package/dist/react/english.d.mts +3 -0
  400. package/dist/react/english.mjs +149 -0
  401. package/dist/react/errors.d.mts +12 -0
  402. package/dist/react/errors.mjs +13 -0
  403. package/dist/react/format.d.mts +25 -0
  404. package/dist/react/format.mjs +153 -0
  405. package/dist/react/index.d.mts +27 -0
  406. package/dist/react/index.mjs +25 -0
  407. package/dist/react/marks.d.mts +11 -0
  408. package/dist/react/marks.mjs +62 -0
  409. package/dist/react/messages.d.mts +159 -0
  410. package/dist/react/place.mjs +21 -0
  411. package/dist/react/read.d.mts +15 -0
  412. package/dist/react/read.mjs +54 -0
  413. package/dist/react/renderers/index.d.mts +19 -0
  414. package/dist/react/renderers/index.mjs +85 -0
  415. package/dist/react/review-words.d.mts +79 -0
  416. package/dist/react/review-words.mjs +132 -0
  417. package/dist/react/review.d.mts +26 -0
  418. package/dist/react/review.mjs +110 -0
  419. package/dist/react/scope.mjs +9 -0
  420. package/dist/react/stable.mjs +39 -0
  421. package/dist/react/theme.css +1337 -0
  422. package/dist/react/tile-keys.d.mts +20 -0
  423. package/dist/react/tile-keys.mjs +21 -0
  424. package/dist/react/tile-store.mjs +99 -0
  425. package/dist/react/useBoard.d.mts +80 -0
  426. package/dist/react/useBoard.mjs +53 -0
  427. package/dist/react/useDashboard.d.mts +51 -0
  428. package/dist/react/useDashboard.mjs +56 -0
  429. package/dist/react/useTiles.d.mts +20 -0
  430. package/dist/react/useTiles.mjs +133 -0
  431. package/dist/react/view.mjs +52 -0
  432. package/dist/reading.mjs +43 -0
  433. package/dist/recharts/charts.d.mts +10 -0
  434. package/dist/recharts/charts.mjs +121 -0
  435. package/dist/recharts/index.d.mts +3 -0
  436. package/dist/recharts/index.mjs +3 -0
  437. package/dist/recharts/series.d.mts +22 -0
  438. package/dist/recharts/series.mjs +64 -0
  439. package/dist/request-rows.mjs +21 -0
  440. package/dist/request.mjs +20 -0
  441. package/dist/storage.d.mts +3 -0
  442. package/dist/storage.mjs +54 -0
  443. package/dist/store/apply.mjs +102 -0
  444. package/dist/store/commands.mjs +74 -0
  445. package/dist/store/conflicts.mjs +79 -0
  446. package/dist/store/create-tables.d.mts +29 -0
  447. package/dist/store/create-tables.mjs +91 -0
  448. package/dist/store/discard.mjs +60 -0
  449. package/dist/store/drafts.mjs +132 -0
  450. package/dist/store/editor.mjs +22 -0
  451. package/dist/store/log.mjs +22 -0
  452. package/dist/store/publish.mjs +177 -0
  453. package/dist/store/publisher.mjs +16 -0
  454. package/dist/store/reader.mjs +139 -0
  455. package/dist/store/review.mjs +177 -0
  456. package/dist/store/rows.mjs +205 -0
  457. package/dist/store/tenant.mjs +23 -0
  458. package/dist/store/undo.mjs +49 -0
  459. package/dist/store/unpublished.mjs +47 -0
  460. package/dist/store/versions.mjs +93 -0
  461. package/dist/store/writer.mjs +19 -0
  462. package/dist/testing/adapter-suite.d.mts +12 -0
  463. package/dist/testing/adapter-suite.mjs +281 -0
  464. package/dist/testing/index.d.mts +2 -0
  465. package/dist/testing/index.mjs +1 -0
  466. package/dist/tile-doc.mjs +44 -0
  467. package/dist/tiles.mjs +102 -0
  468. package/package.json +125 -3
  469. package/src/adapter/sql-adapter.ts +95 -0
  470. package/src/adapter/statement.ts +185 -0
  471. package/src/authorize.ts +73 -0
  472. package/src/body.ts +169 -0
  473. package/src/bounded.ts +43 -0
  474. package/src/cache.ts +192 -0
  475. package/src/checks.ts +170 -0
  476. package/src/custom-source.ts +59 -0
  477. package/src/dashboard-id.ts +36 -0
  478. package/src/dashboards.ts +132 -0
  479. package/src/editing.ts +148 -0
  480. package/src/endpoints/access.ts +41 -0
  481. package/src/endpoints/dashboards.ts +92 -0
  482. package/src/endpoints/drafts.ts +138 -0
  483. package/src/endpoints/index.ts +21 -0
  484. package/src/endpoints/meta.ts +137 -0
  485. package/src/endpoints/query.ts +86 -0
  486. package/src/endpoints/read.ts +92 -0
  487. package/src/endpoints/review.ts +89 -0
  488. package/src/endpoints/values.ts +62 -0
  489. package/src/endpoints/versions.ts +104 -0
  490. package/src/execute.ts +207 -0
  491. package/src/handler.ts +232 -0
  492. package/src/http.ts +66 -0
  493. package/src/index.ts +163 -0
  494. package/src/introspect.ts +205 -0
  495. package/src/mcp/api.ts +59 -0
  496. package/src/mcp/format.ts +67 -0
  497. package/src/mcp/index.ts +151 -0
  498. package/src/mcp/query.ts +153 -0
  499. package/src/mcp/resolve.ts +114 -0
  500. package/src/node-postgres.ts +81 -0
  501. package/src/owner.ts +36 -0
  502. package/src/postgres-connection.ts +143 -0
  503. package/src/postgres-store.ts +82 -0
  504. package/src/principal.ts +39 -0
  505. package/src/reading.ts +56 -0
  506. package/src/request-rows.ts +23 -0
  507. package/src/request.ts +22 -0
  508. package/src/storage.ts +63 -0
  509. package/src/store/apply.ts +129 -0
  510. package/src/store/commands.ts +75 -0
  511. package/src/store/conflicts.ts +98 -0
  512. package/src/store/create-tables.ts +104 -0
  513. package/src/store/discard.ts +42 -0
  514. package/src/store/drafts.ts +133 -0
  515. package/src/store/editor.ts +28 -0
  516. package/src/store/log.ts +28 -0
  517. package/src/store/publish.ts +199 -0
  518. package/src/store/publisher.ts +21 -0
  519. package/src/store/reader.ts +139 -0
  520. package/src/store/review.ts +239 -0
  521. package/src/store/rows.ts +250 -0
  522. package/src/store/tenant.ts +28 -0
  523. package/src/store/undo.ts +56 -0
  524. package/src/store/unpublished.ts +33 -0
  525. package/src/store/versions.ts +106 -0
  526. package/src/store/writer.ts +19 -0
  527. package/src/testing/adapter-suite.ts +239 -0
  528. package/src/testing/index.ts +2 -0
  529. package/src/tile-doc.ts +46 -0
  530. package/src/tiles.ts +120 -0
@@ -0,0 +1,97 @@
1
+ import { useDashboards } from "./context.mjs";
2
+ import { FilterBar } from "./FilterBar.mjs";
3
+ import { Grid } from "./Grid.mjs";
4
+ import { Header } from "./Header.mjs";
5
+ import { linkTo } from "./view.mjs";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ // src/Canvas.tsx
8
+ function Tabs({ doc, current, onSelect }) {
9
+ if (doc.tabs.length < 2) return null;
10
+ return /* @__PURE__ */ jsx("div", {
11
+ className: "dd-tabs",
12
+ role: "tablist",
13
+ children: doc.tabs.map((t) => /* @__PURE__ */ jsx("button", {
14
+ type: "button",
15
+ role: "tab",
16
+ "aria-selected": t.id === current.id,
17
+ onClick: () => {
18
+ onSelect(t.id);
19
+ },
20
+ children: t.title
21
+ }, t.id))
22
+ });
23
+ }
24
+ /** The filters a link carried that this dashboard does not have, named once. */
25
+ function Dropped({ names }) {
26
+ const { messages } = useDashboards();
27
+ return names.length === 0 ? null : /* @__PURE__ */ jsx("p", {
28
+ className: "dd-tile-note",
29
+ role: "status",
30
+ children: messages.droppedFromLink(names)
31
+ });
32
+ }
33
+ /** Whether the tab shown has nothing on it, not even a removed tile. */
34
+ const emptyTab = (shown) => shown.tab.layout.length === 0 && (shown.ghosts ?? []).length === 0;
35
+ /** A tab with nothing on it while editing: what to do first. */
36
+ function EmptyTab({ onAdd }) {
37
+ const { messages } = useDashboards();
38
+ return /* @__PURE__ */ jsxs("div", {
39
+ className: "dd-empty",
40
+ children: [/* @__PURE__ */ jsx("p", { children: messages.emptyTab }), /* @__PURE__ */ jsx("button", {
41
+ type: "button",
42
+ className: "dd-button dd-primary",
43
+ onClick: onAdd,
44
+ children: messages.addWidget
45
+ })]
46
+ });
47
+ }
48
+ /** The canvas: header, tabs, filters, and the grid with its marks. */
49
+ function Canvas(props) {
50
+ const { board, shown } = props;
51
+ const { edit, panels, view } = board;
52
+ const add = () => {
53
+ props.onBuild({});
54
+ };
55
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
56
+ /* @__PURE__ */ jsx(Header, {
57
+ doc: shown.doc,
58
+ version: board.version,
59
+ unpublished: board.unpublished,
60
+ canEdit: board.canEdit && panels.previewing === void 0,
61
+ waiting: board.waiting,
62
+ edit,
63
+ historyOpen: panels.panel === "history",
64
+ onAdd: add,
65
+ onHistory: panels.toggleHistory,
66
+ link: () => linkTo(view.current, props.dashboard.linkFor)
67
+ }),
68
+ /* @__PURE__ */ jsx(Dropped, { names: view.dropped }),
69
+ /* @__PURE__ */ jsx(Tabs, {
70
+ doc: shown.doc,
71
+ current: shown.tab,
72
+ onSelect: view.setTab
73
+ }),
74
+ /* @__PURE__ */ jsx(FilterBar, {
75
+ controls: shown.doc.controls,
76
+ picks: view.picks,
77
+ onChange: view.setPicks
78
+ }),
79
+ edit.draft === void 0 || !emptyTab(shown) ? null : /* @__PURE__ */ jsx(EmptyTab, { onAdd: add }),
80
+ /* @__PURE__ */ jsx(Grid, {
81
+ doc: shown.doc,
82
+ tab: shown.tab,
83
+ edit,
84
+ results: board.tiles.results,
85
+ pending: board.tiles.pending,
86
+ marks: shown.marks,
87
+ ghosts: shown.ghosts,
88
+ highlight: panels.point,
89
+ fresh: props.fresh,
90
+ arrangeable: shown.arrangeable,
91
+ onEdit: (widgetId) => {
92
+ props.onBuild({ widgetId });
93
+ }
94
+ })
95
+ ] });
96
+ }
97
+ export { Canvas };
@@ -0,0 +1,106 @@
1
+ import { useDashboards } from "./context.mjs";
2
+ import { TileActions } from "./Editing.mjs";
3
+ import { placeOf, useBringIntoView } from "./place.mjs";
4
+ import { Tile } from "./Tile.mjs";
5
+ import { memo, useEffect, useMemo } from "react";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ // src/Cell.tsx
8
+ /** The grip that moves a tile, and the corner that resizes it, while the dashboard is a draft. */
9
+ function Handles(props) {
10
+ const { messages } = useDashboards();
11
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
12
+ type: "button",
13
+ className: "dd-move",
14
+ "aria-label": messages.moveWidget(props.title),
15
+ "aria-keyshortcuts": "ArrowUp ArrowDown ArrowLeft ArrowRight Shift+ArrowRight Shift+ArrowDown",
16
+ title: messages.arrangeHint,
17
+ ...props.handle(props.item, "move"),
18
+ children: /* @__PURE__ */ jsx("span", {
19
+ "aria-hidden": "true",
20
+ children: "⠿"
21
+ })
22
+ }), /* @__PURE__ */ jsx("button", {
23
+ type: "button",
24
+ className: "dd-resize",
25
+ "aria-label": messages.resizeWidget(props.title),
26
+ title: messages.arrangeHint,
27
+ ...props.handle(props.item, "resize")
28
+ })] });
29
+ }
30
+ const samePlace = (a, b) => a.widget === b.widget && a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h;
31
+ /** A cell draws again only when something it shows changed; a new layout list with its place unchanged is not that. */
32
+ const sameCell = (a, b) => samePlace(a.item, b.item) && Object.entries(a).every(([key, value]) => key === "item" || Object.is(value, Reflect.get(b, key)));
33
+ /** A tile's own buttons while editing: Edit, Remove, and on a phone Move up and Move down. */
34
+ function useActions(props) {
35
+ const { item, widget, editing, busy, onEdit, onRemove, onStep, first, last } = props;
36
+ return useMemo(() => {
37
+ const step = (by) => () => {
38
+ onStep(item.widget, by);
39
+ };
40
+ return editing ? /* @__PURE__ */ jsx(TileActions, {
41
+ busy,
42
+ title: widget.title,
43
+ onEdit: () => {
44
+ onEdit(item.widget);
45
+ },
46
+ onRemove: () => {
47
+ onRemove(item.widget);
48
+ },
49
+ onUp: first ? void 0 : step(-1),
50
+ onDown: last ? void 0 : step(1)
51
+ }) : null;
52
+ }, [
53
+ editing,
54
+ busy,
55
+ widget.title,
56
+ item.widget,
57
+ onEdit,
58
+ onRemove,
59
+ onStep,
60
+ first,
61
+ last
62
+ ]);
63
+ }
64
+ /** One widget in its place on the grid; while editing, with its grip, corner, Edit and Remove. */
65
+ const Cell = memo(function Cell(props) {
66
+ const { messages } = useDashboards();
67
+ const { item, widget, mark, editing } = props;
68
+ const ref = useBringIntoView(props.fresh || props.lit);
69
+ useEffect(() => {
70
+ if (props.fresh && editing) ref.current?.querySelector(".dd-tile-edit")?.focus();
71
+ }, [
72
+ props.fresh,
73
+ editing,
74
+ ref
75
+ ]);
76
+ const actions = useActions(props);
77
+ const badge = useMemo(() => mark === void 0 ? void 0 : /* @__PURE__ */ jsx("span", {
78
+ className: "dd-mark",
79
+ children: messages.marks[mark]
80
+ }), [mark, messages]);
81
+ return /* @__PURE__ */ jsxs("div", {
82
+ ref,
83
+ className: "dd-cell",
84
+ "data-widget": item.widget,
85
+ "data-kind": widget.kind,
86
+ "data-fresh": props.fresh,
87
+ "data-lit": props.lit,
88
+ "data-mark": mark,
89
+ "data-moving": props.moving,
90
+ style: placeOf(item),
91
+ children: [editing ? /* @__PURE__ */ jsx(Handles, {
92
+ item,
93
+ title: widget.title,
94
+ handle: props.handle
95
+ }) : null, /* @__PURE__ */ jsx(Tile, {
96
+ widgetId: item.widget,
97
+ widget,
98
+ result: props.result,
99
+ loading: props.loading,
100
+ controlLabels: props.controlLabels,
101
+ actions,
102
+ badge
103
+ })]
104
+ });
105
+ }, sameCell);
106
+ export { Cell };
@@ -0,0 +1,31 @@
1
+ import { useState } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ // src/ConfirmButton.tsx
4
+ /**
5
+ * A button for a step that cannot be undone: the first press asks, in the button itself, and
6
+ * the second does it. Leaving it (Escape, or focus moving on) takes the question back.
7
+ */
8
+ function ConfirmButton(props) {
9
+ const [asking, setAsking] = useState(false);
10
+ return /* @__PURE__ */ jsx("button", {
11
+ type: "button",
12
+ className: asking ? "dd-button dd-danger" : "dd-button",
13
+ "aria-disabled": props.busy,
14
+ onClick: () => {
15
+ if (props.busy) return;
16
+ if (asking) props.onConfirm();
17
+ setAsking(!asking);
18
+ },
19
+ onBlur: () => {
20
+ setAsking(false);
21
+ },
22
+ onKeyDown: (event) => {
23
+ if (event.key === "Escape" && asking) {
24
+ event.stopPropagation();
25
+ setAsking(false);
26
+ }
27
+ },
28
+ children: asking ? props.confirm : props.label
29
+ });
30
+ }
31
+ export { ConfirmButton };
@@ -0,0 +1,27 @@
1
+ import { DashboardEvents } from "./useDashboard.mjs";
2
+ import { ViewState } from "derive-dashboards/core";
3
+ /**
4
+ * A dashboard by id: its title, filter bar and tiles on a 12-column grid. Picks change the
5
+ * tiles' answers, never the dashboard. Those who may edit it get Edit: changes go to their own
6
+ * draft, which only they see; the edit bar counts them and undoes and redoes any of them;
7
+ * changed tiles are marked in place. Review and publish opens the review beside the canvas:
8
+ * every change, and over a newer version the merged result, then Publish. History opens the
9
+ * 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.
11
+ *
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.
14
+ */
15
+ export type DashboardProps = {
16
+ id: string;
17
+ /** False shows it read-only, whatever the viewer may do: no Edit, no Restore. */
18
+ editable?: boolean;
19
+ /** The tab and filters to show, when the host keeps them (from a link, say). */
20
+ view?: ViewState;
21
+ onViewChange?: (view: ViewState) => void;
22
+ /** What the host's `decodeView` could not read from a link, so the page says it was left out. */
23
+ linkDropped?: readonly string[];
24
+ /** The link Share copies for a view; by default, this page's address with the view in it. */
25
+ linkFor?: (view: ViewState) => string;
26
+ } & DashboardEvents;
27
+ export declare function Dashboard(props: DashboardProps): import("react").JSX.Element;
@@ -0,0 +1,80 @@
1
+ import { Canvas } from "./Canvas.mjs";
2
+ import { useDashboards } from "./context.mjs";
3
+ import { BuildPage } from "./Editing.mjs";
4
+ import { Bars, Side } from "./Parts.mjs";
5
+ import { ScopeContext } from "./scope.mjs";
6
+ import { useBoard } from "./useBoard.mjs";
7
+ import { useState } from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ // src/Dashboard.tsx
10
+ /** Focuses what opened the builder once the dashboard is back: the tile's Edit, or Add widget. */
11
+ function focusOpener(widgetId) {
12
+ requestAnimationFrame(() => {
13
+ ((widgetId === void 0 ? null : document.querySelector(`.dd-cell[data-widget="${CSS.escape(widgetId)}"] .dd-tile-edit`)) ?? document.querySelector("[data-focus-after]"))?.focus();
14
+ });
15
+ }
16
+ function Dashboard(props) {
17
+ const { messages } = useDashboards();
18
+ const board = useBoard(props);
19
+ const [building, setBuilding] = useState();
20
+ const [fresh, setFresh] = useState();
21
+ const { error, edit, shown, panels, view } = board;
22
+ if (board.missing) return /* @__PURE__ */ jsx("div", {
23
+ className: "dd-tile-state",
24
+ children: messages.dashboardMissing
25
+ });
26
+ if (error) return /* @__PURE__ */ jsx("div", {
27
+ className: "dd-tile-error",
28
+ role: "alert",
29
+ children: messages.dashboardFailed
30
+ });
31
+ if (shown?.tab === void 0) return /* @__PURE__ */ jsx("div", {
32
+ className: "dd-dashboard",
33
+ "aria-busy": "true"
34
+ });
35
+ const tab = shown.tab;
36
+ if (building !== void 0 && edit.draft !== void 0) return /* @__PURE__ */ jsx(BuildPage, {
37
+ doc: edit.draft.doc,
38
+ tab,
39
+ edit,
40
+ ...building,
41
+ onDone: (saved) => {
42
+ setBuilding(void 0);
43
+ setFresh(saved);
44
+ if (saved === void 0) focusOpener(building.widgetId);
45
+ }
46
+ });
47
+ const editing = edit.draft !== void 0;
48
+ return /* @__PURE__ */ jsx(ScopeContext.Provider, {
49
+ value: {
50
+ dashboardId: props.id,
51
+ picks: view.picks,
52
+ ...editing ? { draft: true } : {}
53
+ },
54
+ children: /* @__PURE__ */ jsxs("div", {
55
+ className: "dd-dashboard",
56
+ "data-editing": editing,
57
+ "data-panel": panels.panel !== void 0,
58
+ children: [/* @__PURE__ */ jsxs("div", {
59
+ 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
+ })]
73
+ }), /* @__PURE__ */ jsx(Side, {
74
+ board,
75
+ props
76
+ })]
77
+ })
78
+ });
79
+ }
80
+ export { Dashboard };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Every dashboard the viewer can open, theirs not yet published marked as drafts, and
3
+ * "+ New dashboard" for those who may make one, which opens it straight into editing. A long
4
+ * list gets a search box. The host decides where a dashboard opens (`onOpen` gets its id) and,
5
+ * with `linkFor`, how to link to one: each row then has Copy link.
6
+ */
7
+ export declare function DashboardList({ current, onOpen, linkFor }: {
8
+ current?: string;
9
+ onOpen: (id: string) => void;
10
+ /** A link to a dashboard by id: each row gets Copy link. */
11
+ linkFor?: (id: string) => string;
12
+ }): import("react").JSX.Element;
@@ -0,0 +1,155 @@
1
+ import { useDashboards } from "./context.mjs";
2
+ import { useId, useState } from "react";
3
+ import useSWR from "swr";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ // src/DashboardList.tsx
6
+ /** The SWR key of the dashboard list, refreshed whenever a dashboard is made, published or discarded. */
7
+ const LIST_KEY = "dd-list";
8
+ /** Makes a new dashboard, once per click even if the request is retried, and opens it. */
9
+ function useCreate(onOpen, refresh) {
10
+ const { client, messages } = useDashboards();
11
+ const [error, setError] = useState();
12
+ const [making, setMaking] = useState(false);
13
+ const create = async () => {
14
+ setMaking(true);
15
+ setError(void 0);
16
+ try {
17
+ const draft = await client.newDashboard({
18
+ title: messages.untitledDashboard,
19
+ requestId: crypto.randomUUID()
20
+ });
21
+ await refresh();
22
+ onOpen(draft.dashboardId);
23
+ } catch (failure) {
24
+ setError(failure instanceof Error ? failure.message : String(failure));
25
+ } finally {
26
+ setMaking(false);
27
+ }
28
+ };
29
+ return {
30
+ making,
31
+ error,
32
+ create
33
+ };
34
+ }
35
+ /**
36
+ * Copy link on a row, shown on hover or focus, when the host says how to link a dashboard. It
37
+ * comes after the row's own button and says which dashboard it links, so it never names the row.
38
+ */
39
+ function CopyLink(props) {
40
+ const { id, linkFor } = props;
41
+ const { messages } = useDashboards();
42
+ const [copied, setCopied] = useState(false);
43
+ return /* @__PURE__ */ jsx("button", {
44
+ type: "button",
45
+ className: "dd-list-copy",
46
+ "aria-label": messages.copyLinkTo(props.title),
47
+ onClick: () => {
48
+ const copy = async () => {
49
+ await navigator.clipboard.writeText(linkFor(id));
50
+ setCopied(true);
51
+ };
52
+ copy();
53
+ },
54
+ children: copied ? messages.copied : messages.copyLink
55
+ });
56
+ }
57
+ /** A search box once the list is long, and a line when nothing matches. */
58
+ function Search(props) {
59
+ const { messages } = useDashboards();
60
+ const { all, search, setSearch } = props;
61
+ return /* @__PURE__ */ jsxs(Fragment, { children: [all.length > 6 ? /* @__PURE__ */ jsx("input", {
62
+ type: "search",
63
+ className: "dd-list-search",
64
+ "aria-label": messages.searchDashboards,
65
+ placeholder: messages.searchDashboards,
66
+ value: search,
67
+ onChange: (event) => {
68
+ setSearch(event.target.value);
69
+ }
70
+ }) : null, props.shown === 0 && all.length > 0 ? /* @__PURE__ */ jsx("p", {
71
+ className: "dd-tile-note",
72
+ children: messages.noMatches
73
+ }) : null] });
74
+ }
75
+ /**
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.
78
+ */
79
+ function Items({ items, current, onOpen, linkFor }) {
80
+ const { messages } = useDashboards();
81
+ 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", {
94
+ 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)) });
102
+ }
103
+ /**
104
+ * Every dashboard the viewer can open, theirs not yet published marked as drafts, and
105
+ * "+ New dashboard" for those who may make one, which opens it straight into editing. A long
106
+ * list gets a search box. The host decides where a dashboard opens (`onOpen` gets its id) and,
107
+ * with `linkFor`, how to link to one: each row then has Copy link.
108
+ */
109
+ function DashboardList({ current, onOpen, linkFor }) {
110
+ const { client, messages } = useDashboards();
111
+ const list = useSWR(LIST_KEY, () => client.listDashboards());
112
+ const [search, setSearch] = useState("");
113
+ const all = list.data?.dashboards ?? [];
114
+ const words = search.trim().toLocaleLowerCase();
115
+ const shown = words === "" ? all : all.filter((d) => d.title.toLocaleLowerCase().includes(words));
116
+ const { making, error, create } = useCreate(onOpen, async () => {
117
+ await list.mutate();
118
+ });
119
+ return /* @__PURE__ */ jsxs("nav", {
120
+ className: "dd-list",
121
+ "aria-label": messages.dashboards,
122
+ children: [
123
+ list.data?.can.create === true ? /* @__PURE__ */ jsx("button", {
124
+ type: "button",
125
+ className: "dd-button dd-list-new",
126
+ disabled: making,
127
+ onClick: () => void create(),
128
+ children: messages.newDashboard
129
+ }) : null,
130
+ error === void 0 ? null : /* @__PURE__ */ jsx("p", {
131
+ className: "dd-draft-error",
132
+ role: "alert",
133
+ children: error
134
+ }),
135
+ list.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
136
+ className: "dd-draft-error",
137
+ role: "alert",
138
+ children: messages.listFailed
139
+ }),
140
+ /* @__PURE__ */ jsx(Search, {
141
+ all,
142
+ search,
143
+ setSearch,
144
+ shown: shown.length
145
+ }),
146
+ /* @__PURE__ */ jsx(Items, {
147
+ items: shown,
148
+ current,
149
+ onOpen,
150
+ linkFor
151
+ })
152
+ ]
153
+ });
154
+ }
155
+ export { DashboardList, LIST_KEY };
@@ -0,0 +1,99 @@
1
+ import { useDashboards } from "./context.mjs";
2
+ import { isShifted } from "./marks.mjs";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ // src/Discard.tsx
6
+ /**
7
+ * Discard, asked once in the bar itself: the draft cannot be recovered. A dashboard never
8
+ * published goes with its draft, and the question says so.
9
+ */
10
+ function DiscardButton({ edit, isNew = false }) {
11
+ const { messages } = useDashboards();
12
+ const [asking, setAsking] = useState(false);
13
+ const discard = useRef(null);
14
+ const keep = useRef(null);
15
+ const answered = useRef(false);
16
+ useEffect(() => {
17
+ if (asking) keep.current?.focus();
18
+ else if (answered.current) discard.current?.focus();
19
+ }, [asking]);
20
+ const ask = (on) => {
21
+ answered.current = !on;
22
+ setAsking(on);
23
+ };
24
+ if (!asking) return /* @__PURE__ */ jsx("button", {
25
+ ref: discard,
26
+ type: "button",
27
+ className: "dd-button dd-quiet",
28
+ "aria-disabled": edit.busy,
29
+ onClick: () => {
30
+ if (!edit.busy) ask(true);
31
+ },
32
+ children: messages.discard
33
+ });
34
+ return /* @__PURE__ */ jsx(DiscardAsk, {
35
+ edit,
36
+ isNew,
37
+ keep,
38
+ onKeep: () => {
39
+ ask(false);
40
+ }
41
+ });
42
+ }
43
+ /** After a discard the bar is gone: say so, and put focus back on Edit. */
44
+ function saidAndBack(text) {
45
+ requestAnimationFrame(() => {
46
+ const said = document.querySelector(".dd-placed");
47
+ if (said !== null) said.textContent = text;
48
+ document.querySelector("[data-focus-after]")?.focus();
49
+ });
50
+ }
51
+ /** Escape answers "keep": the question goes, and nothing else Escape does happens with it. */
52
+ function useEscape(onEscape) {
53
+ const latest = useRef(onEscape);
54
+ latest.current = onEscape;
55
+ useEffect(() => {
56
+ const onKey = (event) => {
57
+ if (event.key !== "Escape") return;
58
+ event.stopImmediatePropagation();
59
+ latest.current();
60
+ };
61
+ globalThis.addEventListener("keydown", onKey, { capture: true });
62
+ return () => {
63
+ globalThis.removeEventListener("keydown", onKey, { capture: true });
64
+ };
65
+ }, []);
66
+ }
67
+ /** The question Discard asks in the bar: how many changes go, Keep editing, and the step itself. */
68
+ function DiscardAsk(props) {
69
+ const { messages } = useDashboards();
70
+ const { edit, isNew, onKeep } = props;
71
+ useEscape(onKeep);
72
+ return /* @__PURE__ */ jsxs("span", {
73
+ className: "dd-row",
74
+ children: [
75
+ /* @__PURE__ */ jsx("span", { children: isNew ? messages.deleteNewAsk : messages.discardAsk(edit.draft?.changes.filter((c) => !isShifted(c)).length ?? 0) }),
76
+ /* @__PURE__ */ jsx("button", {
77
+ ref: props.keep,
78
+ type: "button",
79
+ className: "dd-button dd-quiet",
80
+ onClick: props.onKeep,
81
+ children: messages.keepEditing
82
+ }),
83
+ /* @__PURE__ */ jsx("button", {
84
+ type: "button",
85
+ className: "dd-button dd-danger",
86
+ disabled: edit.busy,
87
+ onClick: () => {
88
+ const discard = async () => {
89
+ await edit.discard();
90
+ if (!isNew) saidAndBack(messages.changesDiscarded);
91
+ };
92
+ discard();
93
+ },
94
+ children: isNew ? messages.deleteNewConfirm : messages.discardConfirm
95
+ })
96
+ ]
97
+ });
98
+ }
99
+ export { DiscardButton };
@@ -0,0 +1,16 @@
1
+ import { DraftEditor } from "./draft.mjs";
2
+ import { Doc } from "derive-dashboards/core";
3
+ /**
4
+ * The bar over a dashboard being edited: who sees the changes, how many there are (which opens
5
+ * the review), Undo and Redo across the whole draft, Discard, and Review and publish. Every
6
+ * action has a keyboard shortcut.
7
+ */
8
+ export declare function EditBar(props: {
9
+ edit: DraftEditor;
10
+ doc: Doc;
11
+ /** Nothing is published yet: publishing makes the first version, changed or not. */
12
+ firstPublish: boolean;
13
+ /** Never published: Discard deletes the dashboard, and says so. */
14
+ unpublished?: boolean;
15
+ onReview: () => void;
16
+ }): import("react").JSX.Element;