camox 0.71.0 → 0.74.1

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 (104) hide show
  1. package/dist/core/createApp.d.ts +4 -103
  2. package/dist/core/createApp.js +3 -24
  3. package/dist/core/createBlock.d.ts +2 -2
  4. package/dist/core/createBlock.js +41 -185
  5. package/dist/core/createLayout.d.ts +6 -77
  6. package/dist/core/createLayout.js +12 -50
  7. package/dist/core/editing/createEditableBlock.d.ts +9 -75
  8. package/dist/core/editing/createEditableBlock.js +258 -640
  9. package/dist/core/hooks/useIsEditable.js +2 -2
  10. package/dist/core/lib/artifactData.js +8 -3
  11. package/dist/core/lib/contentType.d.ts +23 -38
  12. package/dist/core/lib/contentType.js +34 -62
  13. package/dist/core/lib/iconTypes.d.ts +0 -3
  14. package/dist/core/lib/icons.js +63 -51
  15. package/dist/core/lib/recordScope.js +1 -1
  16. package/dist/features/canvas/CanvasOverlays.js +94 -176
  17. package/dist/features/canvas/CanvasPageFrame.js +62 -68
  18. package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -3
  19. package/dist/features/canvas/canvasOverlayGeometry.js +1 -7
  20. package/dist/features/canvas/sidebar/CuratedPageInspector.js +3 -21
  21. package/dist/features/canvas/sidebar/LayoutPageBlocks.js +1 -2
  22. package/dist/features/canvas/useCanvasCamera.js +1 -1
  23. package/dist/features/canvas/useCanvasFrame.js +1 -1
  24. package/dist/features/content/ContentCollection.js +2 -2
  25. package/dist/features/content/collection-form.js +6 -7
  26. package/dist/features/page/CuratedPageContent.js +15 -24
  27. package/dist/features/page/UnplacedBlockContent.js +1 -6
  28. package/dist/features/preview/CamoxPreview.js +30 -33
  29. package/dist/features/preview/EditablePageContent.js +131 -151
  30. package/dist/features/preview/components/BlockActionsPopover.js +43 -152
  31. package/dist/features/preview/components/CanvasPreview.js +2 -2
  32. package/dist/features/preview/components/Frame.js +3 -3
  33. package/dist/features/preview/components/IconFieldEditor.js +1 -1
  34. package/dist/features/preview/components/ItemFieldsEditor.js +1 -3
  35. package/dist/features/preview/components/Overlays.js +18 -84
  36. package/dist/features/preview/components/PageInfo.js +121 -98
  37. package/dist/features/preview/components/PageTree.js +57 -103
  38. package/dist/features/preview/components/PreviewPanel.js +8 -11
  39. package/dist/features/preview/components/RecordCombobox.js +65 -78
  40. package/dist/features/preview/components/ReferenceFieldEditor.js +1 -19
  41. package/dist/features/preview/components/ReferenceListFieldEditor.js +1 -19
  42. package/dist/features/preview/components/RemovedBlockPlaceholder.js +2 -2
  43. package/dist/features/preview/components/SelectionEditor.js +6 -5
  44. package/dist/features/preview/components/useRepeatableItemActions.js +18 -24
  45. package/dist/features/preview/components/useUpdateBlockPosition.js +1 -1
  46. package/dist/features/preview/overlayMessages.js +1 -4
  47. package/dist/features/preview/previewStore.js +3 -23
  48. package/dist/features/renderer/RendererApp.js +17 -141
  49. package/dist/features/renderer/definitionAnswers.js +1 -8
  50. package/dist/features/renderer/rendererHost.js +1 -31
  51. package/dist/features/renderer/studioConnection.js +1 -25
  52. package/dist/features/routes/pageRuntime.js +15 -4
  53. package/dist/features/runtime/ClaimCard.js +192 -0
  54. package/dist/features/runtime/pageApp.js +5 -4
  55. package/dist/features/runtime/runtime.js +29 -8
  56. package/dist/features/runtime/worker.js +2 -2
  57. package/dist/features/runtime/workerRequest.d.ts +6 -0
  58. package/dist/features/runtime/workerRequest.js +13 -1
  59. package/dist/features/runtime/workerRuntime.d.ts +2 -2
  60. package/dist/features/runtime/workerRuntime.js +2 -2
  61. package/dist/features/studio/components/AgentSidebar.js +7 -7
  62. package/dist/features/studio/components/ChatWidget.js +142 -106
  63. package/dist/features/studio/components/ContentFindings.js +127 -230
  64. package/dist/features/studio/components/DeleteDraftDialog.js +112 -0
  65. package/dist/features/studio/components/DraftBar.js +98 -53
  66. package/dist/features/studio/components/DraftsControl.js +203 -190
  67. package/dist/features/studio/components/ReviewDraftDialog.js +670 -0
  68. package/dist/features/studio/components/{Patrol.js → Specialists.js} +291 -330
  69. package/dist/features/studio/components/Squareling.js +5 -5
  70. package/dist/features/studio/components/ThreadComposer.js +106 -127
  71. package/dist/features/studio/components/ThreadMessages.js +137 -45
  72. package/dist/features/studio/findingSentence.js +14 -12
  73. package/dist/features/studio/fixMessage.js +23 -0
  74. package/dist/features/studio/reportSentence.js +1 -1
  75. package/dist/features/studio/{patrollerBio.js → specialistBio.js} +8 -5
  76. package/dist/features/studio/studioStore.js +29 -15
  77. package/dist/features/studio/workingSentence.js +1 -1
  78. package/dist/features/vite/blockBoilerplate.js +1 -1
  79. package/dist/features/vite/definitionsSync.js +1 -8
  80. package/dist/lib/api-client.js +5 -1
  81. package/dist/lib/queries.js +5 -6
  82. package/dist/lib/studio-definitions.js +0 -2
  83. package/dist/lib/studio-reads.d.ts +1 -1
  84. package/dist/lib/studio-reads.js +5 -10
  85. package/dist/lib/use-thread.js +196 -138
  86. package/dist/package.js +1 -1
  87. package/dist/studio-overlays.css +0 -29
  88. package/dist/studio.css +1 -1
  89. package/package.json +4 -4
  90. package/skills/camox/SKILL.md +1 -1
  91. package/skills/camox/references/artifacts.md +4 -4
  92. package/skills/camox/references/block-definitions.md +21 -25
  93. package/skills/camox/references/dom-integrations.md +1 -1
  94. package/skills/camox/references/layout-definitions.md +3 -12
  95. package/skills/camox/references/routed-layouts.md +2 -2
  96. package/skills/camox-expand/SKILL.md +5 -5
  97. package/skills/camoxify/SKILL.md +4 -4
  98. package/dist/features/canvas/canvasInsertionSeams.js +0 -44
  99. package/dist/features/preview/components/AddBlockSheet.js +0 -314
  100. package/dist/features/preview/components/BlockPeek.js +0 -66
  101. package/dist/features/preview/components/BlockThumbnail.js +0 -281
  102. package/dist/features/preview/components/blockGridNavigation.js +0 -15
  103. package/dist/features/preview/referencePickerFocus.js +0 -29
  104. package/dist/features/studio/components/ReviewDraftSheet.js +0 -1587
