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
@@ -1,30 +1,17 @@
1
1
  import { useArrange } from "./arrange.mjs";
2
- import { Cell } from "./Cell.mjs";
3
- import { placeOf } from "./place.mjs";
4
- import { Spaces } from "./Spaces.mjs";
2
+ import { Cell as Cell$1 } from "./Cell.mjs";
3
+ import { useDashboards } from "./context.mjs";
4
+ import { Drop, Spaces } from "./Spaces.mjs";
5
5
  import { useSameWidgets, useStable } from "./stable.mjs";
6
+ import { useViewGrid } from "./view-grid.mjs";
6
7
  import { useMemo, useRef } from "react";
7
8
  import { readingOrder, stepCommands } from "derive-dashboards/core";
8
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
9
10
  // src/Grid.tsx
10
11
  /** Each filter control's label by id, made once per set of controls rather than per tile. */
11
12
  function useControlLabels(controls) {
12
13
  return useMemo(() => new Map(controls.map((c) => [c.id, c.label])), [controls]);
13
14
  }
14
- /**
15
- * The outline where a dragged tile will land, and where one moved by the keyboard is now, said
16
- * to a screen reader (`arrange` writes it).
17
- */
18
- function Drop({ at }) {
19
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
20
- className: "dd-placed dd-sr",
21
- role: "status"
22
- }), at === void 0 ? null : /* @__PURE__ */ jsx("div", {
23
- className: "dd-drop",
24
- "aria-hidden": "true",
25
- style: placeOf(at)
26
- })] });
27
- }
28
15
  /** Focuses the first of `selectors` that matches in a widget's cell, once it is drawn. */
