camox 0.6.1 → 0.7.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 (77) hide show
  1. package/dist/core/components/AddBlockControlBar.d.ts.map +1 -1
  2. package/dist/core/components/AddBlockControlBar.js +51 -117
  3. package/dist/core/components/lexical/InlineLexicalEditor.js +1 -1
  4. package/dist/core/components/lexical/SidebarLexicalEditor.js +1 -1
  5. package/dist/core/createApp.d.ts +314 -44
  6. package/dist/core/createApp.d.ts.map +1 -1
  7. package/dist/core/createBlock.d.ts +160 -22
  8. package/dist/core/createBlock.d.ts.map +1 -1
  9. package/dist/core/createBlock.js +467 -579
  10. package/dist/features/content/components/AssetCard.js +1 -1
  11. package/dist/features/preview/CamoxPreview.d.ts.map +1 -1
  12. package/dist/features/preview/CamoxPreview.js +12 -16
  13. package/dist/features/preview/components/AddBlockSheet.d.ts.map +1 -1
  14. package/dist/features/preview/components/AddBlockSheet.js +1 -2
  15. package/dist/features/preview/components/AssetLightbox.d.ts.map +1 -1
  16. package/dist/features/preview/components/AssetLightbox.js +13 -15
  17. package/dist/features/preview/components/BlockActionsPopover.d.ts.map +1 -1
  18. package/dist/features/preview/components/BlockActionsPopover.js +19 -22
  19. package/dist/features/preview/components/CreatePageSheet.d.ts.map +1 -1
  20. package/dist/features/preview/components/CreatePageSheet.js +10 -4
  21. package/dist/features/preview/components/EditPageSheet.d.ts +1 -1
  22. package/dist/features/preview/components/EditPageSheet.d.ts.map +1 -1
  23. package/dist/features/preview/components/EditPageSheet.js +20 -17
  24. package/dist/features/preview/components/FieldOverlayStyles.d.ts +2 -0
  25. package/dist/features/preview/components/FieldOverlayStyles.d.ts.map +1 -0
  26. package/dist/features/preview/components/FieldOverlayStyles.js +15 -0
  27. package/dist/features/preview/components/Frame.d.ts +20 -0
  28. package/dist/features/preview/components/Frame.d.ts.map +1 -0
  29. package/dist/features/preview/components/Frame.js +162 -0
  30. package/dist/features/preview/components/LinkFieldEditor.d.ts.map +1 -1
  31. package/dist/features/preview/components/LinkFieldEditor.js +11 -12
  32. package/dist/features/preview/components/OverlayTracker.js +1 -1
  33. package/dist/features/preview/components/PageContentSheet.d.ts.map +1 -1
  34. package/dist/features/preview/components/PageContentSheet.js +3 -3
  35. package/dist/features/preview/components/PageLocationFieldset.d.ts.map +1 -1
  36. package/dist/features/preview/components/PageLocationFieldset.js +9 -11
  37. package/dist/features/preview/components/PagePicker.d.ts.map +1 -1
  38. package/dist/features/preview/components/PagePicker.js +15 -15
  39. package/dist/features/preview/components/PageTree.d.ts.map +1 -1
  40. package/dist/features/preview/components/PageTree.js +215 -203
  41. package/dist/features/preview/components/PreviewPanel.d.ts.map +1 -1
  42. package/dist/features/preview/components/PreviewPanel.js +21 -15
  43. package/dist/features/preview/components/PreviewSideSheet.d.ts.map +1 -1
  44. package/dist/features/preview/components/PreviewSideSheet.js +42 -26
  45. package/dist/features/preview/components/PreviewToolbar.d.ts.map +1 -1
  46. package/dist/features/preview/components/PreviewToolbar.js +191 -171
  47. package/dist/features/preview/components/RepeatableItemsList.d.ts.map +1 -1
  48. package/dist/features/preview/components/RepeatableItemsList.js +4 -5
  49. package/dist/features/preview/components/TextFormatToolbar.d.ts.map +1 -1
  50. package/dist/features/preview/components/TextFormatToolbar.js +5 -6
  51. package/dist/features/preview/components/UnlinkAssetButton.d.ts.map +1 -1
  52. package/dist/features/preview/components/UnlinkAssetButton.js +70 -91
  53. package/dist/features/preview/studio-overlays.css?inline.js +4 -0
  54. package/dist/features/provider/components/CamoxAppContext.d.ts +314 -44
  55. package/dist/features/provider/components/CamoxAppContext.d.ts.map +1 -1
  56. package/dist/features/provider/components/CommandPalette.d.ts.map +1 -1
  57. package/dist/features/provider/components/CommandPalette.js +22 -14
  58. package/dist/features/studio/CamoxStudio.d.ts +2 -3
  59. package/dist/features/studio/CamoxStudio.d.ts.map +1 -1
  60. package/dist/features/studio/components/EnvironmentMenu.d.ts.map +1 -1
  61. package/dist/features/studio/components/EnvironmentMenu.js +39 -35
  62. package/dist/features/studio/components/Navbar.js +2 -2
  63. package/dist/features/studio/components/ProjectMenu.d.ts.map +1 -1
  64. package/dist/features/studio/components/ProjectMenu.js +143 -129
  65. package/dist/features/studio/components/UserButton.d.ts.map +1 -1
  66. package/dist/features/studio/components/UserButton.js +8 -9
  67. package/dist/features/vite/vite.d.ts +2 -0
  68. package/dist/features/vite/vite.d.ts.map +1 -1
  69. package/dist/features/vite/vite.js +26 -30
  70. package/dist/lib/api-client.d.ts +17 -17
  71. package/dist/lib/queries.d.ts +7 -7
  72. package/dist/studio.css +1 -1
  73. package/package.json +5 -6
  74. package/skills/camox-block/SKILL.md +55 -28
  75. package/dist/features/preview/overlayConstants.d.ts +0 -19
  76. package/dist/features/preview/overlayConstants.d.ts.map +0 -1
  77. package/dist/features/preview/overlayConstants.js +0 -21
@@ -2,7 +2,7 @@ import { previewStore } from "../features/preview/previewStore.js";
2
2
  import { useIsPreviewSheetOpen } from "../features/preview/components/PreviewSideSheet.js";
3
3
  import { useProjectSlug } from "../lib/auth.js";
4
4
  import { blockMutations, pageQueries, projectQueries, repeatableItemMutations } from "../lib/queries.js";
5
- import { LAYOUT_OVERLAY_COLORS, OVERLAY_COLORS, OVERLAY_OFFSETS, OVERLAY_WIDTHS } from "../features/preview/overlayConstants.js";
5
+ import { useFrame } from "../features/preview/components/Frame.js";
6
6
  import { postOverlayMessage } from "../features/preview/overlayMessages.js";
7
7
  import { isFileMarker, isItemMarker, resolveFileMarker, useNormalizedData } from "../lib/normalized-data.js";
8
8
  import { AddBlockControlBar } from "./components/AddBlockControlBar.js";
@@ -13,13 +13,11 @@ import { useOverlayMessage } from "./hooks/useOverlayMessage.js";
13
13
  import { Type } from "./lib/contentType.js";
14
14
  import { markdownToReactNodes } from "./lib/lexicalReact.js";
15
15
  import { c } from "react/compiler-runtime";
16
- import { useFrame } from "@camox/ui/frame";
17
16
  import { Input } from "@camox/ui/input";
18
17
  import { Kbd } from "@camox/ui/kbd";
19
18
  import { Label } from "@camox/ui/label";
20
- import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
19
+ import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
21
20
  import { toast } from "@camox/ui/toaster";
22
- import { Slot } from "@radix-ui/react-slot";
23
21
  import { Type as Type$1 } from "@sinclair/typebox";
24
22
  import { useMutation, useQuery } from "@tanstack/react-query";
25
23
  import { useSelector } from "@xstate/store/react";
