@arbidocs/blocks 0.5.151 → 0.5.153

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 (153) hide show
  1. package/dist/{ConnectedNativeDocxComparison-JLT3VHYQ.cjs → ConnectedNativeDocxComparison-244UIHSM.cjs} +9 -9
  2. package/dist/{ConnectedStreamedWordArtifact-KWK6HLCZ.cjs.map → ConnectedNativeDocxComparison-244UIHSM.cjs.map} +1 -1
  3. package/dist/{ConnectedPresentation-SY42ADRU.cjs → ConnectedPresentation-JUXIXKYN.cjs} +9 -8
  4. package/dist/ConnectedPresentation-JUXIXKYN.cjs.map +1 -0
  5. package/dist/{ConnectedSlidesTab-JATNBI22.cjs → ConnectedSlidesTab-JA3VB66W.cjs} +8 -7
  6. package/dist/ConnectedSlidesTab-JA3VB66W.cjs.map +1 -0
  7. package/dist/{ConnectedStreamedWordArtifact-KWK6HLCZ.cjs → ConnectedStreamedWordArtifact-V6BRZMEQ.cjs} +9 -9
  8. package/dist/{ConnectedNativeDocxComparison-JLT3VHYQ.cjs.map → ConnectedStreamedWordArtifact-V6BRZMEQ.cjs.map} +1 -1
  9. package/dist/{DocumentReviewCard-USFBTVEL.cjs → DocumentReviewCard-5W2QQWKA.cjs} +14 -14
  10. package/dist/{DocumentReviewCard-USFBTVEL.cjs.map → DocumentReviewCard-5W2QQWKA.cjs.map} +1 -1
  11. package/dist/{FilesViewerDialog-O4CY7GM3.cjs → FilesViewerDialog-63QUTG4L.cjs} +12 -12
  12. package/dist/{FilesViewerDialog-O4CY7GM3.cjs.map → FilesViewerDialog-63QUTG4L.cjs.map} +1 -1
  13. package/dist/{RechartsRenderer-NRLQZSSY.cjs → RechartsRenderer-NU6WUZJS.cjs} +21 -20
  14. package/dist/RechartsRenderer-NU6WUZJS.cjs.map +1 -0
  15. package/dist/{SpotlightStrip-QQ2WUI32.cjs → SpotlightStrip-HXQFPAAL.cjs} +6 -5
  16. package/dist/SpotlightStrip-HXQFPAAL.cjs.map +1 -0
  17. package/dist/agents/index.cjs +179 -179
  18. package/dist/{chunk-3XCYPWC5.cjs → chunk-2P7VH2SK.cjs} +3 -3
  19. package/dist/chunk-2P7VH2SK.cjs.map +1 -0
  20. package/dist/{chunk-7Q46YAX4.cjs → chunk-3CJTO6RV.cjs} +152 -199
  21. package/dist/chunk-3CJTO6RV.cjs.map +1 -0
  22. package/dist/{chunk-PJTKXKDS.cjs → chunk-4I2PCP7O.cjs} +28 -28
  23. package/dist/{chunk-PJTKXKDS.cjs.map → chunk-4I2PCP7O.cjs.map} +1 -1
  24. package/dist/{chunk-OGJCEWME.cjs → chunk-4XNP27N4.cjs} +36 -36
  25. package/dist/{chunk-OGJCEWME.cjs.map → chunk-4XNP27N4.cjs.map} +1 -1
  26. package/dist/{chunk-2SILSQNF.cjs → chunk-4ZR4O5SP.cjs} +26 -8
  27. package/dist/chunk-4ZR4O5SP.cjs.map +1 -0
  28. package/dist/{chunk-ILATBO5Z.cjs → chunk-6ZZWQ3OL.cjs} +4 -4
  29. package/dist/{chunk-ILATBO5Z.cjs.map → chunk-6ZZWQ3OL.cjs.map} +1 -1
  30. package/dist/{chunk-VH4QXK5W.cjs → chunk-AG6KAGAX.cjs} +4 -4
  31. package/dist/{chunk-VH4QXK5W.cjs.map → chunk-AG6KAGAX.cjs.map} +1 -1
  32. package/dist/{chunk-MFZW4FEW.cjs → chunk-B5BGVPQ5.cjs} +4 -4
  33. package/dist/{chunk-MFZW4FEW.cjs.map → chunk-B5BGVPQ5.cjs.map} +1 -1
  34. package/dist/{chunk-PJ6J4EMZ.cjs → chunk-CULUTYOD.cjs} +4 -4
  35. package/dist/{chunk-PJ6J4EMZ.cjs.map → chunk-CULUTYOD.cjs.map} +1 -1
  36. package/dist/{chunk-H7AI54V2.cjs → chunk-CVVQHFLR.cjs} +3 -3
  37. package/dist/{chunk-H7AI54V2.cjs.map → chunk-CVVQHFLR.cjs.map} +1 -1
  38. package/dist/{chunk-R3C3S6EH.cjs → chunk-D5DOK2AE.cjs} +58 -58
  39. package/dist/{chunk-R3C3S6EH.cjs.map → chunk-D5DOK2AE.cjs.map} +1 -1
  40. package/dist/{chunk-MH7P5FEK.cjs → chunk-FCT62ZPE.cjs} +4 -4
  41. package/dist/{chunk-MH7P5FEK.cjs.map → chunk-FCT62ZPE.cjs.map} +1 -1
  42. package/dist/{chunk-QX2LAMVE.cjs → chunk-IXTDOPSB.cjs} +4 -4
  43. package/dist/{chunk-QX2LAMVE.cjs.map → chunk-IXTDOPSB.cjs.map} +1 -1
  44. package/dist/{chunk-AKR4JN6I.cjs → chunk-JCFXS336.cjs} +3 -3
  45. package/dist/{chunk-AKR4JN6I.cjs.map → chunk-JCFXS336.cjs.map} +1 -1
  46. package/dist/{chunk-N4TOSY7B.cjs → chunk-JLNKD56X.cjs} +4 -4
  47. package/dist/{chunk-N4TOSY7B.cjs.map → chunk-JLNKD56X.cjs.map} +1 -1
  48. package/dist/{chunk-DNTSR7UV.cjs → chunk-LYKT336H.cjs} +5 -5
  49. package/dist/{chunk-DNTSR7UV.cjs.map → chunk-LYKT336H.cjs.map} +1 -1
  50. package/dist/{chunk-MGGDT6JK.cjs → chunk-MAKCWF45.cjs} +4 -4
  51. package/dist/{chunk-MGGDT6JK.cjs.map → chunk-MAKCWF45.cjs.map} +1 -1
  52. package/dist/{chunk-DGUQK5GA.cjs → chunk-TFRCNIUY.cjs} +6 -6
  53. package/dist/{chunk-DGUQK5GA.cjs.map → chunk-TFRCNIUY.cjs.map} +1 -1
  54. package/dist/chunk-UM3EWCDE.cjs +105 -0
  55. package/dist/chunk-UM3EWCDE.cjs.map +1 -0
  56. package/dist/{chunk-WPUEGDBE.cjs → chunk-WUM76MJU.cjs} +6 -6
  57. package/dist/{chunk-WPUEGDBE.cjs.map → chunk-WUM76MJU.cjs.map} +1 -1
  58. package/dist/{chunk-6WWYH66F.cjs → chunk-Z3N32LL4.cjs} +8 -8
  59. package/dist/{chunk-6WWYH66F.cjs.map → chunk-Z3N32LL4.cjs.map} +1 -1
  60. package/dist/{chunk-JMBAUHI7.cjs → chunk-ZCQXQIBA.cjs} +28 -28
  61. package/dist/{chunk-JMBAUHI7.cjs.map → chunk-ZCQXQIBA.cjs.map} +1 -1
  62. package/dist/components/MetricCard.js +1 -1
  63. package/dist/components/MetricCard.js.map +2 -2
  64. package/dist/components/gestures/GestureHandle.d.ts +21 -0
  65. package/dist/components/gestures/GestureHandle.js +44 -0
  66. package/dist/components/gestures/GestureHandle.js.map +7 -0
  67. package/dist/components/gestures/handles.d.ts +43 -0
  68. package/dist/components/gestures/handles.js +18 -0
  69. package/dist/components/gestures/handles.js.map +7 -0
  70. package/dist/components/gestures/index.d.ts +3 -0
  71. package/dist/components/gestures/index.js +5 -0
  72. package/dist/components/gestures/index.js.map +7 -0
  73. package/dist/components/gestures/usePointerGesture.d.ts +51 -0
  74. package/dist/components/gestures/usePointerGesture.js +61 -0
  75. package/dist/components/gestures/usePointerGesture.js.map +7 -0
  76. package/dist/connect/docx.cjs +12 -12
  77. package/dist/connect/index.cjs +651 -628
  78. package/dist/connect/index.cjs.map +1 -1
  79. package/dist/connect/viewer.cjs +10 -10
  80. package/dist/connection/dashboards/DashboardPanel.js +6 -1
  81. package/dist/connection/dashboards/DashboardPanel.js.map +2 -2
  82. package/dist/connection/pages/BlockEditor.d.ts +0 -5
  83. package/dist/connection/pages/BlockEditor.js +3 -65
  84. package/dist/connection/pages/BlockEditor.js.map +2 -2
  85. package/dist/connection/pages/ConnectedPagesPage.d.ts +4 -1
  86. package/dist/connection/pages/ConnectedPagesPage.js +52 -71
  87. package/dist/connection/pages/ConnectedPagesPage.js.map +2 -2
  88. package/dist/connection/pages/DocumentBlocks.js +3 -3
  89. package/dist/connection/pages/DocumentBlocks.js.map +2 -2
  90. package/dist/connection/pages/DocumentsPicker.js +1 -1
  91. package/dist/connection/pages/DocumentsPicker.js.map +2 -2
  92. package/dist/connection/pages/EditablePageGrid.d.ts +31 -0
  93. package/dist/connection/pages/EditablePageGrid.js +200 -0
  94. package/dist/connection/pages/EditablePageGrid.js.map +7 -0
  95. package/dist/connection/pages/PageGrid.d.ts +7 -4
  96. package/dist/connection/pages/PageGrid.js +9 -3
  97. package/dist/connection/pages/PageGrid.js.map +2 -2
  98. package/dist/connection/pages/TableViewBlock.d.ts +5 -4
  99. package/dist/connection/pages/TableViewBlock.js +20 -20
  100. package/dist/connection/pages/TableViewBlock.js.map +2 -2
  101. package/dist/connection/pages/grid-layout.d.ts +38 -0
  102. package/dist/connection/pages/grid-layout.js +98 -0
  103. package/dist/connection/pages/grid-layout.js.map +7 -0
  104. package/dist/connection/pages/index.d.ts +2 -0
  105. package/dist/connection/pages/index.js +19 -1
  106. package/dist/connection/pages/index.js.map +2 -2
  107. package/dist/connection/pages/labels.d.ts +0 -2
  108. package/dist/connection/pages/labels.js +0 -2
  109. package/dist/connection/pages/labels.js.map +2 -2
  110. package/dist/connection/shell/experimentalNav.d.ts +8 -0
  111. package/dist/connection/shell/experimentalNav.js +23 -0
  112. package/dist/connection/shell/experimentalNav.js.map +7 -0
  113. package/dist/connection/storage/ConnectedStorageProjectCard.js +1 -1
  114. package/dist/connection/storage/ConnectedStorageProjectCard.js.map +2 -2
  115. package/dist/connection/storage/ConnectedWorkspaceTrash.d.ts +3 -0
  116. package/dist/connection/storage/ConnectedWorkspaceTrash.js +41 -17
  117. package/dist/connection/storage/ConnectedWorkspaceTrash.js.map +2 -2
  118. package/dist/dashboards/ChartRenderer.d.ts +6 -0
  119. package/dist/dashboards/ChartRenderer.js +7 -2
  120. package/dist/dashboards/ChartRenderer.js.map +2 -2
  121. package/dist/dashboards/PanelView.d.ts +2 -0
  122. package/dist/dashboards/PanelView.js +12 -2
  123. package/dist/dashboards/PanelView.js.map +2 -2
  124. package/dist/dashboards/RechartsRenderer.js +19 -18
  125. package/dist/dashboards/RechartsRenderer.js.map +2 -2
  126. package/dist/dashboards/index.cjs +16 -16
  127. package/dist/embed/index.cjs +13 -13
  128. package/dist/facts/index.cjs +1 -1
  129. package/dist/files/index.cjs +226 -226
  130. package/dist/index.cjs +338 -320
  131. package/dist/index.cjs.map +1 -1
  132. package/dist/index.d.ts +1 -0
  133. package/dist/index.js +3 -0
  134. package/dist/index.js.map +2 -2
  135. package/dist/pages/index.cjs +404 -199
  136. package/dist/pages/index.cjs.map +1 -1
  137. package/dist/presentation/StageBox.js +63 -86
  138. package/dist/presentation/StageBox.js.map +2 -2
  139. package/dist/presentation/StageItem.js +86 -117
  140. package/dist/presentation/StageItem.js.map +2 -2
  141. package/dist/site/index.cjs +5 -5
  142. package/dist/studio/index.cjs +13 -13
  143. package/dist/styles.css +1 -1
  144. package/dist/workflow-canvas/index.cjs +25 -25
  145. package/node_modules/@arbidocs/coedit/package.json +1 -1
  146. package/package.json +5 -5
  147. package/dist/ConnectedPresentation-SY42ADRU.cjs.map +0 -1
  148. package/dist/ConnectedSlidesTab-JATNBI22.cjs.map +0 -1
  149. package/dist/RechartsRenderer-NRLQZSSY.cjs.map +0 -1
  150. package/dist/SpotlightStrip-QQ2WUI32.cjs.map +0 -1
  151. package/dist/chunk-2SILSQNF.cjs.map +0 -1
  152. package/dist/chunk-3XCYPWC5.cjs.map +0 -1
  153. package/dist/chunk-7Q46YAX4.cjs.map +0 -1
