camox 0.45.0 → 0.47.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 (45) hide show
  1. package/dist/core/hooks/useArtifactHost.js +2 -2
  2. package/dist/features/canvas/CamoxCanvas.js +438 -771
  3. package/dist/features/canvas/CanvasPageFrame.js +1 -3
  4. package/dist/features/canvas/CanvasPreviewPageSlot.js +26 -6
  5. package/dist/features/canvas/canvasCamera.js +24 -9
  6. package/dist/features/canvas/canvasFrameDocument.js +4 -19
  7. package/dist/features/canvas/canvasItems.js +12 -102
  8. package/dist/features/canvas/canvasStore.js +3 -92
  9. package/dist/features/canvas/sidebar/CanvasNavigator.js +81 -183
  10. package/dist/features/canvas/sidebar/CanvasSidebar.js +22 -28
  11. package/dist/features/canvas/sidebar/CuratedPageInspector.js +2 -2
  12. package/dist/features/canvas/useCanvasCamera.js +16 -31
  13. package/dist/features/canvas/useCanvasFrame.js +5 -6
  14. package/dist/features/preview/CamoxPreview.js +137 -120
  15. package/dist/features/preview/components/{AddBlockDialog.js → AddBlockSheet.js} +35 -32
  16. package/dist/features/preview/components/BlockActionsPopover.js +6 -6
  17. package/dist/features/preview/components/BlockThumbnail.js +31 -33
  18. package/dist/features/preview/components/Overlays.js +1 -1
  19. package/dist/features/preview/components/PageTree.js +1 -1
  20. package/dist/features/preview/components/PreviewPanel.js +1 -1
  21. package/dist/features/preview/components/PreviewToolbar.js +74 -85
  22. package/dist/features/preview/previewStore.js +9 -9
  23. package/dist/features/provider/CamoxProvider.js +8 -16
  24. package/dist/features/provider/CoreCamoxProvider.js +10 -12
  25. package/dist/features/provider/signInShortcut.js +60 -0
  26. package/dist/features/routes/pageRuntime.js +8 -8
  27. package/dist/features/runtime/RuntimeChrome.js +1 -1
  28. package/dist/features/runtime/pageApp.js +11 -39
  29. package/dist/features/runtime/runtime.d.ts +2 -7
  30. package/dist/features/runtime/runtime.js +6 -19
  31. package/dist/features/studio/FollowAgentProvider.js +11 -22
  32. package/dist/features/studio/components/FaviconDialog.js +3 -3
  33. package/dist/features/studio/followAgent.js +5 -14
  34. package/dist/features/studio/routes.js +1 -23
  35. package/dist/lib/auth.js +36 -24
  36. package/dist/lib/studio-reads.js +0 -20
  37. package/dist/package.js +1 -1
  38. package/dist/studio.css +1 -1
  39. package/package.json +4 -4
  40. package/skills/camox-expand/SKILL.md +5 -4
  41. package/dist/features/canvas/CanvasBlockFrame.js +0 -353
  42. package/dist/features/canvas/CanvasBlockHeader.js +0 -55
  43. package/dist/features/canvas/CanvasShelfMarker.js +0 -255
  44. package/dist/features/canvas/sidebar/CatalogBlockInspector.js +0 -189
  45. package/dist/features/provider/LocalhostPreviewProvider.js +0 -158
@@ -17,10 +17,11 @@ import { canvasStore } from "../canvas/canvasStore.js";
17
17
  import { SHOW_WHOLE_CANVAS_SHORTCUT, TOGGLE_CANVAS_SHORTCUT } from "./previewConstants.js";
18
18
  import { CanvasSidebarSkeleton } from "../canvas/sidebar/CanvasSidebarSkeleton.js";
19
19
  import { DerivedPageContent } from "../page/DerivedPageContent.js";
20
+ import { takeShowCanvasRequest } from "../provider/signInShortcut.js";
20
21
  import { STUDIO_CANVAS_PATH } from "../studio/routes.js";
21
22
  import { studioStore } from "../studio/studioStore.js";
22
23
  import { previewStore, selectIsCanvasShown } from "./previewStore.js";
23
- import { AddBlockDialog } from "./components/AddBlockDialog.js";
24
+ import { AddBlockSheet } from "./components/AddBlockSheet.js";
24
25
  import { CanvasPreview, prefetchCanvas } from "./components/CanvasPreview.js";
25
26
  import { CreatePageModal } from "./components/CreatePageModal.js";
26
27
  import { PreviewEditingOwnerContext } from "./previewSelection.js";