29
16
  function focusIn(widget, ...selectors) {
30
17
  requestAnimationFrame(() => {
@@ -48,21 +35,27 @@ function useStep(edit, current) {
48
35
  }
49
36
  /** What a tile's own buttons call, each keeping one identity so tiles do not draw again. */
50
37
  function useTileCalls(edit, props) {
38
+ const { messages } = useDashboards();
51
39
  const onEdit = useStable(props.onEdit);
52
40
  const tab = useRef(props.tab);
53
41
  tab.current = props.tab;
42
+ const doc = useRef(props.doc);
43
+ doc.current = props.doc;
54
44
  return {
55
45
  onEdit,
56
46
  onRemove: useStable((id) => {
57
47
  const order = readingOrder(tab.current.layout).map((i) => i.widget);
58
48
  const at = order.indexOf(id);
59
49
  const next = order[at + 1] ?? order[at - 1];
50
+ const title = doc.current.widgets[id]?.title ?? "";
60
51
  const remove = async () => {
61
- await edit.apply([{
52
+ if (!await edit.apply([{
62
53
  type: "widget.remove",
63
54
  id
64
- }]);
65
- if (next !== void 0) focusIn(next, ".dd-tile-remove");
55
+ }])) return;
56
+ if (next !== void 0) focusIn(next, ".dd-tile-edit");
57
+ const said = document.querySelector(".dd-placed");
58
+ if (said !== null) said.textContent = messages.removedTile(title);
66
59
  };
67
60
  remove();
68
61
  }),
@@ -92,7 +85,8 @@ function Grid(props) {
92
85
  const widgets = useSameWidgets(doc.widgets);
93
86
  const { onEdit, onRemove, onStep } = useTileCalls(edit, props);
94
87
  const editing = edit.draft !== void 0 && arrangeable;
95
- const cells = useReadingOrder(props.tab.layout, arrange.layout);
88
+ const view = useViewGrid(props.tab.layout, widgets, props.results);
89
+ const cells = useReadingOrder(props.tab.layout, editing ? arrange.layout : view.layout);
96
90
  return /* @__PURE__ */ jsxs("div", {
97
91
  ref: arrange.gridRef,
98
92
  className: "dd-grid",
@@ -107,7 +101,7 @@ function Grid(props) {
107
101
  /* @__PURE__ */ jsx(Drop, { at: arrange.drop }),
108
102
  cells.map((item) => {
109
103
  const widget = widgets[item.widget];
110
- return widget === void 0 ? null : /* @__PURE__ */ jsx(Cell, {
104
+ return widget === void 0 ? null : /* @__PURE__ */ jsx(Cell$1, {
111
105
  item,
112
106
  widget,
113
107
  result: props.results.get(item.widget),
@@ -124,7 +118,8 @@ function Grid(props) {
124
118
  onRemove,
125
119
  onStep,
126
120
  first: cells[0]?.widget === item.widget,
127
- last: cells.at(-1)?.widget === item.widget
121
+ last: cells.at(-1)?.widget === item.widget,
122
+ sharedSpan: view.sharedSpan
128
123
  }, item.widget);
129
124
  })
130
125
  ]
@@ -47,6 +47,15 @@ function Title({ doc, edit, isNew }) {
47
47
  function ShareButton({ link }) {
48
48
  const { messages } = useDashboards();
49
49
  const [said, setSaid] = useState();
50
+ useEffect(() => {
51
+ if (said !== messages.linkCopied) return;
52
+ const wait = setTimeout(() => {
53
+ setSaid(void 0);
54
+ }, 4e3);
55
+ return () => {
56
+ clearTimeout(wait);
57
+ };
58
+ }, [said, messages.linkCopied]);
50
59
  const share = async () => {
51
60
  const url = link();
52
61
  try {
@@ -82,7 +91,7 @@ function Header(props) {
82
91
  }), /* @__PURE__ */ jsxs("div", {
83
92
  className: "dd-header-actions",
84
93
  children: [
85
- props.unpublished === true ? null : /* @__PURE__ */ jsx(ShareButton, { link: props.link }),
94
+ props.unpublished === true || editing ? null : /* @__PURE__ */ jsx(ShareButton, { link: props.link }),
86
95
  editing || version === 0 ? null : /* @__PURE__ */ jsx("button", {
87
96
  type: "button",
88
97
  className: "dd-button dd-quiet",
@@ -3,6 +3,7 @@ import { useDashboards } from "./context.mjs";
3
3
  import { LIST_KEY } from "./DashboardList.mjs";
4
4
  import { formatInstant } from "./format.mjs";
5
5
  import { Panel } from "./Panel.mjs";
6
+ import { ReadFailed } from "./ReadFailed.mjs";
6
7
  import { useState } from "react";
7
8
  import { useSWRConfig } from "swr";
8
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -82,6 +83,10 @@ function HistoryPanel(props) {
82
83
  className: "dd-tile-note",
83
84
  children: messages.noHistory
84
85
  }) : null,
86
+ /* @__PURE__ */ jsx(ReadFailed, {
87
+ error: history.error,
88
+ retry: () => void history.mutate()
89
+ }),
85
90
  /* @__PURE__ */ jsx("ol", {
86
91
  className: "dd-timeline",
87
92
  children: entries.map((entry) => /* @__PURE__ */ jsx(Entry, {
@@ -1,4 +1,5 @@
1
1
  import { useDashboards } from "./context.mjs";
2
+ import { DrillSide } from "./drill/board.mjs";
2
3
  import { EditBar } from "./EditBar.mjs";
3
4
  import { HistoryPanel, VersionBar } from "./History.mjs";
4
5
  import { PublishedNotice } from "./Notice.mjs";
@@ -77,7 +78,7 @@ function Bars({ board, props }) {
77
78
  })
78
79
  ] });
79
80
  }
80
- /** The side panel: the review, or the history timeline. */
81
+ /** The side panel: the review, the history timeline, or the drill open. */
81
82
  function Side({ board, props }) {
82
83
  const { panels, review, edit } = board;
83
84
  if (panels.panel === "review") return /* @__PURE__ */ jsx(ReviewPanel, {
@@ -93,6 +94,9 @@ function Side({ board, props }) {
93
94
  onSelect: board.canEdit ? panels.setPreviewing : void 0,
94
95
  onClose: panels.close
95
96
  });
96
- return null;
97
+ return /* @__PURE__ */ jsx(DrillSide, {
98
+ board,
99
+ props
100
+ });
97
101
  }
98
102
  export { Bars, Side };
@@ -0,0 +1,23 @@
1
+ import { useDashboards } from "./context.mjs";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ // src/ReadFailed.tsx
4
+ /** A list that could not be read (the history, a page of it): said, with a way to try again. */
5
+ function ReadFailed({ error, retry }) {
6
+ const { messages } = useDashboards();
7
+ if (error === void 0) return null;
8
+ return /* @__PURE__ */ jsxs("p", {
9
+ className: "dd-tile-error",
10
+ role: "alert",
11
+ children: [
12
+ messages.readFailed,
13
+ " ",
14
+ /* @__PURE__ */ jsx("button", {
15
+ type: "button",
16
+ className: "dd-button dd-quiet",
17
+ onClick: retry,
18
+ children: messages.drillRetry
19
+ })
20
+ ]
21
+ });
22
+ }
23
+ export { ReadFailed };
@@ -5,6 +5,12 @@ import { ChangeList, Panel } from "./Panel.mjs";
5
5
  import { closeGapsCommands } from "derive-dashboards/core";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  // src/ReviewPanel.tsx
8
+ /** The refused changes in words, each once: "Moved “Tasks closed”; resized “Tasks closed”". */
9
+ function changesIn(refusals, words) {
10
+ const said = refusals.map((r) => words.undone(r.body.type, r.widget?.title));
11
+ const unique = [...new Set(said)].join("; ");
12
+ return unique.charAt(0).toUpperCase() + unique.slice(1);
13
+ }
8
14
  /**
9
15
  * The changes to one widget that no longer apply, for one reason: what they were, why, and the
10
16
  * ways out. Drop drops them all, since dropping one alone leaves the others still refused. Put
@@ -18,7 +24,12 @@ function Refused(props) {
18
24
  const { widget } = refusal;
19
25
  return /* @__PURE__ */ jsxs("li", {
20
26
  className: "dd-refused",
21
- children: [/* @__PURE__ */ jsxs("p", { children: [widget === void 0 ? null : /* @__PURE__ */ jsx("strong", { children: `“${widget.title}” ` }), refusal.issue.code === "WIDGET_UNKNOWN" ? messages.widgetGone : refusal.issue.message] }), /* @__PURE__ */ jsxs("div", {
27
+ children: [/* @__PURE__ */ jsxs("p", { children: [
28
+ /* @__PURE__ */ jsx("strong", { children: changesIn(refusals, messages) }),
29
+ ":",
30
+ " ",
31
+ refusal.issue.code === "WIDGET_UNKNOWN" ? messages.widgetGone : refusal.issue.message
32
+ ] }), /* @__PURE__ */ jsxs("div", {
22
33
  className: "dd-row",
23
34
  children: [/* @__PURE__ */ jsx(ConfirmButton, {
24
35
  label: messages.dropChange,
@@ -139,7 +150,7 @@ function PublishFoot({ review, busy }) {
139
150
  "data-publish": "",
140
151
  disabled: busy || nothing || waiting,
141
152
  onClick: () => void review.publish(),
142
- children: messages.publishVersion((preview?.head ?? 0) + 1)
153
+ children: preview === void 0 ? messages.publish : messages.publishVersion(preview.head + 1)
143
154
  })
144
155
  ]
145
156
  });
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from "react";
2
+ /**
3
+ * What one row of a list shows, for a drill's Items and the list widget alike: a title, a meta
4
+ * line, an optional lead (an avatar), badge and trailing value, and a chevron when it opens.
5
+ */
6
+ export type RowContent = {
7
+ title: string;
8
+ meta: readonly string[];
9
+ badge?: {
10
+ text: string;
11
+ tone?: string | undefined;
12
+ } | undefined;
13
+ /** Before the text: an avatar's initials. */
14
+ lead?: string | undefined;
15
+ /** After the text: one number. */
16
+ value?: string | undefined;
17
+ /** The row opens something: a chevron says so. */
18
+ opens?: boolean;
19
+ };
@@ -0,0 +1,55 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ // src/RowBody.tsx
3
+ /** The class names of one family of rows: `dd-item-*` (Items) or `dd-lines-*` (the list widget). */
4
+ const CLASSES = {
5
+ item: {
6
+ lead: "dd-item-lead",
7
+ text: "dd-item-text",
8
+ title: "dd-item-title",
9
+ meta: "dd-item-meta",
10
+ value: "dd-item-value"
11
+ },
12
+ lines: {
13
+ lead: "dd-lines-avatar",
14
+ text: "dd-lines-text",
15
+ title: "dd-lines-title",
16
+ meta: "dd-lines-sub",
17
+ value: "dd-lines-meta"
18
+ }
19
+ };
20
+ /** One row's parts, the one markup every list of rows shares. */
21
+ function RowBody({ row, family }) {
22
+ const c = CLASSES[family];
23
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
24
+ row.lead === void 0 ? null : /* @__PURE__ */ jsx("span", {
25
+ className: c.lead,
26
+ "aria-hidden": "true",
27
+ children: row.lead
28
+ }),
29
+ /* @__PURE__ */ jsxs("span", {
30
+ className: c.text,
31
+ children: [/* @__PURE__ */ jsx("strong", {
32
+ className: c.title,
33
+ children: row.title
34
+ }), family === "item" && row.meta.length === 0 ? null : /* @__PURE__ */ jsx("span", {
35
+ className: c.meta,
36
+ children: row.meta.join(" · ")
37
+ })]
38
+ }),
39
+ row.badge === void 0 ? null : /* @__PURE__ */ jsx("span", {
40
+ className: "dd-item-badge",
41
+ "data-tone": row.badge.tone ?? "neutral",
42
+ children: row.badge.text
43
+ }),
44
+ row.value === void 0 ? null : /* @__PURE__ */ jsx("span", {
45
+ className: c.value,
46
+ children: row.value
47
+ }),
48
+ row.opens === true ? /* @__PURE__ */ jsx("span", {
49
+ className: "dd-item-go",
50
+ "aria-hidden": "true",
51
+ children: "›"
52
+ }) : null
53
+ ] });
54
+ }
55
+ export { RowBody };
@@ -105,4 +105,18 @@ function Spaces(props) {
105
105
  }) : null
106
106
  }, `${gap.widget}-gap`))] });
107
107
  }
108
- export { Spaces, ghostPlaces };
108
+ /**
109
+ * The outline where a dragged tile will land, and where one moved by the keyboard is now, said
110
+ * to a screen reader (`arrange` writes it).
111
+ */
112
+ function Drop({ at }) {
113
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
114
+ className: "dd-placed dd-sr",
115
+ role: "status"
116
+ }), at === void 0 ? null : /* @__PURE__ */ jsx("div", {
117
+ className: "dd-drop",
118
+ "aria-hidden": "true",
119
+ style: placeOf(at)
120
+ })] });
121
+ }
122
+ export { Drop, Spaces, ghostPlaces };
@@ -11,10 +11,12 @@ type Props = {
11
11
  actions?: ReactNode;
12
12
  /** What changed about it, beside its title: New, Edited, Moved, or a preview's mark. */
13
13
  badge?: ReactNode;
14
+ /** The span most tiles cover (`spanKey`), said once for the dashboard, not on each tile. */
15
+ sharedSpan?: string | undefined;
14
16
  };
15
17
  /**
16
18
  * One widget: its title, then its answer, a refusal, or an empty state; and the rows behind it
17
- * on request. It draws again only when one of its props changes.
19
+ * on request (Rows opens its drill on Items). It draws again only when one of its props changes.
18
20
  */
19
21
  export declare const Tile: import("react").MemoExoticComponent<(props: Props) => import("react").JSX.Element>;
20
22
  export {};
@@ -1,12 +1,13 @@
1
1
  import { useDashboards } from "./context.mjs";
2
- import { RecordsPanel } from "./Records.mjs";
3
- import { memo, useState } from "react";
2
+ import { useTileDrill } from "./drill/host.mjs";
3
+ import { formatInstantAt } from "./format.mjs";
4
+ import { memo } from "react";
4
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
6
  // src/Tile.tsx
6
7
  /** Refusals that last only until the dashboard is read again, never shown as errors. */
7
8
  const PASSING = /* @__PURE__ */ new Set(["VERSION_CONFLICT", "TILE_UNKNOWN"]);
8
9
  /** The answer's state when there is nothing to draw yet or instead: waiting, refused, unreadable, empty. */
9
- function TileState({ result, loading }) {
10
+ function TileState({ result, loading, empty }) {
10
11
  const { messages } = useDashboards();
11
12
  if (result === void 0 || "error" in result && PASSING.has(result.error.code)) {
12
13
  const busy = result !== void 0 || loading;
@@ -31,24 +32,30 @@ function TileState({ result, loading }) {
31
32
  });
32
33
  return /* @__PURE__ */ jsx("div", {
33
34
  className: "dd-tile-state",
34
- children: messages.noData
35
+ children: empty
35
36
  });
36
37
  }
37
38
  /** Whether an answer has rows to draw. */
38
39
  const drawable = (result) => result !== void 0 && !("error" in result) && result.unreadable !== true && result.rows.length > 0;
39
40
  /** The answer drawn: a memo of its own, so a change to the tile's buttons or badge never draws the chart again. */
40
- const Body = memo(function Body({ widget, result, loading }) {
41
- const { renderers, locale, messages } = useDashboards();
42
- if (!drawable(result)) return /* @__PURE__ */ jsx(TileState, {
43
- result,
44
- loading
45
- });
46
- const Renderer = renderers[widget.kind] ?? renderers["table"];
41
+ const Body = memo(function Body({ widget, result, loading, drill }) {
42
+ const { renderers, locale, messages, link } = useDashboards();
43
+ if (!drawable(result)) {
44
+ const empty = widget.display?.empty;
45
+ return /* @__PURE__ */ jsx(TileState, {
46
+ result,
47
+ loading,
48
+ empty: typeof empty === "string" ? empty : messages.noData
49
+ });
50
+ }
51
+ const Renderer = renderers[widget.kind] ?? renderers.table;
47
52
  return Renderer === void 0 ? null : /* @__PURE__ */ jsx(Renderer, {
48
53
  answer: result,
49
54
  widget,
50
55
  messages,
51
- ...locale === void 0 ? {} : { locale }
56
+ ...locale === void 0 ? {} : { locale },
57
+ ...drill === void 0 ? {} : { drill },
58
+ ...link === void 0 ? {} : { link }
52
59
  });
53
60
  });
54
61
  /** Notes under a tile: a viewer's filter that could not apply, or an answer cut at the row cap. */
@@ -56,27 +63,73 @@ function Notes({ result, controlLabels }) {
56
63
  const { messages } = useDashboards();
57
64
  if (result === void 0 || "error" in result) return null;
58
65
  const dropped = result.receipt.coverage.dropped.map((id) => controlLabels?.get(id) ?? id);
59
- return /* @__PURE__ */ jsxs(Fragment, { children: [dropped.length === 0 ? null : /* @__PURE__ */ jsx("p", {
60
- className: "dd-tile-note",
61
- children: messages.notFilteredBy(dropped)
62
- }), result.status === "truncated" ? /* @__PURE__ */ jsx("p", {
63
- className: "dd-tile-note",
64
- children: messages.firstRows(result.rows.length)
65
- }) : null] });
66
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
67
+ dropped.length === 0 ? null : /* @__PURE__ */ jsx("p", {
68
+ className: "dd-tile-note",
69
+ children: messages.notFilteredBy(dropped)
70
+ }),
71
+ result.status === "truncated" ? /* @__PURE__ */ jsx("p", {
72
+ className: "dd-tile-note",
73
+ children: messages.firstRows(result.rows.length)
74
+ }) : null,
75
+ result.drill?.reason === void 0 ? null : /* @__PURE__ */ jsx("p", {
76
+ className: "dd-tile-note",
77
+ children: messages.drillCut
78
+ })
79
+ ] });
66
80
  }
67
81
  /** Whether a tile has rows behind it to show: an answer the viewer can read. */
68
82
  const hasRows = (result) => result !== void 0 && !("error" in result) && result.unreadable !== true && result.rows.length > 0;
83
+ /** The time a tile's answer covers, as a key two tiles share when they cover the same days. */
84
+ const spanKey = (result) => {
85
+ if (result === void 0 || "error" in result) return void 0;
86
+ const range = result.receipt.range;
87
+ return range === void 0 ? void 0 : `${range.from}|${range.to}`;
88
+ };
89
+ /**
90
+ * The time a tile's answer covers, as it read it ("Oct 15 to Nov 14"), so a reader knows its
91
+ * window. A tile covering the span most tiles do leaves it to the dashboard, which says it once.
92
+ */
93
+ function Span({ result, shared }) {
94
+ const format = useDashboards();
95
+ if (result === void 0 || "error" in result) return null;
96
+ const range = result.receipt.range;
97
+ if (range === void 0 || shared !== void 0 && spanKey(result) === shared) return null;
98
+ const zone = result.receipt.calendar.timezone;
99
+ const day = (at) => formatInstantAt(at, "day", format.locale, zone);
100
+ return /* @__PURE__ */ jsx("p", {
101
+ className: "dd-tile-span",
102
+ children: format.messages.drillRange(day(range.from), day(range.to))
103
+ });
104
+ }
105
+ /**
106
+ * The span most of the tiles cover, when at least two do and they are most of them: the
107
+ * dashboard says it once and those tiles leave it out. None when the tiles disagree.
108
+ */
109
+ function sharedSpan(results) {
110
+ const counts = /* @__PURE__ */ new Map();
111
+ let spans = 0;
112
+ for (const result of results.values()) {
113
+ const key = spanKey(result);
114
+ if (key === void 0) continue;
115
+ spans += 1;
116
+ counts.set(key, (counts.get(key) ?? 0) + 1);
117
+ }
118
+ const [top] = [...counts].toSorted((a, b) => b[1] - a[1]);
119
+ return top !== void 0 && top[1] >= 2 && top[1] * 2 > spans ? top[0] : void 0;
120
+ }
69
121
  /**
70
122
  * One widget: its title, then its answer, a refusal, or an empty state; and the rows behind it
71
- * on request. It draws again only when one of its props changes.
123
+ * on request (Rows opens its drill on Items). It draws again only when one of its props changes.
72
124
  */
73
125
  const Tile = memo(function Tile(props) {
74
126
  const { messages } = useDashboards();
75
- const [open, setOpen] = useState(false);
127
+ const drill = useTileDrill(props.widgetId, props.result);
76
128
  return /* @__PURE__ */ jsxs("section", {
77
129
  className: "dd-tile",
78
130
  "aria-busy": props.loading,
79
131
  "data-kind": props.widget.kind,
132
+ "data-widget": props.widgetId,
80
133
  children: [
81
134
  /* @__PURE__ */ jsxs("header", {
82
135
  className: "dd-tile-header",
@@ -84,40 +137,39 @@ const Tile = memo(function Tile(props) {
84
137
  /* @__PURE__ */ jsx("h3", {
85
138
  className: "dd-tile-title",
86
139
  title: props.widget.title,
140
+ tabIndex: -1,
87
141
  children: props.widget.title
88
142
  }),
89
143
  props.badge,
90
144
  /* @__PURE__ */ jsxs("span", {
91
145
  className: "dd-tile-actions",
92
- children: [hasRows(props.result) ? /* @__PURE__ */ jsx("button", {
146
+ children: [hasRows(props.result) && drill !== void 0 ? /* @__PURE__ */ jsx("button", {
93
147
  type: "button",
94
148
  className: "dd-tile-rows",
95
149
  "aria-label": messages.rowsBehind(props.widget.title),
96
150
  onClick: () => {
97
- setOpen(true);
151
+ drill.openAll();
98
152
  },
99
153
  children: messages.rows
100
154
  }) : null, props.actions]
101
155
  })
102
156
  ]
103
157
  }),
104
- open ? /* @__PURE__ */ jsx(RecordsPanel, {
105
- widgetId: props.widgetId,
106
- widget: props.widget,
107
- onClose: () => {
108
- setOpen(false);
109
- }
110
- }) : null,
158
+ /* @__PURE__ */ jsx(Span, {
159
+ result: props.result,
160
+ shared: props.sharedSpan
161
+ }),
111
162
  /* @__PURE__ */ jsx("div", {
112
163
  className: "dd-tile-body",
113
164
  children: /* @__PURE__ */ jsx(Body, {
114
165
  widget: props.widget,
115
166
  result: props.result,
116
- loading: props.result === void 0 && props.loading
167
+ loading: props.result === void 0 && props.loading,
168
+ drill
117
169
  })
118
170
  }),
119
171
  /* @__PURE__ */ jsx(Notes, { ...props })
120
172
  ]
121
173
  });
122
174
  });
123
- export { Tile };
175
+ export { Span, Tile, sharedSpan, spanKey };
@@ -0,0 +1,12 @@
1
+ // \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ export { __exportAll };
@@ -39,41 +39,44 @@ function stepOf(grid) {
39
39
  y: row + rowGap
40
40
  };
41
41
  }
42
- /** The smallest a person can resize a tile to: room for its title, its buttons and a number. */
43
- const SMALLEST = {
44
- w: 2,
45
- h: 2
46
- };
47
42
  /**
48
43
  * The item moved or resized by whole cells: a move keeps the size; a resize keeps the top left,
49
- * stops at the grid's edge, and never makes a tile smaller than it can be read (one already
50
- * smaller stays as it is).
44
+ * stops at the grid's edge, and never makes a tile smaller than its kind reads at (core's
45
+ * `smallestFor`; one already smaller stays as it is).
51
46
  */
52
- function shifted(item, mode, dx, dy) {
47
+ function shifted(item, how, by) {
48
+ const { mode, least } = how;
49
+ const { dx, dy } = by;
53
50
  return mode === "move" ? {
54
51
  ...item,
55
52
  x: Math.max(0, item.x + dx),
56
53
  y: Math.max(0, item.y + dy)
57
54
  } : {
58
55
  ...item,
59
- w: Math.min(Math.max(Math.min(SMALLEST.w, item.w), item.w + dx), GRID_COLUMNS - item.x),
60
- h: Math.max(Math.min(SMALLEST.h, item.h), item.h + dy)
56
+ w: Math.min(Math.max(Math.min(least.w, item.w), item.w + dx), GRID_COLUMNS - item.x),
57
+ h: Math.max(Math.min(least.h, item.h), item.h + dy)
61
58
  };
62
59
  }
63
60
  /** Where a drag puts the item: whole cells from where the pointer went down. */
64
61
  function dragged(d, event) {
65
62
  const dx = Math.round((event.clientX - d.x0) / d.step.x);
66
63
  const dy = Math.round((event.clientY - d.y0) / d.step.y);
67
- return shifted(d.start, d.mode, dx, dy);
64
+ return shifted(d.start, d, {
65
+ dx,
66
+ dy
67
+ });
68
68
  }
69
69
  /**
70
70
  * One arrow key's move: the nearest place in that direction where the layout really changes,
71
71
  * so moving down past a tile takes one press, not as many as it is tall.
72
72
  */
73
- function nextStep(tab, item, mode, key) {
73
+ function nextStep(tab, item, how, key) {
74
74
  const before = JSON.stringify(placeItem(tab.layout, item));
75
75
  for (let n = 1; n <= 48; n += 1) {
76
- const next = shifted(item, mode, key.dx * n, key.dy * n);
76
+ const next = shifted(item, how, {
77
+ dx: key.dx * n,
78
+ dy: key.dy * n
79
+ });
77
80
  if (JSON.stringify(placeItem(tab.layout, next)) !== before) return next;
78
81
  }
79
82
  return item;
@@ -2,7 +2,7 @@ import { KEYS, commit, dragged, follow, nextStep, same, stepOf } from "./arrange
2
2
  import { useDashboards } from "./context.mjs";
3
3
  import { useStable } from "./stable.mjs";
4
4
  import { useMemo, useRef, useState } from "react";
5
- import { placeItem } from "derive-dashboards/core";
5
+ import { placeItem, smallestFor } from "derive-dashboards/core";
6
6
  // src/arrange.ts
7
7
  /**
8
8
  * A preview that only changes when its place does: a pointer moving inside one grid cell
@@ -25,12 +25,18 @@ function usePreview() {
25
25
  show: useStable(show)
26
26
  };
27
27
  }
28
+ /** The smallest the tile's kind reads at, from the draft's own widget. */
29
+ const leastOf = (a, item) => smallestFor(a.edit().draft?.doc.widgets[item.widget]?.kind);
28
30
  /** An arrow key on a handle: a cell's move (or with Shift, a resize), then where the tile is now. */
29
31
  const onKey = (a, send, item, mode) => (event) => {
30
32
  const key = KEYS[event.key];
31
33
  if (key === void 0 || a.edit().busy) return;
32
34
  event.preventDefault();
33
- const wanted = nextStep(a.tab(), item, event.shiftKey ? "resize" : mode, key);
35
+ const how = {
36
+ mode: event.shiftKey ? "resize" : mode,
37
+ least: leastOf(a, item)
38
+ };
39
+ const wanted = nextStep(a.tab(), item, how, key);
34
40
  const said = async () => {
35
41
  await send(wanted);
36
42
  requestAnimationFrame(() => {
@@ -67,7 +73,8 @@ function handlers(a, drag, show) {
67
73
  last: {
68
74
  clientX: x0,
69
75
  clientY: y0
70
- }
76
+ },
77
+ least: leastOf(a, item)
71
78
  };
72
79
  show(item, mode === "move" ? item : void 0);
73
80
  },