@measured/puck 0.14.0-canary.70cf177 → 0.14.0-canary.83be956

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.
package/dist/index.js CHANGED
@@ -8084,7 +8084,7 @@ var require_react_dom_development = __commonJS({
8084
8084
  var HostPortal = 4;
8085
8085
  var HostComponent = 5;
8086
8086
  var HostText = 6;
8087
- var Fragment14 = 7;
8087
+ var Fragment17 = 7;
8088
8088
  var Mode = 8;
8089
8089
  var ContextConsumer = 9;
8090
8090
  var ContextProvider = 10;
@@ -9240,7 +9240,7 @@ var require_react_dom_development = __commonJS({
9240
9240
  return "DehydratedFragment";
9241
9241
  case ForwardRef:
9242
9242
  return getWrappedName$1(type, type.render, "ForwardRef");
9243
- case Fragment14:
9243
+ case Fragment17:
9244
9244
  return "Fragment";
9245
9245
  case HostComponent:
9246
9246
  return type;
@@ -18911,7 +18911,7 @@ var require_react_dom_development = __commonJS({
18911
18911
  }
18912
18912
  }
18913
18913
  function updateFragment2(returnFiber, current2, fragment, lanes, key) {
18914
- if (current2 === null || current2.tag !== Fragment14) {
18914
+ if (current2 === null || current2.tag !== Fragment17) {
18915
18915
  var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
18916
18916
  created.return = returnFiber;
18917
18917
  return created;
@@ -19314,7 +19314,7 @@ var require_react_dom_development = __commonJS({
19314
19314
  if (child.key === key) {
19315
19315
  var elementType = element.type;
19316
19316
  if (elementType === REACT_FRAGMENT_TYPE) {
19317
- if (child.tag === Fragment14) {
19317
+ if (child.tag === Fragment17) {
19318
19318
  deleteRemainingChildren(returnFiber, child.sibling);
19319
19319
  var existing = useFiber(child, element.props.children);
19320
19320
  existing.return = returnFiber;
@@ -23489,7 +23489,7 @@ var require_react_dom_development = __commonJS({
23489
23489
  var _resolvedProps2 = workInProgress2.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
23490
23490
  return updateForwardRef(current2, workInProgress2, type, _resolvedProps2, renderLanes2);
23491
23491
  }
23492
- case Fragment14:
23492
+ case Fragment17:
23493
23493
  return updateFragment(current2, workInProgress2, renderLanes2);
23494
23494
  case Mode:
23495
23495
  return updateMode(current2, workInProgress2, renderLanes2);
@@ -23762,7 +23762,7 @@ var require_react_dom_development = __commonJS({
23762
23762
  case SimpleMemoComponent:
23763
23763
  case FunctionComponent:
23764
23764
  case ForwardRef:
23765
- case Fragment14:
23765
+ case Fragment17:
23766
23766
  case Mode:
23767
23767
  case Profiler:
23768
23768
  case ContextConsumer:
@@ -28021,7 +28021,7 @@ var require_react_dom_development = __commonJS({
28021
28021
  return fiber;
28022
28022
  }
28023
28023
  function createFiberFromFragment(elements, mode, lanes, key) {
28024
- var fiber = createFiber(Fragment14, elements, key, mode);
28024
+ var fiber = createFiber(Fragment17, elements, key, mode);
28025
28025
  fiber.lanes = lanes;
28026
28026
  return fiber;
28027
28027
  }
@@ -29173,7 +29173,7 @@ var import_react2 = require("react");
29173
29173
 
29174
29174
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
29175
29175
  init_react_import();
29176
- var Button_module_default = { "Button": "_Button_8fn3a_1", "Button--medium": "_Button--medium_8fn3a_29", "Button--large": "_Button--large_8fn3a_37", "Button-icon": "_Button-icon_8fn3a_44", "Button--primary": "_Button--primary_8fn3a_48", "Button--secondary": "_Button--secondary_8fn3a_67", "Button--flush": "_Button--flush_8fn3a_82", "Button--disabled": "_Button--disabled_8fn3a_86", "Button--fullWidth": "_Button--fullWidth_8fn3a_93", "Button-spinner": "_Button-spinner_8fn3a_98" };
29176
+ var Button_module_default = { "Button": "_Button_1t64k_1", "Button--medium": "_Button--medium_1t64k_29", "Button--large": "_Button--large_1t64k_37", "Button-icon": "_Button-icon_1t64k_44", "Button--primary": "_Button--primary_1t64k_48", "Button--secondary": "_Button--secondary_1t64k_67", "Button--flush": "_Button--flush_1t64k_84", "Button--disabled": "_Button--disabled_1t64k_88", "Button--fullWidth": "_Button--fullWidth_1t64k_95", "Button-spinner": "_Button-spinner_1t64k_100" };
29177
29177
 
29178
29178
  // lib/get-class-name-factory.ts
29179
29179
  init_react_import();
@@ -29343,12 +29343,14 @@ var defaultContext = {
29343
29343
  history: {},
29344
29344
  viewports: defaultViewports,
29345
29345
  zoomConfig: {
29346
- autoZoom: 0,
29346
+ autoZoom: 1,
29347
29347
  rootHeight: 0,
29348
29348
  zoom: 1
29349
29349
  },
29350
29350
  setZoomConfig: () => null,
29351
- status: "LOADING"
29351
+ status: "LOADING",
29352
+ setStatus: () => null,
29353
+ iframe: {}
29352
29354
  };
29353
29355
  var appContext = (0, import_react3.createContext)(defaultContext);
29354
29356
  var AppProvider = ({
@@ -29358,12 +29360,12 @@ var AppProvider = ({
29358
29360
  const [zoomConfig, setZoomConfig] = (0, import_react3.useState)(defaultContext.zoomConfig);
29359
29361
  const [status, setStatus] = (0, import_react3.useState)("LOADING");
29360
29362
  (0, import_react3.useEffect)(() => {
29361
- setStatus("READY");
29363
+ setStatus("MOUNTED");
29362
29364
  }, []);
29363
29365
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
29364
29366
  appContext.Provider,
29365
29367
  {
29366
- value: __spreadProps(__spreadValues({}, value), { zoomConfig, setZoomConfig, status }),
29368
+ value: __spreadProps(__spreadValues({}, value), { zoomConfig, setZoomConfig, status, setStatus }),
29367
29369
  children
29368
29370
  }
29369
29371
  );
@@ -29400,10 +29402,10 @@ var defaultSnapshot = {
29400
29402
  draggingFromThisWith: null,
29401
29403
  isUsingPlaceholder: false
29402
29404
  };
29403
- var DefaultDroppable = ({ children }) => children(defaultProvided, defaultSnapshot);
29405
+ var DefaultDroppable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: children(defaultProvided, defaultSnapshot) });
29404
29406
  var Droppable = (props) => {
29405
29407
  const { status } = useAppContext();
29406
- const El = status === "READY" ? import_dnd.Droppable : DefaultDroppable;
29408
+ const El = status !== "LOADING" ? import_dnd.Droppable : DefaultDroppable;
29407
29409
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(El, __spreadValues({}, props));
29408
29410
  };
29409
29411
 
@@ -29438,7 +29440,7 @@ var defaultRubric = {
29438
29440
  type: "",
29439
29441
  source: { droppableId: "", index: 0 }
29440
29442
  };
29441
- var DefaultDraggable = ({ children }) => children(defaultProvided2, defaultSnapshot2, defaultRubric);
29443
+ var DefaultDraggable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: children(defaultProvided2, defaultSnapshot2, defaultRubric) });
29442
29444
  var Draggable = ({
29443
29445
  className,
29444
29446
  children,
@@ -29449,7 +29451,7 @@ var Draggable = ({
29449
29451
  isDragDisabled = false
29450
29452
  }) => {
29451
29453
  const { status } = useAppContext();
29452
- const El = status === "READY" ? import_dnd2.Draggable : DefaultDraggable;
29454
+ const El = status !== "LOADING" ? import_dnd2.Draggable : DefaultDraggable;
29453
29455
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(El, { draggableId: id, index, isDragDisabled, children: (provided, snapshot) => {
29454
29456
  var _a;
29455
29457
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
@@ -29587,7 +29589,7 @@ var import_dnd3 = require("@measured/dnd");
29587
29589
 
29588
29590
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
29589
29591
  init_react_import();
29590
- var styles_module_default3 = { "DraggableComponent": "_DraggableComponent_175tf_1", "DraggableComponent--isDragging": "_DraggableComponent--isDragging_175tf_11", "DraggableComponent-contents": "_DraggableComponent-contents_175tf_16", "DraggableComponent-overlay": "_DraggableComponent-overlay_175tf_29", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_175tf_49", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_175tf_65", "DraggableComponent--forceHover": "_DraggableComponent--forceHover_175tf_71", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_175tf_76", "DraggableComponent--indicativeHover": "_DraggableComponent--indicativeHover_175tf_81", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_175tf_97", "DraggableComponent-actions": "_DraggableComponent-actions_175tf_97", "DraggableComponent-actionsLabel": "_DraggableComponent-actionsLabel_175tf_127", "DraggableComponent-action": "_DraggableComponent-action_175tf_97" };
29592
+ var styles_module_default3 = { "DraggableComponent": "_DraggableComponent_1542z_1", "DraggableComponent--isDragging": "_DraggableComponent--isDragging_1542z_11", "DraggableComponent-contents": "_DraggableComponent-contents_1542z_16", "DraggableComponent-overlay": "_DraggableComponent-overlay_1542z_29", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1542z_49", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1542z_65", "DraggableComponent--forceHover": "_DraggableComponent--forceHover_1542z_71", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1542z_76", "DraggableComponent--indicativeHover": "_DraggableComponent--indicativeHover_1542z_81", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1542z_97", "DraggableComponent-actions": "_DraggableComponent-actions_1542z_97", "DraggableComponent-actionsLabel": "_DraggableComponent-actionsLabel_1542z_127", "DraggableComponent-action": "_DraggableComponent-action_1542z_97" };
29591
29593
 
29592
29594
  // ../../node_modules/lucide-react/dist/esm/lucide-react.js
29593
29595
  init_react_import();
@@ -29877,6 +29879,18 @@ var useModifierHeld = (modifier) => {
29877
29879
  return modifierHeld;
29878
29880
  };
29879
29881
 
29882
+ // lib/is-ios.ts
29883
+ init_react_import();
29884
+ var isIos = () => [
29885
+ "iPad Simulator",
29886
+ "iPhone Simulator",
29887
+ "iPod Simulator",
29888
+ "iPad",
29889
+ "iPhone",
29890
+ "iPod"
29891
+ ].includes(navigator.platform) || // iPad on iOS 13 detection
29892
+ navigator.userAgent.includes("Mac") && "ontouchend" in document;
29893
+
29880
29894
  // components/DraggableComponent/index.tsx
29881
29895
  var import_react_spinners2 = require("react-spinners");
29882
29896
  var import_jsx_runtime7 = require("react/jsx-runtime");
@@ -29910,62 +29924,78 @@ var DraggableComponent = ({
29910
29924
  const { zoomConfig } = useAppContext();
29911
29925
  const isModifierHeld = useModifierHeld("Alt");
29912
29926
  const { status } = useAppContext();
29913
- const El = status === "READY" ? import_dnd3.Draggable : DefaultDraggable;
29927
+ const El = status !== "LOADING" ? import_dnd3.Draggable : DefaultDraggable;
29914
29928
  (0, import_react7.useEffect)(onMount, []);
29915
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(El, { draggableId: id, index, isDragDisabled, children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
29916
- "div",
29917
- __spreadProps(__spreadValues(__spreadValues({
29918
- ref: provided.innerRef
29919
- }, provided.draggableProps), provided.dragHandleProps), {
29920
- className: getClassName4({
29921
- isSelected,
29922
- isModifierHeld,
29923
- isDragging: snapshot.isDragging,
29924
- isLocked,
29925
- forceHover,
29926
- indicativeHover
29927
- }),
29928
- style: __spreadProps(__spreadValues(__spreadValues({}, style), provided.draggableProps.style), {
29929
- cursor: isModifierHeld ? "initial" : "grab"
29930
- }),
29931
- onMouseOver,
29932
- onMouseOut,
29933
- onMouseDown,
29934
- onMouseUp,
29935
- onClick,
29936
- children: [
29937
- debug,
29938
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_spinners2.ClipLoader, { "aria-label": "loading", size: 16, color: "inherit" }) }),
29939
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
29940
- "div",
29941
- {
29942
- className: getClassName4("actionsOverlay"),
29943
- style: {
29944
- top: actionsOverlayTop / zoomConfig.zoom
29945
- },
29946
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
29929
+ const [disableSecondaryAnimation, setDisableSecondaryAnimation] = (0, import_react7.useState)(false);
29930
+ (0, import_react7.useEffect)(() => {
29931
+ if (isIos()) {
29932
+ setDisableSecondaryAnimation(true);
29933
+ }
29934
+ }, []);
29935
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
29936
+ El,
29937
+ {
29938
+ draggableId: id,
29939
+ index,
29940
+ isDragDisabled,
29941
+ disableSecondaryAnimation,
29942
+ children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
29943
+ "div",
29944
+ __spreadProps(__spreadValues(__spreadValues({
29945
+ ref: provided.innerRef
29946
+ }, provided.draggableProps), provided.dragHandleProps), {
29947
+ className: getClassName4({
29948
+ isSelected,
29949
+ isModifierHeld,
29950
+ isDragging: snapshot.isDragging,
29951
+ isLocked,
29952
+ forceHover,
29953
+ indicativeHover
29954
+ }),
29955
+ style: __spreadProps(__spreadValues(__spreadValues({}, style), provided.draggableProps.style), {
29956
+ cursor: isModifierHeld ? "initial" : "grab"
29957
+ }),
29958
+ onMouseOver,
29959
+ onMouseOut,
29960
+ onMouseDown,
29961
+ onMouseUp,
29962
+ onClick,
29963
+ children: [
29964
+ debug,
29965
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_spinners2.ClipLoader, { "aria-label": "loading", size: 16, color: "inherit" }) }),
29966
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
29947
29967
  "div",
29948
29968
  {
29949
- className: getClassName4("actions"),
29969
+ className: getClassName4("actionsOverlay"),
29950
29970
  style: {
29951
- transform: `scale(${1 / zoomConfig.zoom}`,
29952
- top: actionsTop / zoomConfig.zoom,
29953
- right: actionsRight / zoomConfig.zoom
29971
+ top: actionsOverlayTop / zoomConfig.zoom
29954
29972
  },
29955
- children: [
29956
- label && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("actionsLabel"), children: label }),
29957
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: getClassName4("action"), onClick: onDuplicate, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 }) }),
29958
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: getClassName4("action"), onClick: onDelete, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 }) })
29959
- ]
29973
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
29974
+ "div",
29975
+ {
29976
+ className: getClassName4("actions"),
29977
+ style: {
29978
+ transform: `scale(${1 / zoomConfig.zoom}`,
29979
+ top: actionsTop / zoomConfig.zoom,
29980
+ right: actionsRight / zoomConfig.zoom
29981
+ },
29982
+ children: [
29983
+ label && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("actionsLabel"), children: label }),
29984
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: getClassName4("action"), onClick: onDuplicate, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 }) }),
29985
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: getClassName4("action"), onClick: onDelete, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 }) })
29986
+ ]
29987
+ }
29988
+ )
29960
29989
  }
29961
- )
29962
- }
29963
- ),
29964
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("overlay") }),
29965
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("contents"), children })
29966
- ]
29967
- })
29968
- ) }, id);
29990
+ ),
29991
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("overlay") }),
29992
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("contents"), children })
29993
+ ]
29994
+ })
29995
+ )
29996
+ },
29997
+ id
29998
+ );
29969
29999
  };
