@puckeditor/core 0.21.1 → 0.21.2-canary.0bbe7fec

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 (41) hide show
  1. package/README.md +1 -1
  2. package/dist/{Editor-NK3TZSR6.mjs → Editor-G7Y32A5X.mjs} +9 -9
  3. package/dist/{actions-BkBoKAc5.d.mts → actions-C3e2nJ9v.d.mts} +2 -2
  4. package/dist/{actions-BkBoKAc5.d.ts → actions-C3e2nJ9v.d.ts} +2 -2
  5. package/dist/{chunk-PMXRXC2B.mjs → chunk-754HNMU2.mjs} +18 -11
  6. package/dist/{chunk-MSZPUXZP.mjs → chunk-7TULKVSG.mjs} +1 -1
  7. package/dist/{chunk-MDUBGHWF.mjs → chunk-BOKX3EBR.mjs} +3 -12
  8. package/dist/{chunk-EBISZQTK.mjs → chunk-DVS6IJRQ.mjs} +3794 -3733
  9. package/dist/{chunk-TNORMHZU.mjs → chunk-FOGDNETJ.mjs} +4 -4
  10. package/dist/{chunk-5V242HXR.mjs → chunk-MFEVRMA4.mjs} +7 -7
  11. package/dist/{chunk-SKJTJUWU.mjs → chunk-NBH4DF6Y.mjs} +1 -1
  12. package/dist/{chunk-RHVK562Z.mjs → chunk-OLGXKSQT.mjs} +3 -3
  13. package/dist/{chunk-KOUWDQ4Q.mjs → chunk-OYCFPEDG.mjs} +1 -1
  14. package/dist/{chunk-UMTU6EA7.mjs → chunk-RSOD4APZ.mjs} +20 -10
  15. package/dist/{chunk-37HTE4KO.mjs → chunk-YLLE6KXH.mjs} +1 -1
  16. package/dist/{full-KLPRWVS4.mjs → full-AG4GMB6M.mjs} +8 -8
  17. package/dist/{index-lt1zf5WR.d.ts → index-DAXMlG_V.d.mts} +2 -1
  18. package/dist/{index-bqD1SEOb.d.mts → index-s4HBwSMe.d.ts} +2 -1
  19. package/dist/index.d.mts +4 -4
  20. package/dist/index.d.ts +4 -4
  21. package/dist/index.js +228 -156
  22. package/dist/index.mjs +17 -12
  23. package/dist/internal.d.mts +2 -2
  24. package/dist/internal.d.ts +2 -2
  25. package/dist/internal.js +16 -11
  26. package/dist/internal.mjs +2 -2
  27. package/dist/{loaded-SJJ63OY2.mjs → loaded-JCBZ5OYD.mjs} +5 -5
  28. package/dist/{loaded-DIHUQBWF.mjs → loaded-VT5I2E7C.mjs} +5 -5
  29. package/dist/{loaded-362ACKSQ.mjs → loaded-YDSVEZZY.mjs} +5 -5
  30. package/dist/no-external.css +143 -147
  31. package/dist/no-external.d.mts +3 -3
  32. package/dist/no-external.d.ts +3 -3
  33. package/dist/no-external.js +226 -157
  34. package/dist/no-external.mjs +11 -11
  35. package/dist/rsc.d.mts +2 -2
  36. package/dist/rsc.d.ts +2 -2
  37. package/dist/rsc.js +50 -35
  38. package/dist/rsc.mjs +45 -27
  39. package/dist/{walk-tree-CRRDqx6_.d.mts → walk-tree-BJoNgZ0l.d.mts} +1 -1
  40. package/dist/{walk-tree-CS7sEpfG.d.ts → walk-tree-f8Yzs5o3.d.ts} +1 -1
  41. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1651,6 +1651,21 @@ var init_flatten_node = __esm({
1651
1651
  }
1652
1652
  });
1653
1653
 
1654
+ // lib/data/to-component.ts
1655
+ var toComponent;
1656
+ var init_to_component = __esm({
1657
+ "lib/data/to-component.ts"() {
1658
+ "use strict";
1659
+ init_react_import();
1660
+ toComponent = (item) => {
1661
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
1662
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
1663
+ type: "root"
1664
+ });
1665
+ };
1666
+ }
1667
+ });
1668
+
1654
1669
  // lib/data/walk-app-state.ts
1655
1670
  function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
1656
1671
  var _a;