@@ -1,15 +1,16 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkDNTSR7UV_cjs = require('../chunk-DNTSR7UV.cjs');
4
+ var chunkUM3EWCDE_cjs = require('../chunk-UM3EWCDE.cjs');
5
+ var chunkDLGYR4JL_cjs = require('../chunk-DLGYR4JL.cjs');
6
+ var chunkLYKT336H_cjs = require('../chunk-LYKT336H.cjs');
5
7
  var chunkKRQCUVH7_cjs = require('../chunk-KRQCUVH7.cjs');
6
- var chunk2SILSQNF_cjs = require('../chunk-2SILSQNF.cjs');
8
+ var chunk4ZR4O5SP_cjs = require('../chunk-4ZR4O5SP.cjs');
7
9
  require('../chunk-PBPO54KZ.cjs');
8
- var chunkDLGYR4JL_cjs = require('../chunk-DLGYR4JL.cjs');
9
10
  var chunkQ25CZLK6_cjs = require('../chunk-Q25CZLK6.cjs');
10
11
  require('../chunk-MWHVETKN.cjs');
11
12
  var chunkNSD37OF5_cjs = require('../chunk-NSD37OF5.cjs');
12
- require('../chunk-3XCYPWC5.cjs');
13
+ require('../chunk-2P7VH2SK.cjs');
13
14
  require('../chunk-ZU2B2RZK.cjs');
