@measured/puck 0.21.0-canary.6dae6cb7 → 0.21.0-canary.7dca3a5a

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
@@ -153,6 +153,42 @@ var require_classnames = __commonJS({
153
153
  }
154
154
  });
155
155
 
156
+ // ../../node_modules/fast-deep-equal/index.js
157
+ var require_fast_deep_equal = __commonJS({
158
+ "../../node_modules/fast-deep-equal/index.js"(exports2, module2) {
159
+ "use strict";
160
+ init_react_import();
161
+ module2.exports = function equal(a, b) {
162
+ if (a === b) return true;
163
+ if (a && b && typeof a == "object" && typeof b == "object") {
164
+ if (a.constructor !== b.constructor) return false;
165
+ var length, i, keys;
166
+ if (Array.isArray(a)) {
167
+ length = a.length;
168
+ if (length != b.length) return false;
169
+ for (i = length; i-- !== 0; )
170
+ if (!equal(a[i], b[i])) return false;
171
+ return true;
172
+ }
173
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
174
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
175
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
176
+ keys = Object.keys(a);
177
+ length = keys.length;
178
+ if (length !== Object.keys(b).length) return false;
179
+ for (i = length; i-- !== 0; )
180
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
181
+ for (i = length; i-- !== 0; ) {
182
+ var key = keys[i];
183
+ if (!equal(a[key], b[key])) return false;
184
+ }
185
+ return true;
186
+ }
187
+ return a !== a && b !== b;
188
+ };
189
+ }
190
+ });
191
+
156
192
  // bundle/index.ts
157
193
  var bundle_exports = {};