29970
30000
 
29971
30001
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
@@ -30473,21 +30503,33 @@ var import_react28 = require("react");
30473
30503
  // lib/use-placeholder-style.ts
30474
30504
  init_react_import();
30475
30505
  var import_react11 = require("react");
30506
+
30507
+ // lib/get-frame.ts
30508
+ init_react_import();
30509
+ var getFrame = () => {
30510
+ let frame = document.querySelector("#preview-frame");
30511
+ if ((frame == null ? void 0 : frame.tagName) === "IFRAME") {
30512
+ frame = frame.contentDocument;
30513
+ }
30514
+ return frame;
30515
+ };
30516
+
30517
+ // lib/use-placeholder-style.ts
30476
30518
  var usePlaceholderStyle = () => {
30477
30519
  const queryAttr = "data-rfd-drag-handle-draggable-id";
30478
30520
  const [placeholderStyle, setPlaceholderStyle] = (0, import_react11.useState)();
30479
30521
  const onDragStartOrUpdate = (draggedItem) => {
30480
- var _a, _b, _c;
30522
+ var _a;
30481
30523
  const draggableId = draggedItem.draggableId;
30482
30524
  const destinationIndex = (draggedItem.destination || draggedItem.source).index;
30483
30525
  const droppableId = (draggedItem.destination || draggedItem.source).droppableId;
30484
30526
  const domQuery = `[${queryAttr}='${draggableId}']`;
30485
- const iframe = document.querySelector(`#preview-iframe`);
30486
- const draggedDOM = document.querySelector(domQuery) || ((_a = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _a.document.querySelector(domQuery));
30527
+ const frame = getFrame();
30528
+ const draggedDOM = document.querySelector(domQuery) || (frame == null ? void 0 : frame.querySelector(domQuery));
30487
30529
  if (!draggedDOM) {
30488
30530
  return;
30489
30531
  }
30490
- const targetListElement = (_b = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _b.document.querySelector(
30532
+ const targetListElement = frame == null ? void 0 : frame.querySelector(
30491
30533
  `[data-rfd-droppable-id='${droppableId}']`
30492
30534
  );
30493
30535
  const { clientHeight } = draggedDOM;
@@ -30495,7 +30537,7 @@ var usePlaceholderStyle = () => {
30495
30537
  return;
30496
30538
  }
30497
30539
  let clientY = 0;
30498
- const isSameDroppable = draggedItem.source.droppableId === ((_c = draggedItem.destination) == null ? void 0 : _c.droppableId);
30540
+ const isSameDroppable = draggedItem.source.droppableId === ((_a = draggedItem.destination) == null ? void 0 : _a.droppableId);
30499
30541
  if (destinationIndex > 0) {
30500
30542
  const end = destinationIndex > draggedItem.source.index && isSameDroppable ? destinationIndex + 1 : destinationIndex;
30501
30543
  const children = Array.from(targetListElement.children).filter(
@@ -31300,7 +31342,7 @@ var MenuBar = ({
31300
31342
 
31301
31343
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
31302
31344
  init_react_import();
31303
- var styles_module_default8 = { "Puck": "_Puck_3qn7l_19", "Puck--leftSideBarVisible": "_Puck--leftSideBarVisible_3qn7l_36", "Puck--rightSideBarVisible": "_Puck--rightSideBarVisible_3qn7l_42", "Puck-header": "_Puck-header_3qn7l_96", "Puck-headerInner": "_Puck-headerInner_3qn7l_105", "Puck-headerToggle": "_Puck-headerToggle_3qn7l_115", "Puck-rightSideBarToggle": "_Puck-rightSideBarToggle_3qn7l_122", "Puck-leftSideBarToggle": "_Puck-leftSideBarToggle_3qn7l_123", "Puck-headerTitle": "_Puck-headerTitle_3qn7l_127", "Puck-headerPath": "_Puck-headerPath_3qn7l_131", "Puck-headerTools": "_Puck-headerTools_3qn7l_138", "Puck-menuButton": "_Puck-menuButton_3qn7l_144", "Puck--menuOpen": "_Puck--menuOpen_3qn7l_149", "Puck-leftSideBar": "_Puck-leftSideBar_3qn7l_123", "Puck-frame": "_Puck-frame_3qn7l_168", "Puck-root": "_Puck-root_3qn7l_179", "Puck-rightSideBar": "_Puck-rightSideBar_3qn7l_122", "Puck-canvas": "_Puck-canvas_3qn7l_211", "Puck-canvasControls": "_Puck-canvasControls_3qn7l_226" };
31345
+ var styles_module_default8 = { "Puck": "_Puck_u70b9_19", "Puck--mounted": "_Puck--mounted_u70b9_36", "Puck--leftSideBarVisible": "_Puck--leftSideBarVisible_u70b9_40", "Puck--rightSideBarVisible": "_Puck--rightSideBarVisible_u70b9_46", "Puck-mounted": "_Puck-mounted_u70b9_59", "Puck-header": "_Puck-header_u70b9_100", "Puck-headerInner": "_Puck-headerInner_u70b9_109", "Puck-headerToggle": "_Puck-headerToggle_u70b9_119", "Puck-rightSideBarToggle": "_Puck-rightSideBarToggle_u70b9_126", "Puck-leftSideBarToggle": "_Puck-leftSideBarToggle_u70b9_127", "Puck-headerTitle": "_Puck-headerTitle_u70b9_131", "Puck-headerPath": "_Puck-headerPath_u70b9_135", "Puck-headerTools": "_Puck-headerTools_u70b9_142", "Puck-menuButton": "_Puck-menuButton_u70b9_148", "Puck--menuOpen": "_Puck--menuOpen_u70b9_153", "Puck-leftSideBar": "_Puck-leftSideBar_u70b9_127", "Puck-rightSideBar": "_Puck-rightSideBar_u70b9_126", "Puck-portal": "_Puck-portal_u70b9_181" };
31304
31346
 
31305
31347
  // components/Puck/components/Fields/index.tsx
31306
31348
  init_react_import();
@@ -31324,7 +31366,7 @@ init_react_import();
31324
31366
 
31325
31367
  // css-module:/home/runner/work/puck/puck/packages/core/components/InputOrGroup/fields/ArrayField/styles.module.css#css-module
31326
31368
  init_react_import();
31327
- var styles_module_default10 = { "ArrayField": "_ArrayField_1txra_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_1txra_13", "ArrayField-addButton": "_ArrayField-addButton_1txra_17", "ArrayField--hasItems": "_ArrayField--hasItems_1txra_32", "ArrayFieldItem": "_ArrayFieldItem_1txra_61", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_1txra_69", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_1txra_74", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_1txra_84", "ArrayFieldItem--readOnly": "_ArrayFieldItem--readOnly_1txra_108", "ArrayFieldItem-body": "_ArrayFieldItem-body_1txra_142", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_1txra_150", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_1txra_157", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_1txra_163" };
31369
+ var styles_module_default10 = { "ArrayField": "_ArrayField_1lr58_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_1lr58_13", "ArrayField-addButton": "_ArrayField-addButton_1lr58_18", "ArrayField--hasItems": "_ArrayField--hasItems_1lr58_33", "ArrayFieldItem": "_ArrayFieldItem_1lr58_63", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_1lr58_71", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_1lr58_81", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_1lr58_97", "ArrayField--addDisabled": "_ArrayField--addDisabled_1lr58_128", "ArrayFieldItem-body": "_ArrayFieldItem-body_1lr58_164", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_1lr58_173", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_1lr58_180", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_1lr58_186" };
31328
31370
 
31329
31371
  // components/InputOrGroup/fields/ArrayField/index.tsx
31330
31372
  var import_react14 = require("react");
@@ -31333,10 +31375,10 @@ var import_react14 = require("react");
31333
31375
  init_react_import();
31334
31376
  var import_dnd4 = require("@measured/dnd");
31335
31377
  var import_jsx_runtime14 = require("react/jsx-runtime");
31336
- var DefaultDragDropContext = ({ children }) => children;
31378
+ var DefaultDragDropContext = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children });
31337
31379
  var DragDropContext = (props) => {
31338
31380
  const { status } = useAppContext();
31339
- const El = status === "READY" ? import_dnd4.DragDropContext : DefaultDragDropContext;
31381
+ const El = status !== "LOADING" ? import_dnd4.DragDropContext : DefaultDragDropContext;
31340
31382
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(El, __spreadValues({}, props));
31341
31383
  };
31342
31384
 
@@ -31405,12 +31447,15 @@ var ArrayField = ({
31405
31447
  [arrayState]
31406
31448
  );
31407
31449
  (0, import_react14.useEffect)(() => {
31408
- setUi(mapArrayStateToUi(arrayState));
31450
+ if (arrayState.items.length > 0) {
31451
+ setUi(mapArrayStateToUi(arrayState));
31452
+ }
31409
31453
  }, []);
31410
31454
  const [hovering, setHovering] = (0, import_react14.useState)(false);
31411
31455
  if (field.type !== "array" || !field.arrayFields) {
31412
31456
  return null;
31413
31457
  }
31458
+ const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
31414
31459
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
31415
31460
  FieldLabelInternal,
31416
31461
  {
@@ -31452,7 +31497,8 @@ var ArrayField = ({
31452
31497
  ref: provided.innerRef,
31453
31498
  className: getClassName10({
31454
31499
  isDraggingFrom: !!snapshot.draggingFromThisWith,
31455
- hasItems: Array.isArray(value) && value.length > 0
31500
+ hasItems: Array.isArray(value) && value.length > 0,
31501
+ addDisabled
31456
31502
  }),
31457
31503
  onMouseOver: (e) => {
31458
31504
  e.stopPropagation();
@@ -31503,6 +31549,7 @@ var ArrayField = ({
31503
31549
  !readOnly && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameItem2("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameItem2("action"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
31504
31550
  IconButton,
31505
31551
  {
31552
+ type: "button",
31506
31553
  disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
31507
31554
  onClick: (e) => {
31508
31555
  e.stopPropagation();
@@ -31564,11 +31611,11 @@ var ArrayField = ({
31564
31611
  );
31565
31612
  }),
31566
31613
  provided.placeholder,
31567
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
31614
+ !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
31568
31615
  "button",
31569
31616
  {
31617
+ type: "button",
31570
31618
  className: getClassName10("addButton"),
31571
- disabled: field.max !== void 0 && localState.arrayState.items.length >= field.max,
31572
31619
  onClick: () => {
31573
31620
  const existingValue = value || [];
31574
31621
  const newValue = [
@@ -31730,7 +31777,7 @@ var ExternalInput = ({
31730
31777
  const search = (0, import_react16.useCallback)(
31731
31778
  (query, filters2) => __async(void 0, null, function* () {
31732
31779
  setIsLoading(true);
31733
- const cacheKey = `${id}-${name}-${query}-${JSON.stringify(filters2)}`;
31780
+ const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
31734
31781
  const listData = dataCache[cacheKey] || (yield field.fetchList({ query, filters: filters2 }));
31735
31782
  if (listData) {
31736
31783
  setData(listData);
@@ -31756,6 +31803,7 @@ var ExternalInput = ({
31756
31803
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
31757
31804
  "button",
31758
31805
  {
31806
+ type: "button",
31759
31807
  onClick: () => setOpen(true),
31760
31808
  className: getClassName13("button"),
31761
31809
  children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
@@ -32552,17 +32600,22 @@ var import_auto_frame_component = __toESM(require("@measured/auto-frame-componen
32552
32600
 
32553
32601
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
32554
32602
  init_react_import();
32555
- var styles_module_default16 = { "PuckPreview": "_PuckPreview_29rm6_1", "PuckPreview-iframe": "_PuckPreview-iframe_29rm6_5" };
32603
+ var styles_module_default16 = { "PuckPreview": "_PuckPreview_1mia0_1", "PuckPreview-frame": "_PuckPreview-frame_1mia0_5" };
32556
32604
 
32557
32605
  // components/Puck/components/Preview/index.tsx
32558
32606
  var import_jsx_runtime29 = require("react/jsx-runtime");
32559
32607
  var getClassName21 = get_class_name_factory_default("PuckPreview", styles_module_default16);
32560
32608
  var Preview = ({ id = "puck-preview" }) => {
32561
- const { config, dispatch, state } = useAppContext();
32609
+ const { config, dispatch, state, setStatus, iframe } = useAppContext();
32562
32610
  const Page = (0, import_react22.useCallback)(
32563
32611
  (pageProps) => {
32564
32612
  var _a, _b;
32565
- return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadProps(__spreadValues({}, pageProps), { editMode: true })) : pageProps.children;
32613
+ return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadProps(__spreadValues({
32614
+ id: "puck-root"
32615
+ }, pageProps), {
32616
+ editMode: true,
32617
+ puck: { renderDropZone: DropZone }
32618
+ })) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: pageProps.children });
32566
32619
  },
32567
32620
  [config.root]
32568
32621
  );
@@ -32576,16 +32629,19 @@ var Preview = ({ id = "puck-preview" }) => {
32576
32629
  onClick: () => {
32577
32630
  dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
32578
32631
  },
32579
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
32632
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
32580
32633
  import_auto_frame_component.default,
32581
32634
  {
32582
- id: "preview-iframe",
32583
- className: getClassName21("iframe"),
32635
+ id: "preview-frame",
32636
+ className: getClassName21("frame"),
32584
32637
  "data-rfd-iframe": true,
32585
32638
  ref,
32639
+ onStylesLoaded: () => {
32640
+ setStatus("READY");
32641
+ },
32586
32642
  children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Page, __spreadProps(__spreadValues({ dispatch, state }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DropZone, { zone: rootDroppableId }) }))
32587
32643
  }
32588
- )
32644
+ ) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { id: "preview-frame", className: getClassName21("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Page, __spreadProps(__spreadValues({ dispatch, state }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DropZone, { zone: rootDroppableId }) })) })
32589
32645
  }
32590
32646
  );
32591
32647
  };
@@ -32708,14 +32764,9 @@ var LayerTree = ({
32708
32764
  zone
32709
32765
  });
32710
32766
  const id = zoneContent[i].props.id;
32711
- const iframe = document.querySelector("#preview-iframe");
32712
- if (!(iframe == null ? void 0 : iframe.contentDocument)) {
32713
- throw new Error(
32714
- `Preview iframe could not be found when trying to scroll to item ${id}`
32715
- );
32716
- }
32767
+ const frame = getFrame();
32717
32768
  scrollIntoView(
32718
- iframe.contentDocument.querySelector(
32769
+ frame == null ? void 0 : frame.querySelector(
32719
32770
  `[data-rfd-drag-handle-draggable-id="draggable-${id}"]`
32720
32771
  )
32721
32772
  );
@@ -33056,7 +33107,7 @@ var import_react26 = require("react");
33056
33107
 
33057
33108
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
33058
33109
  init_react_import();
33059
- var styles_module_default18 = { "ViewportControls": "_ViewportControls_14bhf_1", "ViewportControls-divider": "_ViewportControls-divider_14bhf_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_14bhf_21", "ViewportButton--isActive": "_ViewportButton--isActive_14bhf_33", "ViewportButton-inner": "_ViewportButton-inner_14bhf_33" };
33110
+ var styles_module_default18 = { "ViewportControls": "_ViewportControls_3zdvn_1", "ViewportControls-divider": "_ViewportControls-divider_3zdvn_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_3zdvn_21", "ViewportButton--isActive": "_ViewportButton--isActive_3zdvn_33", "ViewportButton-inner": "_ViewportButton-inner_3zdvn_33" };
33060
33111
 
33061
33112
  // components/ViewportControls/index.tsx
33062
33113
  var import_jsx_runtime32 = require("react/jsx-runtime");
@@ -33075,7 +33126,10 @@ var ViewportButton = ({
33075
33126
  onClick
33076
33127
  }) => {
33077
33128
  const { state } = useAppContext();
33078
- const isActive = width === state.ui.viewports.current.width;
33129
+ const [isActive, setIsActive] = (0, import_react26.useState)(false);
33130
+ (0, import_react26.useEffect)(() => {
33131
+ setIsActive(width === state.ui.viewports.current.width);
33132
+ }, [width, state.ui.viewports.current.width]);
33079
33133
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
33080
33134
  IconButton,
33081
33135
  {
@@ -33104,8 +33158,7 @@ var ViewportControls = ({
33104
33158
  onViewportChange,
33105
33159
  onZoom
33106
33160
  }) => {
33107
- const { state, viewports } = useAppContext();
33108
- const viewport = state.ui.viewports.current;
33161
+ const { viewports } = useAppContext();
33109
33162
  const defaultsContainAutoZoom = defaultZoomOptions.find(
33110
33163
  (option) => option.value === autoZoom
33111
33164
  );
@@ -33122,14 +33175,14 @@ var ViewportControls = ({
33122
33175
  [autoZoom]
33123
33176
  );
33124
33177
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: getClassName23(), children: [
33125
- viewports.map((viewport2, i) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
33178
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
33126
33179
  ViewportButton,
33127
33180
  {
33128
- height: viewport2.height,
33129
- width: viewport2.width,
33130
- title: viewport2.label ? `Switch to ${viewport2.label} viewport` : "Switch viewport",
33181
+ height: viewport.height,
33182
+ width: viewport.width,
33183
+ title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
33131
33184
  onClick: onViewportChange,
33132
- children: typeof viewport2.icon === "string" ? icons[viewport2.icon] || viewport2.icon : viewport2.icon || icons.Smartphone
33185
+ children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
33133
33186
  },
33134
33187
  i
33135
33188
  )),
@@ -33190,6 +33243,10 @@ var ViewportControls = ({
33190
33243
  ] });
33191
33244
  };
33192
33245
 
33246
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
33247
+ init_react_import();
33248
+ var styles_module_default19 = { "PuckCanvas": "_PuckCanvas_6zd4y_1", "PuckCanvas-controls": "_PuckCanvas-controls_6zd4y_16", "PuckCanvas-inner": "_PuckCanvas-inner_6zd4y_21", "PuckCanvas-root": "_PuckCanvas-root_6zd4y_32", "PuckCanvas--ready": "_PuckCanvas--ready_6zd4y_56" };
33249
+
33193
33250
  // lib/get-zoom-config.ts
33194
33251
  init_react_import();
33195
33252
  var RESET_ZOOM_SMALLER_THAN_FRAME = true;
@@ -33222,9 +33279,10 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
33222
33279
 
33223
33280
  // components/Puck/components/Canvas/index.tsx
33224
33281
  var import_jsx_runtime33 = require("react/jsx-runtime");
33225
- var getClassName24 = get_class_name_factory_default("Puck", styles_module_default8);
33282
+ var getClassName24 = get_class_name_factory_default("PuckCanvas", styles_module_default19);
33226
33283
  var ZOOM_ON_CHANGE = true;
33227
33284
  var Canvas = () => {
33285
+ const { status, iframe } = useAppContext();
33228
33286
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
33229
33287
  const { ui } = state;
33230
33288
  const frameRef = (0, import_react27.useRef)(null);
@@ -33282,14 +33340,16 @@ var Canvas = () => {
33282
33340
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
33283
33341
  "div",
33284
33342
  {
33285
- className: getClassName24("canvas"),
33343
+ className: getClassName24({
33344
+ ready: status === "READY" || !iframe.enabled
33345
+ }),
33286
33346
  onClick: () => dispatch({
33287
33347
  type: "setUi",
33288
33348
  ui: { itemSelector: null },
33289
33349
  recordHistory: true
33290
33350
  }),
33291
33351
  children: [
33292
- ui.viewports.controlsVisible && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("canvasControls"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
33352
+ ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
33293
33353
  ViewportControls,
33294
33354
  {
33295
33355
  autoZoom: zoomConfig.autoZoom,
@@ -33314,16 +33374,18 @@ var Canvas = () => {
33314
33374
  }
33315
33375
  }
33316
33376
  ) }),
33317
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("frame"), ref: frameRef, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
33377
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("inner"), ref: frameRef, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
33318
33378
  "div",
33319
33379
  {
33320
33380
  className: getClassName24("root"),
33321
33381
  style: {
33322
- width: ui.viewports.current.width,
33382
+ width: iframe.enabled ? ui.viewports.current.width : void 0,
33323
33383
  height: zoomConfig.rootHeight,
33324
- transform: `scale(${zoomConfig.zoom})`,
33325
- transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : ""
33384
+ transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
33385
+ transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
33386
+ overflow: iframe.enabled ? void 0 : "auto"
33326
33387
  },
33388
+ suppressHydrationWarning: true,
33327
33389
  children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Preview, {}) })
33328
33390
  }
33329
33391
  ) })
@@ -33348,7 +33410,10 @@ function Puck({
33348
33410
  renderHeaderActions,
33349
33411
  headerTitle,
33350
33412
  headerPath,
33351
- viewports = defaultViewports
33413
+ viewports = defaultViewports,
33414
+ iframe = {
33415
+ enabled: true
33416
+ }
33352
33417
  }) {
33353
33418
  var _a;
33354
33419
  const historyStore = useHistoryStore();
@@ -33360,23 +33425,28 @@ function Puck({
33360
33425
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
33361
33426
  let clientUiState = {};
33362
33427
  if (typeof window !== "undefined") {
33428
+ if (window.matchMedia("(max-width: 638px)").matches) {
33429
+ clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
33430
+ leftSideBarVisible: false,
33431
+ rightSideBarVisible: false
33432
+ });
33433
+ }
33363
33434
  const viewportWidth = window.innerWidth;
33364
33435
  const viewportDifferences = Object.entries(viewports).map(([key, value]) => ({
33365
33436
  key,
33366
33437
  diff: Math.abs(viewportWidth - value.width)
33367
33438
  })).sort((a, b) => a.diff > b.diff ? 1 : -1);
33368
33439
  const closestViewport = viewportDifferences[0].key;
33369
- clientUiState = __spreadProps(__spreadValues({}, window.matchMedia("(min-width: 638px)").matches ? {} : {
33370
- leftSideBarVisible: false,
33371
- rightSideBarVisible: false
33372
- }), {
33373
- viewports: __spreadProps(__spreadValues({}, initial.viewports), {
33374
- current: __spreadProps(__spreadValues({}, initial.viewports.current), {
33375
- height: ((_b = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b.height) || viewports[closestViewport].height || "auto",
33376
- width: ((_d = (_c = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _c.current) == null ? void 0 : _d.width) || viewports[closestViewport].width
33440
+ if (iframe.enabled) {
33441
+ clientUiState = {
33442
+ viewports: __spreadProps(__spreadValues({}, initial.viewports), {
33443
+ current: __spreadProps(__spreadValues({}, initial.viewports.current), {
33444
+ height: ((_b = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b.height) || viewports[closestViewport].height || "auto",
33445
+ width: ((_d = (_c = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _c.current) == null ? void 0 : _d.width) || viewports[closestViewport].width
33446
+ })
33377
33447
  })
33378
- })
33379
- });
33448
+ };
33449
+ }
33380
33450
  }
33381
33451
  return __spreadProps(__spreadValues({}, defaultAppState), {
33382
33452
  data: initialData,
@@ -33521,198 +33591,208 @@ function Puck({
33521
33591
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
33522
33592
  [loadedOverrides]
33523
33593
  );
33524
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "Puck", children: [
33525
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33526
- AppProvider,
33527
- {
33528
- value: {
33529
- state: appState,
33530
- dispatch,
33531
- config,
33532
- componentState,
33533
- resolveData,
33534
- plugins,
33535
- overrides: loadedOverrides,
33536
- history,
33537
- viewports
33538
- },
33539
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33540
- DragDropContext,
33541
- {
33542
- onDragUpdate: (update) => {
33543
- setDraggedItem(__spreadValues(__spreadValues({}, draggedItem), update));
33544
- onDragStartOrUpdate(update);
33545
- },
33546
- onBeforeDragStart: (start) => {
33547
- onDragStartOrUpdate(start);
33548
- setItemSelector(null);
33549
- dispatch({ type: "setUi", ui: { isDragging: true } });
33550
- },
33551
- onDragEnd: (droppedItem) => {
33552
- setDraggedItem(void 0);
33553
- dispatch({ type: "setUi", ui: { isDragging: false } });
33554
- if (!droppedItem.destination) {
33555
- return;
33556
- }
33557
- if (droppedItem.source.droppableId.startsWith("component-list") && droppedItem.destination) {
33558
- const [_, componentType] = droppedItem.draggableId.split("::");
33594
+ const [mounted, setMounted] = (0, import_react28.useState)(false);
33595
+ (0, import_react28.useEffect)(() => {
33596
+ setMounted(true);
33597
+ }, []);
33598
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "Puck", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33599
+ AppProvider,
33600
+ {
33601
+ value: {
33602
+ state: appState,
33603
+ dispatch,
33604
+ config,
33605
+ componentState,
33606
+ resolveData,
33607
+ plugins,
33608
+ overrides: loadedOverrides,
33609
+ history,
33610
+ viewports,
33611
+ iframe
33612
+ },
33613
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33614
+ DragDropContext,
33615
+ {
33616
+ onDragUpdate: (update) => {
33617
+ setDraggedItem(__spreadValues(__spreadValues({}, draggedItem), update));
33618
+ onDragStartOrUpdate(update);
33619
+ },
33620
+ onBeforeDragStart: (start) => {
33621
+ onDragStartOrUpdate(start);
33622
+ setItemSelector(null);
33623
+ dispatch({ type: "setUi", ui: { isDragging: true } });
33624
+ },
33625
+ onDragEnd: (droppedItem) => {
33626
+ setDraggedItem(void 0);
33627
+ dispatch({ type: "setUi", ui: { isDragging: false } });
33628
+ if (!droppedItem.destination) {
33629
+ return;
33630
+ }
33631
+ if (droppedItem.source.droppableId.startsWith("component-list") && droppedItem.destination) {
33632
+ const [_, componentType] = droppedItem.draggableId.split("::");
33633
+ dispatch({
33634
+ type: "insert",
33635
+ componentType: componentType || droppedItem.draggableId,
33636
+ destinationIndex: droppedItem.destination.index,
33637
+ destinationZone: droppedItem.destination.droppableId
33638
+ });
33639
+ setItemSelector({
33640
+ index: droppedItem.destination.index,
33641
+ zone: droppedItem.destination.droppableId
33642
+ });
33643
+ return;
33644
+ } else {
33645
+ const { source, destination } = droppedItem;
33646
+ if (source.droppableId === destination.droppableId) {
33559
33647
  dispatch({
33560
- type: "insert",
33561
- componentType: componentType || droppedItem.draggableId,
33562
- destinationIndex: droppedItem.destination.index,
33563
- destinationZone: droppedItem.destination.droppableId
33564
- });
33565
- setItemSelector({
33566
- index: droppedItem.destination.index,
33567
- zone: droppedItem.destination.droppableId
33648
+ type: "reorder",
33649
+ sourceIndex: source.index,
33650
+ destinationIndex: destination.index,
33651
+ destinationZone: destination.droppableId
33568
33652
  });
33569
- return;
33570
33653
  } else {
33571
- const { source, destination } = droppedItem;
33572
- if (source.droppableId === destination.droppableId) {
33573
- dispatch({
33574
- type: "reorder",
33575
- sourceIndex: source.index,
33576
- destinationIndex: destination.index,
33577
- destinationZone: destination.droppableId
33578
- });
33579
- } else {
33580
- dispatch({
33581
- type: "move",
33582
- sourceZone: source.droppableId,
33583
- sourceIndex: source.index,
33584
- destinationIndex: destination.index,
33585
- destinationZone: destination.droppableId
33586
- });
33587
- }
33588
- setItemSelector({
33589
- index: destination.index,
33590
- zone: destination.droppableId
33654
+ dispatch({
33655
+ type: "move",
33656
+ sourceZone: source.droppableId,
33657
+ sourceIndex: source.index,
33658
+ destinationIndex: destination.index,
33659
+ destinationZone: destination.droppableId
33591
33660
  });
33592
33661
  }
33593
- },
33594
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33595
- DropZoneProvider,
33596
- {
33597
- value: {
33598
- data,
33599
- itemSelector,
33600
- setItemSelector,
33601
- config,
33602
- dispatch,
33603
- draggedItem,
33604
- placeholderStyle,
33605
- mode: "edit",
33606
- areaId: "root"
33607
- },
33608
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
33609
- "div",
33610
- {
33611
- className: getClassName25({
33612
- leftSideBarVisible,
33613
- menuOpen,
33614
- rightSideBarVisible
33615
- }),
33616
- children: [
33617
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33618
- CustomHeader,
33619
- {
33620
- actions: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
33621
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CustomHeaderActions, {}),
33622
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33623
- Button,
33662
+ setItemSelector({
33663
+ index: destination.index,
33664
+ zone: destination.droppableId
33665
+ });
33666
+ }
33667
+ },
33668
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33669
+ DropZoneProvider,
33670
+ {
33671
+ value: {
33672
+ data,
33673
+ itemSelector,
33674
+ setItemSelector,
33675
+ config,
33676
+ dispatch,
33677
+ draggedItem,
33678
+ placeholderStyle,
33679
+ mode: "edit",
33680
+ areaId: "root"
33681
+ },
33682
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
33683
+ "div",
33684
+ {
33685
+ className: getClassName25({
33686
+ leftSideBarVisible,
33687
+ menuOpen,
33688
+ mounted,
33689
+ rightSideBarVisible
33690
+ }),
33691
+ children: [
33692
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33693
+ CustomHeader,
33694
+ {
33695
+ actions: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
33696
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CustomHeaderActions, {}),
33697
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33698
+ Button,
33699
+ {
33700
+ onClick: () => {
33701
+ onPublish && onPublish(data);
33702
+ },
33703
+ icon: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Globe, { size: "14px" }),
33704
+ children: "Publish"
33705
+ }
33706
+ )
33707
+ ] }),
33708
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("header", { className: getClassName25("header"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("headerInner"), children: [
33709
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("headerToggle"), children: [
33710
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33711
+ IconButton,
33624
33712
  {
33625
33713
  onClick: () => {
33626
- onPublish && onPublish(data);
33714
+ toggleSidebars("left");
33627
33715
  },
33628
- icon: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Globe, { size: "14px" }),
33629
- children: "Publish"
33716
+ title: "Toggle left sidebar",
33717
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(PanelLeft, { focusable: "false" })
33630
33718
  }
33631
- )
33719
+ ) }),
33720
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33721
+ IconButton,
33722
+ {
33723
+ onClick: () => {
33724
+ toggleSidebars("right");
33725
+ },
33726
+ title: "Toggle right sidebar",
33727
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(PanelRight, { focusable: "false" })
33728
+ }
33729
+ ) })
33632
33730
  ] }),
33633
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("header", { className: getClassName25("header"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("headerInner"), children: [
33634
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("headerToggle"), children: [
33635
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33636
- IconButton,
33637
- {
33638
- onClick: () => {
33639
- toggleSidebars("left");
33640
- },
33641
- title: "Toggle left sidebar",
33642
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(PanelLeft, { focusable: "false" })
33643
- }
33644
- ) }),
33645
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33646
- IconButton,
33647
- {
33648
- onClick: () => {
33649
- toggleSidebars("right");
33650
- },
33651
- title: "Toggle right sidebar",
33652
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(PanelRight, { focusable: "false" })
33653
- }
33654
- ) })
33655
- ] }),
33656
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Heading, { rank: 2, size: "xs", children: [
33657
- headerTitle || rootProps.title || "Page",
33658
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
33659
- " ",
33660
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("code", { className: getClassName25("headerPath"), children: headerPath })
33661
- ] })
33662
- ] }) }),
33663
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("headerTools"), children: [
33664
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33665
- IconButton,
33666
- {
33667
- onClick: () => {
33668
- return setMenuOpen(!menuOpen);
33669
- },
33670
- title: "Toggle menu bar",
33671
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { focusable: "false" })
33672
- }
33673
- ) }),
33674
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33675
- MenuBar,
33676
- {
33677
- appState,
33678
- data,
33679
- dispatch,
33680
- onPublish,
33681
- menuOpen,
33682
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CustomHeaderActions, {}),
33683
- setMenuOpen
33684
- }
33685
- )
33731
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Heading, { rank: 2, size: "xs", children: [
33732
+ headerTitle || rootProps.title || "Page",
33733
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
33734
+ " ",
33735
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("code", { className: getClassName25("headerPath"), children: headerPath })
33686
33736
  ] })
33687
- ] }) })
33688
- }
33689
- ),
33690
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("leftSideBar"), children: [
33691
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Components, {}) }),
33692
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Outline, {}) })
33693
- ] }),
33694
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Canvas, {}),
33695
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33696
- SidebarSection,
33697
- {
33698
- noPadding: true,
33699
- noBorderTop: true,
33700
- showBreadcrumbs: true,
33701
- title: selectedItem ? (_a = config.components[selectedItem.type]["label"]) != null ? _a : selectedItem.type : "Page",
33702
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Fields, {})
33703
- }
33704
- ) })
33705
- ]
33706
- }
33707
- ) })
33708
- }
33709
- )
33710
- }
33711
- )
33712
- }
33713
- ),
33714
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { id: "puck-portal-root" })
33715
- ] });
33737
+ ] }) }),
33738
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("headerTools"), children: [
33739
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33740
+ IconButton,
33741
+ {
33742
+ onClick: () => {
33743
+ return setMenuOpen(!menuOpen);
33744
+ },
33745
+ title: "Toggle menu bar",
33746
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { focusable: "false" })
33747
+ }
33748
+ ) }),
33749
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33750
+ MenuBar,
33751
+ {
33752
+ appState,
33753
+ data,
33754
+ dispatch,
33755
+ onPublish,
33756
+ menuOpen,
33757
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CustomHeaderActions, {}),
33758
+ setMenuOpen
33759
+ }
33760
+ )
33761
+ ] })
33762
+ ] }) })
33763
+ }
33764
+ ),
33765
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("leftSideBar"), children: [
33766
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Components, {}) }),
33767
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Outline, {}) })
33768
+ ] }),
33769
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Canvas, {}),
33770
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33771
+ SidebarSection,
33772
+ {
33773
+ noPadding: true,
33774
+ noBorderTop: true,
33775
+ showBreadcrumbs: true,
33776
+ title: selectedItem ? (_a = config.components[selectedItem.type]["label"]) != null ? _a : selectedItem.type : "Page",
33777
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Fields, {})
33778
+ }
33779
+ ) }),
33780
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
33781
+ "div",
33782
+ {
33783
+ id: "puck-portal-root",
33784
+ className: getClassName25("portal")
33785
+ }
33786
+ )
33787
+ ]
33788
+ }
33789
+ ) })
33790
+ }
33791
+ )
33792
+ }
33793
+ )
33794
+ }
33795
+ ) });
33716
33796
  }