14
15
  require('../chunk-YA6GXWC2.cjs');
15
16
  require('../chunk-ZVEW3JBT.cjs');
@@ -84,7 +85,7 @@ function DocumentsPicker({
84
85
  "data-testid": `${testId}-search`
85
86
  }
86
87
  ),
87
- documents.isLoading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: l.loading }) : found.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: l.none }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "max-h-56 overflow-y-auto rounded-md border", role: "listbox", children: found.map((d) => {
88
+ documents.isLoading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: l.loading }) : found.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: l.none }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "max-h-56 overflow-y-auto rounded-md border border-border", role: "listbox", children: found.map((d) => {
88
89
  const blocked = sharedOnly && !d.shared;
89
90
  const chosen = value.includes(d.external_id);
90
91
  return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -204,43 +205,12 @@ function ViewPicker({
204
205
  }
205
206
  var DEFAULT_BLOCK_EDITOR_LABELS = {
206
207
  title: "Block",
207
- description: "Choose what the block shows and its size on the page.",
208
+ description: "Choose what the block shows. Drag it on the page to place and size it.",
208
209
  text: "Text (Markdown)",
209
210
  view: "Table view",
210
- width: "Width",
211
- height: "Height",
212
- columns: (n) => n === react.PAGE_GRID_COLUMNS ? "Full width" : n === 6 ? "Half" : `${n} of ${react.PAGE_GRID_COLUMNS} columns`,
213
- rows: (n) => `${n} ${n === 1 ? "row" : "rows"}`,
214
211
  cancel: "Cancel",
215
212
  done: "Done"
216
213
  };
217
- var WIDTHS = [3, 4, 6, 8, 9, 12];
218
- var HEIGHTS = [1, 2, 3, 4, 5, 6, 8, 10, 12];
219
- function SizeSelect({
220
- id,
221
- label,
222
- value,
223
- options,
224
- format,
225
- onChange,
226
- testId
227
- }) {
228
- const all = options.includes(value) ? options : [...options, value].sort((a, b) => a - b);
229
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
230
- /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { htmlFor: id, children: label }),
231
- /* @__PURE__ */ jsxRuntime.jsx(
232
- "select",
233
- {
234
- id,
235
- className: "h-9 rounded-md border border-input bg-background px-2 text-sm",
236
- value,
237
- onChange: (e) => onChange(Number(e.target.value)),
238
- "data-testid": testId,
239
- children: all.map((n) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: n, children: format(n) }, n))
240
- }
241
- )
242
- ] });
243
- }
244
214
  function BlockEditor({
245
215
  block,
246
216
  shared,
@@ -255,7 +225,6 @@ function BlockEditor({
255
225
  const l = { ...DEFAULT_BLOCK_EDITOR_LABELS, ...labels };
256
226
  const [value, setValue] = react$1.useState(block);
257
227
  react$1.useEffect(() => setValue(block), [block]);
258
- const setLayout = (patch) => setValue((b) => b ? { ...b, layout: { ...b.layout, ...patch } } : b);
259
228
  const setPanel = (panel) => setValue((b) => b ? { ...react.blockOfPanel(panel, b.layout.h), layout: b.layout } : b);
260
229
  const ready = !!value && (value.kind === "table" ? !!value.config.view : value.kind === "document" ? !!value.config.document : value.kind === "gallery" ? value.config.documents.length > 0 : true);
261
230
  return /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { open: block !== null, onOpenChange: (open) => !open && onCancel(), children: /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogContent, { className: "max-h-[90dvh] max-w-5xl overflow-y-auto", "data-testid": testId, children: [
@@ -265,7 +234,7 @@ function BlockEditor({
265
234
  ] }),
266
235
  value && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
267
236
  (value.kind === "chart" || value.kind === "metric") && /* @__PURE__ */ jsxRuntime.jsx(
268
- chunkDNTSR7UV_cjs.PanelEditor,
237
+ chunkLYKT336H_cjs.PanelEditor,
269
238
  {
270
239
  value: react.panelOfBlock(value),
271
240
  onChange: setPanel,
@@ -308,33 +277,7 @@ function BlockEditor({
308
277
  labels: documentsLabels,
309
278
  testId: `${testId}-documents`
310
279
  }
311
- ),
312
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [
313
- /* @__PURE__ */ jsxRuntime.jsx(
314
- SizeSelect,
315
- {
316
- id: `${testId}-width`,
317
- label: l.width,
318
- value: value.layout.w,
319
- options: WIDTHS,
320
- format: l.columns,
321
- onChange: (w) => setLayout({ w }),
322
- testId: `${testId}-width`
323
- }
324
- ),
325
- /* @__PURE__ */ jsxRuntime.jsx(
326
- SizeSelect,
327
- {
328
- id: `${testId}-height`,
329
- label: l.height,
330
- value: value.layout.h,
331
- options: HEIGHTS,
332
- format: l.rows,
333
- onChange: (h) => setLayout({ h }),
334
- testId: `${testId}-height`
335
- }
336
- )
337
- ] })
280
+ )
338
281
  ] }),
339
282
  /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogFooter, { children: [
340
283
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "ghost", onClick: onCancel, children: l.cancel }),
@@ -350,6 +293,324 @@ function BlockEditor({
350
293
  ] })
351
294
  ] }) });