158
194
  __export(bundle_exports, {
@@ -168,8 +204,11 @@ __export(bundle_exports, {
168
204
  Label: () => Label,
169
205
  Puck: () => Puck,
170
206
  Render: () => Render,
207
+ blocksPlugin: () => blocksPlugin,
171
208
  createUsePuck: () => createUsePuck,
209
+ fieldsPlugin: () => fieldsPlugin,
172
210
  migrate: () => migrate,
211
+ outlinePlugin: () => outlinePlugin,
173
212
  overrideKeys: () => overrideKeys,
174
213
  registerOverlayPortal: () => registerOverlayPortal,
175
214
  renderContext: () => renderContext,
@@ -459,6 +498,15 @@ var EllipsisVertical = createLucideIcon("EllipsisVertical", [
459
498
  ["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
460
499
  ]);
461
500
 
501
+ // ../../node_modules/lucide-react/dist/esm/icons/expand.js
502
+ init_react_import();
503
+ var Expand = createLucideIcon("Expand", [
504
+ ["path", { d: "m21 21-6-6m6 6v-4.8m0 4.8h-4.8", key: "1c15vz" }],
505
+ ["path", { d: "M3 16.2V21m0 0h4.8M3 21l6-6", key: "1fsnz2" }],
506
+ ["path", { d: "M21 7.8V3m0 0h-4.8M21 3l-6 6", key: "hawz9i" }],
507
+ ["path", { d: "M3 7.8V3m0 0h4.8M3 3l6 6", key: "u9ee12" }]
508
+ ]);
509
+
462
510
  // ../../node_modules/lucide-react/dist/esm/icons/globe.js
463
511
  init_react_import();
464
512
  var Globe = createLucideIcon("Globe", [
@@ -467,6 +515,20 @@ var Globe = createLucideIcon("Globe", [
467
515
  ["path", { d: "M2 12h20", key: "9i4pu4" }]
468
516
  ]);
469
517
 
518
+ // ../../node_modules/lucide-react/dist/esm/icons/hammer.js
519
+ init_react_import();
520
+ var Hammer = createLucideIcon("Hammer", [
521
+ ["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
522
+ ["path", { d: "m18 15 4-4", key: "16gjal" }],
523
+ [
524
+ "path",
525
+ {
526
+ d: "m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",
527
+ key: "b7pghm"
528
+ }
529
+ ]
530
+ ]);
531
+
470
532
  // ../../node_modules/lucide-react/dist/esm/icons/hash.js
471
533
  init_react_import();
472
534
  var Hash = createLucideIcon("Hash", [
@@ -543,6 +605,24 @@ var Lock = createLucideIcon("Lock", [
543
605
  ["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
544
606
  ]);
545
607
 
608
+ // ../../node_modules/lucide-react/dist/esm/icons/maximize-2.js
609
+ init_react_import();
610
+ var Maximize2 = createLucideIcon("Maximize2", [
611
+ ["polyline", { points: "15 3 21 3 21 9", key: "mznyad" }],
612
+ ["polyline", { points: "9 21 3 21 3 15", key: "1avn1i" }],
613
+ ["line", { x1: "21", x2: "14", y1: "3", y2: "10", key: "ota7mn" }],
614
+ ["line", { x1: "3", x2: "10", y1: "21", y2: "14", key: "1atl0r" }]
615
+ ]);
616
+
617
+ // ../../node_modules/lucide-react/dist/esm/icons/minimize-2.js
618
+ init_react_import();
619
+ var Minimize2 = createLucideIcon("Minimize2", [
620
+ ["polyline", { points: "4 14 10 14 10 20", key: "11kfnr" }],
621
+ ["polyline", { points: "20 10 14 10 14 4", key: "rlmsce" }],
622
+ ["line", { x1: "14", x2: "21", y1: "10", y2: "3", key: "o5lafz" }],
623
+ ["line", { x1: "3", x2: "10", y1: "21", y2: "14", key: "1atl0r" }]
624
+ ]);
625
+
546
626
  // ../../node_modules/lucide-react/dist/esm/icons/monitor.js
547
627
  init_react_import();
548
628
  var Monitor = createLucideIcon("Monitor", [
@@ -572,6 +652,15 @@ var Plus = createLucideIcon("Plus", [
572
652
  ["path", { d: "M12 5v14", key: "s699le" }]
573
653
  ]);
574
654
 
655
+ // ../../node_modules/lucide-react/dist/esm/icons/rectangle-ellipsis.js
656
+ init_react_import();
657
+ var RectangleEllipsis = createLucideIcon("RectangleEllipsis", [
658
+ ["rect", { width: "20", height: "12", x: "2", y: "6", rx: "2", key: "9lu3g6" }],
659
+ ["path", { d: "M12 12h.01", key: "1mp3jc" }],
660
+ ["path", { d: "M17 12h.01", key: "1m0b6t" }],
661
+ ["path", { d: "M7 12h.01", key: "eqddd0" }]
662
+ ]);
663
+
575
664
  // ../../node_modules/lucide-react/dist/esm/icons/redo-2.js
576
665
  init_react_import();
577
666
  var Redo2 = createLucideIcon("Redo2", [
@@ -614,6 +703,14 @@ var Tablet = createLucideIcon("Tablet", [
614
703
  ["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
615
704
  ]);
616
705
 
706
+ // ../../node_modules/lucide-react/dist/esm/icons/toy-brick.js
707
+ init_react_import();
708
+ var ToyBrick = createLucideIcon("ToyBrick", [
709
+ ["rect", { width: "18", height: "12", x: "3", y: "8", rx: "1", key: "158fvp" }],
710
+ ["path", { d: "M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3", key: "s0042v" }],
711
+ ["path", { d: "M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3", key: "9wmeh2" }]
712
+ ]);
713
+
617
714
  // ../../node_modules/lucide-react/dist/esm/icons/trash.js
618
715
  init_react_import();
619
716
  var Trash = createLucideIcon("Trash", [
@@ -637,6 +734,13 @@ var Undo2 = createLucideIcon("Undo2", [
637
734
  ["path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11", key: "f3b9sd" }]
638
735
  ]);
639
736
 
737
+ // ../../node_modules/lucide-react/dist/esm/icons/x.js
738
+ init_react_import();
739
+ var X = createLucideIcon("X", [
740
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
741
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
742
+ ]);
743
+
640
744
  // ../../node_modules/lucide-react/dist/esm/icons/zoom-in.js
641
745
  init_react_import();
642
746
  var ZoomIn = createLucideIcon("ZoomIn", [
@@ -1612,7 +1716,8 @@ init_react_import();
1612
1716
  var defaultViewports = [
1613
1717
  { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1614
1718
  { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1615
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1719
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" },
1720
+ { width: "100%", height: "auto", icon: "FullWidth", label: "Full-width" }
1616
1721
  ];
1617
1722
 
1618
1723
  // store/index.ts
@@ -1661,7 +1766,9 @@ var keyCodeMap = {
1661
1766
  KeyW: "w",
1662
1767
  KeyX: "x",
1663
1768
  KeyY: "y",
1664
- KeyZ: "z"
1769
+ KeyZ: "z",
1770
+ Delete: "delete",
1771
+ Backspace: "backspace"
1665
1772
  };
1666
1773
  var useHotkeyStore = (0, import_zustand.create)()(
1667
1774
  (0, import_middleware.subscribeWithSelector)((set) => ({
@@ -1685,8 +1792,10 @@ var monitorHotkeys = (doc) => {
1685
1792
  ([key2, value]) => value === !!combo[key2]
1686
1793
  );
1687
1794
  if (conditionMet) {
1688
- e.preventDefault();
1689
- cb();
1795
+ const handled = cb(e);
1796
+ if (handled !== false) {
1797
+ e.preventDefault();
1798
+ }
1690
1799
  }
1691
1800
  });
1692
1801
  if (key !== "meta" && key !== "ctrl" && key !== "shift") {
@@ -1709,6 +1818,10 @@ var monitorHotkeys = (doc) => {
1709
1818
  useHotkeyStore.getState().reset();
1710
1819
  }
1711
1820
  };
1821
+ const onBlur = () => {
1822
+ useHotkeyStore.getState().reset();
1823
+ };
1824
+ window.addEventListener("blur", onBlur);
1712
1825
  doc.addEventListener("keydown", onKeyDown);
1713
1826
  doc.addEventListener("keyup", onKeyUp);
1714
1827
  doc.addEventListener("visibilitychange", onVisibilityChanged);
@@ -1716,6 +1829,7 @@ var monitorHotkeys = (doc) => {
1716
1829
  doc.removeEventListener("keydown", onKeyDown);
1717
1830
  doc.removeEventListener("keyup", onKeyUp);
1718
1831
  doc.removeEventListener("visibilitychange", onVisibilityChanged);
1832
+ window.removeEventListener("blur", onBlur);
1719
1833
  };
1720
1834
  };
1721
1835
  var useMonitorHotkeys = () => {
@@ -1910,7 +2024,7 @@ var flattenData = (state, config) => {
1910
2024
  (content) => content,
1911
2025
  (item) => {
1912
2026
  data.push(item);
1913
- return null;
2027
+ return item;
1914
2028
  }
1915
2029
  );
1916
2030
  return data;
@@ -1918,13 +2032,13 @@ var flattenData = (state, config) => {
1918
2032
 
1919
2033
  // lib/get-changed.ts
1920
2034
  init_react_import();
1921
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
2035
+ var import_fast_equals = require("fast-equals");
1922
2036
  var getChanged = (newItem, oldItem) => {
1923
2037
  return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1924
2038
  const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1925
2039
  const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1926
2040
  return __spreadProps(__spreadValues({}, acc), {
1927
- [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
2041
+ [item]: !(0, import_fast_equals.deepEqual)(oldItemProps[item], newItemProps[item])
1928
2042
  });
1929
2043
  }, {}) : {};
1930
2044
  };
@@ -2145,7 +2259,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
2145
2259
 
2146
2260
  // lib/resolve-component-data.ts
2147
2261
  init_react_import();
2148
- var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
2262
+ var import_fast_equals2 = require("fast-equals");
2149
2263
  var cache = { lastChange: {} };
2150
2264
  var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2151
2265
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
@@ -2154,7 +2268,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2154
2268
  const id = "id" in item.props ? item.props.id : "root";
2155
2269
  if (shouldRunResolver) {
2156
2270
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
2157
- if (trigger !== "force" && item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
2271
+ if (trigger !== "force" && item && (0, import_fast_equals2.deepEqual)(item, oldItem)) {
2158
2272
  return { node: resolved, didChange: false };
2159
2273
  }
2160
2274
  const changed = getChanged(item, oldItem);
@@ -2204,7 +2318,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2204
2318
  };
2205
2319
  return {
2206
2320
  node: itemWithResolvedChildren,
2207
- didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
2321
+ didChange: !(0, import_fast_equals2.deepEqual)(item, itemWithResolvedChildren)
2208
2322
  };
2209
2323
  });
2210
2324
 
@@ -2245,7 +2359,8 @@ var defaultAppState = {
2245
2359
  options: [],
2246
2360
  controlsVisible: true
2247
2361
  },
2248
- field: { focus: null }
2362
+ field: { focus: null },
2363
+ plugin: { current: null }
2249
2364
  },
2250
2365
  indexes: {
2251
2366
  nodes: {},
@@ -2261,6 +2376,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
2261
2376
  (0, import_middleware2.subscribeWithSelector)((set, get) => {
2262
2377
  var _a, _b;
2263
2378
  return __spreadProps(__spreadValues({
2379
+ instanceId: generateId(),
2264
2380
  state: defaultAppState,
2265
2381
  config: { components: {} },
2266
2382
  componentState: {},
@@ -2569,7 +2685,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
2569
2685
  const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
2570
2686
  let rootHeight = 0;
2571
2687
  let autoZoom = 1;
2572
- if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
2688
+ if (typeof uiViewport.width === "number" && (uiViewport.width > frameWidth || viewportHeight > frameHeight)) {
2573
2689
  const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
2574
2690
  const heightZoom = Math.min(frameHeight / viewportHeight, 1);
2575
2691
  zoom = widthZoom;
@@ -2648,7 +2764,8 @@ var IconButton = ({
2648
2764
  tabIndex,
2649
2765
  newTab,
2650
2766
  fullWidth,
2651
- title
2767
+ title,
2768
+ suppressHydrationWarning
2652
2769
  }) => {
2653
2770
  const [loading, setLoading] = (0, import_react9.useState)(false);
2654
2771
  const ElementType = href ? "a" : "button";
@@ -2675,6 +2792,7 @@ var IconButton = ({
2675
2792
  rel: newTab ? "noreferrer" : void 0,
2676
2793
  href,
2677
2794
  title,
2795
+ suppressHydrationWarning,
2678
2796
  children: [
2679
2797
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: getClassName3("title"), children: title }),
2680
2798
  children,
@@ -3490,8 +3608,9 @@ var ArrayField = ({
3490
3608
  var _a;
3491
3609
  if (isDraggingAny) return;
3492
3610
  const existingValue = value || [];
3611
+ const defaultProps = typeof field.defaultItemProps === "function" ? field.defaultItemProps(existingValue.length) : (_a = field.defaultItemProps) != null ? _a : {};
3493
3612
  const newItem = defaultSlots(
3494
- uniqifyItem((_a = field.defaultItemProps) != null ? _a : {}),
3613
+ uniqifyItem(defaultProps),
3495
3614
  field.arrayFields
3496
3615
  );
3497
3616
  const newValue = [...existingValue, newItem];
@@ -3750,11 +3869,13 @@ var ExternalInput = ({
3750
3869
  id,
3751
3870
  readOnly
3752
3871
  }) => {
3872
+ var _a;
3753
3873
  const {
3754
3874
  mapProp = (val) => val,
3755
3875
  mapRow = (val) => val,
3756
3876
  filterFields
3757
3877
  } = field || {};
3878
+ const { enabled: shouldCacheData } = (_a = field.cache) != null ? _a : { enabled: true };
3758
3879
  const [data, setData] = (0, import_react17.useState)([]);
3759
3880
  const [isOpen, setOpen] = (0, import_react17.useState)(false);
3760
3881
  const [isLoading, setIsLoading] = (0, import_react17.useState)(true);
@@ -3780,11 +3901,18 @@ var ExternalInput = ({
3780
3901
  (query, filters2) => __async(void 0, null, function* () {
3781
3902
  setIsLoading(true);
3782
3903
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
3783
- const listData = dataCache[cacheKey] || (yield field.fetchList({ query, filters: filters2 }));
3904
+ let listData;
3905
+ if (shouldCacheData && dataCache[cacheKey]) {
3906
+ listData = dataCache[cacheKey];
3907
+ } else {
3908
+ listData = yield field.fetchList({ query, filters: filters2 });
3909
+ }
3784
3910
  if (listData) {
3785
3911
  setData(listData);
3786
3912
  setIsLoading(false);
3787
- dataCache[cacheKey] = listData;
3913
+ if (shouldCacheData) {
3914
+ dataCache[cacheKey] = listData;
3915
+ }
3788
3916
  }
3789
3917
  }),
3790
3918
  [id, field]
@@ -3848,6 +3976,7 @@ var ExternalInput = ({
3848
3976
  }),
3849
3977
  onSubmit: (e) => {
3850
3978
  e.preventDefault();
3979
+ e.stopPropagation();
3851
3980
  search(searchQuery, filters);
3852
3981
  },
3853
3982
  children: [
@@ -4751,12 +4880,14 @@ var DraggableComponent = ({
4751
4880
  }
4752
4881
  return cleanup;
4753
4882
  }, [permissions.drag, zoneCompound]);
4883
+ const [, setRerender] = (0, import_react24.useState)(0);
4754
4884
  const ref = (0, import_react24.useRef)(null);
4755
4885
  const refSetter = (0, import_react24.useCallback)(
4756
4886
  (el) => {
4757
4887
  sortableRef(el);
4758
- if (el) {
4888
+ if (ref.current !== el) {
4759
4889
  ref.current = el;
4890
+ setRerender((update) => update + 1);
4760
4891
  }
4761
4892
  },
4762
4893
  [sortableRef]
@@ -4844,14 +4975,23 @@ var DraggableComponent = ({
4844
4975
  if (!el.closest("[data-puck-overlay-portal]")) {
4845
4976
  e.stopPropagation();
4846
4977
  }
4847
- dispatch({
4848
- type: "setUi",
4849
- ui: {
4850
- itemSelector: { index, zone: zoneCompound }
4851
- }
4852
- });
4978
+ if (isSelected) {
4979
+ dispatch({
4980
+ type: "setUi",
4981
+ ui: {
4982
+ itemSelector: null
4983
+ }
4984
+ });
4985
+ } else {
4986
+ dispatch({
4987
+ type: "setUi",
4988
+ ui: {
4989
+ itemSelector: { index, zone: zoneCompound }
4990
+ }
4991
+ });
4992
+ }
4853
4993
  },
4854
- [index, zoneCompound, id]
4994
+ [index, zoneCompound, id, isSelected]
4855
4995
  );
4856
4996
  const appStore = useAppStoreApi();
4857
4997
  const onSelectParent = (0, import_react24.useCallback)(() => {
@@ -5531,26 +5671,26 @@ var registerOverlayPortal = (el, opts = {}) => {
5531
5671
  capture: true
5532
5672
  });
5533
5673
  };
5534
- if (disableDragOnFocus) {
5535
- el.addEventListener("focus", onFocus, { capture: true });
5536
- el.addEventListener("blur", onBlur, { capture: true });
5537
- } else if (disableDrag) {
5674
+ if (disableDrag) {
5538
5675
  el.addEventListener("pointerdown", stopPropagation, {
5539
5676
  capture: true
5540
5677
  });
5678
+ } else if (disableDragOnFocus) {
5679
+ el.addEventListener("focus", onFocus, { capture: true });
5680
+ el.addEventListener("blur", onBlur, { capture: true });
5541
5681
  }
5542
5682
  el.setAttribute("data-puck-overlay-portal", "true");
5543
5683
  return () => {
5544
5684
  el.removeEventListener("mouseover", stopPropagation, {
5545
5685
  capture: true
5546
5686
  });
5547
- if (disableDragOnFocus) {
5548
- el.removeEventListener("focus", onFocus, { capture: true });
5549
- el.removeEventListener("blur", onFocus, { capture: true });
5550
- } else if (disableDrag) {
5687
+ if (disableDrag) {
5551
5688
  el.removeEventListener("pointerdown", stopPropagation, {
5552
5689
  capture: true
5553
5690
  });
5691
+ } else if (disableDragOnFocus) {
5692
+ el.removeEventListener("focus", onFocus, { capture: true });
5693
+ el.removeEventListener("blur", onBlur, { capture: true });
5554
5694
  }
5555
5695
  el.removeAttribute("data-puck-overlay-portal");
5556
5696
  };
@@ -5558,7 +5698,7 @@ var registerOverlayPortal = (el, opts = {}) => {
5558
5698
 
5559
5699
  // css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
5560
5700
  init_react_import();
5561
- var styles_module_default13 = { "InlineTextField": "_InlineTextField_1xph6_1" };
5701
+ var styles_module_default13 = { "InlineTextField": "_InlineTextField_104qp_1" };
5562
5702
 
5563
5703
  // lib/data/set-deep.ts
5564
5704
  init_react_import();
@@ -6545,8 +6685,8 @@ var DragDropContextClient = ({
6545
6685
  disableAutoScroll
6546
6686
  }) => {
6547
6687
  const dispatch = useAppStore((s) => s.dispatch);
6688
+ const instanceId = useAppStore((s) => s.instanceId);
6548
6689
  const appStore = useAppStoreApi();
6549
- const id = useSafeId();
6550
6690
  const debouncedParamsRef = (0, import_react37.useRef)(null);
6551
6691
  const tempDisableFallback = useTempDisableFallback(100);
6552
6692
  const [zoneStore] = (0, import_react37.useState)(
@@ -6562,7 +6702,7 @@ var DragDropContextClient = ({
6562
6702
  }))
6563
6703
  );
6564
6704
  const getChanged2 = (0, import_react37.useCallback)(
6565
- (params, id2) => {
6705
+ (params) => {
6566
6706
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
6567
6707
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
6568
6708
  const stateHasArea = Object.keys(areaDepthIndex).length > 0;
@@ -6584,7 +6724,7 @@ var DragDropContextClient = ({
6584
6724
  );
6585
6725
  const setDeepestAndCollide = (0, import_react37.useCallback)(
6586
6726
  (params, manager) => {
6587
- const { zoneChanged, areaChanged } = getChanged2(params, id);
6727
+ const { zoneChanged, areaChanged } = getChanged2(params);
6588
6728
  if (!zoneChanged && !areaChanged) return;
6589
6729
  zoneStore.setState({
6590
6730
  zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
@@ -6626,7 +6766,7 @@ var DragDropContextClient = ({
6626
6766
  {
6627
6767
  onChange: (params, manager) => {
6628
6768
  const state = zoneStore.getState();
6629
- const { zoneChanged, areaChanged } = getChanged2(params, id);
6769
+ const { zoneChanged, areaChanged } = getChanged2(params);
6630
6770
  const isDragging = manager.dragOperation.status.dragging;
6631
6771
  if (areaChanged || zoneChanged) {
6632
6772
  let nextZoneDepthIndex = {};
@@ -6664,7 +6804,7 @@ var DragDropContextClient = ({
6664
6804
  cancelDb();
6665
6805
  }
6666
6806
  },
6667
- id
6807
+ instanceId
6668
6808
  )
6669
6809
  ]);
6670
6810
  const sensors = useSensors();
@@ -6679,7 +6819,7 @@ var DragDropContextClient = ({
6679
6819
  }),
6680
6820
  []
6681
6821
  );
6682
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6822
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6683
6823
  dragListenerContext.Provider,
6684
6824
  {
6685
6825
  value: {
@@ -6906,7 +7046,7 @@ var DragDropContextClient = ({
6906
7046
  }
6907
7047
  )
6908
7048
  }
6909
- ) });
7049
+ );
6910
7050
  };
6911
7051
  var DragDropContext = ({
6912
7052
  children,
@@ -7048,121 +7188,24 @@ Drawer.Item = DrawerItem;
7048
7188
 
7049
7189
  // components/Puck/index.tsx
7050
7190
  init_react_import();
7051
- var import_react59 = require("react");
7052
-
7053
- // components/SidebarSection/index.tsx
7054
- init_react_import();
7055
-
7056
- // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
7057
- init_react_import();
7058
- var styles_module_default14 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
7059
-
7060
- // lib/use-breadcrumbs.ts
7061
- init_react_import();
7062
- var import_react40 = require("react");
7063
- var useBreadcrumbs = (renderCount) => {
7064
- const selectedId = useAppStore((s) => {
7065
- var _a;
7066
- return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
7067
- });
7068
- const config = useAppStore((s) => s.config);
7069
- const path = useAppStore((s) => {
7070
- var _a;
7071
- return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
7072
- });
7073
- const appStore = useAppStoreApi();
7074
- return (0, import_react40.useMemo)(() => {
7075
- const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
7076
- var _a, _b, _c;
7077
- const [componentId] = zoneCompound.split(":");
7078
- if (componentId === "root") {
7079
- return {
7080
- label: "Page",
7081
- selector: null
7082
- };
7083
- }
7084
- const node = appStore.getState().state.indexes.nodes[componentId];
7085
- const parentId = node.path[node.path.length - 1];
7086
- const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
7087
- const index = contentIds.indexOf(componentId);
7088
- const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
7089
- return {
7090
- label,
7091
- selector: node ? {
7092
- index,
7093
- zone: node.path[node.path.length - 1]
7094
- } : null
7095
- };
7096
- })) || [];
7097
- if (renderCount) {
7098
- return breadcrumbs.slice(breadcrumbs.length - renderCount);
7099
- }
7100
- return breadcrumbs;
7101
- }, [path, renderCount]);
7102
- };
7103
-
7104
- // components/SidebarSection/index.tsx
7105
- var import_jsx_runtime29 = require("react/jsx-runtime");
7106
- var getClassName20 = get_class_name_factory_default("SidebarSection", styles_module_default14);
7107
- var SidebarSection = ({
7108
- children,
7109
- title,
7110
- background,
7111
- showBreadcrumbs,
7112
- noBorderTop,
7113
- noPadding,
7114
- isLoading
7115
- }) => {
7116
- const setUi = useAppStore((s) => s.setUi);
7117
- const breadcrumbs = useBreadcrumbs(1);
7118
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
7119
- "div",
7120
- {
7121
- className: getClassName20({ noBorderTop, noPadding }),
7122
- style: { background },
7123
- children: [
7124
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("title"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("breadcrumbs"), children: [
7125
- showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("breadcrumb"), children: [
7126
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
7127
- "button",
7128
- {
7129
- type: "button",
7130
- className: getClassName20("breadcrumbLabel"),
7131
- onClick: () => setUi({ itemSelector: breadcrumb.selector }),
7132
- children: breadcrumb.label
7133
- }
7134
- ),
7135
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronRight, { size: 16 })
7136
- ] }, i)) : null,
7137
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
7138
- ] }) }),
7139
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("content"), children }),
7140
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 32 }) })
7141
- ]
7142
- }
7143
- );
7144
- };
7145
-
7146
- // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
7147
- init_react_import();
7148
- var styles_module_default15 = { "Puck": "_Puck_1yxlw_19", "Puck-portal": "_Puck-portal_1yxlw_31", "PuckLayout-inner": "_PuckLayout-inner_1yxlw_38", "PuckLayout--mounted": "_PuckLayout--mounted_1yxlw_59", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_1yxlw_63", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_1yxlw_69", "PuckLayout-mounted": "_PuckLayout-mounted_1yxlw_83", "PuckLayout": "_PuckLayout_1yxlw_38" };
7191
+ var import_react61 = require("react");
7149
7192
 
7150
7193
  // components/Puck/components/Fields/index.tsx
7151
7194
  init_react_import();
7152
7195
 
7153
7196
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
7154
7197
  init_react_import();
7155
- var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
7198
+ var styles_module_default14 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
7156
7199
 
7157
7200
  // components/Puck/components/Fields/index.tsx
7158
- var import_react41 = require("react");
7201
+ var import_react40 = require("react");
7159
7202
  var import_shallow5 = require("zustand/react/shallow");
7160
- var import_jsx_runtime30 = require("react/jsx-runtime");
7161
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
7203
+ var import_jsx_runtime29 = require("react/jsx-runtime");
7204
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default14);
7162
7205
  var DefaultFields = ({
7163
7206
  children
7164
7207
  }) => {
7165
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
7208
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
7166
7209
  };
7167
7210
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
7168
7211
  let currentProps;
@@ -7228,13 +7271,13 @@ var FieldsChild = ({ fieldName }) => {
7228
7271
  })
7229
7272
  );
7230
7273
  const appStore = useAppStoreApi();
7231
- const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
7274
+ const onChange = (0, import_react40.useCallback)(createOnChange(fieldName, appStore), [
7232
7275
  fieldName
7233
7276
  ]);
7234
7277
  const { visible = true } = field != null ? field : {};
7235
7278
  if (!field || !id || !visible) return null;
7236
7279
  if (field.type === "slot") return null;
7237
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
7280
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("field"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
7238
7281
  AutoFieldPrivate,
7239
7282
  {
7240
7283
  field,
@@ -7246,7 +7289,7 @@ var FieldsChild = ({ fieldName }) => {
7246
7289
  }
7247
7290
  ) }, id);
7248
7291
  };
7249
- var FieldsChildMemo = (0, import_react41.memo)(FieldsChild);
7292
+ var FieldsChildMemo = (0, import_react40.memo)(FieldsChild);
7250
7293
  var FieldsInternal = ({ wrapFields = true }) => {
7251
7294
  const overrides = useAppStore((s) => s.overrides);
7252
7295
  const componentResolving = useAppStore((s) => {
@@ -7271,41 +7314,41 @@ var FieldsInternal = ({ wrapFields = true }) => {
7271
7314
  })
7272
7315
  );
7273
7316
  const isLoading = fieldsLoading || componentResolving;
7274
- const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
7275
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
7317
+ const Wrapper = (0, import_react40.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
7318
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
7276
7319
  "form",
7277
7320
  {
7278
- className: getClassName21({ wrapFields }),
7321
+ className: getClassName20({ wrapFields }),
7279
7322
  onSubmit: (e) => {
7280
7323
  e.preventDefault();
7281
7324
  },
7282
7325
  children: [
7283
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
7284
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 16 }) }) })
7326
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
7327
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) }) })
7285
7328
  ]
7286
7329
  }
7287
7330
  );
7288
7331
  };
7289
- var Fields = (0, import_react41.memo)(FieldsInternal);
7332
+ var Fields = (0, import_react40.memo)(FieldsInternal);
7290
7333
 
7291
7334
  // components/Puck/components/Components/index.tsx
7292
7335
  init_react_import();
7293
7336
 
7294
7337
  // lib/use-component-list.tsx
7295
7338
  init_react_import();
7296
- var import_react43 = require("react");
7339
+ var import_react42 = require("react");
7297
7340
 
7298
7341
  // components/ComponentList/index.tsx
7299
7342
  init_react_import();
7300
7343
 
7301
7344
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
7302
7345
  init_react_import();
7303
- var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
7346
+ var styles_module_default15 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
7304
7347
 
7305
7348
  // components/ComponentList/index.tsx
7306
- var import_react42 = require("react");
7307
- var import_jsx_runtime31 = require("react/jsx-runtime");
7308
- var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
7349
+ var import_react41 = require("react");
7350
+ var import_jsx_runtime30 = require("react/jsx-runtime");
7351
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default15);
7309
7352
  var ComponentListItem = ({
7310
7353
  name,
7311
7354
  label
@@ -7317,14 +7360,14 @@ var ComponentListItem = ({
7317
7360
  type: name
7318
7361
  }).insert
7319
7362
  );
7320
- (0, import_react42.useEffect)(() => {
7363
+ (0, import_react41.useEffect)(() => {
7321
7364
  if (overrides.componentItem) {
7322
7365
  console.warn(
7323
7366
  "The `componentItem` override has been deprecated and renamed to `drawerItem`"
7324
7367
  );
7325
7368
  }
7326
7369
  }, [overrides]);
7327
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
7370
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
7328
7371
  };
7329
7372
  var ComponentList = ({
7330
7373
  children,
@@ -7335,12 +7378,12 @@ var ComponentList = ({
7335
7378
  const setUi = useAppStore((s) => s.setUi);
7336
7379
  const componentList = useAppStore((s) => s.state.ui.componentList);
7337
7380
  const { expanded = true } = componentList[id] || {};
7338
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
7339
- title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
7381
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName21({ isExpanded: expanded }), children: [
7382
+ title && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
7340
7383
  "button",
7341
7384
  {
7342
7385
  type: "button",
7343
- className: getClassName22("title"),
7386
+ className: getClassName21("title"),
7344
7387
  onClick: () => setUi({
7345
7388
  componentList: __spreadProps(__spreadValues({}, componentList), {
7346
7389
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -7350,14 +7393,14 @@ var ComponentList = ({
7350
7393
  }),
7351
7394
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
7352
7395
  children: [
7353
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
7354
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: 12 }) })
7396
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { children: title }),
7397
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronDown, { size: 12 }) })
7355
7398
  ]
7356
7399
  }
7357
7400
  ),
7358
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
7401
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("content"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
7359
7402
  var _a;
7360
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
7403
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
7361
7404
  ComponentListItem,
7362
7405
  {
7363
7406
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -7371,12 +7414,12 @@ var ComponentList = ({
7371
7414
  ComponentList.Item = ComponentListItem;
7372
7415
 
7373
7416
  // lib/use-component-list.tsx
7374
- var import_jsx_runtime32 = require("react/jsx-runtime");
7417
+ var import_jsx_runtime31 = require("react/jsx-runtime");
7375
7418
  var useComponentList = () => {
7376
- const [componentList, setComponentList] = (0, import_react43.useState)();
7419
+ const [componentList, setComponentList] = (0, import_react42.useState)();
7377
7420
  const config = useAppStore((s) => s.config);
7378
7421
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
7379
- (0, import_react43.useEffect)(() => {
7422
+ (0, import_react42.useEffect)(() => {
7380
7423
  var _a, _b, _c;
7381
7424
  if (Object.keys(uiComponentList).length > 0) {
7382
7425
  const matchedComponents = [];
@@ -7392,7 +7435,7 @@ var useComponentList = () => {
7392
7435
  if (category.visible === false) {
7393
7436
  return null;
7394
7437
  }
7395
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
7438
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
7396
7439
  ComponentList,
7397
7440
  {
7398
7441
  id: categoryKey,
@@ -7400,7 +7443,7 @@ var useComponentList = () => {
7400
7443
  children: category.components.map((componentName, i) => {
7401
7444
  var _a2;
7402
7445
  const componentConf = config.components[componentName] || {};
7403
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
7446
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
7404
7447
  ComponentList.Item,
7405
7448
  {
7406
7449
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -7420,7 +7463,7 @@ var useComponentList = () => {
7420
7463
  );
7421
7464
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
7422
7465
  _componentList.push(
7423
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
7466
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
7424
7467
  ComponentList,
7425
7468
  {
7426
7469
  id: "other",
@@ -7428,7 +7471,7 @@ var useComponentList = () => {
7428
7471
  children: remainingComponents.map((componentName, i) => {
7429
7472
  var _a2;
7430
7473
  const componentConf = config.components[componentName] || {};
7431
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
7474
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
7432
7475
  ComponentList.Item,
7433
7476
  {
7434
7477
  name: componentName,
@@ -7450,12 +7493,19 @@ var useComponentList = () => {
7450
7493
  };
7451
7494
 
7452
7495
  // components/Puck/components/Components/index.tsx
7453
- var import_react44 = require("react");
7454
- var import_jsx_runtime33 = require("react/jsx-runtime");
7496
+ var import_react43 = require("react");
7497
+
7498
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Components/styles.module.css#css-module
7499
+ init_react_import();
7500
+ var styles_module_default16 = { "Components": "_Components_3pbdy_1" };
7501
+
7502
+ // components/Puck/components/Components/index.tsx
7503
+ var import_jsx_runtime32 = require("react/jsx-runtime");
7504
+ var getClassName22 = get_class_name_factory_default("Components", styles_module_default16);
7455
7505
  var Components = () => {
7456
7506
  const overrides = useAppStore((s) => s.overrides);
7457
7507
  const componentList = useComponentList();
7458
- const Wrapper = (0, import_react44.useMemo)(() => {
7508
+ const Wrapper = (0, import_react43.useMemo)(() => {
7459
7509
  if (overrides.components) {
7460
7510
  console.warn(
7461
7511
  "The `components` override has been deprecated and renamed to `drawer`"
@@ -7463,19 +7513,19 @@ var Components = () => {
7463
7513
  }
7464
7514
  return overrides.components || overrides.drawer || "div";
7465
7515
  }, [overrides]);
7466
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
7516
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassName22(), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) }) });
7467
7517
  };
7468
7518
 
7469
7519
  // components/Puck/components/Preview/index.tsx
7470
7520
  init_react_import();
7471
- var import_react46 = require("react");
7521
+ var import_react45 = require("react");
7472
7522
 
7473
7523
  // components/AutoFrame/index.tsx
7474
7524
  init_react_import();
7475
- var import_react45 = require("react");
7525
+ var import_react44 = require("react");
7476
7526
  var import_object_hash = __toESM(require("object-hash"));
7477
7527
  var import_react_dom3 = require("react-dom");
7478
- var import_jsx_runtime34 = require("react/jsx-runtime");
7528
+ var import_jsx_runtime33 = require("react/jsx-runtime");
7479
7529
  var styleSelector = 'style, link[rel="stylesheet"]';
7480
7530
  var collectStyles = (doc) => {
7481
7531
  const collected = [];
@@ -7525,7 +7575,7 @@ var CopyHostStyles = ({
7525
7575
  onStylesLoaded = () => null
7526
7576
  }) => {
7527
7577
  const { document: doc, window: win } = useFrame();
7528
- (0, import_react45.useEffect)(() => {
7578
+ (0, import_react44.useEffect)(() => {
7529
7579
  if (!win || !doc) {
7530
7580
  return () => {
7531
7581
  };
@@ -7682,10 +7732,10 @@ var CopyHostStyles = ({
7682
7732
  observer.disconnect();
7683
7733
  };
7684
7734
  }, []);
7685
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
7735
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
7686
7736
  };
7687
- var autoFrameContext = (0, import_react45.createContext)({});
7688
- var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
7737
+ var autoFrameContext = (0, import_react44.createContext)({});
7738
+ var useFrame = () => (0, import_react44.useContext)(autoFrameContext);
7689
7739
  function AutoFrame(_a) {
7690
7740
  var _b = _a, {
7691
7741
  children,
@@ -7706,11 +7756,11 @@ function AutoFrame(_a) {
7706
7756
  "onNotReady",
7707
7757
  "frameRef"
7708
7758
  ]);
7709
- const [loaded, setLoaded] = (0, import_react45.useState)(false);
7710
- const [ctx, setCtx] = (0, import_react45.useState)({});
7711
- const [mountTarget, setMountTarget] = (0, import_react45.useState)();
7712
- const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
7713
- (0, import_react45.useEffect)(() => {
7759
+ const [loaded, setLoaded] = (0, import_react44.useState)(false);
7760
+ const [ctx, setCtx] = (0, import_react44.useState)({});
7761
+ const [mountTarget, setMountTarget] = (0, import_react44.useState)();
7762
+ const [stylesLoaded, setStylesLoaded] = (0, import_react44.useState)(false);
7763
+ (0, import_react44.useEffect)(() => {
7714
7764
  var _a2;
7715
7765
  if (frameRef.current) {
7716
7766
  const doc = frameRef.current.contentDocument;
@@ -7729,7 +7779,7 @@ function AutoFrame(_a) {
7729
7779
  }
7730
7780
  }
7731
7781
  }, [frameRef, loaded, stylesLoaded]);
7732
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7782
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7733
7783
  "iframe",
7734
7784
  __spreadProps(__spreadValues({}, props), {
7735
7785
  className,
@@ -7739,7 +7789,7 @@ function AutoFrame(_a) {
7739
7789
  onLoad: () => {
7740
7790
  setLoaded(true);
7741
7791
  },
7742
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7792
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7743
7793
  CopyHostStyles,
7744
7794
  {
7745
7795
  debug,
@@ -7755,14 +7805,14 @@ var AutoFrame_default = AutoFrame;
7755
7805
 
7756
7806
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
7757
7807
  init_react_import();
7758
- var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7808
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7759
7809
 
7760
7810
  // components/Puck/components/Preview/index.tsx
7761
- var import_jsx_runtime35 = require("react/jsx-runtime");
7762
- var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
7811
+ var import_jsx_runtime34 = require("react/jsx-runtime");
7812
+ var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default17);
7763
7813
  var useBubbleIframeEvents = (ref) => {
7764
7814
  const status = useAppStore((s) => s.status);
7765
- (0, import_react46.useEffect)(() => {
7815
+ (0, import_react45.useEffect)(() => {
7766
7816
  if (ref.current && status === "READY") {
7767
7817
  const iframe = ref.current;
7768
7818
  const handlePointerMove = (event) => {
@@ -7811,7 +7861,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
7811
7861
  const renderData = useAppStore(
7812
7862
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
7813
7863
  );
7814
- const Page = (0, import_react46.useCallback)(
7864
+ const Page = (0, import_react45.useCallback)(
7815
7865
  (pageProps) => {
7816
7866
  var _a, _b;
7817
7867
  const propsWithSlots = useSlots(
@@ -7821,15 +7871,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
7821
7871
  );
7822
7872
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
7823
7873
  id: "puck-root"
7824
- }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
7874
+ }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: propsWithSlots.children });
7825
7875
  },
7826
7876
  [config]
7827
7877
  );
7828
- const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
7878
+ const Frame = (0, import_react45.useMemo)(() => overrides.iframe, [overrides]);
7829
7879
  const rootProps = root.props || root;
7830
- const ref = (0, import_react46.useRef)(null);
7880
+ const ref = (0, import_react45.useRef)(null);
7831
7881
  useBubbleIframeEvents(ref);
7832
- const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7882
+ const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7833
7883
  Page,
7834
7884
  __spreadProps(__spreadValues({}, rootProps), {
7835
7885
  puck: {
@@ -7839,15 +7889,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
7839
7889
  metadata
7840
7890
  },
7841
7891
  editMode: true,
7842
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
7892
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
7843
7893
  })
7844
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config, metadata });
7845
- (0, import_react46.useEffect)(() => {
7894
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config, metadata });
7895
+ (0, import_react45.useEffect)(() => {
7846
7896
  if (!iframe.enabled) {
7847
7897
  setStatus("READY");
7848
7898
  }
7849
7899
  }, [iframe.enabled]);
7850
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7900
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7851
7901
  "div",
7852
7902
  {
7853
7903
  className: getClassName23(),
@@ -7859,7 +7909,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
7859
7909
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7860
7910
  }
7861
7911
  },
7862
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7912
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7863
7913
  AutoFrame_default,
7864
7914
  {
7865
7915
  id: "preview-frame",
@@ -7872,14 +7922,14 @@ var Preview2 = ({ id = "puck-preview" }) => {
7872
7922
  setStatus("MOUNTED");
7873
7923
  },
7874
7924
  frameRef: ref,
7875
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7925
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7876
7926
  if (Frame) {
7877
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
7927
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Frame, { document: document2, children: inner });
7878
7928
  }
7879
7929
  return inner;
7880
7930
  } })
7881
7931
  }
7882
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7932
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7883
7933
  "div",
7884
7934
  {
7885
7935
  id: "preview-frame",
@@ -7901,7 +7951,7 @@ init_react_import();
7901
7951
 
7902
7952
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
7903
7953
  init_react_import();
7904
- var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
7954
+ var styles_module_default18 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
7905
7955
 
7906
7956
  // lib/scroll-into-view.ts
7907
7957
  init_react_import();
@@ -7915,7 +7965,7 @@ var scrollIntoView = (el) => {
7915
7965
  };
7916
7966
 
7917
7967
  // components/LayerTree/index.tsx
7918
- var import_react47 = require("react");
7968
+ var import_react46 = require("react");
7919
7969
 
7920
7970
  // lib/on-scroll-end.ts
7921
7971
  init_react_import();
@@ -7938,9 +7988,9 @@ var onScrollEnd = (frame, cb) => {
7938
7988
 
7939
7989
  // components/LayerTree/index.tsx
7940
7990
  var import_shallow6 = require("zustand/react/shallow");
7941
- var import_jsx_runtime36 = require("react/jsx-runtime");
7942
- var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
7943
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
7991
+ var import_jsx_runtime35 = require("react/jsx-runtime");
7992
+ var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default18);
7993
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
7944
7994
  var Layer = ({
7945
7995
  index,
7946
7996
  itemId,
@@ -7950,7 +8000,7 @@ var Layer = ({
7950
8000
  const config = useAppStore((s) => s.config);
7951
8001
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
7952
8002
  const dispatch = useAppStore((s) => s.dispatch);
7953
- const setItemSelector = (0, import_react47.useCallback)(
8003
+ const setItemSelector = (0, import_react46.useCallback)(
7954
8004
  (itemSelector2) => {
7955
8005
  dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
7956
8006
  },
@@ -7970,7 +8020,7 @@ var Layer = ({
7970
8020
  )
7971
8021
  );
7972
8022
  const containsZone = zonesForItem.length > 0;
7973
- const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
8023
+ const zoneStore = (0, import_react46.useContext)(ZoneStoreContext);
7974
8024
  const isHovering = useContextStore(
7975
8025
  ZoneStoreContext,
7976
8026
  (s) => s.hoveringComponent === itemId
@@ -7985,7 +8035,7 @@ var Layer = ({
7985
8035
  });
7986
8036
  const componentConfig = config.components[nodeData.data.type];
7987
8037
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
7988
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
8038
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7989
8039
  "li",
7990
8040
  {
7991
8041
  className: getClassNameLayer({
@@ -7995,7 +8045,7 @@ var Layer = ({
7995
8045
  childIsSelected
7996
8046
  }),
7997
8047
  children: [
7998
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
8048
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7999
8049
  "button",
8000
8050
  {
8001
8051
  type: "button",
@@ -8033,22 +8083,22 @@ var Layer = ({
8033
8083
  zoneStore.setState({ hoveringComponent: null });
8034
8084
  },
8035
8085
  children: [
8036
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
8086
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
8037
8087
  "div",
8038
8088
  {
8039
8089
  className: getClassNameLayer("chevron"),
8040
8090
  title: isSelected ? "Collapse" : "Expand",
8041
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
8091
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { size: "12" })
8042
8092
  }
8043
8093
  ),
8044
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
8045
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayoutGrid, { size: "16" }) }),
8046
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
8094
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassNameLayer("title"), children: [
8095
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayoutGrid, { size: "16" }) }),
8096
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("name"), children: label })
8047
8097
  ] })
8048
8098
  ]
8049
8099
  }
8050
8100
  ) }),
8051
- containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
8101
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
8052
8102
  ]
8053
8103
  }
8054
8104
  );
@@ -8074,15 +8124,15 @@ var LayerTree = ({
8074
8124
  }
8075
8125
  )
8076
8126
  );
8077
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
8078
- label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
8079
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
8127
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
8128
+ label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
8129
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
8080
8130
  label
8081
8131
  ] }),
8082
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
8083
- contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
8132
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName24(), children: [
8133
+ contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
8084
8134
  contentIds.map((itemId, i) => {
8085
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
8135
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
8086
8136
  Layer,
8087
8137
  {
8088
8138
  index: i,
@@ -8097,7 +8147,7 @@ var LayerTree = ({
8097
8147
  };
8098
8148
 
8099
8149
  // components/Puck/components/Outline/index.tsx
8100
- var import_react48 = require("react");
8150
+ var import_react47 = require("react");
8101
8151
 
8102
8152
  // lib/data/find-zones-for-area.ts
8103
8153
  init_react_import();
@@ -8109,456 +8159,204 @@ var findZonesForArea = (state, area) => {
8109
8159
 
8110
8160
  // components/Puck/components/Outline/index.tsx
8111
8161
  var import_shallow7 = require("zustand/react/shallow");
8112
- var import_jsx_runtime37 = require("react/jsx-runtime");
8162
+
8163
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Outline/styles.module.css#css-module
8164
+ init_react_import();
8165
+ var styles_module_default19 = { "Outline": "_Outline_cvjlj_1" };
8166
+
8167
+ // components/Puck/components/Outline/index.tsx
8168
+ var import_jsx_runtime36 = require("react/jsx-runtime");
8169
+ var getClassName25 = get_class_name_factory_default("Outline", styles_module_default19);
8113
8170
  var Outline = () => {
8114
8171
  const outlineOverride = useAppStore((s) => s.overrides.outline);
8115
8172
  const rootZones = useAppStore(
8116
8173
  (0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
8117
8174
  );
8118
- const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
8119
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
8175
+ const Wrapper = (0, import_react47.useMemo)(() => outlineOverride || "div", [outlineOverride]);
8176
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25(), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
8120
8177
  LayerTree,
8121
8178
  {
8122
8179
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
8123
8180
  zoneCompound
8124
8181
  },
8125
8182
  zoneCompound
8126
- )) });
8183
+ )) }) });
8127
8184
  };
8128
8185
 
8129
- // components/Puck/components/Canvas/index.tsx
8130
- init_react_import();
8131
- var import_react51 = require("react");
8132
-
8133
- // components/ViewportControls/index.tsx
8186
+ // lib/use-loaded-overrides.ts
8134
8187
  init_react_import();
8135
- var import_react49 = require("react");
8188
+ var import_react48 = require("react");
8136
8189
 
8137
- // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
8190
+ // lib/load-overrides.ts
8138
8191
  init_react_import();
8139
- var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
8140
-
8141
- // components/ViewportControls/index.tsx
8142
- var import_jsx_runtime38 = require("react/jsx-runtime");
8143
- var icons = {
8144
- Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
8145
- Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
8146
- Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
8192
+ var loadOverrides = ({
8193
+ overrides,
8194
+ plugins
8195
+ }) => {
8196
+ const collected = __spreadValues({}, overrides);
8197
+ plugins == null ? void 0 : plugins.forEach((plugin) => {
8198
+ if (!plugin.overrides) return;
8199
+ Object.keys(plugin.overrides).forEach((_overridesType) => {
8200
+ var _a;
8201
+ const overridesType = _overridesType;
8202
+ if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
8203
+ if (overridesType === "fieldTypes") {
8204
+ const fieldTypes = plugin.overrides.fieldTypes;
8205
+ Object.keys(fieldTypes).forEach((fieldType) => {
8206
+ collected.fieldTypes = collected.fieldTypes || {};
8207
+ const childNode2 = collected.fieldTypes[fieldType];
8208
+ const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
8209
+ children: childNode2 ? childNode2(props) : props.children
8210
+ }));
8211
+ collected.fieldTypes[fieldType] = Comp2;
8212
+ });
8213
+ return;
8214
+ }
8215
+ const childNode = collected[overridesType];
8216
+ const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
8217
+ children: childNode ? childNode(props) : props.children
8218
+ }));
8219
+ collected[overridesType] = Comp;
8220
+ });
8221
+ });
8222
+ return collected;
8147
8223
  };
8148
- var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
8149
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
8150
- var ViewportButton = ({
8151
- children,
8152
- height = "auto",
8153
- title,
8154
- width,
8155
- onClick
8224
+
8225
+ // lib/use-loaded-overrides.ts
8226
+ var useLoadedOverrides = ({
8227
+ overrides,
8228
+ plugins
8156
8229
  }) => {
8157
- const viewports = useAppStore((s) => s.state.ui.viewports);
8158
- const [isActive, setIsActive] = (0, import_react49.useState)(false);
8159
- (0, import_react49.useEffect)(() => {
8160
- setIsActive(width === viewports.current.width);
8161
- }, [width, viewports.current.width]);
8162
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8163
- IconButton,
8164
- {
8165
- type: "button",
8166
- title,
8167
- disabled: isActive,
8168
- onClick: (e) => {
8169
- e.stopPropagation();
8170
- onClick({ width, height });
8171
- },
8172
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
8173
- }
8174
- ) });
8230
+ return (0, import_react48.useMemo)(() => {
8231
+ return loadOverrides({ overrides, plugins });
8232
+ }, [plugins, overrides]);
8175
8233
  };
8176
- var defaultZoomOptions = [
8177
- { label: "25%", value: 0.25 },
8178
- { label: "50%", value: 0.5 },
8179
- { label: "75%", value: 0.75 },
8180
- { label: "100%", value: 1 },
8181
- { label: "125%", value: 1.25 },
8182
- { label: "150%", value: 1.5 },
8183
- { label: "200%", value: 2 }
8184
- ];
8185
- var ViewportControls = ({
8186
- autoZoom,
8187
- zoom,
8188
- onViewportChange,
8189
- onZoom
8190
- }) => {
8191
- var _a, _b;
8192
- const viewports = useAppStore((s) => s.viewports);
8193
- const defaultsContainAutoZoom = defaultZoomOptions.find(
8194
- (option) => option.value === autoZoom
8195
- );
8196
- const zoomOptions = (0, import_react49.useMemo)(
8197
- () => [
8198
- ...defaultZoomOptions,
8199
- ...defaultsContainAutoZoom ? [] : [
8200
- {
8201
- value: autoZoom,
8202
- label: `${(autoZoom * 100).toFixed(0)}% (Auto)`
8203
- }
8204
- ]
8205
- ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
8206
- [autoZoom]
8234
+
8235
+ // lib/use-puck.ts
8236
+ init_react_import();
8237
+ var import_react49 = require("react");
8238
+ var import_zustand6 = require("zustand");
8239
+ var generateUsePuck = (store) => {
8240
+ const history = {
8241
+ back: store.history.back,
8242
+ forward: store.history.forward,
8243
+ setHistories: store.history.setHistories,
8244
+ setHistoryIndex: store.history.setHistoryIndex,
8245
+ hasPast: store.history.hasPast(),
8246
+ hasFuture: store.history.hasFuture(),
8247
+ histories: store.history.histories,
8248
+ index: store.history.index
8249
+ };
8250
+ const storeData = {
8251
+ appState: makeStatePublic(store.state),
8252
+ config: store.config,
8253
+ dispatch: store.dispatch,
8254
+ getPermissions: store.permissions.getPermissions,
8255
+ refreshPermissions: store.permissions.refreshPermissions,
8256
+ history,
8257
+ selectedItem: store.selectedItem || null,
8258
+ getItemBySelector: (selector) => getItem(selector, store.state),
8259
+ getItemById: (id) => store.state.indexes.nodes[id].data,
8260
+ getSelectorForId: (id) => getSelectorForId(store.state, id)
8261
+ };
8262
+ return storeData;
8263
+ };
8264
+ var UsePuckStoreContext = (0, import_react49.createContext)(
8265
+ null
8266
+ );
8267
+ var convertToPickedStore = (store) => {
8268
+ return {
8269
+ state: store.state,
8270
+ config: store.config,
8271
+ dispatch: store.dispatch,
8272
+ permissions: store.permissions,
8273
+ history: store.history,
8274
+ selectedItem: store.selectedItem
8275
+ };
8276
+ };
8277
+ var useRegisterUsePuckStore = (appStore) => {
8278
+ const [usePuckStore] = (0, import_react49.useState)(
8279
+ () => (0, import_zustand6.createStore)(
8280
+ () => generateUsePuck(convertToPickedStore(appStore.getState()))
8281
+ )
8207
8282
  );
8208
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
8209
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8210
- ViewportButton,
8211
- {
8212
- height: viewport.height,
8213
- width: viewport.width,
8214
- title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
8215
- onClick: onViewportChange,
8216
- children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
8217
- },
8218
- i
8219
- )),
8220
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
8221
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8222
- IconButton,
8223
- {
8224
- type: "button",
8225
- title: "Zoom viewport out",
8226
- disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
8227
- onClick: (e) => {
8228
- e.stopPropagation();
8229
- onZoom(
8230
- zoomOptions[Math.max(
8231
- zoomOptions.findIndex((option) => option.value === zoom) - 1,
8232
- 0
8233
- )].value
8234
- );
8235
- },
8236
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
8237
- }
8238
- ),
8239
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8240
- IconButton,
8241
- {
8242
- type: "button",
8243
- title: "Zoom viewport in",
8244
- disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
8245
- onClick: (e) => {
8246
- e.stopPropagation();
8247
- onZoom(
8248
- zoomOptions[Math.min(
8249
- zoomOptions.findIndex((option) => option.value === zoom) + 1,
8250
- zoomOptions.length - 1
8251
- )].value
8252
- );
8253
- },
8254
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
8255
- }
8256
- ),
8257
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
8258
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8259
- "select",
8260
- {
8261
- className: getClassName25("zoomSelect"),
8262
- value: zoom.toString(),
8263
- onClick: (e) => {
8264
- e.stopPropagation();
8265
- },
8266
- onChange: (e) => {
8267
- onZoom(parseFloat(e.currentTarget.value));
8268
- },
8269
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8270
- "option",
8271
- {
8272
- value: option.value,
8273
- label: option.label
8274
- },
8275
- option.label
8276
- ))
8283
+ (0, import_react49.useEffect)(() => {
8284
+ return appStore.subscribe(
8285
+ (store) => convertToPickedStore(store),
8286
+ (pickedStore) => {
8287
+ usePuckStore.setState(generateUsePuck(pickedStore));
8277
8288
  }
8278
- )
8279
- ] });
8289
+ );
8290
+ }, []);
8291
+ return usePuckStore;
8292
+ };
8293
+ function createUsePuck() {
8294
+ return function usePuck2(selector) {
8295
+ const usePuckApi = (0, import_react49.useContext)(UsePuckStoreContext);
8296
+ if (!usePuckApi) {
8297
+ throw new Error("usePuck must be used inside <Puck>.");
8298
+ }
8299
+ const result = (0, import_zustand6.useStore)(
8300
+ usePuckApi,
8301
+ selector != null ? selector : (s) => s
8302
+ );
8303
+ return result;
8304
+ };
8305
+ }
8306
+ function usePuck() {
8307
+ (0, import_react49.useEffect)(() => {
8308
+ console.warn(
8309
+ "You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
8310
+ );
8311
+ }, []);
8312
+ return createUsePuck()((s) => s);
8313
+ }
8314
+ function useGetPuck() {
8315
+ const usePuckApi = (0, import_react49.useContext)(UsePuckStoreContext);
8316
+ if (!usePuckApi) {
8317
+ throw new Error("usePuckGet must be used inside <Puck>.");
8318
+ }
8319
+ return usePuckApi.getState;
8320
+ }
8321
+
8322
+ // components/Puck/index.tsx
8323
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
8324
+
8325
+ // lib/data/to-component.ts
8326
+ init_react_import();
8327
+ var toComponent = (item) => {
8328
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
8329
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
8330
+ type: "root"
8331
+ });
8280
8332
  };
8281
8333
 
8282
- // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
8334
+ // components/Puck/components/Layout/index.tsx
8283
8335
  init_react_import();
8284
- var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
8336
+ var import_react60 = require("react");
8285
8337
 
8286
- // components/Puck/components/Canvas/index.tsx
8287
- var import_shallow8 = require("zustand/react/shallow");
8338
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Layout/styles.module.css#css-module
8339
+ init_react_import();
8340
+ var styles_module_default20 = { "Puck": "_Puck_hv23j_19", "Puck-portal": "_Puck-portal_hv23j_31", "PuckLayout": "_PuckLayout_hv23j_36", "PuckLayout-inner": "_PuckLayout-inner_hv23j_40", "PuckLayout--mounted": "_PuckLayout--mounted_hv23j_73", "PuckLayout--mobilePanelHeightToggle": "_PuckLayout--mobilePanelHeightToggle_hv23j_77", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_hv23j_77", "PuckLayout--isExpanded": "_PuckLayout--isExpanded_hv23j_83", "PuckLayout--mobilePanelHeightMinContent": "_PuckLayout--mobilePanelHeightMinContent_hv23j_101", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_hv23j_128", "PuckLayout-mounted": "_PuckLayout-mounted_hv23j_147", "PuckLayout-nav": "_PuckLayout-nav_hv23j_188", "PuckLayout-header": "_PuckLayout-header_hv23j_204", "PuckPluginTab": "_PuckPluginTab_hv23j_218", "PuckPluginTab--visible": "_PuckPluginTab--visible_hv23j_224", "PuckPluginTab-body": "_PuckPluginTab-body_hv23j_229" };
8288
8341
 
8289
- // lib/frame-context.tsx
8342
+ // lib/use-inject-css.ts
8290
8343
  init_react_import();
8291
8344
  var import_react50 = require("react");
8292
- var import_jsx_runtime39 = require("react/jsx-runtime");
8293
- var FrameContext = (0, import_react50.createContext)(null);
8294
- var FrameProvider = ({
8295
- children
8296
- }) => {
8297
- const frameRef = (0, import_react50.useRef)(null);
8298
- const value = (0, import_react50.useMemo)(
8299
- () => ({
8300
- frameRef
8301
- }),
8302
- []
8303
- );
8304
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(FrameContext.Provider, { value, children });
8305
- };
8306
- var useCanvasFrame = () => {
8307
- const context = (0, import_react50.useContext)(FrameContext);
8308
- if (context === null) {
8309
- throw new Error("useCanvasFrame must be used within a FrameProvider");
8310
- }
8311
- return context;
8312
- };
8313
-
8314
- // components/Puck/components/Canvas/index.tsx
8315
- var import_jsx_runtime40 = require("react/jsx-runtime");
8316
- var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
8317
- var ZOOM_ON_CHANGE = true;
8318
- var TRANSITION_DURATION = 150;
8319
- var Canvas = () => {
8320
- const { frameRef } = useCanvasFrame();
8321
- const resetAutoZoom = useResetAutoZoom(frameRef);
8322
- const {
8323
- dispatch,
8324
- overrides,
8325
- setUi,
8326
- zoomConfig,
8327
- setZoomConfig,
8328
- status,
8329
- iframe
8330
- } = useAppStore(
8331
- (0, import_shallow8.useShallow)((s) => ({
8332
- dispatch: s.dispatch,
8333
- overrides: s.overrides,
8334
- setUi: s.setUi,
8335
- zoomConfig: s.zoomConfig,
8336
- setZoomConfig: s.setZoomConfig,
8337
- status: s.status,
8338
- iframe: s.iframe
8339
- }))
8340
- );
8341
- const {
8342
- leftSideBarVisible,
8343
- rightSideBarVisible,
8344
- leftSideBarWidth,
8345
- rightSideBarWidth,
8346
- viewports
8347
- } = useAppStore(
8348
- (0, import_shallow8.useShallow)((s) => ({
8349
- leftSideBarVisible: s.state.ui.leftSideBarVisible,
8350
- rightSideBarVisible: s.state.ui.rightSideBarVisible,
8351
- leftSideBarWidth: s.state.ui.leftSideBarWidth,
8352
- rightSideBarWidth: s.state.ui.rightSideBarWidth,
8353
- viewports: s.state.ui.viewports
8354
- }))
8355
- );
8356
- const [showTransition, setShowTransition] = (0, import_react51.useState)(false);
8357
- const isResizingRef = (0, import_react51.useRef)(false);
8358
- const defaultRender = (0, import_react51.useMemo)(() => {
8359
- const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
8360
- return PuckDefault;
8345
+ var styles = ``;
8346
+ var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
8347
+ const [el, setEl] = (0, import_react50.useState)();
8348
+ (0, import_react50.useEffect)(() => {
8349
+ setEl(document.createElement("style"));
8361
8350
  }, []);
8362
- const CustomPreview = (0, import_react51.useMemo)(
8363
- () => overrides.preview || defaultRender,
8364
- [overrides]
8365
- );
8366
- const getFrameDimensions = (0, import_react51.useCallback)(() => {
8367
- if (frameRef.current) {
8368
- const frame = frameRef.current;
8369
- const box = getBox(frame);
8370
- return { width: box.contentBox.width, height: box.contentBox.height };
8371
- }
8372
- return { width: 0, height: 0 };
8373
- }, [frameRef]);
8374
- (0, import_react51.useEffect)(() => {
8375
- resetAutoZoom();
8376
- }, [
8377
- frameRef,
8378
- leftSideBarVisible,
8379
- rightSideBarVisible,
8380
- leftSideBarWidth,
8381
- rightSideBarWidth,
8382
- viewports
8383
- ]);
8384
- (0, import_react51.useEffect)(() => {
8385
- const { height: frameHeight } = getFrameDimensions();
8386
- if (viewports.current.height === "auto") {
8387
- setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
8388
- rootHeight: frameHeight / zoomConfig.zoom
8389
- }));
8351
+ (0, import_react50.useEffect)(() => {
8352
+ var _a;
8353
+ if (!el || typeof window === "undefined") {
8354
+ return;
8390
8355
  }
8391
- }, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
8392
- (0, import_react51.useEffect)(() => {
8393
- if (ZOOM_ON_CHANGE) {
8394
- resetAutoZoom();
8395
- }
8396
- }, [viewports.current.width, viewports]);
8397
- (0, import_react51.useEffect)(() => {
8398
- if (!frameRef.current) return;
8399
- const resizeObserver = new ResizeObserver(() => {
8400
- if (!isResizingRef.current) {
8401
- resetAutoZoom();
8402
- }
8403
- });
8404
- resizeObserver.observe(frameRef.current);
8405
- return () => {
8406
- resizeObserver.disconnect();
8407
- };
8408
- }, [frameRef.current]);
8409
- const [showLoader, setShowLoader] = (0, import_react51.useState)(false);
8410
- (0, import_react51.useEffect)(() => {
8411
- setTimeout(() => {
8412
- setShowLoader(true);
8413
- }, 500);
8414
- }, []);
8415
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
8416
- "div",
8417
- {
8418
- className: getClassName26({
8419
- ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
8420
- showLoader
8421
- }),
8422
- onClick: (e) => {
8423
- const el = e.target;
8424
- if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
8425
- dispatch({
8426
- type: "setUi",
8427
- ui: { itemSelector: null },
8428
- recordHistory: true
8429
- });
8430
- }
8431
- },
8432
- children: [
8433
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8434
- ViewportControls,
8435
- {
8436
- autoZoom: zoomConfig.autoZoom,
8437
- zoom: zoomConfig.zoom,
8438
- onViewportChange: (viewport) => {
8439
- setShowTransition(true);
8440
- isResizingRef.current = true;
8441
- const uiViewport = __spreadProps(__spreadValues({}, viewport), {
8442
- height: viewport.height || "auto",
8443
- zoom: zoomConfig.zoom
8444
- });
8445
- const newUi = {
8446
- viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
8447
- };
8448
- setUi(newUi);
8449
- if (ZOOM_ON_CHANGE) {
8450
- resetAutoZoom({
8451
- viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
8452
- });
8453
- }
8454
- },
8455
- onZoom: (zoom) => {
8456
- setShowTransition(true);
8457
- isResizingRef.current = true;
8458
- setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
8459
- }
8460
- }
8461
- ) }),
8462
- /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
8463
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8464
- "div",
8465
- {
8466
- className: getClassName26("root"),
8467
- style: {
8468
- width: iframe.enabled ? viewports.current.width : "100%",
8469
- height: zoomConfig.rootHeight,
8470
- transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
8471
- transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
8472
- overflow: iframe.enabled ? void 0 : "auto"
8473
- },
8474
- suppressHydrationWarning: true,
8475
- id: "puck-canvas-root",
8476
- onTransitionEnd: () => {
8477
- setShowTransition(false);
8478
- isResizingRef.current = false;
8479
- },
8480
- children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Preview2, {}) })
8481
- }
8482
- ),
8483
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Loader, { size: 24 }) })
8484
- ] })
8485
- ]
8486
- }
8487
- );
8488
- };
8489
-
8490
- // lib/use-loaded-overrides.ts
8491
- init_react_import();
8492
- var import_react52 = require("react");
8493
-
8494
- // lib/load-overrides.ts
8495
- init_react_import();
8496
- var loadOverrides = ({
8497
- overrides,
8498
- plugins
8499
- }) => {
8500
- const collected = __spreadValues({}, overrides);
8501
- plugins == null ? void 0 : plugins.forEach((plugin) => {
8502
- if (!plugin.overrides) return;
8503
- Object.keys(plugin.overrides).forEach((_overridesType) => {
8504
- var _a;
8505
- const overridesType = _overridesType;
8506
- if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
8507
- if (overridesType === "fieldTypes") {
8508
- const fieldTypes = plugin.overrides.fieldTypes;
8509
- Object.keys(fieldTypes).forEach((fieldType) => {
8510
- collected.fieldTypes = collected.fieldTypes || {};
8511
- const childNode2 = collected.fieldTypes[fieldType];
8512
- const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
8513
- children: childNode2 ? childNode2(props) : props.children
8514
- }));
8515
- collected.fieldTypes[fieldType] = Comp2;
8516
- });
8517
- return;
8518
- }
8519
- const childNode = collected[overridesType];
8520
- const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
8521
- children: childNode ? childNode(props) : props.children
8522
- }));
8523
- collected[overridesType] = Comp;
8524
- });
8525
- });
8526
- return collected;
8527
- };
8528
-
8529
- // lib/use-loaded-overrides.ts
8530
- var useLoadedOverrides = ({
8531
- overrides,
8532
- plugins
8533
- }) => {
8534
- return (0, import_react52.useMemo)(() => {
8535
- return loadOverrides({ overrides, plugins });
8536
- }, [plugins, overrides]);
8537
- };
8538
-
8539
- // components/DefaultOverride/index.tsx
8540
- init_react_import();
8541
- var import_jsx_runtime41 = require("react/jsx-runtime");
8542
- var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children });
8543
-
8544
- // lib/use-inject-css.ts
8545
- init_react_import();
8546
- var import_react53 = require("react");
8547
- var styles = ``;
8548
- var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
8549
- const [el, setEl] = (0, import_react53.useState)();
8550
- (0, import_react53.useEffect)(() => {
8551
- setEl(document.createElement("style"));
8552
- }, []);
8553
- (0, import_react53.useEffect)(() => {
8554
- var _a;
8555
- if (!el || typeof window === "undefined") {
8556
- return;
8557
- }
8558
- el.innerHTML = initialStyles;
8559
- if (iframeEnabled) {
8560
- const frame = getFrame();
8561
- (_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
8356
+ el.innerHTML = initialStyles;
8357
+ if (iframeEnabled) {
8358
+ const frame = getFrame();
8359
+ (_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
8562
8360
  }
8563
8361
  document.head.appendChild(el);
8564
8362
  }, [iframeEnabled, el]);
@@ -8568,12 +8366,17 @@ var useInjectGlobalCss = (iframeEnabled) => {
8568
8366
  return useInjectStyleSheet(styles, iframeEnabled);
8569
8367
  };
8570
8368
 
8369
+ // components/DefaultOverride/index.tsx
8370
+ init_react_import();
8371
+ var import_jsx_runtime37 = require("react/jsx-runtime");
8372
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
8373
+
8571
8374
  // lib/use-preview-mode-hotkeys.ts
8572
8375
  init_react_import();
8573
- var import_react54 = require("react");
8376
+ var import_react51 = require("react");
8574
8377
  var usePreviewModeHotkeys = () => {
8575
8378
  const appStore = useAppStoreApi();
8576
- const toggleInteractive = (0, import_react54.useCallback)(() => {
8379
+ const toggleInteractive = (0, import_react51.useCallback)(() => {
8577
8380
  const dispatch = appStore.getState().dispatch;
8578
8381
  dispatch({
8579
8382
  type: "setUi",
@@ -8586,110 +8389,20 @@ var usePreviewModeHotkeys = () => {
8586
8389
  useHotkey({ ctrl: true, i: true }, toggleInteractive);
8587
8390
  };
8588
8391
 
8589
- // lib/use-puck.ts
8590
- init_react_import();
8591
- var import_react55 = require("react");
8592
- var import_zustand6 = require("zustand");
8593
- var generateUsePuck = (store) => {
8594
- const history = {
8595
- back: store.history.back,
8596
- forward: store.history.forward,
8597
- setHistories: store.history.setHistories,
8598
- setHistoryIndex: store.history.setHistoryIndex,
8599
- hasPast: store.history.hasPast(),
8600
- hasFuture: store.history.hasFuture(),
8601
- histories: store.history.histories,
8602
- index: store.history.index
8603
- };
8604
- const storeData = {
8605
- appState: makeStatePublic(store.state),
8606
- config: store.config,
8607
- dispatch: store.dispatch,
8608
- getPermissions: store.permissions.getPermissions,
8609
- refreshPermissions: store.permissions.refreshPermissions,
8610
- history,
8611
- selectedItem: store.selectedItem || null,
8612
- getItemBySelector: (selector) => getItem(selector, store.state),
8613
- getItemById: (id) => store.state.indexes.nodes[id].data,
8614
- getSelectorForId: (id) => getSelectorForId(store.state, id)
8615
- };
8616
- return storeData;
8617
- };
8618
- var UsePuckStoreContext = (0, import_react55.createContext)(
8619
- null
8620
- );
8621
- var convertToPickedStore = (store) => {
8622
- return {
8623
- state: store.state,
8624
- config: store.config,
8625
- dispatch: store.dispatch,
8626
- permissions: store.permissions,
8627
- history: store.history,
8628
- selectedItem: store.selectedItem
8629
- };
8630
- };
8631
- var useRegisterUsePuckStore = (appStore) => {
8632
- const [usePuckStore] = (0, import_react55.useState)(
8633
- () => (0, import_zustand6.createStore)(
8634
- () => generateUsePuck(convertToPickedStore(appStore.getState()))
8635
- )
8636
- );
8637
- (0, import_react55.useEffect)(() => {
8638
- return appStore.subscribe(
8639
- (store) => convertToPickedStore(store),
8640
- (pickedStore) => {
8641
- usePuckStore.setState(generateUsePuck(pickedStore));
8642
- }
8643
- );
8644
- }, []);
8645
- return usePuckStore;
8646
- };
8647
- function createUsePuck() {
8648
- return function usePuck2(selector) {
8649
- const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
8650
- if (!usePuckApi) {
8651
- throw new Error("usePuck must be used inside <Puck>.");
8652
- }
8653
- const result = (0, import_zustand6.useStore)(
8654
- usePuckApi,
8655
- selector != null ? selector : (s) => s
8656
- );
8657
- return result;
8658
- };
8659
- }
8660
- function usePuck() {
8661
- (0, import_react55.useEffect)(() => {
8662
- console.warn(
8663
- "You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
8664
- );
8665
- }, []);
8666
- return createUsePuck()((s) => s);
8667
- }
8668
- function useGetPuck() {
8669
- const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
8670
- if (!usePuckApi) {
8671
- throw new Error("usePuckGet must be used inside <Puck>.");
8672
- }
8673
- return usePuckApi.getState;
8674
- }
8675
-
8676
- // components/Puck/index.tsx
8677
- var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
8678
-
8679
8392
  // components/Puck/components/Header/index.tsx
8680
8393
  init_react_import();
8681
- var import_react56 = require("react");
8394
+ var import_react52 = require("react");
8682
8395
 
8683
8396
  // components/MenuBar/index.tsx
8684
8397
  init_react_import();
8685
8398
 
8686
8399
  // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
8687
8400
  init_react_import();
8688
- var styles_module_default22 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
8401
+ var styles_module_default21 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
8689
8402
 
8690
8403
  // components/MenuBar/index.tsx
8691
- var import_jsx_runtime42 = require("react/jsx-runtime");
8692
- var getClassName27 = get_class_name_factory_default("MenuBar", styles_module_default22);
8404
+ var import_jsx_runtime38 = require("react/jsx-runtime");
8405
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
8693
8406
  function MenuBar({
8694
8407
  menuOpen = false,
8695
8408
  renderHeaderActions,
@@ -8699,10 +8412,10 @@ function MenuBar({
8699
8412
  const forward = useAppStore((s) => s.history.forward);
8700
8413
  const hasFuture = useAppStore((s) => s.history.hasFuture());
8701
8414
  const hasPast = useAppStore((s) => s.history.hasPast());
8702
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8415
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8703
8416
  "div",
8704
8417
  {
8705
- className: getClassName27({ menuOpen }),
8418
+ className: getClassName26({ menuOpen }),
8706
8419
  onClick: (event) => {
8707
8420
  var _a;
8708
8421
  const element = event.target;
@@ -8713,30 +8426,30 @@ function MenuBar({
8713
8426
  setMenuOpen(false);
8714
8427
  }
8715
8428
  },
8716
- children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("inner"), children: [
8717
- /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("history"), children: [
8718
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8429
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName26("inner"), children: [
8430
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName26("history"), children: [
8431
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8719
8432
  IconButton,
8720
8433
  {
8721
8434
  type: "button",
8722
8435
  title: "undo",
8723
8436
  disabled: !hasPast,
8724
8437
  onClick: back,
8725
- children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Undo2, { size: 21 })
8438
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Undo2, { size: 21 })
8726
8439
  }
8727
8440
  ),
8728
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8441
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8729
8442
  IconButton,
8730
8443
  {
8731
8444
  type: "button",
8732
8445
  title: "redo",
8733
8446
  disabled: !hasFuture,
8734
8447
  onClick: forward,
8735
- children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Redo2, { size: 21 })
8448
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Redo2, { size: 21 })
8736
8449
  }
8737
8450
  )
8738
8451
  ] }),
8739
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: renderHeaderActions && renderHeaderActions() })
8452
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children: renderHeaderActions && renderHeaderActions() })
8740
8453
  ] })
8741
8454
  }
8742
8455
  );
@@ -8744,11 +8457,11 @@ function MenuBar({
8744
8457
 
8745
8458
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
8746
8459
  init_react_import();
8747
- var styles_module_default23 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
8460
+ var styles_module_default22 = { "PuckHeader": "_PuckHeader_1bhmt_1", "PuckHeader-inner": "_PuckHeader-inner_1bhmt_16", "PuckHeader-toggle": "_PuckHeader-toggle_1bhmt_32", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_1bhmt_39", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_1bhmt_39", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_1bhmt_40", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_1bhmt_40", "PuckHeader-title": "_PuckHeader-title_1bhmt_56", "PuckHeader-path": "_PuckHeader-path_1bhmt_60", "PuckHeader-tools": "_PuckHeader-tools_1bhmt_67", "PuckHeader-menuButton": "_PuckHeader-menuButton_1bhmt_73", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_1bhmt_78" };
8748
8461
 
8749
8462
  // components/Puck/components/Header/index.tsx
8750
- var import_jsx_runtime43 = require("react/jsx-runtime");
8751
- var getClassName28 = get_class_name_factory_default("PuckHeader", styles_module_default23);
8463
+ var import_jsx_runtime39 = require("react/jsx-runtime");
8464
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
8752
8465
  var HeaderInner = () => {
8753
8466
  const {
8754
8467
  onPublish,
@@ -8760,7 +8473,7 @@ var HeaderInner = () => {
8760
8473
  } = usePropsContext();
8761
8474
  const dispatch = useAppStore((s) => s.dispatch);
8762
8475
  const appStore = useAppStoreApi();
8763
- const defaultHeaderRender = (0, import_react56.useMemo)(() => {
8476
+ const defaultHeaderRender = (0, import_react52.useMemo)(() => {
8764
8477
  if (renderHeader) {
8765
8478
  console.warn(
8766
8479
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -8769,13 +8482,13 @@ var HeaderInner = () => {
8769
8482
  var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8770
8483
  const Comp = renderHeader;
8771
8484
  const appState = useAppStore((s) => s.state);
8772
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8485
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8773
8486
  };
8774
8487
  return RenderHeader;
8775
8488
  }
8776
8489
  return DefaultOverride;
8777
8490
  }, [renderHeader]);
8778
- const defaultHeaderActionsRender = (0, import_react56.useMemo)(() => {
8491
+ const defaultHeaderActionsRender = (0, import_react52.useMemo)(() => {
8779
8492
  if (renderHeaderActions) {
8780
8493
  console.warn(
8781
8494
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -8783,7 +8496,7 @@ var HeaderInner = () => {
8783
8496
  const RenderHeader = (props) => {
8784
8497
  const Comp = renderHeaderActions;
8785
8498
  const appState = useAppStore((s) => s.state);
8786
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8499
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8787
8500
  };
8788
8501
  return RenderHeader;
8789
8502
  }
@@ -8795,7 +8508,7 @@ var HeaderInner = () => {
8795
8508
  const CustomHeaderActions = useAppStore(
8796
8509
  (s) => s.overrides.headerActions || defaultHeaderActionsRender
8797
8510
  );
8798
- const [menuOpen, setMenuOpen] = (0, import_react56.useState)(false);
8511
+ const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
8799
8512
  const rootTitle = useAppStore((s) => {
8800
8513
  var _a, _b;
8801
8514
  const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
@@ -8805,7 +8518,7 @@ var HeaderInner = () => {
8805
8518
  const rightSideBarVisible = useAppStore(
8806
8519
  (s) => s.state.ui.rightSideBarVisible
8807
8520
  );
8808
- const toggleSidebars = (0, import_react56.useCallback)(
8521
+ const toggleSidebars = (0, import_react52.useCallback)(
8809
8522
  (sidebar) => {
8810
8523
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8811
8524
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -8819,27 +8532,27 @@ var HeaderInner = () => {
8819
8532
  },
8820
8533
  [dispatch, leftSideBarVisible, rightSideBarVisible]
8821
8534
  );
8822
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
8535
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8823
8536
  CustomHeader,
8824
8537
  {
8825
- actions: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_jsx_runtime43.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
8538
+ actions: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8826
8539
  Button,
8827
8540
  {
8828
8541
  onClick: () => {
8829
8542
  const data = appStore.getState().state.data;
8830
8543
  onPublish && onPublish(data);
8831
8544
  },
8832
- icon: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Globe, { size: "14px" }),
8545
+ icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
8833
8546
  children: "Publish"
8834
8547
  }
8835
8548
  ) }) }),
8836
- children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
8549
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8837
8550
  "header",
8838
8551
  {
8839
- className: getClassName28({ leftSideBarVisible, rightSideBarVisible }),
8840
- children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName28("inner"), children: [
8841
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName28("toggle"), children: [
8842
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
8552
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
8553
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName27("inner"), children: [
8554
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName27("toggle"), children: [
8555
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8843
8556
  IconButton,
8844
8557
  {
8845
8558
  type: "button",
@@ -8847,10 +8560,10 @@ var HeaderInner = () => {
8847
8560
  toggleSidebars("left");
8848
8561
  },
8849
8562
  title: "Toggle left sidebar",
8850
- children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PanelLeft, { focusable: "false" })
8563
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
8851
8564
  }
8852
8565
  ) }),
8853
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
8566
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8854
8567
  IconButton,
8855
8568
  {
8856
8569
  type: "button",
@@ -8858,19 +8571,19 @@ var HeaderInner = () => {
8858
8571
  toggleSidebars("right");
8859
8572
  },
8860
8573
  title: "Toggle right sidebar",
8861
- children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PanelRight, { focusable: "false" })
8574
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
8862
8575
  }
8863
8576
  ) })
8864
8577
  ] }),
8865
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("title"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Heading, { rank: "2", size: "xs", children: [
8578
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
8866
8579
  headerTitle || rootTitle || "Page",
8867
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
8580
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
8868
8581
  " ",
8869
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("code", { className: getClassName28("path"), children: headerPath })
8582
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("code", { className: getClassName27("path"), children: headerPath })
8870
8583
  ] })
8871
8584
  ] }) }),
8872
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName28("tools"), children: [
8873
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
8585
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName27("tools"), children: [
8586
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8874
8587
  IconButton,
8875
8588
  {
8876
8589
  type: "button",
@@ -8878,23 +8591,23 @@ var HeaderInner = () => {
8878
8591
  return setMenuOpen(!menuOpen);
8879
8592
  },
8880
8593
  title: "Toggle menu bar",
8881
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ChevronDown, { focusable: "false" })
8594
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
8882
8595
  }
8883
8596
  ) }),
8884
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
8597
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8885
8598
  MenuBar,
8886
8599
  {
8887
8600
  dispatch,
8888
8601
  onPublish,
8889
8602
  menuOpen,
8890
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
8603
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
8891
8604
  Button,
8892
8605
  {
8893
8606
  onClick: () => {
8894
8607
  const data = appStore.getState().state.data;
8895
8608
  onPublish && onPublish(data);
8896
8609
  },
8897
- icon: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Globe, { size: "14px" }),
8610
+ icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
8898
8611
  children: "Publish"
8899
8612
  }
8900
8613
  ) }),
@@ -8908,22 +8621,603 @@ var HeaderInner = () => {
8908
8621
  }
8909
8622
  );
