@measured/puck 0.19.0-canary.5bf4fccf → 0.19.0-canary.61865257

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,16 +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,
14
+ migrate,
17
15
  resolveAllData,
18
16
  resolveComponentData,
19
17
  rootAreaId,
@@ -22,8 +20,9 @@ import {
22
20
  setupZone,
23
21
  transformProps,
24
22
  useSlots,
23
+ walkAppState,
25
24
  walkTree
26
- } from "./chunk-COT3ZFIM.mjs";
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);
@@ -1377,14 +1184,6 @@ function createReducer({
1377
1184
  );
1378
1185
  }
1379
1186
 
1380
- // components/ViewportControls/default-viewports.ts
1381
- init_react_import();
1382
- var defaultViewports = [
1383
- { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1384
- { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1385
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1386
- ];
1387
-
1388
1187
  // store/index.ts
1389
1188
  import { create as create2, useStore } from "zustand";
1390
1189
  import { subscribeWithSelector as subscribeWithSelector2 } from "zustand/middleware";
@@ -1626,7 +1425,11 @@ var createNodesSlice = (set, get) => ({
1626
1425
  const s = get().nodes;
1627
1426
  const emptyNode = {
1628
1427
  id,
1629
- methods: { sync: () => null },
1428
+ methods: {
1429
+ sync: () => null,
1430
+ hideOverlay: () => null,
1431
+ showOverlay: () => null
1432
+ },
1630
1433
  element: null
1631
1434
  };
1632
1435
  const existingNode = s.nodes[id];
@@ -1905,31 +1708,6 @@ var toRoot = (item) => {
1905
1708
  };
1906
1709
 
1907
1710
  // store/index.ts
1908
- var defaultAppState = {
1909
- data: { content: [], root: {}, zones: {} },
1910
- ui: {
1911
- leftSideBarVisible: true,
1912
- rightSideBarVisible: true,
1913
- arrayState: {},
1914
- itemSelector: null,
1915
- componentList: {},
1916
- isDragging: false,
1917
- previewMode: "edit",
1918
- viewports: {
1919
- current: {
1920
- width: defaultViewports[0].width,
1921
- height: defaultViewports[0].height || "auto"
1922
- },
1923
- options: [],
1924
- controlsVisible: true
1925
- },
1926
- field: { focus: null }
1927
- },
1928
- indexes: {
1929
- nodes: {},
1930
- zones: {}
1931
- }
1932
- };
1933
1711
  var defaultPageFields = {
1934
1712
  title: { type: "text" }
1935
1713
  };
@@ -2118,326 +1896,11 @@ function useAppStoreApi() {
2118
1896
  init_react_import();
2119
1897
  import { DragDropProvider } from "@dnd-kit/react";
2120
1898
 
2121
- // lib/dnd/dnd-kit/safe.ts
2122
- init_react_import();
2123
- import {
2124
- useDraggable,
2125
- useDroppable
2126
- } from "@dnd-kit/react";
2127
- import { useSortable } from "@dnd-kit/react/sortable";
2128
- function useDroppableSafe(input) {
2129
- if (typeof window === "undefined") {
2130
- return { ref: () => {
2131
- } };
2132
- }
2133
- return useDroppable(input);
2134
- }
2135
- function useDraggableSafe(input) {
2136
- if (typeof window === "undefined") {
2137
- return { ref: () => {
2138
- } };
2139
- }
2140
- return useDraggable(input);
2141
- }
2142
- function useSortableSafe(input) {
2143
- if (typeof window === "undefined") {
2144
- return { ref: () => {
2145
- }, status: "idle", handleRef: () => {
2146
- } };
2147
- }
2148
- return useSortable(input);
2149
- }
2150
-
2151
1899
  // lib/dnd/use-sensors.ts
2152
1900
  init_react_import();
2153
1901
  import { useState as useState2 } from "react";
2154
-
2155
- // lib/dnd/PointerSensor.ts
2156
- init_react_import();
2157
- import { batch, effect } from "@dnd-kit/state";
2158
- import { Sensor, configurator } from "@dnd-kit/abstract";
2159
- import {
2160
- exceedsDistance
2161
- } from "@dnd-kit/geometry";
2162
- import {
2163
- getDocument,
2164
- isElement,
2165
- isHTMLElement,
2166
- isPointerEvent,
2167
- Listeners,
2168
- getFrameTransform
2169
- } from "@dnd-kit/dom/utilities";
2170
- var _clearTimeout;
2171
- var _PointerSensor = class _PointerSensor extends Sensor {
2172
- constructor(manager, options) {
2173
- super(manager);
2174
- this.manager = manager;
2175
- this.options = options;
2176
- this.listeners = new Listeners();
2177
- this.cleanup = /* @__PURE__ */ new Set();
2178
- this.source = void 0;
2179
- this.started = false;
2180
- __privateAdd(this, _clearTimeout);
2181
- this.handleCancel = this.handleCancel.bind(this);
2182
- this.handlePointerUp = this.handlePointerUp.bind(this);
2183
- this.handleKeyDown = this.handleKeyDown.bind(this);
2184
- effect(() => {
2185
- const unbindGlobal = this.bindGlobal(options != null ? options : {});
2186
- return () => {
2187
- unbindGlobal();
2188
- };
2189
- });
2190
- }
2191
- bind(source, options = this.options) {
2192
- const unbind = effect(() => {
2193
- var _a;
2194
- const target = (_a = source.handle) != null ? _a : source.element;
2195
- const listener = (event) => {
2196
- if (isPointerEvent(event)) {
2197
- this.handlePointerDown(event, source, options);
2198
- }
2199
- };
2200
- if (target) {
2201
- patchWindow(target.ownerDocument.defaultView);
2202
- target.addEventListener("pointerdown", listener);
2203
- return () => {
2204
- target.removeEventListener("pointerdown", listener);
2205
- };
2206
- }
2207
- });
2208
- return unbind;
2209
- }
2210
- bindGlobal(options) {
2211
- const documents = /* @__PURE__ */ new Set();
2212
- for (const draggable of this.manager.registry.draggables.value) {
2213
- if (draggable.element) {
2214
- documents.add(getDocument(draggable.element));
2215
- }
2216
- }
2217
- for (const droppable of this.manager.registry.droppables.value) {
2218
- if (droppable.element) {
2219
- documents.add(getDocument(droppable.element));
2220
- }
2221
- }
2222
- const unbindFns = Array.from(documents).map(
2223
- (doc) => this.listeners.bind(doc, [
2224
- {
2225
- type: "pointermove",
2226
- listener: (event) => this.handlePointerMove(event, doc, options)
2227
- },
2228
- {
2229
- type: "pointerup",
2230
- listener: this.handlePointerUp,
2231
- options: {
2232
- capture: true
2233
- }
2234
- },
2235
- {
2236
- // Cancel activation if there is a competing Drag and Drop interaction
2237
- type: "dragstart",
2238
- listener: this.handleDragStart
2239
- }
2240
- ])
2241
- );
2242
- return () => {
2243
- unbindFns.forEach((unbind) => unbind());
2244
- };
2245
- }
2246
- handlePointerDown(event, source, options = {}) {
2247
- if (this.disabled || !event.isPrimary || event.button !== 0 || !isElement(event.target) || source.disabled) {
2248
- return;
2249
- }
2250
- const offset = getFrameTransform(source.element);
2251
- this.initialCoordinates = {
2252
- x: event.clientX * offset.scaleX + offset.x,
2253
- y: event.clientY * offset.scaleY + offset.y
2254
- };
2255
- this.source = source;
2256
- const { activationConstraints } = options;
2257
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
2258
- event.stopImmediatePropagation();
2259
- if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
2260
- this.handleStart(source, event);
2261
- } else {
2262
- const { delay } = constraints;
2263
- if (delay) {
2264
- const timeout3 = setTimeout(
2265
- () => this.handleStart(source, event),
2266
- delay.value
2267
- );
2268
- __privateSet(this, _clearTimeout, () => {
2269
- clearTimeout(timeout3);
2270
- __privateSet(this, _clearTimeout, void 0);
2271
- });
2272
- }
2273
- }
2274
- const cleanup = () => {
2275
- var _a;
2276
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2277
- this.initialCoordinates = void 0;
2278
- this.source = void 0;
2279
- };
2280
- this.cleanup.add(cleanup);
2281
- }
2282
- handlePointerMove(event, doc, options) {
2283
- if (!this.source) {
2284
- return;
2285
- }
2286
- const ownerDocument = this.source.element && getDocument(this.source.element);
2287
- if (doc !== ownerDocument) {
2288
- return;
2289
- }
2290
- const coordinates = {
2291
- x: event.clientX,
2292
- y: event.clientY
2293
- };
2294
- const offset = getFrameTransform(this.source.element);
2295
- coordinates.x = coordinates.x * offset.scaleX + offset.x;
2296
- coordinates.y = coordinates.y * offset.scaleY + offset.y;
2297
- if (this.manager.dragOperation.status.dragging) {
2298
- event.preventDefault();
2299
- event.stopPropagation();
2300
- this.manager.actions.move({ to: coordinates });
2301
- return;
2302
- }
2303
- if (!this.initialCoordinates) {
2304
- return;
2305
- }
2306
- const delta = {
2307
- x: coordinates.x - this.initialCoordinates.x,
2308
- y: coordinates.y - this.initialCoordinates.y
2309
- };
2310
- const { activationConstraints } = options;
2311
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
2312
- const { distance, delay } = constraints != null ? constraints : {};
2313
- if (distance) {
2314
- if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
2315
- return this.handleCancel();
2316
- }
2317
- if (exceedsDistance(delta, distance.value)) {
2318
- return this.handleStart(this.source, event);
2319
- }
2320
- }
2321
- if (delay) {
2322
- if (exceedsDistance(delta, delay.tolerance)) {
2323
- return this.handleCancel();
2324
- }
2325
- }
2326
- }
2327
- handlePointerUp(event) {
2328
- if (!this.source) {
2329
- return;
2330
- }
2331
- event.preventDefault();
2332
- event.stopPropagation();
2333
- const { status } = this.manager.dragOperation;
2334
- if (!status.idle) {
2335
- const canceled = !status.initialized;
2336
- this.manager.actions.stop({ canceled });
2337
- } else if (this.started) {
2338
- setTimeout(() => {
2339
- if (!this.manager.dragOperation.status.idle) {
2340
- this.manager.actions.stop({ canceled: false });
2341
- }
2342
- }, 10);
2343
- }
2344
- this.cleanup.forEach((cleanup) => cleanup());
2345
- this.cleanup.clear();
2346
- }
2347
- handleKeyDown(event) {
2348
- if (event.key === "Escape") {
2349
- event.preventDefault();
2350
- this.handleCancel();
2351
- }
2352
- }
2353
- handleStart(source, event) {
2354
- var _a;
2355
- const { manager, initialCoordinates } = this;
2356
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2357
- if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2358
- return;
2359
- }
2360
- if (event.defaultPrevented) {
2361
- return;
2362
- }
2363
- this.started = true;
2364
- event.preventDefault();
2365
- batch(() => {
2366
- manager.actions.setDragSource(source.id);
2367
- manager.actions.start({ coordinates: initialCoordinates, event });
2368
- });
2369
- const ownerDocument = getDocument(event.target);
2370
- const unbind = this.listeners.bind(ownerDocument, [
2371
- {
2372
- // Prevent scrolling on touch devices
2373
- type: "touchmove",
2374
- listener: preventDefault,
2375
- options: {
2376
- passive: false
2377
- }
2378
- },
2379
- {
2380
- // Prevent click events
2381
- type: "click",
2382
- listener: preventDefault
2383
- },
2384
- {
2385
- type: "keydown",
2386
- listener: this.handleKeyDown
2387
- }
2388
- ]);
2389
- ownerDocument.body.setPointerCapture(event.pointerId);
2390
- this.cleanup.add(unbind);
2391
- this.cleanup.add(() => {
2392
- this.started = false;
2393
- });
2394
- }
2395
- handleDragStart(event) {
2396
- const { target } = event;
2397
- if (!isElement(target)) {
2398
- return;
2399
- }
2400
- const isNativeDraggable = isHTMLElement(target) && target.draggable && target.getAttribute("draggable") === "true";
2401
- if (isNativeDraggable) {
2402
- this.handleCancel();
2403
- } else {
2404
- preventDefault(event);
2405
- }
2406
- }
2407
- handleCancel() {
2408
- const { dragOperation } = this.manager;
2409
- if (dragOperation.status.initialized) {
2410
- this.manager.actions.stop({ canceled: true });
2411
- }
2412
- this.cleanup.forEach((cleanup) => cleanup());
2413
- this.cleanup.clear();
2414
- }
2415
- destroy() {
2416
- this.listeners.clear();
2417
- }
2418
- };
2419
- _clearTimeout = new WeakMap();
2420
- _PointerSensor.configure = configurator(_PointerSensor);
2421
- var PointerSensor = _PointerSensor;
2422
- function preventDefault(event) {
2423
- event.preventDefault();
2424
- }
2425
- function noop() {
2426
- }
2427
- var windows = /* @__PURE__ */ new WeakSet();
2428
- function patchWindow(window2) {
2429
- if (!window2 || windows.has(window2)) {
2430
- return;
2431
- }
2432
- window2.addEventListener("touchmove", noop, {
2433
- capture: false,
2434
- passive: false
2435
- });
2436
- windows.add(window2);
2437
- }
2438
-
2439
- // lib/dnd/use-sensors.ts
2440
- import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
1902
+ import { PointerSensor } from "@dnd-kit/react";
1903
+ import { isElement } from "@dnd-kit/dom/utilities";
2441
1904
  var useSensors = ({
2442
1905
  other,
2443
1906
  mouse,
@@ -2451,7 +1914,7 @@ var useSensors = ({
2451
1914
  activationConstraints(event, source) {
2452
1915
  var _a;
2453
1916
  const { pointerType, target } = event;
2454
- 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)))) {
2455
1918
  return mouse;
2456
1919
  }
2457
1920
  if (pointerType === "touch") {
@@ -2621,7 +2084,7 @@ import { Point as Point2 } from "@dnd-kit/geometry";
2621
2084
  import { CollisionPriority as CollisionPriority2, CollisionType as CollisionType22 } from "@dnd-kit/abstract";
2622
2085
  import { Point as Point22 } from "@dnd-kit/geometry";
2623
2086
  import { CollisionPriority as CollisionPriority3, CollisionType as CollisionType3 } from "@dnd-kit/abstract";
2624
- import { Point as Point3 } from "@dnd-kit/geometry";
2087
+ import { Point as Point3, Rectangle } from "@dnd-kit/geometry";
2625
2088
  import { CollisionPriority as CollisionPriority4, CollisionType as CollisionType4 } from "@dnd-kit/abstract";
2626
2089
  import { Point as Point4 } from "@dnd-kit/geometry";
2627
2090
  import { CollisionPriority as CollisionPriority5, CollisionType as CollisionType5 } from "@dnd-kit/abstract";
@@ -2657,31 +2120,15 @@ var closestCorners = (input) => {
2657
2120
  if (!droppable.shape) {
2658
2121
  return null;
2659
2122
  }
2660
- const { left, top, right, bottom } = droppable.shape.boundingRectangle;
2661
- const corners = [
2662
- {
2663
- x: left,
2664
- y: top
2665
- },
2666
- {
2667
- x: right,
2668
- y: top
2669
- },
2670
- {
2671
- x: left,
2672
- y: bottom
2673
- },
2674
- {
2675
- x: right,
2676
- y: bottom
2677
- }
2678
- ];
2679
- const distance = corners.reduce(
2680
- (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) => {
2681
2128
  var _a;
2682
2129
  return acc + Point3.distance(
2683
2130
  Point3.from(corner),
2684
- (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
2131
+ (_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
2685
2132
  );
2686
2133
  },
2687
2134
  0
@@ -2716,12 +2163,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2716
2163
  const { center: dragCenter } = dragShape;
2717
2164
  const { fallbackEnabled } = collisionStore.getState();
2718
2165
  const interval = trackMovementInterval(position.current, dragAxis);
2719
- dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2720
- direction: interval.direction
2721
- });
2722
- const collisionMap = dragOperation.data.collisionMap || {};
2723
- dragOperation.data.collisionMap = collisionMap;
2724
- collisionMap[droppable.id] = {
2166
+ const data = {
2725
2167
  direction: interval.direction
2726
2168
  };
2727
2169
  const { center: dropCenter } = dropShape;
@@ -2736,7 +2178,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2736
2178
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
2737
2179
  if (collision) {
2738
2180
  return __spreadProps(__spreadValues({}, collision), {
2739
- priority: CollisionPriority7.Highest
2181
+ priority: CollisionPriority7.Highest,
2182
+ data
2740
2183
  });
2741
2184
  }
2742
2185
  }
@@ -2758,7 +2201,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2758
2201
  };
2759
2202
  const shouldFlushId = flushNext === droppable.id;
2760
2203
  flushNext = "";
2761
- return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2204
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
2762
2205
  }
2763
2206
  if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2764
2207
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
@@ -2770,9 +2213,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2770
2213
  x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
2771
2214
  y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
2772
2215
  });
2773
- collisionMap[droppable.id] = {
2774
- direction
2775
- };
2216
+ data.direction = direction;
2776
2217
  if (intersectionArea) {
2777
2218
  collisionDebug(
2778
2219
  dragCenter,
@@ -2783,7 +2224,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2783
2224
  );
2784
2225
  flushNext = droppable.id;
2785
2226
  return __spreadProps(__spreadValues({}, fallbackCollision), {
2786
- priority: CollisionPriority7.Low
2227
+ priority: CollisionPriority7.Low,
2228
+ data
2787
2229
  });
2788
2230
  }
2789
2231
  collisionDebug(
@@ -2793,16 +2235,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2793
2235
  "orange",
2794
2236
  direction || ""
2795
2237
  );
2796
- return __spreadProps(__spreadValues({}, fallbackCollision), { priority: CollisionPriority7.Lowest });
2238
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2239
+ priority: CollisionPriority7.Lowest,
2240
+ data
2241
+ });
2797
2242
  }