352
295
  }
296
+ var MIN_BLOCK_SIZE = {
297
+ metric: { w: 2, h: react.DEFAULT_BLOCK_HEIGHT.metric },
298
+ text: { w: 2, h: react.DEFAULT_BLOCK_HEIGHT.text },
299
+ chart: { w: 3, h: react.DEFAULT_BLOCK_HEIGHT.chart },
300
+ table: { w: 4, h: react.DEFAULT_BLOCK_HEIGHT.table },
301
+ document: { w: 3, h: react.DEFAULT_BLOCK_HEIGHT.document },
302
+ gallery: { w: 3, h: react.DEFAULT_BLOCK_HEIGHT.gallery }
303
+ };
304
+ var overlaps = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
305
+ var clampInt = (n, lo, hi) => Math.min(hi, Math.max(lo, Math.round(n)));
306
+ function compactLayout(items, pinned) {
307
+ const placed = [];
308
+ const out = /* @__PURE__ */ new Map();
309
+ const fixed = items.find((i) => i.id === pinned);
310
+ if (fixed) {
311
+ placed.push(fixed.layout);
312
+ out.set(fixed.id, fixed);
313
+ }
314
+ const order = items.filter((i) => i.id !== pinned).sort((a, b) => a.layout.y - b.layout.y || a.layout.x - b.layout.x);
315
+ for (const item of order) {
316
+ const layout = { ...item.layout };
317
+ while (placed.some((p) => overlaps(p, layout))) layout.y += 1;
318
+ while (layout.y > 0 && !placed.some((p) => overlaps(p, { ...layout, y: layout.y - 1 })))
319
+ layout.y -= 1;
320
+ placed.push(layout);
321
+ out.set(item.id, { ...item, layout });
322
+ }
323
+ return items.map((i) => out.get(i.id) ?? i);
324
+ }
325
+ function pushAway(items, mover) {
326
+ let next = items;
327
+ const others = () => next.filter((i) => i.id !== mover.id);
328
+ for (const hit of others().sort((a, b) => a.layout.y - b.layout.y)) {
329
+ const current = next.find((i) => i.id === hit.id);
330
+ if (!current || !overlaps(current.layout, mover.layout)) continue;
331
+ const above = { ...current.layout, y: mover.layout.y - current.layout.h };
332
+ const fitsAbove = above.y >= 0 && !next.some((i) => i.id !== current.id && overlaps(i.layout, above));
333
+ const layout = fitsAbove ? above : { ...current.layout, y: mover.layout.y + mover.layout.h };
334
+ const moved = { ...current, layout };
335
+ next = next.map((i) => i.id === moved.id ? moved : i);
336
+ if (!fitsAbove) next = pushAway(next, moved).map((i) => i.id === mover.id ? mover : i);
337
+ }
338
+ return next;
339
+ }
340
+ function place(items, id, layout) {
341
+ const mover = items.find((i) => i.id === id);
342
+ if (!mover) return [...items];
343
+ const moved = { ...mover, layout };
344
+ return pushAway(
345
+ items.map((i) => i.id === id ? moved : i),
346
+ moved
347
+ );
348
+ }
349
+ function moveBlock(items, id, to, settle = true) {
350
+ const item = items.find((i) => i.id === id);
351
+ if (!item) return [...items];
352
+ const layout = {
353
+ ...item.layout,
354
+ x: clampInt(to.x, 0, react.PAGE_GRID_COLUMNS - item.layout.w),
355
+ y: Math.max(0, Math.round(to.y))
356
+ };
357
+ const next = compactLayout(place(items, id, layout), id);
358
+ return settle ? compactLayout(next) : next;
359
+ }
360
+ function resizeBlock(items, id, to, settle = true) {
361
+ const item = items.find((i) => i.id === id);
362
+ if (!item) return [...items];
363
+ const min = MIN_BLOCK_SIZE[item.kind];
364
+ const layout = {
365
+ ...item.layout,
366
+ w: clampInt(
367
+ to.w,
368
+ Math.min(min.w, react.PAGE_GRID_COLUMNS - item.layout.x),
369
+ react.PAGE_GRID_COLUMNS - item.layout.x
370
+ ),
371
+ h: Math.max(min.h, Math.round(to.h))
372
+ };
373
+ const next = compactLayout(place(items, id, layout), id);
374
+ return settle ? compactLayout(next) : next;
375
+ }
376
+ function appendBlock(items, item) {
377
+ const bottom = Math.max(0, ...items.map((i) => i.layout.y + i.layout.h));
378
+ const w = clampInt(item.layout.w, 1, react.PAGE_GRID_COLUMNS);
379
+ return compactLayout([...items, { ...item, layout: { ...item.layout, x: 0, y: bottom, w } }]);
380
+ }
381
+ var PAGE_ROW_HEIGHT = "4.5rem";
382
+ function PageGrid({ children, className, testId, gridRef }) {
383
+ return /* @__PURE__ */ jsxRuntime.jsx(
384
+ "div",
385
+ {
386
+ ref: gridRef,
387
+ className: ui.cn("grid grid-cols-1 gap-4 md:grid-cols-12", className),
388
+ style: { gridAutoRows: `minmax(${PAGE_ROW_HEIGHT}, auto)` },
389
+ "data-slot": "page-grid",
390
+ "data-testid": testId,
391
+ children
392
+ }
393
+ );
394
+ }
395
+ function inReadingOrder(blocks) {
396
+ return [...blocks].sort((a, b) => a.layout.y - b.layout.y || a.layout.x - b.layout.x);
397
+ }
398
+ function PageCell({
399
+ layout,
400
+ children,
401
+ className,
402
+ style,
403
+ testId,
404
+ cellRef,
405
+ ...rest
406
+ }) {
407
+ const place2 = {
408
+ "--page-col": `${layout.x + 1} / span ${layout.w}`,
409
+ "--page-row": `${layout.y + 1} / span ${layout.h}`
410
+ };
411
+ return /* @__PURE__ */ jsxRuntime.jsx(
412
+ "div",
413
+ {
414
+ ...rest,
415
+ ref: cellRef,
416
+ className: ui.cn(
417
+ "col-span-1 min-w-0 md:[grid-column:var(--page-col)] md:[grid-row:var(--page-row)]",
418
+ className
419
+ ),
420
+ style: { ...place2, ...style },
421
+ "data-slot": "page-cell",
422
+ "data-testid": testId,
423
+ children
424
+ }
425
+ );
426
+ }
427
+ var DEFAULT_EDITABLE_PAGE_GRID_LABELS = {
428
+ move: "Move the block",
429
+ moveHint: "Drag to move. Arrow keys move it; Shift and the arrow keys resize it.",
430
+ resize: "Resize the block"
431
+ };
432
+ var RESIZE_HANDLES = [
433
+ { kind: "e", left: "100%", top: "50%", cursor: "ew-resize" },
434
+ { kind: "s", left: "50%", top: "100%", cursor: "ns-resize" },
435
+ { kind: "se", left: "100%", top: "100%", cursor: "nwse-resize" }
436
+ ];
437
+ var px = (value) => {
438
+ const n = parseFloat(value);
439
+ return Number.isFinite(n) ? n : 0;
440
+ };
441
+ function pitchOf(grid) {
442
+ if (!grid) return { col: 0, row: 0 };
443
+ const view = grid.ownerDocument.defaultView ?? window;
444
+ const style = view.getComputedStyle(grid);
445
+ const rem = px(view.getComputedStyle(grid.ownerDocument.documentElement).fontSize) || 16;
446
+ const gapX = px(style.columnGap);
447
+ const gapY = px(style.rowGap);
448
+ return {
449
+ col: (grid.getBoundingClientRect().width + gapX) / 12,
450
+ row: px(PAGE_ROW_HEIGHT) * rem + gapY
451
+ };
452
+ }
453
+ var keyOf = (blocks) => blocks.map((b) => `${b.id}:${b.layout.x},${b.layout.y},${b.layout.w},${b.layout.h}`).join("|");
454
+ function EditableCell({
455
+ block,
456
+ layout,
457
+ grid,
458
+ blocks,
459
+ dragged,
460
+ onPreview,
461
+ onCommit,
462
+ renderBlock,
463
+ l,
464
+ testId
465
+ }) {
466
+ const element = react$1.useRef(null);
467
+ const gesture = chunkUM3EWCDE_cjs.usePointerGesture({
468
+ element,
469
+ threshold: 3,
470
+ begin: () => {
471
+ const { col, row } = pitchOf(grid());
472
+ if (!col || !row) return null;
473
+ return { base: blocks, start: block.layout, col, row, shown: keyOf(blocks) };
474
+ },
475
+ dragStart: () => {
476
+ if (element.current) element.current.style.willChange = "transform";
477
+ },
478
+ update: (g, kind, { dx, dy }) => {
479
+ const cols = Math.round(dx / g.col);
480
+ const rows = Math.round(dy / g.row);
481
+ const next = kind === "move" ? moveBlock(g.base, block.id, { x: g.start.x + cols, y: g.start.y + rows }, false) : resizeBlock(
482
+ g.base,
483
+ block.id,
484
+ {
485
+ w: g.start.w + (kind === "s" ? 0 : cols),
486
+ h: g.start.h + (kind === "e" ? 0 : rows)
487
+ },
488
+ false
489
+ );
490
+ return { blocks: next, key: keyOf(next), dx, dy };
491
+ },
492
+ apply: (g, next, kind) => {
493
+ if (kind === "move" && element.current) {
494
+ element.current.style.transform = `translate3d(${next.dx}px, ${next.dy}px, 0)`;
495
+ }
496
+ if (next.key !== g.shown) {
497
+ g.shown = next.key;
498
+ onPreview({ id: block.id, moving: kind === "move", blocks: next.blocks });
499
+ }
500
+ },
501
+ end: (g, next, kind) => {
502
+ if (element.current) {
503
+ element.current.style.transform = "";
504
+ element.current.style.willChange = "";
505
+ }
506
+ onPreview(null);
507
+ if (!next) return;
508
+ const to = next.blocks.find((b) => b.id === block.id)?.layout ?? block.layout;
509
+ const settled = kind === "move" ? moveBlock(g.base, block.id, to) : resizeBlock(g.base, block.id, to);
510
+ if (keyOf(settled) !== keyOf(g.base)) onCommit(settled);
511
+ }
512
+ });
513
+ const onKeyDown = (event) => {
514
+ const step = {
515
+ ArrowLeft: [-1, 0],
516
+ ArrowRight: [1, 0],
517
+ ArrowUp: [0, -1],
518
+ ArrowDown: [0, 1]
519
+ }[event.key];
520
+ if (!step) return;
521
+ event.preventDefault();
522
+ const [x, y] = step;
523
+ const { layout: at } = block;
524
+ onCommit(
525
+ event.shiftKey ? resizeBlock(blocks, block.id, { w: at.w + x, h: at.h + y }) : moveBlock(blocks, block.id, { x: at.x + x, y: at.y + y })
526
+ );
527
+ };
528
+ const grip = /* @__PURE__ */ jsxRuntime.jsx(
529
+ ui.Button,
530
+ {
531
+ variant: "ghost",
532
+ size: "icon",
533
+ className: "hidden size-7 cursor-grab touch-none active:cursor-grabbing md:inline-flex",
534
+ "aria-label": l.move,
535
+ title: l.moveHint,
536
+ onPointerDown: (event) => gesture.start(event, "move"),
537
+ onKeyDown,
538
+ "data-testid": `${testId}-move-${block.id}`,
539
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GripVertical, { className: "size-3.5" })
540
+ }
541
+ );
542
+ return /* @__PURE__ */ jsxRuntime.jsxs(
543
+ PageCell,
544
+ {
545
+ layout,
546
+ cellRef: element,
547
+ className: ui.cn("group/cell relative", dragged && "z-10 opacity-90"),
548
+ ...gesture.handlers,
549
+ testId: `${testId}-cell-${block.id}`,
550
+ children: [
551
+ renderBlock(block, grip),
552
+ RESIZE_HANDLES.map(({ kind, left, top, cursor }) => /* @__PURE__ */ jsxRuntime.jsx(
553
+ chunkUM3EWCDE_cjs.GestureHandle,
554
+ {
555
+ left,
556
+ top,
557
+ cursor,
558
+ size: "sm",
559
+ bar: kind === "e" ? "v" : kind === "s" ? "h" : void 0,
560
+ className: "hidden opacity-0 transition-opacity group-hover/cell:opacity-100 pointer-coarse:opacity-100 md:flex",
561
+ onPointerDown: (event) => gesture.start(event, kind),
562
+ "aria-label": l.resize,
563
+ testId: `${testId}-resize-${kind}-${block.id}`
564
+ },
565
+ kind
566
+ ))
567
+ ]
568
+ }
569
+ );
570
+ }
571
+ function EditablePageGrid({
572
+ blocks,
573
+ onChange,
574
+ renderBlock,
575
+ labels,
576
+ testId = "page"
577
+ }) {
578
+ const l = { ...DEFAULT_EDITABLE_PAGE_GRID_LABELS, ...labels };
579
+ const grid = react$1.useRef(null);
580
+ const [preview, setPreview] = react$1.useState(null);
581
+ const placeOf = (block) => preview?.blocks.find((b) => b.id === block.id)?.layout ?? block.layout;
582
+ const target = preview?.moving ? preview.blocks.find((b) => b.id === preview.id) : void 0;
583
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageGrid, { testId: `${testId}-grid`, gridRef: grid, children: [
584
+ target && /* @__PURE__ */ jsxRuntime.jsx(
585
+ PageCell,
586
+ {
587
+ layout: target.layout,
588
+ className: "rounded-xl border-2 border-dashed border-primary/30 bg-primary/5",
589
+ "aria-hidden": true,
590
+ testId: `${testId}-drop-target`
591
+ }
592
+ ),
593
+ inReadingOrder(blocks).map((block) => {
594
+ const isDragged = preview?.id === block.id;
595
+ return /* @__PURE__ */ jsxRuntime.jsx(
596
+ EditableCell,
597
+ {
598
+ block,
599
+ layout: isDragged && preview.moving ? block.layout : placeOf(block),
600
+ grid: () => grid.current,
601
+ blocks,
602
+ dragged: isDragged,
603
+ onPreview: setPreview,
604
+ onCommit: onChange,
605
+ renderBlock,
606
+ l,
607
+ testId
608
+ },
609
+ block.id
610
+ );
611
+ })
612
+ ] });
613
+ }
353
614
  var DEFAULT_DOCUMENT_BLOCK_LABELS = {
354
615
  loading: "Loading\u2026",
355
616
  unavailable: "This document is not available to you.",
@@ -403,7 +664,7 @@ function BlockCard({
403
664
  className: ui.cn("flex h-full min-h-[14rem] flex-col overflow-hidden rounded-xl p-0", className),
404
665
  "data-testid": testId,
405
666
  children: [
406
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 border-b px-4 py-2", children: [
667
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 border-b border-border px-4 py-2", children: [
407
668
  icon,
408
669
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-medium", "data-testid": testId && `${testId}-name`, children: title }),
409
670
  actions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex gap-1", children: actions })
@@ -509,7 +770,7 @@ function GalleryBlockView({
509
770
  },
510
771
  current
511
772
  ) }),
512
- count > 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-2 overflow-x-auto border-t p-2", role: "list", children: documentIds.map((id, i) => {
773
+ count > 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-2 overflow-x-auto border-t border-border p-2", role: "list", children: documentIds.map((id, i) => {
513
774
  const src = thumbnails.get(id);
514
775
  return /* @__PURE__ */ jsxRuntime.jsx(
515
776
  "button",
@@ -520,7 +781,7 @@ function GalleryBlockView({
520
781
  "aria-current": i === at,
521
782
  onClick: () => setIndex(i),
522
783
  className: ui.cn(
523
- "flex h-14 w-12 shrink-0 items-center justify-center overflow-hidden rounded border bg-muted",
784
+ "flex h-14 w-12 shrink-0 items-center justify-center overflow-hidden rounded border border-border bg-muted",
524
785
  i === at && "ring-2 ring-primary"
525
786
  ),
526
787
  "data-testid": testId && `${testId}-thumb-${i}`,
@@ -544,6 +805,12 @@ var toRowView = (r) => ({
544
805
  titles: { ...r.titles ?? {} },
545
806
  shared: r.shared ?? true
546
807
  });
808
+ var GRID_TYPES = new Set(chunkQ25CZLK6_cjs.DATABASE_COLUMN_TYPES);
809
+ var isGridType = (type) => GRID_TYPES.has(type);
810
+ var toColumnView = (c) => ({
811
+ ...c,
812
+ type: isGridType(c.type) ? c.type : "text"
813
+ });
547
814
  function TableViewBlock({
548
815
  viewId,
549
816
  actions,
@@ -552,34 +819,25 @@ function TableViewBlock({
552
819
  testId
553
820
  }) {
554
821
  const l = { ...DEFAULT_TABLE_VIEW_BLOCK_LABELS, ...labels };
555
- const view = react.useTableView(viewId || null);
556
- const target = view.data?.target ?? null;
557
- const databaseId = target && target.startsWith("dbs-") ? target : null;
558
- const database = react.useDatabase(databaseId);
559
- const rows = react.useDatabaseRows(databaseId, "", { view: viewId });
560
- const columns = react$1.useMemo(() => {
561
- const all = database.data?.columns ?? [];
562
- const wanted = view.data?.spec.columns ?? [];
563
- if (!wanted.length) return all;
564
- const byId = new Map(all.map((c) => [c.id, c]));
565
- return wanted.flatMap((id) => byId.get(id) ?? []);
566
- }, [database.data, view.data]);
822
+ const read = react.useTableViewRows(viewId || null);
823
+ const data = read.data;
824
+ const columns = react$1.useMemo(() => (data?.columns ?? []).map(toColumnView), [data]);
825
+ const rows = react$1.useMemo(() => (data?.rows ?? []).map(toRowView), [data]);
567
826
  let body;
568
- if (view.isError || database.isError) {
827
+ if (read.isError) {
569
828
  body = /* @__PURE__ */ jsxRuntime.jsx("p", { className: "p-4 text-sm text-muted-foreground", children: l.unavailable });
570
- } else if (view.data && !databaseId) {
829
+ } else if (data && !data.database) {
571
830
  body = /* @__PURE__ */ jsxRuntime.jsx("p", { className: "p-4 text-sm text-muted-foreground", children: l.notADatabase });
572
- } else if (!view.data || !database.data) {
831
+ } else if (!data) {
573
832
  body = /* @__PURE__ */ jsxRuntime.jsx("p", { className: "p-4 text-sm text-muted-foreground", children: l.loading });
574
833
  } else {
575
834
  body = /* @__PURE__ */ jsxRuntime.jsx(
576
835
  chunkQ25CZLK6_cjs.DatabaseTable,
577
836
  {
578
837
  columns,
579
- rows: (rows.data?.rows ?? []).map(toRowView),
838
+ rows,
580
839
  readOnly: true,
581
840
  isFiltered: true,
582
- isLoading: rows.isLoading,
583
841
  gridId: `page-view-${viewId}`,
584
842
  height: "100%",
585
843
  testId: testId && `${testId}-table`
@@ -593,9 +851,9 @@ function TableViewBlock({
593
851
  className: ui.cn("flex h-full min-h-[12rem] flex-col overflow-hidden rounded-xl p-0", className),
594
852
  "data-testid": testId,
595
853
  children: [
596
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 border-b px-4 py-2", children: [
854
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 border-b border-border px-4 py-2", children: [
597
855
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Table2, { className: "size-4 text-muted-foreground" }),
598
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-medium", "data-testid": testId && `${testId}-name`, children: view.data?.spec.name ?? "" }),
856
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-medium", "data-testid": testId && `${testId}-name`, children: data?.view.spec.name ?? "" }),
599
857
  actions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex gap-1", children: actions })
600
858
  ] }),
601
859
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 flex-1", children: body })
@@ -616,7 +874,7 @@ function PageBlockView({
616
874
  case "chart":
617
875
  case "metric":
618
876
  return /* @__PURE__ */ jsxRuntime.jsx(
619
- chunk2SILSQNF_cjs.DashboardPanel,
877
+ chunk4ZR4O5SP_cjs.DashboardPanel,
620
878
  {
621
879
  panel: react.panelOfBlock(block),
622
880
  actions,
@@ -673,46 +931,6 @@ function PageBlockView({
673
931
  ) });
674
932
  }
675
933
  }
676
- var PAGE_ROW_HEIGHT = "4.5rem";
677
- function PageGrid({ children, className, testId }) {
678
- return /* @__PURE__ */ jsxRuntime.jsx(
679
- "div",
680
- {
681
- className: ui.cn("grid grid-cols-1 gap-4 md:grid-cols-12", className),
682
- style: { gridAutoRows: `minmax(${PAGE_ROW_HEIGHT}, auto)` },
683
- "data-slot": "page-grid",
684
- "data-testid": testId,
685
- children
686
- }
687
- );
688
- }
689
- function inReadingOrder(blocks) {
690
- return [...blocks].sort((a, b) => a.layout.y - b.layout.y || a.layout.x - b.layout.x);
691
- }
692
- function PageCell({
693
- layout,
694
- children,
695
- className,
696
- testId
697
- }) {
698
- const place = {
699
- "--page-col": `${layout.x + 1} / span ${layout.w}`,
700
- "--page-row": `${layout.y + 1} / span ${layout.h}`
701
- };
702
- return /* @__PURE__ */ jsxRuntime.jsx(
703
- "div",
704
- {
705
- className: ui.cn(
706
- "col-span-1 min-w-0 md:[grid-column:var(--page-col)] md:[grid-row:var(--page-row)]",
707
- className
708
- ),
709
- style: place,
710
- "data-slot": "page-cell",
711
- "data-testid": testId,
712
- children
713
- }
714
- );
715
- }
716
934
  function NewPageButton({
717
935
  templates,
718
936
  l,
@@ -951,8 +1169,6 @@ var DEFAULT_PAGES_PAGE_LABELS = {
951
1169
  gallery: "Gallery"
952
1170
  },
953
1171
  editBlock: "Edit the block",
954
- moveUp: "Move up",
955
- moveDown: "Move down",
956
1172
  removeBlock: "Remove the block",
957
1173
  noBlocks: "No blocks yet. Add one to start.",
958
1174
  saved: "Page saved",
@@ -1000,6 +1216,7 @@ function ConnectedPagesPage({
1000
1216
  panelLabels,
1001
1217
  editorLabels,
1002
1218
  blockLabels,
1219
+ gridLabels,
1003
1220
  tableLabels,
1004
1221
  pickerLabels,
1005
1222
  className,
@@ -1085,7 +1302,7 @@ function ConnectedPagesPage({
1085
1302
  setDraft(null);
1086
1303
  };
1087
1304
  const updateDraft = (patch) => setDraft((d) => d ? { ...d, spec: { ...d.spec, ...patch } } : d);
1088
- const setBlocks = (blocks) => updateDraft({ blocks: react.packBlocks(blocks) });
1305
+ const setBlocks = (blocks) => updateDraft({ blocks });
1089
1306
  const commit = async () => {
1090
1307
  if (!draft) return;
1091
1308
  try {
@@ -1120,13 +1337,7 @@ function ConnectedPagesPage({
1120
1337
  };
1121
1338
  let content;
1122
1339
  if (draft) {
1123
- const blocks = inReadingOrder(draft.spec.blocks);
1124
- const move = (index, by) => {
1125
- const next = [...blocks];
1126
- const [moved] = next.splice(index, 1);
1127
- next.splice(index + by, 0, moved);
1128
- setBlocks(next);
1129
- };
1340
+ const blocks = draft.spec.blocks;
1130
1341
  content = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", "data-testid": `${testId}-editor`, children: [
1131
1342
  /* @__PURE__ */ jsxRuntime.jsx(
1132
1343
  chunkNSD37OF5_cjs.PageHeader,
@@ -1179,64 +1390,51 @@ function ConnectedPagesPage({
1179
1390
  )
1180
1391
  ] })
1181
1392
  ] }),
1182
- blocks.length ? /* @__PURE__ */ jsxRuntime.jsx(PageGrid, { testId: `${testId}-grid`, children: blocks.map((block, i) => /* @__PURE__ */ jsxRuntime.jsx(PageCell, { layout: block.layout, testId: `${testId}-cell-${block.id}`, children: /* @__PURE__ */ jsxRuntime.jsx(
1183
- PageBlockView,
1393
+ blocks.length ? /* @__PURE__ */ jsxRuntime.jsx(
1394
+ EditablePageGrid,
1184
1395
  {
1185
- block,
1186
- panelLabels,
1187
- tableLabels,
1188
- testId: `${testId}-block-${block.id}`,
1189
- actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1190
- /* @__PURE__ */ jsxRuntime.jsx(
1191
- ui.Button,
1192
- {
1193
- variant: "ghost",
1194
- size: "icon",
1195
- className: "size-7",
1196
- "aria-label": l.editBlock,
1197
- onClick: () => setEditing({ index: i, block }),
1198
- "data-testid": `${testId}-edit-block-${block.id}`,
1199
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pencil, { className: "size-3.5" })
1200
- }
1201
- ),
1202
- /* @__PURE__ */ jsxRuntime.jsx(
1203
- ui.Button,
1204
- {
1205
- variant: "ghost",
1206
- size: "icon",
1207
- className: "size-7",
1208
- "aria-label": l.moveUp,
1209
- disabled: i === 0,
1210
- onClick: () => move(i, -1),
1211
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "size-3.5" })
1212
- }
1213
- ),
1214
- /* @__PURE__ */ jsxRuntime.jsx(
1215
- ui.Button,
1216
- {
1217
- variant: "ghost",
1218
- size: "icon",
1219
- className: "size-7",
1220
- "aria-label": l.moveDown,
1221
- disabled: i === blocks.length - 1,
1222
- onClick: () => move(i, 1),
1223
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "size-3.5" })
1224
- }
1225
- ),
1226
- /* @__PURE__ */ jsxRuntime.jsx(
1227
- ui.Button,
1228
- {
1229
- variant: "ghost",
1230
- size: "icon",
1231
- className: "size-7",
1232
- "aria-label": l.removeBlock,
1233
- onClick: () => setBlocks(blocks.filter((_, j) => j !== i)),
1234
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "size-3.5" })
1235
- }
1236
- )
1237
- ] })
1396
+ blocks,
1397
+ onChange: setBlocks,
1398
+ labels: gridLabels,
1399
+ testId,
1400
+ renderBlock: (block, grip) => /* @__PURE__ */ jsxRuntime.jsx(
1401
+ PageBlockView,
1402
+ {
1403
+ block,
1404
+ panelLabels,
1405
+ tableLabels,
1406
+ testId: `${testId}-block-${block.id}`,
1407
+ actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1408
+ grip,
1409
+ /* @__PURE__ */ jsxRuntime.jsx(
1410
+ ui.Button,
1411
+ {
1412
+ variant: "ghost",
1413
+ size: "icon",
1414
+ className: "size-7",
1415
+ "aria-label": l.editBlock,
1416
+ onClick: () => setEditing({ block, isNew: false }),
1417
+ "data-testid": `${testId}-edit-block-${block.id}`,
1418
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pencil, { className: "size-3.5" })
1419
+ }
1420
+ ),
1421
+ /* @__PURE__ */ jsxRuntime.jsx(
1422
+ ui.Button,
1423
+ {
1424
+ variant: "ghost",
1425
+ size: "icon",
1426
+ className: "size-7",
1427
+ "aria-label": l.removeBlock,
1428
+ onClick: () => setBlocks(compactLayout(blocks.filter((b) => b.id !== block.id))),
1429
+ "data-testid": `${testId}-remove-block-${block.id}`,
1430
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "size-3.5" })
1431
+ }
1432
+ )
1433
+ ] })
1434
+ }
1435
+ )
1238
1436
  }
1239
- ) }, block.id)) }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: l.noBlocks }),
1437
+ ) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: l.noBlocks }),
1240
1438
  /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