8910
8623
  };
8911
- var Header = (0, import_react56.memo)(HeaderInner);
8624
+ var Header = (0, import_react52.memo)(HeaderInner);
8625
+
8626
+ // components/SidebarSection/index.tsx
8627
+ init_react_import();
8628
+
8629
+ // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
8630
+ init_react_import();
8631
+ var styles_module_default23 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
8632
+
8633
+ // components/Breadcrumbs/index.tsx
8634
+ init_react_import();
8635
+
8636
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Breadcrumbs/styles.module.css#css-module
8637
+ init_react_import();
8638
+ var styles_module_default24 = { "Breadcrumbs": "_Breadcrumbs_1c9yh_1", "Breadcrumbs-breadcrumbLabel": "_Breadcrumbs-breadcrumbLabel_1c9yh_7", "Breadcrumbs-breadcrumb": "_Breadcrumbs-breadcrumb_1c9yh_7" };
8639
+
8640
+ // lib/use-breadcrumbs.ts
8641
+ init_react_import();
8642
+ var import_react53 = require("react");
8643
+ var useBreadcrumbs = (renderCount) => {
8644
+ const selectedId = useAppStore((s) => {
8645
+ var _a;
8646
+ return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
8647
+ });
8648
+ const config = useAppStore((s) => s.config);
8649
+ const path = useAppStore((s) => {
8650
+ var _a;
8651
+ return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
8652
+ });
8653
+ const appStore = useAppStoreApi();
8654
+ return (0, import_react53.useMemo)(() => {
8655
+ const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
8656
+ var _a, _b, _c;
8657
+ const [componentId] = zoneCompound.split(":");
8658
+ if (componentId === "root") {
8659
+ return {
8660
+ label: "Page",
8661
+ selector: null
8662
+ };
8663
+ }
8664
+ const node = appStore.getState().state.indexes.nodes[componentId];
8665
+ const parentId = node.path[node.path.length - 1];
8666
+ const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
8667
+ const index = contentIds.indexOf(componentId);
8668
+ const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
8669
+ return {
8670
+ label,
8671
+ selector: node ? {
8672
+ index,
8673
+ zone: node.path[node.path.length - 1]
8674
+ } : null
8675
+ };
8676
+ })) || [];
8677
+ if (renderCount) {
8678
+ return breadcrumbs.slice(breadcrumbs.length - renderCount);
8679
+ }
8680
+ return breadcrumbs;
8681
+ }, [path, renderCount]);
8682
+ };
8683
+
8684
+ // components/Breadcrumbs/index.tsx
8685
+ var import_jsx_runtime40 = require("react/jsx-runtime");
8686
+ var getClassName28 = get_class_name_factory_default("Breadcrumbs", styles_module_default24);
8687
+ var Breadcrumbs = ({
8688
+ children,
8689
+ numParents = 1
8690
+ }) => {
8691
+ const setUi = useAppStore((s) => s.setUi);
8692
+ const breadcrumbs = useBreadcrumbs(numParents);
8693
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName28(), children: [
8694
+ breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName28("breadcrumb"), children: [
8695
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8696
+ "button",
8697
+ {
8698
+ type: "button",
8699
+ className: getClassName28("breadcrumbLabel"),
8700
+ onClick: () => setUi({ itemSelector: breadcrumb.selector }),
8701
+ children: breadcrumb.label
8702
+ }
8703
+ ),
8704
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ChevronRight, { size: 16 })
8705
+ ] }, i)),
8706
+ children
8707
+ ] });
8708
+ };
8709
+
8710
+ // components/SidebarSection/index.tsx
8711
+ var import_jsx_runtime41 = require("react/jsx-runtime");
8712
+ var getClassName29 = get_class_name_factory_default("SidebarSection", styles_module_default23);
8713
+ var SidebarSection = ({
8714
+ children,
8715
+ title,
8716
+ background,
8717
+ showBreadcrumbs,
8718
+ noBorderTop,
8719
+ noPadding,
8720
+ isLoading
8721
+ }) => {
8722
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
8723
+ "div",
8724
+ {
8725
+ className: getClassName29({ noBorderTop, noPadding }),
8726
+ style: { background },
8727
+ children: [
8728
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName29("title"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName29("breadcrumbs"), children: [
8729
+ showBreadcrumbs && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Breadcrumbs, {}),
8730
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName29("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
8731
+ ] }) }),
8732
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName29("content"), children }),
8733
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName29("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Loader, { size: 32 }) })
8734
+ ]
8735
+ }
8736
+ );
8737
+ };
8738
+
8739
+ // components/Puck/components/Canvas/index.tsx
8740
+ init_react_import();
8741
+ var import_react56 = require("react");
8742
+
8743
+ // components/ViewportControls/index.tsx
8744
+ init_react_import();
8745
+ var import_react54 = require("react");
8746
+
8747
+ // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
8748
+ init_react_import();
8749
+ var styles_module_default25 = { "ViewportControls": "_ViewportControls_e3unb_1", "ViewportControls--fullScreen": "_ViewportControls--fullScreen_e3unb_5", "ViewportControls-toggleButton": "_ViewportControls-toggleButton_e3unb_14", "ViewportControls--isExpanded": "_ViewportControls--isExpanded_e3unb_38", "ViewportControls-actions": "_ViewportControls-actions_e3unb_42", "ViewportControls-actionsInner": "_ViewportControls-actionsInner_e3unb_46", "ViewportControls-divider": "_ViewportControls-divider_e3unb_75", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_e3unb_81", "ViewportControls-zoom": "_ViewportControls-zoom_e3unb_81", "ViewportButton-inner": "_ViewportButton-inner_e3unb_111", "ViewportButton--isActive": "_ViewportButton--isActive_e3unb_119" };
8750
+
8751
+ // components/ViewportControls/index.tsx
8752
+ var import_jsx_runtime42 = require("react/jsx-runtime");
8753
+ var icons = {
8754
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Smartphone, { size: 16 }),
8755
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Tablet, { size: 16 }),
8756
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Monitor, { size: 16 }),
8757
+ FullWidth: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Expand, { size: 16 })
8758
+ };
8759
+ var getClassName30 = get_class_name_factory_default("ViewportControls", styles_module_default25);
8760
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default25);
8761
+ var ActionButton = ({
8762
+ children,
8763
+ title,
8764
+ onClick,
8765
+ isActive,
8766
+ disabled
8767
+ }) => {
8768
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: getClassNameButton({ isActive }), suppressHydrationWarning: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8769
+ IconButton,
8770
+ {
8771
+ type: "button",
8772
+ title,
8773
+ disabled: disabled || isActive,
8774
+ onClick,
8775
+ suppressHydrationWarning: true,
8776
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: getClassNameButton("inner"), children })
8777
+ }
8778
+ ) });
8779
+ };
8780
+ var defaultZoomOptions = [
8781
+ { label: "25%", value: 0.25 },
8782
+ { label: "50%", value: 0.5 },
8783
+ { label: "75%", value: 0.75 },
8784
+ { label: "100%", value: 1 },
8785
+ { label: "125%", value: 1.25 },
8786
+ { label: "150%", value: 1.5 },
8787
+ { label: "200%", value: 2 }
8788
+ ];
8789
+ var ViewportControls = ({
8790
+ autoZoom,
8791
+ zoom,
8792
+ onViewportChange,
8793
+ onZoom,
8794
+ fullScreen
8795
+ }) => {
8796
+ var _a, _b;
8797
+ const viewports = useAppStore((s) => s.viewports);
8798
+ const uiViewports = useAppStore((s) => s.state.ui.viewports);
8799
+ const defaultsContainAutoZoom = defaultZoomOptions.find(
8800
+ (option) => option.value === autoZoom
8801
+ );
8802
+ const zoomOptions = (0, import_react54.useMemo)(
8803
+ () => [
8804
+ ...defaultZoomOptions,
8805
+ ...defaultsContainAutoZoom ? [] : [
8806
+ {
8807
+ value: autoZoom,
8808
+ label: `${(autoZoom * 100).toFixed(0)}% (Auto)`
8809
+ }
8810
+ ]
8811
+ ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
8812
+ [autoZoom]
8813
+ );
8814
+ const [activeViewport, setActiveViewport] = (0, import_react54.useState)(
8815
+ uiViewports.current.width
8816
+ );
8817
+ (0, import_react54.useEffect)(() => {
8818
+ setActiveViewport(uiViewports.current.width);
8819
+ }, [uiViewports.current]);
8820
+ const [isExpanded, setIsExpanded] = (0, import_react54.useState)(false);
8821
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
8822
+ "div",
8823
+ {
8824
+ className: getClassName30({ isExpanded, fullScreen }),
8825
+ suppressHydrationWarning: true,
8826
+ children: [
8827
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName30("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName30("actionsInner"), children: [
8828
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8829
+ ActionButton,
8830
+ {
8831
+ title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
8832
+ onClick: () => {
8833
+ setActiveViewport(viewport.width);
8834
+ onViewportChange(viewport);
8835
+ },
8836
+ isActive: activeViewport === viewport.width,
8837
+ children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
8838
+ },
8839
+ i
8840
+ )),
8841
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName30("divider") }),
8842
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8843
+ ActionButton,
8844
+ {
8845
+ title: "Zoom viewport out",
8846
+ disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
8847
+ onClick: (e) => {
8848
+ e.stopPropagation();
8849
+ onZoom(
8850
+ zoomOptions[Math.max(
8851
+ zoomOptions.findIndex((option) => option.value === zoom) - 1,
8852
+ 0
8853
+ )].value
8854
+ );
8855
+ },
8856
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ZoomOut, { size: 16 })
8857
+ }
8858
+ ),
8859
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8860
+ ActionButton,
8861
+ {
8862
+ title: "Zoom viewport in",
8863
+ disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
8864
+ onClick: (e) => {
8865
+ e.stopPropagation();
8866
+ onZoom(
8867
+ zoomOptions[Math.min(
8868
+ zoomOptions.findIndex((option) => option.value === zoom) + 1,
8869
+ zoomOptions.length - 1
8870
+ )].value
8871
+ );
8872
+ },
8873
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ZoomIn, { size: 16 })
8874
+ }
8875
+ ),
8876
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName30("zoom"), children: [
8877
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName30("divider") }),
8878
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8879
+ "select",
8880
+ {
8881
+ className: getClassName30("zoomSelect"),
8882
+ value: zoom.toString(),
8883
+ onClick: (e) => {
8884
+ e.stopPropagation();
8885
+ },
8886
+ onChange: (e) => {
8887
+ onZoom(parseFloat(e.currentTarget.value));
8888
+ },
8889
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8890
+ "option",
8891
+ {
8892
+ value: option.value,
8893
+ label: option.label
8894
+ },
8895
+ option.label
8896
+ ))
8897
+ }
8898
+ )
8899
+ ] })
8900
+ ] }) }),
8901
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8902
+ "button",
8903
+ {
8904
+ className: getClassName30("toggleButton"),
8905
+ title: "Toggle viewport menu",
8906
+ onClick: () => setIsExpanded((s) => !s),
8907
+ children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(X, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Monitor, { size: 16 })
8908
+ }
8909
+ )
8910
+ ]
8911
+ }
8912
+ );
8913
+ };
8914
+
8915
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
8916
+ init_react_import();
8917
+ var styles_module_default26 = { "PuckCanvas": "_PuckCanvas_t6s9b_1", "PuckCanvas-controls": "_PuckCanvas-controls_t6s9b_17", "PuckCanvas--fullScreen": "_PuckCanvas--fullScreen_t6s9b_22", "PuckCanvas-inner": "_PuckCanvas-inner_t6s9b_33", "PuckCanvas-root": "_PuckCanvas-root_t6s9b_42", "PuckCanvas--ready": "_PuckCanvas--ready_t6s9b_67", "PuckCanvas-loader": "_PuckCanvas-loader_t6s9b_72", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_t6s9b_82" };
8918
+
8919
+ // components/Puck/components/Canvas/index.tsx
8920
+ var import_shallow8 = require("zustand/react/shallow");
8921
+
8922
+ // lib/frame-context.tsx
8923
+ init_react_import();
8924
+ var import_react55 = require("react");
8925
+ var import_jsx_runtime43 = require("react/jsx-runtime");
8926
+ var FrameContext = (0, import_react55.createContext)(null);
8927
+ var FrameProvider = ({
8928
+ children
8929
+ }) => {
8930
+ const frameRef = (0, import_react55.useRef)(null);
8931
+ const value = (0, import_react55.useMemo)(
8932
+ () => ({
8933
+ frameRef
8934
+ }),
8935
+ []
8936
+ );
8937
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(FrameContext.Provider, { value, children });
8938
+ };
8939
+ var useCanvasFrame = () => {
8940
+ const context = (0, import_react55.useContext)(FrameContext);
8941
+ if (context === null) {
8942
+ throw new Error("useCanvasFrame must be used within a FrameProvider");
8943
+ }
8944
+ return context;
8945
+ };
8946
+
8947
+ // components/Puck/components/Canvas/index.tsx
8948
+ var import_jsx_runtime44 = require("react/jsx-runtime");
8949
+ var getClassName31 = get_class_name_factory_default("PuckCanvas", styles_module_default26);
8950
+ var ZOOM_ON_CHANGE = true;
8951
+ var TRANSITION_DURATION = 150;
8952
+ var Canvas = () => {
8953
+ const { frameRef } = useCanvasFrame();
8954
+ const resetAutoZoom = useResetAutoZoom(frameRef);
8955
+ const { _experimentalFullScreenCanvas } = usePropsContext();
8956
+ const {
8957
+ dispatch,
8958
+ overrides,
8959
+ setUi,
8960
+ zoomConfig,
8961
+ setZoomConfig,
8962
+ status,
8963
+ iframe
8964
+ } = useAppStore(
8965
+ (0, import_shallow8.useShallow)((s) => ({
8966
+ dispatch: s.dispatch,
8967
+ overrides: s.overrides,
8968
+ setUi: s.setUi,
8969
+ zoomConfig: s.zoomConfig,
8970
+ setZoomConfig: s.setZoomConfig,
8971
+ status: s.status,
8972
+ iframe: s.iframe
8973
+ }))
8974
+ );
8975
+ const {
8976
+ leftSideBarVisible,
8977
+ rightSideBarVisible,
8978
+ leftSideBarWidth,
8979
+ rightSideBarWidth,
8980
+ viewports
8981
+ } = useAppStore(
8982
+ (0, import_shallow8.useShallow)((s) => ({
8983
+ leftSideBarVisible: s.state.ui.leftSideBarVisible,
8984
+ rightSideBarVisible: s.state.ui.rightSideBarVisible,
8985
+ leftSideBarWidth: s.state.ui.leftSideBarWidth,
8986
+ rightSideBarWidth: s.state.ui.rightSideBarWidth,
8987
+ viewports: s.state.ui.viewports
8988
+ }))
8989
+ );
8990
+ const [showTransition, setShowTransition] = (0, import_react56.useState)(false);
8991
+ const isResizingRef = (0, import_react56.useRef)(false);
8992
+ const defaultRender = (0, import_react56.useMemo)(() => {
8993
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_jsx_runtime44.Fragment, { children });
8994
+ return PuckDefault;
8995
+ }, []);
8996
+ const CustomPreview = (0, import_react56.useMemo)(
8997
+ () => overrides.preview || defaultRender,
8998
+ [overrides]
8999
+ );
9000
+ const getFrameDimensions = (0, import_react56.useCallback)(() => {
9001
+ if (frameRef.current) {
9002
+ const frame = frameRef.current;
9003
+ const box = getBox(frame);
9004
+ return { width: box.contentBox.width, height: box.contentBox.height };
9005
+ }
9006
+ return { width: 0, height: 0 };
9007
+ }, [frameRef]);
9008
+ (0, import_react56.useEffect)(() => {
9009
+ resetAutoZoom();
9010
+ }, [
9011
+ frameRef,
9012
+ leftSideBarVisible,
9013
+ rightSideBarVisible,
9014
+ leftSideBarWidth,
9015
+ rightSideBarWidth,
9016
+ viewports
9017
+ ]);
9018
+ (0, import_react56.useEffect)(() => {
9019
+ const { height: frameHeight } = getFrameDimensions();
9020
+ if (viewports.current.height === "auto") {
9021
+ setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
9022
+ rootHeight: frameHeight / zoomConfig.zoom
9023
+ }));
9024
+ }
9025
+ }, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
9026
+ (0, import_react56.useEffect)(() => {
9027
+ if (ZOOM_ON_CHANGE) {
9028
+ resetAutoZoom();
9029
+ }
9030
+ }, [viewports.current.width, viewports]);
9031
+ (0, import_react56.useEffect)(() => {
9032
+ if (!frameRef.current) return;
9033
+ const resizeObserver = new ResizeObserver(() => {
9034
+ if (!isResizingRef.current) {
9035
+ resetAutoZoom();
9036
+ }
9037
+ });
9038
+ resizeObserver.observe(frameRef.current);
9039
+ return () => {
9040
+ resizeObserver.disconnect();
9041
+ };
9042
+ }, [frameRef.current]);
9043
+ const [showLoader, setShowLoader] = (0, import_react56.useState)(false);
9044
+ (0, import_react56.useEffect)(() => {
9045
+ setTimeout(() => {
9046
+ setShowLoader(true);
9047
+ }, 500);
9048
+ }, []);
9049
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
9050
+ "div",
9051
+ {
9052
+ className: getClassName31({
9053
+ ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
9054
+ showLoader,
9055
+ fullScreen: _experimentalFullScreenCanvas
9056
+ }),
9057
+ onClick: (e) => {
9058
+ const el = e.target;
9059
+ if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
9060
+ dispatch({
9061
+ type: "setUi",
9062
+ ui: { itemSelector: null },
9063
+ recordHistory: true
9064
+ });
9065
+ }
9066
+ },
9067
+ children: [
9068
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName31("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9069
+ ViewportControls,
9070
+ {
9071
+ fullScreen: _experimentalFullScreenCanvas,
9072
+ autoZoom: zoomConfig.autoZoom,
9073
+ zoom: zoomConfig.zoom,
9074
+ onViewportChange: (viewport) => {
9075
+ setShowTransition(true);
9076
+ isResizingRef.current = true;
9077
+ const uiViewport = __spreadProps(__spreadValues({}, viewport), {
9078
+ height: viewport.height || "auto",
9079
+ zoom: zoomConfig.zoom
9080
+ });
9081
+ const newUi = {
9082
+ viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
9083
+ };
9084
+ setUi(newUi);
9085
+ if (ZOOM_ON_CHANGE) {
9086
+ resetAutoZoom({
9087
+ viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
9088
+ });
9089
+ }
9090
+ },
9091
+ onZoom: (zoom) => {
9092
+ setShowTransition(true);
9093
+ isResizingRef.current = true;
9094
+ setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
9095
+ }
9096
+ }
9097
+ ) }),
9098
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: getClassName31("inner"), ref: frameRef, children: [
9099
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9100
+ "div",
9101
+ {
9102
+ className: getClassName31("root"),
9103
+ style: {
9104
+ width: iframe.enabled ? viewports.current.width : "100%",
9105
+ height: zoomConfig.rootHeight,
9106
+ transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
9107
+ transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
9108
+ overflow: iframe.enabled ? void 0 : "auto"
9109
+ },
9110
+ suppressHydrationWarning: true,
9111
+ id: "puck-canvas-root",
9112
+ onTransitionEnd: () => {
9113
+ setShowTransition(false);
9114
+ isResizingRef.current = false;
9115
+ },
9116
+ children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Preview2, {}) })
9117
+ }
9118
+ ),
9119
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName31("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Loader, { size: 24 }) })
9120
+ ] })
9121
+ ]
9122
+ }
9123
+ );
9124
+ };
9125
+
9126
+ // lib/use-sidebar-resize.ts
9127
+ init_react_import();
9128
+ var import_react57 = require("react");
9129
+ function useSidebarResize(position, dispatch) {
9130
+ const [width, setWidth] = (0, import_react57.useState)(null);
9131
+ const sidebarRef = (0, import_react57.useRef)(null);
9132
+ const storeWidth = useAppStore(
9133
+ (s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
9134
+ );
9135
+ (0, import_react57.useEffect)(() => {
9136
+ if (typeof window !== "undefined" && !storeWidth) {
9137
+ try {
9138
+ const savedWidths = localStorage.getItem("puck-sidebar-widths");
9139
+ if (savedWidths) {
9140
+ const widths = JSON.parse(savedWidths);
9141
+ const savedWidth = widths[position];
9142
+ const key = position === "left" ? "leftSideBarWidth" : "rightSideBarWidth";
9143
+ if (savedWidth) {
9144
+ dispatch({
9145
+ type: "setUi",
9146
+ ui: {
9147
+ [key]: savedWidth
9148
+ }
9149
+ });
9150
+ }
9151
+ }
9152
+ } catch (error) {
9153
+ console.error(
9154
+ `Failed to load ${position} sidebar width from localStorage`,
9155
+ error
9156
+ );
9157
+ }
9158
+ }
9159
+ }, [dispatch, position, storeWidth]);
9160
+ (0, import_react57.useEffect)(() => {
9161
+ if (storeWidth !== void 0) {
9162
+ setWidth(storeWidth);
9163
+ }
9164
+ }, [storeWidth]);
9165
+ const handleResizeEnd = (0, import_react57.useCallback)(
9166
+ (width2) => {
9167
+ dispatch({
9168
+ type: "setUi",
9169
+ ui: {
9170
+ [position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
9171
+ }
9172
+ });
9173
+ let widths = {};
9174
+ try {
9175
+ const savedWidths = localStorage.getItem("puck-sidebar-widths");
9176
+ widths = savedWidths ? JSON.parse(savedWidths) : {};
9177
+ } catch (error) {
9178
+ console.error(
9179
+ `Failed to save ${position} sidebar width to localStorage`,
9180
+ error
9181
+ );
9182
+ } finally {
9183
+ localStorage.setItem(
9184
+ "puck-sidebar-widths",
9185
+ JSON.stringify(__spreadProps(__spreadValues({}, widths), {
9186
+ [position]: width2
9187
+ }))
9188
+ );
9189
+ }
9190
+ window.dispatchEvent(
9191
+ new CustomEvent("viewportchange", {
9192
+ bubbles: true,
9193
+ cancelable: false
9194
+ })
9195
+ );
9196
+ },
9197
+ [dispatch, position]
9198
+ );
9199
+ return {
9200
+ width,
9201
+ setWidth,
9202
+ sidebarRef,
9203
+ handleResizeEnd
9204
+ };
9205
+ }
8912
9206
 
8913
9207
  // components/Puck/components/Sidebar/index.tsx
8914
9208
  init_react_import();
8915
9209
 
8916
9210
  // components/Puck/components/ResizeHandle/index.tsx
8917
9211
  init_react_import();
8918
- var import_react57 = require("react");
9212
+ var import_react58 = require("react");
8919
9213
 
8920
9214
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
8921
9215
  init_react_import();
8922
- var styles_module_default24 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
9216
+ var styles_module_default27 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
8923
9217
 
8924
9218
  // components/Puck/components/ResizeHandle/index.tsx
8925
- var import_jsx_runtime44 = require("react/jsx-runtime");
8926
- var getClassName29 = get_class_name_factory_default("ResizeHandle", styles_module_default24);
9219
+ var import_jsx_runtime45 = require("react/jsx-runtime");
9220
+ var getClassName32 = get_class_name_factory_default("ResizeHandle", styles_module_default27);
8927
9221
  var ResizeHandle = ({
8928
9222
  position,
8929
9223
  sidebarRef,
@@ -8932,11 +9226,11 @@ var ResizeHandle = ({
8932
9226
  }) => {
8933
9227
  const { frameRef } = useCanvasFrame();
8934
9228
  const resetAutoZoom = useResetAutoZoom(frameRef);
8935
- const handleRef = (0, import_react57.useRef)(null);
8936
- const isDragging = (0, import_react57.useRef)(false);
8937
- const startX = (0, import_react57.useRef)(0);
8938
- const startWidth = (0, import_react57.useRef)(0);
8939
- const handleMouseMove = (0, import_react57.useCallback)(
9229
+ const handleRef = (0, import_react58.useRef)(null);
9230
+ const isDragging = (0, import_react58.useRef)(false);
9231
+ const startX = (0, import_react58.useRef)(0);
9232
+ const startWidth = (0, import_react58.useRef)(0);
9233
+ const handleMouseMove = (0, import_react58.useCallback)(
8940
9234
  (e) => {
8941
9235
  if (!isDragging.current) return;
8942
9236
  const delta = e.clientX - startX.current;
@@ -8947,7 +9241,7 @@ var ResizeHandle = ({
8947
9241
  },
8948
9242
  [onResize, position]
8949
9243
  );
8950
- const handleMouseUp = (0, import_react57.useCallback)(() => {
9244
+ const handleMouseUp = (0, import_react58.useCallback)(() => {
8951
9245
  var _a;
8952
9246
  if (!isDragging.current) return;
8953
9247
  isDragging.current = false;
@@ -8963,7 +9257,7 @@ var ResizeHandle = ({
8963
9257
  onResizeEnd(finalWidth);
8964
9258
  resetAutoZoom();
8965
9259
  }, [onResizeEnd]);
8966
- const handleMouseDown = (0, import_react57.useCallback)(
9260
+ const handleMouseDown = (0, import_react58.useCallback)(
8967
9261
  (e) => {
8968
9262
  var _a;
8969
9263
  isDragging.current = true;
@@ -8981,11 +9275,11 @@ var ResizeHandle = ({
8981
9275
  },
8982
9276
  [position, handleMouseMove, handleMouseUp]
8983
9277
  );
8984
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9278
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
8985
9279
  "div",
8986
9280
  {
8987
9281
  ref: handleRef,
8988
- className: getClassName29({ [position]: true }),
9282
+ className: getClassName32({ [position]: true }),
8989
9283
  onMouseDown: handleMouseDown
8990
9284
  }
8991
9285
  );
@@ -8993,11 +9287,11 @@ var ResizeHandle = ({
8993
9287
 
8994
9288
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
8995
9289
  init_react_import();
8996
- var styles_module_default25 = { "Sidebar": "_Sidebar_1xksb_1", "Sidebar--left": "_Sidebar--left_1xksb_8", "Sidebar--right": "_Sidebar--right_1xksb_14", "Sidebar-resizeHandle": "_Sidebar-resizeHandle_1xksb_20" };
9290
+ var styles_module_default28 = { "Sidebar": "_Sidebar_o396p_1", "Sidebar--isVisible": "_Sidebar--isVisible_o396p_9", "Sidebar--left": "_Sidebar--left_o396p_13", "Sidebar--right": "_Sidebar--right_o396p_25", "Sidebar-resizeHandle": "_Sidebar-resizeHandle_o396p_37" };
8997
9291
 
8998
9292
  // components/Puck/components/Sidebar/index.tsx
8999
- var import_jsx_runtime45 = require("react/jsx-runtime");
9000
- var getClassName30 = get_class_name_factory_default("Sidebar", styles_module_default25);
9293
+ var import_jsx_runtime46 = require("react/jsx-runtime");
9294
+ var getClassName33 = get_class_name_factory_default("Sidebar", styles_module_default28);
9001
9295
  var Sidebar = ({
9002
9296
  position,
9003
9297
  sidebarRef,
@@ -9006,10 +9300,16 @@ var Sidebar = ({
9006
9300
  onResizeEnd,
9007
9301
  children
9008
9302
  }) => {
9009
- if (!isVisible) return null;
9010
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
9011
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ref: sidebarRef, className: getClassName30({ [position]: true }), children }),
9012
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: `${getClassName30("resizeHandle")}`, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
9303
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
9304
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9305
+ "div",
9306
+ {
9307
+ ref: sidebarRef,
9308
+ className: getClassName33({ [position]: true, isVisible }),
9309
+ children
9310
+ }
9311
+ ),
9312
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: `${getClassName33("resizeHandle")}`, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9013
9313
  ResizeHandle,
9014
9314
  {
9015
9315
  position,
@@ -9021,105 +9321,415 @@ var Sidebar = ({
9021
9321
  ] });
9022
9322
  };
9023
9323
 
9024
- // lib/use-sidebar-resize.ts
9324
+ // lib/use-delete-hotkeys.ts
9025
9325
  init_react_import();
9026
- var import_react58 = require("react");
9027
- function useSidebarResize(position, dispatch) {
9028
- const [width, setWidth] = (0, import_react58.useState)(null);
9029
- const sidebarRef = (0, import_react58.useRef)(null);
9030
- const storeWidth = useAppStore(
9031
- (s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
9326
+ var import_react59 = require("react");
9327
+ var isElementVisible = (element) => {
9328
+ let current = element;
9329
+ while (current && current !== document.body) {
9330
+ const style = window.getComputedStyle(current);
9331
+ if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
9332
+ return false;
9333
+ }
9334
+ current = current.parentElement;
9335
+ }
9336
+ return true;
9337
+ };
9338
+ var shouldBlockDeleteHotkey = (e) => {
9339
+ var _a;
9340
+ if (e == null ? void 0 : e.defaultPrevented) return true;
9341
+ const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
9342
+ if (origin instanceof HTMLElement) {
9343
+ const tag = origin.tagName.toLowerCase();
9344
+ if (tag === "input" || tag === "textarea" || tag === "select") return true;
9345
+ if (origin.isContentEditable) return true;
9346
+ const role = origin.getAttribute("role");
9347
+ if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
9348
+ return true;
9349
+ }
9350
+ }
9351
+ const modal = document.querySelector(
9352
+ 'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
9032
9353
  );
9033
- (0, import_react58.useEffect)(() => {
9034
- if (typeof window !== "undefined" && !storeWidth) {
9035
- try {
9036
- const savedWidths = localStorage.getItem("puck-sidebar-widths");
9037
- if (savedWidths) {
9038
- const widths = JSON.parse(savedWidths);
9039
- const savedWidth = widths[position];
9040
- const key = position === "left" ? "leftSideBarWidth" : "rightSideBarWidth";
9041
- if (savedWidth) {
9042
- dispatch({
9043
- type: "setUi",
9044
- ui: {
9045
- [key]: savedWidth
9046
- }
9047
- });
9048
- }
9354
+ if (modal && isElementVisible(modal)) {
9355
+ return true;
9356
+ }
9357
+ return false;
9358
+ };
9359
+ var useDeleteHotkeys = () => {
9360
+ const appStore = useAppStoreApi();
9361
+ const deleteSelectedComponent = (0, import_react59.useCallback)(
9362
+ (e) => {
9363
+ var _a;
9364
+ if (shouldBlockDeleteHotkey(e)) {
9365
+ return false;
9366
+ }
9367
+ const { state, dispatch, permissions, selectedItem } = appStore.getState();
9368
+ const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
9369
+ if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
9370
+ if (!permissions.getPermissions({ item: selectedItem }).delete)
9371
+ return true;
9372
+ dispatch({
9373
+ type: "remove",
9374
+ index: sel.index,
9375
+ zone: sel.zone
9376
+ });
9377
+ return true;
9378
+ },
9379
+ [appStore]
9380
+ );
9381
+ useHotkey({ delete: true }, deleteSelectedComponent);
9382
+ useHotkey({ backspace: true }, deleteSelectedComponent);
9383
+ };
9384
+
9385
+ // components/Puck/components/Nav/index.tsx
9386
+ init_react_import();
9387
+
9388
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Nav/styles.module.css#css-module
9389
+ init_react_import();
9390
+ var styles_module_default29 = { "Nav": "_Nav_3nnxc_1", "Nav-list": "_Nav-list_3nnxc_5", "Nav-mobileActions": "_Nav-mobileActions_3nnxc_23", "NavItem-link": "_NavItem-link_3nnxc_38", "NavItem": "_NavItem_3nnxc_38", "NavItem-linkIcon": "_NavItem-linkIcon_3nnxc_88", "NavItem--active": "_NavItem--active_3nnxc_93", "NavItem--mobileOnly": "_NavItem--mobileOnly_3nnxc_120" };
9391
+
9392
+ // components/Puck/components/Nav/index.tsx
9393
+ var import_jsx_runtime47 = require("react/jsx-runtime");
9394
+ var getClassName34 = get_class_name_factory_default("Nav", styles_module_default29);
9395
+ var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default29);
9396
+ var MenuItem = ({
9397
+ label,
9398
+ icon,
9399
+ onClick,
9400
+ isActive,
9401
+ mobileOnly
9402
+ }) => {
9403
+ return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("li", { className: getClassNameItem3({ active: isActive, mobileOnly }), children: onClick && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: getClassNameItem3("link"), onClick, children: [
9404
+ icon && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: getClassNameItem3("linkIcon"), children: icon }),
9405
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: getClassNameItem3("linkLabel"), children: label })
9406
+ ] }) });
9407
+ };
9408
+ var Nav = ({
9409
+ items,
9410
+ mobileActions
9411
+ }) => {
9412
+ return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("nav", { className: getClassName34(), children: [
9413
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("ul", { className: getClassName34("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(MenuItem, __spreadValues({}, item), key)) }),
9414
+ mobileActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: getClassName34("mobileActions"), children: mobileActions })
9415
+ ] });
9416
+ };
9417
+
9418
+ // plugins/blocks/index.tsx
9419
+ init_react_import();
9420
+ var import_jsx_runtime48 = require("react/jsx-runtime");
9421
+ var blocksPlugin = () => ({
9422
+ name: "blocks",
9423
+ label: "Blocks",
9424
+ render: Components,
9425
+ icon: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Hammer, {})
9426
+ });
9427
+
9428
+ // plugins/outline/index.tsx
9429
+ init_react_import();
9430
+ var import_jsx_runtime49 = require("react/jsx-runtime");
9431
+ var outlinePlugin = () => ({
9432
+ name: "outline",
9433
+ label: "Outline",
9434
+ render: Outline,
9435
+ icon: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Layers, {})
9436
+ });
9437
+
9438
+ // plugins/fields/index.tsx
9439
+ init_react_import();
9440
+
9441
+ // css-module:/home/runner/work/puck/puck/packages/core/plugins/fields/styles.module.css#css-module
9442
+ init_react_import();
9443
+ var styles_module_default30 = { "FieldsPlugin": "_FieldsPlugin_nd930_1", "FieldsPlugin-header": "_FieldsPlugin-header_nd930_7" };
9444
+
9445
+ // plugins/fields/index.tsx
9446
+ var import_jsx_runtime50 = require("react/jsx-runtime");
9447
+ var getClassName35 = get_class_name_factory_default("FieldsPlugin", styles_module_default30);
9448
+ var CurrentTitle = () => {
9449
+ const label = useAppStore((s) => {
9450
+ var _a, _b;
9451
+ const selectedItem = s.selectedItem;
9452
+ return selectedItem ? (_b = (_a = s.config.components[selectedItem.type]) == null ? void 0 : _a.label) != null ? _b : selectedItem.type : "Page";
9453
+ });
9454
+ return label;
9455
+ };
9456
+ var fieldsPlugin = ({ mobileOnly = true } = {}) => ({
9457
+ name: "fields",
9458
+ label: "Fields",
9459
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: getClassName35(), children: [
9460
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: getClassName35("header"), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Breadcrumbs, { numParents: 2, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(CurrentTitle, {}) }) }),
9461
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Fields, {})
9462
+ ] }),
9463
+ icon: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(RectangleEllipsis, {}),
9464
+ mobileOnly
9465
+ });
9466
+
9467
+ // components/Puck/components/Layout/index.tsx
9468
+ var import_jsx_runtime51 = require("react/jsx-runtime");
9469
+ var getClassName36 = get_class_name_factory_default("Puck", styles_module_default20);
9470
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default20);
9471
+ var getPluginTabClassName = get_class_name_factory_default("PuckPluginTab", styles_module_default20);
9472
+ var FieldSideBar = () => {
9473
+ const title = useAppStore(
9474
+ (s) => {
9475
+ var _a, _b;
9476
+ return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
9477
+ }
9478
+ );
9479
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Fields, {}) });
9480
+ };
9481
+ var PluginTab = ({
9482
+ children,
9483
+ visible,
9484
+ mobileOnly
9485
+ }) => {
9486
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: getPluginTabClassName({ visible, mobileOnly }), children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: getPluginTabClassName("body"), children }) });
9487
+ };
9488
+ var Layout = ({ children }) => {
9489
+ const {
9490
+ iframe: _iframe,
9491
+ dnd,
9492
+ initialHistory: _initialHistory,
9493
+ plugins,
9494
+ height = "100dvh"
9495
+ } = usePropsContext();
9496
+ const iframe = (0, import_react60.useMemo)(
9497
+ () => __spreadValues({
9498
+ enabled: true,
9499
+ waitForStyles: true
9500
+ }, _iframe),
9501
+ [_iframe]
9502
+ );
9503
+ useInjectGlobalCss(iframe.enabled);
9504
+ const dispatch = useAppStore((s) => s.dispatch);
9505
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
9506
+ const rightSideBarVisible = useAppStore(
9507
+ (s) => s.state.ui.rightSideBarVisible
9508
+ );
9509
+ const instanceId = useAppStore((s) => s.instanceId);
9510
+ const {
9511
+ width: leftWidth,
9512
+ setWidth: setLeftWidth,
9513
+ sidebarRef: leftSidebarRef,
9514
+ handleResizeEnd: handleLeftSidebarResizeEnd
9515
+ } = useSidebarResize("left", dispatch);
9516
+ const {
9517
+ width: rightWidth,
9518
+ setWidth: setRightWidth,
9519
+ sidebarRef: rightSidebarRef,
9520
+ handleResizeEnd: handleRightSidebarResizeEnd
9521
+ } = useSidebarResize("right", dispatch);
9522
+ (0, import_react60.useEffect)(() => {
9523
+ if (!window.matchMedia("(min-width: 638px)").matches) {
9524
+ dispatch({
9525
+ type: "setUi",
9526
+ ui: {
9527
+ leftSideBarVisible: false,
9528
+ rightSideBarVisible: false
9529
+ }
9530
+ });
9531
+ }
9532
+ const handleResize = () => {
9533
+ if (!window.matchMedia("(min-width: 638px)").matches) {
9534
+ dispatch({
9535
+ type: "setUi",
9536
+ ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
9537
+ });
9538
+ }
9539
+ };
9540
+ window.addEventListener("resize", handleResize);
9541
+ return () => {
9542
+ window.removeEventListener("resize", handleResize);
9543
+ };
9544
+ }, []);
9545
+ const overrides = useAppStore((s) => s.overrides);
9546
+ const CustomPuck = (0, import_react60.useMemo)(
9547
+ () => overrides.puck || DefaultOverride,
9548
+ [overrides]
9549
+ );
9550
+ const [mounted, setMounted] = (0, import_react60.useState)(false);
9551
+ (0, import_react60.useEffect)(() => {
9552
+ setMounted(true);
9553
+ }, []);
9554
+ const ready = useAppStore((s) => s.status === "READY");
9555
+ useMonitorHotkeys();
9556
+ (0, import_react60.useEffect)(() => {
9557
+ if (ready && iframe.enabled) {
9558
+ const frameDoc = getFrame();
9559
+ if (frameDoc) {
9560
+ return monitorHotkeys(frameDoc);
9561
+ }
9562
+ }
9563
+ }, [ready, iframe.enabled]);
9564
+ usePreviewModeHotkeys();
9565
+ useDeleteHotkeys();
9566
+ const layoutOptions = {};
9567
+ if (leftWidth) {
9568
+ layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
9569
+ }
9570
+ if (rightWidth) {
9571
+ layoutOptions["--puck-user-right-side-bar-width"] = `${rightWidth}px`;
9572
+ }
9573
+ const setUi = useAppStore((s) => s.setUi);
9574
+ const currentPlugin = useAppStore((s) => {
9575
+ var _a;
9576
+ return (_a = s.state.ui.plugin) == null ? void 0 : _a.current;
9577
+ });
9578
+ const appStoreApi = useAppStoreApi();
9579
+ const [mobilePanelHeightMode, setMobilePanelHeightMode] = (0, import_react60.useState)("toggle");
9580
+ const pluginItems = (0, import_react60.useMemo)(() => {
9581
+ const details = {};
9582
+ const defaultPlugins = [blocksPlugin(), outlinePlugin()];
9583
+ const combinedPlugins = [
9584
+ ...defaultPlugins,
9585
+ ...plugins != null ? plugins : []
9586
+ ];
9587
+ if (!(plugins == null ? void 0 : plugins.some((p) => p.name === "fields"))) {
9588
+ combinedPlugins.push(fieldsPlugin());
9589
+ }
9590
+ combinedPlugins == null ? void 0 : combinedPlugins.forEach((plugin) => {
9591
+ var _a, _b;
9592
+ if (plugin.name && plugin.render) {
9593
+ if (details[plugin.name]) {
9594
+ delete details[plugin.name];
9049
9595
  }
9050
- } catch (error) {
9051
- console.error(
9052
- `Failed to load ${position} sidebar width from localStorage`,
9053
- error
9054
- );
9596
+ details[plugin.name] = {
9597
+ label: (_a = plugin.label) != null ? _a : plugin.name,
9598
+ icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ToyBrick, {}),
9599
+ onClick: () => {
9600
+ var _a2;
9601
+ setMobilePanelHeightMode((_a2 = plugin.mobilePanelHeight) != null ? _a2 : "toggle");
9602
+ if (plugin.name === currentPlugin) {
9603
+ if (leftSideBarVisible) {
9604
+ setUi({ leftSideBarVisible: false });
9605
+ } else {
9606
+ setUi({ leftSideBarVisible: true });
9607
+ }
9608
+ } else {
9609
+ if (plugin.name) {
9610
+ setUi({
9611
+ plugin: { current: plugin.name },
9612
+ leftSideBarVisible: true
9613
+ });
9614
+ }
9615
+ }
9616
+ },
9617
+ isActive: leftSideBarVisible && currentPlugin === plugin.name,
9618
+ render: plugin.render,
9619
+ mobileOnly: plugin.mobileOnly
9620
+ };
9055
9621
  }
9622
+ });
9623
+ return details;
9624
+ }, [plugins, currentPlugin, appStoreApi, leftSideBarVisible]);
9625
+ (0, import_react60.useEffect)(() => {
9626
+ if (!currentPlugin) {
9627
+ const names = Object.keys(pluginItems);
9628
+ setUi({ plugin: { current: names[0] } });
9629
+ }
9630
+ }, [pluginItems, currentPlugin]);
9631
+ const hasDesktopFieldsPlugin = pluginItems["fields"] && pluginItems["fields"].mobileOnly === false;
9632
+ const mobilePanelExpanded = useAppStore(
9633
+ (s) => {
9634
+ var _a;
9635
+ return (_a = s.state.ui.mobilePanelExpanded) != null ? _a : false;
9056
9636
  }
9057
- }, [dispatch, position, storeWidth]);
9058
- (0, import_react58.useEffect)(() => {
9059
- if (storeWidth !== void 0) {
9060
- setWidth(storeWidth);
9061
- }
9062
- }, [storeWidth]);
9063
- const handleResizeEnd = (0, import_react58.useCallback)(
9064
- (width2) => {
9065
- dispatch({
9066
- type: "setUi",
9067
- ui: {
9068
- [position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
9069
- }
9070
- });
9071
- let widths = {};
9072
- try {
9073
- const savedWidths = localStorage.getItem("puck-sidebar-widths");
9074
- widths = savedWidths ? JSON.parse(savedWidths) : {};
9075
- } catch (error) {
9076
- console.error(
9077
- `Failed to save ${position} sidebar width to localStorage`,
9078
- error
9079
- );
9080
- } finally {
9081
- localStorage.setItem(
9082
- "puck-sidebar-widths",
9083
- JSON.stringify(__spreadProps(__spreadValues({}, widths), {
9084
- [position]: width2
9085
- }))
9086
- );
9087
- }
9088
- window.dispatchEvent(
9089
- new CustomEvent("viewportchange", {
9090
- bubbles: true,
9091
- cancelable: false
9092
- })
9093
- );
9094
- },
9095
- [dispatch, position]
9096
9637
  );
9097
- return {
9098
- width,
9099
- setWidth,
9100
- sidebarRef,
9101
- handleResizeEnd
9102
- };
9103
- }
9104
-
9105
- // components/Puck/index.tsx
9106
- var import_jsx_runtime46 = require("react/jsx-runtime");
9107
- var getClassName31 = get_class_name_factory_default("Puck", styles_module_default15);
9108
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
9109
- var FieldSideBar = () => {
9110
- const title = useAppStore(
9111
- (s) => {
9112
- var _a, _b;
9113
- return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
9638
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
9639
+ "div",
9640
+ {
9641
+ className: `Puck ${getClassName36()}`,
9642
+ style: { height },
9643
+ id: instanceId,
9644
+ children: [
9645
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(FrameProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
9646
+ "div",
9647
+ {
9648
+ className: getLayoutClassName({
9649
+ leftSideBarVisible,
9650
+ mounted,
9651
+ rightSideBarVisible: !hasDesktopFieldsPlugin && rightSideBarVisible,
9652
+ isExpanded: mobilePanelExpanded,
9653
+ mobilePanelHeightToggle: mobilePanelHeightMode === "toggle",
9654
+ mobilePanelHeightMinContent: mobilePanelHeightMode === "min-content"
9655
+ }),
9656
+ children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
9657
+ "div",
9658
+ {
9659
+ className: getLayoutClassName("inner"),
9660
+ style: layoutOptions,
9661
+ children: [
9662
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Header, {}) }),
9663
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: getLayoutClassName("nav"), children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
9664
+ Nav,
9665
+ {
9666
+ items: pluginItems,
9667
+ mobileActions: leftSideBarVisible && mobilePanelHeightMode === "toggle" && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
9668
+ IconButton,
9669
+ {
9670
+ type: "button",
9671
+ title: "maximize",
9672
+ onClick: () => {
9673
+ setUi({
9674
+ mobilePanelExpanded: !mobilePanelExpanded
9675
+ });
9676
+ },
9677
+ children: mobilePanelExpanded ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Minimize2, { size: 21 }) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Maximize2, { size: 21 })
9678
+ }
9679
+ )
9680
+ }
9681
+ ) }),
9682
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
9683
+ Sidebar,
9684
+ {
9685
+ position: "left",
9686
+ sidebarRef: leftSidebarRef,
9687
+ isVisible: leftSideBarVisible,
9688
+ onResize: setLeftWidth,
9689
+ onResizeEnd: handleLeftSidebarResizeEnd,
9690
+ children: Object.entries(pluginItems).map(
9691
+ ([id, { mobileOnly, render: Render2, label }]) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
9692
+ PluginTab,
9693
+ {
9694
+ visible: currentPlugin === id,
9695
+ mobileOnly,
9696
+ children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Render2, {})
9697
+ },
9698
+ id
9699
+ )
9700
+ )
9701
+ }
9702
+ ),
9703
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Canvas, {}),
9704
+ !hasDesktopFieldsPlugin && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
9705
+ Sidebar,
9706
+ {
9707
+ position: "right",
9708
+ sidebarRef: rightSidebarRef,
9709
+ isVisible: rightSideBarVisible,
9710
+ onResize: setRightWidth,
9711
+ onResizeEnd: handleRightSidebarResizeEnd,
9712
+ children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(FieldSideBar, {})
9713
+ }
9714
+ )
9715
+ ]
9716
+ }
9717
+ )
9718
+ }
9719
+ ) }) }) }),
9720
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { id: "puck-portal-root", className: getClassName36("portal") })
9721
+ ]
9114
9722
  }