33717
33797
  Puck.Components = Components;
33718
33798
  Puck.Fields = Fields;
@@ -33722,7 +33802,10 @@ Puck.Preview = Preview;
33722
33802
  // components/Render/index.tsx
33723
33803
  init_react_import();
33724
33804
  var import_jsx_runtime35 = require("react/jsx-runtime");
33725
- function Render({ config, data }) {
33805
+ function Render({
33806
+ config,
33807
+ data
33808
+ }) {
33726
33809
  var _a;
33727
33810
  const rootProps = data.root.props || data.root;
33728
33811
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
@@ -33801,37 +33884,51 @@ function transformProps(data, propTransforms) {
33801
33884
 
33802
33885
  // lib/resolve-all-data.ts
33803
33886
  init_react_import();
33804
- var resolveAllData = (data, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
33805
- const dynamicRoot = yield resolveRootData(data, config);
33806
- const { zones = {} } = data;
33807
- const zoneKeys = Object.keys(zones);
33808
- const resolvedZones = {};
33809
- for (let i = 0; i < zoneKeys.length; i++) {
33810
- const zoneKey = zoneKeys[i];
33811
- resolvedZones[zoneKey] = yield resolveAllComponentData(
33812
- zones[zoneKey],
33813
- config,
33814
- onResolveStart,
33815
- onResolveEnd
33816
- );
33817
- }
33818
- return __spreadProps(__spreadValues({}, data), {
33819
- root: dynamicRoot,
33820
- content: yield resolveAllComponentData(
33821
- data.content,
33822
- config,
33823
- onResolveStart,
33824
- onResolveEnd
33825
- ),
33826
- zones: resolvedZones
33887
+ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
33888
+ return __async(this, null, function* () {
33889
+ const dynamicRoot = yield resolveRootData(data, config);
33890
+ const { zones = {} } = data;
33891
+ const zoneKeys = Object.keys(zones);
33892
+ const resolvedZones = {};
33893
+ for (let i = 0; i < zoneKeys.length; i++) {
33894
+ const zoneKey = zoneKeys[i];
33895
+ resolvedZones[zoneKey] = yield resolveAllComponentData(
33896
+ zones[zoneKey],
33897
+ config,
33898
+ onResolveStart,
33899
+ onResolveEnd
33900
+ );
33901
+ }
33902
+ return __spreadProps(__spreadValues({}, data), {
33903
+ root: dynamicRoot,
33904
+ content: yield resolveAllComponentData(
33905
+ data.content,
33906
+ config,
33907
+ onResolveStart,
33908
+ onResolveEnd
33909
+ ),
33910
+ zones: resolvedZones
33911
+ });
33827
33912
  });
33828
- });
33913
+ }
33829
33914
 
33830
33915
  // lib/use-puck.ts
33831
33916
  init_react_import();
33832
33917
  var usePuck = () => {
33833
- const { state: appState, config, history, dispatch } = useAppContext();
33834
- return { appState, config, dispatch, history };
33918
+ const {
33919
+ state: appState,
33920
+ config,
33921
+ history,
33922
+ dispatch,
33923
+ selectedItem
33924
+ } = useAppContext();
33925
+ return {
33926
+ appState,
33927
+ config,
33928
+ dispatch,
33929
+ history,
33930
+ selectedItem: selectedItem || null
33931
+ };
33835
33932
  };
33836
33933
  // Annotate the CommonJS export names for ESM import in node:
33837
33934
  0 && (module.exports = {