1241
1439
  /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Button, { variant: "outline", "data-testid": `${testId}-add-block`, children: [
1242
1440
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" }),
@@ -1248,7 +1446,7 @@ function ConnectedPagesPage({
1248
1446
  return /* @__PURE__ */ jsxRuntime.jsxs(
1249
1447
  ui.DropdownMenuItem,
1250
1448
  {
1251
- onSelect: () => setEditing({ index: blocks.length, block: newBlock(kind) }),
1449
+ onSelect: () => setEditing({ block: newBlock(kind), isNew: true }),
1252
1450
  "data-testid": `${testId}-add-${kind}`,
1253
1451
  children: [
1254
1452
  /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-4" }),
@@ -1272,9 +1470,9 @@ function ConnectedPagesPage({
1272
1470
  onCancel: () => setEditing(null),
1273
1471
  onDone: (block) => {
1274
1472
  if (!editing) return;
1275
- const next = [...blocks];
1276
- next[editing.index] = block;
1277
- setBlocks(next);
1473
+ setBlocks(
1474
+ editing.isNew ? appendBlock(blocks, block) : blocks.map((b) => b.id === block.id ? block : b)
1475
+ );
1278
1476
  setEditing(null);
1279
1477
  }
1280
1478
  }
@@ -1345,19 +1543,26 @@ exports.ConnectedPagesPage = ConnectedPagesPage;
1345
1543
  exports.DEFAULT_BLOCK_EDITOR_LABELS = DEFAULT_BLOCK_EDITOR_LABELS;
1346
1544
  exports.DEFAULT_DOCUMENTS_PICKER_LABELS = DEFAULT_DOCUMENTS_PICKER_LABELS;
1347
1545
  exports.DEFAULT_DOCUMENT_BLOCK_LABELS = DEFAULT_DOCUMENT_BLOCK_LABELS;
1546
+ exports.DEFAULT_EDITABLE_PAGE_GRID_LABELS = DEFAULT_EDITABLE_PAGE_GRID_LABELS;
1348
1547
  exports.DEFAULT_PAGES_PAGE_LABELS = DEFAULT_PAGES_PAGE_LABELS;
1349
1548
  exports.DEFAULT_TABLE_VIEW_BLOCK_LABELS = DEFAULT_TABLE_VIEW_BLOCK_LABELS;
1350
1549
  exports.DEFAULT_VIEW_PICKER_LABELS = DEFAULT_VIEW_PICKER_LABELS;
1351
1550
  exports.DocumentBlockView = DocumentBlockView;
1352
1551
  exports.DocumentReadView = DocumentReadView;
1353
1552
  exports.DocumentsPicker = DocumentsPicker;
1553
+ exports.EditablePageGrid = EditablePageGrid;
1354
1554
  exports.GalleryBlockView = GalleryBlockView;
1555
+ exports.MIN_BLOCK_SIZE = MIN_BLOCK_SIZE;
1355
1556
  exports.PAGE_ROW_HEIGHT = PAGE_ROW_HEIGHT;
1356
1557
  exports.PageBlockView = PageBlockView;
1357
1558
  exports.PageCell = PageCell;
1358
1559
  exports.PageGrid = PageGrid;
1359
1560
  exports.TableViewBlock = TableViewBlock;
1360
1561
  exports.ViewPicker = ViewPicker;
1562
+ exports.appendBlock = appendBlock;
1563
+ exports.compactLayout = compactLayout;
1361
1564
  exports.inReadingOrder = inReadingOrder;
1565
+ exports.moveBlock = moveBlock;
1566
+ exports.resizeBlock = resizeBlock;
1362
1567
  //# sourceMappingURL=index.cjs.map
1363
1568
  //# sourceMappingURL=index.cjs.map