9115
9723
  );
9116
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Fields, {}) });
9117
9724
  };
9118
- var propsContext = (0, import_react59.createContext)({});
9725
+
9726
+ // components/Puck/index.tsx
9727
+ var import_jsx_runtime52 = require("react/jsx-runtime");
9728
+ var propsContext = (0, import_react61.createContext)({});
9119
9729
  function PropsProvider(props) {
9120
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(propsContext.Provider, { value: props, children: props.children });
9730
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(propsContext.Provider, { value: props, children: props.children });
9121
9731
  }
9122
- var usePropsContext = () => (0, import_react59.useContext)(propsContext);
9732
+ var usePropsContext = () => (0, import_react61.useContext)(propsContext);
9123
9733
  function PuckProvider({ children }) {
9124
9734
  const {
9125
9735
  config,
@@ -9136,15 +9746,15 @@ function PuckProvider({ children }) {
9136
9746
  onAction,
9137
9747
  fieldTransforms
9138
9748
  } = usePropsContext();
9139
- const iframe = (0, import_react59.useMemo)(
9749
+ const iframe = (0, import_react61.useMemo)(
9140
9750
  () => __spreadValues({
9141
9751
  enabled: true,
9142
9752
  waitForStyles: true
9143
9753
  }, _iframe),
9144
9754
  [_iframe]
9145
9755
  );
9146
- const [generatedAppState] = (0, import_react59.useState)(() => {
9147
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
9756
+ const [generatedAppState] = (0, import_react61.useState)(() => {
9757
+ var _a, _b, _c, _d, _e, _f, _g;
9148
9758
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
9149
9759
  let clientUiState = {};
9150
9760
  if (typeof window !== "undefined") {
@@ -9155,32 +9765,46 @@ function PuckProvider({ children }) {
9155
9765
  });
9156
9766
  }
9157
9767
  const viewportWidth = window.innerWidth;
9158
- const viewportDifferences = Object.entries(viewports).map(([key, value]) => ({
9768
+ const fullWidthViewport = Object.values(viewports).find(
9769
+ (v) => v.width === "100%"
9770
+ );
9771
+ const containsFullWidthViewport = !!fullWidthViewport;
9772
+ const viewportDifferences = Object.entries(viewports).filter(([_, value]) => value.width !== "100%").map(([key, value]) => ({
9159
9773
  key,
9160
- diff: Math.abs(viewportWidth - value.width)
9774
+ diff: Math.abs(
9775
+ viewportWidth - (typeof value.width === "string" ? viewportWidth : value.width)
9776
+ ),
9777
+ value
9161
9778
  })).sort((a, b) => a.diff > b.diff ? 1 : -1);
9162
- const closestViewport = viewportDifferences[0].key;
9779
+ let closestViewport = viewportDifferences[0].value;
9780
+ if (closestViewport.width < viewportWidth && containsFullWidthViewport) {
9781
+ closestViewport = fullWidthViewport;
9782
+ }
9163
9783
  if (iframe.enabled) {
9164
9784
  clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
9165
9785
  viewports: __spreadProps(__spreadValues({}, initial.viewports), {
9166
9786
  current: __spreadProps(__spreadValues({}, initial.viewports.current), {
9167
- height: ((_b = (_a = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a.current) == null ? void 0 : _b.height) || ((_c = viewports[closestViewport]) == null ? void 0 : _c.height) || "auto",
9168
- width: ((_e = (_d = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _d.current) == null ? void 0 : _e.width) || ((_f = viewports[closestViewport]) == null ? void 0 : _f.width)
9787
+ height: ((_b = (_a = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a.current) == null ? void 0 : _b.height) || (closestViewport == null ? void 0 : closestViewport.height) || "auto",
9788
+ width: ((_d = (_c = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _c.current) == null ? void 0 : _d.width) || (closestViewport == null ? void 0 : closestViewport.width)
9169
9789
  })
9170
9790
  })
9171
9791
  });
9172
9792
  }
9173
9793
  }
9174
- if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
9794
+ if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_e = initialData == null ? void 0 : initialData.root) == null ? void 0 : _e.props)) {
9175
9795
  console.warn(
9176
9796
  "Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
9177
9797
  );
9178
9798
  }
9179
- const rootProps = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
9180
- const defaultedRootProps = __spreadValues(__spreadValues({}, (_i = config.root) == null ? void 0 : _i.defaultProps), rootProps);
9799
+ const rootProps = ((_f = initialData == null ? void 0 : initialData.root) == null ? void 0 : _f.props) || (initialData == null ? void 0 : initialData.root) || {};
9800
+ const defaultedRootProps = __spreadValues(__spreadValues({}, (_g = config.root) == null ? void 0 : _g.defaultProps), rootProps);
9801
+ const root = populateIds(
9802
+ toComponent(__spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps })),
9803
+ config
9804
+ );
9181
9805
  const newAppState = __spreadProps(__spreadValues({}, defaultAppState), {
9182
9806
  data: __spreadProps(__spreadValues({}, initialData), {
9183
- root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
9807
+ root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: root.props }),
9184
9808
  content: initialData.content || []
9185
9809
  }),
9186
9810
  ui: __spreadProps(__spreadValues(__spreadValues({}, initial), clientUiState), {
@@ -9203,7 +9827,7 @@ function PuckProvider({ children }) {
9203
9827
  return walkAppState(newAppState, config);
9204
9828
  });
9205
9829
  const { appendData = true } = _initialHistory || {};
9206
- const [blendedHistories] = (0, import_react59.useState)(
9830
+ const [blendedHistories] = (0, import_react61.useState)(
9207
9831
  [
9208
9832
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
9209
9833
  ...appendData ? [{ state: generatedAppState }] : []
@@ -9223,7 +9847,7 @@ function PuckProvider({ children }) {
9223
9847
  overrides,
9224
9848
  plugins
9225
9849
  });
9226
- const loadedFieldTransforms = (0, import_react59.useMemo)(() => {
9850
+ const loadedFieldTransforms = (0, import_react61.useMemo)(() => {
9227
9851
  const _plugins = plugins || [];
9228
9852
  const pluginFieldTransforms = _plugins.reduce(
9229
9853
  (acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
@@ -9231,9 +9855,11 @@ function PuckProvider({ children }) {
9231
9855
  );
9232
9856
  return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
9233
9857
  }, [fieldTransforms, plugins]);
9234
- const generateAppStore = (0, import_react59.useCallback)(
9858
+ const instanceId = useSafeId();
9859
+ const generateAppStore = (0, import_react61.useCallback)(
9235
9860
  (state) => {
9236
9861
  return {
9862
+ instanceId,
9237
9863
  state,
9238
9864
  config,
9239
9865
  plugins: plugins || [],
@@ -9246,6 +9872,7 @@ function PuckProvider({ children }) {
9246
9872
  };
9247
9873
  },
9248
9874
  [
9875
+ instanceId,
9249
9876
  initialAppState,
9250
9877
  config,
9251
9878
  plugins,
@@ -9257,15 +9884,15 @@ function PuckProvider({ children }) {
9257
9884
  loadedFieldTransforms
9258
9885
  ]
9259
9886
  );
9260
- const [appStore] = (0, import_react59.useState)(
9887
+ const [appStore] = (0, import_react61.useState)(
9261
9888
  () => createAppStore(generateAppStore(initialAppState))
9262
9889
  );
9263
- (0, import_react59.useEffect)(() => {
9890
+ (0, import_react61.useEffect)(() => {
9264
9891
  if (process.env.NODE_ENV !== "production") {
9265
9892
  window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
9266
9893
  }
9267
9894
  }, [appStore]);
9268
- (0, import_react59.useEffect)(() => {
9895
+ (0, import_react61.useEffect)(() => {
9269
9896
  const state = appStore.getState().state;
9270
9897
  appStore.setState(__spreadValues({}, generateAppStore(state)));
9271
9898
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -9274,160 +9901,29 @@ function PuckProvider({ children }) {
9274
9901
  index: initialHistoryIndex,
9275
9902
  initialAppState
9276
9903
  });
9277
- const previousData = (0, import_react59.useRef)(null);
9278
- (0, import_react59.useEffect)(() => {
9279
- appStore.subscribe(
9904
+ const previousData = (0, import_react61.useRef)(null);
9905
+ (0, import_react61.useEffect)(() => {
9906
+ return appStore.subscribe(
9280
9907
  (s) => s.state.data,
9281
9908
  (data) => {
9282
9909
  if (onChange) {
9283
- if ((0, import_fast_deep_equal3.default)(data, previousData.current)) return;
9910
+ if ((0, import_fast_deep_equal.default)(data, previousData.current)) return;
9284
9911
  onChange(data);
9285
9912
  previousData.current = data;
9286
9913
  }
9287
9914
  }
9288
9915
  );
9289
- }, []);
9916
+ }, [onChange]);
9290
9917
  useRegisterPermissionsSlice(appStore, permissions);
9291
9918
  const uPuckStore = useRegisterUsePuckStore(appStore);
9292
- (0, import_react59.useEffect)(() => {
9919
+ (0, import_react61.useEffect)(() => {
9293
9920
  const { resolveAndCommitData } = appStore.getState();
9294
9921
  resolveAndCommitData();
9295
9922
  }, []);
9296
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
9297
- }
9298
- function PuckLayout({ children }) {
9299
- const {
9300
- iframe: _iframe,
9301
- dnd,
9302
- initialHistory: _initialHistory
9303
- } = usePropsContext();
9304
- const iframe = (0, import_react59.useMemo)(
9305
- () => __spreadValues({
9306
- enabled: true,
9307
- waitForStyles: true
9308
- }, _iframe),
9309
- [_iframe]
9310
- );
9311
- useInjectGlobalCss(iframe.enabled);
9312
- const dispatch = useAppStore((s) => s.dispatch);
9313
- const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
9314
- const rightSideBarVisible = useAppStore(
9315
- (s) => s.state.ui.rightSideBarVisible
9316
- );
9317
- const {
9318
- width: leftWidth,
9319
- setWidth: setLeftWidth,
9320
- sidebarRef: leftSidebarRef,
9321
- handleResizeEnd: handleLeftSidebarResizeEnd
9322
- } = useSidebarResize("left", dispatch);
9323
- const {
9324
- width: rightWidth,
9325
- setWidth: setRightWidth,
9326
- sidebarRef: rightSidebarRef,
9327
- handleResizeEnd: handleRightSidebarResizeEnd
9328
- } = useSidebarResize("right", dispatch);
9329
- (0, import_react59.useEffect)(() => {
9330
- if (!window.matchMedia("(min-width: 638px)").matches) {
9331
- dispatch({
9332
- type: "setUi",
9333
- ui: {
9334
- leftSideBarVisible: false,
9335
- rightSideBarVisible: false
9336
- }
9337
- });
9338
- }
9339
- const handleResize = () => {
9340
- if (!window.matchMedia("(min-width: 638px)").matches) {
9341
- dispatch({
9342
- type: "setUi",
9343
- ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
9344
- });
9345
- }
9346
- };
9347
- window.addEventListener("resize", handleResize);
9348
- return () => {
9349
- window.removeEventListener("resize", handleResize);
9350
- };
9351
- }, []);
9352
- const overrides = useAppStore((s) => s.overrides);
9353
- const CustomPuck = (0, import_react59.useMemo)(
9354
- () => overrides.puck || DefaultOverride,
9355
- [overrides]
9356
- );
9357
- const [mounted, setMounted] = (0, import_react59.useState)(false);
9358
- (0, import_react59.useEffect)(() => {
9359
- setMounted(true);
9360
- }, []);
9361
- const ready = useAppStore((s) => s.status === "READY");
9362
- useMonitorHotkeys();
9363
- (0, import_react59.useEffect)(() => {
9364
- if (ready && iframe.enabled) {
9365
- const frameDoc = getFrame();
9366
- if (frameDoc) {
9367
- return monitorHotkeys(frameDoc);
9368
- }
9369
- }
9370
- }, [ready, iframe.enabled]);
9371
- usePreviewModeHotkeys();
9372
- const layoutOptions = {};
9373
- if (leftWidth) {
9374
- layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
9375
- }
9376
- if (rightWidth) {
9377
- layoutOptions["--puck-user-right-side-bar-width"] = `${rightWidth}px`;
9378
- }
9379
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: `Puck ${getClassName31()}`, children: [
9380
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(FrameProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9381
- "div",
9382
- {
9383
- className: getLayoutClassName({
9384
- leftSideBarVisible,
9385
- mounted,
9386
- rightSideBarVisible
9387
- }),
9388
- children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
9389
- "div",
9390
- {
9391
- className: getLayoutClassName("inner"),
9392
- style: layoutOptions,
9393
- children: [
9394
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Header, {}),
9395
- /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
9396
- Sidebar,
9397
- {
9398
- position: "left",
9399
- sidebarRef: leftSidebarRef,
9400
- isVisible: leftSideBarVisible,
9401
- onResize: setLeftWidth,
9402
- onResizeEnd: handleLeftSidebarResizeEnd,
9403
- children: [
9404
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Components, {}) }),
9405
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Outline, {}) })
9406
- ]
9407
- }
9408
- ),
9409
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Canvas, {}),
9410
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9411
- Sidebar,
9412
- {
9413
- position: "right",
9414
- sidebarRef: rightSidebarRef,
9415
- isVisible: rightSideBarVisible,
9416
- onResize: setRightWidth,
9417
- onResizeEnd: handleRightSidebarResizeEnd,
9418
- children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(FieldSideBar, {})
9419
- }
9420
- )
9421
- ]
9422
- }
9423
- )
9424
- }
9425
- ) }) }) }),
9426
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { id: "puck-portal-root", className: getClassName31("portal") })
9427
- ] });
9923
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
9428
9924
  }
9429
9925
  function Puck(props) {
9430
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
9926
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Layout, { children: props.children }) })) }));
9431
9927
  }