2798
2243
  }
2799
2244
  }
2800
2245
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2801
- delete collisionMap[droppable.id];
2802
2246
  return null;
2803
2247
  };
2804
2248
 
2805
2249
  // components/Sortable/index.tsx
2250
+ import { useSortable } from "@dnd-kit/react/sortable";
2806
2251
  import { jsx as jsx5 } from "react/jsx-runtime";
2807
2252
  var SortableProvider = ({
2808
2253
  children,
@@ -2822,16 +2267,16 @@ var SortableProvider = ({
2822
2267
  return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
2823
2268
  },
2824
2269
  onDragOver: (event, manager) => {
2825
- var _a, _b;
2270
+ var _a;
2826
2271
  event.preventDefault();
2827
2272
  const { operation } = event;
2828
2273
  const { source, target } = operation;
2829
2274
  if (!source || !target) return;
2830
2275
  let sourceIndex = source.data.index;
2831
2276
  let targetIndex = target.data.index;
2832
- 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;
2833
2278
  if (sourceIndex !== targetIndex && source.id !== target.id) {
2834
- const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2279
+ const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
2835
2280
  if (targetIndex >= sourceIndex) {
2836
2281
  targetIndex = targetIndex - 1;
2837
2282
  }
@@ -2862,9 +2307,10 @@ var Sortable = ({
2862
2307
  }) => {
2863
2308
  const {
2864
2309
  ref: sortableRef,
2865
- status,
2310
+ isDragging,
2311
+ isDropping,
2866
2312
  handleRef
2867
- } = useSortableSafe({
2313
+ } = useSortable({
2868
2314
  id,
2869
2315
  type,
2870
2316
  index,
@@ -2872,7 +2318,7 @@ var Sortable = ({
2872
2318
  data: { index },
2873
2319
  collisionDetector: createDynamicCollisionDetector("y")
2874
2320
  });
2875
- return children({ status, ref: sortableRef, handleRef });
2321
+ return children({ isDragging, isDropping, ref: sortableRef, handleRef });
2876
2322
  };
2877
2323
 
2878
2324
  // components/AutoField/context.tsx
@@ -2997,7 +2443,7 @@ var ArrayField = ({
2997
2443
  }
2998
2444
  }, []);
2999
2445
  const [draggedItem, setDraggedItem] = useState3("");
3000
- const isDragging = !!draggedItem;
2446
+ const isDraggingAny = !!draggedItem;
3001
2447
  const canEdit = useAppStore(
3002
2448
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
3003
2449
  );
@@ -3062,13 +2508,13 @@ var ArrayField = ({
3062
2508
  id: _arrayId,
3063
2509
  index: i,
3064
2510
  disabled: readOnly,
3065
- children: ({ status, ref, handleRef }) => /* @__PURE__ */ jsxs3(
2511
+ children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ jsxs3(
3066
2512
  "div",
3067
2513
  {
3068
2514
  ref,
3069
2515
  className: getClassNameItem({
3070
2516
  isExpanded: arrayState.openId === _arrayId,
3071
- isDragging: status === "dragging",
2517
+ isDragging,
3072
2518
  readOnly
3073
2519
  }),
3074
2520
  children: [
@@ -3209,7 +2655,7 @@ var ArrayField = ({
3209
2655
  type: "button",
3210
2656
  className: getClassName5("addButton"),
3211
2657
  onClick: () => {
3212
- if (isDragging) return;
2658
+ if (isDraggingAny) return;
3213
2659
  const existingValue = value || [];
3214
2660
  const newValue = [
3215
2661
  ...existingValue,
@@ -4208,11 +3654,11 @@ init_react_import();
4208
3654
  import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
4209
3655
  import {
4210
3656
  createContext as createContext4,
4211
- useCallback as useCallback10,
4212
- useContext as useContext7,
4213
- useEffect as useEffect16,
3657
+ useCallback as useCallback11,
3658
+ useContext as useContext8,
3659
+ useEffect as useEffect17,
4214
3660
  useMemo as useMemo10,
4215
- useRef as useRef4,
3661
+ useRef as useRef5,
4216
3662
  useState as useState14
4217
3663
  } from "react";
4218
3664
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
@@ -4222,22 +3668,23 @@ init_react_import();
4222
3668
  import {
4223
3669
  forwardRef as forwardRef3,
4224
3670
  memo,
4225
- useCallback as useCallback9,
4226
- useContext as useContext6,
4227
- useEffect as useEffect15,
3671
+ useCallback as useCallback10,
3672
+ useContext as useContext7,
3673
+ useEffect as useEffect16,
4228
3674
  useMemo as useMemo9,
4229
- useRef as useRef3
3675
+ useRef as useRef4
4230
3676
  } from "react";
4231
3677
 
4232
3678
  // components/DraggableComponent/index.tsx
4233
3679
  init_react_import();
4234
3680
  import {
4235
- useCallback as useCallback6,
3681
+ useCallback as useCallback7,
4236
3682
  useContext as useContext5,
4237
- useEffect as useEffect11,
3683
+ useEffect as useEffect12,
4238
3684
  useMemo as useMemo7,
4239
3685
  useRef as useRef2,
4240
- useState as useState10
3686
+ useState as useState10,
3687
+ useTransition
4241
3688
  } from "react";
4242
3689
 
4243
3690
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
@@ -4271,8 +3718,7 @@ init_react_import();
4271
3718
  import {
4272
3719
  createContext as createContext3,
4273
3720
  useCallback as useCallback5,
4274
- useMemo as useMemo6,
4275
- useState as useState9
3721
+ useMemo as useMemo6
4276
3722
  } from "react";
4277
3723
  import { createStore as createStore2 } from "zustand";
4278
3724
  import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
@@ -4284,7 +3730,9 @@ var ZoneStoreContext = createContext3(
4284
3730
  areaDepthIndex: {},
4285
3731
  nextAreaDepthIndex: {},
4286
3732
  draggedItem: null,
4287
- previewIndex: {}
3733
+ previewIndex: {},
3734
+ enabledIndex: {},
3735
+ hoveringComponent: null
4288
3736
  }))
4289
3737
  );
4290
3738
  var ZoneStoreProvider = ({
@@ -4297,7 +3745,6 @@ var DropZoneProvider = ({
4297
3745
  children,
4298
3746
  value
4299
3747
  }) => {
4300
- const [hoveringComponent, setHoveringComponent] = useState9();
4301
3748
  const dispatch = useAppStore((s) => s.dispatch);
4302
3749
  const registerZone = useCallback5(
4303
3750
  (zoneCompound) => {
@@ -4319,16 +3766,33 @@ var DropZoneProvider = ({
4319
3766
  );
4320
3767
  const memoValue = useMemo6(
4321
3768
  () => __spreadValues({
4322
- hoveringComponent,
4323
- setHoveringComponent,
4324
3769
  registerZone,
4325
3770
  unregisterZone
4326
3771
  }, value),
4327
- [value, hoveringComponent]
3772
+ [value]
4328
3773
  );
4329
3774
  return /* @__PURE__ */ jsx19(Fragment5, { children: memoValue && /* @__PURE__ */ jsx19(dropZoneContext.Provider, { value: memoValue, children }) });
4330
3775
  };
4331
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
+
4332
3796
  // lib/use-context-store.ts
4333
3797
  init_react_import();
4334
3798
  import { useContext as useContext4 } from "react";
@@ -4342,8 +3806,39 @@ function useContextStore(context, selector) {
4342
3806
  return useStore2(store, useShallow(selector));
4343
3807
  }
4344
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
+
4345
3841
  // components/DraggableComponent/index.tsx
4346
- import { useShallow as useShallow2 } from "zustand/react/shallow";
4347
3842
  import { jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
4348
3843
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
4349
3844
  var DEBUG2 = false;
@@ -4373,7 +3868,6 @@ var DraggableComponent = ({
4373
3868
  isSelected = false,
4374
3869
  debug,
4375
3870
  label,
4376
- isEnabled,
4377
3871
  autoDragAxis,
4378
3872
  userDragAxis,
4379
3873
  inDroppableZone = true
@@ -4389,7 +3883,7 @@ var DraggableComponent = ({
4389
3883
  const iframe = useAppStore((s) => s.iframe);
4390
3884
  const ctx = useContext5(dropZoneContext);
4391
3885
  const [localZones, setLocalZones] = useState10({});
4392
- const registerLocalZone = useCallback6(
3886
+ const registerLocalZone = useCallback7(
4393
3887
  (zoneCompound2, active) => {
4394
3888
  var _a;
4395
3889
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4399,7 +3893,7 @@ var DraggableComponent = ({
4399
3893
  },
4400
3894
  [setLocalZones]
4401
3895
  );
4402
- const unregisterLocalZone = useCallback6(
3896
+ const unregisterLocalZone = useCallback7(
4403
3897
  (zoneCompound2) => {
4404
3898
  var _a;
4405
3899
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4422,14 +3916,17 @@ var DraggableComponent = ({
4422
3916
  return s.permissions.getPermissions({ item });
4423
3917
  })
4424
3918
  );
4425
- const userIsDragging = useContextStore(
4426
- ZoneStoreContext,
4427
- (s) => !!s.draggedItem
4428
- );
4429
- const canCollide = permissions.drag || userIsDragging;
4430
- const disabled = !isEnabled || !canCollide;
3919
+ const zoneStore = useContext5(ZoneStoreContext);
4431
3920
  const [dragAxis, setDragAxis] = useState10(userDragAxis || autoDragAxis);
4432
- 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({
4433
3930
  id,
4434
3931
  index,
4435
3932
  group: zoneCompound,
@@ -4444,18 +3941,34 @@ var DraggableComponent = ({
4444
3941
  path: path || [],
4445
3942
  inDroppableZone
4446
3943
  },
4447
- collisionPriority: isEnabled ? depth : 0,
4448
- collisionDetector: createDynamicCollisionDetector(dragAxis),
4449
- disabled,
3944
+ collisionPriority: depth,
3945
+ collisionDetector: dynamicCollisionDetector,
4450
3946
  // "Out of the way" transition from react-beautiful-dnd
4451
3947
  transition: {
4452
3948
  duration: 200,
4453
3949
  easing: "cubic-bezier(0.2, 0, 0, 1)"
4454
- }
3950
+ },
3951
+ feedback: "clone"
4455
3952
  });
4456
- const thisIsDragging = status === "dragging";
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]);
4457
3970
  const ref = useRef2(null);
4458
- const refSetter = useCallback6(
3971
+ const refSetter = useCallback7(
4459
3972
  (el) => {
4460
3973
  sortableRef(el);
4461
3974
  if (el) {
@@ -4465,13 +3978,13 @@ var DraggableComponent = ({
4465
3978
  [sortableRef]
4466
3979
  );
4467
3980
  const [portalEl, setPortalEl] = useState10();
4468
- useEffect11(() => {
3981
+ useEffect12(() => {
4469
3982
  var _a, _b, _c;
4470
3983
  setPortalEl(
4471
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
4472
3985
  );
4473
3986
  }, [iframe.enabled, ref.current]);
4474
- const getStyle = useCallback6(() => {
3987
+ const getStyle = useCallback7(() => {
4475
3988
  var _a, _b, _c;
4476
3989
  if (!ref.current) return;
4477
3990
  const rect = ref.current.getBoundingClientRect();
@@ -4483,40 +3996,61 @@ var DraggableComponent = ({
4483
3996
  x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
4484
3997
  y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
4485
3998
  };
3999
+ const untransformed = {
4000
+ height: ref.current.offsetHeight,
4001
+ width: ref.current.offsetWidth
4002
+ };
4003
+ const transform = accumulateTransform(ref.current);
4486
4004
  const style2 = {
4487
- left: `${rect.left + scroll.x}px`,
4488
- top: `${rect.top + scroll.y}px`,
4489
- height: `${rect.height}px`,
4490
- 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`
4491
4009
  };
4492
4010
  return style2;
4493
4011
  }, [ref.current]);
4494
4012
  const [style, setStyle] = useState10();
4495
- const sync = useCallback6(() => {
4013
+ const sync = useCallback7(() => {
4496
4014
  setStyle(getStyle());
4497
4015
  }, [ref.current, iframe]);
4498
- useEffect11(() => {
4499
- if (ref.current && !userIsDragging) {
4016
+ useEffect12(() => {
4017
+ if (ref.current) {
4500
4018
  const observer = new ResizeObserver(sync);
4501
4019
  observer.observe(ref.current);
4502
4020
  return () => {
4503
4021
  observer.disconnect();
4504
4022
  };
4505
4023
  }
4506
- }, [ref.current, userIsDragging]);
4024
+ }, [ref.current]);
4507
4025
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4508
- useEffect11(() => {
4026
+ const hideOverlay = useCallback7(() => {
4027
+ setIsVisible(false);
4028
+ }, []);
4029
+ const showOverlay = useCallback7(() => {
4030
+ setIsVisible(true);
4031
+ }, []);
4032
+ useEffect12(() => {
4509
4033
  var _a;
4510
- 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
+ });
4511
4038
  return () => {
4512
- 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
+ });
4513
4047
  };
4514
4048
  }, [id, zoneCompound, index, componentType, sync]);
4515
4049
  const CustomActionBar = useMemo7(
4516
4050
  () => overrides.actionBar || DefaultActionBar,
4517
4051
  [overrides.actionBar]
4518
4052
  );
4519
- const onClick = useCallback6(
4053
+ const onClick = useCallback7(
4520
4054
  (e) => {
4521
4055
  e.stopPropagation();
4522
4056
  dispatch({
@@ -4529,7 +4063,7 @@ var DraggableComponent = ({
4529
4063
  [index, zoneCompound, id]
4530
4064
  );
4531
4065
  const appStore = useAppStoreApi();
4532
- const onSelectParent = useCallback6(() => {
4066
+ const onSelectParent = useCallback7(() => {
4533
4067
  const { nodes, zones } = appStore.getState().state.indexes;
4534
4068
  const node = nodes[id];
4535
4069
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4550,14 +4084,14 @@ var DraggableComponent = ({
4550
4084
  }
4551
4085
  });
4552
4086
  }, [ctx, path]);
4553
- const onDuplicate = useCallback6(() => {
4087
+ const onDuplicate = useCallback7(() => {
4554
4088
  dispatch({
4555
4089
  type: "duplicate",
4556
4090
  sourceIndex: index,
4557
4091
  sourceZone: zoneCompound
4558
4092
  });
4559
4093
  }, [index, zoneCompound]);
4560
- const onDelete = useCallback6(() => {
4094
+ const onDelete = useCallback7(() => {
4561
4095
  dispatch({
4562
4096
  type: "remove",
4563
4097
  index,
@@ -4565,13 +4099,17 @@ var DraggableComponent = ({
4565
4099
  });
4566
4100
  }, [index, zoneCompound]);
4567
4101
  const [hover, setHover] = useState10(false);
4568
- const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4569
- useEffect11(() => {
4570
- if (!ref.current) {
4571
- return;
4102
+ const indicativeHover = useContextStore(
4103
+ ZoneStoreContext,
4104
+ (s) => s.hoveringComponent === id
4105
+ );
4106
+ useEffect12(() => {
4107
+ if (!ref.current) {
4108
+ return;
4572
4109
  }
4573
4110
  const el = ref.current;
4574
4111
  const _onMouseOver = (e) => {
4112
+ const userIsDragging = !!zoneStore.getState().draggedItem;
4575
4113
  if (userIsDragging) {
4576
4114
  if (thisIsDragging) {
4577
4115
  setHover(true);
@@ -4593,18 +4131,12 @@ var DraggableComponent = ({
4593
4131
  el.addEventListener("click", onClick);
4594
4132
  el.addEventListener("mouseover", _onMouseOver);
4595
4133
  el.addEventListener("mouseout", _onMouseOut);
4596
- if (thisIsDragging) {
4597
- el.setAttribute("data-puck-dragging", "");
4598
- } else {
4599
- el.removeAttribute("data-puck-dragging");
4600
- }
4601
4134
  return () => {
4602
4135
  el.removeAttribute("data-puck-component");
4603
4136
  el.removeAttribute("data-puck-dnd");
4604
4137
  el.removeEventListener("click", onClick);
4605
4138
  el.removeEventListener("mouseover", _onMouseOver);
4606
4139
  el.removeEventListener("mouseout", _onMouseOut);
4607
- el.removeAttribute("data-puck-dragging");
4608
4140
  };
4609
4141
  }, [
4610
4142
  ref,
@@ -4612,29 +4144,43 @@ var DraggableComponent = ({
4612
4144
  containsActiveZone,
4613
4145
  zoneCompound,
4614
4146
  id,
4615
- userIsDragging,
4616
4147
  thisIsDragging,
4617
4148
  inDroppableZone
4618
4149
  ]);
4619
- useEffect11(() => {
4620
- if (ref.current && disabled) {
4621
- ref.current.setAttribute("data-puck-disabled", "");
4622
- return () => {
4623
- var _a;
4624
- (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4625
- };
4626
- }
4627
- }, [disabled, ref]);
4628
4150
  const [isVisible, setIsVisible] = useState10(false);
4629
- useEffect11(() => {
4630
- sync();
4631
- if ((isSelected || hover || indicativeHover) && !userIsDragging) {
4632
- 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
+ });
4633
4171
  } else {
4634
- setIsVisible(false);
4172
+ setDragFinished(false);
4173
+ }
4174
+ });
4175
+ useEffect12(() => {
4176
+ if (thisIsDragging) {
4177
+ setThisWasDragging(true);
4635
4178
  }
4636
- }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
4637
- const syncActionsPosition = useCallback6(
4179
+ }, [thisIsDragging]);
4180
+ useEffect12(() => {
4181
+ if (thisWasDragging) return onDragFinished();
4182
+ }, [thisWasDragging, onDragFinished]);
4183
+ const syncActionsPosition = useCallback7(
4638
4184
  (el) => {
4639
4185
  if (el) {
4640
4186
  const view = el.ownerDocument.defaultView;
@@ -4659,7 +4205,7 @@ var DraggableComponent = ({
4659
4205
  },
4660
4206
  [zoom]
4661
4207
  );
4662
- useEffect11(() => {
4208
+ useEffect12(() => {
4663
4209
  if (userDragAxis) {
4664
4210
  setDragAxis(userDragAxis);
4665
4211
  return;
@@ -4673,7 +4219,10 @@ var DraggableComponent = ({
4673
4219
  }
4674
4220
  setDragAxis(autoDragAxis);
4675
4221
  }, [ref, userDragAxis, autoDragAxis]);
4676
- 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
+ );
4677
4226
  const nextContextValue = useMemo7(
4678
4227
  () => __spreadProps(__spreadValues({}, ctx), {
4679
4228
  areaId: id,
@@ -4694,7 +4243,7 @@ var DraggableComponent = ({
4694
4243
  ]
4695
4244
  );
4696
4245
  return /* @__PURE__ */ jsxs9(DropZoneProvider, { value: nextContextValue, children: [
4697
- isVisible && createPortal2(
4246
+ dragFinished && isVisible && createPortal2(
4698
4247
  /* @__PURE__ */ jsxs9(
4699
4248
  "div",
4700
4249
  {
@@ -4754,11 +4303,15 @@ var DraggableComponent = ({
4754
4303
 
4755
4304
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
4756
4305
  init_react_import();
4757
- 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";
4758
4310
 
4759
4311
  // components/DropZone/lib/use-min-empty-height.ts
4760
4312
  init_react_import();
4761
- 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;
4762
4315
  var useMinEmptyHeight = ({
4763
4316
  zoneCompound,
4764
4317
  userMinEmptyHeight,
@@ -4774,32 +4327,52 @@ var useMinEmptyHeight = ({
4774
4327
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
4775
4328
  };
4776
4329
  });
4777
- 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(() => {
4778
4366
  if (draggedItem && ref.current) {
4779
4367
  if (isZone) {
4780
4368
  const rect = ref.current.getBoundingClientRect();
4369
+ numItems.current = getNumItems(appStore, zoneCompound);
4781
4370
  setPrevHeight(rect.height);
4782
4371
  setIsAnimating(true);
4783
- return;
4372
+ return onDragFinished();
4784
4373
  }
4785
4374
  }
4786
- setPrevHeight(0);
4787
- setTimeout(() => {
4788
- var _a, _b;
4789
- const zones = appStore.getState().state.indexes.zones;
4790
- const nodes = appStore.getState().nodes;
4791
- const selectedItem = appStore.getState().selectedItem;
4792
- const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
4793
- contentIds.forEach((contentId) => {
4794
- const node = nodes.nodes[contentId];
4795
- node == null ? void 0 : node.methods.sync();
4796
- });
4797
- if (selectedItem) {
4798
- (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
4799
- }
4800
- setIsAnimating(false);
4801
- }, 400);
4802
- }, [ref.current, draggedItem, zoneCompound]);
4375
+ }, [ref.current, draggedItem, onDragFinished]);
4803
4376
  return [prevHeight || userMinEmptyHeight, isAnimating];
4804
4377
  };
4805
4378
 
@@ -4820,15 +4393,15 @@ function assignRefs(refs, node) {
4820
4393
 
4821
4394
  // components/DropZone/lib/use-content-with-preview.ts
4822
4395
  init_react_import();
4823
- import { useEffect as useEffect13, useState as useState12 } from "react";
4396
+ import { useContext as useContext6, useEffect as useEffect14, useState as useState12 } from "react";
4824
4397
 
4825
4398
  // lib/dnd/use-rendered-callback.ts
4826
4399
  init_react_import();
4827
4400
  import { useDragDropManager } from "@dnd-kit/react";
4828
- import { useCallback as useCallback7 } from "react";
4401
+ import { useCallback as useCallback8 } from "react";
4829
4402
  function useRenderedCallback(callback, deps) {
4830
4403
  const manager = useDragDropManager();
4831
- return useCallback7(
4404
+ return useCallback8(
4832
4405
  (...args) => __async(this, null, function* () {
4833
4406
  yield manager == null ? void 0 : manager.renderer.rendering;
4834
4407
  return callback(...args);
@@ -4839,16 +4412,10 @@ function useRenderedCallback(callback, deps) {
4839
4412
 
4840
4413
  // components/DropZone/lib/use-content-with-preview.ts
4841
4414
  var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4842
- const { draggedItemId, preview, previewExists } = useContextStore(
4415
+ const zoneStore = useContext6(ZoneStoreContext);
4416
+ const preview = useContextStore(
4843
4417
  ZoneStoreContext,
4844
- (s) => {
4845
- var _a;
4846
- return {
4847
- draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
4848
- preview: s.previewIndex[zoneCompound],
4849
- previewExists: Object.keys(s.previewIndex || {}).length > 0
4850
- };
4851
- }
4418
+ (s) => s.previewIndex[zoneCompound]
4852
4419
  );
4853
4420
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
4854
4421
  const [contentIdsWithPreview, setContentIdsWithPreview] = useState12(contentIds);
@@ -4856,10 +4423,10 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4856
4423
  preview
4857
4424
  );
4858
4425
  const updateContent = useRenderedCallback(
4859
- (contentIds2, preview2, isDragging2) => {
4860
- if (isDragging2 && !previewExists) {
4861
- return;
4862
- }
4426
+ (contentIds2, preview2) => {
4427
+ var _a;
4428
+ const s = zoneStore.getState();
4429
+ const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
4863
4430
  if (preview2) {
4864
4431
  if (preview2.type === "insert") {
4865
4432
  setContentIdsWithPreview(
@@ -4880,14 +4447,14 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4880
4447
  }
4881
4448
  } else {
4882
4449
  setContentIdsWithPreview(
4883
- previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
4450
+ contentIds2.filter((id) => id !== draggedItemId)
4884
4451
  );
4885
4452
  }
4886
4453
  setLocalPreview(preview2);
4887
4454
  },
4888
- [draggedItemId, previewExists]
4455
+ []
4889
4456
  );
4890
- useEffect13(() => {
4457
+ useEffect14(() => {
4891
4458
  updateContent(contentIds, preview, isDragging);
4892
4459
  }, [contentIds, preview, isDragging]);
4893
4460
  return [contentIdsWithPreview, localPreview];
@@ -4895,7 +4462,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4895
4462
 
4896
4463
  // components/DropZone/lib/use-drag-axis.ts
4897
4464
  init_react_import();
4898
- 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";
4899
4466
  var GRID_DRAG_AXIS = "dynamic";
4900
4467
  var FLEX_ROW_DRAG_AXIS = "x";
4901
4468
  var DEFAULT_DRAG_AXIS = "y";
@@ -4904,7 +4471,7 @@ var useDragAxis = (ref, collisionAxis) => {
4904
4471
  const [dragAxis, setDragAxis] = useState13(
4905
4472
  collisionAxis || DEFAULT_DRAG_AXIS
4906
4473
  );
4907
- const calculateDragAxis = useCallback8(() => {
4474
+ const calculateDragAxis = useCallback9(() => {
4908
4475
  if (ref.current) {
4909
4476
  const computedStyle = window.getComputedStyle(ref.current);
4910
4477
  if (computedStyle.display === "grid") {
@@ -4916,7 +4483,7 @@ var useDragAxis = (ref, collisionAxis) => {
4916
4483
  }
4917
4484
  }
4918
4485
  }, [ref.current]);
4919
- useEffect14(() => {
4486
+ useEffect15(() => {
4920
4487
  const onViewportChange = () => {
4921
4488
  calculateDragAxis();
4922
4489
  };
@@ -4925,7 +4492,7 @@ var useDragAxis = (ref, collisionAxis) => {
4925
4492
  window.removeEventListener("viewportchange", onViewportChange);
4926
4493
  };
4927
4494
  }, []);
4928
- useEffect14(calculateDragAxis, [status, collisionAxis]);
4495
+ useEffect15(calculateDragAxis, [status, collisionAxis]);
4929
4496
  return [dragAxis, calculateDragAxis];
4930
4497
  };
4931
4498
 
@@ -5015,17 +4582,16 @@ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx23(DropZoneEdit, __spreadVa
5015
4582
  var DropZoneChild = ({
5016
4583
  zoneCompound,
5017
4584
  componentId,
5018
- preview,
5019
4585
  index,
5020
- isEnabled,
5021
4586
  dragAxis,
5022
4587
  collisionAxis,
5023
4588
  inDroppableZone
5024
4589
  }) => {
5025
4590
  var _a, _b;
5026
4591
  const metadata = useAppStore((s) => s.metadata);
5027
- const ctx = useContext6(dropZoneContext);
4592
+ const ctx = useContext7(dropZoneContext);
5028
4593
  const { depth = 1 } = ctx != null ? ctx : {};
4594
+ const zoneStore = useContext7(ZoneStoreContext);
5029
4595
  const nodeProps = useAppStore(
5030
4596
  useShallow3((s) => {
5031
4597
  var _a2;
@@ -5044,17 +4610,32 @@ var DropZoneChild = ({
5044
4610
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
5045
4611
  })
5046
4612
  );
5047
- const node = { type: nodeType, props: nodeProps };
5048
- 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]);
5049
4627
  const componentConfig = useAppStore(
5050
4628
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
5051
4629
  );
5052
- const puckProps = {
5053
- renderDropZone: DropZoneEditPure,
5054
- isEditing: true,
5055
- dragRef: null,
5056
- metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5057
- };
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
+ );
5058
4639
  const overrides = useAppStore((s) => s.overrides);
5059
4640
  const isLoading = useAppStore(
5060
4641
  (s) => {
@@ -5070,7 +4651,7 @@ var DropZoneChild = ({
5070
4651
  );
5071
4652
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
5072
4653
  const renderPreview = useMemo9(
5073
- () => function Preview4() {
4654
+ () => function Preview3() {
5074
4655
  return /* @__PURE__ */ jsx23(DrawerItemInner, { name: label, children: overrides.componentItem });
5075
4656
  },
5076
4657
  [componentId, label, overrides]
@@ -5097,8 +4678,8 @@ var DropZoneChild = ({
5097
4678
  item.type
5098
4679
  ] });
5099
4680
  let componentType = item.type;
5100
- const isPreview = componentId === (preview == null ? void 0 : preview.props.id) && preview.type === "insert";
5101
- if (isPreview) {
4681
+ const isInserting = item.previewType === "insert";
4682
+ if (isInserting) {
5102
4683
  Render2 = renderPreview;
5103
4684
  }
5104
4685
  return /* @__PURE__ */ jsx23(
@@ -5112,11 +4693,10 @@ var DropZoneChild = ({
5112
4693
  isLoading,
5113
4694
  isSelected,
5114
4695
  label,
5115
- isEnabled,
5116
4696
  autoDragAxis: dragAxis,
5117
4697
  userDragAxis: collisionAxis,
5118
4698
  inDroppableZone,
5119
- 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(
5120
4700
  Render2,
5121
4701
  __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
5122
4702
  puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
@@ -5138,7 +4718,7 @@ var DropZoneEdit = forwardRef3(
5138
4718
  minEmptyHeight: userMinEmptyHeight = 128,
5139
4719
  collisionAxis
5140
4720
  }, userRef) {
5141
- const ctx = useContext6(dropZoneContext);
4721
+ const ctx = useContext7(dropZoneContext);
5142
4722
  const {
5143
4723
  // These all need setting via context
5144
4724
  areaId,
@@ -5159,20 +4739,10 @@ var DropZoneEdit = forwardRef3(
5159
4739
  }
5160
4740
  }
5161
4741
  const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
5162
- const {
5163
- isDeepestZone,
5164
- inNextDeepestArea,
5165
- draggedComponentType,
5166
- userIsDragging
5167
- } = useContextStore(ZoneStoreContext, (s) => {
5168
- var _a, _b;
5169
- return {
5170
- isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
5171
- inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
5172
- draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
5173
- userIsDragging: !!s.draggedItem
5174
- };
5175
- });
4742
+ const inNextDeepestArea = useContextStore(
4743
+ ZoneStoreContext,
4744
+ (s) => s.nextAreaDepthIndex[areaId || ""]
4745
+ );
5176
4746
  const zoneContentIds = useAppStore(
5177
4747
  useShallow3((s) => {
5178
4748
  var _a;
@@ -5185,7 +4755,7 @@ var DropZoneEdit = forwardRef3(
5185
4755
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
5186
4756
  })
5187
4757
  );
5188
- useEffect15(() => {
4758
+ useEffect16(() => {
5189
4759
  if (!zoneType || zoneType === "dropzone") {
5190
4760
  if (ctx == null ? void 0 : ctx.registerZone) {
5191
4761
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
@@ -5197,7 +4767,7 @@ var DropZoneEdit = forwardRef3(
5197
4767
  };
5198
4768
  }
5199
4769
  }, [zoneType]);
5200
- useEffect15(() => {
4770
+ useEffect16(() => {
5201
4771
  if (zoneType === "dropzone") {
5202
4772
  if (zoneCompound !== rootDroppableId) {
5203
4773
  console.warn(
@@ -5209,8 +4779,8 @@ var DropZoneEdit = forwardRef3(
5209
4779
  const contentIds = useMemo9(() => {
5210
4780
  return zoneContentIds || [];
5211
4781
  }, [zoneContentIds]);
5212
- const ref = useRef3(null);
5213
- const acceptsTarget = useCallback9(
4782
+ const ref = useRef4(null);
4783
+ const acceptsTarget = useCallback10(
5214
4784
  (componentType) => {
5215
4785
  if (!componentType) {
5216
4786
  return true;
@@ -5232,29 +4802,44 @@ var DropZoneEdit = forwardRef3(
5232
4802
  },
5233
4803
  [allow, disallow]
5234
4804
  );
5235
- 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(() => {
5236
4822
  if (registerLocalZone) {
5237
- registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
4823
+ registerLocalZone(zoneCompound, isEnabled);
5238
4824
  }
5239
4825
  return () => {
5240
4826
  if (unregisterLocalZone) {
5241
4827
  unregisterLocalZone(zoneCompound);
5242
4828
  }
5243
4829
  };
5244
- }, [draggedComponentType, zoneCompound]);
5245
- const hoveringOverArea = inNextDeepestArea || isRootZone;
5246
- let isEnabled = true;
5247
- if (userIsDragging) {
5248
- isEnabled = isDeepestZone;
5249
- }
5250
- if (isEnabled) {
5251
- isEnabled = acceptsTarget(draggedComponentType);
5252
- }
4830
+ }, [isEnabled, zoneCompound]);
5253
4831
  const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
5254
4832
  contentIds,
5255
4833
  zoneCompound
5256
4834
  );
5257
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]);
5258
4843
  const droppableConfig = {
5259
4844
  id: zoneCompound,
5260
4845
  collisionPriority: isEnabled ? depth : 0,
@@ -5264,11 +4849,11 @@ var DropZoneEdit = forwardRef3(
5264
4849
  data: {
5265
4850
  areaId,
5266
4851
  depth,
5267
- isDroppableTarget: acceptsTarget(draggedComponentType),
4852
+ isDroppableTarget: targetAccepted,
5268
4853
  path: path || []
5269
4854
  }
5270
4855
  };
5271
- const { ref: dropRef } = useDroppableSafe(droppableConfig);
4856
+ const { ref: dropRef } = useDroppable(droppableConfig);
5272
4857
  const isAreaSelected = useAppStore(
5273
4858
  (s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
5274
4859
  );
@@ -5283,7 +4868,6 @@ var DropZoneEdit = forwardRef3(
5283
4868
  {
5284
4869
  className: `${getClassName17({
5285
4870
  isRootZone,
5286
- userIsDragging,
5287
4871
  hoveringOverArea,
5288
4872
  isEnabled,
5289
4873
  isAreaSelected,
@@ -5305,12 +4889,10 @@ var DropZoneEdit = forwardRef3(
5305
4889
  {
5306
4890
  zoneCompound,
5307
4891
  componentId,
5308
- preview,
5309
4892
  dragAxis,
5310
- isEnabled,
5311
4893
  index: i,
5312
4894
  collisionAxis,
5313
- inDroppableZone: acceptsTarget(draggedComponentType)
4895
+ inDroppableZone: targetAccepted
5314
4896
  },
5315
4897
  componentId
5316
4898
  );
@@ -5346,12 +4928,12 @@ var DropZoneRenderItem = ({
5346
4928
  var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx23(DropZoneRender, __spreadValues({}, props));
5347
4929
  var DropZoneRender = forwardRef3(
5348
4930
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5349
- const ctx = useContext6(dropZoneContext);
4931
+ const ctx = useContext7(dropZoneContext);
5350
4932
  const { areaId = "root" } = ctx || {};
5351
- const { config, data, metadata } = useContext6(renderContext);
4933
+ const { config, data, metadata } = useContext7(renderContext);
5352
4934
  let zoneCompound = rootDroppableId;
5353
4935
  let content = (data == null ? void 0 : data.content) || [];
5354
- useEffect15(() => {
4936
+ useEffect16(() => {
5355
4937
  if (!content) {
5356
4938
  if (ctx == null ? void 0 : ctx.registerZone) {
5357
4939
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
@@ -5390,7 +4972,7 @@ var DropZoneRender = forwardRef3(
5390
4972
  var DropZonePure = (props) => /* @__PURE__ */ jsx23(DropZone, __spreadValues({}, props));
5391
4973
  var DropZone = forwardRef3(
5392
4974
  function DropZone2(props, ref) {
5393
- const ctx = useContext6(dropZoneContext);
4975
+ const ctx = useContext7(dropZoneContext);
5394
4976
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5395
4977
  return /* @__PURE__ */ jsx23(Fragment6, { children: /* @__PURE__ */ jsx23(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5396
4978
  }
@@ -5401,7 +4983,6 @@ var DropZone = forwardRef3(
5401
4983
  // lib/dnd/NestedDroppablePlugin.ts
5402
4984
  init_react_import();
5403
4985
  import { Plugin } from "@dnd-kit/abstract";
5404
- import { effects } from "@dnd-kit/state";
5405
4986
 
5406
4987
  // lib/throttle.ts
5407
4988
  init_react_import();
@@ -5515,7 +5096,7 @@ var depthSort = (candidates) => {
5515
5096
  return 0;
5516
5097
  });
5517
5098
  };
5518
- var getZoneId2 = (candidate) => {
5099
+ var getZoneId = (candidate) => {
5519
5100
  let id = candidate == null ? void 0 : candidate.id;
5520
5101
  if (!candidate) return null;
5521
5102
  if (candidate.type === "component") {
@@ -5555,7 +5136,8 @@ var getPointerCollisions = (position, manager) => {
5555
5136
  const element = elements[i];
5556
5137
  const dropzoneId = element.getAttribute("data-puck-dropzone");
5557
5138
  const id = element.getAttribute("data-puck-dnd");
5558
- if (BUFFER && (dropzoneId || id)) {
5139
+ const isVoid = element.hasAttribute("data-puck-dnd-void");
5140
+ if (BUFFER && (dropzoneId || id) && !isVoid) {
5559
5141
  const box = element.getBoundingClientRect();
5560
5142
  const contractedBox = {
5561
5143
  left: box.left + BUFFER,
@@ -5621,7 +5203,7 @@ var findDeepestCandidate = (position, manager) => {
5621
5203
  return true;
5622
5204
  });
5623
5205
  filteredCandidates.reverse();
5624
- const zone = getZoneId2(filteredCandidates[0]);
5206
+ const zone = getZoneId(filteredCandidates[0]);
5625
5207
  const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
5626
5208
  return { zone, area };
5627
5209
  }
@@ -5636,7 +5218,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
5636
5218
  if (typeof window === "undefined") {
5637
5219
  return;
5638
5220
  }
5639
- const cleanupEffect = effects(() => {
5221
+ this.registerEffect(() => {
5640
5222
  const handleMove = (event) => {
5641
5223
  const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
5642
5224
  const position = new GlobalPosition(target, {
@@ -5660,12 +5242,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
5660
5242
  capture: true
5661
5243
  // dndkit's PointerSensor prevents propagation during drag
5662
5244
  });
5663
- this.destroy = () => {
5245
+ const cleanup = () => {
5664
5246
  document.body.removeEventListener("pointermove", handlePointerMove, {
5665
5247
  capture: true
5666
5248
  });
5667
- cleanupEffect();
5668
5249
  };
5250
+ return cleanup;
5669
5251
  });
5670
5252
  }
5671
5253
  };
@@ -5725,14 +5307,15 @@ function getDeepDir(el) {
5725
5307
  }
5726
5308
 
5727
5309
  // components/DragDropContext/index.tsx
5310
+ import { effect } from "@dnd-kit/state";
5728
5311
  import { jsx as jsx24 } from "react/jsx-runtime";
5729
5312
  var DEBUG3 = false;
5730
5313
  var dragListenerContext = createContext4({
5731
5314
  dragListeners: {}
5732
5315
  });
5733
5316
  function useDragListener(type, fn, deps = []) {
5734
- const { setDragListeners } = useContext7(dragListenerContext);
5735
- useEffect16(() => {
5317
+ const { setDragListeners } = useContext8(dragListenerContext);
5318
+ useEffect17(() => {
5736
5319
  if (setDragListeners) {
5737
5320
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
5738
5321
  [type]: [...old[type] || [], fn]
@@ -5742,8 +5325,8 @@ function useDragListener(type, fn, deps = []) {
5742
5325
  }
5743
5326
  var AREA_CHANGE_DEBOUNCE_MS = 100;
5744
5327
  var useTempDisableFallback = (timeout3) => {
5745
- const lastFallbackDisable = useRef4(null);
5746
- return useCallback10((manager) => {
5328
+ const lastFallbackDisable = useRef5(null);
5329
+ return useCallback11((manager) => {
5747
5330
  collisionStore.setState({ fallbackEnabled: false });
5748
5331
  const fallbackId = generateId();
5749
5332
  lastFallbackDisable.current = fallbackId;
@@ -5762,7 +5345,7 @@ var DragDropContextClient = ({
5762
5345
  const dispatch = useAppStore((s) => s.dispatch);
5763
5346
  const appStore = useAppStoreApi();
5764
5347
  const id = useSafeId();
5765
- const debouncedParamsRef = useRef4(null);
5348
+ const debouncedParamsRef = useRef5(null);
5766
5349
  const tempDisableFallback = useTempDisableFallback(100);
5767
5350
  const [zoneStore] = useState14(
5768
5351
  () => createStore3(() => ({
@@ -5771,10 +5354,12 @@ var DragDropContextClient = ({
5771
5354
  areaDepthIndex: {},
5772
5355
  nextAreaDepthIndex: {},
5773
5356
  draggedItem: null,
5774
- previewIndex: {}
5357
+ previewIndex: {},
5358
+ enabledIndex: {},
5359
+ hoveringComponent: null
5775
5360
  }))
5776
5361
  );
5777
- const getChanged2 = useCallback10(
5362
+ const getChanged2 = useCallback11(
5778
5363
  (params, id2) => {
5779
5364
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
5780
5365
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -5795,7 +5380,7 @@ var DragDropContextClient = ({
5795
5380
  },
5796
5381
  [zoneStore]
5797
5382
  );
5798
- const setDeepestAndCollide = useCallback10(
5383
+ const setDeepestAndCollide = useCallback11(
5799
5384
  (params, manager) => {
5800
5385
  const { zoneChanged, areaChanged } = getChanged2(params, id);
5801
5386
  if (!zoneChanged && !areaChanged) return;
@@ -5819,7 +5404,7 @@ var DragDropContextClient = ({
5819
5404
  setDeepestDb.cancel();
5820
5405
  debouncedParamsRef.current = null;
5821
5406
  };
5822
- useEffect16(() => {
5407
+ useEffect17(() => {
5823
5408
  if (DEBUG3) {
5824
5409
  zoneStore.subscribe(
5825
5410
  (s) => {
@@ -5882,8 +5467,8 @@ var DragDropContextClient = ({
5882
5467
  ]);
5883
5468
  const sensors = useSensors();
5884
5469
  const [dragListeners, setDragListeners] = useState14({});
5885
- const dragMode = useRef4(null);
5886
- const initialSelector = useRef4(void 0);
5470
+ const dragMode = useRef5(null);
5471
+ const initialSelector = useRef5(void 0);
5887
5472
  const nextContextValue = useMemo10(
5888
5473
  () => ({
5889
5474
  mode: "edit",
@@ -5905,7 +5490,9 @@ var DragDropContextClient = ({
5905
5490
  plugins,
5906
5491
  sensors,
5907
5492
  onDragEnd: (event, manager) => {
5908
- 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");
5909
5496
  const { source, target } = event.operation;
5910
5497
  if (!source) {
5911
5498
  zoneStore.setState({ draggedItem: null });
@@ -5913,9 +5500,9 @@ var DragDropContextClient = ({
5913
5500
  }
5914
5501
  const { zone, index } = source.data;
5915
5502
  const { previewIndex = {} } = zoneStore.getState() || {};
5916
- const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
5917
- setTimeout(() => {
5918
- 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;
5919
5506
  zoneStore.setState({ draggedItem: null });
5920
5507
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
5921
5508
  zoneStore.setState({ previewIndex: {} });
@@ -5951,23 +5538,28 @@ var DragDropContextClient = ({
5951
5538
  });
5952
5539
  }
5953
5540
  }
5954
- setTimeout(() => {
5955
- dispatch({
5956
- type: "setUi",
5957
- ui: {
5958
- itemSelector: { index, zone },
5959
- isDragging: false
5960
- },
5961
- recordHistory: true
5962
- });
5963
- }, 50);
5964
- (_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) => {
5965
5550
  fn(event, manager);
5966
5551
  });
5967
- }, 250);
5552
+ };
5553
+ let dispose;
5554
+ dispose = effect(() => {
5555
+ if (source.status === "idle") {
5556
+ onAnimationEnd();
5557
+ dispose == null ? void 0 : dispose();
5558
+ }
5559
+ });
5968
5560
  },
5969
5561
  onDragOver: (event, manager) => {
5970
- var _a, _b, _c, _d, _e;
5562
+ var _a, _b, _c, _d;
5971
5563
  event.preventDefault();
5972
5564
  const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
5973
5565
  if (!draggedItem) return;
@@ -5985,7 +5577,7 @@ var DragDropContextClient = ({
5985
5577
  const targetData = target.data;
5986
5578
  targetZone = targetData.zone;
5987
5579
  targetIndex = targetData.index;
5988
- 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;
5989
5581
  const dir = getDeepDir(target.element);
5990
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";
5991
5583
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
@@ -5998,7 +5590,7 @@ var DragDropContextClient = ({
5998
5590
  targetZone = target.id.toString();
5999
5591
  targetIndex = 0;
6000
5592
  }
6001
- 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) || [];
6002
5594
  if (targetId === sourceId || path.find((path2) => {
6003
5595
  const [pathId] = path2.split(":");
6004
5596
  return pathId === sourceId;
@@ -6044,16 +5636,12 @@ var DragDropContextClient = ({
6044
5636
  });
6045
5637
  }
6046
5638
  }
6047
- (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
5639
+ (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
6048
5640
  fn(event, manager);
6049
5641
  });
6050
5642
  },
6051
5643
  onDragStart: (event, manager) => {
6052
5644
  var _a;
6053
- dispatch({
6054
- type: "setUi",
6055
- ui: { itemSelector: null, isDragging: true }
6056
- });
6057
5645
  const { source } = event.operation;
6058
5646
  if (source && source.type !== "void") {
6059
5647
  const sourceData = source.data;
@@ -6083,11 +5671,31 @@ var DragDropContextClient = ({
6083
5671
  });
6084
5672
  },
6085
5673
  onBeforeDragStart: (event) => {
6086
- var _a;
6087
- 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";
6088
5676
  dragMode.current = isNewComponent ? "new" : "existing";
6089
5677
  initialSelector.current = void 0;
6090
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");
6091
5699
  },
6092
5700
  children: /* @__PURE__ */ jsx24(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx24(DropZoneProvider, { value: nextContextValue, children }) })
6093
5701
  }
@@ -6107,6 +5715,7 @@ var DragDropContext = ({
6107
5715
  };
6108
5716
 
6109
5717
  // components/Drawer/index.tsx
5718
+ import { useDraggable, useDroppable as useDroppable2 } from "@dnd-kit/react";
6110
5719
  import { jsx as jsx25, jsxs as jsxs11 } from "react/jsx-runtime";
6111
5720
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
6112
5721
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
@@ -6143,10 +5752,11 @@ var DrawerItemDraggable = ({
6143
5752
  id,
6144
5753
  isDragDisabled
6145
5754
  }) => {
6146
- const { ref } = useDraggableSafe({
5755
+ const { ref } = useDraggable({
6147
5756
  id,
6148
- data: { type: "drawer", componentType: name },
6149
- disabled: isDragDisabled
5757
+ data: { componentType: name },
5758
+ disabled: isDragDisabled,
5759
+ type: "drawer"
6150
5760
  });
6151
5761
  return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
6152
5762
  /* @__PURE__ */ jsx25("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx25(DrawerItemInner, { name, label, children }) }),
@@ -6211,7 +5821,7 @@ var Drawer = ({
6211
5821
  );
6212
5822
  }
6213
5823
  const id = useSafeId();
6214
- const { ref } = useDroppableSafe({
5824
+ const { ref } = useDroppable2({
6215
5825
  id,
6216
5826
  type: "void",
6217
5827
  collisionPriority: 0
@@ -6224,6 +5834,7 @@ var Drawer = ({
6224
5834
  ref,
6225
5835
  "data-puck-dnd": id,
6226
5836
  "data-puck-drawer": true,
5837
+ "data-puck-dnd-void": true,
6227
5838
  children
6228
5839
  }
6229
5840
  );
@@ -6234,12 +5845,12 @@ Drawer.Item = DrawerItem;
6234
5845
  init_react_import();
6235
5846
  import {
6236
5847
  createContext as createContext7,
6237
- useCallback as useCallback16,
6238
- useContext as useContext11,
6239
- useEffect as useEffect24,
6240
- useMemo as useMemo20,
6241
- useRef as useRef7,
6242
- 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
6243
5854
  } from "react";
6244
5855
 
6245
5856
  // components/SidebarSection/index.tsx
@@ -6335,70 +5946,26 @@ var SidebarSection = ({
6335
5946
  );
6336
5947
  };
6337
5948
 
6338
- // components/MenuBar/index.tsx
6339
- init_react_import();
6340
-
6341
- // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
6342
- init_react_import();
6343
- 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" };
6344
-
6345
- // components/MenuBar/index.tsx
6346
- import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
6347
- var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
6348
- function MenuBar({
6349
- menuOpen = false,
6350
- renderHeaderActions,
6351
- setMenuOpen
6352
- }) {
6353
- const back = useAppStore((s) => s.history.back);
6354
- const forward = useAppStore((s) => s.history.forward);
6355
- const hasFuture = useAppStore((s) => s.history.hasFuture());
6356
- const hasPast = useAppStore((s) => s.history.hasPast());
6357
- return /* @__PURE__ */ jsx27(
6358
- "div",
6359
- {
6360
- className: getClassName20({ menuOpen }),
6361
- onClick: (event) => {
6362
- var _a;
6363
- const element = event.target;
6364
- if (window.matchMedia("(min-width: 638px)").matches) {
6365
- return;
6366
- }
6367
- if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
6368
- setMenuOpen(false);
6369
- }
6370
- },
6371
- children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
6372
- /* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
6373
- /* @__PURE__ */ jsx27(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx27(Undo2, { size: 21 }) }),
6374
- /* @__PURE__ */ jsx27(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx27(Redo2, { size: 21 }) })
6375
- ] }),
6376
- /* @__PURE__ */ jsx27(Fragment7, { children: renderHeaderActions && renderHeaderActions() })
6377
- ] })
6378
- }
6379
- );
6380
- }
6381
-
6382
5949
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6383
5950
  init_react_import();
6384
- 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" };
6385
5952
 
6386
5953
  // components/Puck/components/Fields/index.tsx
6387
5954
  init_react_import();
6388
5955
 
6389
5956
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
6390
5957
  init_react_import();
6391
- 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" };
6392
5959
 
6393
5960
  // components/Puck/components/Fields/index.tsx
6394
- import { useCallback as useCallback11, useMemo as useMemo13 } from "react";
5961
+ import { memo as memo2, useCallback as useCallback12, useMemo as useMemo13 } from "react";
6395
5962
  import { useShallow as useShallow4 } from "zustand/react/shallow";
6396
- import { Fragment as Fragment8, jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
6397
- 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);
6398
5965
  var DefaultFields = ({
6399
5966
  children
6400
5967
  }) => {
6401
- return /* @__PURE__ */ jsx28(Fragment8, { children });
5968
+ return /* @__PURE__ */ jsx27(Fragment7, { children });
6402
5969
  };
6403
5970
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6404
5971
  let currentProps;
@@ -6464,12 +6031,12 @@ var FieldsChild = ({ fieldName }) => {
6464
6031
  })
6465
6032
  );
6466
6033
  const appStore = useAppStoreApi();
6467
- const onChange = useCallback11(createOnChange(fieldName, appStore), [
6034
+ const onChange = useCallback12(createOnChange(fieldName, appStore), [
6468
6035
  fieldName
6469
6036
  ]);
6470
6037
  if (!field || !id) return null;
6471
6038
  if (field.type === "slot") return null;
6472
- return /* @__PURE__ */ jsx28("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx28(
6039
+ return /* @__PURE__ */ jsx27("div", { className: getClassName20("field"), children: /* @__PURE__ */ jsx27(
6473
6040
  AutoFieldPrivate,
6474
6041
  {
6475
6042
  field,
@@ -6481,7 +6048,8 @@ var FieldsChild = ({ fieldName }) => {
6481
6048
  }
6482
6049
  ) }, id);
6483
6050
  };
6484
- var Fields = ({ wrapFields = true }) => {
6051
+ var FieldsChildMemo = memo2(FieldsChild);
6052
+ var FieldsInternal = ({ wrapFields = true }) => {
6485
6053
  const overrides = useAppStore((s) => s.overrides);
6486
6054
  const componentResolving = useAppStore((s) => {
6487
6055
  var _a, _b;
@@ -6506,38 +6074,39 @@ var Fields = ({ wrapFields = true }) => {
6506
6074
  );
6507
6075
  const isLoading = fieldsLoading || componentResolving;
6508
6076
  const Wrapper = useMemo13(() => overrides.fields || DefaultFields, [overrides]);
6509
- return /* @__PURE__ */ jsxs14(
6077
+ return /* @__PURE__ */ jsxs13(
6510
6078
  "form",
6511
6079
  {
6512
- className: getClassName21({ wrapFields }),
6080
+ className: getClassName20({ wrapFields }),
6513
6081
  onSubmit: (e) => {
6514
6082
  e.preventDefault();
6515
6083
  },
6516
6084
  children: [
6517
- /* @__PURE__ */ jsx28(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx28(FieldsChild, { fieldName }, fieldName)) }),
6518
- 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 }) }) })
6519
6087
  ]
6520
6088
  }
6521
6089
  );
6522
6090
  };
6091
+ var Fields = memo2(FieldsInternal);
6523
6092
 
6524
6093
  // components/Puck/components/Components/index.tsx
6525
6094
  init_react_import();
6526
6095
 
6527
6096
  // lib/use-component-list.tsx
6528
6097
  init_react_import();
6529
- import { useEffect as useEffect17, useState as useState16 } from "react";
6098
+ import { useEffect as useEffect18, useState as useState16 } from "react";
6530
6099
 
6531
6100
  // components/ComponentList/index.tsx
6532
6101
  init_react_import();
6533
6102
 
6534
6103
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6535
6104
  init_react_import();
6536
- 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" };
6537
6106
 
6538
6107
  // components/ComponentList/index.tsx
6539
- import { jsx as jsx29, jsxs as jsxs15 } from "react/jsx-runtime";
6540
- 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);
6541
6110
  var ComponentListItem = ({
6542
6111
  name,
6543
6112
  label
@@ -6548,7 +6117,7 @@ var ComponentListItem = ({
6548
6117
  type: name
6549
6118
  }).insert
6550
6119
  );
6551
- 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 });
6552
6121
  };
6553
6122
  var ComponentList = ({
6554
6123
  children,
@@ -6559,12 +6128,12 @@ var ComponentList = ({
6559
6128
  const setUi = useAppStore((s) => s.setUi);
6560
6129
  const componentList = useAppStore((s) => s.state.ui.componentList);
6561
6130
  const { expanded = true } = componentList[id] || {};
6562
- return /* @__PURE__ */ jsxs15("div", { className: getClassName22({ isExpanded: expanded }), children: [
6563
- title && /* @__PURE__ */ jsxs15(
6131
+ return /* @__PURE__ */ jsxs14("div", { className: getClassName21({ isExpanded: expanded }), children: [
6132
+ title && /* @__PURE__ */ jsxs14(
6564
6133
  "button",
6565
6134
  {
6566
6135
  type: "button",
6567
- className: getClassName22("title"),
6136
+ className: getClassName21("title"),
6568
6137
  onClick: () => setUi({
6569
6138
  componentList: __spreadProps(__spreadValues({}, componentList), {
6570
6139
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6574,14 +6143,14 @@ var ComponentList = ({
6574
6143
  }),
6575
6144
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6576
6145
  children: [
6577
- /* @__PURE__ */ jsx29("div", { children: title }),
6578
- /* @__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 }) })
6579
6148
  ]
6580
6149
  }
6581
6150
  ),
6582
- /* @__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) => {
6583
6152
  var _a;
6584
- return /* @__PURE__ */ jsx29(
6153
+ return /* @__PURE__ */ jsx28(
6585
6154
  ComponentListItem,
6586
6155
  {
6587
6156
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6595,12 +6164,12 @@ var ComponentList = ({
6595
6164
  ComponentList.Item = ComponentListItem;
6596
6165
 
6597
6166
  // lib/use-component-list.tsx
6598
- import { jsx as jsx30 } from "react/jsx-runtime";
6167
+ import { jsx as jsx29 } from "react/jsx-runtime";
6599
6168
  var useComponentList = () => {
6600
6169
  const [componentList, setComponentList] = useState16();
6601
6170
  const config = useAppStore((s) => s.config);
6602
6171
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6603
- useEffect17(() => {
6172
+ useEffect18(() => {
6604
6173
  var _a, _b, _c;
6605
6174
  if (Object.keys(uiComponentList).length > 0) {
6606
6175
  const matchedComponents = [];
@@ -6610,7 +6179,7 @@ var useComponentList = () => {
6610
6179
  if (category.visible === false || !category.components) {
6611
6180
  return null;
6612
6181
  }
6613
- return /* @__PURE__ */ jsx30(
6182
+ return /* @__PURE__ */ jsx29(
6614
6183
  ComponentList,
6615
6184
  {
6616
6185
  id: categoryKey,
@@ -6619,7 +6188,7 @@ var useComponentList = () => {
6619
6188
  var _a2;
6620
6189
  matchedComponents.push(componentName);
6621
6190
  const componentConf = config.components[componentName] || {};
6622
- return /* @__PURE__ */ jsx30(
6191
+ return /* @__PURE__ */ jsx29(
6623
6192
  ComponentList.Item,
6624
6193
  {
6625
6194
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6639,7 +6208,7 @@ var useComponentList = () => {
6639
6208
  );
6640
6209
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6641
6210
  _componentList.push(
6642
- /* @__PURE__ */ jsx30(
6211
+ /* @__PURE__ */ jsx29(
6643
6212
  ComponentList,
6644
6213
  {
6645
6214
  id: "other",
@@ -6647,7 +6216,7 @@ var useComponentList = () => {
6647
6216
  children: remainingComponents.map((componentName, i) => {
6648
6217
  var _a2;
6649
6218
  const componentConf = config.components[componentName] || {};
6650
- return /* @__PURE__ */ jsx30(
6219
+ return /* @__PURE__ */ jsx29(
6651
6220
  ComponentList.Item,
6652
6221
  {
6653
6222
  name: componentName,
@@ -6670,29 +6239,29 @@ var useComponentList = () => {
6670
6239
 
6671
6240
  // components/Puck/components/Components/index.tsx
6672
6241
  import { useMemo as useMemo14 } from "react";
6673
- import { jsx as jsx31 } from "react/jsx-runtime";
6242
+ import { jsx as jsx30 } from "react/jsx-runtime";
6674
6243
  var Components = () => {
6675
6244
  const overrides = useAppStore((s) => s.overrides);
6676
6245
  const componentList = useComponentList();
6677
6246
  const Wrapper = useMemo14(() => overrides.components || "div", [overrides]);
6678
- 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" }) });
6679
6248
  };
6680
6249
 
6681
6250
  // components/Puck/components/Preview/index.tsx
6682
6251
  init_react_import();
6683
- 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";
6684
6253
 
6685
6254
  // components/AutoFrame/index.tsx
6686
6255
  init_react_import();
6687
6256
  import {
6688
6257
  createContext as createContext5,
6689
- useContext as useContext8,
6690
- useEffect as useEffect18,
6258
+ useContext as useContext9,
6259
+ useEffect as useEffect19,
6691
6260
  useState as useState17
6692
6261
  } from "react";
6693
6262
  import hash from "object-hash";
6694
6263
  import { createPortal as createPortal3 } from "react-dom";
6695
- import { Fragment as Fragment9, jsx as jsx32 } from "react/jsx-runtime";
6264
+ import { Fragment as Fragment8, jsx as jsx31 } from "react/jsx-runtime";
6696
6265
  var styleSelector = 'style, link[rel="stylesheet"]';
6697
6266
  var collectStyles = (doc) => {
6698
6267
  const collected = [];
@@ -6735,7 +6304,7 @@ var CopyHostStyles = ({
6735
6304
  onStylesLoaded = () => null
6736
6305
  }) => {
6737
6306
  const { document: doc, window: win } = useFrame();
6738
- useEffect18(() => {
6307
+ useEffect19(() => {
6739
6308
  if (!win || !doc) {
6740
6309
  return () => {
6741
6310
  };
@@ -6892,10 +6461,10 @@ var CopyHostStyles = ({
6892
6461
  observer.disconnect();
6893
6462
  };
6894
6463
  }, []);
6895
- return /* @__PURE__ */ jsx32(Fragment9, { children });
6464
+ return /* @__PURE__ */ jsx31(Fragment8, { children });
6896
6465
  };
6897
6466
  var autoFrameContext = createContext5({});
6898
- var useFrame = () => useContext8(autoFrameContext);
6467
+ var useFrame = () => useContext9(autoFrameContext);
6899
6468
  function AutoFrame(_a) {
6900
6469
  var _b = _a, {
6901
6470
  children,
@@ -6920,7 +6489,7 @@ function AutoFrame(_a) {
6920
6489
  const [ctx, setCtx] = useState17({});
6921
6490
  const [mountTarget, setMountTarget] = useState17();
6922
6491
  const [stylesLoaded, setStylesLoaded] = useState17(false);
6923
- useEffect18(() => {
6492
+ useEffect19(() => {
6924
6493
  var _a2;
6925
6494
  if (frameRef.current) {
6926
6495
  const doc = frameRef.current.contentDocument;
@@ -6939,7 +6508,7 @@ function AutoFrame(_a) {
6939
6508
  }
6940
6509
  }
6941
6510
  }, [frameRef, loaded, stylesLoaded]);
6942
- return /* @__PURE__ */ jsx32(
6511
+ return /* @__PURE__ */ jsx31(
6943
6512
  "iframe",
6944
6513
  __spreadProps(__spreadValues({}, props), {
6945
6514
  className,
@@ -6949,7 +6518,7 @@ function AutoFrame(_a) {
6949
6518
  onLoad: () => {
6950
6519
  setLoaded(true);
6951
6520
  },
6952
- 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(
6953
6522
  CopyHostStyles,
6954
6523
  {
6955
6524
  debug,
@@ -6965,14 +6534,14 @@ var AutoFrame_default = AutoFrame;
6965
6534
 
6966
6535
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
6967
6536
  init_react_import();
6968
- 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" };
6969
6538
 
6970
6539
  // components/Puck/components/Preview/index.tsx
6971
- import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
6972
- 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);
6973
6542
  var useBubbleIframeEvents = (ref) => {
6974
6543
  const status = useAppStore((s) => s.status);
6975
- useEffect19(() => {
6544
+ useEffect20(() => {
6976
6545
  if (ref.current && status === "READY") {
6977
6546
  const iframe = ref.current;
6978
6547
  const handlePointerMove = (event) => {
@@ -7010,7 +6579,7 @@ var useBubbleIframeEvents = (ref) => {
7010
6579
  }
7011
6580
  }, [status]);
7012
6581
  };
7013
- var Preview3 = ({ id = "puck-preview" }) => {
6582
+ var Preview2 = ({ id = "puck-preview" }) => {
7014
6583
  const dispatch = useAppStore((s) => s.dispatch);
7015
6584
  const root = useAppStore((s) => s.state.data.root);
7016
6585
  const config = useAppStore((s) => s.config);
@@ -7021,22 +6590,22 @@ var Preview3 = ({ id = "puck-preview" }) => {
7021
6590
  const renderData = useAppStore(
7022
6591
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
7023
6592
  );
7024
- const Page = useCallback12(
6593
+ const Page = useCallback13(
7025
6594
  (pageProps) => {
7026
6595
  var _a, _b;
7027
6596
  const rootConfig = config.root;
7028
6597
  const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
7029
6598
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
7030
6599
  id: "puck-root"
7031
- }, propsWithSlots)) : /* @__PURE__ */ jsx33(Fragment10, { children: propsWithSlots.children });
6600
+ }, propsWithSlots)) : /* @__PURE__ */ jsx32(Fragment9, { children: propsWithSlots.children });
7032
6601
  },
7033
6602
  [config.root]
7034
6603
  );
7035
6604
  const Frame = useMemo15(() => overrides.iframe, [overrides]);
7036
6605
  const rootProps = root.props || root;
7037
- const ref = useRef5(null);
6606
+ const ref = useRef6(null);
7038
6607
  useBubbleIframeEvents(ref);
7039
- const inner = !renderData ? /* @__PURE__ */ jsx33(
6608
+ const inner = !renderData ? /* @__PURE__ */ jsx32(
7040
6609
  Page,
7041
6610
  __spreadProps(__spreadValues({}, rootProps), {
7042
6611
  puck: {
@@ -7046,28 +6615,28 @@ var Preview3 = ({ id = "puck-preview" }) => {
7046
6615
  metadata
7047
6616
  },
7048
6617
  editMode: true,
7049
- children: /* @__PURE__ */ jsx33(DropZonePure, { zone: rootDroppableId })
6618
+ children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
7050
6619
  })
7051
- ) : /* @__PURE__ */ jsx33(Render, { data: renderData, config });
7052
- useEffect19(() => {
6620
+ ) : /* @__PURE__ */ jsx32(Render, { data: renderData, config });
6621
+ useEffect20(() => {
7053
6622
  if (!iframe.enabled) {
7054
6623
  setStatus("READY");
7055
6624
  }
7056
6625
  }, [iframe.enabled]);
7057
- return /* @__PURE__ */ jsx33(
6626
+ return /* @__PURE__ */ jsx32(
7058
6627
  "div",
7059
6628
  {
7060
- className: getClassName23(),
6629
+ className: getClassName22(),
7061
6630
  id,
7062
6631
  "data-puck-preview": true,
7063
6632
  onClick: () => {
7064
6633
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7065
6634
  },
7066
- children: iframe.enabled ? /* @__PURE__ */ jsx33(
6635
+ children: iframe.enabled ? /* @__PURE__ */ jsx32(
7067
6636
  AutoFrame_default,
7068
6637
  {
7069
6638
  id: "preview-frame",
7070
- className: getClassName23("frame"),
6639
+ className: getClassName22("frame"),
7071
6640
  "data-rfd-iframe": true,
7072
6641
  onReady: () => {
7073
6642
  setStatus("READY");
@@ -7076,18 +6645,18 @@ var Preview3 = ({ id = "puck-preview" }) => {
7076
6645
  setStatus("MOUNTED");
7077
6646
  },
7078
6647
  frameRef: ref,
7079
- children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6648
+ children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7080
6649
  if (Frame) {
7081
- return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
6650
+ return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
7082
6651
  }
7083
6652
  return inner;
7084
6653
  } })
7085
6654
  }
7086
- ) : /* @__PURE__ */ jsx33(
6655
+ ) : /* @__PURE__ */ jsx32(
7087
6656
  "div",
7088
6657
  {
7089
6658
  id: "preview-frame",
7090
- className: getClassName23("frame"),
6659
+ className: getClassName22("frame"),
7091
6660
  ref,
7092
6661
  "data-puck-entry": true,
7093
6662
  children: inner
@@ -7105,7 +6674,7 @@ init_react_import();
7105
6674
 
7106
6675
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
7107
6676
  init_react_import();
7108
- 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" };
7109
6678
 
7110
6679
  // lib/scroll-into-view.ts
7111
6680
  init_react_import();
@@ -7119,7 +6688,7 @@ var scrollIntoView = (el) => {
7119
6688
  };
7120
6689
 
7121
6690
  // components/LayerTree/index.tsx
7122
- import { useCallback as useCallback13, useContext as useContext9 } from "react";
6691
+ import { useCallback as useCallback14, useContext as useContext10 } from "react";
7123
6692
 
7124
6693
  // lib/on-scroll-end.ts
7125
6694
  init_react_import();
@@ -7142,20 +6711,20 @@ var onScrollEnd = (frame, cb) => {
7142
6711
 
7143
6712
  // components/LayerTree/index.tsx
7144
6713
  import { useShallow as useShallow5 } from "zustand/react/shallow";
7145
- import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
7146
- var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
7147
- 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);
7148
6717
  var Layer = ({
7149
6718
  index,
7150
6719
  itemId,
7151
6720
  zoneCompound
7152
6721
  }) => {
7153
6722
  var _a;
7154
- const ctx = useContext9(dropZoneContext);
6723
+ const ctx = useContext10(dropZoneContext);
7155
6724
  const config = useAppStore((s) => s.config);
7156
6725
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
7157
6726
  const dispatch = useAppStore((s) => s.dispatch);
7158
- const setItemSelector = useCallback13(
6727
+ const setItemSelector = useCallback14(
7159
6728
  (itemSelector2) => {
7160
6729
  dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
7161
6730
  },
@@ -7175,9 +6744,11 @@ var Layer = ({
7175
6744
  )
7176
6745
  );
7177
6746
  const containsZone = zonesForItem.length > 0;
7178
- const { setHoveringComponent = () => {
7179
- }, hoveringComponent } = ctx || {};
7180
- const isHovering = hoveringComponent === itemId;
6747
+ const zoneStore = useContext10(ZoneStoreContext);
6748
+ const isHovering = useContextStore(
6749
+ ZoneStoreContext,
6750
+ (s) => s.hoveringComponent === itemId
6751
+ );
7181
6752
  const childIsSelected = useAppStore((s) => {
7182
6753
  var _a2, _b;
7183
6754
  const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
@@ -7188,7 +6759,7 @@ var Layer = ({
7188
6759
  });
7189
6760
  const componentConfig = config.components[nodeData.data.type];
7190
6761
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
7191
- return /* @__PURE__ */ jsxs16(
6762
+ return /* @__PURE__ */ jsxs15(
7192
6763
  "li",
7193
6764
  {
7194
6765
  className: getClassNameLayer({
@@ -7198,7 +6769,7 @@ var Layer = ({
7198
6769
  childIsSelected
7199
6770
  }),
7200
6771
  children: [
7201
- /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6772
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs15(
7202
6773
  "button",
7203
6774
  {
7204
6775
  type: "button",
@@ -7224,31 +6795,31 @@ var Layer = ({
7224
6795
  });
7225
6796
  });
7226
6797
  },
7227
- onMouseOver: (e) => {
6798
+ onMouseEnter: (e) => {
7228
6799
  e.stopPropagation();
7229
- setHoveringComponent(itemId);
6800
+ zoneStore.setState({ hoveringComponent: itemId });
7230
6801
  },
7231
- onMouseOut: (e) => {
6802
+ onMouseLeave: (e) => {
7232
6803
  e.stopPropagation();
7233
- setHoveringComponent(null);
6804
+ zoneStore.setState({ hoveringComponent: null });
7234
6805
  },
7235
6806
  children: [
7236
- containsZone && /* @__PURE__ */ jsx34(
6807
+ containsZone && /* @__PURE__ */ jsx33(
7237
6808
  "div",
7238
6809
  {
7239
6810
  className: getClassNameLayer("chevron"),
7240
6811
  title: isSelected ? "Collapse" : "Expand",
7241
- children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
6812
+ children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
7242
6813
  }
7243
6814
  ),
7244
- /* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
7245
- /* @__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" }) }),
7246
- /* @__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 })
7247
6818
  ] })
7248
6819
  ]
7249
6820
  }
7250
6821
  ) }),
7251
- 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))
7252
6823
  ]
7253
6824
  }
7254
6825
  );
@@ -7266,15 +6837,15 @@ var LayerTree = ({
7266
6837
  }
7267
6838
  )
7268
6839
  );
7269
- return /* @__PURE__ */ jsxs16(Fragment11, { children: [
7270
- label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
7271
- /* @__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" }) }),
7272
6843
  label
7273
6844
  ] }),
7274
- /* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
7275
- 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" }),
7276
6847
  contentIds.map((itemId, i) => {
7277
- return /* @__PURE__ */ jsx34(
6848
+ return /* @__PURE__ */ jsx33(
7278
6849
  Layer,
7279
6850
  {
7280
6851
  index: i,
@@ -7301,14 +6872,14 @@ var findZonesForArea = (state, area) => {
7301
6872
 
7302
6873
  // components/Puck/components/Outline/index.tsx
7303
6874
  import { useShallow as useShallow6 } from "zustand/react/shallow";
7304
- import { jsx as jsx35 } from "react/jsx-runtime";
6875
+ import { jsx as jsx34 } from "react/jsx-runtime";
7305
6876
  var Outline = () => {
7306
6877
  const outlineOverride = useAppStore((s) => s.overrides.outline);
7307
6878
  const rootZones = useAppStore(
7308
6879
  useShallow6((s) => findZonesForArea(s.state, "root"))
7309
6880
  );
7310
6881
  const Wrapper = useMemo16(() => outlineOverride || "div", [outlineOverride]);
7311
- return /* @__PURE__ */ jsx35(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx35(
6882
+ return /* @__PURE__ */ jsx34(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx34(
7312
6883
  LayerTree,
7313
6884
  {
7314
6885
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -7442,30 +7013,30 @@ var getBox = function getBox2(el) {
7442
7013
 
7443
7014
  // components/Puck/components/Canvas/index.tsx
7444
7015
  import {
7445
- useCallback as useCallback14,
7446
- useEffect as useEffect21,
7016
+ useCallback as useCallback15,
7017
+ useEffect as useEffect22,
7447
7018
  useMemo as useMemo18,
7448
- useRef as useRef6,
7019
+ useRef as useRef7,
7449
7020
  useState as useState19
7450
7021
  } from "react";
7451
7022
 
7452
7023
  // components/ViewportControls/index.tsx
7453
7024
  init_react_import();
7454
- 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";
7455
7026
 
7456
7027
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7457
7028
  init_react_import();
7458
- 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" };
7459
7030
 
7460
7031
  // components/ViewportControls/index.tsx
7461
- import { jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
7032
+ import { jsx as jsx35, jsxs as jsxs16 } from "react/jsx-runtime";
7462
7033
  var icons = {
7463
- Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
7464
- Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
7465
- 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 })
7466
7037
  };
7467
- var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
7468
- 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);
7469
7040
  var ViewportButton = ({
7470
7041
  children,
7471
7042
  height = "auto",
@@ -7475,10 +7046,10 @@ var ViewportButton = ({
7475
7046
  }) => {
7476
7047
  const viewports = useAppStore((s) => s.state.ui.viewports);
7477
7048
  const [isActive, setIsActive] = useState18(false);
7478
- useEffect20(() => {
7049
+ useEffect21(() => {
7479
7050
  setIsActive(width === viewports.current.width);
7480
7051
  }, [width, viewports.current.width]);
7481
- return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
7052
+ return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
7482
7053
  IconButton,
7483
7054
  {
7484
7055
  title,
@@ -7487,7 +7058,7 @@ var ViewportButton = ({
7487
7058
  e.stopPropagation();
7488
7059
  onClick({ width, height });
7489
7060
  },
7490
- children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
7061
+ children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
7491
7062
  }
7492
7063
  ) });
7493
7064
  };
@@ -7523,8 +7094,8 @@ var ViewportControls = ({
7523
7094
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7524
7095
  [autoZoom]
7525
7096
  );
7526
- return /* @__PURE__ */ jsxs17("div", { className: getClassName25(), children: [
7527
- viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
7097
+ return /* @__PURE__ */ jsxs16("div", { className: getClassName24(), children: [
7098
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
7528
7099
  ViewportButton,
7529
7100
  {
7530
7101
  height: viewport.height,
@@ -7535,8 +7106,8 @@ var ViewportControls = ({
7535
7106
  },
7536
7107
  i
7537
7108
  )),
7538
- /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
7539
- /* @__PURE__ */ jsx36(
7109
+ /* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
7110
+ /* @__PURE__ */ jsx35(
7540
7111
  IconButton,
7541
7112
  {
7542
7113
  title: "Zoom viewport out",
@@ -7550,10 +7121,10 @@ var ViewportControls = ({
7550
7121
  )].value
7551
7122
  );
7552
7123
  },
7553
- children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
7124
+ children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
7554
7125
  }
7555
7126
  ),
7556
- /* @__PURE__ */ jsx36(
7127
+ /* @__PURE__ */ jsx35(
7557
7128
  IconButton,
7558
7129
  {
7559
7130
  title: "Zoom viewport in",
@@ -7567,19 +7138,19 @@ var ViewportControls = ({
7567
7138
  )].value
7568
7139
  );
7569
7140
  },
7570
- children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
7141
+ children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
7571
7142
  }
7572
7143
  ),
7573
- /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
7574
- /* @__PURE__ */ jsx36(
7144
+ /* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
7145
+ /* @__PURE__ */ jsx35(
7575
7146
  "select",
7576
7147
  {
7577
- className: getClassName25("zoomSelect"),
7148
+ className: getClassName24("zoomSelect"),
7578
7149
  value: zoom.toString(),
7579
7150
  onChange: (e) => {
7580
7151
  onZoom(parseFloat(e.currentTarget.value));
7581
7152
  },
7582
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
7153
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
7583
7154
  "option",
7584
7155
  {
7585
7156
  value: option.value,
@@ -7594,7 +7165,7 @@ var ViewportControls = ({
7594
7165
 
7595
7166
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7596
7167
  init_react_import();
7597
- 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" };
7598
7169
 
7599
7170
  // lib/get-zoom-config.ts
7600
7171
  init_react_import();
@@ -7628,8 +7199,8 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7628
7199
 
7629
7200
  // components/Puck/components/Canvas/index.tsx
7630
7201
  import { useShallow as useShallow7 } from "zustand/react/shallow";
7631
- import { Fragment as Fragment12, jsx as jsx37, jsxs as jsxs18 } from "react/jsx-runtime";
7632
- 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);
7633
7204
  var ZOOM_ON_CHANGE = true;
7634
7205
  var Canvas = () => {
7635
7206
  const {
@@ -7658,17 +7229,17 @@ var Canvas = () => {
7658
7229
  viewports: s.state.ui.viewports
7659
7230
  }))
7660
7231
  );
7661
- const frameRef = useRef6(null);
7232
+ const frameRef = useRef7(null);
7662
7233
  const [showTransition, setShowTransition] = useState19(false);
7663
7234
  const defaultRender = useMemo18(() => {
7664
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
7235
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment11, { children });
7665
7236
  return PuckDefault;
7666
7237
  }, []);
7667
7238
  const CustomPreview = useMemo18(
7668
7239
  () => overrides.preview || defaultRender,
7669
7240
  [overrides]
7670
7241
  );
7671
- const getFrameDimensions = useCallback14(() => {
7242
+ const getFrameDimensions = useCallback15(() => {
7672
7243
  if (frameRef.current) {
7673
7244
  const frame = frameRef.current;
7674
7245
  const box = getBox(frame);
@@ -7676,7 +7247,7 @@ var Canvas = () => {
7676
7247
  }
7677
7248
  return { width: 0, height: 0 };
7678
7249
  }, [frameRef]);
7679
- const resetAutoZoom = useCallback14(
7250
+ const resetAutoZoom = useCallback15(
7680
7251
  (newViewports = viewports) => {
7681
7252
  if (frameRef.current) {
7682
7253
  setZoomConfig(
@@ -7690,11 +7261,11 @@ var Canvas = () => {
7690
7261
  },
7691
7262
  [frameRef, zoomConfig, viewports]
7692
7263
  );
7693
- useEffect21(() => {
7264
+ useEffect22(() => {
7694
7265
  setShowTransition(false);
7695
7266
  resetAutoZoom(viewports);
7696
7267
  }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
7697
- useEffect21(() => {
7268
+ useEffect22(() => {
7698
7269
  const { height: frameHeight } = getFrameDimensions();
7699
7270
  if (viewports.current.height === "auto") {
7700
7271
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -7702,13 +7273,13 @@ var Canvas = () => {
7702
7273
  }));
7703
7274
  }
7704
7275
  }, [zoomConfig.zoom]);
7705
- useEffect21(() => {
7276
+ useEffect22(() => {
7706
7277
  if (ZOOM_ON_CHANGE) {
7707
7278
  setShowTransition(true);
7708
7279
  resetAutoZoom(viewports);
7709
7280
  }
7710
7281
  }, [viewports.current.width]);
7711
- useEffect21(() => {
7282
+ useEffect22(() => {
7712
7283
  const cb = () => {
7713
7284
  setShowTransition(false);
7714
7285
  resetAutoZoom();
@@ -7719,15 +7290,15 @@ var Canvas = () => {
7719
7290
  };
7720
7291
  }, []);
7721
7292
  const [showLoader, setShowLoader] = useState19(false);
7722
- useEffect21(() => {
7293
+ useEffect22(() => {
7723
7294
  setTimeout(() => {
7724
7295
  setShowLoader(true);
7725
7296
  }, 500);
7726
7297
  }, []);
7727
- return /* @__PURE__ */ jsxs18(
7298
+ return /* @__PURE__ */ jsxs17(
7728
7299
  "div",
7729
7300
  {
7730
- className: getClassName26({
7301
+ className: getClassName25({
7731
7302
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7732
7303
  showLoader
7733
7304
  }),
@@ -7737,7 +7308,7 @@ var Canvas = () => {
7737
7308
  recordHistory: true
7738
7309
  }),
7739
7310
  children: [
7740
- 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(
7741
7312
  ViewportControls,
7742
7313
  {
7743
7314
  autoZoom: zoomConfig.autoZoom,
@@ -7763,11 +7334,11 @@ var Canvas = () => {
7763
7334
  }
7764
7335
  }
7765
7336
  ) }),
7766
- /* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), ref: frameRef, children: [
7767
- /* @__PURE__ */ jsx37(
7337
+ /* @__PURE__ */ jsxs17("div", { className: getClassName25("inner"), ref: frameRef, children: [
7338
+ /* @__PURE__ */ jsx36(
7768
7339
  "div",
7769
7340
  {
7770
- className: getClassName26("root"),
7341
+ className: getClassName25("root"),
7771
7342
  style: {
7772
7343
  width: iframe.enabled ? viewports.current.width : "100%",
7773
7344
  height: zoomConfig.rootHeight,
@@ -7785,10 +7356,10 @@ var Canvas = () => {
7785
7356
  })
7786
7357
  );
7787
7358
  },
7788
- children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview3, {}) })
7359
+ children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview2, {}) })
7789
7360
  }
7790
7361
  ),
7791
- /* @__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 }) })
7792
7363
  ] })
7793
7364
  ]
7794
7365
  }
@@ -7843,19 +7414,19 @@ var useLoadedOverrides = ({
7843
7414
 
7844
7415
  // components/DefaultOverride/index.tsx
7845
7416
  init_react_import();
7846
- import { Fragment as Fragment13, jsx as jsx38 } from "react/jsx-runtime";
7847
- 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 });
7848
7419
 
7849
7420
  // lib/use-inject-css.ts
7850
7421
  init_react_import();
7851
- import { useEffect as useEffect22, useState as useState20 } from "react";
7422
+ import { useEffect as useEffect23, useState as useState20 } from "react";
7852
7423
  var styles = ``;
7853
7424
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7854
7425
  const [el, setEl] = useState20();
7855
- useEffect22(() => {
7426
+ useEffect23(() => {
7856
7427
  setEl(document.createElement("style"));
7857
7428
  }, []);
7858
- useEffect22(() => {
7429
+ useEffect23(() => {
7859
7430
  var _a;
7860
7431
  if (!el || typeof window === "undefined") {
7861
7432
  return;
@@ -7875,10 +7446,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
7875
7446
 
7876
7447
  // lib/use-preview-mode-hotkeys.ts
7877
7448
  init_react_import();
7878
- import { useCallback as useCallback15 } from "react";
7449
+ import { useCallback as useCallback16 } from "react";
7879
7450
  var usePreviewModeHotkeys = () => {
7880
7451
  const appStore = useAppStoreApi();
7881
- const toggleInteractive = useCallback15(() => {
7452
+ const toggleInteractive = useCallback16(() => {
7882
7453
  const dispatch = appStore.getState().dispatch;
7883
7454
  dispatch({
7884
7455
  type: "setUi",
@@ -7893,7 +7464,7 @@ var usePreviewModeHotkeys = () => {
7893
7464
 
7894
7465
  // lib/use-puck.ts
7895
7466
  init_react_import();
7896
- 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";
7897
7468
  import { createStore as createStore4, useStore as useStore3 } from "zustand";
7898
7469
  var generateUsePuck = (store) => {
7899
7470
  const history = {
@@ -7946,7 +7517,7 @@ var useRegisterUsePuckStore = (appStore) => {
7946
7517
  () => generateUsePuck(convertToPickedStore(appStore.getState()))
7947
7518
  )
7948
7519
  );
7949
- useEffect23(() => {
7520
+ useEffect24(() => {
7950
7521
  return appStore.subscribe(
7951
7522
  (store) => convertToPickedStore(store),
7952
7523
  (pickedStore) => {
@@ -7958,7 +7529,7 @@ var useRegisterUsePuckStore = (appStore) => {
7958
7529
  };
7959
7530
  function createUsePuck() {
7960
7531
  return function usePuck2(selector) {
7961
- const usePuckApi = useContext10(UsePuckStoreContext);
7532
+ const usePuckApi = useContext11(UsePuckStoreContext);
7962
7533
  if (!usePuckApi) {
7963
7534
  throw new Error("usePuck must be used inside <Puck>.");
7964
7535
  }
@@ -7970,19 +7541,241 @@ function createUsePuck() {
7970
7541
  };
7971
7542
  }
7972
7543
  function usePuck() {
7973
- useEffect23(() => {
7544
+ useEffect24(() => {
7974
7545
  console.warn(
7975
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."
7976
7547
  );
7977
7548
  }, []);
7978
7549
  return createUsePuck()((s) => s);
7979
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
+ }
7980
7558
 
7981
7559
  // components/Puck/index.tsx
7982
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
7983
7615
  import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
7984
- var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
7985
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
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);
7986
7779
  var FieldSideBar = () => {
7987
7780
  const title = useAppStore(
7988
7781
  (s) => {
@@ -7990,13 +7783,13 @@ var FieldSideBar = () => {
7990
7783
  return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
7991
7784
  }
7992
7785
  );
7993
- return /* @__PURE__ */ jsx39(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx39(Fields, {}) });
7786
+ return /* @__PURE__ */ jsx40(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx40(Fields, {}) });
7994
7787
  };
7995
7788
  var propsContext = createContext7({});
7996
7789
  function PropsProvider(props) {
7997
- return /* @__PURE__ */ jsx39(propsContext.Provider, { value: props, children: props.children });
7790
+ return /* @__PURE__ */ jsx40(propsContext.Provider, { value: props, children: props.children });
7998
7791
  }
7999
- var usePropsContext = () => useContext11(propsContext);
7792
+ var usePropsContext = () => useContext12(propsContext);
8000
7793
  function PuckProvider({ children }) {
8001
7794
  const {
8002
7795
  config,
@@ -8012,11 +7805,14 @@ function PuckProvider({ children }) {
8012
7805
  metadata,
8013
7806
  onAction
8014
7807
  } = usePropsContext();
8015
- const iframe = __spreadValues({
8016
- enabled: true,
8017
- waitForStyles: true
8018
- }, _iframe);
8019
- const [generatedAppState] = useState22(() => {
7808
+ const iframe = useMemo21(
7809
+ () => __spreadValues({
7810
+ enabled: true,
7811
+ waitForStyles: true
7812
+ }, _iframe),
7813
+ [_iframe]
7814
+ );
7815
+ const [generatedAppState] = useState23(() => {
8020
7816
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8021
7817
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
8022
7818
  let clientUiState = {};
@@ -8076,7 +7872,7 @@ function PuckProvider({ children }) {
8076
7872
  return walkAppState(newAppState, config);
8077
7873
  });
8078
7874
  const { appendData = true } = _initialHistory || {};
8079
- const [blendedHistories] = useState22(
7875
+ const [blendedHistories] = useState23(
8080
7876
  [
8081
7877
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8082
7878
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8096,7 +7892,7 @@ function PuckProvider({ children }) {
8096
7892
  overrides,
8097
7893
  plugins
8098
7894
  });
8099
- const generateAppStore = useCallback16(
7895
+ const generateAppStore = useCallback18(
8100
7896
  (state) => {
8101
7897
  return {
8102
7898
  state,
@@ -8120,10 +7916,10 @@ function PuckProvider({ children }) {
8120
7916
  metadata
8121
7917
  ]
8122
7918
  );
8123
- const [appStore] = useState22(
7919
+ const [appStore] = useState23(
8124
7920
  () => createAppStore(generateAppStore(initialAppState))
8125
7921
  );
8126
- useEffect24(() => {
7922
+ useEffect25(() => {
8127
7923
  const state = appStore.getState().state;
8128
7924
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8129
7925
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8132,8 +7928,8 @@ function PuckProvider({ children }) {
8132
7928
  index: initialHistoryIndex,
8133
7929
  initialAppState
8134
7930
  });
8135
- const previousData = useRef7(null);
8136
- useEffect24(() => {
7931
+ const previousData = useRef8(null);
7932
+ useEffect25(() => {
8137
7933
  appStore.subscribe(
8138
7934
  (s) => s.state.data,
8139
7935
  (data) => {
@@ -8147,53 +7943,32 @@ function PuckProvider({ children }) {
8147
7943
  }, []);
8148
7944
  useRegisterPermissionsSlice(appStore, permissions);
8149
7945
  const uPuckStore = useRegisterUsePuckStore(appStore);
8150
- useEffect24(() => {
7946
+ useEffect25(() => {
8151
7947
  const { resolveAndCommitData } = appStore.getState();
8152
7948
  resolveAndCommitData();
8153
7949
  }, []);
8154
- 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 }) });
8155
7951
  }
8156
7952
  function PuckLayout({ children }) {
8157
7953
  const {
8158
- onPublish,
8159
- renderHeader,
8160
- renderHeaderActions,
8161
- headerTitle,
8162
- headerPath,
8163
7954
  iframe: _iframe,
8164
7955
  dnd,
8165
7956
  initialHistory: _initialHistory
8166
7957
  } = usePropsContext();
8167
- const iframe = __spreadValues({
8168
- enabled: true,
8169
- waitForStyles: true
8170
- }, _iframe);
7958
+ const iframe = useMemo21(
7959
+ () => __spreadValues({
7960
+ enabled: true,
7961
+ waitForStyles: true
7962
+ }, _iframe),
7963
+ [_iframe]
7964
+ );
8171
7965
  useInjectGlobalCss(iframe.enabled);
8172
7966
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8173
7967
  const rightSideBarVisible = useAppStore(
8174
7968
  (s) => s.state.ui.rightSideBarVisible
8175
7969
  );
8176
- const [menuOpen, setMenuOpen] = useState22(false);
8177
- const appStore = useAppStoreApi();
8178
- const rootProps = useAppStore(
8179
- (s) => s.state.data.root.props || s.state.data.root.props
8180
- );
8181
7970
  const dispatch = useAppStore((s) => s.dispatch);
8182
- const toggleSidebars = useCallback16(
8183
- (sidebar) => {
8184
- const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8185
- const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8186
- const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8187
- dispatch({
8188
- type: "setUi",
8189
- ui: __spreadValues({
8190
- [`${sidebar}SideBarVisible`]: !sideBarVisible
8191
- }, !widerViewport ? { [oppositeSideBar]: false } : {})
8192
- });
8193
- },
8194
- [dispatch, leftSideBarVisible, rightSideBarVisible]
8195
- );
8196
- useEffect24(() => {
7971
+ useEffect25(() => {
8197
7972
  if (!window.matchMedia("(min-width: 638px)").matches) {
8198
7973
  dispatch({
8199
7974
  type: "setUi",
@@ -8216,55 +7991,18 @@ function PuckLayout({ children }) {
8216
7991
  window.removeEventListener("resize", handleResize);
8217
7992
  };
8218
7993
  }, []);
8219
- const defaultHeaderRender = useMemo20(() => {
8220
- if (renderHeader) {
8221
- console.warn(
8222
- "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8223
- );
8224
- const RenderHeader = (_a) => {
8225
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8226
- const Comp = renderHeader;
8227
- const appState = useAppStore((s) => s.state);
8228
- return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8229
- };
8230
- return RenderHeader;
8231
- }
8232
- return DefaultOverride;
8233
- }, [renderHeader]);
8234
- const defaultHeaderActionsRender = useMemo20(() => {
8235
- if (renderHeaderActions) {
8236
- console.warn(
8237
- "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8238
- );
8239
- const RenderHeader = (props) => {
8240
- const Comp = renderHeaderActions;
8241
- const appState = useAppStore((s) => s.state);
8242
- return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8243
- };
8244
- return RenderHeader;
8245
- }
8246
- return DefaultOverride;
8247
- }, [renderHeader]);
8248
7994
  const overrides = useAppStore((s) => s.overrides);
8249
- const CustomPuck = useMemo20(
7995
+ const CustomPuck = useMemo21(
8250
7996
  () => overrides.puck || DefaultOverride,
8251
7997
  [overrides]
8252
7998
  );
8253
- const CustomHeader = useMemo20(
8254
- () => overrides.header || defaultHeaderRender,
8255
- [overrides]
8256
- );
8257
- const CustomHeaderActions = useMemo20(
8258
- () => overrides.headerActions || defaultHeaderActionsRender,
8259
- [overrides]
8260
- );
8261
- const [mounted, setMounted] = useState22(false);
8262
- useEffect24(() => {
7999
+ const [mounted, setMounted] = useState23(false);
8000
+ useEffect25(() => {
8263
8001
  setMounted(true);
8264
8002
  }, []);
8265
8003
  const ready = useAppStore((s) => s.status === "READY");
8266
8004
  useMonitorHotkeys();
8267
- useEffect24(() => {
8005
+ useEffect25(() => {
8268
8006
  if (ready && iframe.enabled) {
8269
8007
  const frameDoc = getFrame();
8270
8008
  if (frameDoc) {
@@ -8273,213 +8011,36 @@ function PuckLayout({ children }) {
8273
8011
  }
8274
8012
  }, [ready, iframe.enabled]);
8275
8013
  usePreviewModeHotkeys();
8276
- return /* @__PURE__ */ jsxs19("div", { className: `Puck ${getClassName27()}`, children: [
8277
- /* @__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(
8278
8016
  "div",
8279
8017
  {
8280
8018
  className: getLayoutClassName({
8281
8019
  leftSideBarVisible,
8282
- menuOpen,
8283
8020
  mounted,
8284
8021
  rightSideBarVisible
8285
8022
  }),
8286
- children: /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("inner"), children: [
8287
- /* @__PURE__ */ jsx39(
8288
- CustomHeader,
8289
- {
8290
- actions: /* @__PURE__ */ jsx39(Fragment14, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
8291
- Button,
8292
- {
8293
- onClick: () => {
8294
- const data = appStore.getState().state.data;
8295
- onPublish && onPublish(data);
8296
- },
8297
- icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
8298
- children: "Publish"
8299
- }
8300
- ) }) }),
8301
- children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerInner"), children: [
8302
- /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerToggle"), children: [
8303
- /* @__PURE__ */ jsx39(
8304
- "div",
8305
- {
8306
- className: getLayoutClassName("leftSideBarToggle"),
8307
- children: /* @__PURE__ */ jsx39(
8308
- IconButton,
8309
- {
8310
- onClick: () => {
8311
- toggleSidebars("left");
8312
- },
8313
- title: "Toggle left sidebar",
8314
- children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
8315
- }
8316
- )
8317
- }
8318
- ),
8319
- /* @__PURE__ */ jsx39(
8320
- "div",
8321
- {
8322
- className: getLayoutClassName("rightSideBarToggle"),
8323
- children: /* @__PURE__ */ jsx39(
8324
- IconButton,
8325
- {
8326
- onClick: () => {
8327
- toggleSidebars("right");
8328
- },
8329
- title: "Toggle right sidebar",
8330
- children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
8331
- }
8332
- )
8333
- }
8334
- )
8335
- ] }),
8336
- /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
8337
- headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
8338
- headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
8339
- " ",
8340
- /* @__PURE__ */ jsx39(
8341
- "code",
8342
- {
8343
- className: getLayoutClassName("headerPath"),
8344
- children: headerPath
8345
- }
8346
- )
8347
- ] })
8348
- ] }) }),
8349
- /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerTools"), children: [
8350
- /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
8351
- IconButton,
8352
- {
8353
- onClick: () => {
8354
- return setMenuOpen(!menuOpen);
8355
- },
8356
- title: "Toggle menu bar",
8357
- children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
8358
- }
8359
- ) }),
8360
- /* @__PURE__ */ jsx39(
8361
- MenuBar,
8362
- {
8363
- dispatch,
8364
- onPublish,
8365
- menuOpen,
8366
- renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
8367
- Button,
8368
- {
8369
- onClick: () => {
8370
- const data = appStore.getState().state.data;
8371
- onPublish && onPublish(data);
8372
- },
8373
- icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
8374
- children: "Publish"
8375
- }
8376
- ) }),
8377
- setMenuOpen
8378
- }
8379
- )
8380
- ] })
8381
- ] }) })
8382
- }
8383
- ),
8384
- /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("leftSideBar"), children: [
8385
- /* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
8386
- /* @__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, {}) })
8387
8028
  ] }),
8388
- /* @__PURE__ */ jsx39(Canvas, {}),
8389
- /* @__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, {}) })
8390
8031
  ] })
8391
8032
  }
8392
8033
  ) }) }),
8393
- /* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
8034
+ /* @__PURE__ */ jsx40("div", { id: "puck-portal-root", className: getClassName28("portal") })
8394
8035
  ] });
8395
8036
  }
8396
8037
  function Puck(props) {
8397
- 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)) })) }));
8398
8039
  }
8399
8040
  Puck.Components = Components;
8400
8041
  Puck.Fields = Fields;
8401
8042
  Puck.Outline = Outline;
8402
- Puck.Preview = Preview3;
8403
-
8404
- // lib/migrate.ts
8405
- init_react_import();
8406
- var migrations = [
8407
- // Migrate root to root.props
8408
- (data) => {
8409
- const rootProps = data.root.props || data.root;
8410
- if (Object.keys(data.root).length > 0 && !data.root.props) {
8411
- console.warn(
8412
- "Migration applied: Root props moved from `root` to `root.props`."
8413
- );
8414
- return __spreadProps(__spreadValues({}, data), {
8415
- root: {
8416
- props: __spreadValues({}, rootProps)
8417
- }
8418
- });
8419
- }
8420
- return data;
8421
- },
8422
- // Migrate zones to slots
8423
- (data, config) => {
8424
- var _a;
8425
- if (!config) return data;
8426
- console.log("Migrating DropZones to slots...");
8427
- const updatedItems = {};
8428
- const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
8429
- const { indexes } = walkAppState(appState, config);
8430
- const deletedCompounds = [];
8431
- walkAppState(appState, config, (content, zoneCompound, zoneType) => {
8432
- var _a2, _b;
8433
- if (zoneType === "dropzone") {
8434
- const [id, slotName] = zoneCompound.split(":");
8435
- const nodeData = indexes.nodes[id].data;
8436
- const componentType = nodeData.type;
8437
- const configForComponent = config.components[componentType];
8438
- if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
8439
- updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
8440
- props: __spreadProps(__spreadValues({}, nodeData.props), {
8441
- [slotName]: content
8442
- })
8443
- });
8444
- deletedCompounds.push(zoneCompound);
8445
- }
8446
- return content;
8447
- }
8448
- return content;
8449
- });
8450
- const updated = walkAppState(
8451
- appState,
8452
- config,
8453
- (content) => content,
8454
- (item) => {
8455
- var _a2;
8456
- return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
8457
- }
8458
- );
8459
- deletedCompounds.forEach((zoneCompound) => {
8460
- var _a2;
8461
- const [_, propName] = zoneCompound.split(":");
8462
- console.log(
8463
- `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
8464
- );
8465
- (_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
8466
- });
8467
- Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
8468
- const [_, propName] = zoneCompound.split(":");
8469
- throw new Error(
8470
- `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
8471
- );
8472
- });
8473
- delete updated.data.zones;
8474
- return updated.data;
8475
- }
8476
- ];
8477
- function migrate(data, config) {
8478
- return migrations == null ? void 0 : migrations.reduce(
8479
- (acc, migration) => migration(acc, config),
8480
- data
8481
- );
8482
- }
8043
+ Puck.Preview = Preview2;
8483
8044
  export {
8484
8045
  Action,
8485
8046
  ActionBar,
@@ -8499,6 +8060,7 @@ export {
8499
8060
  renderContext,
8500
8061
  resolveAllData,
8501
8062
  transformProps,
8063
+ useGetPuck,
8502
8064
  usePuck,
8503
8065
  walkTree
8504
8066
  };