@@ -1714,7 +1729,7 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
1714
1729
  id
1715
1730
  });
1716
1731
  processRelatedZones(item, id, path);
1717
- const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
1732
+ const newItem = __spreadProps(__spreadValues({}, mappedItem), { props: newProps });
1718
1733
  const thisZoneCompound = path[path.length - 1];
1719
1734
  const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
1720
1735
  newNodeIndex[id] = {
@@ -1754,17 +1769,14 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
1754
1769
  );
1755
1770
  newZones[zoneCompound] = newContent2;
1756
1771
  }, newZones);
1757
- const processedRoot = processItem(
1758
- {
1759
- type: "root",
1760
- props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
1761
- },
1762
- [],
1763
- -1
1764
- );
1765
- const root = __spreadProps(__spreadValues({}, state.data.root), {
1766
- props: processedRoot.props
1772
+ let rootAsComponent = toComponent({
1773
+ props: __spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root)
1767
1774
  });
1775
+ if (state.data.root.readOnly) {
1776
+ rootAsComponent.readOnly = state.data.root.readOnly;
1777
+ }
1778
+ const processedRoot = processItem(rootAsComponent, [], -1);
1779
+ const root = __spreadValues(__spreadValues({}, state.data.root), processedRoot);
1768
1780
  return __spreadProps(__spreadValues({}, state), {
1769
1781
  data: {
1770
1782
  root,
@@ -1785,6 +1797,7 @@ var init_walk_app_state = __esm({
1785
1797
  init_root_droppable_id();
1786
1798
  init_map_fields();
1787
1799
  init_flatten_node();
1800
+ init_to_component();
1788
1801
  }
1789
1802
  });
1790
1803
 
@@ -2566,7 +2579,8 @@ var init_use_hotkey = __esm({
2566
2579
  KeyY: "y",
2567
2580
  KeyZ: "z",
2568
2581
  Delete: "delete",
2569
- Backspace: "backspace"
2582
+ Backspace: "backspace",
2583
+ AltRight: "altRight"
2570
2584
  };
2571
2585
  useHotkeyStore = (0, import_zustand3.create)()(
2572
2586
  (0, import_middleware2.subscribeWithSelector)((set) => ({
@@ -2579,6 +2593,10 @@ var init_use_hotkey = __esm({
2579
2593
  );
2580
2594
  monitorHotkeys = (doc) => {
2581
2595
  const onKeyDown = (e) => {
2596
+ if (e.getModifierState("AltGraph")) {
2597
+ useHotkeyStore.getState().hold("altRight");
2598
+ return;
2599
+ }
2582
2600
  const key = keyCodeMap[e.code];
2583
2601
  if (key) {
2584
2602
  useHotkeyStore.getState().hold(key);
@@ -2602,6 +2620,10 @@ var init_use_hotkey = __esm({
2602
2620
  }
2603
2621
  };
2604
2622
  const onKeyUp = (e) => {
2623
+ if (!e.getModifierState("AltGraph") && e.code === "ControlRight") {
2624
+ useHotkeyStore.getState().release("altRight");
2625
+ return;
2626
+ }
2605
2627
  const key = keyCodeMap[e.code];
2606
2628
  if (key) {
2607
2629
  if (key === "meta") {
@@ -2677,12 +2699,12 @@ function useRegisterHistorySlice(appStore, {
2677
2699
  const forward = () => {
2678
2700
  appStore.getState().history.forward();
2679
2701
  };
2680
- useHotkey({ meta: true, z: true }, back);
2681
- useHotkey({ meta: true, shift: true, z: true }, forward);
2682
- useHotkey({ meta: true, y: true }, forward);
2683
- useHotkey({ ctrl: true, z: true }, back);
2684
- useHotkey({ ctrl: true, shift: true, z: true }, forward);
2685
- useHotkey({ ctrl: true, y: true }, forward);
2702
+ useHotkey({ altRight: false, meta: true, z: true }, back);
2703
+ useHotkey({ altRight: false, meta: true, shift: true, z: true }, forward);
2704
+ useHotkey({ altRight: false, meta: true, y: true }, forward);
2705
+ useHotkey({ altRight: false, ctrl: true, z: true }, back);
2706
+ useHotkey({ altRight: false, ctrl: true, shift: true, z: true }, forward);
2707
+ useHotkey({ altRight: false, ctrl: true, y: true }, forward);
2686
2708
  }
2687
2709
  var import_react7, EMPTY_HISTORY_INDEX, tidyState, createHistorySlice;
2688
2710
  var init_history = __esm({
@@ -3110,21 +3132,6 @@ var init_fields = __esm({
3110
3132
  }
3111
3133
  });
3112
3134
 
3113
- // lib/data/to-component.ts
3114
- var toComponent;
3115
- var init_to_component = __esm({
3116
- "lib/data/to-component.ts"() {
3117
- "use strict";
3118
- init_react_import();
3119
- toComponent = (item) => {
3120
- return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
3121
- props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
3122
- type: "root"
3123
- });
3124
- };
3125
- }
3126
- });
3127
-
3128
3135
  // lib/resolve-component-data.ts
3129
3136
  var import_fast_equals2, cache, resolveComponentData;
3130
3137
  var init_resolve_component_data = __esm({
@@ -3320,6 +3327,7 @@ var init_store = __esm({
3320
3327
  },
3321
3328
  status: "LOADING",
3322
3329
  iframe: {},
3330
+ _experimentalFullScreenCanvas: false,
3323
3331
  metadata: {},
3324
3332
  fieldTransforms: {}
3325
3333
  }, initialAppStore), {
@@ -6298,6 +6306,40 @@ var SubFieldInternal = ({
6298
6306
  };
6299
6307
  var SubField = (0, import_react16.memo)(SubFieldInternal);
6300
6308
 
6309
+ // lib/data/set-deep.ts
6310
+ init_react_import();
6311
+ function setDeep(node, path, newVal) {
6312
+ const parts = path.split(".");
6313
+ const newNode = __spreadValues({}, node);
6314
+ let cur = newNode;
6315
+ for (let i = 0; i < parts.length; i++) {
6316
+ const [prop, idxStr] = parts[i].replace("]", "").split("[");
6317
+ const isLast = i === parts.length - 1;
6318
+ if (idxStr !== void 0) {
6319
+ if (!Array.isArray(cur[prop])) {
6320
+ cur[prop] = [];
6321
+ }
6322
+ const idx = Number(idxStr);
6323
+ if (isLast) {
6324
+ cur[prop][idx] = newVal;
6325
+ continue;
6326
+ }
6327
+ if (cur[prop][idx] === void 0) cur[prop][idx] = {};
6328
+ cur = cur[prop][idx];
6329
+ continue;
6330
+ }
6331
+ if (isLast) {
6332
+ cur[prop] = newVal;
6333
+ continue;
6334
+ }
6335
+ if (cur[prop] === void 0) {
6336
+ cur[prop] = {};
6337
+ }
6338
+ cur = cur[prop];
6339
+ }
6340
+ return __spreadValues(__spreadValues({}, node), newNode);
6341
+ }
6342
+
6301
6343
  // components/AutoField/fields/ArrayField/index.tsx
6302
6344
  var import_jsx_runtime9 = require("react/jsx-runtime");
6303
6345
  var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
@@ -6365,9 +6407,10 @@ var ArrayFieldItemInternal = ({
6365
6407
  {
6366
6408
  ref: handleRef,
6367
6409
  onClick: (e) => {
6368
- if (isDragging || !hasVisibleFields) return;
6410
+ if (isDragging) return;
6369
6411
  e.preventDefault();
6370
6412
  e.stopPropagation();
6413
+ if (!hasVisibleFields) return;
6371
6414
  onToggleExpand(id, isExpanded);
6372
6415
  },
6373
6416
  className: getClassNameItem("summary"),
@@ -6731,10 +6774,13 @@ var useLocalValue = (path, onChange) => {
6731
6774
  const value = useDeepField(path);
6732
6775
  const isFocused = useIsFocused(path);
6733
6776
  const [localValue, setLocalValue] = (0, import_react18.useState)(value == null ? void 0 : value.toString());
6734
- const onChangeLocal = (0, import_react18.useCallback)((val) => {
6735
- setLocalValue(val);
6736
- onChange(val);
6737
- }, []);
6777
+ const onChangeLocal = (0, import_react18.useCallback)(
6778
+ (val) => {
6779
+ setLocalValue(val);
6780
+ onChange(val);
6781
+ },
6782
+ [onChange]
6783
+ );
6738
6784
  (0, import_react18.useEffect)(() => {
6739
6785
  if (!isFocused) {
6740
6786
  setLocalValue(value);
@@ -7927,21 +7973,6 @@ var import_shallow4 = require("zustand/react/shallow");
7927
7973
  init_get_item();
7928
7974
  var import_sortable2 = require("@dnd-kit/react/sortable");
7929
7975
 
7930
- // lib/accumulate-transform.ts
7931
- init_react_import();
7932
- function accumulateTransform(el) {
7933
- let matrix = new DOMMatrixReadOnly();
7934
- let n = el.parentElement;
7935
- while (n && n !== document.documentElement) {
7936
- const t = getComputedStyle(n).transform;
7937
- if (t && t !== "none") {
7938
- matrix = new DOMMatrixReadOnly(t).multiply(matrix);
7939
- }
7940
- n = n.parentElement;
7941
- }
7942
- return { scaleX: matrix.a, scaleY: matrix.d };
7943
- }
7944
-
7945
7976
  // lib/dnd/use-on-drag-finished.ts
7946
7977
  init_react_import();
7947
7978
  var import_react50 = require("react");
@@ -7980,6 +8011,7 @@ init_RichTextMenu();
7980
8011
  var import_jsx_runtime56 = require("react/jsx-runtime");
7981
8012
  var getClassName21 = get_class_name_factory_default("DraggableComponent", styles_module_default15);
7982
8013
  var DEBUG2 = false;
8014
+ var MEASURE_EVERY_MS = 100;
7983
8015
  var space = 8;
7984
8016
  var actionsOverlayTop = space * 6.5;
7985
8017
  var actionsTop = -(actionsOverlayTop - 8);
@@ -8019,9 +8051,13 @@ var DraggableComponent = ({
8019
8051
  return ((_a = s.selectedItem) == null ? void 0 : _a.props.id) === id ? s.zoomConfig.zoom : 1;
8020
8052
  }
8021
8053
  );
8054
+ const _experimentalFullScreenCanvas = useAppStore(
8055
+ (s) => s._experimentalFullScreenCanvas
8056
+ );
8022
8057
  const overrides = useAppStore((s) => s.overrides);
8023
8058
  const dispatch = useAppStore((s) => s.dispatch);
8024
8059
  const iframe = useAppStore((s) => s.iframe);
8060
+ const lastMeasureRef = (0, import_react51.useRef)(0);
8025
8061
  const ctx = (0, import_react51.useContext)(dropZoneContext);
8026
8062
  const [localZones, setLocalZones] = (0, import_react51.useState)({});
8027
8063
  const registerLocalZone = (0, import_react51.useCallback)(
@@ -8126,45 +8162,71 @@ var DraggableComponent = ({
8126
8162
  setPortalEl(
8127
8163
  iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
8128
8164
  );
8129
- }, [iframe.enabled, ref.current]);
8165
+ }, [iframe.enabled]);
8130
8166
  const getStyle = (0, import_react51.useCallback)(() => {
8131
- var _a, _b, _c;
8167
+ var _a, _b;
8132
8168
  if (!ref.current) return;
8133
- const rect = ref.current.getBoundingClientRect();
8134
- const deepScrollPosition = getDeepScrollPosition(ref.current);
8135
- const portalContainerEl = iframe.enabled ? null : (_a = ref.current) == null ? void 0 : _a.closest("[data-puck-preview]");
8169
+ const el = ref.current;
8170
+ const rect = el.getBoundingClientRect();
8171
+ const portalContainerEl = iframe.enabled ? null : el.closest("[data-puck-preview]");
8172
+ const targetIsFixed = (() => {
8173
+ let node = el;
8174
+ while (node && node !== document.documentElement) {
8175
+ if (getComputedStyle(node).position === "fixed") {
8176
+ return true;
8177
+ }
8178
+ node = node.parentElement;
8179
+ }
8180
+ return false;
8181
+ })();
8136
8182
  const portalContainerRect = portalContainerEl == null ? void 0 : portalContainerEl.getBoundingClientRect();
8137
8183
  const portalScroll = portalContainerEl ? getDeepScrollPosition(portalContainerEl) : { x: 0, y: 0 };
8138
- const scroll = {
8139
- x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
8140
- y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
8141
- };
8142
- const untransformed = {
8143
- height: ref.current.offsetHeight,
8144
- width: ref.current.offsetWidth
8184
+ const deepScrollPosition = targetIsFixed ? { x: 0, y: 0 } : getDeepScrollPosition(el);
8185
+ const scroll = targetIsFixed ? { x: 0, y: 0 } : {
8186
+ x: deepScrollPosition.x - portalScroll.x - ((_a = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _a : 0),
8187
+ y: deepScrollPosition.y - portalScroll.y - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _b : 0)
8145
8188
  };
8146
- const transform = accumulateTransform(ref.current);
8147
8189
  const style2 = {
8148
- left: `${(rect.left + scroll.x) / transform.scaleX}px`,
8149
- top: `${(rect.top + scroll.y) / transform.scaleY}px`,
8150
- height: `${untransformed.height}px`,
8151
- width: `${untransformed.width}px`
8190
+ left: `${rect.left + scroll.x}px`,
8191
+ top: `${rect.top + scroll.y}px`,
8192
+ height: `${rect.height}px`,
8193
+ width: `${rect.width}px`,
8194
+ position: targetIsFixed ? "fixed" : void 0
8152
8195
  };
8153
8196
  return style2;
8154
- }, [ref.current]);
8197
+ }, [iframe.enabled]);
8155
8198
  const [style, setStyle] = (0, import_react51.useState)();
8199
+ const lastRectRef = (0, import_react51.useRef)(null);
8200
+ const syncRafRef = (0, import_react51.useRef)(null);
8156
8201
  const sync = (0, import_react51.useCallback)(() => {
8157
8202
  setStyle(getStyle());
8158
- }, [ref.current, iframe]);
8203
+ }, [getStyle]);
8204
+ const scheduleSync = (0, import_react51.useCallback)(() => {
8205
+ if (syncRafRef.current != null) return;
8206
+ syncRafRef.current = requestAnimationFrame(() => {
8207
+ syncRafRef.current = null;
8208
+ sync();
8209
+ });
8210
+ }, [sync]);
8211
+ (0, import_react51.useEffect)(() => {
8212
+ return () => {
8213
+ if (syncRafRef.current != null) {
8214
+ cancelAnimationFrame(syncRafRef.current);
8215
+ syncRafRef.current = null;
8216
+ }
8217
+ };
8218
+ }, []);
8159
8219
  (0, import_react51.useEffect)(() => {
8160
8220
  if (ref.current) {
8161
- const observer = new ResizeObserver(sync);
8221
+ const observer = new ResizeObserver(() => {
8222
+ scheduleSync();
8223
+ });
8162
8224
  observer.observe(ref.current);
8163
8225
  return () => {
8164
8226
  observer.disconnect();
8165
8227
  };
8166
8228
  }
8167
- }, [ref.current]);
8229
+ }, [scheduleSync]);
8168
8230
  const registerNode = useAppStore((s) => s.nodes.registerNode);
8169
8231
  const hideOverlay = (0, import_react51.useCallback)(() => {
8170
8232
  setIsVisible(false);
@@ -8203,11 +8265,11 @@ var DraggableComponent = ({
8203
8265
  if (!el.closest("[data-puck-overlay-portal]")) {
8204
8266
  e.stopPropagation();
8205
8267
  }
8206
- if (isSelected) {
8268
+ if (_experimentalFullScreenCanvas) {
8207
8269
  dispatch({
8208
8270
  type: "setUi",
8209
8271
  ui: {
8210
- itemSelector: null
8272
+ itemSelector: isSelected ? null : { index, zone: zoneCompound }
8211
8273
  }
8212
8274
  });
8213
8275
  } else {
@@ -8219,7 +8281,7 @@ var DraggableComponent = ({
8219
8281
  });
8220
8282
  }
8221
8283
  },
8222
- [index, zoneCompound, id, isSelected]
8284
+ [index, zoneCompound, id, isSelected, _experimentalFullScreenCanvas]
8223
8285
  );
8224
8286
  const appStore = useAppStoreApi();
8225
8287
  const onSelectParent = (0, import_react51.useCallback)(() => {
@@ -8313,7 +8375,7 @@ var DraggableComponent = ({
8313
8375
  (0, import_react51.useEffect)(() => {
8314
8376
  startTransition(() => {
8315
8377
  if (hover || indicativeHover || isSelected) {
8316
- sync();
8378
+ scheduleSync();
8317
8379
  setIsVisible(true);
8318
8380
  setThisWasDragging(false);
8319
8381
  } else {
@@ -8340,6 +8402,43 @@ var DraggableComponent = ({
8340
8402
  (0, import_react51.useEffect)(() => {
8341
8403
  if (thisWasDragging) return onDragFinished();
8342
8404
  }, [thisWasDragging, onDragFinished]);
8405
+ (0, import_react51.useEffect)(() => {
8406
+ if (!dragFinished || !(isSelected || thisIsDragging)) return;
8407
+ const el = ref.current;
8408
+ if (!el) return;
8409
+ const doc = el.ownerDocument;
8410
+ const view = doc.defaultView;
8411
+ if (!view) return;
8412
+ lastMeasureRef.current = 0;
8413
+ scheduleSync();
8414
+ const onScroll = () => scheduleSync();
8415
+ const onResize = () => scheduleSync();
8416
+ doc.addEventListener("scroll", onScroll, true);
8417
+ view.addEventListener("resize", onResize);
8418
+ let frame = 0;
8419
+ const tick = (t) => {
8420
+ if (t - lastMeasureRef.current >= MEASURE_EVERY_MS) {
8421
+ lastMeasureRef.current = t;
8422
+ const node = ref.current;
8423
+ if (node) {
8424
+ const rect = node.getBoundingClientRect();
8425
+ const prev = lastRectRef.current;
8426
+ const changed = !prev || Math.abs(rect.x - prev.x) > 0.5 || Math.abs(rect.y - prev.y) > 0.5 || Math.abs(rect.width - prev.width) > 0.5 || Math.abs(rect.height - prev.height) > 0.5;
8427
+ if (changed) {
8428
+ lastRectRef.current = rect;
8429
+ scheduleSync();
8430
+ }
8431
+ }
8432
+ }
8433
+ frame = requestAnimationFrame(tick);
8434
+ };
8435
+ frame = requestAnimationFrame(tick);
8436
+ return () => {
8437
+ doc.removeEventListener("scroll", onScroll, true);
8438
+ view.removeEventListener("resize", onResize);
8439
+ cancelAnimationFrame(frame);
8440
+ };
8441
+ }, [dragFinished, isSelected, thisIsDragging, scheduleSync]);
8343
8442
  const syncActionsPosition = (0, import_react51.useCallback)(
8344
8443
  (el) => {
8345
8444
  if (el) {
@@ -9115,40 +9214,6 @@ var styles_module_default17 = { "InlineTextField": "_InlineTextField_104qp_1" };
9115
9214
  // components/InlineTextField/index.tsx
9116
9215
  init_lib();
9117
9216
 
9118
- // lib/data/set-deep.ts
9119
- init_react_import();
9120
- function setDeep(node, path, newVal) {
9121
- const parts = path.split(".");
9122
- const newNode = __spreadValues({}, node);
9123
- let cur = newNode;
9124
- for (let i = 0; i < parts.length; i++) {
9125
- const [prop, idxStr] = parts[i].replace("]", "").split("[");
9126
- const isLast = i === parts.length - 1;
9127
- if (idxStr !== void 0) {
9128
- if (!Array.isArray(cur[prop])) {
9129
- cur[prop] = [];
9130
- }
9131
- const idx = Number(idxStr);
9132
- if (isLast) {
9133
- cur[prop][idx] = newVal;
9134
- continue;
9135
- }
9136
- if (cur[prop][idx] === void 0) cur[prop][idx] = {};
9137
- cur = cur[prop][idx];
9138
- continue;
9139
- }
9140
- if (isLast) {
9141
- cur[prop] = newVal;
9142
- continue;
9143
- }
9144
- if (cur[prop] === void 0) {
9145
- cur[prop] = {};
9146
- }
9147
- cur = cur[prop];
9148
- }
9149
- return __spreadValues(__spreadValues({}, node), newNode);
9150
- }
9151
-
9152
9217
  // lib/get-selector-for-id.ts
9153
9218
  init_react_import();
9154
9219
  var getSelectorForId = (state, id) => {
@@ -10500,24 +10565,9 @@ var DragDropContextClient = ({
10500
10565
  zoneStore.setState({ draggedItem: null });
10501
10566
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
10502
10567
  zoneStore.setState({ previewIndex: {} });
10503
- if (thisPreview) {
10504
- zoneStore.setState({ previewIndex: {} });
10505
- if (thisPreview.type === "insert") {
10506
- insertComponent(
10507
- thisPreview.componentType,
10508
- thisPreview.zone,
10509
- thisPreview.index,
10510
- appStore
10511
- );
10512
- } else if (initialSelector.current) {
10513
- moveComponent(
10514
- thisPreview.props.id,
10515
- initialSelector.current,
10516
- thisPreview,
10517
- appStore
10518
- );
10519
- }
10520
- }
10568
+ (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
10569
+ fn(event, manager);
10570
+ });
10521
10571
  dispatch({
10522
10572
  type: "setUi",
10523
10573
  ui: {
@@ -10525,9 +10575,6 @@ var DragDropContextClient = ({
10525
10575
  isDragging: false
10526
10576
  }
10527
10577
  });
10528
- (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
10529
- fn(event, manager);
10530
- });
10531
10578
  return;
10532
10579
  }
10533
10580
  if (thisPreview) {
@@ -10540,14 +10587,12 @@ var DragDropContextClient = ({
10540
10587
  appStore
10541
10588
  );
10542
10589
  } else if (initialSelector.current) {
10543
- dispatch({
10544
- type: "move",
10545
- sourceIndex: initialSelector.current.index,
10546
- sourceZone: initialSelector.current.zone,
10547
- destinationIndex: thisPreview.index,
10548
- destinationZone: thisPreview.zone,
10549
- recordHistory: false
10550
- });
10590
+ moveComponent(
10591
+ thisPreview.props.id,
10592
+ initialSelector.current,
10593
+ thisPreview,
10594
+ appStore
10595
+ );
10551
10596
  }
10552
10597
  }
10553
10598
  dispatch({
@@ -10556,7 +10601,7 @@ var DragDropContextClient = ({
10556
10601
  itemSelector: { index, zone },
10557
10602
  isDragging: false
10558
10603
  },
10559
- recordHistory: true
10604
+ recordHistory: false
10560
10605
  });
10561
10606
  (_b2 = dragListeners.dragend) == null ? void 0 : _b2.forEach((fn) => {
10562
10607
  fn(event, manager);
@@ -11403,20 +11448,28 @@ var CopyHostStyles = ({
11403
11448
  filtered.forEach((mirror) => {
11404
11449
  mirror.onload = () => {
11405
11450
  stylesLoaded = stylesLoaded + 1;
11406
- if (stylesLoaded >= elements.length) {
11451
+ if (stylesLoaded >= filtered.length) {
11407
11452
  onStylesLoaded();
11408
11453
  }
11409
11454
  };
11410
11455
  mirror.onerror = () => {
11411
11456
  console.warn(`AutoFrame couldn't load a stylesheet`);
11412
11457
  stylesLoaded = stylesLoaded + 1;
11413
- if (stylesLoaded >= elements.length) {
11458
+ if (stylesLoaded >= filtered.length) {
11414
11459
  onStylesLoaded();
11415
11460
  }
11416
11461
  };
11417
11462
  });
11418
11463
  doc.head.innerHTML = "";
11419
11464
  doc.head.append(...filtered);
11465
+ filtered.forEach((mirror) => {
11466
+ if (mirror.nodeName === "STYLE") {
11467
+ stylesLoaded = stylesLoaded + 1;
11468
+ }
11469
+ });
11470
+ if (stylesLoaded >= filtered.length) {
11471
+ onStylesLoaded();
11472
+ }
11420
11473
  observer.observe(parentDocument.head, { childList: true, subtree: true });
11421
11474
  filtered.forEach((el) => {
11422
11475
  const elHash = (0, import_object_hash.default)(el.outerHTML);
@@ -12773,12 +12826,10 @@ var getClassName36 = get_class_name_factory_default("PuckCanvas", styles_module_
12773
12826
  var ZOOM_ON_CHANGE = true;
12774
12827
  var TRANSITION_DURATION = 150;
12775
12828
  var Canvas = () => {
12829
+ var _a;
12776
12830
  const { frameRef } = useCanvasFrame();
12777
12831
  const resetAutoZoom = useResetAutoZoom(frameRef);
12778
- const {
12779
- _experimentalFullScreenCanvas,
12780
- viewports: viewportOptions = defaultViewports
12781
- } = usePropsContext();
12832
+ const { viewports: viewportOptions = defaultViewports, ui: uiProp } = usePropsContext();
12782
12833
  const {
12783
12834
  dispatch,
12784
12835
  overrides,
@@ -12786,7 +12837,8 @@ var Canvas = () => {
12786
12837
  zoomConfig,
12787
12838
  setZoomConfig,
12788
12839
  status,
12789
- iframe
12840
+ iframe,
12841
+ _experimentalFullScreenCanvas
12790
12842
  } = useAppStore(
12791
12843
  (0, import_shallow10.useShallow)((s) => ({
12792
12844
  dispatch: s.dispatch,
@@ -12795,7 +12847,8 @@ var Canvas = () => {
12795
12847
  zoomConfig: s.zoomConfig,
12796
12848
  setZoomConfig: s.setZoomConfig,
12797
12849
  status: s.status,
12798
- iframe: s.iframe
12850
+ iframe: s.iframe,
12851
+ _experimentalFullScreenCanvas: s._experimentalFullScreenCanvas
12799
12852
  }))
12800
12853
  );
12801
12854
  const {
@@ -12874,10 +12927,11 @@ var Canvas = () => {
12874
12927
  }, []);
12875
12928
  const appStoreApi = useAppStoreApi();
12876
12929
  (0, import_react88.useEffect)(() => {
12877
- var _a;
12930
+ var _a2, _b;
12878
12931
  if (typeof window === "undefined") return;
12932
+ if ((_a2 = uiProp == null ? void 0 : uiProp.viewports) == null ? void 0 : _a2.current) return;
12879
12933
  const viewportWidth = window.innerWidth;
12880
- const frameWidth = (_a = frameRef.current) == null ? void 0 : _a.getBoundingClientRect().width;
12934
+ const frameWidth = (_b = frameRef.current) == null ? void 0 : _b.getBoundingClientRect().width;
12881
12935
  if (!viewportWidth) return;
12882
12936
  if (!frameWidth) return;
12883
12937
  if (viewportOptions.length === 0) return;
@@ -12916,7 +12970,13 @@ var Canvas = () => {
12916
12970
  }
12917
12971
  appStoreApi.setState(__spreadProps(__spreadValues({}, appState), { history }));
12918
12972
  }
12919
- }, [viewportOptions, frameRef.current, iframe, appStoreApi]);
12973
+ }, [
12974
+ viewportOptions,
12975
+ frameRef.current,
12976
+ iframe,
12977
+ appStoreApi,
12978
+ (_a = uiProp == null ? void 0 : uiProp.viewports) == null ? void 0 : _a.current
12979
+ ]);
12920
12980
  return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
12921
12981
  "div",
12922
12982
  {
@@ -12931,7 +12991,7 @@ var Canvas = () => {
12931
12991
  dispatch({
12932
12992
  type: "setUi",
12933
12993
  ui: { itemSelector: null },
12934
- recordHistory: true
12994
+ recordHistory: false
12935
12995
  });
12936
12996
  }
12937
12997
  },
@@ -13669,7 +13729,8 @@ function PuckProvider({ children }) {
13669
13729
  initialHistory: _initialHistory,
13670
13730
  metadata,
13671
13731
  onAction,
13672
- fieldTransforms
13732
+ fieldTransforms,
13733
+ _experimentalFullScreenCanvas
13673
13734
  } = usePropsContext();
13674
13735
  const iframe = (0, import_react93.useMemo)(
13675
13736
  () => __spreadValues({
@@ -13762,6 +13823,7 @@ function PuckProvider({ children }) {
13762
13823
  overrides: loadedOverrides,
13763
13824
  viewports,
13764
13825
  iframe,
13826
+ _experimentalFullScreenCanvas: !!_experimentalFullScreenCanvas,
13765
13827
  onAction,
13766
13828
  metadata,
13767
13829
  fieldTransforms: loadedFieldTransforms
@@ -13775,6 +13837,7 @@ function PuckProvider({ children }) {
13775
13837
  loadedOverrides,
13776
13838
  viewports,
13777
13839
  iframe,
13840
+ _experimentalFullScreenCanvas,
13778
13841
  onAction,
13779
13842
  metadata,
13780
13843
  loadedFieldTransforms
@@ -13791,7 +13854,16 @@ function PuckProvider({ children }) {
13791
13854
  (0, import_react93.useEffect)(() => {
13792
13855
  const state = appStore.getState().state;
13793
13856
  appStore.setState(__spreadValues({}, generateAppStore(state)));
13794
- }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
13857
+ }, [
13858
+ config,
13859
+ plugins,
13860
+ loadedOverrides,
13861
+ viewports,
13862
+ iframe,
13863
+ _experimentalFullScreenCanvas,
13864
+ onAction,
13865
+ metadata
13866
+ ]);
13795
13867
  useRegisterHistorySlice(appStore, {
13796
13868
  histories: blendedHistories,
13797
13869
  index: initialHistoryIndex,