9432
9928
  Puck.Components = Components;
9433
9929
  Puck.Fields = Fields;
@@ -9598,17 +10094,6 @@ function transformProps(data, propTransforms, config = { components: {} }) {
9598
10094
 
9599
10095
  // lib/resolve-all-data.ts
9600
10096
  init_react_import();
9601
-
9602
- // lib/data/to-component.ts
9603
- init_react_import();
9604
- var toComponent = (item) => {
9605
- return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
9606
- props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
9607
- type: "root"
9608
- });
9609
- };
9610
-
9611
- // lib/resolve-all-data.ts
9612
10097
  function resolveAllData(_0, _1) {
9613
10098
  return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
9614
10099
  var _a;
@@ -9671,8 +10156,11 @@ function resolveAllData(_0, _1) {
9671
10156
  Label,
9672
10157
  Puck,
9673
10158
  Render,
10159
+ blocksPlugin,
9674
10160
  createUsePuck,
10161
+ fieldsPlugin,
9675
10162
  migrate,
10163
+ outlinePlugin,
9676
10164
  overrideKeys,
9677
10165
  registerOverlayPortal,
9678
10166
  renderContext,
@@ -9780,6 +10268,14 @@ lucide-react/dist/esm/icons/ellipsis-vertical.js:
9780
10268
  * See the LICENSE file in the root directory of this source tree.
9781
10269
  *)
9782
10270
 
10271
+ lucide-react/dist/esm/icons/expand.js:
10272
+ (**
10273
+ * @license lucide-react v0.468.0 - ISC
10274
+ *
10275
+ * This source code is licensed under the ISC license.
10276
+ * See the LICENSE file in the root directory of this source tree.
10277
+ *)
10278
+
9783
10279
  lucide-react/dist/esm/icons/globe.js:
9784
10280
  (**
9785
10281
  * @license lucide-react v0.468.0 - ISC
@@ -9788,6 +10284,14 @@ lucide-react/dist/esm/icons/globe.js:
9788
10284
  * See the LICENSE file in the root directory of this source tree.
9789
10285
  *)
9790
10286
 
10287
+ lucide-react/dist/esm/icons/hammer.js:
10288
+ (**
10289
+ * @license lucide-react v0.468.0 - ISC
10290
+ *
10291
+ * This source code is licensed under the ISC license.
10292
+ * See the LICENSE file in the root directory of this source tree.
10293
+ *)
10294
+
9791
10295
  lucide-react/dist/esm/icons/hash.js:
9792
10296
  (**
9793
10297
  * @license lucide-react v0.468.0 - ISC
@@ -9844,6 +10348,22 @@ lucide-react/dist/esm/icons/lock.js:
9844
10348
  * See the LICENSE file in the root directory of this source tree.
9845
10349
  *)
9846
10350
 
10351
+ lucide-react/dist/esm/icons/maximize-2.js:
10352
+ (**
10353
+ * @license lucide-react v0.468.0 - ISC
10354
+ *
10355
+ * This source code is licensed under the ISC license.
10356
+ * See the LICENSE file in the root directory of this source tree.
10357
+ *)
10358
+
10359
+ lucide-react/dist/esm/icons/minimize-2.js:
10360
+ (**
10361
+ * @license lucide-react v0.468.0 - ISC
10362
+ *
10363
+ * This source code is licensed under the ISC license.
10364
+ * See the LICENSE file in the root directory of this source tree.
10365
+ *)
10366
+
9847
10367
  lucide-react/dist/esm/icons/monitor.js:
9848
10368
  (**
9849
10369
  * @license lucide-react v0.468.0 - ISC
@@ -9876,6 +10396,14 @@ lucide-react/dist/esm/icons/plus.js:
9876
10396
  * See the LICENSE file in the root directory of this source tree.
9877
10397
  *)
9878
10398
 
10399
+ lucide-react/dist/esm/icons/rectangle-ellipsis.js:
10400
+ (**
10401
+ * @license lucide-react v0.468.0 - ISC
10402
+ *
10403
+ * This source code is licensed under the ISC license.
10404
+ * See the LICENSE file in the root directory of this source tree.
10405
+ *)
10406
+
9879
10407
  lucide-react/dist/esm/icons/redo-2.js:
9880
10408
  (**
9881
10409
  * @license lucide-react v0.468.0 - ISC
@@ -9916,6 +10444,14 @@ lucide-react/dist/esm/icons/tablet.js:
9916
10444
  * See the LICENSE file in the root directory of this source tree.
9917
10445
  *)
9918
10446
 
10447
+ lucide-react/dist/esm/icons/toy-brick.js:
10448
+ (**
10449
+ * @license lucide-react v0.468.0 - ISC
10450
+ *
10451
+ * This source code is licensed under the ISC license.
10452
+ * See the LICENSE file in the root directory of this source tree.
10453
+ *)
10454
+
9919
10455
  lucide-react/dist/esm/icons/trash.js:
9920
10456
  (**
9921
10457
  * @license lucide-react v0.468.0 - ISC
@@ -9940,6 +10476,14 @@ lucide-react/dist/esm/icons/undo-2.js:
9940
10476
  * See the LICENSE file in the root directory of this source tree.
9941
10477
  *)
9942
10478
 
10479
+ lucide-react/dist/esm/icons/x.js:
10480
+ (**
10481
+ * @license lucide-react v0.468.0 - ISC
10482
+ *
10483
+ * This source code is licensed under the ISC license.
10484
+ * See the LICENSE file in the root directory of this source tree.
10485
+ *)
10486
+
9943
10487
  lucide-react/dist/esm/icons/zoom-in.js:
9944
10488
  (**
9945
10489
  * @license lucide-react v0.468.0 - ISC