@@ -18,7 +18,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
18
18
  import { Command as Command$1, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from "@camox/ui/command";
19
19
 
20
20
  //#region src/features/preview/components/BlockActionsPopover.tsx
21
- const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "start", isLayoutBlock, layoutSlot }) => {
21
+ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "start" }) => {
22
22
  const [blockToDelete, setBlockToDelete] = React.useState(null);
23
23
  const page = usePreviewedPage();
24
24
  const { pageBlocks } = usePageBlocks(page);
@@ -45,21 +45,6 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
45
45
  toast.error("Could not duplicate block");
46
46
  }
47
47
  };
48
- const handleAddBlockAbove = (block) => {
49
- if (!page) return;
50
- const blockIndex = pageBlocks.findIndex((b) => b.id === block.id);
51
- const afterPosition = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
52
- previewStore.send({
53
- type: "openAddBlockSheet",
54
- afterPosition
55
- });
56
- };
57
- const handleAddBlockBelow = (block) => {
58
- previewStore.send({
59
- type: "openAddBlockSheet",
60
- afterPosition: block.position
61
- });
62
- };
63
48
  const getBlocksAbove = (block) => {
64
49
  if (!page) return [];
65
50
  const blockIndex = pageBlocks.findIndex((b) => b.id === block.id);
@@ -101,97 +86,46 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
101
86
  children: /* @__PURE__ */ jsxs(Command$1, { children: [/* @__PURE__ */ jsx(CommandInput, { placeholder: "Search actions..." }), /* @__PURE__ */ jsxs(CommandList, {
102
87
  className: "max-h-[350px]",
103
88
  children: [
104
- isLayoutBlock && layoutSlot === "before" && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsx(CommandItem, {
105
- onSelect: () => {
106
- previewStore.send({
107
- type: "openAddBlockSheet",
108
- afterPosition: ""
109
- });
110
- onOpenChange(false);
111
- },
112
- children: /* @__PURE__ */ jsxs("div", {
113
- className: "flex items-center gap-2",
114
- children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Add block below"]
115
- })
116
- }) }) }),
117
- isLayoutBlock && layoutSlot === "after" && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsx(CommandItem, {
89
+ /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(CommandItem, {
90
+ className: "justify-between",
118
91
  onSelect: () => {
119
- const lastPageBlock = pageBlocks[pageBlocks.length - 1];
120
- previewStore.send({
121
- type: "openAddBlockSheet",
122
- afterPosition: lastPageBlock?.position
123
- });
92
+ handleDuplicateBlock(block);
124
93
  onOpenChange(false);
125
94
  },
126
- children: /* @__PURE__ */ jsxs("div", {
95
+ children: [/* @__PURE__ */ jsxs("div", {
127
96
  className: "flex items-center gap-2",
128
- children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Add block above"]
129
- })
130
- }) }) }),
131
- !isLayoutBlock && /* @__PURE__ */ jsxs(Fragment, { children: [
132
- /* @__PURE__ */ jsxs(CommandGroup, { children: [/* @__PURE__ */ jsxs(CommandItem, {
133
- className: "justify-between",
97
+ children: [/* @__PURE__ */ jsx(Copy, { className: "h-4 w-4" }), "Duplicate block"]
98
+ }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Mod+D") })]
99
+ }) }),
100
+ /* @__PURE__ */ jsx(CommandSeparator, {}),
101
+ /* @__PURE__ */ jsxs(CommandGroup, { children: [
102
+ /* @__PURE__ */ jsxs(CommandItem, {
134
103
  onSelect: () => {
135
- handleAddBlockBelow(block);
104
+ handleDeleteBlocksAbove(block);
136
105
  onOpenChange(false);
137
106
  },
138
- children: [/* @__PURE__ */ jsxs("div", {
139
- className: "flex items-center gap-2",
140
- children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Add block below"]
141
- }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("O") })]
142
- }), /* @__PURE__ */ jsxs(CommandItem, {
143
- className: "justify-between",
107
+ disabled: getBlocksAbove(block).length === 0,
108
+ children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Delete blocks above"]
109
+ }),
110
+ /* @__PURE__ */ jsxs(CommandItem, {
144
111
  onSelect: () => {
145
- handleAddBlockAbove(block);
112
+ handleDeleteBlocksBelow(block);
146
113
  onOpenChange(false);
147
114
  },
148
- children: [/* @__PURE__ */ jsxs("div", {
149
- className: "flex items-center gap-2",
150
- children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Add block above"]
151
- }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Shift+O") })]
152
- })] }),
153
- /* @__PURE__ */ jsx(CommandSeparator, {}),
154
- /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(CommandItem, {
115
+ disabled: getBlocksBelow(block).length === 0,
116
+ children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Delete blocks below"]
117
+ }),
118
+ /* @__PURE__ */ jsxs(CommandItem, {
155
119
  className: "justify-between",
156
120
  onSelect: () => {
157
- handleDuplicateBlock(block);
121
+ handleDeleteBlock(block);
158
122
  onOpenChange(false);
159
123
  },
160
124
  children: [/* @__PURE__ */ jsxs("div", {
161
125
  className: "flex items-center gap-2",
162
- children: [/* @__PURE__ */ jsx(Copy, { className: "h-4 w-4" }), "Duplicate block"]
163
- }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Mod+D") })]
164
- }) }),
165
- /* @__PURE__ */ jsx(CommandSeparator, {}),
166
- /* @__PURE__ */ jsxs(CommandGroup, { children: [
167
- /* @__PURE__ */ jsxs(CommandItem, {
168
- onSelect: () => {
169
- handleDeleteBlocksAbove(block);
170
- onOpenChange(false);
171
- },
172
- disabled: getBlocksAbove(block).length === 0,
173
- children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Delete blocks above"]
174
- }),
175
- /* @__PURE__ */ jsxs(CommandItem, {
176
- onSelect: () => {
177
- handleDeleteBlocksBelow(block);
178
- onOpenChange(false);
179
- },
180
- disabled: getBlocksBelow(block).length === 0,
181
- children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Delete blocks below"]
182
- }),
183
- /* @__PURE__ */ jsxs(CommandItem, {
184
- className: "justify-between",
185
- onSelect: () => {
186
- handleDeleteBlock(block);
187
- onOpenChange(false);
188
- },
189
- children: [/* @__PURE__ */ jsxs("div", {
190
- className: "flex items-center gap-2",
191
- children: [/* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }), "Delete block"]
192
- }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Mod+Backspace") })]
193
- })
194
- ] })
126
+ children: [/* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }), "Delete block"]
127
+ }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Mod+Backspace") })]
128
+ })
195
129
  ] })
196
130
  ]
197
131
  })] })
@@ -293,12 +227,12 @@ function useBlockActionsShortcuts() {
293
227
  if (!sel_0) return;
294
228
  const itemId_0 = selectionItemId(sel_0);
295
229
  if (itemId_0 != null) {
296
- deleteRepeatableItem({ id: itemId_0 }).then(_temp4, _temp5);
230
+ deleteRepeatableItem({ id: itemId_0 }).then(_temp3, _temp4);
297
231
  previewStore.send({ type: "selectParent" });
298
232
  return;
299
233
  }
300
234
  const block_0 = pageBlocks.find((b_0) => b_0.id === sel_0.blockId);
301
- deleteBlock({ id: sel_0.blockId }).then(() => toast.success(`Deleted "${block_0 ? entityName(block_0, block_0.type) : ""}" block`), _temp6);
235
+ deleteBlock({ id: sel_0.blockId }).then(() => toast.success(`Deleted "${block_0 ? entityName(block_0, block_0.type) : ""}" block`), _temp5);
302
236
  previewStore.send({ type: "clearSelection" });
303
237
  }
304
238
  },
@@ -320,11 +254,11 @@ function useBlockActionsShortcuts() {
320
254
  if (!sel_2) return;
321
255
  const itemId_1 = selectionItemId(sel_2);
322
256
  if (itemId_1 != null) {
323
- duplicateRepeatableItem({ id: itemId_1 }).then(_temp7, _temp8);
257
+ duplicateRepeatableItem({ id: itemId_1 }).then(_temp6, _temp7);
324
258
  return;
325
259
  }
326
260
  const block_1 = pageBlocks.find((b_1) => b_1.id === sel_2.blockId);
327
- duplicateBlock({ id: sel_2.blockId }).then(() => toast.success(`Duplicated "${block_1 ? entityName(block_1, block_1.type) : ""}" block`), _temp9);
261
+ duplicateBlock({ id: sel_2.blockId }).then(() => toast.success(`Duplicated "${block_1 ? entityName(block_1, block_1.type) : ""}" block`), _temp8);
328
262
  }
329
263
  },
330
264
  {
@@ -351,7 +285,7 @@ function useBlockActionsShortcuts() {
351
285
  id: sel_4.blockId,
352
286
  afterPosition,
353
287
  beforePosition
354
- }).then(_temp10, _temp11);
288
+ }).then(_temp9, _temp10);
355
289
  }
356
290
  },
357
291
  {
@@ -379,50 +313,7 @@ function useBlockActionsShortcuts() {
379
313
  id: sel_6.blockId,
380
314
  afterPosition: afterPosition_0,
381
315
  beforePosition: beforePosition_0
382
- }).then(_temp12, _temp13);
383
- }
384
- },
385
- {
386
- id: "add-block-below",
387
- label: "Add block below",
388
- groupLabel: "Website",
389
- shortcut: "O",
390
- checkIfAvailable: () => {
391
- const ctx_3 = previewStore.getSnapshot().context;
392
- if (ctx_3.view !== "canvas") return false;
393
- return blockSelectionForPage(ctx_3, page.page.id) !== null;
394
- },
395
- execute: () => {
396
- const sel_7 = blockSelectionForPage(previewStore.getSnapshot().context, page.page.id);
397
- if (!sel_7 || !page) return;
398
- const block_2 = pageBlocks.find((b_6) => b_6.id === sel_7.blockId);
399
- if (!block_2) return;
400
- previewStore.send({
401
- type: "openAddBlockSheet",
402
- afterPosition: block_2.position
403
- });
404
- }
405
- },
406
- {
407
- id: "add-block-above",
408
- label: "Add block above",
409
- groupLabel: "Website",
410
- shortcut: "Shift+O",
411
- checkIfAvailable: () => {
412
- const ctx_4 = previewStore.getSnapshot().context;
413
- if (ctx_4.view !== "canvas") return false;
414
- return blockSelectionForPage(ctx_4, page.page.id) !== null;
415
- },
416
- execute: () => {
417
- const sel_8 = blockSelectionForPage(previewStore.getSnapshot().context, page.page.id);
418
- if (!sel_8 || !page) return;
419
- const blockIndex = pageBlocks.findIndex((b_7) => b_7.id === sel_8.blockId);
420
- if (blockIndex === -1) return;
421
- const afterPosition_1 = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
422
- previewStore.send({
423
- type: "openAddBlockSheet",
424
- afterPosition: afterPosition_1
425
- });
316
+ }).then(_temp11, _temp12);
426
317
  }
427
318
  }
428
319
  ];
@@ -433,7 +324,7 @@ function useBlockActionsShortcuts() {
433
324
  return () => {
434
325
  actionsStore.send({
435
326
  type: "unregisterManyActions",
436
- ids: actions.map(_temp14)
327
+ ids: actions.map(_temp13)
437
328
  });
438
329
  };
439
330
  };
@@ -470,33 +361,33 @@ function useBlockActionsShortcuts() {
470
361
  } else t6 = $[22];
471
362
  React.useEffect(t5, t6);
472
363
  }
473
- function _temp14(a) {
364
+ function _temp13(a) {
474
365
  return a.id;
475
366
  }
476
- function _temp13() {
367
+ function _temp12() {
477
368
  return toast.error("Could not move block");
478
369
  }
479
- function _temp12() {}
480
- function _temp11() {
370
+ function _temp11() {}
371
+ function _temp10() {
481
372
  return toast.error("Could not move block");
482
373
  }
483
- function _temp10() {}
484
- function _temp9() {
374
+ function _temp9() {}
375
+ function _temp8() {
485
376
  return toast.error("Could not duplicate block");
486
377
  }
487
- function _temp8() {
378
+ function _temp7() {
488
379
  return toast.error("Could not duplicate item");
489
380
  }
490
- function _temp7() {
381
+ function _temp6() {
491
382
  return toast.success("Duplicated item");
492
383
  }
493
- function _temp6() {
384
+ function _temp5() {
494
385
  return toast.error("Could not delete block");
495
386
  }
496
- function _temp5() {
387
+ function _temp4() {
497
388
  return toast.error("Could not delete item");
498
389
  }
499
- function _temp4() {
390
+ function _temp3() {
500
391
  return toast.success("Deleted item");
501
392
  }
502
393
 
@@ -1,8 +1,8 @@
1
1
  import { CanvasLoadingScreen } from "../../canvas/CanvasLoadingScreen.js";
2
- import { ViewportContinuity, ViewportContinuityContext } from "../viewportContinuity.js";
3
- import { PreviewActivationContext } from "./PreviewActivation.js";
4
2
  import { PreviewPageFrame, PreviewPageFrameContext } from "../previewPageFrame.js";
5
3
  import { PreviewPreparationContext } from "../previewPreparation.js";
4
+ import { ViewportContinuity, ViewportContinuityContext } from "../viewportContinuity.js";
5
+ import { PreviewActivationContext } from "./PreviewActivation.js";
6
6
  import { c } from "react/compiler-runtime";
7
7
  import * as React from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1,11 +1,11 @@
1
1
  import { useLocation, useNavigate } from "../../navigation/navigation.js";
2
2
  import { cn } from "../../../lib/utils.js";
3
- import { listenForLinkIntent } from "../../runtime/linkPrefetch.js";
4
- import { PageViewportContext } from "../../runtime/pageViewport.js";
5
- import { PreviewDocumentContext } from "../../runtime/PreviewDocumentContext.js";
6
3
  import { ViewportContinuityContext, capturePreviewAnchor, restorePreviewAnchor } from "../viewportContinuity.js";
7
4
  import { PreviewActivationContext } from "./PreviewActivation.js";
8
5
  import { EMPTY_PREVIEW_DOCUMENT, isSiteStyle, restyle } from "./previewStyles.js";
6
+ import { listenForLinkIntent } from "../../runtime/linkPrefetch.js";
7
+ import { PageViewportContext } from "../../runtime/pageViewport.js";
8
+ import { PreviewDocumentContext } from "../../runtime/PreviewDocumentContext.js";
9
9
  import { c } from "react/compiler-runtime";
10
10
  import * as React from "react";
11
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -6,8 +6,8 @@ import { Button } from "@camox/ui/button";
6
6
  import { ChevronsUpDown, SearchIcon } from "lucide-react";
7
7
  import { Combobox } from "@base-ui/react/combobox";
8
8
  import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
9
- import { commandFilter } from "@camox/ui/command";
10
9
  import { InputGroup, InputGroupAddon, InputGroupInput } from "@camox/ui/input-group";
10
+ import { commandFilter } from "@camox/ui/command";
11
11
  import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual";
12
12
 
13
13
  //#region src/features/preview/components/IconFieldEditor.tsx
@@ -258,7 +258,6 @@ const ItemFieldsEditor = (t0) => {
258
258
  const renderField = () => {
259
259
  if (field_0.fieldType === "Reference" && field_0.collectionId) return /* @__PURE__ */ jsx(ReferenceFieldEditor, {
260
260
  collectionId: field_0.collectionId,
261
- fieldId: fieldId_1,
262
261
  value: data[field_0.name],
263
262
  required: field_0.required,
264
263
  record: singleReference(references, field_0.name),
@@ -273,7 +272,6 @@ const ItemFieldsEditor = (t0) => {
273
272
  }, field_0.name);
274
273
  if (field_0.fieldType === "ReferenceList" && field_0.collectionId) return /* @__PURE__ */ jsx(ReferenceListFieldEditor, {
275
274
  collectionId: field_0.collectionId,
276
- fieldId: fieldId_1,
277
275
  value: data[field_0.name],
278
276
  maxItems: field_0.maxItems,
279
277
  query: field_0.query,
@@ -358,7 +356,7 @@ const ItemFieldsEditor = (t0) => {
358
356
  }, field_0.name);
359
357
  }
360
358
  if (field_0.fieldType === "Icon") return /* @__PURE__ */ jsx(IconFieldEditor, {
361
- value: String(data[field_0.name] ?? schema?.properties?.[field_0.name]?.default ?? ""),
359
+ value: typeof data[field_0.name] === "string" ? data[field_0.name] : "",
362
360
  ids: field_0.enumValues ?? [],
363
361
  onChange: (value_3) => onFieldChange(field_0.name, value_3)
364
362
  }, field_0.name);
@@ -1,69 +1,11 @@
1
- import { usePageBlocks } from "../../../lib/normalized-data.js";
2
- import { previewStore, selectIsCanvasShown, selectionForOwner } from "../previewStore.js";
1
+ import { previewStore, selectionForOwner } from "../previewStore.js";
3
2
  import { useEditingFrame } from "../editingFrame.js";
4
- import { isOverlayMessage, overlayFieldId, recordFieldId } from "../overlayMessages.js";
5
- import { usePreviewedPage } from "../CamoxPreview.js";
3
+ import { overlayFieldId, recordFieldId } from "../overlayMessages.js";
6
4
  import { c } from "react/compiler-runtime";
7
5
  import * as React from "react";
8
- import { jsx } from "react/jsx-runtime";
9
6
  import { useSelector } from "@xstate/store-react";
10
7
 
11
8
  //#region src/features/preview/components/Overlays.tsx
12
- function CuratedAddBlockListener(t0) {
13
- const $ = c(5);
14
- const { frame } = t0;
15
- const page = usePreviewedPage();
16
- const { pageBlocks } = usePageBlocks(page);
17
- const { document: editingDocument } = useEditingFrame();
18
- const isEditingFrame = !!editingDocument && editingDocument === frame?.contentDocument;
19
- let t1;
20
- let t2;
21
- if ($[0] !== isEditingFrame || $[1] !== page.page.id || $[2] !== pageBlocks) {
22
- t1 = () => {
23
- const handleMessage = (event) => {
24
- if (!isOverlayMessage(event.data)) return;
25
- const message = event.data;
26
- if (message.type === "CAMOX_ADD_BLOCK_REQUEST") {
27
- const snapshot = previewStore.getSnapshot();
28
- if (!selectIsCanvasShown(snapshot)) return;
29
- if (!isEditingFrame) return;
30
- const owner = snapshot.context.editingContext;
31
- if (owner?.kind !== "page" || owner.pageId !== page.page.id) return;
32
- const { blockPosition, insertPosition } = message;
33
- let afterPosition = null;
34
- if (message.afterPosition !== void 0) afterPosition = message.afterPosition;
35
- else if (insertPosition === "after") afterPosition = blockPosition;
36
- else {
37
- const blockIndex = pageBlocks.findIndex((b) => b.position === blockPosition);
38
- if (blockIndex > 0) afterPosition = pageBlocks[blockIndex - 1].position ?? null;
39
- else if (blockIndex === 0) afterPosition = "";
40
- }
41
- previewStore.send({
42
- type: "openAddBlockSheet",
43
- afterPosition
44
- });
45
- }
46
- };
47
- window.addEventListener("message", handleMessage);
48
- return () => window.removeEventListener("message", handleMessage);
49
- };
50
- t2 = [
51
- pageBlocks,
52
- page.page.id,
53
- isEditingFrame
54
- ];
55
- $[0] = isEditingFrame;
56
- $[1] = page.page.id;
57
- $[2] = pageBlocks;
58
- $[3] = t1;
59
- $[4] = t2;
60
- } else {
61
- t1 = $[3];
62
- t2 = $[4];
63
- }
64
- React.useEffect(t1, t2);
65
- return null;
66
- }
67
9
  /** The field ID of a selected String field; only those are focused in the page. */
68
10
  function stringFieldId(selection) {
69
11
  if (!selection) return null;
@@ -75,22 +17,21 @@ function stringFieldId(selection) {
75
17
  }
76
18
  }
77
19
  const Overlays = (t0) => {
78
- const $ = c(10);
79
- const { frame, canAddBlocks: t1, owner } = t0;
80
- const canAddBlocks = t1 === void 0 ? false : t1;
81
- let t2;
20
+ const $ = c(7);
21
+ const { frame, owner } = t0;
22
+ let t1;
82
23
  if ($[0] !== owner) {
83
- t2 = (state) => selectionForOwner(state.context, owner);
24
+ t1 = (state) => selectionForOwner(state.context, owner);
84
25
  $[0] = owner;
85
- $[1] = t2;
86
- } else t2 = $[1];
87
- const selection = useSelector(previewStore, t2);
26
+ $[1] = t1;
27
+ } else t1 = $[1];
28
+ const selection = useSelector(previewStore, t1);
88
29
  const { document: editingDocument, send } = useEditingFrame();
89
30
  const isEditingFrame = !!editingDocument && editingDocument === frame?.contentDocument;
31
+ let t2;
90
32
  let t3;
91
- let t4;
92
33
  if ($[2] !== isEditingFrame || $[3] !== selection || $[4] !== send) {
93
- t3 = () => {
34
+ t2 = () => {
94
35
  const fieldId = stringFieldId(selection);
95
36
  if (!fieldId || !isEditingFrame) return;
96
37
  send({
@@ -98,7 +39,7 @@ const Overlays = (t0) => {
98
39
  fieldId
99
40
  });
100
41
  };
101
- t4 = [
42
+ t3 = [
102
43
  selection,
103
44
  isEditingFrame,
104
45
  send
@@ -106,21 +47,14 @@ const Overlays = (t0) => {
106
47
  $[2] = isEditingFrame;
107
48
  $[3] = selection;
108
49
  $[4] = send;
109
- $[5] = t3;
110
- $[6] = t4;
50
+ $[5] = t2;
51
+ $[6] = t3;
111
52
  } else {
112
- t3 = $[5];
113
- t4 = $[6];
53
+ t2 = $[5];
54
+ t3 = $[6];
114
55
  }
115
- React.useEffect(t3, t4);
116
- let t5;
117
- if ($[7] !== canAddBlocks || $[8] !== frame) {
118
- t5 = canAddBlocks ? /* @__PURE__ */ jsx(CuratedAddBlockListener, { frame }) : null;
119
- $[7] = canAddBlocks;
120
- $[8] = frame;
121
- $[9] = t5;
122
- } else t5 = $[9];
123
- return t5;
56
+ React.useEffect(t2, t3);
57
+ return null;
124
58
  };
125
59
 
126
60
  //#endregion