@@ -617,7 +618,7 @@ function usePrefetchCanvas(enabled, projectUuid) {
617
618
  }
618
619
  /** Studio chrome is shared; only curated previews require a Camox page record. */
619
620
  const PreviewShell = (t0) => {
620
- const $ = c(49);
621
+ const $ = c(53);
621
622
  const { children, pageData, derivedLayout, pageLocation, canvasOnly, runtimeBasePath: t1 } = t0;
622
623
  const runtimeBasePath = t1 === void 0 ? "" : t1;
623
624
  const isAuthenticated = useIsAuthenticated();
@@ -663,26 +664,42 @@ const PreviewShell = (t0) => {
663
664
  const editingOwner = t2;
664
665
  let t3;
665
666
  let t4;
666
- if ($[4] !== isMobileStudio) {
667
+ if ($[4] !== isAuthenticated || $[5] !== isMobileStudio) {
667
668
  t3 = () => {
668
- if (!isMobileStudio) return;
669
- previewStore.send({ type: "hideCanvas" });
670
- previewStore.send({ type: "closeAddBlockDialog" });
669
+ if (isAuthenticated && takeShowCanvasRequest() && !isMobileStudio) previewStore.send({ type: "showCanvas" });
671
670
  };
672
- t4 = [isMobileStudio];
673
- $[4] = isMobileStudio;
674
- $[5] = t3;
675
- $[6] = t4;
671
+ t4 = [isAuthenticated, isMobileStudio];
672
+ $[4] = isAuthenticated;
673
+ $[5] = isMobileStudio;
674
+ $[6] = t3;
675
+ $[7] = t4;
676
676
  } else {
677
- t3 = $[5];
678
- t4 = $[6];
677
+ t3 = $[6];
678
+ t4 = $[7];
679
679
  }
680
680
  React.useEffect(t3, t4);
681
- useCanvasOnlyLocation(!!canvasOnly && isAuthenticated, isCanvasShown, isMobileStudio, pageLocation);
682
681
  let t5;
683
682
  let t6;
684
- if ($[7] !== isAuthenticated || $[8] !== isCanvasShown || $[9] !== isMobileStudio) {
683
+ if ($[8] !== isMobileStudio) {
685
684
  t5 = () => {
685
+ if (!isMobileStudio) return;
686
+ previewStore.send({ type: "hideCanvas" });
687
+ previewStore.send({ type: "closeAddBlockSheet" });
688
+ };
689
+ t6 = [isMobileStudio];
690
+ $[8] = isMobileStudio;
691
+ $[9] = t5;
692
+ $[10] = t6;
693
+ } else {
694
+ t5 = $[9];
695
+ t6 = $[10];
696
+ }
697
+ React.useEffect(t5, t6);
698
+ useCanvasOnlyLocation(!!canvasOnly && isAuthenticated, isCanvasShown, isMobileStudio, pageLocation);
699
+ let t7;
700
+ let t8;
701
+ if ($[11] !== isAuthenticated || $[12] !== isCanvasShown || $[13] !== isMobileStudio) {
702
+ t7 = () => {
686
703
  const actions = [
687
704
  {
688
705
  id: "hide-canvas",
@@ -732,140 +749,140 @@ const PreviewShell = (t0) => {
732
749
  });
733
750
  };
734
751
  };
735
- t6 = [
752
+ t8 = [
736
753
  isCanvasShown,
737
754
  isAuthenticated,
738
755
  isMobileStudio
739
756
  ];
740
- $[7] = isAuthenticated;
741
- $[8] = isCanvasShown;
742
- $[9] = isMobileStudio;
743
- $[10] = t5;
744
- $[11] = t6;
757
+ $[11] = isAuthenticated;
758
+ $[12] = isCanvasShown;
759
+ $[13] = isMobileStudio;
760
+ $[14] = t7;
761
+ $[15] = t8;
745
762
  } else {
746
- t5 = $[10];
747
- t6 = $[11];
763
+ t7 = $[14];
764
+ t8 = $[15];
748
765
  }
749
- React.useEffect(t5, t6);
766
+ React.useEffect(t7, t8);
750
767
  if (!isAuthenticated) {
751
- let t7;
752
- if ($[12] !== children) {
753
- t7 = /* @__PURE__ */ jsx(Fragment, { children });
754
- $[12] = children;
755
- $[13] = t7;
756
- } else t7 = $[13];
757
- return t7;
768
+ let t9;
769
+ if ($[16] !== children) {
770
+ t9 = /* @__PURE__ */ jsx(Fragment, { children });
771
+ $[16] = children;
772
+ $[17] = t9;
773
+ } else t9 = $[17];
774
+ return t9;
758
775
  }
759
- const t7 = !isCanvasShown && "bg-black";
760
- let t8;
761
- if ($[14] !== t7) {
762
- t8 = cn("bg-background relative flex h-full min-h-0 flex-1 flex-col overflow-hidden", t7);
763
- $[14] = t7;
764
- $[15] = t8;
765
- } else t8 = $[15];
766
- const t9 = pageLocation?.pathname;
767
- const t10 = !canvasOnly;
768
- const t11 = !!derivedLayout;
769
- let t12;
770
- if ($[16] !== t10 || $[17] !== t11) {
771
- t12 = /* @__PURE__ */ jsx(CanvasSidebarSkeleton, {
772
- page: t10,
773
- layoutPage: t11
776
+ const t9 = !isCanvasShown && "bg-black";
777
+ let t10;
778
+ if ($[18] !== t9) {
779
+ t10 = cn("bg-background relative flex h-full min-h-0 flex-1 flex-col overflow-hidden", t9);
780
+ $[18] = t9;
781
+ $[19] = t10;
782
+ } else t10 = $[19];
783
+ const t11 = pageLocation?.pathname;
784
+ const t12 = !canvasOnly;
785
+ const t13 = !!derivedLayout;
786
+ let t14;
787
+ if ($[20] !== t12 || $[21] !== t13) {
788
+ t14 = /* @__PURE__ */ jsx(CanvasSidebarSkeleton, {
789
+ page: t12,
790
+ layoutPage: t13
774
791
  });
775
- $[16] = t10;
776
- $[17] = t11;
777
- $[18] = t12;
778
- } else t12 = $[18];
779
- const t13 = !isCanvasEnabled;
780
- const t14 = pageData?.page;
781
- const t15 = derivedLayout?.layoutId;
782
- const t16 = pageData?.projectName;
783
- let t17;
784
- if ($[19] !== children || $[20] !== isMobileStudio || $[21] !== pageLocation || $[22] !== t13 || $[23] !== t14 || $[24] !== t15 || $[25] !== t16) {
785
- t17 = /* @__PURE__ */ jsx("div", {
792
+ $[20] = t12;
793
+ $[21] = t13;
794
+ $[22] = t14;
795
+ } else t14 = $[22];
796
+ const t15 = !isCanvasEnabled;
797
+ const t16 = pageData?.page;
798
+ const t17 = derivedLayout?.layoutId;
799
+ const t18 = pageData?.projectName;
800
+ let t19;
801
+ if ($[23] !== children || $[24] !== isMobileStudio || $[25] !== pageLocation || $[26] !== t15 || $[27] !== t16 || $[28] !== t17 || $[29] !== t18) {
802
+ t19 = /* @__PURE__ */ jsx("div", {
786
803
  className: "flex min-h-0 flex-1 flex-row items-stretch",
787
804
  children: /* @__PURE__ */ jsx(PreviewPanel, {
788
- active: t13,
805
+ active: t15,
789
806
  isMobileExperience: isMobileStudio,
790
- page: t14,
791
- layoutId: t15,
807
+ page: t16,
808
+ layoutId: t17,
792
809
  pageLocation,
793
- projectName: t16,
810
+ projectName: t18,
794
811
  children
795
812
  })
796
813
  });
797
- $[19] = children;
798
- $[20] = isMobileStudio;
799
- $[21] = pageLocation;
800
- $[22] = t13;
801
- $[23] = t14;
802
- $[24] = t15;
803
- $[25] = t16;
804
- $[26] = t17;
805
- } else t17 = $[26];
806
- let t18;
807
- if ($[27] !== isCanvasEnabled || $[28] !== pathname || $[29] !== runtimeBasePath || $[30] !== t12 || $[31] !== t17 || $[32] !== t9) {
808
- t18 = /* @__PURE__ */ jsx(CanvasPreview, {
814
+ $[23] = children;
815
+ $[24] = isMobileStudio;
816
+ $[25] = pageLocation;
817
+ $[26] = t15;
818
+ $[27] = t16;
819
+ $[28] = t17;
820
+ $[29] = t18;
821
+ $[30] = t19;
822
+ } else t19 = $[30];
823
+ let t20;
824
+ if ($[31] !== isCanvasEnabled || $[32] !== pathname || $[33] !== runtimeBasePath || $[34] !== t11 || $[35] !== t14 || $[36] !== t19) {
825
+ t20 = /* @__PURE__ */ jsx(CanvasPreview, {
809
826
  enabled: isCanvasEnabled,
810
827
  pathname,
811
- pagePathname: t9,
828
+ pagePathname: t11,
812
829
  runtimeBasePath,
813
- placeholder: t12,
814
- children: t17
830
+ placeholder: t14,
831
+ children: t19
815
832
  });
816
- $[27] = isCanvasEnabled;
817
- $[28] = pathname;
818
- $[29] = runtimeBasePath;
819
- $[30] = t12;
820
- $[31] = t17;
821
- $[32] = t9;
822
- $[33] = t18;
823
- } else t18 = $[33];
824
- let t19;
825
- if ($[34] !== isCanvasEnabled || $[35] !== pageId) {
826
- t19 = !isCanvasEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CreatePageModal, {}), pageId != null && /* @__PURE__ */ jsx(AddBlockDialog, {})] });
827
- $[34] = isCanvasEnabled;
828
- $[35] = pageId;
833
+ $[31] = isCanvasEnabled;
834
+ $[32] = pathname;
835
+ $[33] = runtimeBasePath;
836
+ $[34] = t11;
837
+ $[35] = t14;
829
838
  $[36] = t19;
830
- } else t19 = $[36];
831
- let t20;
832
- if ($[37] !== t18 || $[38] !== t19 || $[39] !== t8) {
833
- t20 = /* @__PURE__ */ jsxs("div", {
834
- className: t8,
835
- children: [t18, t19]
836
- });
837
- $[37] = t18;
838
- $[38] = t19;
839
- $[39] = t8;
840
- $[40] = t20;
841
- } else t20 = $[40];
839
+ $[37] = t20;
840
+ } else t20 = $[37];
842
841
  let t21;
843
- if ($[41] !== editingOwner || $[42] !== t20) {
844
- t21 = /* @__PURE__ */ jsx(PreviewEditingOwnerContext, {
845
- value: editingOwner,
846
- children: t20
842
+ if ($[38] !== isCanvasEnabled || $[39] !== pageId) {
843
+ t21 = !isCanvasEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CreatePageModal, {}), pageId != null && /* @__PURE__ */ jsx(AddBlockSheet, {})] });
844
+ $[38] = isCanvasEnabled;
845
+ $[39] = pageId;
846
+ $[40] = t21;
847
+ } else t21 = $[40];
848
+ let t22;
849
+ if ($[41] !== t10 || $[42] !== t20 || $[43] !== t21) {
850
+ t22 = /* @__PURE__ */ jsxs("div", {
851
+ className: t10,
852
+ children: [t20, t21]
847
853
  });
848
- $[41] = editingOwner;
854
+ $[41] = t10;
849
855
  $[42] = t20;
850
856
  $[43] = t21;
851
- } else t21 = $[43];
852
- let t22;
853
- if ($[44] !== projectUuid) {
854
- t22 = /* @__PURE__ */ jsx(ContentCollectionItemSheet, { projectUuid });
855
- $[44] = projectUuid;
856
- $[45] = t22;
857
- } else t22 = $[45];
857
+ $[44] = t22;
858
+ } else t22 = $[44];
858
859
  let t23;
859
- if ($[46] !== t21 || $[47] !== t22) {
860
- t23 = /* @__PURE__ */ jsxs(CollectionItemSheetProvider, {
860
+ if ($[45] !== editingOwner || $[46] !== t22) {
861
+ t23 = /* @__PURE__ */ jsx(PreviewEditingOwnerContext, {
862
+ value: editingOwner,
863
+ children: t22
864
+ });
865
+ $[45] = editingOwner;
866
+ $[46] = t22;
867
+ $[47] = t23;
868
+ } else t23 = $[47];
869
+ let t24;
870
+ if ($[48] !== projectUuid) {
871
+ t24 = /* @__PURE__ */ jsx(ContentCollectionItemSheet, { projectUuid });
872
+ $[48] = projectUuid;
873
+ $[49] = t24;
874
+ } else t24 = $[49];
875
+ let t25;
876
+ if ($[50] !== t23 || $[51] !== t24) {
877
+ t25 = /* @__PURE__ */ jsxs(CollectionItemSheetProvider, {
861
878
  onRouteTargetClose: _temp9,
862
- children: [t21, t22]
879
+ children: [t23, t24]
863
880
  });
864
- $[46] = t21;
865
- $[47] = t22;
866
- $[48] = t23;
867
- } else t23 = $[48];
868
- return t23;
881
+ $[50] = t23;
882
+ $[51] = t24;
883
+ $[52] = t25;
884
+ } else t25 = $[52];
885
+ return t25;
869
886
  };
870
887
  /** Zooms out to the whole Canvas, from anywhere in the site or the Studio. */
871
888
  function useShowCanvasAction() {
@@ -14,12 +14,12 @@ import { generateKeyBetween } from "fractional-indexing";
14
14
  import { useSelector } from "@xstate/store-react";
15
15
  import { jsx, jsxs } from "react/jsx-runtime";
16
16
  import { useMutation } from "@tanstack/react-query";
17
- import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@camox/ui/dialog";
17
+ import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@camox/ui/sheet";
18
18
  import { Badge } from "@camox/ui/badge";
19
19
  import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, commandFilter } from "@camox/ui/command";
20
20
 
21
- //#region src/features/preview/components/AddBlockDialog.tsx
22
- const AddBlockDialog = ({ focusCreatedBlock = true }) => {
21
+ //#region src/features/preview/components/AddBlockSheet.tsx
22
+ const AddBlockSheet = ({ focusCreatedBlock = true }) => {
23
23
  const [highlightedValue, setHighlightedValue] = React.useState("");
24
24
  const [search, setSearch] = React.useState("");
25
25
  const [error, setError] = React.useState(null);
@@ -32,7 +32,7 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
32
32
  };
33
33
  }, []);
34
34
  const gridRef = React.useRef(null);
35
- const dialog = useSelector(previewStore, (state) => state.context.addBlockDialog);
35
+ const sheet = useSelector(previewStore, (state) => state.context.addBlockSheet);
36
36
  const studioCache = useStudioCache();
37
37
  const projectUuid = useProjectUuid();
38
38
  const pathname = useLocalePath();
@@ -117,15 +117,15 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
117
117
  for (const block of pageBlocks) counts[block.type] = (counts[block.type] ?? 0) + 1;
118
118
  return counts;
119
119
  }, [page, pageBlocks]);
120
- const [previousDialog, setPreviousDialog] = React.useState(dialog);
121
- if (dialog !== previousDialog) {
122
- setPreviousDialog(dialog);
120
+ const [previousSheet, setPreviousSheet] = React.useState(sheet);
121
+ if (sheet !== previousSheet) {
122
+ setPreviousSheet(sheet);
123
123
  setHighlightedValue("");
124
124
  setSearch("");
125
125
  setError(null);
126
126
  }
127
127
  const handleAddBlock = async (block) => {
128
- if (!page || !dialog || submitting.current) return;
128
+ if (!page || !sheet || submitting.current) return;
129
129
  submitting.current = true;
130
130
  setError(null);
131
131
  const owner = {
@@ -140,21 +140,21 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
140
140
  type: block._internal.id,
141
141
  content: bundle.content,
142
142
  settings: bundle.settings,
143
- afterPosition: dialog.afterPosition,
143
+ afterPosition: sheet.afterPosition,
144
144
  repeatableItems: bundle.repeatableItems
145
145
  });
146
146
  const context = previewStore.getSnapshot().context;
147
147
  if (!mounted.current) return;
148
148
  if (focusCreatedBlock && !sameEditingOwner(context.editingContext, owner)) return;
149
- if (context.addBlockDialog !== dialog) return;
150
- previewStore.send({ type: "closeAddBlockDialog" });
149
+ if (context.addBlockSheet !== sheet) return;
150
+ previewStore.send({ type: "closeAddBlockSheet" });
151
151
  if (focusCreatedBlock) previewStore.send({
152
152
  type: "focusCreatedBlock",
153
153
  ...owner,
154
154
  blockId
155
155
  });
156
156
  } catch {
157
- if (previewStore.getSnapshot().context.addBlockDialog === dialog) setError("Could not add this block. Please try again.");
157
+ if (previewStore.getSnapshot().context.addBlockSheet === sheet) setError("Could not add this block. Please try again.");
158
158
  } finally {
159
159
  submitting.current = false;
160
160
  }
@@ -165,24 +165,25 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
165
165
  const page = pageCounts[blockId] ?? "none";
166
166
  return `${total} use${total > 1 ? "s" : ""} (${page} here)`;
167
167
  };
168
- return /* @__PURE__ */ jsx(Dialog, {
169
- open: dialog != null,
168
+ return /* @__PURE__ */ jsx(Sheet, {
169
+ open: sheet != null,
170
170
  onOpenChange: (open) => {
171
- if (!open && !submitting.current) previewStore.send({ type: "closeAddBlockDialog" });
171
+ if (!open && !submitting.current) previewStore.send({ type: "closeAddBlockSheet" });
172
172
  },
173
- children: /* @__PURE__ */ jsxs(DialogContent, {
174
- className: "flex h-[min(85dvh,900px)] flex-col gap-4 overflow-hidden sm:max-w-6xl",
173
+ children: /* @__PURE__ */ jsxs(SheetContent, {
174
+ side: "right",
175
+ className: "gap-0 overflow-hidden data-[side=right]:w-full data-[side=right]:sm:max-w-4xl",
175
176
  children: [
176
- /* @__PURE__ */ jsxs(DialogHeader, {
177
- className: "pr-8",
178
- children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Add a block" }), /* @__PURE__ */ jsx(DialogDescription, { children: "Search blocks, use the arrow keys to browse, and press Enter to add." })]
177
+ /* @__PURE__ */ jsxs(SheetHeader, {
178
+ className: "pr-12",
179
+ children: [/* @__PURE__ */ jsx(SheetTitle, { children: "Add a block" }), /* @__PURE__ */ jsx(SheetDescription, { children: "Search blocks, use the arrow keys to browse, and press Enter to add." })]
179
180
  }),
180
181
  /* @__PURE__ */ jsxs(Command, {
181
182
  label: "Search blocks",
182
183
  shouldFilter: false,
183
184
  value: selectedValue,
184
185
  onValueChange: setHighlightedValue,
185
- className: "h-0 min-h-0 flex-1 rounded-none! bg-transparent! p-0!",
186
+ className: "h-0 min-h-0 flex-1 rounded-none! bg-transparent! px-4! pt-0! pb-0!",
186
187
  onKeyDown: (e) => {
187
188
  if (e.nativeEvent.isComposing || e.altKey || e.ctrlKey || e.metaKey) return;
188
189
  if (![
@@ -214,11 +215,11 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
214
215
  autoFocus: true
215
216
  }), /* @__PURE__ */ jsxs(CommandList, {
216
217
  label: "Available blocks",
217
- className: "mt-4 max-h-none min-h-0 flex-1 pb-2",
218
+ className: "mt-4 max-h-none min-h-0 flex-1 pb-4",
218
219
  "aria-busy": createBlock.isPending,
219
220
  children: [/* @__PURE__ */ jsx(CommandEmpty, { children: "No blocks found." }), /* @__PURE__ */ jsx(CommandGroup, {
220
221
  ref: gridRef,
221
- className: "p-0 [&>[cmdk-group-items]]:grid [&>[cmdk-group-items]]:grid-cols-1 [&>[cmdk-group-items]]:gap-4 sm:[&>[cmdk-group-items]]:grid-cols-2 lg:[&>[cmdk-group-items]]:grid-cols-3",
222
+ className: "@container p-0 [&>[cmdk-group-items]]:grid [&>[cmdk-group-items]]:grid-cols-1 [&>[cmdk-group-items]]:gap-4 @xl:[&>[cmdk-group-items]]:grid-cols-2 @3xl:[&>[cmdk-group-items]]:grid-cols-3",
222
223
  children: filteredBlocks.map((block) => /* @__PURE__ */ jsxs(CommandItem, {
223
224
  value: block._internal.id,
224
225
  keywords: [block._internal.title, block._internal.description ?? ""],
@@ -252,14 +253,16 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
252
253
  })]
253
254
  })]
254
255
  }),
255
- createBlock.isPending && /* @__PURE__ */ jsx("p", {
256
- role: "status",
257
- children: "Adding block…"
258
- }),
259
- error && /* @__PURE__ */ jsx("p", {
260
- role: "alert",
261
- className: "text-destructive",
262
- children: error
256
+ (createBlock.isPending || error) && /* @__PURE__ */ jsxs("div", {
257
+ className: "border-border border-t p-4",
258
+ children: [createBlock.isPending && /* @__PURE__ */ jsx("p", {
259
+ role: "status",
260
+ children: "Adding block…"
261
+ }), error && /* @__PURE__ */ jsx("p", {
262
+ role: "alert",
263
+ className: "text-destructive",
264
+ children: error
265
+ })]
263
266
  })
264
267
  ]
265
268
  })
@@ -267,4 +270,4 @@ const AddBlockDialog = ({ focusCreatedBlock = true }) => {
267
270
  };
268
271
 
269
272
  //#endregion
270
- export { AddBlockDialog };
273
+ export { AddBlockSheet };
@@ -50,13 +50,13 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
50
50
  const blockIndex = pageBlocks.findIndex((b) => b.id === block.id);
51
51
  const afterPosition = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
52
52
  previewStore.send({
53
- type: "openAddBlockDialog",
53
+ type: "openAddBlockSheet",
54
54
  afterPosition
55
55
  });
56
56
  };
57
57
  const handleAddBlockBelow = (block) => {
58
58
  previewStore.send({
59
- type: "openAddBlockDialog",
59
+ type: "openAddBlockSheet",
60
60
  afterPosition: block.position
61
61
  });
62
62
  };
@@ -104,7 +104,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
104
104
  isLayoutBlock && layoutSlot === "before" && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsx(CommandItem, {
105
105
  onSelect: () => {
106
106
  previewStore.send({
107
- type: "openAddBlockDialog",
107
+ type: "openAddBlockSheet",
108
108
  afterPosition: ""
109
109
  });
110
110
  onOpenChange(false);
@@ -118,7 +118,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
118
118
  onSelect: () => {
119
119
  const lastPageBlock = pageBlocks[pageBlocks.length - 1];
120
120
  previewStore.send({
121
- type: "openAddBlockDialog",
121
+ type: "openAddBlockSheet",
122
122
  afterPosition: lastPageBlock?.position
123
123
  });
124
124
  onOpenChange(false);
@@ -419,7 +419,7 @@ function useBlockActionsShortcuts() {
419
419
  const block_2 = pageBlocks.find((b_6) => b_6.id === sel_7.blockId);
420
420
  if (!block_2) return;
421
421
  previewStore.send({
422
- type: "openAddBlockDialog",
422
+ type: "openAddBlockSheet",
423
423
  afterPosition: block_2.position
424
424
  });
425
425
  }
@@ -444,7 +444,7 @@ function useBlockActionsShortcuts() {
444
444
  if (blockIndex === -1) return;
445
445
  const afterPosition_1 = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
446
446
  previewStore.send({
447
- type: "openAddBlockDialog",
447
+ type: "openAddBlockSheet",
448
448
  afterPosition: afterPosition_1
449
449
  });
450
450
  }
@@ -27,6 +27,7 @@ const ThumbnailFrame = (t0) => {
27
27
  $[1] = t1;
28
28
  } else t1 = $[1];
29
29
  const bundle = t1;
30
+ const initialization = React.useRef(0);
30
31
  let t2;
31
32
  if ($[2] !== frame?.contentDocument || $[3] !== sourceDocument) {
32
33
  t2 = () => {
@@ -38,8 +39,15 @@ const ThumbnailFrame = (t0) => {
38
39
  const base = doc.createElement("base");
39
40
  base.href = source.baseURI;
40
41
  doc.head.appendChild(base);
42
+ const stylesheetsLoaded = [];
41
43
  source.querySelectorAll("style, link[rel=\"stylesheet\"]").forEach((style) => {
42
- if (isSiteStyle(style)) doc.head.appendChild(style.cloneNode(true));
44
+ if (!isSiteStyle(style)) return;
45
+ const clone = style.cloneNode(true);
46
+ if (clone.localName === "link") stylesheetsLoaded.push(new Promise((resolve) => {
47
+ clone.addEventListener("load", resolve, { once: true });
48
+ clone.addEventListener("error", resolve, { once: true });
49
+ }));
50
+ doc.head.appendChild(clone);
43
51
  });
44
52
  if (source !== document) for (const [from, to] of [
45
53
  [source.documentElement, doc.documentElement],
@@ -53,7 +61,10 @@ const ThumbnailFrame = (t0) => {
53
61
  reset.textContent = "\n html, body { margin: 0 !important; overflow: hidden !important; }\n *, *::before, *::after {\n animation: none !important;\n transition: none !important;\n caret-color: transparent !important;\n }\n ";
54
62
  doc.head.appendChild(reset);
55
63
  doc.body.setAttribute("inert", "");
56
- setRoot(mount);
64
+ const generation = initialization.current = initialization.current + 1;
65
+ Promise.all(stylesheetsLoaded).then(() => {
66
+ if (initialization.current === generation) setRoot(mount);
67
+ });
57
68
  };
58
69
  $[2] = frame?.contentDocument;
59
70
  $[3] = sourceDocument;
@@ -185,12 +196,11 @@ const ThumbnailFrame = (t0) => {
185
196
  return t14;
186
197
  };
187
198
  const BlockThumbnail = (t0) => {
188
- const $ = c(15);
199
+ const $ = c(11);
189
200
  const { block, className } = t0;
190
201
  const ref = React.useRef(null);
191
202
  const [isVisible, setIsVisible] = React.useState(false);
192
203
  const [width, setWidth] = React.useState(0);
193
- const checkerSize = 8 * (1 + width / VIEWPORT_WIDTH);
194
204
  let t1;
195
205
  let t2;
196
206
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -222,46 +232,34 @@ const BlockThumbnail = (t0) => {
222
232
  React.useEffect(t1, t2);
223
233
  let t3;
224
234
  if ($[2] !== className) {
225
- t3 = cn("checkered pointer-events-none relative flex h-28 w-full items-center overflow-hidden", className);
235
+ t3 = cn("bg-muted pointer-events-none relative flex h-28 w-full items-center overflow-hidden", className);
226
236
  $[2] = className;
227
237
  $[3] = t3;
228
238
  } else t3 = $[3];
229
239
  let t4;
230
- if ($[4] !== checkerSize || $[5] !== width) {
231
- t4 = width > 0 ? {
232
- backgroundSize: `${checkerSize * 2}px ${checkerSize * 2}px`,
233
- backgroundPosition: `0 0, 0 ${checkerSize}px, ${checkerSize}px ${-checkerSize}px, ${-checkerSize}px 0`
234
- } : void 0;
235
- $[4] = checkerSize;
236
- $[5] = width;
237
- $[6] = t4;
238
- } else t4 = $[6];
239
- let t5;
240
- if ($[7] !== block || $[8] !== isVisible || $[9] !== width) {
241
- t5 = isVisible && width > 0 && /* @__PURE__ */ jsx(ThumbnailFrame, {
240
+ if ($[4] !== block || $[5] !== isVisible || $[6] !== width) {
241
+ t4 = isVisible && width > 0 && /* @__PURE__ */ jsx(ThumbnailFrame, {
242
242
  block,
243
243
  width
244
244
  });
245
- $[7] = block;
246
- $[8] = isVisible;
247
- $[9] = width;
248
- $[10] = t5;
249
- } else t5 = $[10];
250
- let t6;
251
- if ($[11] !== t3 || $[12] !== t4 || $[13] !== t5) {
252
- t6 = /* @__PURE__ */ jsx("div", {
245
+ $[4] = block;
246
+ $[5] = isVisible;
247
+ $[6] = width;
248
+ $[7] = t4;
249
+ } else t4 = $[7];
250
+ let t5;
251
+ if ($[8] !== t3 || $[9] !== t4) {
252
+ t5 = /* @__PURE__ */ jsx("div", {
253
253
  ref,
254
254
  className: t3,
255
- style: t4,
256
255
  "aria-hidden": "true",
257
- children: t5
256
+ children: t4
258
257
  });
259
- $[11] = t3;
260
- $[12] = t4;
261
- $[13] = t5;
262
- $[14] = t6;
263
- } else t6 = $[14];
264
- return t6;
258
+ $[8] = t3;
259
+ $[9] = t4;
260
+ $[10] = t5;
261
+ } else t5 = $[10];
262
+ return t5;
265
263
  };
266
264
 
267
265
  //#endregion
@@ -39,7 +39,7 @@ function CuratedAddBlockListener(t0) {
39
39
  else if (blockIndex === 0) afterPosition = "";
40
40
  }
41
41
  previewStore.send({
42
- type: "openAddBlockDialog",
42
+ type: "openAddBlockSheet",
43
43
  afterPosition
44
44
  });
45
45
  }
@@ -835,7 +835,7 @@ function _temp3(block_3) {
835
835
  return /* @__PURE__ */ jsx(SortableBlock, { block: block_3 }, block_3.id);
836
836
  }
837
837
  function _temp4() {
838
- previewStore.send({ type: "openAddBlockDialog" });
838
+ previewStore.send({ type: "openAddBlockSheet" });
839
839
  }
840
840
 
841
841
  //#endregion
@@ -478,7 +478,7 @@ const PreviewPanel = (t0) => {
478
478
  $[43] = t19;
479
479
  } else t19 = $[43];
480
480
  const t20 = !placed && "inset-0";
481
- const t21 = underCanvas && (!placed || placed.hidden) && "invisible";
481
+ const t21 = underCanvas && !placed && "invisible";
482
482
  const t22 = device && "checkered flex items-center justify-center";
483
483
  let t23;
484
484
  if ($[44] !== t20 || $[45] !== t21 || $[46] !== t22) {