@@ -179,7 +177,6 @@ function createBlock(options) {
179
177
  if (!blockContext) throw new Error("Field must be used within a Block Component");
180
178
  const { blockId, content, mode } = blockContext;
181
179
  const isContentEditable = useIsEditable(mode);
182
- const colors = mode === "layout" ? LAYOUT_OVERLAY_COLORS : OVERLAY_COLORS;
183
180
  const elementRef = React.useRef(null);
184
181
  const { window: iframeWindow } = useFrame();
185
182
  const repeaterContext = React.use(RepeaterItemContext);
@@ -242,34 +239,32 @@ function createBlock(options) {
242
239
  const handleMouseLeave = () => {
243
240
  if (isContentEditable) setIsHovered(false);
244
241
  };
245
- const overlayStyle = isContentEditable && (isHovered || isFocused) ? {
246
- outline: `${isFocused ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isFocused ? colors.selected : colors.hover}`,
247
- outlineOffset: isFocused ? OVERLAY_OFFSETS.fieldSelected : OVERLAY_OFFSETS.fieldHover
248
- } : void 0;
249
- if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children(markdownToReactNodes(fieldValue)) });
250
- return /* @__PURE__ */ jsx(Slot, {
242
+ const fieldData = { text: fieldValue };
243
+ if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children({ children: markdownToReactNodes(fieldValue) }, fieldData) });
244
+ return /* @__PURE__ */ jsx(Fragment, { children: children({
251
245
  ref: elementRef,
252
246
  "data-camox-field-id": fieldId,
247
+ "data-camox-hovered": isHovered || void 0,
248
+ "data-camox-focused": isFocused || void 0,
249
+ "data-camox-overlay-mode": mode === "layout" ? "layout" : void 0,
253
250
  onMouseEnter: handleMouseEnter,
254
251
  onMouseLeave: handleMouseLeave,
255
- style: overlayStyle,
256
- children: children(/* @__PURE__ */ jsx(InlineLexicalEditor, {
252
+ children: /* @__PURE__ */ jsx(InlineLexicalEditor, {
257
253
  initialState: fieldValue,
258
254
  externalState: fieldValue,
259
255
  onChange: handleChange,
260
256
  onFocus: handleFocus,
261
257
  onBlur: handleBlur
262
- }))
263
- });
258
+ })
259
+ }, fieldData) });
264
260
  };
