@measured/puck 0.19.0-canary.8d459e4e → 0.19.0-canary.91cb9cee

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.mjs CHANGED
@@ -4,17 +4,14 @@ import {
4
4
  __async,
5
5
  __commonJS,
6
6
  __objRest,
7
- __privateAdd,
8
- __privateGet,
9
- __privateSet,
10
7
  __spreadProps,
11
8
  __spreadValues,
12
9
  __toESM,
13
- createIsSlotConfig,
10
+ defaultAppState,
11
+ defaultViewports,
14
12
  getChanged,
15
13
  init_react_import,
16
- isSlot,
17
- mapSlotsSync,
14
+ migrate,
18
15
  resolveAllData,
19
16
  resolveComponentData,
20
17
  rootAreaId,
@@ -22,8 +19,10 @@ import {
22
19
  rootZone,
23
20
  setupZone,
24
21
  transformProps,
25
- useSlots
26
- } from "./chunk-D6ENWNOG.mjs";
22
+ useSlots,
23
+ walkAppState,
24
+ walkTree
25
+ } from "./chunk-GL73J54P.mjs";
27
26
 
28
27
  // ../../node_modules/classnames/index.js
29
28
  var require_classnames = __commonJS({
@@ -703,198 +702,6 @@ init_react_import();
703
702
 
704
703
  // reducer/actions/set.ts
705
704
  init_react_import();
706
-
707
- // lib/data/walk-app-state.ts
708
- init_react_import();
709
-
710
- // lib/data/for-each-slot.ts
711
- init_react_import();
712
- var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
713
- const props = item.props || {};
714
- const propKeys = Object.keys(props);
715
- for (let i = 0; i < propKeys.length; i++) {
716
- const propKey = propKeys[i];
717
- const itemType = "type" in item ? item.type : "root";
718
- if (isSlot2(itemType, propKey, props[propKey])) {
719
- const content = props[propKey];
720
- cb(props.id, propKey, content);
721
- if (recursive) {
722
- content.forEach(
723
- (childItem) => __async(void 0, null, function* () {
724
- return forEachSlot(childItem, cb, true, isSlot2);
725
- })
726
- );
727
- }
728
- }
729
- }
730
- };
731
-
732
- // lib/data/for-related-zones.ts
733
- init_react_import();
734
-
735
- // lib/get-zone-id.ts
736
- init_react_import();
737
- var getZoneId = (zoneCompound) => {
738
- if (!zoneCompound) {
739
- return [];
740
- }
741
- if (zoneCompound && zoneCompound.indexOf(":") > -1) {
742
- return zoneCompound.split(":");
743
- }
744
- return [rootDroppableId, zoneCompound];
745
- };
746
-
747
- // lib/data/for-related-zones.ts
748
- function forRelatedZones(item, data, cb, path = []) {
749
- Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
750
- const [parentId] = getZoneId(zoneCompound);
751
- if (parentId === item.props.id) {
752
- cb(path, zoneCompound, content);
753
- }
754
- });
755
- }
756
-
757
- // lib/data/strip-slots.ts
758
- init_react_import();
759
- var stripSlots = (data) => {
760
- return __spreadProps(__spreadValues({}, data), {
761
- props: Object.entries(data.props).reduce(
762
- (acc, [propKey, propVal]) => {
763
- if (isSlot(propVal)) {
764
- return acc;
765
- }
766
- return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
767
- },
768
- { id: data.props.id }
769
- )
770
- });
771
- };
772
-
773
- // lib/data/walk-app-state.ts
774
- function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
775
- var _a;
776
- let newZones = {};
777
- const newZoneIndex = {};
778
- const newNodeIndex = {};
779
- const processContent = (path, zoneCompound, content, zoneType, newId) => {
780
- var _a2;
781
- const [parentId] = zoneCompound.split(":");
782
- const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
783
- const [_2, zone] = zoneCompound.split(":");
784
- const newZoneCompound = `${newId || parentId}:${zone}`;
785
- const newContent2 = mappedContent.map(
786
- (zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
787
- );
788
- newZoneIndex[newZoneCompound] = {
789
- contentIds: newContent2.map((item) => item.props.id),
790
- type: zoneType
791
- };
792
- return [newZoneCompound, newContent2];
793
- };
794
- const processRelatedZones = (item, newId, initialPath) => {
795
- forRelatedZones(
796
- item,
797
- state.data,
798
- (relatedPath, relatedZoneCompound, relatedContent) => {
799
- const [zoneCompound, newContent2] = processContent(
800
- relatedPath,
801
- relatedZoneCompound,
802
- relatedContent,
803
- "dropzone",
804
- newId
805
- );
806
- newZones[zoneCompound] = newContent2;
807
- },
808
- initialPath
809
- );
810
- };
811
- const processItem = (item, path, index) => {
812
- const mappedItem = mapNodeOrSkip(item, path, index);
813
- if (!mappedItem) return item;
814
- const id = mappedItem.props.id;
815
- const newProps = __spreadValues({}, mappedItem.props);
816
- forEachSlot(
817
- mappedItem,
818
- (parentId2, slotId, content) => {
819
- const zoneCompound = `${parentId2}:${slotId}`;
820
- const [_2, newContent2] = processContent(
821
- path,
822
- zoneCompound,
823
- content,
824
- "slot",
825
- parentId2
826
- );
827
- newProps[slotId] = newContent2;
828
- },
829
- false,
830
- createIsSlotConfig(config)
831
- );
832
- processRelatedZones(item, id, path);
833
- const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
834
- const thisZoneCompound = path[path.length - 1];
835
- const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
836
- newNodeIndex[id] = {
837
- data: newItem,
838
- flatData: stripSlots(newItem),
839
- path,
840
- parentId,
841
- zone
842
- };
843
- const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
844
- if (newProps.id === "root") {
845
- delete finalData["type"];
846
- delete finalData.props["id"];
847
- }
848
- return finalData;
849
- };
850
- const zones = state.data.zones || {};
851
- const [_, newContent] = processContent(
852
- [],
853
- rootDroppableId,
854
- state.data.content,
855
- "root"
856
- );
857
- const processedContent = newContent;
858
- const zonesAlreadyProcessed = Object.keys(newZones);
859
- Object.keys(zones || {}).forEach((zoneCompound) => {
860
- const [parentId] = zoneCompound.split(":");
861
- if (zonesAlreadyProcessed.includes(zoneCompound)) {
862
- return;
863
- }
864
- const [_2, newContent2] = processContent(
865
- [rootDroppableId],
866
- zoneCompound,
867
- zones[zoneCompound],
868
- "dropzone",
869
- parentId
870
- );
871
- newZones[zoneCompound] = newContent2;
872
- }, newZones);
873
- const processedRoot = processItem(
874
- {
875
- type: "root",
876
- props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
877
- },
878
- [],
879
- -1
880
- );
881
- const root = __spreadProps(__spreadValues({}, state.data.root), {
882
- props: processedRoot.props
883
- });
884
- return __spreadProps(__spreadValues({}, state), {
885
- data: {
886
- root,
887
- content: processedContent,
888
- zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
889
- },
890
- indexes: {
891
- nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
892
- zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
893
- }
894
- });
895
- }
896
-
897
- // reducer/actions/set.ts
898
705
  var setAction = (state, action, appStore) => {
899
706
  if (typeof action.state === "object") {
900
707
  const newState = __spreadValues(__spreadValues({}, state), action.state);
@@ -933,15 +740,36 @@ var getIdsForParent = (zoneCompound, state) => {
933
740
  return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
934
741
  };
935
742
 
743
+ // lib/data/populate-ids.ts
744
+ init_react_import();
745
+ var populateIds = (data, config, override = false) => {
746
+ const id = generateId(data.type);
747
+ return walkTree(
748
+ __spreadProps(__spreadValues({}, data), {
749
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
750
+ }),
751
+ config,
752
+ (contents) => contents.map((item) => {
753
+ const id2 = generateId(item.type);
754
+ return __spreadProps(__spreadValues({}, item), {
755
+ props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
756
+ });
757
+ })
758
+ );
759
+ };
760
+
936
761
  // reducer/actions/insert.ts
937
762
  function insertAction(state, action, appStore) {
938
763
  const id = action.id || generateId(action.componentType);
939
- const emptyComponentData = {
940
- type: action.componentType,
941
- props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
942
- id
943
- })
944
- };
764
+ const emptyComponentData = populateIds(
765
+ {
766
+ type: action.componentType,
767
+ props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
768
+ id
769
+ })
770
+ },
771
+ appStore.config
772
+ );
945
773
  const [parentId] = action.destinationZone.split(":");
946
774
  const idsInPath = getIdsForParent(action.destinationZone, state);