265
261
  const Embed = (t0) => {
266
- const $ = c(55);
262
+ const $ = c(58);
267
263
  const { name, children } = t0;
268
264
  const blockContext = React.use(Context);
269
265
  if (!blockContext) throw new Error("Embed must be used within a Block Component");
270
266
  const { blockId, content, mode } = blockContext;
271
267
  const isContentEditable = useIsEditable(mode);
272
- const colors = mode === "layout" ? LAYOUT_OVERLAY_COLORS : OVERLAY_COLORS;
273
268
  const { window: iframeWindow } = useFrame();
274
269
  const repeaterContext = React.use(RepeaterItemContext);
275
270
  const fieldValue = repeaterContext ? repeaterContext.itemContent[name] : content[name];
@@ -378,7 +373,7 @@ function createBlock(options) {
378
373
  const handleUrlChange = t12;
379
374
  let t13;
380
375
  if ($[23] !== blockId || $[24] !== name || $[25] !== repeaterContext) {
381
- t13 = (open) => {
376
+ t13 = (open, _eventDetails) => {
382
377
  setIsOpen(open);
383
378
  if (open) if (repeaterContext?.itemId) previewStore.send({
384
379
  type: "selectItemField",
@@ -402,72 +397,78 @@ function createBlock(options) {
402
397
  const handleOpenChange = t13;
403
398
  const t14 = isContentEditable ? isOpen : false;
404
399
  const t15 = isContentEditable ? handleOpenChange : void 0;
405
- let t16;
406
- if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
407
- t16 = { position: "relative" };
408
- $[27] = t16;
409
- } else t16 = $[27];
410
- let t17;
411
- if ($[28] !== isContentEditable) {
412
- t17 = isContentEditable ? () => setIsHovered(true) : void 0;
413
- $[28] = isContentEditable;
414
- $[29] = t17;
415
- } else t17 = $[29];
416
- let t18;
417
- if ($[30] !== isContentEditable) {
418
- t18 = isContentEditable ? () => setIsHovered(false) : void 0;
419
- $[30] = isContentEditable;
420
- $[31] = t18;
421
- } else t18 = $[31];
422
- let t19;
423
- if ($[32] !== children || $[33] !== fieldValue) {
424
- t19 = children(fieldValue);
425
- $[32] = children;
426
- $[33] = fieldValue;
400
+ const t16 = isContentEditable ? fieldId : void 0;
401
+ const t17 = isContentEditable ? "embed" : void 0;
402
+ const t18 = isContentEditable && isHovered || void 0;
403
+ const t19 = isContentEditable && isOpen || void 0;
404
+ const t20 = mode === "layout" ? "layout" : void 0;
405
+ let t21;
406
+ if ($[27] !== isContentEditable) {
407
+ t21 = isContentEditable ? () => setIsHovered(true) : void 0;
408
+ $[27] = isContentEditable;
409
+ $[28] = t21;
410
+ } else t21 = $[28];
411
+ let t22;
412
+ if ($[29] !== isContentEditable) {
413
+ t22 = isContentEditable ? () => setIsHovered(false) : void 0;
414
+ $[29] = isContentEditable;
415
+ $[30] = t22;
416
+ } else t22 = $[30];
417
+ let t23;
418
+ if ($[31] !== t16 || $[32] !== t17 || $[33] !== t18 || $[34] !== t19 || $[35] !== t20 || $[36] !== t21 || $[37] !== t22) {
419
+ t23 = /* @__PURE__ */ jsx("div", {
420
+ "data-camox-field-id": t16,
421
+ "data-camox-field-type": t17,
422
+ "data-camox-hovered": t18,
423
+ "data-camox-focused": t19,
424
+ "data-camox-overlay-mode": t20,
425
+ onMouseEnter: t21,
426
+ onMouseLeave: t22
427
+ });
428
+ $[31] = t16;
429
+ $[32] = t17;
430
+ $[33] = t18;
427
431
  $[34] = t19;
428
- } else t19 = $[34];
429
- let t20;
430
- if ($[35] !== colors || $[36] !== isContentEditable || $[37] !== isHovered || $[38] !== isOpen) {
431
- t20 = isContentEditable && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
432
+ $[35] = t20;
433
+ $[36] = t21;
434
+ $[37] = t22;
435
+ $[38] = t23;
436
+ } else t23 = $[38];
437
+ let t24;
438
+ if ($[39] !== children || $[40] !== fieldValue) {
439
+ t24 = children({ src: fieldValue }, { url: fieldValue });
440
+ $[39] = children;
441
+ $[40] = fieldValue;
442
+ $[41] = t24;
443
+ } else t24 = $[41];
444
+ let t25;
445
+ if ($[42] !== isContentEditable) {
446
+ t25 = isContentEditable && /* @__PURE__ */ jsx("div", {
432
447
  style: {
433
448
  position: "absolute",
434
449
  inset: 0,
435
450
  zIndex: 10
436
451
  },
437
452
  onClick: _temp
438
- }), (isHovered || isOpen) && /* @__PURE__ */ jsx("div", { style: {
439
- position: "absolute",
440
- inset: isOpen ? OVERLAY_OFFSETS.blockSelected : OVERLAY_OFFSETS.blockHover,
441
- border: `${isOpen ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isOpen ? colors.selected : colors.hover}`,
442
- pointerEvents: "none",
443
- zIndex: 11
444
- } })] });
445
- $[35] = colors;
446
- $[36] = isContentEditable;
447
- $[37] = isHovered;
448
- $[38] = isOpen;
449
- $[39] = t20;
450
- } else t20 = $[39];
451
- let t21;
452
- if ($[40] !== t17 || $[41] !== t18 || $[42] !== t19 || $[43] !== t20) {
453
- t21 = /* @__PURE__ */ jsx(PopoverTrigger, {
454
- asChild: true,
455
- children: /* @__PURE__ */ jsxs("div", {
456
- style: t16,
457
- onMouseEnter: t17,
458
- onMouseLeave: t18,
459
- children: [t19, t20]
460
- })
461
453
  });
462
- $[40] = t17;
463
- $[41] = t18;
464
- $[42] = t19;
465
- $[43] = t20;
466
- $[44] = t21;
467
- } else t21 = $[44];
468
- let t22;
469
- if ($[45] !== handleUrlChange || $[46] !== isContentEditable || $[47] !== name || $[48] !== urlValue) {
470
- t22 = isContentEditable && /* @__PURE__ */ jsx(PopoverContent, {
454
+ $[42] = isContentEditable;
455
+ $[43] = t25;
456
+ } else t25 = $[43];
457
+ let t26;
458
+ if ($[44] !== t23 || $[45] !== t24 || $[46] !== t25) {
459
+ t26 = /* @__PURE__ */ jsxs(PopoverTrigger, {
460
+ render: t23,
461
+ nativeButton: false,
462
+ children: [t24, t25]
463
+ });
464
+ $[44] = t23;
465
+ $[45] = t24;
466
+ $[46] = t25;
467
+ $[47] = t26;
468
+ } else t26 = $[47];
469
+ let t27;
470
+ if ($[48] !== handleUrlChange || $[49] !== isContentEditable || $[50] !== name || $[51] !== urlValue) {
471
+ t27 = isContentEditable && /* @__PURE__ */ jsx(PopoverContent, {
471
472
  className: "w-96 gap-2",
472
473
  children: /* @__PURE__ */ jsxs("form", {
473
474
  className: "grid gap-2",
@@ -482,35 +483,34 @@ function createBlock(options) {
482
483
  })]
483
484
  })
484
485
  });
485
- $[45] = handleUrlChange;
486
- $[46] = isContentEditable;
487
- $[47] = name;
488
- $[48] = urlValue;
489
- $[49] = t22;
490
- } else t22 = $[49];
491
- let t23;
492
- if ($[50] !== t14 || $[51] !== t15 || $[52] !== t21 || $[53] !== t22) {
493
- t23 = /* @__PURE__ */ jsxs(Popover, {
486
+ $[48] = handleUrlChange;
487
+ $[49] = isContentEditable;
488
+ $[50] = name;
489
+ $[51] = urlValue;
490
+ $[52] = t27;
491
+ } else t27 = $[52];
492
+ let t28;
493
+ if ($[53] !== t14 || $[54] !== t15 || $[55] !== t26 || $[56] !== t27) {
494
+ t28 = /* @__PURE__ */ jsxs(Popover, {
494
495
  open: t14,
495
496
  onOpenChange: t15,
496
- children: [t21, t22]
497
+ children: [t26, t27]
497
498
  });
498
- $[50] = t14;
499
- $[51] = t15;
500
- $[52] = t21;
501
- $[53] = t22;
502
- $[54] = t23;
503
- } else t23 = $[54];
504
- return t23;
499
+ $[53] = t14;
500
+ $[54] = t15;
501
+ $[55] = t26;
502
+ $[56] = t27;
503
+ $[57] = t28;
504
+ } else t28 = $[57];
505
+ return t28;
505
506
  };
506
507
  const Link = (t0) => {
507
- const $ = c(63);
508
+ const $ = c(36);
508
509
  const { name, children } = t0;
509
510
  const blockContext = React.use(Context);
510
511
  if (!blockContext) throw new Error("Link must be used within a Block Component");
511
512
  const { blockId, content, mode } = blockContext;
512
513
  const isContentEditable = useIsEditable(mode);
513
- const colors = mode === "layout" ? LAYOUT_OVERLAY_COLORS : OVERLAY_COLORS;
514
514
  const elementRef = React.useRef(null);
515
515
  const { window: iframeWindow } = useFrame();
516
516
  const repeaterContext = React.use(RepeaterItemContext);
@@ -554,16 +554,7 @@ function createBlock(options) {
554
554
  } else t6 = $[8];
555
555
  const { data: pages } = useQuery(t6);
556
556
  const resolvedHref = resolveLinkHref(fieldValue, pages);
557
- const t7 = String(name);
558
- let t8;
559
- if ($[9] !== blockId || $[10] !== repeaterContext || $[11] !== t7) {
560
- t8 = getOverlayFieldId(blockId, repeaterContext, t7);
561
- $[9] = blockId;
562
- $[10] = repeaterContext;
563
- $[11] = t7;
564
- $[12] = t8;
565
- } else t8 = $[12];
566
- const fieldId = t8;
557
+ const fieldId = getOverlayFieldId(blockId, repeaterContext, String(name));
567
558
  const [isEditing, setIsEditing] = React.useState(false);
568
559
  const [displayText, setDisplayText] = React.useState(fieldValue.text);
569
560
  const [isHovered, setIsHovered] = React.useState(false);
@@ -573,31 +564,25 @@ function createBlock(options) {
573
564
  React.useEffect(() => {
574
565
  if (!isEditing) setDisplayText(fieldValue.text);
575
566
  }, [fieldValue.text, isEditing]);
576
- let t9;
577
- if ($[13] !== fieldId) {
578
- t9 = { fieldId };
579
- $[13] = fieldId;
580
- $[14] = t9;
581
- } else t9 = $[14];
582
- const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t9);
583
- let t10;
584
- let t11;
585
- if ($[15] !== isHoveredFromSidebar) {
586
- t10 = () => {
567
+ const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", { fieldId });
568
+ let t7;
569
+ let t8;
570
+ if ($[9] !== isHoveredFromSidebar) {
571
+ t7 = () => {
587
572
  setIsHovered(isHoveredFromSidebar);
588
573
  };
589
- t11 = [isHoveredFromSidebar];
590
- $[15] = isHoveredFromSidebar;
591
- $[16] = t10;
592
- $[17] = t11;
574
+ t8 = [isHoveredFromSidebar];
575
+ $[9] = isHoveredFromSidebar;
576
+ $[10] = t7;
577
+ $[11] = t8;
593
578
  } else {
594
- t10 = $[16];
595
- t11 = $[17];
579
+ t7 = $[10];
580
+ t8 = $[11];
596
581
  }
597
- React.useEffect(t10, t11);
598
- let t12;
599
- if ($[18] !== blockId || $[19] !== name || $[20] !== repeaterContext || $[21] !== updateBlockContent || $[22] !== updateRepeatableContent) {
600
- t12 = (newLinkValue) => {
582
+ React.useEffect(t7, t8);
583
+ let t9;
584
+ if ($[12] !== blockId || $[13] !== name || $[14] !== repeaterContext || $[15] !== updateBlockContent || $[16] !== updateRepeatableContent) {
585
+ t9 = (newLinkValue) => {
601
586
  if (repeaterContext?.itemId) updateRepeatableContent.mutate({
602
587
  id: Number(repeaterContext.itemId),
603
588
  content: { [name]: newLinkValue }
@@ -607,14 +592,14 @@ function createBlock(options) {
607
592
  content: { [name]: newLinkValue }
608
593
  });
609
594
  };
610
- $[18] = blockId;
611
- $[19] = name;
612
- $[20] = repeaterContext;
613
- $[21] = updateBlockContent;
614
- $[22] = updateRepeatableContent;
615
- $[23] = t12;
616
- } else t12 = $[23];
617
- const saveLinkValue = t12;
595
+ $[12] = blockId;
596
+ $[13] = name;
597
+ $[14] = repeaterContext;
598
+ $[15] = updateBlockContent;
599
+ $[16] = updateRepeatableContent;
600
+ $[17] = t9;
601
+ } else t9 = $[17];
602
+ const saveLinkValue = t9;
618
603
  const handleInput = (e) => {
619
604
  const newText = e.target.textContent || "";
620
605
  saveLinkValue({
@@ -622,9 +607,9 @@ function createBlock(options) {
622
607
  text: newText
623
608
  });
624
609
  };
625
- let t13;
626
- if ($[24] !== blockId || $[25] !== name || $[26] !== repeaterContext) {
627
- t13 = () => {
610
+ let t10;
611
+ if ($[18] !== blockId || $[19] !== name || $[20] !== repeaterContext) {
612
+ t10 = () => {
628
613
  setIsEditing(true);
629
614
  setIsEditorFocused(true);
630
615
  if (repeaterContext?.itemId) previewStore.send({
@@ -641,202 +626,165 @@ function createBlock(options) {
641
626
  fieldType: "Link"
642
627
  });
643
628
  };
644
- $[24] = blockId;
645
- $[25] = name;
646
- $[26] = repeaterContext;
647
- $[27] = t13;
648
- } else t13 = $[27];
649
- const handleFocus = t13;
650
- let t14;
651
- if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
652
- t14 = () => {
629
+ $[18] = blockId;
630
+ $[19] = name;
631
+ $[20] = repeaterContext;
632
+ $[21] = t10;
633
+ } else t10 = $[21];
634
+ const handleFocus = t10;
635
+ let t11;
636
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
637
+ t11 = () => {
653
638
  setIsEditing(false);
654
639
  setIsEditorFocused(false);
655
640
  };
656
- $[28] = t14;
657
- } else t14 = $[28];
658
- const handleBlur = t14;
659
- let t15;
660
- if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
661
- t15 = (e_0) => {
641
+ $[22] = t11;
642
+ } else t11 = $[22];
643
+ const handleBlur = t11;
644
+ let t12;
645
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
646
+ t12 = (e_0) => {
662
647
  e_0.stopPropagation();
663
648
  previewStore.send({ type: "toggleContentSheet" });
664
649
  setIsEditorFocused(false);
665
650
  setIsEditing(false);
666
651
  };
667
- $[29] = t15;
668
- } else t15 = $[29];
669
- const handleEditLink = t15;
670
- const T0 = Popover;
671
- const t16 = isContentEditable && isEditorFocused;
672
- const T1 = PopoverAnchor;
673
- const t17 = true;
674
- const T2 = Slot;
675
- const t18 = isContentEditable ? fieldId : void 0;
676
- const t19 = isContentEditable ? _temp2 : void 0;
677
- let t20;
678
- if ($[30] !== isContentEditable) {
679
- t20 = isContentEditable ? () => setIsHovered(true) : void 0;
680
- $[30] = isContentEditable;
681
- $[31] = t20;
682
- } else t20 = $[31];
683
- let t21;
684
- if ($[32] !== isContentEditable) {
685
- t21 = isContentEditable ? () => setIsHovered(false) : void 0;
686
- $[32] = isContentEditable;
687
- $[33] = t21;
688
- } else t21 = $[33];
689
- const t22 = _temp3;
690
- const t23 = false;
691
- const t24 = true;
692
- let t25;
693
- if ($[34] !== colors || $[35] !== isContentEditable || $[36] !== isFocused || $[37] !== isHovered) {
694
- t25 = isContentEditable && (isHovered || isFocused) ? {
695
- outline: `${isFocused ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isFocused ? colors.selected : colors.hover}`,
696
- outlineOffset: isFocused ? OVERLAY_OFFSETS.fieldSelected : OVERLAY_OFFSETS.fieldHover
697
- } : void 0;
698
- $[34] = colors;
699
- $[35] = isContentEditable;
700
- $[36] = isFocused;
701
- $[37] = isHovered;
702
- $[38] = t25;
703
- } else t25 = $[38];
704
- const t26 = children({
652
+ $[23] = t12;
653
+ } else t12 = $[23];
654
+ const handleEditLink = t12;
655
+ const linkData = {
705
656
  text: displayText,
706
657
  href: resolvedHref,
707
658
  newTab: fieldValue.newTab
708
- });
709
- let t27;
710
- if ($[39] !== T2 || $[40] !== handleBlur || $[41] !== handleFocus || $[42] !== handleInput || $[43] !== isContentEditable || $[44] !== t18 || $[45] !== t19 || $[46] !== t20 || $[47] !== t21 || $[48] !== t22 || $[49] !== t25 || $[50] !== t26) {
711
- t27 = /* @__PURE__ */ jsx(T2, {
712
- ref: elementRef,
713
- "data-camox-field-id": t18,
714
- contentEditable: isContentEditable,
715
- onClick: t19,
716
- onInput: handleInput,
717
- onFocus: handleFocus,
718
- onBlur: handleBlur,
719
- onMouseEnter: t20,
720
- onMouseLeave: t21,
721
- onKeyDown: t22,
722
- spellCheck: t23,
723
- suppressContentEditableWarning: t24,
724
- style: t25,
725
- children: t26
726
- });
727
- $[39] = T2;
728
- $[40] = handleBlur;
729
- $[41] = handleFocus;
730
- $[42] = handleInput;
731
- $[43] = isContentEditable;
732
- $[44] = t18;
733
- $[45] = t19;
734
- $[46] = t20;
735
- $[47] = t21;
736
- $[48] = t22;
737
- $[49] = t25;
738
- $[50] = t26;
739
- $[51] = t27;
740
- } else t27 = $[51];
741
- let t28;
742
- if ($[52] !== T1 || $[53] !== t27) {
743
- t28 = /* @__PURE__ */ jsx(T1, {
744
- asChild: t17,
745
- children: t27
659
+ };
660
+ if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children({
661
+ to: resolvedHref,
662
+ target: fieldValue.newTab ? "_blank" : void 0,
663
+ rel: fieldValue.newTab ? "noreferrer" : void 0,
664
+ children: fieldValue.text
665
+ }, linkData) });
666
+ let t13;
667
+ let t14;
668
+ if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
669
+ t13 = () => setIsHovered(true);
670
+ t14 = () => setIsHovered(false);
671
+ $[24] = t13;
672
+ $[25] = t14;
673
+ } else {
674
+ t13 = $[24];
675
+ t14 = $[25];
676
+ }
677
+ const linkProps = {
678
+ ref: elementRef,
679
+ to: resolvedHref,
680
+ target: fieldValue.newTab ? "_blank" : void 0,
681
+ rel: fieldValue.newTab ? "noreferrer" : void 0,
682
+ children: displayText,
683
+ "data-camox-field-id": fieldId,
684
+ "data-camox-hovered": isHovered || void 0,
685
+ "data-camox-focused": isFocused || void 0,
686
+ "data-camox-overlay-mode": mode === "layout" ? "layout" : void 0,
687
+ contentEditable: true,
688
+ onClick: _temp2,
689
+ onInput: handleInput,
690
+ onFocus: handleFocus,
691
+ onBlur: handleBlur,
692
+ onMouseEnter: t13,
693
+ onMouseLeave: t14,
694
+ onKeyDown: _temp3,
695
+ spellCheck: false,
696
+ suppressContentEditableWarning: true
697
+ };
698
+ const T0 = Popover;
699
+ const t15 = children(linkProps, linkData);
700
+ let t16;
701
+ if ($[26] !== handleEditLink) {
702
+ t16 = /* @__PURE__ */ jsx("button", {
703
+ type: "button",
704
+ className: "hover:bg-accent flex items-center gap-1.5 rounded-md px-2 py-1 text-sm transition-colors",
705
+ onMouseDown: _temp4,
706
+ onClick: handleEditLink,
707
+ children: "Edit link"
746
708
  });
747
- $[52] = T1;
748
- $[53] = t27;
749
- $[54] = t28;
750
- } else t28 = $[54];
751
- let t29;
752
- if ($[55] !== handleEditLink || $[56] !== isContentEditable) {
753
- t29 = isContentEditable && /* @__PURE__ */ jsx(PopoverContent, {
709
+ $[26] = handleEditLink;
710
+ $[27] = t16;
711
+ } else t16 = $[27];
712
+ let t17;
713
+ if ($[28] !== elementRef || $[29] !== t16) {
714
+ t17 = /* @__PURE__ */ jsx(PopoverContent, {
754
715
  className: "w-auto p-2",
755
- onOpenAutoFocus: _temp4,
716
+ initialFocus: false,
717
+ anchor: elementRef,
756
718
  align: "end",
757
- children: /* @__PURE__ */ jsx("button", {
758
- type: "button",
759
- className: "hover:bg-accent flex items-center gap-1.5 rounded-md px-2 py-1 text-sm transition-colors",
760
- onMouseDown: _temp5,
761
- onClick: handleEditLink,
762
- children: "Edit link"
763
- })
719
+ children: t16
764
720
  });
765
- $[55] = handleEditLink;
766
- $[56] = isContentEditable;
767
- $[57] = t29;
768
- } else t29 = $[57];
769
- let t30;
770
- if ($[58] !== T0 || $[59] !== t16 || $[60] !== t28 || $[61] !== t29) {
771
- t30 = /* @__PURE__ */ jsxs(T0, {
772
- open: t16,
773
- children: [t28, t29]
721
+ $[28] = elementRef;
722
+ $[29] = t16;
723
+ $[30] = t17;
724
+ } else t17 = $[30];
725
+ let t18;
726
+ if ($[31] !== T0 || $[32] !== isEditorFocused || $[33] !== t15 || $[34] !== t17) {
727
+ t18 = /* @__PURE__ */ jsxs(T0, {
728
+ open: isEditorFocused,
729
+ children: [t15, t17]
774
730
  });
775
- $[58] = T0;
776
- $[59] = t16;
777
- $[60] = t28;
778
- $[61] = t29;
779
- $[62] = t30;
780
- } else t30 = $[62];
781
- return t30;
731
+ $[31] = T0;
732
+ $[32] = isEditorFocused;
733
+ $[33] = t15;
734
+ $[34] = t17;
735
+ $[35] = t18;
736
+ } else t18 = $[35];
737
+ return t18;
782
738
  };
783
739
  const Image = (t0) => {
784
- const $ = c(37);
740
+ const $ = c(25);
785
741
  const { name, children } = t0;
786
742
  const blockContext = React.use(Context);
787
743
  if (!blockContext) throw new Error("Image must be used within a Block Component");
788
744
  const { blockId, content, mode } = blockContext;
789
745
  const isContentEditable = useIsEditable(mode);
790
- const colors = mode === "layout" ? LAYOUT_OVERLAY_COLORS : OVERLAY_COLORS;
791
746
  const { window: iframeWindow } = useFrame();
792
747
  const repeaterContext = React.use(RepeaterItemContext);
793
748
  const { filesMap } = useNormalizedData();
794
749
  const rawSource = repeaterContext ? repeaterContext.itemContent[name] : content[name];
795
- let t1;
796
- if ($[0] !== filesMap || $[1] !== rawSource) {
797
- t1 = isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource;
798
- $[0] = filesMap;
799
- $[1] = rawSource;
750
+ const fieldValue = (isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource) ?? contentDefaults[String(name)];
751
+ const t1 = String(name);
752
+ let t2;
753
+ if ($[0] !== blockId || $[1] !== repeaterContext || $[2] !== t1) {
754
+ t2 = getOverlayFieldId(blockId, repeaterContext, t1);
755
+ $[0] = blockId;
756
+ $[1] = repeaterContext;
800
757
  $[2] = t1;
801
- } else t1 = $[2];
802
- const fieldValue = t1 ?? contentDefaults[String(name)];
803
- const t2 = String(name);
804
- let t3;
805
- if ($[3] !== blockId || $[4] !== repeaterContext || $[5] !== t2) {
806
- t3 = getOverlayFieldId(blockId, repeaterContext, t2);
807
- $[3] = blockId;
808
- $[4] = repeaterContext;
809
- $[5] = t2;
810
- $[6] = t3;
811
- } else t3 = $[6];
812
- const fieldId = t3;
758
+ $[3] = t2;
759
+ } else t2 = $[3];
760
+ const fieldId = t2;
813
761
  const [isHovered, setIsHovered] = React.useState(false);
814
762
  const isFocused = useFieldSelection(blockId, String(name), "Image", repeaterContext?.itemId);
763
+ let t3;
764
+ if ($[4] !== fieldId) {
765
+ t3 = { fieldId };
766
+ $[4] = fieldId;
767
+ $[5] = t3;
768
+ } else t3 = $[5];
769
+ const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t3);
815
770
  let t4;
816
- if ($[7] !== fieldId) {
817
- t4 = { fieldId };
818
- $[7] = fieldId;
819
- $[8] = t4;
820
- } else t4 = $[8];
821
- const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t4);
822
771
  let t5;
823
- let t6;
824
- if ($[9] !== isHoveredFromSidebar) {
825
- t5 = () => {
772
+ if ($[6] !== isHoveredFromSidebar) {
773
+ t4 = () => {
826
774
  setIsHovered(isHoveredFromSidebar);
827
775
  };
828
- t6 = [isHoveredFromSidebar];
829
- $[9] = isHoveredFromSidebar;
830
- $[10] = t5;
831
- $[11] = t6;
776
+ t5 = [isHoveredFromSidebar];
777
+ $[6] = isHoveredFromSidebar;
778
+ $[7] = t4;
779
+ $[8] = t5;
832
780
  } else {
833
- t5 = $[10];
834
- t6 = $[11];
781
+ t4 = $[7];
782
+ t5 = $[8];
835
783
  }
836
- React.useEffect(t5, t6);
837
- let t7;
838
- if ($[12] !== blockId || $[13] !== isContentEditable || $[14] !== name || $[15] !== repeaterContext) {
839
- t7 = () => {
784
+ React.useEffect(t4, t5);
785
+ let t6;
786
+ if ($[9] !== blockId || $[10] !== isContentEditable || $[11] !== name || $[12] !== repeaterContext) {
787
+ t6 = () => {
840
788
  if (!isContentEditable) return;
841
789
  const imageFieldName = repeaterContext && !repeaterContext.itemId ? repeaterContext.arrayFieldName : String(name);
842
790
  if (repeaterContext?.itemId) previewStore.send({
@@ -854,87 +802,61 @@ function createBlock(options) {
854
802
  });
855
803
  previewStore.send({ type: "toggleContentSheet" });
856
804
  };
857
- $[12] = blockId;
858
- $[13] = isContentEditable;
859
- $[14] = name;
860
- $[15] = repeaterContext;
861
- $[16] = t7;
862
- } else t7 = $[16];
863
- const handleClick = t7;
864
- if (!isContentEditable) {
865
- let t8;
866
- if ($[17] !== children || $[18] !== fieldValue) {
867
- t8 = children(fieldValue);
868
- $[17] = children;
869
- $[18] = fieldValue;
870
- $[19] = t8;
871
- } else t8 = $[19];
872
- let t9;
873
- if ($[20] !== t8) {
874
- t9 = /* @__PURE__ */ jsx(Fragment, { children: t8 });
875
- $[20] = t8;
876
- $[21] = t9;
877
- } else t9 = $[21];
878
- return t9;
879
- }
880
- const showOverlay = isHovered || isFocused;
881
- let t8;
882
- if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
883
- t8 = { position: "relative" };
884
- $[22] = t8;
885
- } else t8 = $[22];
886
- let t10;
887
- let t9;
888
- if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
889
- t9 = () => setIsHovered(true);
890
- t10 = () => setIsHovered(false);
891
- $[23] = t10;
892
- $[24] = t9;
893
- } else {
894
- t10 = $[23];
895
- t9 = $[24];
896
- }
805
+ $[9] = blockId;
806
+ $[10] = isContentEditable;
807
+ $[11] = name;
808
+ $[12] = repeaterContext;
809
+ $[13] = t6;
810
+ } else t6 = $[13];
811
+ const handleClick = t6;
812
+ const imageProps = {
813
+ src: fieldValue.url,
814
+ alt: fieldValue.alt
815
+ };
816
+ if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children(imageProps, fieldValue) });
817
+ const t7 = "image";
818
+ const t8 = isHovered || void 0;
819
+ const t9 = isFocused || void 0;
820
+ const t10 = mode === "layout" ? "layout" : void 0;
897
821
  let t11;
898
- if ($[25] !== children || $[26] !== fieldValue) {
899
- t11 = children(fieldValue);
900
- $[25] = children;
901
- $[26] = fieldValue;
902
- $[27] = t11;
903
- } else t11 = $[27];
904
822
  let t12;
905
- if ($[28] !== colors || $[29] !== isFocused || $[30] !== showOverlay) {
906
- t12 = showOverlay && /* @__PURE__ */ jsx("div", { style: {
907
- position: "absolute",
908
- inset: isFocused ? OVERLAY_OFFSETS.blockSelected : OVERLAY_OFFSETS.blockHover,
909
- border: `${isFocused ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isFocused ? colors.selected : colors.hover}`,
910
- pointerEvents: "none",
911
- zIndex: 10
912
- } });
913
- $[28] = colors;
914
- $[29] = isFocused;
915
- $[30] = showOverlay;
916
- $[31] = t12;
917
- } else t12 = $[31];
918
- let t13;
919
- if ($[32] !== fieldId || $[33] !== handleClick || $[34] !== t11 || $[35] !== t12) {
920
- t13 = /* @__PURE__ */ jsxs("div", {
921
- style: t8,
823
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
824
+ t11 = () => setIsHovered(true);
825
+ t12 = () => setIsHovered(false);
826
+ $[14] = t11;
827
+ $[15] = t12;
828
+ } else {
829
+ t11 = $[14];
830
+ t12 = $[15];
831
+ }
832
+ const t13 = children(imageProps, fieldValue);
833
+ let t14;
834
+ if ($[16] !== fieldId || $[17] !== handleClick || $[18] !== t10 || $[19] !== t11 || $[20] !== t12 || $[21] !== t13 || $[22] !== t8 || $[23] !== t9) {
835
+ t14 = /* @__PURE__ */ jsx("div", {
922
836
  "data-camox-field-id": fieldId,
923
- onMouseEnter: t9,
924
- onMouseLeave: t10,
837
+ "data-camox-field-type": t7,
838
+ "data-camox-hovered": t8,
839
+ "data-camox-focused": t9,
840
+ "data-camox-overlay-mode": t10,
841
+ onMouseEnter: t11,
842
+ onMouseLeave: t12,
925
843
  onClick: handleClick,
926
- children: [t11, t12]
844
+ children: t13
927
845
  });
928
- $[32] = fieldId;
929
- $[33] = handleClick;
930
- $[34] = t11;
931
- $[35] = t12;
932
- $[36] = t13;
933
- } else t13 = $[36];
934
- return t13;
846
+ $[16] = fieldId;
847
+ $[17] = handleClick;
848
+ $[18] = t10;
849
+ $[19] = t11;
850
+ $[20] = t12;
851
+ $[21] = t13;
852
+ $[22] = t8;
853
+ $[23] = t9;
854
+ $[24] = t14;
855
+ } else t14 = $[24];
856
+ return t14;
935
857
  };
936
858
  const File = (t0) => {
937
- const $ = c(8);
859
+ const $ = c(7);
938
860
  const { name, children } = t0;
939
861
  const blockContext = React.use(Context);
940
862
  if (!blockContext) throw new Error("File must be used within a Block Component");
@@ -943,33 +865,30 @@ function createBlock(options) {
943
865
  const { filesMap } = useNormalizedData();
944
866
  const rawSource = repeaterContext ? repeaterContext.itemContent[name] : content[name];
945
867
  let t1;
946
- if ($[0] !== filesMap || $[1] !== rawSource) {
947
- t1 = isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource;
948
- $[0] = filesMap;
949
- $[1] = rawSource;
950
- $[2] = t1;
951
- } else t1 = $[2];
952
- const fieldValue = t1 ?? contentDefaults[String(name)];
868
+ if ($[0] !== children || $[1] !== filesMap || $[2] !== name || $[3] !== rawSource) {
869
+ const fieldValue = (isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource) ?? contentDefaults[String(name)];
870
+ t1 = children({
871
+ href: fieldValue.url,
872
+ download: fieldValue.filename
873
+ }, fieldValue);
874
+ $[0] = children;
875
+ $[1] = filesMap;
876
+ $[2] = name;
877
+ $[3] = rawSource;
878
+ $[4] = t1;
879
+ } else t1 = $[4];
953
880
  let t2;
954
- if ($[3] !== children || $[4] !== fieldValue) {
955
- t2 = children(fieldValue);
956
- $[3] = children;
957
- $[4] = fieldValue;
958
- $[5] = t2;
959
- } else t2 = $[5];
960
- let t3;
961
- if ($[6] !== t2) {
962
- t3 = /* @__PURE__ */ jsx(Fragment, { children: t2 });
881
+ if ($[5] !== t1) {
882
+ t2 = /* @__PURE__ */ jsx(Fragment, { children: t1 });
883
+ $[5] = t1;
963
884
  $[6] = t2;
964
- $[7] = t3;
965
- } else t3 = $[7];
966
- return t3;
885
+ } else t2 = $[6];
886
+ return t2;
967
887
  };
968
888
  const RepeaterItemWrapper = (t0) => {
969
- const $ = c(11);
889
+ const $ = c(8);
970
890
  const { itemId, blockId, mode, children } = t0;
971
891
  const isContentEditable = useIsEditable(mode);
972
- const colors = mode === "layout" ? LAYOUT_OVERLAY_COLORS : OVERLAY_COLORS;
973
892
  const { window: iframeWindow } = useFrame();
974
893
  const isRepeaterHovered = React.useContext(RepeaterHoverContext);
975
894
  let t1;
@@ -984,37 +903,23 @@ function createBlock(options) {
984
903
  } else t1 = $[2];
985
904
  const isHovered = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATER_ITEM", "CAMOX_HOVER_REPEATER_ITEM_END", t1);
986
905
  const showOverlay = isContentEditable && (isHovered || isRepeaterHovered);
987
- let t2;
988
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
989
- t2 = { position: "relative" };
990
- $[3] = t2;
991
- } else t2 = $[3];
992
- const t3 = isContentEditable ? itemId : void 0;
993
- let t4;
994
- if ($[4] !== colors || $[5] !== showOverlay) {
995
- t4 = showOverlay && /* @__PURE__ */ jsx("div", { style: {
996
- position: "absolute",
997
- inset: OVERLAY_OFFSETS.blockHover,
998
- border: `${OVERLAY_WIDTHS.hover} solid ${colors.hover}`,
999
- pointerEvents: "none",
1000
- zIndex: 10
1001
- } });
1002
- $[4] = colors;
1003
- $[5] = showOverlay;
1004
- $[6] = t4;
1005
- } else t4 = $[6];
906
+ const t2 = isContentEditable ? itemId : void 0;
907
+ const t3 = showOverlay || void 0;
908
+ const t4 = mode === "layout" ? "layout" : void 0;
1006
909
  let t5;
1007
- if ($[7] !== children || $[8] !== t3 || $[9] !== t4) {
1008
- t5 = /* @__PURE__ */ jsxs("div", {
1009
- style: t2,
1010
- "data-camox-repeater-item-id": t3,
1011
- children: [children, t4]
910
+ if ($[3] !== children || $[4] !== t2 || $[5] !== t3 || $[6] !== t4) {
911
+ t5 = /* @__PURE__ */ jsx("div", {
912
+ "data-camox-repeater-item-id": t2,
913
+ "data-camox-hovered": t3,
914
+ "data-camox-overlay-mode": t4,
915
+ children
1012
916
  });
1013
- $[7] = children;
1014
- $[8] = t3;
1015
- $[9] = t4;
1016
- $[10] = t5;
1017
- } else t5 = $[10];
917
+ $[3] = children;
918
+ $[4] = t2;
919
+ $[5] = t3;
920
+ $[6] = t4;
921
+ $[7] = t5;
922
+ } else t5 = $[7];
1018
923
  return t5;
1019
924
  };
1020
925
  const RepeaterHoverProvider = (t0) => {
@@ -1134,14 +1039,14 @@ function createBlock(options) {
1134
1039
  return t3;
1135
1040
  };
1136
1041
  const BlockComponent = (t0) => {
1137
- const $ = c(67);
1042
+ const $ = c(69);
1138
1043
  const { blockData, mode, isFirstBlock, showAddBlockTop, showAddBlockBottom, addBlockAfterPosition } = t0;
1139
1044
  const isContentEditable = useIsEditable(mode);
1140
1045
  const { window: iframeWindow } = useFrame();
1141
1046
  const [isHovered, setIsHovered] = React.useState(false);
1142
- const selection = useSelector(previewStore, _temp6);
1143
- const isPageContentSheetOpen = useSelector(previewStore, _temp7);
1144
- const isAddBlockSheetOpen = useSelector(previewStore, _temp8);
1047
+ const selection = useSelector(previewStore, _temp5);
1048
+ const isPageContentSheetOpen = useSelector(previewStore, _temp6);
1049
+ const isAddBlockSheetOpen = useSelector(previewStore, _temp7);
1145
1050
  const isAnySideSheetOpen = useIsPreviewSheetOpen();
1146
1051
  const isBlockSelected = selection?.blockId === blockData._id;
1147
1052
  const ref = React.useRef(null);
@@ -1213,7 +1118,7 @@ function createBlock(options) {
1213
1118
  result = { ...blockData.content };
1214
1119
  for (const key in result) {
1215
1120
  const value = result[key];
1216
- if (Array.isArray(value) && value.length > 0 && value[0]?.content !== void 0) result[key] = value.map(_temp9);
1121
+ if (Array.isArray(value) && value.length > 0 && value[0]?.content !== void 0) result[key] = value.map(_temp8);
1217
1122
  }
1218
1123
  $[15] = blockData.content;
1219
1124
  $[16] = result;
@@ -1279,17 +1184,20 @@ function createBlock(options) {
1279
1184
  $[27] = t12;
1280
1185
  } else t12 = $[27];
1281
1186
  const t13 = isContentEditable ? blockData._id : void 0;
1282
- const t14 = blockData._id;
1283
- let t15;
1187
+ const t14 = shouldShowOverlay && !isBlockSelected || void 0;
1188
+ const t15 = shouldShowOverlay && isBlockSelected || void 0;
1189
+ const t16 = mode === "layout" ? "layout" : void 0;
1190
+ const t17 = blockData._id;
1191
+ let t18;
1284
1192
  if ($[28] !== blockData.content) {
1285
- t15 = {
1193
+ t18 = {
1286
1194
  ...contentDefaults,
1287
1195
  ...blockData.content
1288
1196
  };
1289
1197
  $[28] = blockData.content;
1290
- $[29] = t15;
1291
- } else t15 = $[29];
1292
- const merged = t15;
1198
+ $[29] = t18;
1199
+ } else t18 = $[29];
1200
+ const merged = t18;
1293
1201
  let overrides;
1294
1202
  if ($[30] !== merged) {
1295
1203
  overrides = {};
@@ -1300,33 +1208,33 @@ function createBlock(options) {
1300
1208
  $[30] = merged;
1301
1209
  $[31] = overrides;
1302
1210
  } else overrides = $[31];
1303
- let t16;
1211
+ let t19;
1304
1212
  if ($[32] !== merged || $[33] !== overrides) {
1305
- t16 = {
1213
+ t19 = {
1306
1214
  ...merged,
1307
1215
  ...overrides
1308
1216
  };
1309
1217
  $[32] = merged;
1310
1218
  $[33] = overrides;
1311
- $[34] = t16;
1312
- } else t16 = $[34];
1313
- const t17 = t16;
1314
- let t18;
1219
+ $[34] = t19;
1220
+ } else t19 = $[34];
1221
+ const t20 = t19;
1222
+ let t21;
1315
1223
  if ($[35] !== blockData.settings) {
1316
- t18 = {
1224
+ t21 = {
1317
1225
  ...settingsDefaults,
1318
1226
  ...blockData.settings
1319
1227
  };
1320
1228
  $[35] = blockData.settings;
1321
- $[36] = t18;
1322
- } else t18 = $[36];
1323
- const t19 = t18;
1324
- let t20;
1325
- if ($[37] !== blockData._id || $[38] !== isHovered || $[39] !== mode || $[40] !== t17 || $[41] !== t19) {
1326
- t20 = {
1327
- blockId: t14,
1328
- content: t17,
1329
- settings: t19,
1229
+ $[36] = t21;
1230
+ } else t21 = $[36];
1231
+ const t22 = t21;
1232
+ let t23;
1233
+ if ($[37] !== blockData._id || $[38] !== isHovered || $[39] !== mode || $[40] !== t20 || $[41] !== t22) {
1234
+ t23 = {
1235
+ blockId: t17,
1236
+ content: t20,
1237
+ settings: t22,
1330
1238
  mode,
1331
1239
  isHovered,
1332
1240
  setIsHovered
@@ -1334,105 +1242,89 @@ function createBlock(options) {
1334
1242
  $[37] = blockData._id;
1335
1243
  $[38] = isHovered;
1336
1244
  $[39] = mode;
1337
- $[40] = t17;
1338
- $[41] = t19;
1339
- $[42] = t20;
1340
- } else t20 = $[42];
1341
- let t21;
1245
+ $[40] = t20;
1246
+ $[41] = t22;
1247
+ $[42] = t23;
1248
+ } else t23 = $[42];
1249
+ let t24;
1342
1250
  if ($[43] !== normalizedContent) {
1343
- t21 = /* @__PURE__ */ jsx(options.component, { content: normalizedContent });
1251
+ t24 = /* @__PURE__ */ jsx(options.component, { content: normalizedContent });
1344
1252
  $[43] = normalizedContent;
1345
- $[44] = t21;
1346
- } else t21 = $[44];
1347
- let t22;
1348
- if ($[45] !== t20 || $[46] !== t21) {
1349
- t22 = /* @__PURE__ */ jsx(Context.Provider, {
1350
- value: t20,
1351
- children: t21
1253
+ $[44] = t24;
1254
+ } else t24 = $[44];
1255
+ let t25;
1256
+ if ($[45] !== t23 || $[46] !== t24) {
1257
+ t25 = /* @__PURE__ */ jsx(Context.Provider, {
1258
+ value: t23,
1259
+ children: t24
1352
1260
  });
1353
- $[45] = t20;
1354
- $[46] = t21;
1355
- $[47] = t22;
1356
- } else t22 = $[47];
1357
- const t23 = shouldShowSheetOverlay ? .6 : 0;
1358
- let t24;
1359
- if ($[48] !== t23) {
1360
- t24 = /* @__PURE__ */ jsx("div", {
1361
- style: {
1362
- position: "absolute",
1363
- width: "100%",
1364
- height: "100%",
1365
- top: 0,
1366
- left: 0,
1367
- background: "#000",
1368
- opacity: t23,
1369
- transition: "opacity 0.3s ease-in-out",
1370
- pointerEvents: "none",
1371
- zIndex: 20
1372
- },
1373
- id: "hello"
1261
+ $[45] = t23;
1262
+ $[46] = t24;
1263
+ $[47] = t25;
1264
+ } else t25 = $[47];
1265
+ let t26;
1266
+ if ($[48] !== shouldShowSheetOverlay) {
1267
+ t26 = /* @__PURE__ */ jsx("div", {
1268
+ className: "camox-sheet-overlay",
1269
+ ...shouldShowSheetOverlay ? { "data-camox-visible": "" } : {}
1374
1270
  });
1375
- $[48] = t23;
1376
- $[49] = t24;
1377
- } else t24 = $[49];
1378
- let t25;
1379
- if ($[50] !== handleAddBlockClick || $[51] !== isAnySideSheetOpen || $[52] !== isBlockSelected || $[53] !== isFirstBlock || $[54] !== mode || $[55] !== shouldShowOverlay || $[56] !== showAddBlockBottom || $[57] !== showAddBlockTop) {
1380
- t25 = shouldShowOverlay && (() => {
1381
- const colors = mode === "layout" ? LAYOUT_OVERLAY_COLORS : OVERLAY_COLORS;
1382
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { style: {
1383
- position: "absolute",
1384
- inset: isBlockSelected ? OVERLAY_OFFSETS.blockSelected : OVERLAY_OFFSETS.blockHover,
1385
- border: `${isBlockSelected ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isBlockSelected ? colors.selected : colors.hover}`,
1386
- pointerEvents: "none",
1387
- zIndex: 10
1388
- } }), /* @__PURE__ */ jsxs(Fragment, { children: [(showAddBlockTop ?? (mode !== "layout" && !isFirstBlock)) && /* @__PURE__ */ jsx(AddBlockControlBar, {
1389
- position: "top",
1390
- hidden: isAnySideSheetOpen,
1391
- onMouseLeave: () => setIsHovered(false),
1392
- onClick: () => handleAddBlockClick("before")
1393
- }), (showAddBlockBottom ?? mode !== "layout") && /* @__PURE__ */ jsx(AddBlockControlBar, {
1394
- position: "bottom",
1395
- hidden: isAnySideSheetOpen,
1396
- onMouseLeave: () => setIsHovered(false),
1397
- onClick: () => handleAddBlockClick("after")
1398
- })] })] });
1399
- })();
1271
+ $[48] = shouldShowSheetOverlay;
1272
+ $[49] = t26;
1273
+ } else t26 = $[49];
1274
+ let t27;
1275
+ if ($[50] !== handleAddBlockClick || $[51] !== isAnySideSheetOpen || $[52] !== isFirstBlock || $[53] !== mode || $[54] !== shouldShowOverlay || $[55] !== showAddBlockBottom || $[56] !== showAddBlockTop) {
1276
+ t27 = shouldShowOverlay && /* @__PURE__ */ jsxs(Fragment, { children: [(showAddBlockTop ?? (mode !== "layout" && !isFirstBlock)) && /* @__PURE__ */ jsx(AddBlockControlBar, {
1277
+ position: "top",
1278
+ hidden: isAnySideSheetOpen,
1279
+ onMouseLeave: () => setIsHovered(false),
1280
+ onClick: () => handleAddBlockClick("before")
1281
+ }), (showAddBlockBottom ?? mode !== "layout") && /* @__PURE__ */ jsx(AddBlockControlBar, {
1282
+ position: "bottom",
1283
+ hidden: isAnySideSheetOpen,
1284
+ onMouseLeave: () => setIsHovered(false),
1285
+ onClick: () => handleAddBlockClick("after")
1286
+ })] });
1400
1287
  $[50] = handleAddBlockClick;
1401
1288
  $[51] = isAnySideSheetOpen;
1402
- $[52] = isBlockSelected;
1403
- $[53] = isFirstBlock;
1404
- $[54] = mode;
1405
- $[55] = shouldShowOverlay;
1406
- $[56] = showAddBlockBottom;
1407
- $[57] = showAddBlockTop;
1408
- $[58] = t25;
1409
- } else t25 = $[58];
1410
- let t26;
1411
- if ($[59] !== handleClick || $[60] !== handleMouseEnter || $[61] !== handleMouseLeave || $[62] !== t13 || $[63] !== t22 || $[64] !== t24 || $[65] !== t25) {
1412
- t26 = /* @__PURE__ */ jsxs("div", {
1289
+ $[52] = isFirstBlock;
1290
+ $[53] = mode;
1291
+ $[54] = shouldShowOverlay;
1292
+ $[55] = showAddBlockBottom;
1293
+ $[56] = showAddBlockTop;
1294
+ $[57] = t27;
1295
+ } else t27 = $[57];
1296
+ let t28;
1297
+ if ($[58] !== handleClick || $[59] !== handleMouseEnter || $[60] !== handleMouseLeave || $[61] !== t13 || $[62] !== t14 || $[63] !== t15 || $[64] !== t16 || $[65] !== t25 || $[66] !== t26 || $[67] !== t27) {
1298
+ t28 = /* @__PURE__ */ jsxs("div", {
1413
1299
  className: "group visual-editing-block",
1414
1300
  ref,
1415
1301
  style: t12,
1416
1302
  "data-camox-block-id": t13,
1303
+ "data-camox-hovered": t14,
1304
+ "data-camox-focused": t15,
1305
+ "data-camox-overlay-mode": t16,
1417
1306
  onClick: handleClick,
1418
1307
  onMouseEnter: handleMouseEnter,
1419
1308
  onMouseLeave: handleMouseLeave,
1420
1309
  children: [
1421
- t22,
1422
- t24,
1423
- t25
1310
+ t25,
1311
+ t26,
1312
+ t27
1424
1313
  ]
1425
1314
  });
1426
- $[59] = handleClick;
1427
- $[60] = handleMouseEnter;
1428
- $[61] = handleMouseLeave;
1429
- $[62] = t13;
1430
- $[63] = t22;
1431
- $[64] = t24;
1315
+ $[58] = handleClick;
1316
+ $[59] = handleMouseEnter;
1317
+ $[60] = handleMouseLeave;
1318
+ $[61] = t13;
1319
+ $[62] = t14;
1320
+ $[63] = t15;
1321
+ $[64] = t16;
1432
1322
  $[65] = t25;
1433
1323
  $[66] = t26;
1434
- } else t26 = $[66];
1435
- return t26;
1324
+ $[67] = t27;
1325
+ $[68] = t28;
1326
+ } else t28 = $[68];
1327
+ return t28;
1436
1328
  };
1437
1329
  const useSetting = (name) => {
1438
1330
  const ctx = React.use(Context);
@@ -1444,16 +1336,16 @@ function createBlock(options) {
1444
1336
  * Provides the same hover, selection, and sheet overlays as the main BlockComponent.
1445
1337
  */
1446
1338
  const Detached = (t0) => {
1447
- const $ = c(29);
1339
+ const $ = c(30);
1448
1340
  const { children } = t0;
1449
1341
  const ctx = React.use(Context);
1450
1342
  if (!ctx) throw new Error("Detached must be used within a Block Component");
1451
1343
  const { blockId, mode, isHovered, setIsHovered } = ctx;
1452
1344
  const isContentEditable = useIsEditable(mode);
1453
1345
  const { window: iframeWindow } = useFrame();
1454
- const selection = useSelector(previewStore, _temp0);
1455
- const isAddBlockSheetOpen = useSelector(previewStore, _temp1);
1456
- const isPageContentSheetOpen = useSelector(previewStore, _temp10);
1346
+ const selection = useSelector(previewStore, _temp9);
1347
+ const isAddBlockSheetOpen = useSelector(previewStore, _temp0);
1348
+ const isPageContentSheetOpen = useSelector(previewStore, _temp1);
1457
1349
  const isBlockSelected = selection?.blockId === blockId;
1458
1350
  let t1;
1459
1351
  if ($[0] !== blockId) {
@@ -1516,56 +1408,55 @@ function createBlock(options) {
1516
1408
  } else t6 = $[14];
1517
1409
  const handleMouseLeave = t6;
1518
1410
  const [container, setContainer] = React.useState(null);
1519
- let t7;
1520
- if ($[15] !== children || $[16] !== handleClick || $[17] !== handleMouseEnter || $[18] !== handleMouseLeave) {
1521
- t7 = /* @__PURE__ */ jsx(Slot, {
1411
+ const t7 = shouldShowSheetOverlay ? 0 : 1;
1412
+ let t8;
1413
+ if ($[15] !== children || $[16] !== handleClick || $[17] !== handleMouseEnter || $[18] !== handleMouseLeave || $[19] !== t7) {
1414
+ t8 = children({
1522
1415
  ref: setContainer,
1416
+ style: {
1417
+ opacity: t7,
1418
+ transition: "opacity 0.3s ease-in-out"
1419
+ },
1523
1420
  onClick: handleClick,
1524
1421
  onMouseEnter: handleMouseEnter,
1525
- onMouseLeave: handleMouseLeave,
1526
- children
1422
+ onMouseLeave: handleMouseLeave
1527
1423
  });
1528
1424
  $[15] = children;
1529
1425
  $[16] = handleClick;
1530
1426
  $[17] = handleMouseEnter;
1531
1427
  $[18] = handleMouseLeave;
1532
1428
  $[19] = t7;
1533
- } else t7 = $[19];
1534
- let t8;
1535
- if ($[20] !== container || $[21] !== isBlockSelected || $[22] !== mode || $[23] !== shouldShowOverlay || $[24] !== shouldShowSheetOverlay) {
1536
- t8 = container && createPortal(/* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { style: {
1537
- position: "absolute",
1538
- inset: 0,
1539
- background: "#000",
1540
- opacity: shouldShowSheetOverlay ? .6 : 0,
1541
- transition: "opacity 0.3s ease-in-out",
1542
- pointerEvents: "none",
1543
- zIndex: 20
1544
- } }), shouldShowOverlay && (() => {
1545
- const colors = mode === "layout" ? LAYOUT_OVERLAY_COLORS : OVERLAY_COLORS;
1546
- return /* @__PURE__ */ jsx("div", { style: {
1429
+ $[20] = t8;
1430
+ } else t8 = $[20];
1431
+ let t9;
1432
+ if ($[21] !== blockId || $[22] !== container || $[23] !== isBlockSelected || $[24] !== mode || $[25] !== shouldShowOverlay) {
1433
+ t9 = container && createPortal(/* @__PURE__ */ jsx(Fragment, { children: shouldShowOverlay && /* @__PURE__ */ jsx("div", {
1434
+ "data-camox-block-id": blockId,
1435
+ "data-camox-detached": true,
1436
+ "data-camox-hovered": !isBlockSelected || void 0,
1437
+ "data-camox-focused": isBlockSelected || void 0,
1438
+ "data-camox-overlay-mode": mode === "layout" ? "layout" : void 0,
1439
+ style: {
1547
1440
  position: "absolute",
1548
- inset: isBlockSelected ? OVERLAY_OFFSETS.blockSelected : OVERLAY_OFFSETS.blockHover,
1549
- border: `${isBlockSelected ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isBlockSelected ? colors.selected : colors.hover}`,
1550
1441
  pointerEvents: "none",
1551
1442
  zIndex: 10
1552
- } });
1553
- })()] }), container);
1554
- $[20] = container;
1555
- $[21] = isBlockSelected;
1556
- $[22] = mode;
1557
- $[23] = shouldShowOverlay;
1558
- $[24] = shouldShowSheetOverlay;
1559
- $[25] = t8;
1560
- } else t8 = $[25];
1561
- let t9;
1562
- if ($[26] !== t7 || $[27] !== t8) {
1563
- t9 = /* @__PURE__ */ jsxs(Fragment, { children: [t7, t8] });
1564
- $[26] = t7;
1443
+ }
1444
+ }) }), container);
1445
+ $[21] = blockId;
1446
+ $[22] = container;
1447
+ $[23] = isBlockSelected;
1448
+ $[24] = mode;
1449
+ $[25] = shouldShowOverlay;
1450
+ $[26] = t9;
1451
+ } else t9 = $[26];
1452
+ let t10;
1453
+ if ($[27] !== t8 || $[28] !== t9) {
1454
+ t10 = /* @__PURE__ */ jsxs(Fragment, { children: [t8, t9] });
1565
1455
  $[27] = t8;
1566
1456
  $[28] = t9;
1567
- } else t9 = $[28];
1568
- return t9;
1457
+ $[29] = t10;
1458
+ } else t10 = $[29];
1459
+ return t10;
1569
1460
  };
1570
1461
  return {
1571
1462
  Component: BlockComponent,
@@ -1651,28 +1542,25 @@ function _temp3(e_2) {
1651
1542
  function _temp4(e_3) {
1652
1543
  return e_3.preventDefault();
1653
1544
  }
1654
- function _temp5(e_4) {
1655
- return e_4.preventDefault();
1656
- }
1657
- function _temp6(state) {
1545
+ function _temp5(state) {
1658
1546
  return state.context.selection;
1659
1547
  }
1660
- function _temp7(state_0) {
1548
+ function _temp6(state_0) {
1661
1549
  return state_0.context.isPageContentSheetOpen;
1662
1550
  }
1663
- function _temp8(state_1) {
1551
+ function _temp7(state_1) {
1664
1552
  return state_1.context.isAddBlockSheetOpen;
1665
1553
  }
1666
- function _temp9(item) {
1554
+ function _temp8(item) {
1667
1555
  return item.content;
1668
1556
  }
1669
- function _temp0(state) {
1557
+ function _temp9(state) {
1670
1558
  return state.context.selection;
1671
1559
  }
1672
- function _temp1(state_0) {
1560
+ function _temp0(state_0) {
1673
1561
  return state_0.context.isAddBlockSheetOpen;
1674
1562
  }
1675
- function _temp10(state_1) {
1563
+ function _temp1(state_1) {
1676
1564
  return state_1.context.isPageContentSheetOpen;
1677
1565
  }
1678
1566
  //#endregion