947
775
  return walkAppState(
@@ -982,25 +810,26 @@ var replaceAction = (state, action, appStore) => {
982
810
  `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
983
811
  );
984
812
  }
813
+ const data = populateIds(action.data, appStore.config);
985
814
  return walkAppState(
986
815
  state,
987
816
  appStore.config,
988
817
  (content, zoneCompound) => {
989
818
  const newContent = [...content];
990
819
  if (zoneCompound === action.destinationZone) {
991
- newContent[action.destinationIndex] = action.data;
820
+ newContent[action.destinationIndex] = data;
992
821
  }
993
822
  return newContent;
994
823
  },
995
824
  (childItem, path) => {
996
825
  const pathIds = path.map((p) => p.split(":")[0]);
997
- if (childItem.props.id === action.data.props.id) {
998
- return action.data;
826
+ if (childItem.props.id === data.props.id) {
827
+ return data;
999
828
  } else if (childItem.props.id === parentId) {
1000
829
  return childItem;
1001
830
  } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1002
831
  return childItem;
1003
- } else if (pathIds.indexOf(action.data.props.id) > -1) {
832
+ } else if (pathIds.indexOf(data.props.id) > -1) {
1004
833
  return childItem;
1005
834
  }
1006
835
  return null;
@@ -1355,14 +1184,6 @@ function createReducer({
1355
1184
  );
1356
1185
  }
1357
1186
 
1358
- // components/ViewportControls/default-viewports.ts
1359
- init_react_import();
1360
- var defaultViewports = [
1361
- { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1362
- { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1363
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1364
- ];
1365
-
1366
1187
  // store/index.ts
1367
1188
  import { create as create2, useStore } from "zustand";
1368
1189
  import { subscribeWithSelector as subscribeWithSelector2 } from "zustand/middleware";
@@ -1604,7 +1425,11 @@ var createNodesSlice = (set, get) => ({
1604
1425
  const s = get().nodes;
1605
1426
  const emptyNode = {
1606
1427
  id,
1607
- methods: { sync: () => null },
1428
+ methods: {
1429
+ sync: () => null,
1430
+ hideOverlay: () => null,
1431
+ showOverlay: () => null
1432
+ },
1608
1433
  element: null
1609
1434
  };
1610
1435
  const existingNode = s.nodes[id];
@@ -1794,7 +1619,8 @@ var createFieldsSlice = (_set, _get) => {
1794
1619
  return {
1795
1620
  fields: {},
1796
1621
  loading: false,
1797
- lastResolvedData: {}
1622
+ lastResolvedData: {},
1623
+ id: void 0
1798
1624
  };
1799
1625
  };
1800
1626
  var useRegisterFieldsSlice = (appStore, id) => {
@@ -1815,7 +1641,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
1815
1641
  let lastFields = fields;
1816
1642
  if (reset) {
1817
1643
  appStore.setState((s) => ({
1818
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
1644
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1819
1645
  }));
1820
1646
  lastFields = defaultFields;
1821
1647
  }
@@ -1843,12 +1669,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
1843
1669
  fields: {
1844
1670
  fields: newFields,
1845
1671
  loading: false,
1846
- lastResolvedData: componentData
1672
+ lastResolvedData: componentData,
1673
+ id
1847
1674
  }
1848
1675
  });
1849
1676
  } else {
1850
1677
  appStore.setState((s) => ({
1851
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
1678
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1852
1679
  }));
1853
1680
  }
1854
1681
  }),
@@ -1881,31 +1708,6 @@ var toRoot = (item) => {
1881
1708
  };
1882
1709
 
1883
1710
  // store/index.ts
1884
- var defaultAppState = {
1885
- data: { content: [], root: {}, zones: {} },
1886
- ui: {
1887
- leftSideBarVisible: true,
1888
- rightSideBarVisible: true,
1889
- arrayState: {},
1890
- itemSelector: null,
1891
- componentList: {},
1892
- isDragging: false,
1893
- previewMode: "edit",
1894
- viewports: {
1895
- current: {
1896
- width: defaultViewports[0].width,
1897
- height: defaultViewports[0].height || "auto"
1898
- },
1899
- options: [],
1900
- controlsVisible: true
1901
- },
1902
- field: { focus: null }
1903
- },
1904
- indexes: {
1905
- nodes: {},
1906
- zones: {}
1907
- }
1908
- };
1909
1711
  var defaultPageFields = {
1910
1712
  title: { type: "text" }
1911
1713
  };
@@ -2094,326 +1896,11 @@ function useAppStoreApi() {
2094
1896
  init_react_import();
2095
1897
  import { DragDropProvider } from "@dnd-kit/react";
2096
1898
 
2097
- // lib/dnd/dnd-kit/safe.ts
2098
- init_react_import();
2099
- import {
2100
- useDraggable,
2101
- useDroppable
2102
- } from "@dnd-kit/react";
2103
- import { useSortable } from "@dnd-kit/react/sortable";
2104
- function useDroppableSafe(input) {
2105
- if (typeof window === "undefined") {
2106
- return { ref: () => {
2107
- } };
2108
- }
2109
- return useDroppable(input);
2110
- }
2111
- function useDraggableSafe(input) {
2112
- if (typeof window === "undefined") {
2113
- return { ref: () => {
2114
- } };
2115
- }
2116
- return useDraggable(input);
2117
- }
2118
- function useSortableSafe(input) {
2119
- if (typeof window === "undefined") {
2120
- return { ref: () => {
2121
- }, status: "idle", handleRef: () => {
2122
- } };
2123
- }
2124
- return useSortable(input);
2125
- }
2126
-
2127
1899
  // lib/dnd/use-sensors.ts
2128
1900
  init_react_import();
2129
1901
  import { useState as useState2 } from "react";
2130
-
2131
- // lib/dnd/PointerSensor.ts
2132
- init_react_import();
2133
- import { batch, effect } from "@dnd-kit/state";
2134
- import { Sensor, configurator } from "@dnd-kit/abstract";
2135
- import {
2136
- exceedsDistance
2137
- } from "@dnd-kit/geometry";
2138
- import {
2139
- getDocument,
2140
- isElement,
2141
- isHTMLElement,
2142
- isPointerEvent,
2143
- Listeners,
2144
- getFrameTransform
2145
- } from "@dnd-kit/dom/utilities";
2146
- var _clearTimeout;
2147
- var _PointerSensor = class _PointerSensor extends Sensor {
2148
- constructor(manager, options) {
2149
- super(manager);
2150
- this.manager = manager;
2151
- this.options = options;
2152
- this.listeners = new Listeners();
2153
- this.cleanup = /* @__PURE__ */ new Set();
2154
- this.source = void 0;
2155
- this.started = false;
2156
- __privateAdd(this, _clearTimeout);
2157
- this.handleCancel = this.handleCancel.bind(this);
2158
- this.handlePointerUp = this.handlePointerUp.bind(this);
2159
- this.handleKeyDown = this.handleKeyDown.bind(this);
2160
- effect(() => {
2161
- const unbindGlobal = this.bindGlobal(options != null ? options : {});
2162
- return () => {
2163
- unbindGlobal();
2164
- };
2165
- });
2166
- }
2167
- bind(source, options = this.options) {
2168
- const unbind = effect(() => {
2169
- var _a;
2170
- const target = (_a = source.handle) != null ? _a : source.element;
2171
- const listener = (event) => {
2172
- if (isPointerEvent(event)) {
2173
- this.handlePointerDown(event, source, options);
2174
- }
2175
- };
2176
- if (target) {
2177
- patchWindow(target.ownerDocument.defaultView);
2178
- target.addEventListener("pointerdown", listener);
2179
- return () => {
2180
- target.removeEventListener("pointerdown", listener);
2181
- };
2182
- }
2183
- });
2184
- return unbind;
2185
- }
2186
- bindGlobal(options) {
2187
- const documents = /* @__PURE__ */ new Set();
2188
- for (const draggable of this.manager.registry.draggables.value) {
2189
- if (draggable.element) {
2190
- documents.add(getDocument(draggable.element));
2191
- }
2192
- }
2193
- for (const droppable of this.manager.registry.droppables.value) {
2194
- if (droppable.element) {
2195
- documents.add(getDocument(droppable.element));
2196
- }
2197
- }
2198
- const unbindFns = Array.from(documents).map(
2199
- (doc) => this.listeners.bind(doc, [
2200
- {
2201
- type: "pointermove",
2202
- listener: (event) => this.handlePointerMove(event, doc, options)
2203
- },
2204
- {
2205
- type: "pointerup",
2206
- listener: this.handlePointerUp,
2207
- options: {
2208
- capture: true
2209
- }
2210
- },
2211
- {
2212
- // Cancel activation if there is a competing Drag and Drop interaction
2213
- type: "dragstart",
2214
- listener: this.handleDragStart
2215
- }
2216
- ])
2217
- );
2218
- return () => {
2219
- unbindFns.forEach((unbind) => unbind());
2220
- };
2221
- }
2222
- handlePointerDown(event, source, options = {}) {
2223
- if (this.disabled || !event.isPrimary || event.button !== 0 || !isElement(event.target) || source.disabled) {
2224
- return;
2225
- }
2226
- const offset = getFrameTransform(source.element);
2227
- this.initialCoordinates = {
2228
- x: event.clientX * offset.scaleX + offset.x,
2229
- y: event.clientY * offset.scaleY + offset.y
2230
- };
2231
- this.source = source;
2232
- const { activationConstraints } = options;
2233
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
2234
- event.stopImmediatePropagation();
2235
- if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
2236
- this.handleStart(source, event);
2237
- } else {
2238
- const { delay } = constraints;
2239
- if (delay) {
2240
- const timeout3 = setTimeout(
2241
- () => this.handleStart(source, event),
2242
- delay.value
2243
- );
2244
- __privateSet(this, _clearTimeout, () => {
2245
- clearTimeout(timeout3);
2246
- __privateSet(this, _clearTimeout, void 0);
2247
- });
2248
- }
2249
- }
2250
- const cleanup = () => {
2251
- var _a;
2252
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2253
- this.initialCoordinates = void 0;
2254
- this.source = void 0;
2255
- };
2256
- this.cleanup.add(cleanup);
2257
- }
2258
- handlePointerMove(event, doc, options) {
2259
- if (!this.source) {
2260
- return;
2261
- }
2262
- const ownerDocument = this.source.element && getDocument(this.source.element);
2263
- if (doc !== ownerDocument) {
2264
- return;
2265
- }
2266
- const coordinates = {
2267
- x: event.clientX,
2268
- y: event.clientY
2269
- };
2270
- const offset = getFrameTransform(this.source.element);
2271
- coordinates.x = coordinates.x * offset.scaleX + offset.x;
2272
- coordinates.y = coordinates.y * offset.scaleY + offset.y;
2273
- if (this.manager.dragOperation.status.dragging) {
2274
- event.preventDefault();
2275
- event.stopPropagation();
2276
- this.manager.actions.move({ to: coordinates });
2277
- return;
2278
- }
2279
- if (!this.initialCoordinates) {
2280
- return;
2281
- }
2282
- const delta = {
2283
- x: coordinates.x - this.initialCoordinates.x,
2284
- y: coordinates.y - this.initialCoordinates.y
2285
- };
2286
- const { activationConstraints } = options;
2287
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
2288
- const { distance, delay } = constraints != null ? constraints : {};
2289
- if (distance) {
2290
- if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
2291
- return this.handleCancel();
2292
- }
2293
- if (exceedsDistance(delta, distance.value)) {
2294
- return this.handleStart(this.source, event);
2295
- }
2296
- }
2297
- if (delay) {
2298
- if (exceedsDistance(delta, delay.tolerance)) {
2299
- return this.handleCancel();
2300
- }
2301
- }
2302
- }
2303
- handlePointerUp(event) {
2304
- if (!this.source) {
2305
- return;
2306
- }
2307
- event.preventDefault();
2308
- event.stopPropagation();
2309
- const { status } = this.manager.dragOperation;
2310
- if (!status.idle) {
2311
- const canceled = !status.initialized;
2312
- this.manager.actions.stop({ canceled });
2313
- } else if (this.started) {
2314
- setTimeout(() => {
2315
- if (!this.manager.dragOperation.status.idle) {
2316
- this.manager.actions.stop({ canceled: false });
2317
- }
2318
- }, 10);
2319
- }
2320
- this.cleanup.forEach((cleanup) => cleanup());
2321
- this.cleanup.clear();
2322
- }
2323
- handleKeyDown(event) {
2324
- if (event.key === "Escape") {
2325
- event.preventDefault();
2326
- this.handleCancel();
2327
- }
2328
- }
2329
- handleStart(source, event) {
2330
- var _a;
2331
- const { manager, initialCoordinates } = this;
2332
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2333
- if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2334
- return;
2335
- }
2336
- if (event.defaultPrevented) {
2337
- return;
2338
- }
2339
- this.started = true;
2340
- event.preventDefault();
2341
- batch(() => {
2342
- manager.actions.setDragSource(source.id);
2343
- manager.actions.start({ coordinates: initialCoordinates, event });
2344
- });
2345
- const ownerDocument = getDocument(event.target);
2346
- const unbind = this.listeners.bind(ownerDocument, [
2347
- {
2348
- // Prevent scrolling on touch devices
2349
- type: "touchmove",
2350
- listener: preventDefault,
2351
- options: {
2352
- passive: false
2353
- }
2354
- },
2355
- {
2356
- // Prevent click events
2357
- type: "click",
2358
- listener: preventDefault
2359
- },
2360
- {
2361
- type: "keydown",
2362
- listener: this.handleKeyDown
2363
- }
2364
- ]);
2365
- ownerDocument.body.setPointerCapture(event.pointerId);
2366
- this.cleanup.add(unbind);
2367
- this.cleanup.add(() => {
2368
- this.started = false;
2369
- });
2370
- }
2371
- handleDragStart(event) {
2372
- const { target } = event;
2373
- if (!isElement(target)) {
2374
- return;
2375
- }
2376
- const isNativeDraggable = isHTMLElement(target) && target.draggable && target.getAttribute("draggable") === "true";
2377
- if (isNativeDraggable) {
2378
- this.handleCancel();
2379
- } else {
2380
- preventDefault(event);
2381
- }
2382
- }
2383
- handleCancel() {
2384
- const { dragOperation } = this.manager;
2385
- if (dragOperation.status.initialized) {
2386
- this.manager.actions.stop({ canceled: true });
2387
- }
2388
- this.cleanup.forEach((cleanup) => cleanup());
2389
- this.cleanup.clear();
2390
- }
2391
- destroy() {
2392
- this.listeners.clear();
2393
- }
2394
- };
2395
- _clearTimeout = new WeakMap();
2396
- _PointerSensor.configure = configurator(_PointerSensor);
2397
- var PointerSensor = _PointerSensor;
2398
- function preventDefault(event) {
2399
- event.preventDefault();
2400
- }
2401
- function noop() {
2402
- }
2403
- var windows = /* @__PURE__ */ new WeakSet();
2404
- function patchWindow(window2) {
2405
- if (!window2 || windows.has(window2)) {
2406
- return;
2407
- }
2408
- window2.addEventListener("touchmove", noop, {
2409
- capture: false,
2410
- passive: false
2411
- });
2412
- windows.add(window2);
2413
- }
2414
-
2415
- // lib/dnd/use-sensors.ts
2416
- import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
1902
+ import { PointerSensor } from "@dnd-kit/react";
1903
+ import { isElement } from "@dnd-kit/dom/utilities";
2417
1904
  var useSensors = ({
2418
1905
  other,
2419
1906
  mouse,
@@ -2427,7 +1914,7 @@ var useSensors = ({
2427
1914
  activationConstraints(event, source) {
2428
1915
  var _a;
2429
1916
  const { pointerType, target } = event;
2430
- if (pointerType === "mouse" && isElement2(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
1917
+ if (pointerType === "mouse" && isElement(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2431
1918
  return mouse;
2432
1919
  }
2433
1920
  if (pointerType === "touch") {
@@ -2597,7 +2084,7 @@ import { Point as Point2 } from "@dnd-kit/geometry";
2597
2084
  import { CollisionPriority as CollisionPriority2, CollisionType as CollisionType22 } from "@dnd-kit/abstract";
2598
2085
  import { Point as Point22 } from "@dnd-kit/geometry";
2599
2086
  import { CollisionPriority as CollisionPriority3, CollisionType as CollisionType3 } from "@dnd-kit/abstract";
2600
- import { Point as Point3 } from "@dnd-kit/geometry";
2087
+ import { Point as Point3, Rectangle } from "@dnd-kit/geometry";
2601
2088
  import { CollisionPriority as CollisionPriority4, CollisionType as CollisionType4 } from "@dnd-kit/abstract";
2602
2089
  import { Point as Point4 } from "@dnd-kit/geometry";
2603
2090
  import { CollisionPriority as CollisionPriority5, CollisionType as CollisionType5 } from "@dnd-kit/abstract";
@@ -2633,31 +2120,15 @@ var closestCorners = (input) => {
2633
2120
  if (!droppable.shape) {
2634
2121
  return null;
2635
2122
  }
2636
- const { left, top, right, bottom } = droppable.shape.boundingRectangle;
2637
- const corners = [
2638
- {
2639
- x: left,
2640
- y: top
2641
- },
2642
- {
2643
- x: right,
2644
- y: top
2645
- },
2646
- {
2647
- x: left,
2648
- y: bottom
2649
- },
2650
- {
2651
- x: right,
2652
- y: bottom
2653
- }
2654
- ];
2655
- const distance = corners.reduce(
2656
- (acc, corner) => {
2123
+ const shapeCorners = shape ? Rectangle.from(shape.current.boundingRectangle).corners : void 0;
2124
+ const distance = Rectangle.from(
2125
+ droppable.shape.boundingRectangle
2126
+ ).corners.reduce(
2127
+ (acc, corner, index) => {
2657
2128
  var _a;
2658
2129
  return acc + Point3.distance(
2659
2130
  Point3.from(corner),
2660
- (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
2131
+ (_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
2661
2132
  );
2662
2133
  },
2663
2134
  0
@@ -2692,12 +2163,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2692
2163
  const { center: dragCenter } = dragShape;
2693
2164
  const { fallbackEnabled } = collisionStore.getState();
2694
2165
  const interval = trackMovementInterval(position.current, dragAxis);
2695
- dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2696
- direction: interval.direction
2697
- });
2698
- const collisionMap = dragOperation.data.collisionMap || {};
2699
- dragOperation.data.collisionMap = collisionMap;
2700
- collisionMap[droppable.id] = {
2166
+ const data = {
2701
2167
  direction: interval.direction
2702
2168
  };
2703
2169
  const { center: dropCenter } = dropShape;
@@ -2712,7 +2178,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2712
2178
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
2713
2179
  if (collision) {
2714
2180
  return __spreadProps(__spreadValues({}, collision), {
2715
- priority: CollisionPriority7.Highest
2181
+ priority: CollisionPriority7.Highest,
2182
+ data
2716
2183
  });
2717
2184
  }
2718
2185
  }
@@ -2734,7 +2201,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2734
2201
  };
2735
2202
  const shouldFlushId = flushNext === droppable.id;
2736
2203
  flushNext = "";
2737
- return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2204
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
2738
2205
  }
2739
2206
  if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2740
2207
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
@@ -2746,9 +2213,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2746
2213
  x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
2747
2214
  y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
2748
2215
  });
2749
- collisionMap[droppable.id] = {
2750
- direction
2751
- };
2216
+ data.direction = direction;
2752
2217
  if (intersectionArea) {
2753
2218
  collisionDebug(
2754
2219
  dragCenter,
@@ -2759,7 +2224,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2759
2224
  );
2760
2225
  flushNext = droppable.id;
2761
2226
  return __spreadProps(__spreadValues({}, fallbackCollision), {
2762
- priority: CollisionPriority7.Low
2227
+ priority: CollisionPriority7.Low,
2228
+ data
2763
2229
  });
2764
2230
  }
2765
2231
  collisionDebug(
@@ -2769,16 +2235,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2769
2235
  "orange",
2770
2236
  direction || ""
2771
2237
  );
2772
- return __spreadProps(__spreadValues({}, fallbackCollision), { priority: CollisionPriority7.Lowest });
2238
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2239
+ priority: CollisionPriority7.Lowest,
2240
+ data
2241
+ });
2773
2242
  }
2774
2243
  }
2775
2244
  }
2776
2245
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2777
- delete collisionMap[droppable.id];
2778
2246
  return null;
2779
2247
  };
2780
2248
 
2781
2249
  // components/Sortable/index.tsx
2250
+ import { useSortable } from "@dnd-kit/react/sortable";
2782
2251
  import { jsx as jsx5 } from "react/jsx-runtime";
2783
2252
  var SortableProvider = ({
2784
2253
  children,
@@ -2798,16 +2267,16 @@ var SortableProvider = ({
2798
2267
  return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
2799
2268
  },
2800
2269
  onDragOver: (event, manager) => {
2801
- var _a, _b;
2270
+ var _a;
2802
2271
  event.preventDefault();
2803
2272
  const { operation } = event;
2804
2273
  const { source, target } = operation;
2805
2274
  if (!source || !target) return;
2806
2275
  let sourceIndex = source.data.index;
2807
2276
  let targetIndex = target.data.index;
2808
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
2277
+ const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
2809
2278
  if (sourceIndex !== targetIndex && source.id !== target.id) {
2810
- const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2279
+ const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
2811
2280
  if (targetIndex >= sourceIndex) {
2812
2281
  targetIndex = targetIndex - 1;
2813
2282
  }
@@ -2838,9 +2307,10 @@ var Sortable = ({
2838
2307
  }) => {
2839
2308
  const {
2840
2309
  ref: sortableRef,
2841
- status,
2310
+ isDragging,
2311
+ isDropping,
2842
2312
  handleRef
2843
- } = useSortableSafe({
2313
+ } = useSortable({
2844
2314
  id,
2845
2315
  type,
2846
2316
  index,
@@ -2848,7 +2318,7 @@ var Sortable = ({
2848
2318
  data: { index },
2849
2319
  collisionDetector: createDynamicCollisionDetector("y")
2850
2320
  });
2851
- return children({ status, ref: sortableRef, handleRef });
2321
+ return children({ isDragging, isDropping, ref: sortableRef, handleRef });
2852
2322
  };
2853
2323
 
2854
2324
  // components/AutoField/context.tsx
@@ -2973,7 +2443,7 @@ var ArrayField = ({
2973
2443
  }
2974
2444
  }, []);
2975
2445
  const [draggedItem, setDraggedItem] = useState3("");
2976
- const isDragging = !!draggedItem;
2446
+ const isDraggingAny = !!draggedItem;
2977
2447
  const canEdit = useAppStore(
2978
2448
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
2979
2449
  );
@@ -3038,13 +2508,13 @@ var ArrayField = ({
3038
2508
  id: _arrayId,
3039
2509
  index: i,
3040
2510
  disabled: readOnly,
3041
- children: ({ status, ref, handleRef }) => /* @__PURE__ */ jsxs3(
2511
+ children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ jsxs3(
3042
2512
  "div",
3043
2513
  {
3044
2514
  ref,
3045
2515
  className: getClassNameItem({
3046
2516
  isExpanded: arrayState.openId === _arrayId,
3047
- isDragging: status === "dragging",
2517
+ isDragging,
3048
2518
  readOnly
3049
2519
  }),
3050
2520
  children: [
@@ -3185,7 +2655,7 @@ var ArrayField = ({
3185
2655
  type: "button",
3186
2656
  className: getClassName5("addButton"),
3187
2657
  onClick: () => {
3188
- if (isDragging) return;
2658
+ if (isDraggingAny) return;
3189
2659
  const existingValue = value || [];
3190
2660
  const newValue = [
3191
2661
  ...existingValue,
@@ -4174,7 +3644,7 @@ init_react_import();
4174
3644
 
4175
3645
  // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
4176
3646
  init_react_import();
4177
- var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
3647
+ var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
4178
3648
 
4179
3649
  // components/Drawer/index.tsx
4180
3650
  import { useMemo as useMemo11, useState as useState15 } from "react";
@@ -4184,11 +3654,11 @@ init_react_import();
4184
3654
  import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
4185
3655
  import {
4186
3656
  createContext as createContext4,
4187
- useCallback as useCallback10,
4188
- useContext as useContext7,
4189
- useEffect as useEffect16,
3657
+ useCallback as useCallback11,
3658
+ useContext as useContext8,
3659
+ useEffect as useEffect17,
4190
3660
  useMemo as useMemo10,
4191
- useRef as useRef4,
3661
+ useRef as useRef5,
4192
3662
  useState as useState14
4193
3663
  } from "react";
4194
3664
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
@@ -4198,22 +3668,23 @@ init_react_import();
4198
3668
  import {
4199
3669
  forwardRef as forwardRef3,
4200
3670
  memo,
4201
- useCallback as useCallback9,
4202
- useContext as useContext6,
4203
- useEffect as useEffect15,
3671
+ useCallback as useCallback10,
3672
+ useContext as useContext7,
3673
+ useEffect as useEffect16,
4204
3674
  useMemo as useMemo9,
4205
- useRef as useRef3
3675
+ useRef as useRef4
4206
3676
  } from "react";
4207
3677
 
4208
3678
  // components/DraggableComponent/index.tsx
4209
3679
  init_react_import();
4210
3680
  import {
4211
- useCallback as useCallback6,
3681
+ useCallback as useCallback7,
4212
3682
  useContext as useContext5,
4213
- useEffect as useEffect11,
3683
+ useEffect as useEffect12,
4214
3684
  useMemo as useMemo7,
4215
3685
  useRef as useRef2,
4216
- useState as useState10
3686
+ useState as useState10,
3687
+ useTransition
4217
3688
  } from "react";
4218
3689
 
4219
3690
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
@@ -4247,8 +3718,7 @@ init_react_import();
4247
3718
  import {
4248
3719
  createContext as createContext3,
4249
3720
  useCallback as useCallback5,
4250
- useMemo as useMemo6,
4251
- useState as useState9
3721
+ useMemo as useMemo6
4252
3722
  } from "react";
4253
3723
  import { createStore as createStore2 } from "zustand";
4254
3724
  import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
@@ -4260,7 +3730,9 @@ var ZoneStoreContext = createContext3(
4260
3730
  areaDepthIndex: {},
4261
3731
  nextAreaDepthIndex: {},
4262
3732
  draggedItem: null,
4263
- previewIndex: {}
3733
+ previewIndex: {},
3734
+ enabledIndex: {},
3735
+ hoveringComponent: null
4264
3736
  }))
4265
3737
  );
4266
3738
  var ZoneStoreProvider = ({
@@ -4273,7 +3745,6 @@ var DropZoneProvider = ({
4273
3745
  children,
4274
3746
  value
4275
3747
  }) => {
4276
- const [hoveringComponent, setHoveringComponent] = useState9();
4277
3748
  const dispatch = useAppStore((s) => s.dispatch);
4278
3749
  const registerZone = useCallback5(
4279
3750
  (zoneCompound) => {
@@ -4295,16 +3766,33 @@ var DropZoneProvider = ({
4295
3766
  );
4296
3767
  const memoValue = useMemo6(
4297
3768
  () => __spreadValues({
4298
- hoveringComponent,
4299
- setHoveringComponent,
4300
3769
  registerZone,
4301
3770
  unregisterZone
4302
3771
  }, value),
4303
- [value, hoveringComponent]
3772
+ [value]
4304
3773
  );
4305
3774
  return /* @__PURE__ */ jsx19(Fragment5, { children: memoValue && /* @__PURE__ */ jsx19(dropZoneContext.Provider, { value: memoValue, children }) });
4306
3775
  };
4307
3776
 
3777
+ // components/DraggableComponent/index.tsx
3778
+ import { useShallow as useShallow2 } from "zustand/react/shallow";
3779
+ import { useSortable as useSortable2 } from "@dnd-kit/react/sortable";
3780
+
3781
+ // lib/accumulate-transform.ts
3782
+ init_react_import();
3783
+ function accumulateTransform(el) {
3784
+ let matrix = new DOMMatrixReadOnly();
3785
+ let n = el.parentElement;
3786
+ while (n && n !== document.documentElement) {
3787
+ const t = getComputedStyle(n).transform;
3788
+ if (t && t !== "none") {
3789
+ matrix = new DOMMatrixReadOnly(t).multiply(matrix);
3790
+ }
3791
+ n = n.parentElement;
3792
+ }
3793
+ return { scaleX: matrix.a, scaleY: matrix.d };
3794
+ }
3795
+
4308
3796
  // lib/use-context-store.ts
4309
3797
  init_react_import();
4310
3798
  import { useContext as useContext4 } from "react";
@@ -4318,8 +3806,39 @@ function useContextStore(context, selector) {
4318
3806
  return useStore2(store, useShallow(selector));
4319
3807
  }
4320
3808
 
3809
+ // lib/dnd/use-on-drag-finished.ts
3810
+ init_react_import();
3811
+ import { useCallback as useCallback6 } from "react";
3812
+ var useOnDragFinished = (cb, deps = []) => {
3813
+ const appStore = useAppStoreApi();
3814
+ return useCallback6(() => {
3815
+ let dispose = () => {
3816
+ };
3817
+ const processDragging = (isDragging2) => {
3818
+ if (isDragging2) {
3819
+ cb(false);
3820
+ } else {
3821
+ setTimeout(() => {
3822
+ cb(true);
3823
+ }, 0);
3824
+ if (dispose) dispose();
3825
+ }
3826
+ };
3827
+ const isDragging = appStore.getState().state.ui.isDragging;
3828
+ processDragging(isDragging);
3829
+ if (isDragging) {
3830
+ dispose = appStore.subscribe(
3831
+ (s) => s.state.ui.isDragging,
3832
+ (isDragging2) => {
3833
+ processDragging(isDragging2);
3834
+ }
3835
+ );
3836
+ }
3837
+ return dispose;
3838
+ }, [appStore, ...deps]);
3839
+ };
3840
+
4321
3841
  // components/DraggableComponent/index.tsx
4322
- import { useShallow as useShallow2 } from "zustand/react/shallow";
4323
3842
  import { jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
4324
3843
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
4325
3844
  var DEBUG2 = false;
@@ -4349,7 +3868,6 @@ var DraggableComponent = ({
4349
3868
  isSelected = false,
4350
3869
  debug,
4351
3870
  label,
4352
- isEnabled,
4353
3871
  autoDragAxis,
4354
3872
  userDragAxis,
4355
3873
  inDroppableZone = true
@@ -4365,7 +3883,7 @@ var DraggableComponent = ({
4365
3883
  const iframe = useAppStore((s) => s.iframe);
4366
3884
  const ctx = useContext5(dropZoneContext);
4367
3885
  const [localZones, setLocalZones] = useState10({});
4368
- const registerLocalZone = useCallback6(
3886
+ const registerLocalZone = useCallback7(
4369
3887
  (zoneCompound2, active) => {
4370
3888
  var _a;
4371
3889
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4375,7 +3893,7 @@ var DraggableComponent = ({
4375
3893
  },
4376
3894
  [setLocalZones]
4377
3895
  );
4378
- const unregisterLocalZone = useCallback6(
3896
+ const unregisterLocalZone = useCallback7(
4379
3897
  (zoneCompound2) => {
4380
3898
  var _a;
4381
3899
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4398,14 +3916,17 @@ var DraggableComponent = ({
4398
3916
  return s.permissions.getPermissions({ item });
4399
3917
  })
4400
3918
  );
4401
- const userIsDragging = useContextStore(
4402
- ZoneStoreContext,
4403
- (s) => !!s.draggedItem
4404
- );
4405
- const canCollide = permissions.drag || userIsDragging;
4406
- const disabled = !isEnabled || !canCollide;
3919
+ const zoneStore = useContext5(ZoneStoreContext);
4407
3920
  const [dragAxis, setDragAxis] = useState10(userDragAxis || autoDragAxis);
4408
- const { ref: sortableRef, status } = useSortableSafe({
3921
+ const dynamicCollisionDetector = useMemo7(
3922
+ () => createDynamicCollisionDetector(dragAxis),
3923
+ [dragAxis]
3924
+ );
3925
+ const {
3926
+ ref: sortableRef,
3927
+ isDragging: thisIsDragging,
3928
+ sortable
3929
+ } = useSortable2({
4409
3930
  id,
4410
3931
  index,
4411
3932
  group: zoneCompound,
@@ -4420,20 +3941,36 @@ var DraggableComponent = ({
4420
3941
  path: path || [],
4421
3942
  inDroppableZone
4422
3943
  },
4423
- collisionPriority: isEnabled ? depth : 0,
4424
- collisionDetector: createDynamicCollisionDetector(dragAxis),
4425
- disabled,
3944
+ collisionPriority: depth,
3945
+ collisionDetector: dynamicCollisionDetector,
4426
3946
  // "Out of the way" transition from react-beautiful-dnd
4427
3947
  transition: {
4428
3948
  duration: 200,
4429
3949
  easing: "cubic-bezier(0.2, 0, 0, 1)"
4430
- }
3950
+ },
3951
+ feedback: "clone"
4431
3952
  });
4432
- const thisIsDragging = status === "dragging";
4433
- const ref = useRef2(null);
4434
- const refSetter = useCallback6(
4435
- (el) => {
4436
- sortableRef(el);
3953
+ useEffect12(() => {
3954
+ const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
3955
+ sortable.droppable.disabled = !isEnabled;
3956
+ sortable.draggable.disabled = !permissions.drag;
3957
+ const cleanup = zoneStore.subscribe((s) => {
3958
+ sortable.droppable.disabled = !s.enabledIndex[zoneCompound];
3959
+ });
3960
+ if (ref.current && !permissions.drag) {
3961
+ ref.current.setAttribute("data-puck-disabled", "");
3962
+ return () => {
3963
+ var _a;
3964
+ (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
3965
+ cleanup();
3966
+ };
3967
+ }
3968
+ return cleanup;
3969
+ }, [permissions.drag, zoneCompound]);
3970
+ const ref = useRef2(null);
3971
+ const refSetter = useCallback7(
3972
+ (el) => {
3973
+ sortableRef(el);
4437
3974
  if (el) {
4438
3975
  ref.current = el;
4439
3976
  }
@@ -4441,13 +3978,13 @@ var DraggableComponent = ({
4441
3978
  [sortableRef]
4442
3979
  );
4443
3980
  const [portalEl, setPortalEl] = useState10();
4444
- useEffect11(() => {
3981
+ useEffect12(() => {
4445
3982
  var _a, _b, _c;
4446
3983
  setPortalEl(
4447
3984
  iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
4448
3985
  );
4449
3986
  }, [iframe.enabled, ref.current]);
4450
- const getStyle = useCallback6(() => {
3987
+ const getStyle = useCallback7(() => {
4451
3988
  var _a, _b, _c;
4452
3989
  if (!ref.current) return;
4453
3990
  const rect = ref.current.getBoundingClientRect();
@@ -4459,40 +3996,61 @@ var DraggableComponent = ({
4459
3996
  x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
4460
3997
  y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
4461
3998
  };
3999
+ const untransformed = {
4000
+ height: ref.current.offsetHeight,
4001
+ width: ref.current.offsetWidth
4002
+ };
4003
+ const transform = accumulateTransform(ref.current);
4462
4004
  const style2 = {
4463
- left: `${rect.left + scroll.x}px`,
4464
- top: `${rect.top + scroll.y}px`,
4465
- height: `${rect.height}px`,
4466
- width: `${rect.width}px`
4005
+ left: `${(rect.left + scroll.x) / transform.scaleX}px`,
4006
+ top: `${(rect.top + scroll.y) / transform.scaleY}px`,
4007
+ height: `${untransformed.height}px`,
4008
+ width: `${untransformed.width}px`
4467
4009
  };
4468
4010
  return style2;
4469
4011
  }, [ref.current]);
4470
4012
  const [style, setStyle] = useState10();
4471
- const sync = useCallback6(() => {
4013
+ const sync = useCallback7(() => {
4472
4014
  setStyle(getStyle());
4473
4015
  }, [ref.current, iframe]);
4474
- useEffect11(() => {
4475
- if (ref.current && !userIsDragging) {
4016
+ useEffect12(() => {
4017
+ if (ref.current) {
4476
4018
  const observer = new ResizeObserver(sync);
4477
4019
  observer.observe(ref.current);
4478
4020
  return () => {
4479
4021
  observer.disconnect();
4480
4022
  };
4481
4023
  }
4482
- }, [ref.current, userIsDragging]);
4024
+ }, [ref.current]);
4483
4025
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4484
- useEffect11(() => {
4026
+ const hideOverlay = useCallback7(() => {
4027
+ setIsVisible(false);
4028
+ }, []);
4029
+ const showOverlay = useCallback7(() => {
4030
+ setIsVisible(true);
4031
+ }, []);
4032
+ useEffect12(() => {
4485
4033
  var _a;
4486
- registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
4034
+ registerNode(id, {
4035
+ methods: { sync, showOverlay, hideOverlay },
4036
+ element: (_a = ref.current) != null ? _a : null
4037
+ });
4487
4038
  return () => {
4488
- registerNode(id, { methods: { sync: () => null }, element: null });
4039
+ registerNode(id, {
4040
+ methods: {
4041
+ sync: () => null,
4042
+ hideOverlay: () => null,
4043
+ showOverlay: () => null
4044
+ },
4045
+ element: null
4046
+ });
4489
4047
  };
4490
4048
  }, [id, zoneCompound, index, componentType, sync]);
4491
4049
  const CustomActionBar = useMemo7(
4492
4050
  () => overrides.actionBar || DefaultActionBar,
4493
4051
  [overrides.actionBar]
4494
4052
  );
4495
- const onClick = useCallback6(
4053
+ const onClick = useCallback7(
4496
4054
  (e) => {
4497
4055
  e.stopPropagation();
4498
4056
  dispatch({
@@ -4505,7 +4063,7 @@ var DraggableComponent = ({
4505
4063
  [index, zoneCompound, id]
4506
4064
  );
4507
4065
  const appStore = useAppStoreApi();
4508
- const onSelectParent = useCallback6(() => {
4066
+ const onSelectParent = useCallback7(() => {
4509
4067
  const { nodes, zones } = appStore.getState().state.indexes;
4510
4068
  const node = nodes[id];
4511
4069
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4526,14 +4084,14 @@ var DraggableComponent = ({
4526
4084
  }
4527
4085
  });
4528
4086
  }, [ctx, path]);
4529
- const onDuplicate = useCallback6(() => {
4087
+ const onDuplicate = useCallback7(() => {
4530
4088
  dispatch({
4531
4089
  type: "duplicate",
4532
4090
  sourceIndex: index,
4533
4091
  sourceZone: zoneCompound
4534
4092
  });
4535
4093
  }, [index, zoneCompound]);
4536
- const onDelete = useCallback6(() => {
4094
+ const onDelete = useCallback7(() => {
4537
4095
  dispatch({
4538
4096
  type: "remove",
4539
4097
  index,
@@ -4541,13 +4099,17 @@ var DraggableComponent = ({
4541
4099
  });
4542
4100
  }, [index, zoneCompound]);
4543
4101
  const [hover, setHover] = useState10(false);
4544
- const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4545
- useEffect11(() => {
4102
+ const indicativeHover = useContextStore(
4103
+ ZoneStoreContext,
4104
+ (s) => s.hoveringComponent === id
4105
+ );
4106
+ useEffect12(() => {
4546
4107
  if (!ref.current) {
4547
4108
  return;
4548
4109
  }
4549
4110
  const el = ref.current;
4550
4111
  const _onMouseOver = (e) => {
4112
+ const userIsDragging = !!zoneStore.getState().draggedItem;
4551
4113
  if (userIsDragging) {
4552
4114
  if (thisIsDragging) {
4553
4115
  setHover(true);
@@ -4569,18 +4131,12 @@ var DraggableComponent = ({
4569
4131
  el.addEventListener("click", onClick);
4570
4132
  el.addEventListener("mouseover", _onMouseOver);
4571
4133
  el.addEventListener("mouseout", _onMouseOut);
4572
- if (thisIsDragging) {
4573
- el.setAttribute("data-puck-dragging", "");
4574
- } else {
4575
- el.removeAttribute("data-puck-dragging");
4576
- }
4577
4134
  return () => {
4578
4135
  el.removeAttribute("data-puck-component");
4579
4136
  el.removeAttribute("data-puck-dnd");
4580
4137
  el.removeEventListener("click", onClick);
4581
4138
  el.removeEventListener("mouseover", _onMouseOver);
4582
4139
  el.removeEventListener("mouseout", _onMouseOut);
4583
- el.removeAttribute("data-puck-dragging");
4584
4140
  };
4585
4141
  }, [
4586
4142
  ref,
@@ -4588,29 +4144,43 @@ var DraggableComponent = ({
4588
4144
  containsActiveZone,
4589
4145
  zoneCompound,
4590
4146
  id,
4591
- userIsDragging,
4592
4147
  thisIsDragging,
4593
4148
  inDroppableZone
4594
4149
  ]);
4595
- useEffect11(() => {
4596
- if (ref.current && disabled) {
4597
- ref.current.setAttribute("data-puck-disabled", "");
4598
- return () => {
4599
- var _a;
4600
- (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4601
- };
4602
- }
4603
- }, [disabled, ref]);
4604
4150
  const [isVisible, setIsVisible] = useState10(false);
4605
- useEffect11(() => {
4606
- sync();
4607
- if ((isSelected || hover || indicativeHover) && !userIsDragging) {
4608
- setIsVisible(true);
4151
+ const [dragFinished, setDragFinished] = useState10(true);
4152
+ const [_, startTransition] = useTransition();
4153
+ useEffect12(() => {
4154
+ startTransition(() => {
4155
+ if (hover || indicativeHover || isSelected) {
4156
+ sync();
4157
+ setIsVisible(true);
4158
+ setThisWasDragging(false);
4159
+ } else {
4160
+ setIsVisible(false);
4161
+ }
4162
+ });
4163
+ }, [hover, indicativeHover, isSelected, iframe]);
4164
+ const [thisWasDragging, setThisWasDragging] = useState10(false);
4165
+ const onDragFinished = useOnDragFinished((finished) => {
4166
+ if (finished) {
4167
+ startTransition(() => {
4168
+ sync();
4169
+ setDragFinished(true);
4170
+ });
4609
4171
  } else {
4610
- setIsVisible(false);
4172
+ setDragFinished(false);
4173
+ }
4174
+ });
4175
+ useEffect12(() => {
4176
+ if (thisIsDragging) {
4177
+ setThisWasDragging(true);
4611
4178
  }
4612
- }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
4613
- const syncActionsPosition = useCallback6(
4179
+ }, [thisIsDragging]);
4180
+ useEffect12(() => {
4181
+ if (thisWasDragging) return onDragFinished();
4182
+ }, [thisWasDragging, onDragFinished]);
4183
+ const syncActionsPosition = useCallback7(
4614
4184
  (el) => {
4615
4185
  if (el) {
4616
4186
  const view = el.ownerDocument.defaultView;
@@ -4635,7 +4205,7 @@ var DraggableComponent = ({
4635
4205
  },
4636
4206
  [zoom]
4637
4207
  );
4638
- useEffect11(() => {
4208
+ useEffect12(() => {
4639
4209
  if (userDragAxis) {
4640
4210
  setDragAxis(userDragAxis);
4641
4211
  return;
@@ -4649,7 +4219,10 @@ var DraggableComponent = ({
4649
4219
  }
4650
4220
  setDragAxis(autoDragAxis);
4651
4221
  }, [ref, userDragAxis, autoDragAxis]);
4652
- const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx20(CornerLeftUp, { size: 16 }) });
4222
+ const parentAction = useMemo7(
4223
+ () => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx20(CornerLeftUp, { size: 16 }) }),
4224
+ [ctx == null ? void 0 : ctx.areaId]
4225
+ );
4653
4226
  const nextContextValue = useMemo7(
4654
4227
  () => __spreadProps(__spreadValues({}, ctx), {
4655
4228
  areaId: id,
@@ -4670,7 +4243,7 @@ var DraggableComponent = ({
4670
4243
  ]
4671
4244
  );
4672
4245
  return /* @__PURE__ */ jsxs9(DropZoneProvider, { value: nextContextValue, children: [
4673
- isVisible && createPortal2(
4246
+ dragFinished && isVisible && createPortal2(
4674
4247
  /* @__PURE__ */ jsxs9(
4675
4248
  "div",
4676
4249
  {
@@ -4730,11 +4303,15 @@ var DraggableComponent = ({
4730
4303
 
4731
4304
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
4732
4305
  init_react_import();
4733
- var styles_module_default12 = { "DropZone": "_DropZone_3dmev_1", "DropZone--hasChildren": "_DropZone--hasChildren_3dmev_11", "DropZone--userIsDragging": "_DropZone--userIsDragging_3dmev_19", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_3dmev_23", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_3dmev_24", "DropZone--isRootZone": "_DropZone--isRootZone_3dmev_24", "DropZone--isDestination": "_DropZone--isDestination_3dmev_34", "DropZone-item": "_DropZone-item_3dmev_46", "DropZone-hitbox": "_DropZone-hitbox_3dmev_50", "DropZone--isEnabled": "_DropZone--isEnabled_3dmev_58", "DropZone--isAnimating": "_DropZone--isAnimating_3dmev_67" };
4306
+ var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
4307
+
4308
+ // components/DropZone/index.tsx
4309
+ import { useDroppable } from "@dnd-kit/react";
4734
4310
 
4735
4311
  // components/DropZone/lib/use-min-empty-height.ts
4736
4312
  init_react_import();
4737
- import { useEffect as useEffect12, useState as useState11 } from "react";
4313
+ import { useEffect as useEffect13, useRef as useRef3, useState as useState11 } from "react";
4314
+ var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
4738
4315
  var useMinEmptyHeight = ({
4739
4316
  zoneCompound,
4740
4317
  userMinEmptyHeight,
@@ -4750,32 +4327,52 @@ var useMinEmptyHeight = ({
4750
4327
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
4751
4328
  };
4752
4329
  });
4753
- useEffect12(() => {
4330
+ const numItems = useRef3(0);
4331
+ const onDragFinished = useOnDragFinished(
4332
+ (finished) => {
4333
+ var _a;
4334
+ if (finished) {
4335
+ const newNumItems = getNumItems(appStore, zoneCompound);
4336
+ setPrevHeight(0);
4337
+ if (newNumItems || numItems.current === 0) {
4338
+ setIsAnimating(false);
4339
+ return;
4340
+ }
4341
+ const selectedItem = appStore.getState().selectedItem;
4342
+ const zones = appStore.getState().state.indexes.zones;
4343
+ const nodes = appStore.getState().nodes;
4344
+ (_a = nodes.nodes[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.methods.hideOverlay();
4345
+ setTimeout(() => {
4346
+ var _a2;
4347
+ const contentIds = ((_a2 = zones[zoneCompound]) == null ? void 0 : _a2.contentIds) || [];
4348
+ contentIds.forEach((contentId) => {
4349
+ const node = nodes.nodes[contentId];
4350
+ node == null ? void 0 : node.methods.sync();
4351
+ });
4352
+ if (selectedItem) {
4353
+ setTimeout(() => {
4354
+ var _a3, _b;
4355
+ (_a3 = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _a3.methods.sync();
4356
+ (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.showOverlay();
4357
+ }, 200);
4358
+ }
4359
+ setIsAnimating(false);
4360
+ }, 100);
4361
+ }
4362
+ },
4363
+ [appStore, prevHeight, zoneCompound]
4364
+ );
4365
+ useEffect13(() => {
4754
4366
  if (draggedItem && ref.current) {
4755
4367
  if (isZone) {
4756
4368
  const rect = ref.current.getBoundingClientRect();
4369
+ numItems.current = getNumItems(appStore, zoneCompound);
4757
4370
  setPrevHeight(rect.height);
4758
4371
  setIsAnimating(true);
4759
- return;
4372
+ return onDragFinished();
4760
4373
  }
4761
4374
  }
4762
- setPrevHeight(0);
4763
- setTimeout(() => {
4764
- var _a, _b;
4765
- const zones = appStore.getState().state.indexes.zones;
4766
- const nodes = appStore.getState().nodes;
4767
- const selectedItem = appStore.getState().selectedItem;
4768
- const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
4769
- contentIds.forEach((contentId) => {
4770
- const node = nodes.nodes[contentId];
4771
- node == null ? void 0 : node.methods.sync();
4772
- });
4773
- if (selectedItem) {
4774
- (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
4775
- }
4776
- setIsAnimating(false);
4777
- }, 400);
4778
- }, [ref.current, draggedItem, zoneCompound]);
4375
+ }, [ref.current, draggedItem, onDragFinished]);
4779
4376
  return [prevHeight || userMinEmptyHeight, isAnimating];
4780
4377
  };
4781
4378
 
@@ -4796,15 +4393,15 @@ function assignRefs(refs, node) {
4796
4393
 
4797
4394
  // components/DropZone/lib/use-content-with-preview.ts
4798
4395
  init_react_import();
4799
- import { useEffect as useEffect13, useState as useState12 } from "react";
4396
+ import { useContext as useContext6, useEffect as useEffect14, useState as useState12 } from "react";
4800
4397
 
4801
4398
  // lib/dnd/use-rendered-callback.ts
4802
4399
  init_react_import();
4803
4400
  import { useDragDropManager } from "@dnd-kit/react";
4804
- import { useCallback as useCallback7 } from "react";
4401
+ import { useCallback as useCallback8 } from "react";
4805
4402
  function useRenderedCallback(callback, deps) {
4806
4403
  const manager = useDragDropManager();
4807
- return useCallback7(
4404
+ return useCallback8(
4808
4405
  (...args) => __async(this, null, function* () {
4809
4406
  yield manager == null ? void 0 : manager.renderer.rendering;
4810
4407
  return callback(...args);
@@ -4815,16 +4412,10 @@ function useRenderedCallback(callback, deps) {
4815
4412
 
4816
4413
  // components/DropZone/lib/use-content-with-preview.ts
4817
4414
  var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4818
- const { draggedItemId, preview, previewExists } = useContextStore(
4415
+ const zoneStore = useContext6(ZoneStoreContext);
4416
+ const preview = useContextStore(
4819
4417
  ZoneStoreContext,
4820
- (s) => {
4821
- var _a;
4822
- return {
4823
- draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
4824
- preview: s.previewIndex[zoneCompound],
4825
- previewExists: Object.keys(s.previewIndex || {}).length > 0
4826
- };
4827
- }
4418
+ (s) => s.previewIndex[zoneCompound]
4828
4419
  );
4829
4420
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
4830
4421
  const [contentIdsWithPreview, setContentIdsWithPreview] = useState12(contentIds);
@@ -4832,10 +4423,10 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4832
4423
  preview
4833
4424
  );
4834
4425
  const updateContent = useRenderedCallback(
4835
- (contentIds2, preview2, isDragging2) => {
4836
- if (isDragging2 && !previewExists) {
4837
- return;
4838
- }
4426
+ (contentIds2, preview2) => {
4427
+ var _a;
4428
+ const s = zoneStore.getState();
4429
+ const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
4839
4430
  if (preview2) {
4840
4431
  if (preview2.type === "insert") {
4841
4432
  setContentIdsWithPreview(
@@ -4856,14 +4447,14 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4856
4447
  }
4857
4448
  } else {
4858
4449
  setContentIdsWithPreview(
4859
- previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
4450
+ contentIds2.filter((id) => id !== draggedItemId)
4860
4451
  );
4861
4452
  }
4862
4453
  setLocalPreview(preview2);
4863
4454
  },
4864
- [draggedItemId, previewExists]
4455
+ []
4865
4456
  );
4866
- useEffect13(() => {
4457
+ useEffect14(() => {
4867
4458
  updateContent(contentIds, preview, isDragging);
4868
4459
  }, [contentIds, preview, isDragging]);
4869
4460
  return [contentIdsWithPreview, localPreview];
@@ -4871,7 +4462,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4871
4462
 
4872
4463
  // components/DropZone/lib/use-drag-axis.ts
4873
4464
  init_react_import();
4874
- import { useCallback as useCallback8, useEffect as useEffect14, useState as useState13 } from "react";
4465
+ import { useCallback as useCallback9, useEffect as useEffect15, useState as useState13 } from "react";
4875
4466
  var GRID_DRAG_AXIS = "dynamic";
4876
4467
  var FLEX_ROW_DRAG_AXIS = "x";
4877
4468
  var DEFAULT_DRAG_AXIS = "y";
@@ -4880,7 +4471,7 @@ var useDragAxis = (ref, collisionAxis) => {
4880
4471
  const [dragAxis, setDragAxis] = useState13(
4881
4472
  collisionAxis || DEFAULT_DRAG_AXIS
4882
4473
  );
4883
- const calculateDragAxis = useCallback8(() => {
4474
+ const calculateDragAxis = useCallback9(() => {
4884
4475
  if (ref.current) {
4885
4476
  const computedStyle = window.getComputedStyle(ref.current);
4886
4477
  if (computedStyle.display === "grid") {
@@ -4892,7 +4483,7 @@ var useDragAxis = (ref, collisionAxis) => {
4892
4483
  }
4893
4484
  }
4894
4485
  }, [ref.current]);
4895
- useEffect14(() => {
4486
+ useEffect15(() => {
4896
4487
  const onViewportChange = () => {
4897
4488
  calculateDragAxis();
4898
4489
  };
@@ -4901,7 +4492,7 @@ var useDragAxis = (ref, collisionAxis) => {
4901
4492
  window.removeEventListener("viewportchange", onViewportChange);
4902
4493
  };
4903
4494
  }, []);
4904
- useEffect14(calculateDragAxis, [status, collisionAxis]);
4495
+ useEffect15(calculateDragAxis, [status, collisionAxis]);
4905
4496
  return [dragAxis, calculateDragAxis];
4906
4497
  };
4907
4498
 
@@ -4991,17 +4582,16 @@ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx23(DropZoneEdit, __spreadVa
4991
4582
  var DropZoneChild = ({
4992
4583
  zoneCompound,
4993
4584
  componentId,
4994
- preview,
4995
4585
  index,
4996
- isEnabled,
4997
4586
  dragAxis,
4998
4587
  collisionAxis,
4999
4588
  inDroppableZone
5000
4589
  }) => {
5001
4590
  var _a, _b;
5002
4591
  const metadata = useAppStore((s) => s.metadata);
5003
- const ctx = useContext6(dropZoneContext);
4592
+ const ctx = useContext7(dropZoneContext);
5004
4593
  const { depth = 1 } = ctx != null ? ctx : {};
4594
+ const zoneStore = useContext7(ZoneStoreContext);
5005
4595
  const nodeProps = useAppStore(
5006
4596
  useShallow3((s) => {
5007
4597
  var _a2;
@@ -5020,17 +4610,32 @@ var DropZoneChild = ({
5020
4610
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
5021
4611
  })
5022
4612
  );
5023
- const node = { type: nodeType, props: nodeProps };
5024
- const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
4613
+ const item = useMemo9(() => {
4614
+ if (nodeProps) {
4615
+ return { type: nodeType, props: nodeProps };
4616
+ }
4617
+ const preview = zoneStore.getState().previewIndex[zoneCompound];
4618
+ if (componentId === (preview == null ? void 0 : preview.props.id)) {
4619
+ return {
4620
+ type: preview.componentType,
4621
+ props: preview.props,
4622
+ previewType: preview.type
4623
+ };
4624
+ }
4625
+ return null;
4626
+ }, [componentId, zoneCompound, nodeType, nodeProps]);
5025
4627
  const componentConfig = useAppStore(
5026
4628
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
5027
4629
  );
5028
- const puckProps = {
5029
- renderDropZone: DropZoneEditPure,
5030
- isEditing: true,
5031
- dragRef: null,
5032
- metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5033
- };
4630
+ const puckProps = useMemo9(
4631
+ () => ({
4632
+ renderDropZone: DropZoneEditPure,
4633
+ isEditing: true,
4634
+ dragRef: null,
4635
+ metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
4636
+ }),
4637
+ [metadata, componentConfig == null ? void 0 : componentConfig.metadata]
4638
+ );
5034
4639
  const overrides = useAppStore((s) => s.overrides);
5035
4640
  const isLoading = useAppStore(
5036
4641
  (s) => {
@@ -5046,7 +4651,7 @@ var DropZoneChild = ({
5046
4651
  );
5047
4652
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
5048
4653
  const renderPreview = useMemo9(
5049
- () => function Preview4() {
4654
+ () => function Preview3() {
5050
4655
  return /* @__PURE__ */ jsx23(DrawerItemInner, { name: label, children: overrides.componentItem });
5051
4656
  },
5052
4657
  [componentId, label, overrides]
@@ -5073,8 +4678,8 @@ var DropZoneChild = ({
5073
4678
  item.type
5074
4679
  ] });
5075
4680
  let componentType = item.type;
5076
- const isPreview = componentId === (preview == null ? void 0 : preview.props.id) && preview.type === "insert";
5077
- if (isPreview) {
4681
+ const isInserting = item.previewType === "insert";
4682
+ if (isInserting) {
5078
4683
  Render2 = renderPreview;
5079
4684
  }
5080
4685
  return /* @__PURE__ */ jsx23(
@@ -5088,11 +4693,10 @@ var DropZoneChild = ({
5088
4693
  isLoading,
5089
4694
  isSelected,
5090
4695
  label,
5091
- isEnabled,
5092
4696
  autoDragAxis: dragAxis,
5093
4697
  userDragAxis: collisionAxis,
5094
4698
  inDroppableZone,
5095
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ jsx23(Fragment6, { children: /* @__PURE__ */ jsx23(
4699
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ jsx23(Fragment6, { children: /* @__PURE__ */ jsx23(
5096
4700
  Render2,
5097
4701
  __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
5098
4702
  puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
@@ -5114,7 +4718,7 @@ var DropZoneEdit = forwardRef3(
5114
4718
  minEmptyHeight: userMinEmptyHeight = 128,
5115
4719
  collisionAxis
5116
4720
  }, userRef) {
5117
- const ctx = useContext6(dropZoneContext);
4721
+ const ctx = useContext7(dropZoneContext);
5118
4722
  const {
5119
4723
  // These all need setting via context
5120
4724
  areaId,
@@ -5135,20 +4739,10 @@ var DropZoneEdit = forwardRef3(
5135
4739
  }
5136
4740
  }
5137
4741
  const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
5138
- const {
5139
- isDeepestZone,
5140
- inNextDeepestArea,
5141
- draggedComponentType,
5142
- userIsDragging
5143
- } = useContextStore(ZoneStoreContext, (s) => {
5144
- var _a, _b;
5145
- return {
5146
- isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
5147
- inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
5148
- draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
5149
- userIsDragging: !!s.draggedItem
5150
- };
5151
- });
4742
+ const inNextDeepestArea = useContextStore(
4743
+ ZoneStoreContext,
4744
+ (s) => s.nextAreaDepthIndex[areaId || ""]
4745
+ );
5152
4746
  const zoneContentIds = useAppStore(
5153
4747
  useShallow3((s) => {
5154
4748
  var _a;
@@ -5161,13 +4755,8 @@ var DropZoneEdit = forwardRef3(
5161
4755
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
5162
4756
  })
5163
4757
  );
5164
- useEffect15(() => {
4758
+ useEffect16(() => {
5165
4759
  if (!zoneType || zoneType === "dropzone") {
5166
- if (zoneCompound !== rootDroppableId) {
5167
- console.warn(
5168
- "DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
5169
- );
5170
- }
5171
4760
  if (ctx == null ? void 0 : ctx.registerZone) {
5172
4761
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5173
4762
  }
@@ -5178,11 +4767,20 @@ var DropZoneEdit = forwardRef3(
5178
4767
  };
5179
4768
  }
5180
4769
  }, [zoneType]);
4770
+ useEffect16(() => {
4771
+ if (zoneType === "dropzone") {
4772
+ if (zoneCompound !== rootDroppableId) {
4773
+ console.warn(
4774
+ "DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
4775
+ );
4776
+ }
4777
+ }
4778
+ }, [zoneType]);
5181
4779
  const contentIds = useMemo9(() => {
5182
4780
  return zoneContentIds || [];
5183
4781
  }, [zoneContentIds]);
5184
- const ref = useRef3(null);
5185
- const acceptsTarget = useCallback9(
4782
+ const ref = useRef4(null);
4783
+ const acceptsTarget = useCallback10(
5186
4784
  (componentType) => {
5187
4785
  if (!componentType) {
5188
4786
  return true;
@@ -5204,29 +4802,44 @@ var DropZoneEdit = forwardRef3(
5204
4802
  },
5205
4803
  [allow, disallow]
5206
4804
  );
5207
- useEffect15(() => {
4805
+ const targetAccepted = useContextStore(ZoneStoreContext, (s) => {
4806
+ var _a;
4807
+ const draggedComponentType = (_a = s.draggedItem) == null ? void 0 : _a.data.componentType;
4808
+ return acceptsTarget(draggedComponentType);
4809
+ });
4810
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
4811
+ const isEnabled = useContextStore(ZoneStoreContext, (s) => {
4812
+ var _a;
4813
+ let _isEnabled = true;
4814
+ const isDeepestZone = (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false;
4815
+ _isEnabled = isDeepestZone;
4816
+ if (_isEnabled) {
4817
+ _isEnabled = targetAccepted;
4818
+ }
4819
+ return _isEnabled;
4820
+ });
4821
+ useEffect16(() => {
5208
4822
  if (registerLocalZone) {
5209
- registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
4823
+ registerLocalZone(zoneCompound, isEnabled);
5210
4824
  }
5211
4825
  return () => {
5212
4826
  if (unregisterLocalZone) {
5213
4827
  unregisterLocalZone(zoneCompound);
5214
4828
  }
5215
4829
  };
5216
- }, [draggedComponentType, zoneCompound]);
5217
- const hoveringOverArea = inNextDeepestArea || isRootZone;
5218
- let isEnabled = true;
5219
- if (userIsDragging) {
5220
- isEnabled = isDeepestZone;
5221
- }
5222
- if (isEnabled) {
5223
- isEnabled = acceptsTarget(draggedComponentType);
5224
- }
4830
+ }, [isEnabled, zoneCompound]);
5225
4831
  const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
5226
4832
  contentIds,
5227
4833
  zoneCompound
5228
4834
  );
5229
4835
  const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
4836
+ const zoneStore = useContext7(ZoneStoreContext);
4837
+ useEffect16(() => {
4838
+ const { enabledIndex } = zoneStore.getState();
4839
+ zoneStore.setState({
4840
+ enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
4841
+ });
4842
+ }, [isEnabled, zoneStore, zoneCompound]);
5230
4843
  const droppableConfig = {
5231
4844
  id: zoneCompound,
5232
4845
  collisionPriority: isEnabled ? depth : 0,
@@ -5236,11 +4849,11 @@ var DropZoneEdit = forwardRef3(
5236
4849
  data: {
5237
4850
  areaId,
5238
4851
  depth,
5239
- isDroppableTarget: acceptsTarget(draggedComponentType),
4852
+ isDroppableTarget: targetAccepted,
5240
4853
  path: path || []
5241
4854
  }
5242
4855
  };
5243
- const { ref: dropRef } = useDroppableSafe(droppableConfig);
4856
+ const { ref: dropRef } = useDroppable(droppableConfig);
5244
4857
  const isAreaSelected = useAppStore(
5245
4858
  (s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
5246
4859
  );
@@ -5255,7 +4868,6 @@ var DropZoneEdit = forwardRef3(
5255
4868
  {
5256
4869
  className: `${getClassName17({
5257
4870
  isRootZone,
5258
- userIsDragging,
5259
4871
  hoveringOverArea,
5260
4872
  isEnabled,
5261
4873
  isAreaSelected,
@@ -5277,12 +4889,10 @@ var DropZoneEdit = forwardRef3(
5277
4889
  {
5278
4890
  zoneCompound,
5279
4891
  componentId,
5280
- preview,
5281
4892
  dragAxis,
5282
- isEnabled,
5283
4893
  index: i,
5284
4894
  collisionAxis,
5285
- inDroppableZone: acceptsTarget(draggedComponentType)
4895
+ inDroppableZone: targetAccepted
5286
4896
  },
5287
4897
  componentId
5288
4898
  );
@@ -5318,12 +4928,12 @@ var DropZoneRenderItem = ({
5318
4928
  var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx23(DropZoneRender, __spreadValues({}, props));
5319
4929
  var DropZoneRender = forwardRef3(
5320
4930
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5321
- const ctx = useContext6(dropZoneContext);
4931
+ const ctx = useContext7(dropZoneContext);
5322
4932
  const { areaId = "root" } = ctx || {};
5323
- const { config, data, metadata } = useContext6(renderContext);
4933
+ const { config, data, metadata } = useContext7(renderContext);
5324
4934
  let zoneCompound = rootDroppableId;
5325
4935
  let content = (data == null ? void 0 : data.content) || [];
5326
- useEffect15(() => {
4936
+ useEffect16(() => {
5327
4937
  if (!content) {
5328
4938
  if (ctx == null ? void 0 : ctx.registerZone) {
5329
4939
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
@@ -5362,7 +4972,7 @@ var DropZoneRender = forwardRef3(
5362
4972
  var DropZonePure = (props) => /* @__PURE__ */ jsx23(DropZone, __spreadValues({}, props));
5363
4973
  var DropZone = forwardRef3(
5364
4974
  function DropZone2(props, ref) {
5365
- const ctx = useContext6(dropZoneContext);
4975
+ const ctx = useContext7(dropZoneContext);
5366
4976
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5367
4977
  return /* @__PURE__ */ jsx23(Fragment6, { children: /* @__PURE__ */ jsx23(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5368
4978
  }
@@ -5373,7 +4983,6 @@ var DropZone = forwardRef3(
5373
4983
  // lib/dnd/NestedDroppablePlugin.ts
5374
4984
  init_react_import();
5375
4985
  import { Plugin } from "@dnd-kit/abstract";
5376
- import { effects } from "@dnd-kit/state";
5377
4986
 
5378
4987
  // lib/throttle.ts
5379
4988
  init_react_import();
@@ -5422,7 +5031,7 @@ var GlobalPosition = class {
5422
5031
  var _a;
5423
5032
  this.target = target;
5424
5033
  this.original = original;
5425
- this.frameEl = document.querySelector("#preview-frame");
5034
+ this.frameEl = document.querySelector("iframe#preview-frame");
5426
5035
  if (this.frameEl) {
5427
5036
  this.frameRect = this.frameEl.getBoundingClientRect();
5428
5037
  this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
@@ -5487,7 +5096,7 @@ var depthSort = (candidates) => {
5487
5096
  return 0;
5488
5097
  });
5489
5098
  };
5490
- var getZoneId2 = (candidate) => {
5099
+ var getZoneId = (candidate) => {
5491
5100
  let id = candidate == null ? void 0 : candidate.id;
5492
5101
  if (!candidate) return null;
5493
5102
  if (candidate.type === "component") {
@@ -5502,6 +5111,7 @@ var getZoneId2 = (candidate) => {
5502
5111
  }
5503
5112
  return id;
5504
5113
  };
5114
+ var BUFFER = 6;
5505
5115
  var getPointerCollisions = (position, manager) => {
5506
5116
  const candidates = [];
5507
5117
  let elements = position.target.ownerDocument.elementsFromPoint(
@@ -5525,13 +5135,26 @@ var getPointerCollisions = (position, manager) => {
5525
5135
  for (let i = 0; i < elements.length; i++) {
5526
5136
  const element = elements[i];
5527
5137
  const dropzoneId = element.getAttribute("data-puck-dropzone");
5138
+ const id = element.getAttribute("data-puck-dnd");
5139
+ const isVoid = element.hasAttribute("data-puck-dnd-void");
5140
+ if (BUFFER && (dropzoneId || id) && !isVoid) {
5141
+ const box = element.getBoundingClientRect();
5142
+ const contractedBox = {
5143
+ left: box.left + BUFFER,
5144
+ right: box.right - BUFFER,
5145
+ top: box.top + BUFFER,
5146
+ bottom: box.bottom - BUFFER
5147
+ };
5148
+ if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
5149
+ continue;
5150
+ }
5151
+ }
5528
5152
  if (dropzoneId) {
5529
5153
  const droppable = manager.registry.droppables.get(dropzoneId);
5530
5154
  if (droppable) {
5531
5155
  candidates.push(droppable);
5532
5156
  }
5533
5157
  }
5534
- const id = element.getAttribute("data-puck-dnd");
5535
5158
  if (id) {
5536
5159
  const droppable = manager.registry.droppables.get(id);
5537
5160
  if (droppable) {
@@ -5580,13 +5203,13 @@ var findDeepestCandidate = (position, manager) => {
5580
5203
  return true;
5581
5204
  });
5582
5205
  filteredCandidates.reverse();
5583
- const zone = getZoneId2(filteredCandidates[0]);
5206
+ const zone = getZoneId(filteredCandidates[0]);
5584
5207
  const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
5585
5208
  return { zone, area };
5586
5209
  }
5587
5210
  return {
5588
- zone: "default-zone",
5589
- area: null
5211
+ zone: rootDroppableId,
5212
+ area: rootAreaId
5590
5213
  };
5591
5214
  };
5592
5215
  var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
@@ -5595,7 +5218,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
5595
5218
  if (typeof window === "undefined") {
5596
5219
  return;
5597
5220
  }
5598
- const cleanupEffect = effects(() => {
5221
+ this.registerEffect(() => {
5599
5222
  const handleMove = (event) => {
5600
5223
  const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
5601
5224
  const position = new GlobalPosition(target, {
@@ -5619,12 +5242,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
5619
5242
  capture: true
5620
5243
  // dndkit's PointerSensor prevents propagation during drag
5621
5244
  });
5622
- this.destroy = () => {
5245
+ const cleanup = () => {
5623
5246
  document.body.removeEventListener("pointermove", handlePointerMove, {
5624
5247
  capture: true
5625
5248
  });
5626
- cleanupEffect();
5627
5249
  };
5250
+ return cleanup;
5628
5251
  });
5629
5252
  }
5630
5253
  };
@@ -5684,14 +5307,15 @@ function getDeepDir(el) {
5684
5307
  }
5685
5308
 
5686
5309
  // components/DragDropContext/index.tsx
5310
+ import { effect } from "@dnd-kit/state";
5687
5311
  import { jsx as jsx24 } from "react/jsx-runtime";
5688
5312
  var DEBUG3 = false;
5689
5313
  var dragListenerContext = createContext4({
5690
5314
  dragListeners: {}
5691
5315
  });
5692
5316
  function useDragListener(type, fn, deps = []) {
5693
- const { setDragListeners } = useContext7(dragListenerContext);
5694
- useEffect16(() => {
5317
+ const { setDragListeners } = useContext8(dragListenerContext);
5318
+ useEffect17(() => {
5695
5319
  if (setDragListeners) {
5696
5320
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
5697
5321
  [type]: [...old[type] || [], fn]
@@ -5701,8 +5325,8 @@ function useDragListener(type, fn, deps = []) {
5701
5325
  }
5702
5326
  var AREA_CHANGE_DEBOUNCE_MS = 100;
5703
5327
  var useTempDisableFallback = (timeout3) => {
5704
- const lastFallbackDisable = useRef4(null);
5705
- return useCallback10((manager) => {
5328
+ const lastFallbackDisable = useRef5(null);
5329
+ return useCallback11((manager) => {
5706
5330
  collisionStore.setState({ fallbackEnabled: false });
5707
5331
  const fallbackId = generateId();
5708
5332
  lastFallbackDisable.current = fallbackId;
@@ -5721,7 +5345,7 @@ var DragDropContextClient = ({
5721
5345
  const dispatch = useAppStore((s) => s.dispatch);
5722
5346
  const appStore = useAppStoreApi();
5723
5347
  const id = useSafeId();
5724
- const debouncedParamsRef = useRef4(null);
5348
+ const debouncedParamsRef = useRef5(null);
5725
5349
  const tempDisableFallback = useTempDisableFallback(100);
5726
5350
  const [zoneStore] = useState14(
5727
5351
  () => createStore3(() => ({
@@ -5730,10 +5354,12 @@ var DragDropContextClient = ({
5730
5354
  areaDepthIndex: {},
5731
5355
  nextAreaDepthIndex: {},
5732
5356
  draggedItem: null,
5733
- previewIndex: {}
5357
+ previewIndex: {},
5358
+ enabledIndex: {},
5359
+ hoveringComponent: null
5734
5360
  }))
5735
5361
  );
5736
- const getChanged2 = useCallback10(
5362
+ const getChanged2 = useCallback11(
5737
5363
  (params, id2) => {
5738
5364
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
5739
5365
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -5754,7 +5380,7 @@ var DragDropContextClient = ({
5754
5380
  },
5755
5381
  [zoneStore]
5756
5382
  );
5757
- const setDeepestAndCollide = useCallback10(
5383
+ const setDeepestAndCollide = useCallback11(
5758
5384
  (params, manager) => {
5759
5385
  const { zoneChanged, areaChanged } = getChanged2(params, id);
5760
5386
  if (!zoneChanged && !areaChanged) return;
@@ -5778,7 +5404,7 @@ var DragDropContextClient = ({
5778
5404
  setDeepestDb.cancel();
5779
5405
  debouncedParamsRef.current = null;
5780
5406
  };
5781
- useEffect16(() => {
5407
+ useEffect17(() => {
5782
5408
  if (DEBUG3) {
5783
5409
  zoneStore.subscribe(
5784
5410
  (s) => {
@@ -5841,8 +5467,8 @@ var DragDropContextClient = ({
5841
5467
  ]);
5842
5468
  const sensors = useSensors();
5843
5469
  const [dragListeners, setDragListeners] = useState14({});
5844
- const dragMode = useRef4(null);
5845
- const initialSelector = useRef4(void 0);
5470
+ const dragMode = useRef5(null);
5471
+ const initialSelector = useRef5(void 0);
5846
5472
  const nextContextValue = useMemo10(
5847
5473
  () => ({
5848
5474
  mode: "edit",
@@ -5864,7 +5490,9 @@ var DragDropContextClient = ({
5864
5490
  plugins,
5865
5491
  sensors,
5866
5492
  onDragEnd: (event, manager) => {
5867
- var _a;
5493
+ var _a, _b;
5494
+ const entryEl = (_a = getFrame()) == null ? void 0 : _a.querySelector("[data-puck-entry]");
5495
+ entryEl == null ? void 0 : entryEl.removeAttribute("data-puck-dragging");
5868
5496
  const { source, target } = event.operation;
5869
5497
  if (!source) {
5870
5498
  zoneStore.setState({ draggedItem: null });
@@ -5872,9 +5500,9 @@ var DragDropContextClient = ({
5872
5500
  }
5873
5501
  const { zone, index } = source.data;
5874
5502
  const { previewIndex = {} } = zoneStore.getState() || {};
5875
- const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
5876
- setTimeout(() => {
5877
- var _a2, _b;
5503
+ const thisPreview = ((_b = previewIndex[zone]) == null ? void 0 : _b.props.id) === source.id ? previewIndex[zone] : null;
5504
+ const onAnimationEnd = () => {
5505
+ var _a2, _b2;
5878
5506
  zoneStore.setState({ draggedItem: null });
5879
5507
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
5880
5508
  zoneStore.setState({ previewIndex: {} });
@@ -5910,23 +5538,28 @@ var DragDropContextClient = ({
5910
5538
  });
5911
5539
  }
5912
5540
  }
5913
- setTimeout(() => {
5914
- dispatch({
5915
- type: "setUi",
5916
- ui: {
5917
- itemSelector: { index, zone },
5918
- isDragging: false
5919
- },
5920
- recordHistory: true
5921
- });
5922
- }, 50);
5923
- (_b = dragListeners.dragend) == null ? void 0 : _b.forEach((fn) => {
5541
+ dispatch({
5542
+ type: "setUi",
5543
+ ui: {
5544
+ itemSelector: { index, zone },
5545
+ isDragging: false
5546
+ },
5547
+ recordHistory: true
5548
+ });
5549
+ (_b2 = dragListeners.dragend) == null ? void 0 : _b2.forEach((fn) => {
5924
5550
  fn(event, manager);
5925
5551
  });
5926
- }, 250);
5552
+ };
5553
+ let dispose;
5554
+ dispose = effect(() => {
5555
+ if (source.status === "idle") {
5556
+ onAnimationEnd();
5557
+ dispose == null ? void 0 : dispose();
5558
+ }
5559
+ });
5927
5560
  },
5928
5561
  onDragOver: (event, manager) => {
5929
- var _a, _b, _c, _d, _e;
5562
+ var _a, _b, _c, _d;
5930
5563
  event.preventDefault();
5931
5564
  const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
5932
5565
  if (!draggedItem) return;
@@ -5944,7 +5577,7 @@ var DragDropContextClient = ({
5944
5577
  const targetData = target.data;
5945
5578
  targetZone = targetData.zone;
5946
5579
  targetIndex = targetData.index;
5947
- const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
5580
+ const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
5948
5581
  const dir = getDeepDir(target.element);
5949
5582
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || dir === "ltr" && (collisionData == null ? void 0 : collisionData.direction) === "left" || dir === "rtl" && (collisionData == null ? void 0 : collisionData.direction) === "right" ? "before" : "after";
5950
5583
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
@@ -5957,7 +5590,7 @@ var DragDropContextClient = ({
5957
5590
  targetZone = target.id.toString();
5958
5591
  targetIndex = 0;
5959
5592
  }
5960
- const path = ((_d = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _d.path) || [];
5593
+ const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
5961
5594
  if (targetId === sourceId || path.find((path2) => {
5962
5595
  const [pathId] = path2.split(":");
5963
5596
  return pathId === sourceId;
@@ -6003,16 +5636,12 @@ var DragDropContextClient = ({
6003
5636
  });
6004
5637
  }
6005
5638
  }
6006
- (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
5639
+ (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
6007
5640
  fn(event, manager);
6008
5641
  });
6009
5642
  },
6010
5643
  onDragStart: (event, manager) => {
6011
5644
  var _a;
6012
- dispatch({
6013
- type: "setUi",
6014
- ui: { itemSelector: null, isDragging: true }
6015
- });
6016
5645
  const { source } = event.operation;
6017
5646
  if (source && source.type !== "void") {
6018
5647
  const sourceData = source.data;
@@ -6042,11 +5671,31 @@ var DragDropContextClient = ({
6042
5671
  });
6043
5672
  },
6044
5673
  onBeforeDragStart: (event) => {
6045
- var _a;
6046
- const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
5674
+ var _a, _b, _c, _d;
5675
+ const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
6047
5676
  dragMode.current = isNewComponent ? "new" : "existing";
6048
5677
  initialSelector.current = void 0;
6049
5678
  zoneStore.setState({ draggedItem: event.operation.source });
5679
+ if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== ((_c = event.operation.source) == null ? void 0 : _c.id)) {
5680
+ dispatch({
5681
+ type: "setUi",
5682
+ ui: {
5683
+ itemSelector: null,
5684
+ isDragging: true
5685
+ },
5686
+ recordHistory: false
5687
+ });
5688
+ } else {
5689
+ dispatch({
5690
+ type: "setUi",
5691
+ ui: {
5692
+ isDragging: true
5693
+ },
5694
+ recordHistory: false
5695
+ });
5696
+ }
5697
+ const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
5698
+ entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
6050
5699
  },
6051
5700
  children: /* @__PURE__ */ jsx24(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx24(DropZoneProvider, { value: nextContextValue, children }) })
6052
5701
  }
@@ -6066,6 +5715,7 @@ var DragDropContext = ({
6066
5715
  };
6067
5716
 
6068
5717
  // components/Drawer/index.tsx
5718
+ import { useDraggable, useDroppable as useDroppable2 } from "@dnd-kit/react";
6069
5719
  import { jsx as jsx25, jsxs as jsxs11 } from "react/jsx-runtime";
6070
5720
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
6071
5721
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
@@ -6102,10 +5752,11 @@ var DrawerItemDraggable = ({
6102
5752
  id,
6103
5753
  isDragDisabled
6104
5754
  }) => {
6105
- const { ref } = useDraggableSafe({
5755
+ const { ref } = useDraggable({
6106
5756
  id,
6107
- data: { type: "drawer", componentType: name },
6108
- disabled: isDragDisabled
5757
+ data: { componentType: name },
5758
+ disabled: isDragDisabled,
5759
+ type: "drawer"
6109
5760
  });
6110
5761
  return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
6111
5762
  /* @__PURE__ */ jsx25("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx25(DrawerItemInner, { name, label, children }) }),
@@ -6170,7 +5821,7 @@ var Drawer = ({
6170
5821
  );
6171
5822
  }
6172
5823
  const id = useSafeId();
6173
- const { ref } = useDroppableSafe({
5824
+ const { ref } = useDroppable2({
6174
5825
  id,
6175
5826
  type: "void",
6176
5827
  collisionPriority: 0
@@ -6183,6 +5834,7 @@ var Drawer = ({
6183
5834
  ref,
6184
5835
  "data-puck-dnd": id,
6185
5836
  "data-puck-drawer": true,
5837
+ "data-puck-dnd-void": true,
6186
5838
  children
6187
5839
  }
6188
5840
  );
@@ -6193,11 +5845,12 @@ Drawer.Item = DrawerItem;
6193
5845
  init_react_import();
6194
5846
  import {
6195
5847
  createContext as createContext7,
6196
- useCallback as useCallback16,
6197
- useContext as useContext11,
6198
- useEffect as useEffect24,
6199
- useMemo as useMemo20,
6200
- useState as useState22
5848
+ useCallback as useCallback18,
5849
+ useContext as useContext12,
5850
+ useEffect as useEffect25,
5851
+ useMemo as useMemo21,
5852
+ useRef as useRef8,
5853
+ useState as useState23
6201
5854
  } from "react";
6202
5855
 
6203
5856
  // components/SidebarSection/index.tsx
@@ -6293,70 +5946,26 @@ var SidebarSection = ({
6293
5946
  );
6294
5947
  };
6295
5948
 
6296
- // components/MenuBar/index.tsx
6297
- init_react_import();
6298
-
6299
- // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
6300
- init_react_import();
6301
- var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
6302
-
6303
- // components/MenuBar/index.tsx
6304
- import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
6305
- var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
6306
- function MenuBar({
6307
- menuOpen = false,
6308
- renderHeaderActions,
6309
- setMenuOpen
6310
- }) {
6311
- const back = useAppStore((s) => s.history.back);
6312
- const forward = useAppStore((s) => s.history.forward);
6313
- const hasFuture = useAppStore((s) => s.history.hasFuture());
6314
- const hasPast = useAppStore((s) => s.history.hasPast());
6315
- return /* @__PURE__ */ jsx27(
6316
- "div",
6317
- {
6318
- className: getClassName20({ menuOpen }),
6319
- onClick: (event) => {
6320
- var _a;
6321
- const element = event.target;
6322
- if (window.matchMedia("(min-width: 638px)").matches) {
6323
- return;
6324
- }
6325
- if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
6326
- setMenuOpen(false);
6327
- }
6328
- },
6329
- children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
6330
- /* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
6331
- /* @__PURE__ */ jsx27(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx27(Undo2, { size: 21 }) }),
6332
- /* @__PURE__ */ jsx27(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx27(Redo2, { size: 21 }) })
6333
- ] }),
6334
- /* @__PURE__ */ jsx27(Fragment7, { children: renderHeaderActions && renderHeaderActions() })
6335
- ] })
6336
- }
6337
- );
6338
- }
6339
-
6340
5949
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6341
5950
  init_react_import();
6342
- var styles_module_default15 = { "Puck": "_Puck_11o75_19", "Puck-portal": "_Puck-portal_11o75_24", "PuckLayout-inner": "_PuckLayout-inner_11o75_31", "PuckLayout--mounted": "_PuckLayout--mounted_11o75_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_11o75_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_11o75_53", "PuckLayout-mounted": "_PuckLayout-mounted_11o75_67", "PuckLayout": "_PuckLayout_11o75_31", "PuckLayout-header": "_PuckLayout-header_11o75_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_11o75_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_11o75_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_11o75_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_11o75_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_11o75_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_11o75_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_11o75_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_11o75_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_11o75_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_11o75_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_11o75_134" };
5951
+ var styles_module_default14 = { "Puck": "_Puck_mc1k2_19", "Puck-portal": "_Puck-portal_mc1k2_24", "PuckLayout-inner": "_PuckLayout-inner_mc1k2_31", "PuckLayout--mounted": "_PuckLayout--mounted_mc1k2_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_mc1k2_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_mc1k2_53", "PuckLayout-mounted": "_PuckLayout-mounted_mc1k2_67", "PuckLayout": "_PuckLayout_mc1k2_31", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_mc1k2_108", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_mc1k2_117" };
6343
5952
 
6344
5953
  // components/Puck/components/Fields/index.tsx
6345
5954
  init_react_import();
6346
5955
 
6347
5956
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
6348
5957
  init_react_import();
6349
- 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" };
5958
+ var styles_module_default15 = { "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" };
6350
5959
 
6351
5960
  // components/Puck/components/Fields/index.tsx
6352
- import { useCallback as useCallback11, useMemo as useMemo13 } from "react";
5961
+ import { memo as memo2, useCallback as useCallback12, useMemo as useMemo13 } from "react";
6353
5962
  import { useShallow as useShallow4 } from "zustand/react/shallow";
6354
- import { Fragment as Fragment8, jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
6355
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5963
+ import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
5964
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
6356
5965
  var DefaultFields = ({
6357
5966
  children
6358
5967
  }) => {
6359
- return /* @__PURE__ */ jsx28(Fragment8, { children });
5968
+ return /* @__PURE__ */ jsx27(Fragment7, { children });
6360
5969
  };
6361
5970
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6362
5971
  let currentProps;
@@ -6422,12 +6031,12 @@ var FieldsChild = ({ fieldName }) => {
6422
6031
  })
6423
6032
  );
6424
6033
  const appStore = useAppStoreApi();
6425
- const onChange = useCallback11(createOnChange(fieldName, appStore), [
6034
+ const onChange = useCallback12(createOnChange(fieldName, appStore), [
6426
6035
  fieldName
6427
6036
  ]);
6428
6037
  if (!field || !id) return null;
6429
6038
  if (field.type === "slot") return null;
6430
- return /* @__PURE__ */ jsx28("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx28(
6039
+ return /* @__PURE__ */ jsx27("div", { className: getClassName20("field"), children: /* @__PURE__ */ jsx27(
6431
6040
  AutoFieldPrivate,
6432
6041
  {
6433
6042
  field,
@@ -6439,7 +6048,8 @@ var FieldsChild = ({ fieldName }) => {
6439
6048
  }
6440
6049
  ) }, id);
6441
6050
  };
6442
- var Fields = ({ wrapFields = true }) => {
6051
+ var FieldsChildMemo = memo2(FieldsChild);
6052
+ var FieldsInternal = ({ wrapFields = true }) => {
6443
6053
  const overrides = useAppStore((s) => s.overrides);
6444
6054
  const componentResolving = useAppStore((s) => {
6445
6055
  var _a, _b;
@@ -6455,42 +6065,48 @@ var Fields = ({ wrapFields = true }) => {
6455
6065
  useRegisterFieldsSlice(appStore, id);
6456
6066
  const fieldsLoading = useAppStore((s) => s.fields.loading);
6457
6067
  const fieldNames = useAppStore(
6458
- useShallow4((s) => Object.keys(s.fields.fields))
6068
+ useShallow4((s) => {
6069
+ if (s.fields.id === id) {
6070
+ return Object.keys(s.fields.fields);
6071
+ }
6072
+ return [];
6073
+ })
6459
6074
  );
6460
6075
  const isLoading = fieldsLoading || componentResolving;
6461
6076
  const Wrapper = useMemo13(() => overrides.fields || DefaultFields, [overrides]);
6462
- return /* @__PURE__ */ jsxs14(
6077
+ return /* @__PURE__ */ jsxs13(
6463
6078
  "form",
6464
6079
  {
6465
- className: getClassName21({ wrapFields }),
6080
+ className: getClassName20({ wrapFields }),
6466
6081
  onSubmit: (e) => {
6467
6082
  e.preventDefault();
6468
6083
  },
6469
6084
  children: [
6470
- /* @__PURE__ */ jsx28(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx28(FieldsChild, { fieldName }, fieldName)) }),
6471
- isLoading && /* @__PURE__ */ jsx28("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx28("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx28(Loader, { size: 16 }) }) })
6085
+ /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx27(FieldsChildMemo, { fieldName }, fieldName)) }),
6086
+ isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
6472
6087
  ]
6473
6088
  }
6474
6089
  );
6475
6090
  };
6091
+ var Fields = memo2(FieldsInternal);
6476
6092
 
6477
6093
  // components/Puck/components/Components/index.tsx
6478
6094
  init_react_import();
6479
6095
 
6480
6096
  // lib/use-component-list.tsx
6481
6097
  init_react_import();
6482
- import { useEffect as useEffect17, useState as useState16 } from "react";
6098
+ import { useEffect as useEffect18, useState as useState16 } from "react";
6483
6099
 
6484
6100
  // components/ComponentList/index.tsx
6485
6101
  init_react_import();
6486
6102
 
6487
6103
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6488
6104
  init_react_import();
6489
- 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" };
6105
+ var styles_module_default16 = { "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" };
6490
6106
 
6491
6107
  // components/ComponentList/index.tsx
6492
- import { jsx as jsx29, jsxs as jsxs15 } from "react/jsx-runtime";
6493
- var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
6108
+ import { jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
6109
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
6494
6110
  var ComponentListItem = ({
6495
6111
  name,
6496
6112
  label
@@ -6501,7 +6117,7 @@ var ComponentListItem = ({
6501
6117
  type: name
6502
6118
  }).insert
6503
6119
  );
6504
- return /* @__PURE__ */ jsx29(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6120
+ return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6505
6121
  };
6506
6122
  var ComponentList = ({
6507
6123
  children,
@@ -6512,12 +6128,12 @@ var ComponentList = ({
6512
6128
  const setUi = useAppStore((s) => s.setUi);
6513
6129
  const componentList = useAppStore((s) => s.state.ui.componentList);
6514
6130
  const { expanded = true } = componentList[id] || {};
6515
- return /* @__PURE__ */ jsxs15("div", { className: getClassName22({ isExpanded: expanded }), children: [
6516
- title && /* @__PURE__ */ jsxs15(
6131
+ return /* @__PURE__ */ jsxs14("div", { className: getClassName21({ isExpanded: expanded }), children: [
6132
+ title && /* @__PURE__ */ jsxs14(
6517
6133
  "button",
6518
6134
  {
6519
6135
  type: "button",
6520
- className: getClassName22("title"),
6136
+ className: getClassName21("title"),
6521
6137
  onClick: () => setUi({
6522
6138
  componentList: __spreadProps(__spreadValues({}, componentList), {
6523
6139
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6527,14 +6143,14 @@ var ComponentList = ({
6527
6143
  }),
6528
6144
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6529
6145
  children: [
6530
- /* @__PURE__ */ jsx29("div", { children: title }),
6531
- /* @__PURE__ */ jsx29("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx29(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx29(ChevronDown, { size: 12 }) })
6146
+ /* @__PURE__ */ jsx28("div", { children: title }),
6147
+ /* @__PURE__ */ jsx28("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
6532
6148
  ]
6533
6149
  }
6534
6150
  ),
6535
- /* @__PURE__ */ jsx29("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx29(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6151
+ /* @__PURE__ */ jsx28("div", { className: getClassName21("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6536
6152
  var _a;
6537
- return /* @__PURE__ */ jsx29(
6153
+ return /* @__PURE__ */ jsx28(
6538
6154
  ComponentListItem,
6539
6155
  {
6540
6156
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6548,12 +6164,12 @@ var ComponentList = ({
6548
6164
  ComponentList.Item = ComponentListItem;
6549
6165
 
6550
6166
  // lib/use-component-list.tsx
6551
- import { jsx as jsx30 } from "react/jsx-runtime";
6167
+ import { jsx as jsx29 } from "react/jsx-runtime";
6552
6168
  var useComponentList = () => {
6553
6169
  const [componentList, setComponentList] = useState16();
6554
6170
  const config = useAppStore((s) => s.config);
6555
6171
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6556
- useEffect17(() => {
6172
+ useEffect18(() => {
6557
6173
  var _a, _b, _c;
6558
6174
  if (Object.keys(uiComponentList).length > 0) {
6559
6175
  const matchedComponents = [];
@@ -6563,7 +6179,7 @@ var useComponentList = () => {
6563
6179
  if (category.visible === false || !category.components) {
6564
6180
  return null;
6565
6181
  }
6566
- return /* @__PURE__ */ jsx30(
6182
+ return /* @__PURE__ */ jsx29(
6567
6183
  ComponentList,
6568
6184
  {
6569
6185
  id: categoryKey,
@@ -6572,7 +6188,7 @@ var useComponentList = () => {
6572
6188
  var _a2;
6573
6189
  matchedComponents.push(componentName);
6574
6190
  const componentConf = config.components[componentName] || {};
6575
- return /* @__PURE__ */ jsx30(
6191
+ return /* @__PURE__ */ jsx29(
6576
6192
  ComponentList.Item,
6577
6193
  {
6578
6194
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6592,7 +6208,7 @@ var useComponentList = () => {
6592
6208
  );
6593
6209
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6594
6210
  _componentList.push(
6595
- /* @__PURE__ */ jsx30(
6211
+ /* @__PURE__ */ jsx29(
6596
6212
  ComponentList,
6597
6213
  {
6598
6214
  id: "other",
@@ -6600,7 +6216,7 @@ var useComponentList = () => {
6600
6216
  children: remainingComponents.map((componentName, i) => {
6601
6217
  var _a2;
6602
6218
  const componentConf = config.components[componentName] || {};
6603
- return /* @__PURE__ */ jsx30(
6219
+ return /* @__PURE__ */ jsx29(
6604
6220
  ComponentList.Item,
6605
6221
  {
6606
6222
  name: componentName,
@@ -6623,29 +6239,29 @@ var useComponentList = () => {
6623
6239
 
6624
6240
  // components/Puck/components/Components/index.tsx
6625
6241
  import { useMemo as useMemo14 } from "react";
6626
- import { jsx as jsx31 } from "react/jsx-runtime";
6242
+ import { jsx as jsx30 } from "react/jsx-runtime";
6627
6243
  var Components = () => {
6628
6244
  const overrides = useAppStore((s) => s.overrides);
6629
6245
  const componentList = useComponentList();
6630
6246
  const Wrapper = useMemo14(() => overrides.components || "div", [overrides]);
6631
- return /* @__PURE__ */ jsx31(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx31(ComponentList, { id: "all" }) });
6247
+ return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
6632
6248
  };
6633
6249
 
6634
6250
  // components/Puck/components/Preview/index.tsx
6635
6251
  init_react_import();
6636
- import { useCallback as useCallback12, useEffect as useEffect19, useRef as useRef5, useMemo as useMemo15 } from "react";
6252
+ import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as useMemo15 } from "react";
6637
6253
 
6638
6254
  // components/AutoFrame/index.tsx
6639
6255
  init_react_import();
6640
6256
  import {
6641
6257
  createContext as createContext5,
6642
- useContext as useContext8,
6643
- useEffect as useEffect18,
6258
+ useContext as useContext9,
6259
+ useEffect as useEffect19,
6644
6260
  useState as useState17
6645
6261
  } from "react";
6646
6262
  import hash from "object-hash";
6647
6263
  import { createPortal as createPortal3 } from "react-dom";
6648
- import { Fragment as Fragment9, jsx as jsx32 } from "react/jsx-runtime";
6264
+ import { Fragment as Fragment8, jsx as jsx31 } from "react/jsx-runtime";
6649
6265
  var styleSelector = 'style, link[rel="stylesheet"]';
6650
6266
  var collectStyles = (doc) => {
6651
6267
  const collected = [];
@@ -6688,7 +6304,7 @@ var CopyHostStyles = ({
6688
6304
  onStylesLoaded = () => null
6689
6305
  }) => {
6690
6306
  const { document: doc, window: win } = useFrame();
6691
- useEffect18(() => {
6307
+ useEffect19(() => {
6692
6308
  if (!win || !doc) {
6693
6309
  return () => {
6694
6310
  };
@@ -6845,10 +6461,10 @@ var CopyHostStyles = ({
6845
6461
  observer.disconnect();
6846
6462
  };
6847
6463
  }, []);
6848
- return /* @__PURE__ */ jsx32(Fragment9, { children });
6464
+ return /* @__PURE__ */ jsx31(Fragment8, { children });
6849
6465
  };
6850
6466
  var autoFrameContext = createContext5({});
6851
- var useFrame = () => useContext8(autoFrameContext);
6467
+ var useFrame = () => useContext9(autoFrameContext);
6852
6468
  function AutoFrame(_a) {
6853
6469
  var _b = _a, {
6854
6470
  children,
@@ -6873,7 +6489,7 @@ function AutoFrame(_a) {
6873
6489
  const [ctx, setCtx] = useState17({});
6874
6490
  const [mountTarget, setMountTarget] = useState17();
6875
6491
  const [stylesLoaded, setStylesLoaded] = useState17(false);
6876
- useEffect18(() => {
6492
+ useEffect19(() => {
6877
6493
  var _a2;
6878
6494
  if (frameRef.current) {
6879
6495
  const doc = frameRef.current.contentDocument;
@@ -6892,7 +6508,7 @@ function AutoFrame(_a) {
6892
6508
  }
6893
6509
  }
6894
6510
  }, [frameRef, loaded, stylesLoaded]);
6895
- return /* @__PURE__ */ jsx32(
6511
+ return /* @__PURE__ */ jsx31(
6896
6512
  "iframe",
6897
6513
  __spreadProps(__spreadValues({}, props), {
6898
6514
  className,
@@ -6902,7 +6518,7 @@ function AutoFrame(_a) {
6902
6518
  onLoad: () => {
6903
6519
  setLoaded(true);
6904
6520
  },
6905
- children: /* @__PURE__ */ jsx32(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx32(
6521
+ children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(
6906
6522
  CopyHostStyles,
6907
6523
  {
6908
6524
  debug,
@@ -6918,14 +6534,14 @@ var AutoFrame_default = AutoFrame;
6918
6534
 
6919
6535
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
6920
6536
  init_react_import();
6921
- var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
6537
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
6922
6538
 
6923
6539
  // components/Puck/components/Preview/index.tsx
6924
- import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
6925
- var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
6540
+ import { Fragment as Fragment9, jsx as jsx32 } from "react/jsx-runtime";
6541
+ var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
6926
6542
  var useBubbleIframeEvents = (ref) => {
6927
6543
  const status = useAppStore((s) => s.status);
6928
- useEffect19(() => {
6544
+ useEffect20(() => {
6929
6545
  if (ref.current && status === "READY") {
6930
6546
  const iframe = ref.current;
6931
6547
  const handlePointerMove = (event) => {
@@ -6963,7 +6579,7 @@ var useBubbleIframeEvents = (ref) => {
6963
6579
  }
6964
6580
  }, [status]);
6965
6581
  };
6966
- var Preview3 = ({ id = "puck-preview" }) => {
6582
+ var Preview2 = ({ id = "puck-preview" }) => {
6967
6583
  const dispatch = useAppStore((s) => s.dispatch);
6968
6584
  const root = useAppStore((s) => s.state.data.root);
6969
6585
  const config = useAppStore((s) => s.config);
@@ -6974,22 +6590,22 @@ var Preview3 = ({ id = "puck-preview" }) => {
6974
6590
  const renderData = useAppStore(
6975
6591
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
6976
6592
  );
6977
- const Page = useCallback12(
6593
+ const Page = useCallback13(
6978
6594
  (pageProps) => {
6979
6595
  var _a, _b;
6980
6596
  const rootConfig = config.root;
6981
6597
  const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
6982
6598
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
6983
6599
  id: "puck-root"
6984
- }, propsWithSlots)) : /* @__PURE__ */ jsx33(Fragment10, { children: propsWithSlots.children });
6600
+ }, propsWithSlots)) : /* @__PURE__ */ jsx32(Fragment9, { children: propsWithSlots.children });
6985
6601
  },
6986
6602
  [config.root]
6987
6603
  );
6988
6604
  const Frame = useMemo15(() => overrides.iframe, [overrides]);
6989
6605
  const rootProps = root.props || root;
6990
- const ref = useRef5(null);
6606
+ const ref = useRef6(null);
6991
6607
  useBubbleIframeEvents(ref);
6992
- const inner = !renderData ? /* @__PURE__ */ jsx33(
6608
+ const inner = !renderData ? /* @__PURE__ */ jsx32(
6993
6609
  Page,
6994
6610
  __spreadProps(__spreadValues({}, rootProps), {
6995
6611
  puck: {
@@ -6999,28 +6615,28 @@ var Preview3 = ({ id = "puck-preview" }) => {
6999
6615
  metadata
7000
6616
  },
7001
6617
  editMode: true,
7002
- children: /* @__PURE__ */ jsx33(DropZonePure, { zone: rootDroppableId })
6618
+ children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
7003
6619
  })
7004
- ) : /* @__PURE__ */ jsx33(Render, { data: renderData, config });
7005
- useEffect19(() => {
6620
+ ) : /* @__PURE__ */ jsx32(Render, { data: renderData, config });
6621
+ useEffect20(() => {
7006
6622
  if (!iframe.enabled) {
7007
6623
  setStatus("READY");
7008
6624
  }
7009
6625
  }, [iframe.enabled]);
7010
- return /* @__PURE__ */ jsx33(
6626
+ return /* @__PURE__ */ jsx32(
7011
6627
  "div",
7012
6628
  {
7013
- className: getClassName23(),
6629
+ className: getClassName22(),
7014
6630
  id,
7015
6631
  "data-puck-preview": true,
7016
6632
  onClick: () => {
7017
6633
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7018
6634
  },
7019
- children: iframe.enabled ? /* @__PURE__ */ jsx33(
6635
+ children: iframe.enabled ? /* @__PURE__ */ jsx32(
7020
6636
  AutoFrame_default,
7021
6637
  {
7022
6638
  id: "preview-frame",
7023
- className: getClassName23("frame"),
6639
+ className: getClassName22("frame"),
7024
6640
  "data-rfd-iframe": true,
7025
6641
  onReady: () => {
7026
6642
  setStatus("READY");
@@ -7029,18 +6645,18 @@ var Preview3 = ({ id = "puck-preview" }) => {
7029
6645
  setStatus("MOUNTED");
7030
6646
  },
7031
6647
  frameRef: ref,
7032
- children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6648
+ children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7033
6649
  if (Frame) {
7034
- return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
6650
+ return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
7035
6651
  }
7036
6652
  return inner;
7037
6653
  } })
7038
6654
  }
7039
- ) : /* @__PURE__ */ jsx33(
6655
+ ) : /* @__PURE__ */ jsx32(
7040
6656
  "div",
7041
6657
  {
7042
6658
  id: "preview-frame",
7043
- className: getClassName23("frame"),
6659
+ className: getClassName22("frame"),
7044
6660
  ref,
7045
6661
  "data-puck-entry": true,
7046
6662
  children: inner
@@ -7058,7 +6674,7 @@ init_react_import();
7058
6674
 
7059
6675
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
7060
6676
  init_react_import();
7061
- 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" };
6677
+ 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" };
7062
6678
 
7063
6679
  // lib/scroll-into-view.ts
7064
6680
  init_react_import();
@@ -7072,7 +6688,7 @@ var scrollIntoView = (el) => {
7072
6688
  };
7073
6689
 
7074
6690
  // components/LayerTree/index.tsx
7075
- import { useCallback as useCallback13, useContext as useContext9 } from "react";
6691
+ import { useCallback as useCallback14, useContext as useContext10 } from "react";
7076
6692
 
7077
6693
  // lib/on-scroll-end.ts
7078
6694
  init_react_import();
@@ -7095,20 +6711,20 @@ var onScrollEnd = (frame, cb) => {
7095
6711
 
7096
6712
  // components/LayerTree/index.tsx
7097
6713
  import { useShallow as useShallow5 } from "zustand/react/shallow";
7098
- import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
7099
- var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
7100
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
6714
+ import { Fragment as Fragment10, jsx as jsx33, jsxs as jsxs15 } from "react/jsx-runtime";
6715
+ var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
6716
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
7101
6717
  var Layer = ({
7102
6718
  index,
7103
6719
  itemId,
7104
6720
  zoneCompound
7105
6721
  }) => {
7106
6722
  var _a;
7107
- const ctx = useContext9(dropZoneContext);
6723
+ const ctx = useContext10(dropZoneContext);
7108
6724
  const config = useAppStore((s) => s.config);
7109
6725
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
7110
6726
  const dispatch = useAppStore((s) => s.dispatch);
7111
- const setItemSelector = useCallback13(
6727
+ const setItemSelector = useCallback14(
7112
6728
  (itemSelector2) => {
7113
6729
  dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
7114
6730
  },
@@ -7128,9 +6744,11 @@ var Layer = ({
7128
6744
  )
7129
6745
  );
7130
6746
  const containsZone = zonesForItem.length > 0;
7131
- const { setHoveringComponent = () => {
7132
- }, hoveringComponent } = ctx || {};
7133
- const isHovering = hoveringComponent === itemId;
6747
+ const zoneStore = useContext10(ZoneStoreContext);
6748
+ const isHovering = useContextStore(
6749
+ ZoneStoreContext,
6750
+ (s) => s.hoveringComponent === itemId
6751
+ );
7134
6752
  const childIsSelected = useAppStore((s) => {
7135
6753
  var _a2, _b;
7136
6754
  const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
@@ -7141,7 +6759,7 @@ var Layer = ({
7141
6759
  });
7142
6760
  const componentConfig = config.components[nodeData.data.type];
7143
6761
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
7144
- return /* @__PURE__ */ jsxs16(
6762
+ return /* @__PURE__ */ jsxs15(
7145
6763
  "li",
7146
6764
  {
7147
6765
  className: getClassNameLayer({
@@ -7151,7 +6769,7 @@ var Layer = ({
7151
6769
  childIsSelected
7152
6770
  }),
7153
6771
  children: [
7154
- /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6772
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs15(
7155
6773
  "button",
7156
6774
  {
7157
6775
  type: "button",
@@ -7177,31 +6795,31 @@ var Layer = ({
7177
6795
  });
7178
6796
  });
7179
6797
  },
7180
- onMouseOver: (e) => {
6798
+ onMouseEnter: (e) => {
7181
6799
  e.stopPropagation();
7182
- setHoveringComponent(itemId);
6800
+ zoneStore.setState({ hoveringComponent: itemId });
7183
6801
  },
7184
- onMouseOut: (e) => {
6802
+ onMouseLeave: (e) => {
7185
6803
  e.stopPropagation();
7186
- setHoveringComponent(null);
6804
+ zoneStore.setState({ hoveringComponent: null });
7187
6805
  },
7188
6806
  children: [
7189
- containsZone && /* @__PURE__ */ jsx34(
6807
+ containsZone && /* @__PURE__ */ jsx33(
7190
6808
  "div",
7191
6809
  {
7192
6810
  className: getClassNameLayer("chevron"),
7193
6811
  title: isSelected ? "Collapse" : "Expand",
7194
- children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
6812
+ children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
7195
6813
  }
7196
6814
  ),
7197
- /* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
7198
- /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
7199
- /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label })
6815
+ /* @__PURE__ */ jsxs15("div", { className: getClassNameLayer("title"), children: [
6816
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx33(Type, { size: "16" }) : /* @__PURE__ */ jsx33(LayoutGrid, { size: "16" }) }),
6817
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label })
7200
6818
  ] })
7201
6819
  ]
7202
6820
  }
7203
6821
  ) }),
7204
- containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(LayerTree, { zoneCompound: subzone }) }, subzone))
6822
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(LayerTree, { zoneCompound: subzone }) }, subzone))
7205
6823
  ]
7206
6824
  }
7207
6825
  );
@@ -7219,15 +6837,15 @@ var LayerTree = ({
7219
6837
  }
7220
6838
  )
7221
6839
  );
7222
- return /* @__PURE__ */ jsxs16(Fragment11, { children: [
7223
- label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
7224
- /* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
6840
+ return /* @__PURE__ */ jsxs15(Fragment10, { children: [
6841
+ label && /* @__PURE__ */ jsxs15("div", { className: getClassName23("zoneTitle"), children: [
6842
+ /* @__PURE__ */ jsx33("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
7225
6843
  label
7226
6844
  ] }),
7227
- /* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
7228
- contentIds.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
6845
+ /* @__PURE__ */ jsxs15("ul", { className: getClassName23(), children: [
6846
+ contentIds.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName23("helper"), children: "No items" }),
7229
6847
  contentIds.map((itemId, i) => {
7230
- return /* @__PURE__ */ jsx34(
6848
+ return /* @__PURE__ */ jsx33(
7231
6849
  Layer,
7232
6850
  {
7233
6851
  index: i,
@@ -7254,14 +6872,14 @@ var findZonesForArea = (state, area) => {
7254
6872
 
7255
6873
  // components/Puck/components/Outline/index.tsx
7256
6874
  import { useShallow as useShallow6 } from "zustand/react/shallow";
7257
- import { jsx as jsx35 } from "react/jsx-runtime";
6875
+ import { jsx as jsx34 } from "react/jsx-runtime";
7258
6876
  var Outline = () => {
7259
6877
  const outlineOverride = useAppStore((s) => s.overrides.outline);
7260
6878
  const rootZones = useAppStore(
7261
6879
  useShallow6((s) => findZonesForArea(s.state, "root"))
7262
6880
  );
7263
6881
  const Wrapper = useMemo16(() => outlineOverride || "div", [outlineOverride]);
7264
- return /* @__PURE__ */ jsx35(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx35(
6882
+ return /* @__PURE__ */ jsx34(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx34(
7265
6883
  LayerTree,
7266
6884
  {
7267
6885
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -7395,30 +7013,30 @@ var getBox = function getBox2(el) {
7395
7013
 
7396
7014
  // components/Puck/components/Canvas/index.tsx
7397
7015
  import {
7398
- useCallback as useCallback14,
7399
- useEffect as useEffect21,
7016
+ useCallback as useCallback15,
7017
+ useEffect as useEffect22,
7400
7018
  useMemo as useMemo18,
7401
- useRef as useRef6,
7019
+ useRef as useRef7,
7402
7020
  useState as useState19
7403
7021
  } from "react";
7404
7022
 
7405
7023
  // components/ViewportControls/index.tsx
7406
7024
  init_react_import();
7407
- import { useEffect as useEffect20, useMemo as useMemo17, useState as useState18 } from "react";
7025
+ import { useEffect as useEffect21, useMemo as useMemo17, useState as useState18 } from "react";
7408
7026
 
7409
7027
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7410
7028
  init_react_import();
7411
- 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" };
7029
+ var styles_module_default19 = { "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" };
7412
7030
 
7413
7031
  // components/ViewportControls/index.tsx
7414
- import { jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
7032
+ import { jsx as jsx35, jsxs as jsxs16 } from "react/jsx-runtime";
7415
7033
  var icons = {
7416
- Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
7417
- Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
7418
- Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
7034
+ Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
7035
+ Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
7036
+ Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
7419
7037
  };
7420
- var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
7421
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
7038
+ var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
7039
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
7422
7040
  var ViewportButton = ({
7423
7041
  children,
7424
7042
  height = "auto",
@@ -7428,10 +7046,10 @@ var ViewportButton = ({
7428
7046
  }) => {
7429
7047
  const viewports = useAppStore((s) => s.state.ui.viewports);
7430
7048
  const [isActive, setIsActive] = useState18(false);
7431
- useEffect20(() => {
7049
+ useEffect21(() => {
7432
7050
  setIsActive(width === viewports.current.width);
7433
7051
  }, [width, viewports.current.width]);
7434
- return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
7052
+ return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
7435
7053
  IconButton,
7436
7054
  {
7437
7055
  title,
@@ -7440,7 +7058,7 @@ var ViewportButton = ({
7440
7058
  e.stopPropagation();
7441
7059
  onClick({ width, height });
7442
7060
  },
7443
- children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
7061
+ children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
7444
7062
  }
7445
7063
  ) });
7446
7064
  };
@@ -7476,8 +7094,8 @@ var ViewportControls = ({
7476
7094
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7477
7095
  [autoZoom]
7478
7096
  );
7479
- return /* @__PURE__ */ jsxs17("div", { className: getClassName25(), children: [
7480
- viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
7097
+ return /* @__PURE__ */ jsxs16("div", { className: getClassName24(), children: [
7098
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
7481
7099
  ViewportButton,
7482
7100
  {
7483
7101
  height: viewport.height,
@@ -7488,8 +7106,8 @@ var ViewportControls = ({
7488
7106
  },
7489
7107
  i
7490
7108
  )),
7491
- /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
7492
- /* @__PURE__ */ jsx36(
7109
+ /* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
7110
+ /* @__PURE__ */ jsx35(
7493
7111
  IconButton,
7494
7112
  {
7495
7113
  title: "Zoom viewport out",
@@ -7503,10 +7121,10 @@ var ViewportControls = ({
7503
7121
  )].value
7504
7122
  );
7505
7123
  },
7506
- children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
7124
+ children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
7507
7125
  }
7508
7126
  ),
7509
- /* @__PURE__ */ jsx36(
7127
+ /* @__PURE__ */ jsx35(
7510
7128
  IconButton,
7511
7129
  {
7512
7130
  title: "Zoom viewport in",
@@ -7520,19 +7138,19 @@ var ViewportControls = ({
7520
7138
  )].value
7521
7139
  );
7522
7140
  },
7523
- children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
7141
+ children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
7524
7142
  }
7525
7143
  ),
7526
- /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
7527
- /* @__PURE__ */ jsx36(
7144
+ /* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
7145
+ /* @__PURE__ */ jsx35(
7528
7146
  "select",
7529
7147
  {
7530
- className: getClassName25("zoomSelect"),
7148
+ className: getClassName24("zoomSelect"),
7531
7149
  value: zoom.toString(),
7532
7150
  onChange: (e) => {
7533
7151
  onZoom(parseFloat(e.currentTarget.value));
7534
7152
  },
7535
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
7153
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
7536
7154
  "option",
7537
7155
  {
7538
7156
  value: option.value,
@@ -7547,7 +7165,7 @@ var ViewportControls = ({
7547
7165
 
7548
7166
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7549
7167
  init_react_import();
7550
- 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" };
7168
+ var styles_module_default20 = { "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" };
7551
7169
 
7552
7170
  // lib/get-zoom-config.ts
7553
7171
  init_react_import();
@@ -7581,8 +7199,8 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7581
7199
 
7582
7200
  // components/Puck/components/Canvas/index.tsx
7583
7201
  import { useShallow as useShallow7 } from "zustand/react/shallow";
7584
- import { Fragment as Fragment12, jsx as jsx37, jsxs as jsxs18 } from "react/jsx-runtime";
7585
- var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
7202
+ import { Fragment as Fragment11, jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
7203
+ var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
7586
7204
  var ZOOM_ON_CHANGE = true;
7587
7205
  var Canvas = () => {
7588
7206
  const {
@@ -7611,17 +7229,17 @@ var Canvas = () => {
7611
7229
  viewports: s.state.ui.viewports
7612
7230
  }))
7613
7231
  );
7614
- const frameRef = useRef6(null);
7232
+ const frameRef = useRef7(null);
7615
7233
  const [showTransition, setShowTransition] = useState19(false);
7616
7234
  const defaultRender = useMemo18(() => {
7617
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
7235
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment11, { children });
7618
7236
  return PuckDefault;
7619
7237
  }, []);
7620
7238
  const CustomPreview = useMemo18(
7621
7239
  () => overrides.preview || defaultRender,
7622
7240
  [overrides]
7623
7241
  );
7624
- const getFrameDimensions = useCallback14(() => {
7242
+ const getFrameDimensions = useCallback15(() => {
7625
7243
  if (frameRef.current) {
7626
7244
  const frame = frameRef.current;
7627
7245
  const box = getBox(frame);
@@ -7629,7 +7247,7 @@ var Canvas = () => {
7629
7247
  }
7630
7248
  return { width: 0, height: 0 };
7631
7249
  }, [frameRef]);
7632
- const resetAutoZoom = useCallback14(
7250
+ const resetAutoZoom = useCallback15(
7633
7251
  (newViewports = viewports) => {
7634
7252
  if (frameRef.current) {
7635
7253
  setZoomConfig(
@@ -7643,11 +7261,11 @@ var Canvas = () => {
7643
7261
  },
7644
7262
  [frameRef, zoomConfig, viewports]
7645
7263
  );
7646
- useEffect21(() => {
7264
+ useEffect22(() => {
7647
7265
  setShowTransition(false);
7648
7266
  resetAutoZoom(viewports);
7649
7267
  }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
7650
- useEffect21(() => {
7268
+ useEffect22(() => {
7651
7269
  const { height: frameHeight } = getFrameDimensions();
7652
7270
  if (viewports.current.height === "auto") {
7653
7271
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -7655,13 +7273,13 @@ var Canvas = () => {
7655
7273
  }));
7656
7274
  }
7657
7275
  }, [zoomConfig.zoom]);
7658
- useEffect21(() => {
7276
+ useEffect22(() => {
7659
7277
  if (ZOOM_ON_CHANGE) {
7660
7278
  setShowTransition(true);
7661
7279
  resetAutoZoom(viewports);
7662
7280
  }
7663
7281
  }, [viewports.current.width]);
7664
- useEffect21(() => {
7282
+ useEffect22(() => {
7665
7283
  const cb = () => {
7666
7284
  setShowTransition(false);
7667
7285
  resetAutoZoom();
@@ -7672,15 +7290,15 @@ var Canvas = () => {
7672
7290
  };
7673
7291
  }, []);
7674
7292
  const [showLoader, setShowLoader] = useState19(false);
7675
- useEffect21(() => {
7293
+ useEffect22(() => {
7676
7294
  setTimeout(() => {
7677
7295
  setShowLoader(true);
7678
7296
  }, 500);
7679
7297
  }, []);
7680
- return /* @__PURE__ */ jsxs18(
7298
+ return /* @__PURE__ */ jsxs17(
7681
7299
  "div",
7682
7300
  {
7683
- className: getClassName26({
7301
+ className: getClassName25({
7684
7302
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7685
7303
  showLoader
7686
7304
  }),
@@ -7690,7 +7308,7 @@ var Canvas = () => {
7690
7308
  recordHistory: true
7691
7309
  }),
7692
7310
  children: [
7693
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
7311
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName25("controls"), children: /* @__PURE__ */ jsx36(
7694
7312
  ViewportControls,
7695
7313
  {
7696
7314
  autoZoom: zoomConfig.autoZoom,
@@ -7716,11 +7334,11 @@ var Canvas = () => {
7716
7334
  }
7717
7335
  }
7718
7336
  ) }),
7719
- /* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), ref: frameRef, children: [
7720
- /* @__PURE__ */ jsx37(
7337
+ /* @__PURE__ */ jsxs17("div", { className: getClassName25("inner"), ref: frameRef, children: [
7338
+ /* @__PURE__ */ jsx36(
7721
7339
  "div",
7722
7340
  {
7723
- className: getClassName26("root"),
7341
+ className: getClassName25("root"),
7724
7342
  style: {
7725
7343
  width: iframe.enabled ? viewports.current.width : "100%",
7726
7344
  height: zoomConfig.rootHeight,
@@ -7738,10 +7356,10 @@ var Canvas = () => {
7738
7356
  })
7739
7357
  );
7740
7358
  },
7741
- children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview3, {}) })
7359
+ children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview2, {}) })
7742
7360
  }
7743
7361
  ),
7744
- /* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
7362
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
7745
7363
  ] })
7746
7364
  ]
7747
7365
  }
@@ -7796,19 +7414,19 @@ var useLoadedOverrides = ({
7796
7414
 
7797
7415
  // components/DefaultOverride/index.tsx
7798
7416
  init_react_import();
7799
- import { Fragment as Fragment13, jsx as jsx38 } from "react/jsx-runtime";
7800
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment13, { children });
7417
+ import { Fragment as Fragment12, jsx as jsx37 } from "react/jsx-runtime";
7418
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
7801
7419
 
7802
7420
  // lib/use-inject-css.ts
7803
7421
  init_react_import();
7804
- import { useEffect as useEffect22, useState as useState20 } from "react";
7422
+ import { useEffect as useEffect23, useState as useState20 } from "react";
7805
7423
  var styles = ``;
7806
7424
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7807
7425
  const [el, setEl] = useState20();
7808
- useEffect22(() => {
7426
+ useEffect23(() => {
7809
7427
  setEl(document.createElement("style"));
7810
7428
  }, []);
7811
- useEffect22(() => {
7429
+ useEffect23(() => {
7812
7430
  var _a;
7813
7431
  if (!el || typeof window === "undefined") {
7814
7432
  return;
@@ -7828,10 +7446,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
7828
7446
 
7829
7447
  // lib/use-preview-mode-hotkeys.ts
7830
7448
  init_react_import();
7831
- import { useCallback as useCallback15 } from "react";
7449
+ import { useCallback as useCallback16 } from "react";
7832
7450
  var usePreviewModeHotkeys = () => {
7833
7451
  const appStore = useAppStoreApi();
7834
- const toggleInteractive = useCallback15(() => {
7452
+ const toggleInteractive = useCallback16(() => {
7835
7453
  const dispatch = appStore.getState().dispatch;
7836
7454
  dispatch({
7837
7455
  type: "setUi",
@@ -7846,7 +7464,7 @@ var usePreviewModeHotkeys = () => {
7846
7464
 
7847
7465
  // lib/use-puck.ts
7848
7466
  init_react_import();
7849
- import { createContext as createContext6, useContext as useContext10, useEffect as useEffect23, useState as useState21 } from "react";
7467
+ import { createContext as createContext6, useContext as useContext11, useEffect as useEffect24, useState as useState21 } from "react";
7850
7468
  import { createStore as createStore4, useStore as useStore3 } from "zustand";
7851
7469
  var generateUsePuck = (store) => {
7852
7470
  const history = {
@@ -7899,7 +7517,7 @@ var useRegisterUsePuckStore = (appStore) => {
7899
7517
  () => generateUsePuck(convertToPickedStore(appStore.getState()))
7900
7518
  )
7901
7519
  );
7902
- useEffect23(() => {
7520
+ useEffect24(() => {
7903
7521
  return appStore.subscribe(
7904
7522
  (store) => convertToPickedStore(store),
7905
7523
  (pickedStore) => {
@@ -7911,7 +7529,7 @@ var useRegisterUsePuckStore = (appStore) => {
7911
7529
  };
7912
7530
  function createUsePuck() {
7913
7531
  return function usePuck2(selector) {
7914
- const usePuckApi = useContext10(UsePuckStoreContext);
7532
+ const usePuckApi = useContext11(UsePuckStoreContext);
7915
7533
  if (!usePuckApi) {
7916
7534
  throw new Error("usePuck must be used inside <Puck>.");
7917
7535
  }
@@ -7923,55 +7541,281 @@ function createUsePuck() {
7923
7541
  };
7924
7542
  }
7925
7543
  function usePuck() {
7926
- useEffect23(() => {
7544
+ useEffect24(() => {
7927
7545
  console.warn(
7928
7546
  "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."
7929
7547
  );
7930
7548
  }, []);
7931
7549
  return createUsePuck()((s) => s);
7932
7550
  }
7551
+ function useGetPuck() {
7552
+ const usePuckApi = useContext11(UsePuckStoreContext);
7553
+ if (!usePuckApi) {
7554
+ throw new Error("usePuckGet must be used inside <Puck>.");
7555
+ }
7556
+ return usePuckApi.getState;
7557
+ }
7933
7558
 
7934
7559
  // components/Puck/index.tsx
7935
- import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
7936
- var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
7937
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
7938
- var FieldSideBar = () => {
7939
- const title = useAppStore(
7940
- (s) => {
7941
- var _a, _b;
7942
- return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
7943
- }
7944
- );
7945
- return /* @__PURE__ */ jsx39(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx39(Fields, {}) });
7946
- };
7947
- var propsContext = createContext7({});
7948
- function PropsProvider(props) {
7949
- return /* @__PURE__ */ jsx39(propsContext.Provider, { value: props, children: props.children });
7950
- }
7951
- var usePropsContext = () => useContext11(propsContext);
7952
- function PuckProvider({ children }) {
7953
- const {
7954
- config,
7955
- data: initialData,
7956
- ui: initialUi,
7957
- onChange,
7958
- permissions = {},
7959
- plugins,
7960
- overrides,
7961
- viewports = defaultViewports,
7962
- iframe: _iframe,
7963
- initialHistory: _initialHistory,
7964
- metadata,
7965
- onAction
7966
- } = usePropsContext();
7967
- const iframe = __spreadValues({
7968
- enabled: true,
7969
- waitForStyles: true
7970
- }, _iframe);
7971
- const [generatedAppState] = useState22(() => {
7972
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
7973
- const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7974
- let clientUiState = {};
7560
+ import fdeq from "fast-deep-equal";
7561
+
7562
+ // components/Puck/components/Header/index.tsx
7563
+ init_react_import();
7564
+ import { memo as memo3, useCallback as useCallback17, useMemo as useMemo20, useState as useState22 } from "react";
7565
+
7566
+ // components/MenuBar/index.tsx
7567
+ init_react_import();
7568
+
7569
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
7570
+ init_react_import();
7571
+ 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" };
7572
+
7573
+ // components/MenuBar/index.tsx
7574
+ import { Fragment as Fragment13, jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
7575
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
7576
+ function MenuBar({
7577
+ menuOpen = false,
7578
+ renderHeaderActions,
7579
+ setMenuOpen
7580
+ }) {
7581
+ const back = useAppStore((s) => s.history.back);
7582
+ const forward = useAppStore((s) => s.history.forward);
7583
+ const hasFuture = useAppStore((s) => s.history.hasFuture());
7584
+ const hasPast = useAppStore((s) => s.history.hasPast());
7585
+ return /* @__PURE__ */ jsx38(
7586
+ "div",
7587
+ {
7588
+ className: getClassName26({ menuOpen }),
7589
+ onClick: (event) => {
7590
+ var _a;
7591
+ const element = event.target;
7592
+ if (window.matchMedia("(min-width: 638px)").matches) {
7593
+ return;
7594
+ }
7595
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
7596
+ setMenuOpen(false);
7597
+ }
7598
+ },
7599
+ children: /* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), children: [
7600
+ /* @__PURE__ */ jsxs18("div", { className: getClassName26("history"), children: [
7601
+ /* @__PURE__ */ jsx38(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx38(Undo2, { size: 21 }) }),
7602
+ /* @__PURE__ */ jsx38(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx38(Redo2, { size: 21 }) })
7603
+ ] }),
7604
+ /* @__PURE__ */ jsx38(Fragment13, { children: renderHeaderActions && renderHeaderActions() })
7605
+ ] })
7606
+ }
7607
+ );
7608
+ }
7609
+
7610
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
7611
+ init_react_import();
7612
+ var styles_module_default22 = { "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" };
7613
+
7614
+ // components/Puck/components/Header/index.tsx
7615
+ import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
7616
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
7617
+ var HeaderInner = () => {
7618
+ const {
7619
+ onPublish,
7620
+ renderHeader,
7621
+ renderHeaderActions,
7622
+ headerTitle,
7623
+ headerPath,
7624
+ iframe: _iframe
7625
+ } = usePropsContext();
7626
+ const dispatch = useAppStore((s) => s.dispatch);
7627
+ const appStore = useAppStoreApi();
7628
+ const defaultHeaderRender = useMemo20(() => {
7629
+ if (renderHeader) {
7630
+ console.warn(
7631
+ "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
7632
+ );
7633
+ const RenderHeader = (_a) => {
7634
+ var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
7635
+ const Comp = renderHeader;
7636
+ const appState = useAppStore((s) => s.state);
7637
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7638
+ };
7639
+ return RenderHeader;
7640
+ }
7641
+ return DefaultOverride;
7642
+ }, [renderHeader]);
7643
+ const defaultHeaderActionsRender = useMemo20(() => {
7644
+ if (renderHeaderActions) {
7645
+ console.warn(
7646
+ "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7647
+ );
7648
+ const RenderHeader = (props) => {
7649
+ const Comp = renderHeaderActions;
7650
+ const appState = useAppStore((s) => s.state);
7651
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7652
+ };
7653
+ return RenderHeader;
7654
+ }
7655
+ return DefaultOverride;
7656
+ }, [renderHeader]);
7657
+ const CustomHeader = useAppStore(
7658
+ (s) => s.overrides.header || defaultHeaderRender
7659
+ );
7660
+ const CustomHeaderActions = useAppStore(
7661
+ (s) => s.overrides.headerActions || defaultHeaderActionsRender
7662
+ );
7663
+ const [menuOpen, setMenuOpen] = useState22(false);
7664
+ const rootTitle = useAppStore((s) => {
7665
+ var _a, _b;
7666
+ const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
7667
+ return (_b = rootData.props.title) != null ? _b : "";
7668
+ });
7669
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
7670
+ const rightSideBarVisible = useAppStore(
7671
+ (s) => s.state.ui.rightSideBarVisible
7672
+ );
7673
+ const toggleSidebars = useCallback17(
7674
+ (sidebar) => {
7675
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7676
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
7677
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
7678
+ dispatch({
7679
+ type: "setUi",
7680
+ ui: __spreadValues({
7681
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
7682
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
7683
+ });
7684
+ },
7685
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
7686
+ );
7687
+ return /* @__PURE__ */ jsx39(
7688
+ CustomHeader,
7689
+ {
7690
+ actions: /* @__PURE__ */ jsx39(Fragment14, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7691
+ Button,
7692
+ {
7693
+ onClick: () => {
7694
+ const data = appStore.getState().state.data;
7695
+ onPublish && onPublish(data);
7696
+ },
7697
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7698
+ children: "Publish"
7699
+ }
7700
+ ) }) }),
7701
+ children: /* @__PURE__ */ jsx39(
7702
+ "header",
7703
+ {
7704
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
7705
+ children: /* @__PURE__ */ jsxs19("div", { className: getClassName27("inner"), children: [
7706
+ /* @__PURE__ */ jsxs19("div", { className: getClassName27("toggle"), children: [
7707
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ jsx39(
7708
+ IconButton,
7709
+ {
7710
+ onClick: () => {
7711
+ toggleSidebars("left");
7712
+ },
7713
+ title: "Toggle left sidebar",
7714
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7715
+ }
7716
+ ) }),
7717
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ jsx39(
7718
+ IconButton,
7719
+ {
7720
+ onClick: () => {
7721
+ toggleSidebars("right");
7722
+ },
7723
+ title: "Toggle right sidebar",
7724
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7725
+ }
7726
+ ) })
7727
+ ] }),
7728
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("title"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
7729
+ headerTitle || rootTitle || "Page",
7730
+ headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
7731
+ " ",
7732
+ /* @__PURE__ */ jsx39("code", { className: getClassName27("path"), children: headerPath })
7733
+ ] })
7734
+ ] }) }),
7735
+ /* @__PURE__ */ jsxs19("div", { className: getClassName27("tools"), children: [
7736
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ jsx39(
7737
+ IconButton,
7738
+ {
7739
+ onClick: () => {
7740
+ return setMenuOpen(!menuOpen);
7741
+ },
7742
+ title: "Toggle menu bar",
7743
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7744
+ }
7745
+ ) }),
7746
+ /* @__PURE__ */ jsx39(
7747
+ MenuBar,
7748
+ {
7749
+ dispatch,
7750
+ onPublish,
7751
+ menuOpen,
7752
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7753
+ Button,
7754
+ {
7755
+ onClick: () => {
7756
+ const data = appStore.getState().state.data;
7757
+ onPublish && onPublish(data);
7758
+ },
7759
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7760
+ children: "Publish"
7761
+ }
7762
+ ) }),
7763
+ setMenuOpen
7764
+ }
7765
+ )
7766
+ ] })
7767
+ ] })
7768
+ }
7769
+ )
7770
+ }
7771
+ );
7772
+ };
7773
+ var Header = memo3(HeaderInner);
7774
+
7775
+ // components/Puck/index.tsx
7776
+ import { jsx as jsx40, jsxs as jsxs20 } from "react/jsx-runtime";
7777
+ var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
7778
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
7779
+ var FieldSideBar = () => {
7780
+ const title = useAppStore(
7781
+ (s) => {
7782
+ var _a, _b;
7783
+ return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
7784
+ }
7785
+ );
7786
+ return /* @__PURE__ */ jsx40(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx40(Fields, {}) });
7787
+ };
7788
+ var propsContext = createContext7({});
7789
+ function PropsProvider(props) {
7790
+ return /* @__PURE__ */ jsx40(propsContext.Provider, { value: props, children: props.children });
7791
+ }
7792
+ var usePropsContext = () => useContext12(propsContext);
7793
+ function PuckProvider({ children }) {
7794
+ const {
7795
+ config,
7796
+ data: initialData,
7797
+ ui: initialUi,
7798
+ onChange,
7799
+ permissions = {},
7800
+ plugins,
7801
+ overrides,
7802
+ viewports = defaultViewports,
7803
+ iframe: _iframe,
7804
+ initialHistory: _initialHistory,
7805
+ metadata,
7806
+ onAction
7807
+ } = usePropsContext();
7808
+ const iframe = useMemo21(
7809
+ () => __spreadValues({
7810
+ enabled: true,
7811
+ waitForStyles: true
7812
+ }, _iframe),
7813
+ [_iframe]
7814
+ );
7815
+ const [generatedAppState] = useState23(() => {
7816
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
7817
+ const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7818
+ let clientUiState = {};
7975
7819
  if (typeof window !== "undefined") {
7976
7820
  if (window.matchMedia("(max-width: 638px)").matches) {
7977
7821
  clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
@@ -8028,7 +7872,7 @@ function PuckProvider({ children }) {
8028
7872
  return walkAppState(newAppState, config);
8029
7873
  });
8030
7874
  const { appendData = true } = _initialHistory || {};
8031
- const [blendedHistories] = useState22(
7875
+ const [blendedHistories] = useState23(
8032
7876
  [
8033
7877
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8034
7878
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8048,7 +7892,7 @@ function PuckProvider({ children }) {
8048
7892
  overrides,
8049
7893
  plugins
8050
7894
  });
8051
- const generateAppStore = useCallback16(
7895
+ const generateAppStore = useCallback18(
8052
7896
  (state) => {
8053
7897
  return {
8054
7898
  state,
@@ -8072,10 +7916,10 @@ function PuckProvider({ children }) {
8072
7916
  metadata
8073
7917
  ]
8074
7918
  );
8075
- const [appStore] = useState22(
7919
+ const [appStore] = useState23(
8076
7920
  () => createAppStore(generateAppStore(initialAppState))
8077
7921
  );
8078
- useEffect24(() => {
7922
+ useEffect25(() => {
8079
7923
  const state = appStore.getState().state;
8080
7924
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8081
7925
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8084,66 +7928,47 @@ function PuckProvider({ children }) {
8084
7928
  index: initialHistoryIndex,
8085
7929
  initialAppState
8086
7930
  });
8087
- useEffect24(() => {
8088
- appStore.subscribe((s) => {
8089
- if (onChange) onChange(s.state.data);
8090
- });
7931
+ const previousData = useRef8(null);
7932
+ useEffect25(() => {
7933
+ appStore.subscribe(
7934
+ (s) => s.state.data,
7935
+ (data) => {
7936
+ if (onChange) {
7937
+ if (fdeq(data, previousData.current)) return;
7938
+ onChange(data);
7939
+ previousData.current = data;
7940
+ }
7941
+ }
7942
+ );
8091
7943
  }, []);
8092
7944
  useRegisterPermissionsSlice(appStore, permissions);
8093
7945
  const uPuckStore = useRegisterUsePuckStore(appStore);
8094
- useEffect24(() => {
7946
+ useEffect25(() => {
8095
7947
  const { resolveAndCommitData } = appStore.getState();
8096
7948
  resolveAndCommitData();
8097
7949
  }, []);
8098
- return /* @__PURE__ */ jsx39(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx39(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
7950
+ return /* @__PURE__ */ jsx40(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx40(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8099
7951
  }
8100
7952
  function PuckLayout({ children }) {
8101
7953
  const {
8102
- onChange,
8103
- onPublish,
8104
- renderHeader,
8105
- renderHeaderActions,
8106
- headerTitle,
8107
- headerPath,
8108
7954
  iframe: _iframe,
8109
7955
  dnd,
8110
7956
  initialHistory: _initialHistory
8111
7957
  } = usePropsContext();
8112
- const iframe = __spreadValues({
8113
- enabled: true,
8114
- waitForStyles: true
8115
- }, _iframe);
7958
+ const iframe = useMemo21(
7959
+ () => __spreadValues({
7960
+ enabled: true,
7961
+ waitForStyles: true
7962
+ }, _iframe),
7963
+ [_iframe]
7964
+ );
8116
7965
  useInjectGlobalCss(iframe.enabled);
8117
7966
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8118
7967
  const rightSideBarVisible = useAppStore(
8119
7968
  (s) => s.state.ui.rightSideBarVisible
8120
7969
  );
8121
- const [menuOpen, setMenuOpen] = useState22(false);
8122
- const appStore = useAppStoreApi();
8123
- useEffect24(() => {
8124
- return appStore.subscribe((s) => {
8125
- if (onChange) onChange(s.state.data);
8126
- });
8127
- }, [appStore]);
8128
- const rootProps = useAppStore(
8129
- (s) => s.state.data.root.props || s.state.data.root.props
8130
- );
8131
7970
  const dispatch = useAppStore((s) => s.dispatch);
8132
- const toggleSidebars = useCallback16(
8133
- (sidebar) => {
8134
- const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8135
- const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8136
- const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8137
- dispatch({
8138
- type: "setUi",
8139
- ui: __spreadValues({
8140
- [`${sidebar}SideBarVisible`]: !sideBarVisible
8141
- }, !widerViewport ? { [oppositeSideBar]: false } : {})
8142
- });
8143
- },
8144
- [dispatch, leftSideBarVisible, rightSideBarVisible]
8145
- );
8146
- useEffect24(() => {
7971
+ useEffect25(() => {
8147
7972
  if (!window.matchMedia("(min-width: 638px)").matches) {
8148
7973
  dispatch({
8149
7974
  type: "setUi",
@@ -8166,55 +7991,18 @@ function PuckLayout({ children }) {
8166
7991
  window.removeEventListener("resize", handleResize);
8167
7992
  };
8168
7993
  }, []);
8169
- const defaultHeaderRender = useMemo20(() => {
8170
- if (renderHeader) {
8171
- console.warn(
8172
- "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8173
- );
8174
- const RenderHeader = (_a) => {
8175
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8176
- const Comp = renderHeader;
8177
- const appState = useAppStore((s) => s.state);
8178
- return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8179
- };
8180
- return RenderHeader;
8181
- }
8182
- return DefaultOverride;
8183
- }, [renderHeader]);
8184
- const defaultHeaderActionsRender = useMemo20(() => {
8185
- if (renderHeaderActions) {
8186
- console.warn(
8187
- "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8188
- );
8189
- const RenderHeader = (props) => {
8190
- const Comp = renderHeaderActions;
8191
- const appState = useAppStore((s) => s.state);
8192
- return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8193
- };
8194
- return RenderHeader;
8195
- }
8196
- return DefaultOverride;
8197
- }, [renderHeader]);
8198
7994
  const overrides = useAppStore((s) => s.overrides);
8199
- const CustomPuck = useMemo20(
7995
+ const CustomPuck = useMemo21(
8200
7996
  () => overrides.puck || DefaultOverride,
8201
7997
  [overrides]
8202
7998
  );
8203
- const CustomHeader = useMemo20(
8204
- () => overrides.header || defaultHeaderRender,
8205
- [overrides]
8206
- );
8207
- const CustomHeaderActions = useMemo20(
8208
- () => overrides.headerActions || defaultHeaderActionsRender,
8209
- [overrides]
8210
- );
8211
- const [mounted, setMounted] = useState22(false);
8212
- useEffect24(() => {
7999
+ const [mounted, setMounted] = useState23(false);
8000
+ useEffect25(() => {
8213
8001
  setMounted(true);
8214
8002
  }, []);
8215
8003
  const ready = useAppStore((s) => s.status === "READY");
8216
8004
  useMonitorHotkeys();
8217
- useEffect24(() => {
8005
+ useEffect25(() => {
8218
8006
  if (ready && iframe.enabled) {
8219
8007
  const frameDoc = getFrame();
8220
8008
  if (frameDoc) {
@@ -8223,246 +8011,36 @@ function PuckLayout({ children }) {
8223
8011
  }
8224
8012
  }, [ready, iframe.enabled]);
8225
8013
  usePreviewModeHotkeys();
8226
- return /* @__PURE__ */ jsxs19("div", { className: `Puck ${getClassName27()}`, children: [
8227
- /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
8014
+ return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName28()}`, children: [
8015
+ /* @__PURE__ */ jsx40(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx40(CustomPuck, { children: children || /* @__PURE__ */ jsx40(
8228
8016
  "div",
8229
8017
  {
8230
8018
  className: getLayoutClassName({
8231
8019
  leftSideBarVisible,
8232
- menuOpen,
8233
8020
  mounted,
8234
8021
  rightSideBarVisible
8235
8022
  }),
8236
- children: /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("inner"), children: [
8237
- /* @__PURE__ */ jsx39(
8238
- CustomHeader,
8239
- {
8240
- actions: /* @__PURE__ */ jsx39(Fragment14, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
8241
- Button,
8242
- {
8243
- onClick: () => {
8244
- const data = appStore.getState().state.data;
8245
- onPublish && onPublish(data);
8246
- },
8247
- icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
8248
- children: "Publish"
8249
- }
8250
- ) }) }),
8251
- children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerInner"), children: [
8252
- /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerToggle"), children: [
8253
- /* @__PURE__ */ jsx39(
8254
- "div",
8255
- {
8256
- className: getLayoutClassName("leftSideBarToggle"),
8257
- children: /* @__PURE__ */ jsx39(
8258
- IconButton,
8259
- {
8260
- onClick: () => {
8261
- toggleSidebars("left");
8262
- },
8263
- title: "Toggle left sidebar",
8264
- children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
8265
- }
8266
- )
8267
- }
8268
- ),
8269
- /* @__PURE__ */ jsx39(
8270
- "div",
8271
- {
8272
- className: getLayoutClassName("rightSideBarToggle"),
8273
- children: /* @__PURE__ */ jsx39(
8274
- IconButton,
8275
- {
8276
- onClick: () => {
8277
- toggleSidebars("right");
8278
- },
8279
- title: "Toggle right sidebar",
8280
- children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
8281
- }
8282
- )
8283
- }
8284
- )
8285
- ] }),
8286
- /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
8287
- headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
8288
- headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
8289
- " ",
8290
- /* @__PURE__ */ jsx39(
8291
- "code",
8292
- {
8293
- className: getLayoutClassName("headerPath"),
8294
- children: headerPath
8295
- }
8296
- )
8297
- ] })
8298
- ] }) }),
8299
- /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerTools"), children: [
8300
- /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
8301
- IconButton,
8302
- {
8303
- onClick: () => {
8304
- return setMenuOpen(!menuOpen);
8305
- },
8306
- title: "Toggle menu bar",
8307
- children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
8308
- }
8309
- ) }),
8310
- /* @__PURE__ */ jsx39(
8311
- MenuBar,
8312
- {
8313
- dispatch,
8314
- onPublish,
8315
- menuOpen,
8316
- renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
8317
- Button,
8318
- {
8319
- onClick: () => {
8320
- const data = appStore.getState().state.data;
8321
- onPublish && onPublish(data);
8322
- },
8323
- icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
8324
- children: "Publish"
8325
- }
8326
- ) }),
8327
- setMenuOpen
8328
- }
8329
- )
8330
- ] })
8331
- ] }) })
8332
- }
8333
- ),
8334
- /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("leftSideBar"), children: [
8335
- /* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
8336
- /* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
8023
+ children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
8024
+ /* @__PURE__ */ jsx40(Header, {}),
8025
+ /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
8026
+ /* @__PURE__ */ jsx40(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx40(Components, {}) }),
8027
+ /* @__PURE__ */ jsx40(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx40(Outline, {}) })
8337
8028
  ] }),
8338
- /* @__PURE__ */ jsx39(Canvas, {}),
8339
- /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(FieldSideBar, {}) })
8029
+ /* @__PURE__ */ jsx40(Canvas, {}),
8030
+ /* @__PURE__ */ jsx40("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx40(FieldSideBar, {}) })
8340
8031
  ] })
8341
8032
  }
8342
8033
  ) }) }),
8343
- /* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
8034
+ /* @__PURE__ */ jsx40("div", { id: "puck-portal-root", className: getClassName28("portal") })
8344
8035
  ] });
8345
8036
  }
8346
8037
  function Puck(props) {
8347
- return /* @__PURE__ */ jsx39(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx39(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx39(PuckLayout, __spreadValues({}, props)) })) }));
8038
+ return /* @__PURE__ */ jsx40(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckLayout, __spreadValues({}, props)) })) }));
8348
8039
  }
8349
8040
  Puck.Components = Components;
8350
8041
  Puck.Fields = Fields;
8351
8042
  Puck.Outline = Outline;
8352
- Puck.Preview = Preview3;
8353
-
8354
- // lib/migrate.ts
8355
- init_react_import();
8356
- var migrations = [
8357
- // Migrate root to root.props
8358
- (data) => {
8359
- const rootProps = data.root.props || data.root;
8360
- if (Object.keys(data.root).length > 0 && !data.root.props) {
8361
- console.warn(
8362
- "Migration applied: Root props moved from `root` to `root.props`."
8363
- );
8364
- return __spreadProps(__spreadValues({}, data), {
8365
- root: {
8366
- props: __spreadValues({}, rootProps)
8367
- }
8368
- });
8369
- }
8370
- return data;
8371
- },
8372
- // Migrate zones to slots
8373
- (data, config) => {
8374
- var _a;
8375
- if (!config) return data;
8376
- console.log("Migrating DropZones to slots...");
8377
- const updatedItems = {};
8378
- const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
8379
- const { indexes } = walkAppState(appState, config);
8380
- const deletedCompounds = [];
8381
- walkAppState(appState, config, (content, zoneCompound, zoneType) => {
8382
- var _a2, _b;
8383
- if (zoneType === "dropzone") {
8384
- const [id, slotName] = zoneCompound.split(":");
8385
- const nodeData = indexes.nodes[id].data;
8386
- const componentType = nodeData.type;
8387
- const configForComponent = config.components[componentType];
8388
- if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
8389
- updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
8390
- props: __spreadProps(__spreadValues({}, nodeData.props), {
8391
- [slotName]: content
8392
- })
8393
- });
8394
- deletedCompounds.push(zoneCompound);
8395
- }
8396
- return content;
8397
- }
8398
- return content;
8399
- });
8400
- const updated = walkAppState(
8401
- appState,
8402
- config,
8403
- (content) => content,
8404
- (item) => {
8405
- var _a2;
8406
- return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
8407
- }
8408
- );
8409
- deletedCompounds.forEach((zoneCompound) => {
8410
- var _a2;
8411
- const [_, propName] = zoneCompound.split(":");
8412
- console.log(
8413
- `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
8414
- );
8415
- (_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
8416
- });
8417
- Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
8418
- const [_, propName] = zoneCompound.split(":");
8419
- throw new Error(
8420
- `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
8421
- );
8422
- });
8423
- delete updated.data.zones;
8424
- return updated.data;
8425
- }
8426
- ];
8427
- function migrate(data, config) {
8428
- return migrations == null ? void 0 : migrations.reduce(
8429
- (acc, migration) => migration(acc, config),
8430
- data
8431
- );
8432
- }
8433
-
8434
- // lib/data/walk-tree.ts
8435
- init_react_import();
8436
- function walkTree(data, config, callbackFn) {
8437
- var _a, _b;
8438
- const isSlot2 = createIsSlotConfig(config);
8439
- const walkItem = (item) => {
8440
- return mapSlotsSync(
8441
- item,
8442
- (content, parentId, propName) => callbackFn(content, { parentId, propName }),
8443
- isSlot2
8444
- );
8445
- };
8446
- if ("props" in data) {
8447
- return walkItem(data);
8448
- }
8449
- const _data = data;
8450
- const zones = (_a = _data.zones) != null ? _a : {};
8451
- const mappedContent = _data.content.map(walkItem);
8452
- return {
8453
- root: walkItem(_data.root),
8454
- content: (_b = callbackFn(mappedContent, {
8455
- parentId: "root",
8456
- propName: "default-zone"
8457
- })) != null ? _b : mappedContent,
8458
- zones: Object.keys(zones).reduce(
8459
- (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
8460
- [zoneCompound]: zones[zoneCompound].map(walkItem)
8461
- }),
8462
- {}
8463
- )
8464
- };
8465
- }
8043
+ Puck.Preview = Preview2;
8466
8044
  export {
8467
8045
  Action,
8468
8046
  ActionBar,
@@ -8482,6 +8060,7 @@ export {
8482
8060
  renderContext,
8483
8061
  resolveAllData,
8484
8062
  transformProps,
8063
+ useGetPuck,
8485
8064
  usePuck,
8486
8065
  walkTree
8487
8066
  };