@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.js CHANGED
@@ -9,9 +9,6 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
9
  var __getProtoOf = Object.getPrototypeOf;
10
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __typeError = (msg) => {
13
- throw TypeError(msg);
14
- };
15
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
13
  var __spreadValues = (a, b) => {
17
14
  for (var prop in b || (b = {}))
@@ -64,10 +61,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
64
61
  mod
65
62
  ));
66
63
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
67
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
68
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
69
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
70
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
71
64
  var __async = (__this, __arguments, generator) => {
72
65
  return new Promise((resolve, reject) => {
73
66
  var fulfilled = (value) => {
@@ -181,6 +174,7 @@ __export(core_exports, {
181
174
  renderContext: () => renderContext,
182
175
  resolveAllData: () => resolveAllData,
183
176
  transformProps: () => transformProps,
177
+ useGetPuck: () => useGetPuck,
184
178
  usePuck: () => usePuck,
185
179
  walkTree: () => walkTree
186
180
  });
@@ -1832,7 +1826,11 @@ var createNodesSlice = (set, get) => ({
1832
1826
  const s = get().nodes;
1833
1827
  const emptyNode = {
1834
1828
  id,
1835
- methods: { sync: () => null },
1829
+ methods: {
1830
+ sync: () => null,
1831
+ hideOverlay: () => null,
1832
+ showOverlay: () => null
1833
+ },
1836
1834
  element: null
1837
1835
  };
1838
1836
  const existingNode = s.nodes[id];
@@ -2186,7 +2184,8 @@ var toRoot = (item) => {
2186
2184
  return { props: {}, readOnly };
2187
2185
  };
2188
2186
 
2189
- // store/index.ts
2187
+ // store/default-app-state.ts
2188
+ init_react_import();
2190
2189
  var defaultAppState = {
2191
2190
  data: { content: [], root: {}, zones: {} },
2192
2191
  ui: {
@@ -2212,6 +2211,8 @@ var defaultAppState = {
2212
2211
  zones: {}
2213
2212
  }
2214
2213
  };
2214
+
2215
+ // store/index.ts
2215
2216
  var defaultPageFields = {
2216
2217
  title: { type: "text" }
2217
2218
  };
@@ -2400,314 +2401,11 @@ function useAppStoreApi() {
2400
2401
  init_react_import();
2401
2402
  var import_react12 = require("@dnd-kit/react");
2402
2403
 
2403
- // lib/dnd/dnd-kit/safe.ts
2404
- init_react_import();
2405
- var import_react10 = require("@dnd-kit/react");
2406
- var import_sortable = require("@dnd-kit/react/sortable");
2407
- function useDroppableSafe(input) {
2408
- if (typeof window === "undefined") {
2409
- return { ref: () => {
2410
- } };
2411
- }
2412
- return (0, import_react10.useDroppable)(input);
2413
- }
2414
- function useDraggableSafe(input) {
2415
- if (typeof window === "undefined") {
2416
- return { ref: () => {
2417
- } };
2418
- }
2419
- return (0, import_react10.useDraggable)(input);
2420
- }
2421
- function useSortableSafe(input) {
2422
- if (typeof window === "undefined") {
2423
- return { ref: () => {
2424
- }, status: "idle", handleRef: () => {
2425
- } };
2426
- }
2427
- return (0, import_sortable.useSortable)(input);
2428
- }
2429
-
2430
2404
  // lib/dnd/use-sensors.ts
2431
2405
  init_react_import();
2432
- var import_react11 = require("react");
2433
-
2434
- // lib/dnd/PointerSensor.ts
2435
- init_react_import();
2436
- var import_state = require("@dnd-kit/state");
2437
- var import_abstract = require("@dnd-kit/abstract");
2438
- var import_geometry = require("@dnd-kit/geometry");
2406
+ var import_react10 = require("react");
2407
+ var import_react11 = require("@dnd-kit/react");
2439
2408
  var import_utilities = require("@dnd-kit/dom/utilities");
2440
- var _clearTimeout;
2441
- var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
2442
- constructor(manager, options) {
2443
- super(manager);
2444
- this.manager = manager;
2445
- this.options = options;
2446
- this.listeners = new import_utilities.Listeners();
2447
- this.cleanup = /* @__PURE__ */ new Set();
2448
- this.source = void 0;
2449
- this.started = false;
2450
- __privateAdd(this, _clearTimeout);
2451
- this.handleCancel = this.handleCancel.bind(this);
2452
- this.handlePointerUp = this.handlePointerUp.bind(this);
2453
- this.handleKeyDown = this.handleKeyDown.bind(this);
2454
- (0, import_state.effect)(() => {
2455
- const unbindGlobal = this.bindGlobal(options != null ? options : {});
2456
- return () => {
2457
- unbindGlobal();
2458
- };
2459
- });
2460
- }
2461
- bind(source, options = this.options) {
2462
- const unbind = (0, import_state.effect)(() => {
2463
- var _a;
2464
- const target = (_a = source.handle) != null ? _a : source.element;
2465
- const listener = (event) => {
2466
- if ((0, import_utilities.isPointerEvent)(event)) {
2467
- this.handlePointerDown(event, source, options);
2468
- }
2469
- };
2470
- if (target) {
2471
- patchWindow(target.ownerDocument.defaultView);
2472
- target.addEventListener("pointerdown", listener);
2473
- return () => {
2474
- target.removeEventListener("pointerdown", listener);
2475
- };
2476
- }
2477
- });
2478
- return unbind;
2479
- }
2480
- bindGlobal(options) {
2481
- const documents = /* @__PURE__ */ new Set();
2482
- for (const draggable of this.manager.registry.draggables.value) {
2483
- if (draggable.element) {
2484
- documents.add((0, import_utilities.getDocument)(draggable.element));
2485
- }
2486
- }
2487
- for (const droppable of this.manager.registry.droppables.value) {
2488
- if (droppable.element) {
2489
- documents.add((0, import_utilities.getDocument)(droppable.element));
2490
- }
2491
- }
2492
- const unbindFns = Array.from(documents).map(
2493
- (doc) => this.listeners.bind(doc, [
2494
- {
2495
- type: "pointermove",
2496
- listener: (event) => this.handlePointerMove(event, doc, options)
2497
- },
2498
- {
2499
- type: "pointerup",
2500
- listener: this.handlePointerUp,
2501
- options: {
2502
- capture: true
2503
- }
2504
- },
2505
- {
2506
- // Cancel activation if there is a competing Drag and Drop interaction
2507
- type: "dragstart",
2508
- listener: this.handleDragStart
2509
- }
2510
- ])
2511
- );
2512
- return () => {
2513
- unbindFns.forEach((unbind) => unbind());
2514
- };
2515
- }
2516
- handlePointerDown(event, source, options = {}) {
2517
- if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
2518
- return;
2519
- }
2520
- const offset = (0, import_utilities.getFrameTransform)(source.element);
2521
- this.initialCoordinates = {
2522
- x: event.clientX * offset.scaleX + offset.x,
2523
- y: event.clientY * offset.scaleY + offset.y
2524
- };
2525
- this.source = source;
2526
- const { activationConstraints } = options;
2527
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
2528
- event.stopImmediatePropagation();
2529
- if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
2530
- this.handleStart(source, event);
2531
- } else {
2532
- const { delay } = constraints;
2533
- if (delay) {
2534
- const timeout3 = setTimeout(
2535
- () => this.handleStart(source, event),
2536
- delay.value
2537
- );
2538
- __privateSet(this, _clearTimeout, () => {
2539
- clearTimeout(timeout3);
2540
- __privateSet(this, _clearTimeout, void 0);
2541
- });
2542
- }
2543
- }
2544
- const cleanup = () => {
2545
- var _a;
2546
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2547
- this.initialCoordinates = void 0;
2548
- this.source = void 0;
2549
- };
2550
- this.cleanup.add(cleanup);
2551
- }
2552
- handlePointerMove(event, doc, options) {
2553
- if (!this.source) {
2554
- return;
2555
- }
2556
- const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
2557
- if (doc !== ownerDocument) {
2558
- return;
2559
- }
2560
- const coordinates = {
2561
- x: event.clientX,
2562
- y: event.clientY
2563
- };
2564
- const offset = (0, import_utilities.getFrameTransform)(this.source.element);
2565
- coordinates.x = coordinates.x * offset.scaleX + offset.x;
2566
- coordinates.y = coordinates.y * offset.scaleY + offset.y;
2567
- if (this.manager.dragOperation.status.dragging) {
2568
- event.preventDefault();
2569
- event.stopPropagation();
2570
- this.manager.actions.move({ to: coordinates });
2571
- return;
2572
- }
2573
- if (!this.initialCoordinates) {
2574
- return;
2575
- }
2576
- const delta = {
2577
- x: coordinates.x - this.initialCoordinates.x,
2578
- y: coordinates.y - this.initialCoordinates.y
2579
- };
2580
- const { activationConstraints } = options;
2581
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
2582
- const { distance, delay } = constraints != null ? constraints : {};
2583
- if (distance) {
2584
- if (distance.tolerance != null && (0, import_geometry.exceedsDistance)(delta, distance.tolerance)) {
2585
- return this.handleCancel();
2586
- }
2587
- if ((0, import_geometry.exceedsDistance)(delta, distance.value)) {
2588
- return this.handleStart(this.source, event);
2589
- }
2590
- }
2591
- if (delay) {
2592
- if ((0, import_geometry.exceedsDistance)(delta, delay.tolerance)) {
2593
- return this.handleCancel();
2594
- }
2595
- }
2596
- }
2597
- handlePointerUp(event) {
2598
- if (!this.source) {
2599
- return;
2600
- }
2601
- event.preventDefault();
2602
- event.stopPropagation();
2603
- const { status } = this.manager.dragOperation;
2604
- if (!status.idle) {
2605
- const canceled = !status.initialized;
2606
- this.manager.actions.stop({ canceled });
2607
- } else if (this.started) {
2608
- setTimeout(() => {
2609
- if (!this.manager.dragOperation.status.idle) {
2610
- this.manager.actions.stop({ canceled: false });
2611
- }
2612
- }, 10);
2613
- }
2614
- this.cleanup.forEach((cleanup) => cleanup());
2615
- this.cleanup.clear();
2616
- }
2617
- handleKeyDown(event) {
2618
- if (event.key === "Escape") {
2619
- event.preventDefault();
2620
- this.handleCancel();
2621
- }
2622
- }
2623
- handleStart(source, event) {
2624
- var _a;
2625
- const { manager, initialCoordinates } = this;
2626
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2627
- if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2628
- return;
2629
- }
2630
- if (event.defaultPrevented) {
2631
- return;
2632
- }
2633
- this.started = true;
2634
- event.preventDefault();
2635
- (0, import_state.batch)(() => {
2636
- manager.actions.setDragSource(source.id);
2637
- manager.actions.start({ coordinates: initialCoordinates, event });
2638
- });
2639
- const ownerDocument = (0, import_utilities.getDocument)(event.target);
2640
- const unbind = this.listeners.bind(ownerDocument, [
2641
- {
2642
- // Prevent scrolling on touch devices
2643
- type: "touchmove",
2644
- listener: preventDefault,
2645
- options: {
2646
- passive: false
2647
- }
2648
- },
2649
- {
2650
- // Prevent click events
2651
- type: "click",
2652
- listener: preventDefault
2653
- },
2654
- {
2655
- type: "keydown",
2656
- listener: this.handleKeyDown
2657
- }
2658
- ]);
2659
- ownerDocument.body.setPointerCapture(event.pointerId);
2660
- this.cleanup.add(unbind);
2661
- this.cleanup.add(() => {
2662
- this.started = false;
2663
- });
2664
- }
2665
- handleDragStart(event) {
2666
- const { target } = event;
2667
- if (!(0, import_utilities.isElement)(target)) {
2668
- return;
2669
- }
2670
- const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
2671
- if (isNativeDraggable) {
2672
- this.handleCancel();
2673
- } else {
2674
- preventDefault(event);
2675
- }
2676
- }
2677
- handleCancel() {
2678
- const { dragOperation } = this.manager;
2679
- if (dragOperation.status.initialized) {
2680
- this.manager.actions.stop({ canceled: true });
2681
- }
2682
- this.cleanup.forEach((cleanup) => cleanup());
2683
- this.cleanup.clear();
2684
- }
2685
- destroy() {
2686
- this.listeners.clear();
2687
- }
2688
- };
2689
- _clearTimeout = new WeakMap();
2690
- _PointerSensor.configure = (0, import_abstract.configurator)(_PointerSensor);
2691
- var PointerSensor = _PointerSensor;
2692
- function preventDefault(event) {
2693
- event.preventDefault();
2694
- }
2695
- function noop() {
2696
- }
2697
- var windows = /* @__PURE__ */ new WeakSet();
2698
- function patchWindow(window2) {
2699
- if (!window2 || windows.has(window2)) {
2700
- return;
2701
- }
2702
- window2.addEventListener("touchmove", noop, {
2703
- capture: false,
2704
- passive: false
2705
- });
2706
- windows.add(window2);
2707
- }
2708
-
2709
- // lib/dnd/use-sensors.ts
2710
- var import_utilities2 = require("@dnd-kit/dom/utilities");
2711
2409
  var useSensors = ({
2712
2410
  other,
2713
2411
  mouse,
@@ -2716,12 +2414,12 @@ var useSensors = ({
2716
2414
  touch: { delay: { value: 200, tolerance: 10 } },
2717
2415
  other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
2718
2416
  }) => {
2719
- const [sensors] = (0, import_react11.useState)(() => [
2720
- PointerSensor.configure({
2417
+ const [sensors] = (0, import_react10.useState)(() => [
2418
+ import_react11.PointerSensor.configure({
2721
2419
  activationConstraints(event, source) {
2722
2420
  var _a;
2723
2421
  const { pointerType, target } = event;
2724
- if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2422
+ if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2725
2423
  return mouse;
2726
2424
  }
2727
2425
  if (pointerType === "touch") {
@@ -2736,11 +2434,11 @@ var useSensors = ({
2736
2434
 
2737
2435
  // lib/dnd/collision/dynamic/index.ts
2738
2436
  init_react_import();
2739
- var import_abstract9 = require("@dnd-kit/abstract");
2437
+ var import_abstract8 = require("@dnd-kit/abstract");
2740
2438
 
2741
2439
  // lib/dnd/collision/directional/index.ts
2742
2440
  init_react_import();
2743
- var import_abstract2 = require("@dnd-kit/abstract");
2441
+ var import_abstract = require("@dnd-kit/abstract");
2744
2442
 
2745
2443
  // lib/dnd/collision/collision-debug.ts
2746
2444
  init_react_import();
@@ -2818,7 +2516,7 @@ var directionalCollision = (input, previous) => {
2818
2516
  return {
2819
2517
  id: droppable.id,
2820
2518
  value: 1,
2821
- type: import_abstract2.CollisionType.Collision
2519
+ type: import_abstract.CollisionType.Collision
2822
2520
  };
2823
2521
  }
2824
2522
  return null;
@@ -2860,7 +2558,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2860
2558
 
2861
2559
  // lib/dnd/collision/dynamic/track-movement-interval.ts
2862
2560
  init_react_import();
2863
- var import_geometry2 = require("@dnd-kit/geometry");
2561
+ var import_geometry = require("@dnd-kit/geometry");
2864
2562
  var INTERVAL_SENSITIVITY = 10;
2865
2563
  var intervalCache = {
2866
2564
  current: { x: 0, y: 0 },
@@ -2876,13 +2574,15 @@ var trackMovementInterval = (point, dragAxis = "dynamic") => {
2876
2574
  };
2877
2575
  intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
2878
2576
  if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
2879
- intervalCache.previous = import_geometry2.Point.from(point);
2577
+ intervalCache.previous = import_geometry.Point.from(point);
2880
2578
  }
2881
2579
  return intervalCache;
2882
2580
  };
2883
2581
 
2884
2582
  // ../../node_modules/@dnd-kit/collision/dist/index.js
2885
2583
  init_react_import();
2584
+ var import_abstract2 = require("@dnd-kit/abstract");
2585
+ var import_geometry2 = require("@dnd-kit/geometry");
2886
2586
  var import_abstract3 = require("@dnd-kit/abstract");
2887
2587
  var import_geometry3 = require("@dnd-kit/geometry");
2888
2588
  var import_abstract4 = require("@dnd-kit/abstract");
@@ -2893,8 +2593,6 @@ var import_abstract6 = require("@dnd-kit/abstract");
2893
2593
  var import_geometry6 = require("@dnd-kit/geometry");
2894
2594
  var import_abstract7 = require("@dnd-kit/abstract");
2895
2595
  var import_geometry7 = require("@dnd-kit/geometry");
2896
- var import_abstract8 = require("@dnd-kit/abstract");
2897
- var import_geometry8 = require("@dnd-kit/geometry");
2898
2596
  var pointerIntersection = ({
2899
2597
  dragOperation,
2900
2598
  droppable
@@ -2908,12 +2606,12 @@ var pointerIntersection = ({
2908
2606
  return null;
2909
2607
  }
2910
2608
  if (droppable.shape.containsPoint(pointerCoordinates)) {
2911
- const distance = import_geometry3.Point.distance(droppable.shape.center, pointerCoordinates);
2609
+ const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
2912
2610
  return {
2913
2611
  id,
2914
2612
  value: 1 / distance,
2915
- type: import_abstract3.CollisionType.PointerIntersection,
2916
- priority: import_abstract3.CollisionPriority.High
2613
+ type: import_abstract2.CollisionType.PointerIntersection,
2614
+ priority: import_abstract2.CollisionPriority.High
2917
2615
  };
2918
2616
  }
2919
2617
  return null;
@@ -2924,31 +2622,15 @@ var closestCorners = (input) => {
2924
2622
  if (!droppable.shape) {
2925
2623
  return null;
2926
2624
  }
2927
- const { left, top, right, bottom } = droppable.shape.boundingRectangle;
2928
- const corners = [
2929
- {
2930
- x: left,
2931
- y: top
2932
- },
2933
- {
2934
- x: right,
2935
- y: top
2936
- },
2937
- {
2938
- x: left,
2939
- y: bottom
2940
- },
2941
- {
2942
- x: right,
2943
- y: bottom
2944
- }
2945
- ];
2946
- const distance = corners.reduce(
2947
- (acc, corner) => {
2625
+ const shapeCorners = shape ? import_geometry4.Rectangle.from(shape.current.boundingRectangle).corners : void 0;
2626
+ const distance = import_geometry4.Rectangle.from(
2627
+ droppable.shape.boundingRectangle
2628
+ ).corners.reduce(
2629
+ (acc, corner, index) => {
2948
2630
  var _a;
2949
- return acc + import_geometry5.Point.distance(
2950
- import_geometry5.Point.from(corner),
2951
- (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
2631
+ return acc + import_geometry4.Point.distance(
2632
+ import_geometry4.Point.from(corner),
2633
+ (_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
2952
2634
  );
2953
2635
  },
2954
2636
  0
@@ -2957,8 +2639,8 @@ var closestCorners = (input) => {
2957
2639
  return {
2958
2640
  id: droppable.id,
2959
2641
  value: 1 / value,
2960
- type: import_abstract5.CollisionType.Collision,
2961
- priority: import_abstract5.CollisionPriority.Normal
2642
+ type: import_abstract4.CollisionType.Collision,
2643
+ priority: import_abstract4.CollisionPriority.Normal
2962
2644
  };
2963
2645
  };
2964
2646
 
@@ -2983,12 +2665,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2983
2665
  const { center: dragCenter } = dragShape;
2984
2666
  const { fallbackEnabled } = collisionStore.getState();
2985
2667
  const interval = trackMovementInterval(position.current, dragAxis);
2986
- dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2987
- direction: interval.direction
2988
- });
2989
- const collisionMap = dragOperation.data.collisionMap || {};
2990
- dragOperation.data.collisionMap = collisionMap;
2991
- collisionMap[droppable.id] = {
2668
+ const data = {
2992
2669
  direction: interval.direction
2993
2670
  };
2994
2671
  const { center: dropCenter } = dropShape;
@@ -3003,7 +2680,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3003
2680
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
3004
2681
  if (collision) {
3005
2682
  return __spreadProps(__spreadValues({}, collision), {
3006
- priority: import_abstract9.CollisionPriority.Highest
2683
+ priority: import_abstract8.CollisionPriority.Highest,
2684
+ data
3007
2685
  });
3008
2686
  }
3009
2687
  }
@@ -3020,12 +2698,12 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3020
2698
  const collision = {
3021
2699
  id: droppable.id,
3022
2700
  value: intersectionRatio,
3023
- priority: import_abstract9.CollisionPriority.High,
3024
- type: import_abstract9.CollisionType.Collision
2701
+ priority: import_abstract8.CollisionPriority.High,
2702
+ type: import_abstract8.CollisionType.Collision
3025
2703
  };
3026
2704
  const shouldFlushId = flushNext === droppable.id;
3027
2705
  flushNext = "";
3028
- return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2706
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
3029
2707
  }
3030
2708
  if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
3031
2709
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
@@ -3037,9 +2715,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3037
2715
  x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
3038
2716
  y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
3039
2717
  });
3040
- collisionMap[droppable.id] = {
3041
- direction
3042
- };
2718
+ data.direction = direction;
3043
2719
  if (intersectionArea) {
3044
2720
  collisionDebug(
3045
2721
  dragCenter,
@@ -3050,7 +2726,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3050
2726
  );
3051
2727
  flushNext = droppable.id;
3052
2728
  return __spreadProps(__spreadValues({}, fallbackCollision), {
3053
- priority: import_abstract9.CollisionPriority.Low
2729
+ priority: import_abstract8.CollisionPriority.Low,
2730
+ data
3054
2731
  });
3055
2732
  }
3056
2733
  collisionDebug(
@@ -3060,16 +2737,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3060
2737
  "orange",
3061
2738
  direction || ""
3062
2739
  );
3063
- return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract9.CollisionPriority.Lowest });
2740
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2741
+ priority: import_abstract8.CollisionPriority.Lowest,
2742
+ data
2743
+ });
3064
2744
  }
3065
2745
  }
3066
2746
  }
3067
2747
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
3068
- delete collisionMap[droppable.id];
3069
2748
  return null;
3070
2749
  };
3071
2750
 
3072
2751
  // components/Sortable/index.tsx
2752
+ var import_sortable = require("@dnd-kit/react/sortable");
3073
2753
  var import_jsx_runtime5 = require("react/jsx-runtime");
3074
2754
  var SortableProvider = ({
3075
2755
  children,
@@ -3089,16 +2769,16 @@ var SortableProvider = ({
3089
2769
  return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
3090
2770
  },
3091
2771
  onDragOver: (event, manager) => {
3092
- var _a, _b;
2772
+ var _a;
3093
2773
  event.preventDefault();
3094
2774
  const { operation } = event;
3095
2775
  const { source, target } = operation;
3096
2776
  if (!source || !target) return;
3097
2777
  let sourceIndex = source.data.index;
3098
2778
  let targetIndex = target.data.index;
3099
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
2779
+ const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
3100
2780
  if (sourceIndex !== targetIndex && source.id !== target.id) {
3101
- const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2781
+ const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
3102
2782
  if (targetIndex >= sourceIndex) {
3103
2783
  targetIndex = targetIndex - 1;
3104
2784
  }
@@ -3129,9 +2809,10 @@ var Sortable = ({
3129
2809
  }) => {
3130
2810
  const {
3131
2811
  ref: sortableRef,
3132
- status,
2812
+ isDragging,
2813
+ isDropping,
3133
2814
  handleRef
3134
- } = useSortableSafe({
2815
+ } = (0, import_sortable.useSortable)({
3135
2816
  id,
3136
2817
  type,
3137
2818
  index,
@@ -3139,7 +2820,7 @@ var Sortable = ({
3139
2820
  data: { index },
3140
2821
  collisionDetector: createDynamicCollisionDetector("y")
3141
2822
  });
3142
- return children({ status, ref: sortableRef, handleRef });
2823
+ return children({ isDragging, isDropping, ref: sortableRef, handleRef });
3143
2824
  };
3144
2825
 
3145
2826
  // components/AutoField/context.tsx
@@ -3264,7 +2945,7 @@ var ArrayField = ({
3264
2945
  }
3265
2946
  }, []);
3266
2947
  const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
3267
- const isDragging = !!draggedItem;
2948
+ const isDraggingAny = !!draggedItem;
3268
2949
  const canEdit = useAppStore(
3269
2950
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
3270
2951
  );
@@ -3329,13 +3010,13 @@ var ArrayField = ({
3329
3010
  id: _arrayId,
3330
3011
  index: i,
3331
3012
  disabled: readOnly,
3332
- children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3013
+ children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3333
3014
  "div",
3334
3015
  {
3335
3016
  ref,
3336
3017
  className: getClassNameItem({
3337
3018
  isExpanded: arrayState.openId === _arrayId,
3338
- isDragging: status === "dragging",
3019
+ isDragging,
3339
3020
  readOnly
3340
3021
  }),
3341
3022
  children: [
@@ -3476,7 +3157,7 @@ var ArrayField = ({
3476
3157
  type: "button",
3477
3158
  className: getClassName5("addButton"),
3478
3159
  onClick: () => {
3479
- if (isDragging) return;
3160
+ if (isDraggingAny) return;
3480
3161
  const existingValue = value || [];
3481
3162
  const newValue = [
3482
3163
  ...existingValue,
@@ -4462,21 +4143,21 @@ init_react_import();
4462
4143
  var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
4463
4144
 
4464
4145
  // components/Drawer/index.tsx
4465
- var import_react37 = require("react");
4146
+ var import_react39 = require("react");
4466
4147
 
4467
4148
  // components/DragDropContext/index.tsx
4468
4149
  init_react_import();
4469
- var import_react35 = require("@dnd-kit/react");
4470
- var import_react36 = require("react");
4150
+ var import_react37 = require("@dnd-kit/react");
4151
+ var import_react38 = require("react");
4471
4152
  var import_dom = require("@dnd-kit/dom");
4472
4153
 
4473
4154
  // components/DropZone/index.tsx
4474
4155
  init_react_import();
4475
- var import_react34 = require("react");
4156
+ var import_react35 = require("react");
4476
4157
 
4477
4158
  // components/DraggableComponent/index.tsx
4478
4159
  init_react_import();
4479
- var import_react25 = require("react");
4160
+ var import_react26 = require("react");
4480
4161
 
4481
4162
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
4482
4163
  init_react_import();
@@ -4517,7 +4198,9 @@ var ZoneStoreContext = (0, import_react23.createContext)(
4517
4198
  areaDepthIndex: {},
4518
4199
  nextAreaDepthIndex: {},
4519
4200
  draggedItem: null,
4520
- previewIndex: {}
4201
+ previewIndex: {},
4202
+ enabledIndex: {},
4203
+ hoveringComponent: null
4521
4204
  }))
4522
4205
  );
4523
4206
  var ZoneStoreProvider = ({
@@ -4530,7 +4213,6 @@ var DropZoneProvider = ({
4530
4213
  children,
4531
4214
  value
4532
4215
  }) => {
4533
- const [hoveringComponent, setHoveringComponent] = (0, import_react23.useState)();
4534
4216
  const dispatch = useAppStore((s) => s.dispatch);
4535
4217
  const registerZone = (0, import_react23.useCallback)(
4536
4218
  (zoneCompound) => {
@@ -4552,16 +4234,33 @@ var DropZoneProvider = ({
4552
4234
  );
4553
4235
  const memoValue = (0, import_react23.useMemo)(
4554
4236
  () => __spreadValues({
4555
- hoveringComponent,
4556
- setHoveringComponent,
4557
4237
  registerZone,
4558
4238
  unregisterZone
4559
4239
  }, value),
4560
- [value, hoveringComponent]
4240
+ [value]
4561
4241
  );
4562
4242
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
4563
4243
  };
4564
4244
 
4245
+ // components/DraggableComponent/index.tsx
4246
+ var import_shallow2 = require("zustand/react/shallow");
4247
+ var import_sortable2 = require("@dnd-kit/react/sortable");
4248
+
4249
+ // lib/accumulate-transform.ts
4250
+ init_react_import();
4251
+ function accumulateTransform(el) {
4252
+ let matrix = new DOMMatrixReadOnly();
4253
+ let n = el.parentElement;
4254
+ while (n && n !== document.documentElement) {
4255
+ const t = getComputedStyle(n).transform;
4256
+ if (t && t !== "none") {
4257
+ matrix = new DOMMatrixReadOnly(t).multiply(matrix);
4258
+ }
4259
+ n = n.parentElement;
4260
+ }
4261
+ return { scaleX: matrix.a, scaleY: matrix.d };
4262
+ }
4263
+
4565
4264
  // lib/use-context-store.ts
4566
4265
  init_react_import();
4567
4266
  var import_react24 = require("react");
@@ -4575,8 +4274,39 @@ function useContextStore(context, selector) {
4575
4274
  return (0, import_zustand4.useStore)(store, (0, import_shallow.useShallow)(selector));
4576
4275
  }
4577
4276
 
4277
+ // lib/dnd/use-on-drag-finished.ts
4278
+ init_react_import();
4279
+ var import_react25 = require("react");
4280
+ var useOnDragFinished = (cb, deps = []) => {
4281
+ const appStore = useAppStoreApi();
4282
+ return (0, import_react25.useCallback)(() => {
4283
+ let dispose = () => {
4284
+ };
4285
+ const processDragging = (isDragging2) => {
4286
+ if (isDragging2) {
4287
+ cb(false);
4288
+ } else {
4289
+ setTimeout(() => {
4290
+ cb(true);
4291
+ }, 0);
4292
+ if (dispose) dispose();
4293
+ }
4294
+ };
4295
+ const isDragging = appStore.getState().state.ui.isDragging;
4296
+ processDragging(isDragging);
4297
+ if (isDragging) {
4298
+ dispose = appStore.subscribe(
4299
+ (s) => s.state.ui.isDragging,
4300
+ (isDragging2) => {
4301
+ processDragging(isDragging2);
4302
+ }
4303
+ );
4304
+ }
4305
+ return dispose;
4306
+ }, [appStore, ...deps]);
4307
+ };
4308
+
4578
4309
  // components/DraggableComponent/index.tsx
4579
- var import_shallow2 = require("zustand/react/shallow");
4580
4310
  var import_jsx_runtime20 = require("react/jsx-runtime");
4581
4311
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
4582
4312
  var DEBUG2 = false;
@@ -4606,7 +4336,6 @@ var DraggableComponent = ({
4606
4336
  isSelected = false,
4607
4337
  debug,
4608
4338
  label,
4609
- isEnabled,
4610
4339
  autoDragAxis,
4611
4340
  userDragAxis,
4612
4341
  inDroppableZone = true
@@ -4620,9 +4349,9 @@ var DraggableComponent = ({
4620
4349
  const overrides = useAppStore((s) => s.overrides);
4621
4350
  const dispatch = useAppStore((s) => s.dispatch);
4622
4351
  const iframe = useAppStore((s) => s.iframe);
4623
- const ctx = (0, import_react25.useContext)(dropZoneContext);
4624
- const [localZones, setLocalZones] = (0, import_react25.useState)({});
4625
- const registerLocalZone = (0, import_react25.useCallback)(
4352
+ const ctx = (0, import_react26.useContext)(dropZoneContext);
4353
+ const [localZones, setLocalZones] = (0, import_react26.useState)({});
4354
+ const registerLocalZone = (0, import_react26.useCallback)(
4626
4355
  (zoneCompound2, active) => {
4627
4356
  var _a;
4628
4357
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4632,7 +4361,7 @@ var DraggableComponent = ({
4632
4361
  },
4633
4362
  [setLocalZones]
4634
4363
  );
4635
- const unregisterLocalZone = (0, import_react25.useCallback)(
4364
+ const unregisterLocalZone = (0, import_react26.useCallback)(
4636
4365
  (zoneCompound2) => {
4637
4366
  var _a;
4638
4367
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4655,14 +4384,17 @@ var DraggableComponent = ({
4655
4384
  return s.permissions.getPermissions({ item });
4656
4385
  })
4657
4386
  );
4658
- const userIsDragging = useContextStore(
4659
- ZoneStoreContext,
4660
- (s) => !!s.draggedItem
4387
+ const zoneStore = (0, import_react26.useContext)(ZoneStoreContext);
4388
+ const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
4389
+ const dynamicCollisionDetector = (0, import_react26.useMemo)(
4390
+ () => createDynamicCollisionDetector(dragAxis),
4391
+ [dragAxis]
4661
4392
  );
4662
- const canCollide = permissions.drag || userIsDragging;
4663
- const disabled = !isEnabled || !canCollide;
4664
- const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
4665
- const { ref: sortableRef, status } = useSortableSafe({
4393
+ const {
4394
+ ref: sortableRef,
4395
+ isDragging: thisIsDragging,
4396
+ sortable
4397
+ } = (0, import_sortable2.useSortable)({
4666
4398
  id,
4667
4399
  index,
4668
4400
  group: zoneCompound,
@@ -4677,18 +4409,34 @@ var DraggableComponent = ({
4677
4409
  path: path || [],
4678
4410
  inDroppableZone
4679
4411
  },
4680
- collisionPriority: isEnabled ? depth : 0,
4681
- collisionDetector: createDynamicCollisionDetector(dragAxis),
4682
- disabled,
4412
+ collisionPriority: depth,
4413
+ collisionDetector: dynamicCollisionDetector,
4683
4414
  // "Out of the way" transition from react-beautiful-dnd
4684
4415
  transition: {
4685
4416
  duration: 200,
4686
4417
  easing: "cubic-bezier(0.2, 0, 0, 1)"
4687
- }
4418
+ },
4419
+ feedback: "clone"
4688
4420
  });
4689
- const thisIsDragging = status === "dragging";
4690
- const ref = (0, import_react25.useRef)(null);
4691
- const refSetter = (0, import_react25.useCallback)(
4421
+ (0, import_react26.useEffect)(() => {
4422
+ const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
4423
+ sortable.droppable.disabled = !isEnabled;
4424
+ sortable.draggable.disabled = !permissions.drag;
4425
+ const cleanup = zoneStore.subscribe((s) => {
4426
+ sortable.droppable.disabled = !s.enabledIndex[zoneCompound];
4427
+ });
4428
+ if (ref.current && !permissions.drag) {
4429
+ ref.current.setAttribute("data-puck-disabled", "");
4430
+ return () => {
4431
+ var _a;
4432
+ (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4433
+ cleanup();
4434
+ };
4435
+ }
4436
+ return cleanup;
4437
+ }, [permissions.drag, zoneCompound]);
4438
+ const ref = (0, import_react26.useRef)(null);
4439
+ const refSetter = (0, import_react26.useCallback)(
4692
4440
  (el) => {
4693
4441
  sortableRef(el);
4694
4442
  if (el) {
@@ -4697,14 +4445,14 @@ var DraggableComponent = ({
4697
4445
  },
4698
4446
  [sortableRef]
4699
4447
  );
4700
- const [portalEl, setPortalEl] = (0, import_react25.useState)();
4701
- (0, import_react25.useEffect)(() => {
4448
+ const [portalEl, setPortalEl] = (0, import_react26.useState)();
4449
+ (0, import_react26.useEffect)(() => {
4702
4450
  var _a, _b, _c;
4703
4451
  setPortalEl(
4704
4452
  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
4705
4453
  );
4706
4454
  }, [iframe.enabled, ref.current]);
4707
- const getStyle = (0, import_react25.useCallback)(() => {
4455
+ const getStyle = (0, import_react26.useCallback)(() => {
4708
4456
  var _a, _b, _c;
4709
4457
  if (!ref.current) return;
4710
4458
  const rect = ref.current.getBoundingClientRect();
@@ -4716,40 +4464,61 @@ var DraggableComponent = ({
4716
4464
  x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
4717
4465
  y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
4718
4466
  };
4467
+ const untransformed = {
4468
+ height: ref.current.offsetHeight,
4469
+ width: ref.current.offsetWidth
4470
+ };
4471
+ const transform = accumulateTransform(ref.current);
4719
4472
  const style2 = {
4720
- left: `${rect.left + scroll.x}px`,
4721
- top: `${rect.top + scroll.y}px`,
4722
- height: `${rect.height}px`,
4723
- width: `${rect.width}px`
4473
+ left: `${(rect.left + scroll.x) / transform.scaleX}px`,
4474
+ top: `${(rect.top + scroll.y) / transform.scaleY}px`,
4475
+ height: `${untransformed.height}px`,
4476
+ width: `${untransformed.width}px`
4724
4477
  };
4725
4478
  return style2;
4726
4479
  }, [ref.current]);
4727
- const [style, setStyle] = (0, import_react25.useState)();
4728
- const sync = (0, import_react25.useCallback)(() => {
4480
+ const [style, setStyle] = (0, import_react26.useState)();
4481
+ const sync = (0, import_react26.useCallback)(() => {
4729
4482
  setStyle(getStyle());
4730
4483
  }, [ref.current, iframe]);
4731
- (0, import_react25.useEffect)(() => {
4732
- if (ref.current && !userIsDragging) {
4484
+ (0, import_react26.useEffect)(() => {
4485
+ if (ref.current) {
4733
4486
  const observer = new ResizeObserver(sync);
4734
4487
  observer.observe(ref.current);
4735
4488
  return () => {
4736
4489
  observer.disconnect();
4737
4490
  };
4738
4491
  }
4739
- }, [ref.current, userIsDragging]);
4492
+ }, [ref.current]);
4740
4493
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4741
- (0, import_react25.useEffect)(() => {
4494
+ const hideOverlay = (0, import_react26.useCallback)(() => {
4495
+ setIsVisible(false);
4496
+ }, []);
4497
+ const showOverlay = (0, import_react26.useCallback)(() => {
4498
+ setIsVisible(true);
4499
+ }, []);
4500
+ (0, import_react26.useEffect)(() => {
4742
4501
  var _a;
4743
- registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
4502
+ registerNode(id, {
4503
+ methods: { sync, showOverlay, hideOverlay },
4504
+ element: (_a = ref.current) != null ? _a : null
4505
+ });
4744
4506
  return () => {
4745
- registerNode(id, { methods: { sync: () => null }, element: null });
4507
+ registerNode(id, {
4508
+ methods: {
4509
+ sync: () => null,
4510
+ hideOverlay: () => null,
4511
+ showOverlay: () => null
4512
+ },
4513
+ element: null
4514
+ });
4746
4515
  };
4747
4516
  }, [id, zoneCompound, index, componentType, sync]);
4748
- const CustomActionBar = (0, import_react25.useMemo)(
4517
+ const CustomActionBar = (0, import_react26.useMemo)(
4749
4518
  () => overrides.actionBar || DefaultActionBar,
4750
4519
  [overrides.actionBar]
4751
4520
  );
4752
- const onClick = (0, import_react25.useCallback)(
4521
+ const onClick = (0, import_react26.useCallback)(
4753
4522
  (e) => {
4754
4523
  e.stopPropagation();
4755
4524
  dispatch({
@@ -4762,7 +4531,7 @@ var DraggableComponent = ({
4762
4531
  [index, zoneCompound, id]
4763
4532
  );
4764
4533
  const appStore = useAppStoreApi();
4765
- const onSelectParent = (0, import_react25.useCallback)(() => {
4534
+ const onSelectParent = (0, import_react26.useCallback)(() => {
4766
4535
  const { nodes, zones } = appStore.getState().state.indexes;
4767
4536
  const node = nodes[id];
4768
4537
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4783,28 +4552,32 @@ var DraggableComponent = ({
4783
4552
  }
4784
4553
  });
4785
4554
  }, [ctx, path]);
4786
- const onDuplicate = (0, import_react25.useCallback)(() => {
4555
+ const onDuplicate = (0, import_react26.useCallback)(() => {
4787
4556
  dispatch({
4788
4557
  type: "duplicate",
4789
4558
  sourceIndex: index,
4790
4559
  sourceZone: zoneCompound
4791
4560
  });
4792
4561
  }, [index, zoneCompound]);
4793
- const onDelete = (0, import_react25.useCallback)(() => {
4562
+ const onDelete = (0, import_react26.useCallback)(() => {
4794
4563
  dispatch({
4795
4564
  type: "remove",
4796
4565
  index,
4797
4566
  zone: zoneCompound
4798
4567
  });
4799
4568
  }, [index, zoneCompound]);
4800
- const [hover, setHover] = (0, import_react25.useState)(false);
4801
- const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4802
- (0, import_react25.useEffect)(() => {
4569
+ const [hover, setHover] = (0, import_react26.useState)(false);
4570
+ const indicativeHover = useContextStore(
4571
+ ZoneStoreContext,
4572
+ (s) => s.hoveringComponent === id
4573
+ );
4574
+ (0, import_react26.useEffect)(() => {
4803
4575
  if (!ref.current) {
4804
4576
  return;
4805
4577
  }
4806
4578
  const el = ref.current;
4807
4579
  const _onMouseOver = (e) => {
4580
+ const userIsDragging = !!zoneStore.getState().draggedItem;
4808
4581
  if (userIsDragging) {
4809
4582
  if (thisIsDragging) {
4810
4583
  setHover(true);
@@ -4826,18 +4599,12 @@ var DraggableComponent = ({
4826
4599
  el.addEventListener("click", onClick);
4827
4600
  el.addEventListener("mouseover", _onMouseOver);
4828
4601
  el.addEventListener("mouseout", _onMouseOut);
4829
- if (thisIsDragging) {
4830
- el.setAttribute("data-puck-dragging", "");
4831
- } else {
4832
- el.removeAttribute("data-puck-dragging");
4833
- }
4834
4602
  return () => {
4835
4603
  el.removeAttribute("data-puck-component");
4836
4604
  el.removeAttribute("data-puck-dnd");
4837
4605
  el.removeEventListener("click", onClick);
4838
4606
  el.removeEventListener("mouseover", _onMouseOver);
4839
4607
  el.removeEventListener("mouseout", _onMouseOut);
4840
- el.removeAttribute("data-puck-dragging");
4841
4608
  };
4842
4609
  }, [
4843
4610
  ref,
@@ -4845,29 +4612,43 @@ var DraggableComponent = ({
4845
4612
  containsActiveZone,
4846
4613
  zoneCompound,
4847
4614
  id,
4848
- userIsDragging,
4849
4615
  thisIsDragging,
4850
4616
  inDroppableZone
4851
4617
  ]);
4852
- (0, import_react25.useEffect)(() => {
4853
- if (ref.current && disabled) {
4854
- ref.current.setAttribute("data-puck-disabled", "");
4855
- return () => {
4856
- var _a;
4857
- (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4858
- };
4859
- }
4860
- }, [disabled, ref]);
4861
- const [isVisible, setIsVisible] = (0, import_react25.useState)(false);
4862
- (0, import_react25.useEffect)(() => {
4863
- sync();
4864
- if ((isSelected || hover || indicativeHover) && !userIsDragging) {
4865
- setIsVisible(true);
4618
+ const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
4619
+ const [dragFinished, setDragFinished] = (0, import_react26.useState)(true);
4620
+ const [_, startTransition] = (0, import_react26.useTransition)();
4621
+ (0, import_react26.useEffect)(() => {
4622
+ startTransition(() => {
4623
+ if (hover || indicativeHover || isSelected) {
4624
+ sync();
4625
+ setIsVisible(true);
4626
+ setThisWasDragging(false);
4627
+ } else {
4628
+ setIsVisible(false);
4629
+ }
4630
+ });
4631
+ }, [hover, indicativeHover, isSelected, iframe]);
4632
+ const [thisWasDragging, setThisWasDragging] = (0, import_react26.useState)(false);
4633
+ const onDragFinished = useOnDragFinished((finished) => {
4634
+ if (finished) {
4635
+ startTransition(() => {
4636
+ sync();
4637
+ setDragFinished(true);
4638
+ });
4866
4639
  } else {
4867
- setIsVisible(false);
4640
+ setDragFinished(false);
4641
+ }
4642
+ });
4643
+ (0, import_react26.useEffect)(() => {
4644
+ if (thisIsDragging) {
4645
+ setThisWasDragging(true);
4868
4646
  }
4869
- }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
4870
- const syncActionsPosition = (0, import_react25.useCallback)(
4647
+ }, [thisIsDragging]);
4648
+ (0, import_react26.useEffect)(() => {
4649
+ if (thisWasDragging) return onDragFinished();
4650
+ }, [thisWasDragging, onDragFinished]);
4651
+ const syncActionsPosition = (0, import_react26.useCallback)(
4871
4652
  (el) => {
4872
4653
  if (el) {
4873
4654
  const view = el.ownerDocument.defaultView;
@@ -4892,7 +4673,7 @@ var DraggableComponent = ({
4892
4673
  },
4893
4674
  [zoom]
4894
4675
  );
4895
- (0, import_react25.useEffect)(() => {
4676
+ (0, import_react26.useEffect)(() => {
4896
4677
  if (userDragAxis) {
4897
4678
  setDragAxis(userDragAxis);
4898
4679
  return;
@@ -4906,8 +4687,11 @@ var DraggableComponent = ({
4906
4687
  }
4907
4688
  setDragAxis(autoDragAxis);
4908
4689
  }, [ref, userDragAxis, autoDragAxis]);
4909
- const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) });
4910
- const nextContextValue = (0, import_react25.useMemo)(
4690
+ const parentAction = (0, import_react26.useMemo)(
4691
+ () => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) }),
4692
+ [ctx == null ? void 0 : ctx.areaId]
4693
+ );
4694
+ const nextContextValue = (0, import_react26.useMemo)(
4911
4695
  () => __spreadProps(__spreadValues({}, ctx), {
4912
4696
  areaId: id,
4913
4697
  zoneCompound,
@@ -4927,7 +4711,7 @@ var DraggableComponent = ({
4927
4711
  ]
4928
4712
  );
4929
4713
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
4930
- isVisible && (0, import_react_dom2.createPortal)(
4714
+ dragFinished && isVisible && (0, import_react_dom2.createPortal)(
4931
4715
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4932
4716
  "div",
4933
4717
  {
@@ -4987,19 +4771,23 @@ var DraggableComponent = ({
4987
4771
 
4988
4772
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
4989
4773
  init_react_import();
4990
- 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" };
4774
+ 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" };
4775
+
4776
+ // components/DropZone/index.tsx
4777
+ var import_react36 = require("@dnd-kit/react");
4991
4778
 
4992
4779
  // components/DropZone/lib/use-min-empty-height.ts
4993
4780
  init_react_import();
4994
- var import_react26 = require("react");
4781
+ var import_react27 = require("react");
4782
+ var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
4995
4783
  var useMinEmptyHeight = ({
4996
4784
  zoneCompound,
4997
4785
  userMinEmptyHeight,
4998
4786
  ref
4999
4787
  }) => {
5000
4788
  const appStore = useAppStoreApi();
5001
- const [prevHeight, setPrevHeight] = (0, import_react26.useState)(0);
5002
- const [isAnimating, setIsAnimating] = (0, import_react26.useState)(false);
4789
+ const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
4790
+ const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
5003
4791
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
5004
4792
  var _a, _b;
5005
4793
  return {
@@ -5007,32 +4795,52 @@ var useMinEmptyHeight = ({
5007
4795
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
5008
4796
  };
5009
4797
  });
5010
- (0, import_react26.useEffect)(() => {
4798
+ const numItems = (0, import_react27.useRef)(0);
4799
+ const onDragFinished = useOnDragFinished(
4800
+ (finished) => {
4801
+ var _a;
4802
+ if (finished) {
4803
+ const newNumItems = getNumItems(appStore, zoneCompound);
4804
+ setPrevHeight(0);
4805
+ if (newNumItems || numItems.current === 0) {
4806
+ setIsAnimating(false);
4807
+ return;
4808
+ }
4809
+ const selectedItem = appStore.getState().selectedItem;
4810
+ const zones = appStore.getState().state.indexes.zones;
4811
+ const nodes = appStore.getState().nodes;
4812
+ (_a = nodes.nodes[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.methods.hideOverlay();
4813
+ setTimeout(() => {
4814
+ var _a2;
4815
+ const contentIds = ((_a2 = zones[zoneCompound]) == null ? void 0 : _a2.contentIds) || [];
4816
+ contentIds.forEach((contentId) => {
4817
+ const node = nodes.nodes[contentId];
4818
+ node == null ? void 0 : node.methods.sync();
4819
+ });
4820
+ if (selectedItem) {
4821
+ setTimeout(() => {
4822
+ var _a3, _b;
4823
+ (_a3 = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _a3.methods.sync();
4824
+ (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.showOverlay();
4825
+ }, 200);
4826
+ }
4827
+ setIsAnimating(false);
4828
+ }, 100);
4829
+ }
4830
+ },
4831
+ [appStore, prevHeight, zoneCompound]
4832
+ );
4833
+ (0, import_react27.useEffect)(() => {
5011
4834
  if (draggedItem && ref.current) {
5012
4835
  if (isZone) {
5013
4836
  const rect = ref.current.getBoundingClientRect();
4837
+ numItems.current = getNumItems(appStore, zoneCompound);
5014
4838
  setPrevHeight(rect.height);
5015
4839
  setIsAnimating(true);
5016
- return;
4840
+ return onDragFinished();
5017
4841
  }
5018
4842
  }
5019
- setPrevHeight(0);
5020
- setTimeout(() => {
5021
- var _a, _b;
5022
- const zones = appStore.getState().state.indexes.zones;
5023
- const nodes = appStore.getState().nodes;
5024
- const selectedItem = appStore.getState().selectedItem;
5025
- const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
5026
- contentIds.forEach((contentId) => {
5027
- const node = nodes.nodes[contentId];
5028
- node == null ? void 0 : node.methods.sync();
5029
- });
5030
- if (selectedItem) {
5031
- (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
5032
- }
5033
- setIsAnimating(false);
5034
- }, 400);
5035
- }, [ref.current, draggedItem, zoneCompound]);
4843
+ }, [ref.current, draggedItem, onDragFinished]);
5036
4844
  return [prevHeight || userMinEmptyHeight, isAnimating];
5037
4845
  };
5038
4846
 
@@ -5053,15 +4861,15 @@ function assignRefs(refs, node) {
5053
4861
 
5054
4862
  // components/DropZone/lib/use-content-with-preview.ts
5055
4863
  init_react_import();
5056
- var import_react29 = require("react");
4864
+ var import_react30 = require("react");
5057
4865
 
5058
4866
  // lib/dnd/use-rendered-callback.ts
5059
4867
  init_react_import();
5060
- var import_react27 = require("@dnd-kit/react");
5061
- var import_react28 = require("react");
4868
+ var import_react28 = require("@dnd-kit/react");
4869
+ var import_react29 = require("react");
5062
4870
  function useRenderedCallback(callback, deps) {
5063
- const manager = (0, import_react27.useDragDropManager)();
5064
- return (0, import_react28.useCallback)(
4871
+ const manager = (0, import_react28.useDragDropManager)();
4872
+ return (0, import_react29.useCallback)(
5065
4873
  (...args) => __async(this, null, function* () {
5066
4874
  yield manager == null ? void 0 : manager.renderer.rendering;
5067
4875
  return callback(...args);
@@ -5072,27 +4880,21 @@ function useRenderedCallback(callback, deps) {
5072
4880
 
5073
4881
  // components/DropZone/lib/use-content-with-preview.ts
5074
4882
  var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5075
- const { draggedItemId, preview, previewExists } = useContextStore(
4883
+ const zoneStore = (0, import_react30.useContext)(ZoneStoreContext);
4884
+ const preview = useContextStore(
5076
4885
  ZoneStoreContext,
5077
- (s) => {
5078
- var _a;
5079
- return {
5080
- draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
5081
- preview: s.previewIndex[zoneCompound],
5082
- previewExists: Object.keys(s.previewIndex || {}).length > 0
5083
- };
5084
- }
4886
+ (s) => s.previewIndex[zoneCompound]
5085
4887
  );
5086
4888
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
5087
- const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react29.useState)(contentIds);
5088
- const [localPreview, setLocalPreview] = (0, import_react29.useState)(
4889
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
4890
+ const [localPreview, setLocalPreview] = (0, import_react30.useState)(
5089
4891
  preview
5090
4892
  );
5091
4893
  const updateContent = useRenderedCallback(
5092
- (contentIds2, preview2, isDragging2) => {
5093
- if (isDragging2 && !previewExists) {
5094
- return;
5095
- }
4894
+ (contentIds2, preview2) => {
4895
+ var _a;
4896
+ const s = zoneStore.getState();
4897
+ const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
5096
4898
  if (preview2) {
5097
4899
  if (preview2.type === "insert") {
5098
4900
  setContentIdsWithPreview(
@@ -5113,14 +4915,14 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5113
4915
  }
5114
4916
  } else {
5115
4917
  setContentIdsWithPreview(
5116
- previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
4918
+ contentIds2.filter((id) => id !== draggedItemId)
5117
4919
  );
5118
4920
  }
5119
4921
  setLocalPreview(preview2);
5120
4922
  },
5121
- [draggedItemId, previewExists]
4923
+ []
5122
4924
  );
5123
- (0, import_react29.useEffect)(() => {
4925
+ (0, import_react30.useEffect)(() => {
5124
4926
  updateContent(contentIds, preview, isDragging);
5125
4927
  }, [contentIds, preview, isDragging]);
5126
4928
  return [contentIdsWithPreview, localPreview];
@@ -5128,16 +4930,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5128
4930
 
5129
4931
  // components/DropZone/lib/use-drag-axis.ts
5130
4932
  init_react_import();
5131
- var import_react30 = require("react");
4933
+ var import_react31 = require("react");
5132
4934
  var GRID_DRAG_AXIS = "dynamic";
5133
4935
  var FLEX_ROW_DRAG_AXIS = "x";
5134
4936
  var DEFAULT_DRAG_AXIS = "y";
5135
4937
  var useDragAxis = (ref, collisionAxis) => {
5136
4938
  const status = useAppStore((s) => s.status);
5137
- const [dragAxis, setDragAxis] = (0, import_react30.useState)(
4939
+ const [dragAxis, setDragAxis] = (0, import_react31.useState)(
5138
4940
  collisionAxis || DEFAULT_DRAG_AXIS
5139
4941
  );
5140
- const calculateDragAxis = (0, import_react30.useCallback)(() => {
4942
+ const calculateDragAxis = (0, import_react31.useCallback)(() => {
5141
4943
  if (ref.current) {
5142
4944
  const computedStyle = window.getComputedStyle(ref.current);
5143
4945
  if (computedStyle.display === "grid") {
@@ -5149,7 +4951,7 @@ var useDragAxis = (ref, collisionAxis) => {
5149
4951
  }
5150
4952
  }
5151
4953
  }, [ref.current]);
5152
- (0, import_react30.useEffect)(() => {
4954
+ (0, import_react31.useEffect)(() => {
5153
4955
  const onViewportChange = () => {
5154
4956
  calculateDragAxis();
5155
4957
  };
@@ -5158,7 +4960,7 @@ var useDragAxis = (ref, collisionAxis) => {
5158
4960
  window.removeEventListener("viewportchange", onViewportChange);
5159
4961
  };
5160
4962
  }, []);
5161
- (0, import_react30.useEffect)(calculateDragAxis, [status, collisionAxis]);
4963
+ (0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
5162
4964
  return [dragAxis, calculateDragAxis];
5163
4965
  };
5164
4966
 
@@ -5170,9 +4972,9 @@ init_react_import();
5170
4972
 
5171
4973
  // lib/use-slots.tsx
5172
4974
  init_react_import();
5173
- var import_react31 = require("react");
4975
+ var import_react32 = require("react");
5174
4976
  function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
5175
- const slotProps = (0, import_react31.useMemo)(() => {
4977
+ const slotProps = (0, import_react32.useMemo)(() => {
5176
4978
  if (!(config == null ? void 0 : config.fields)) return props;
5177
4979
  const slotProps2 = {};
5178
4980
  const fieldKeys = Object.keys(config.fields);
@@ -5194,18 +4996,22 @@ function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEd
5194
4996
  }
5195
4997
  return slotProps2;
5196
4998
  }, [config, readOnly, forceReadOnly]);
5197
- return __spreadValues(__spreadValues({}, props), slotProps);
4999
+ const mergedProps = (0, import_react32.useMemo)(
5000
+ () => __spreadValues(__spreadValues({}, props), slotProps),
5001
+ [props, slotProps]
5002
+ );
5003
+ return mergedProps;
5198
5004
  }
5199
5005
 
5200
5006
  // components/Render/index.tsx
5201
- var import_react33 = __toESM(require("react"));
5007
+ var import_react34 = __toESM(require("react"));
5202
5008
 
5203
5009
  // components/SlotRender/index.tsx
5204
5010
  init_react_import();
5205
5011
 
5206
5012
  // components/SlotRender/server.tsx
5207
5013
  init_react_import();
5208
- var import_react32 = require("react");
5014
+ var import_react33 = require("react");
5209
5015
 
5210
5016
  // components/ServerRender/index.tsx
5211
5017
  init_react_import();
@@ -5271,7 +5077,7 @@ var Item = ({
5271
5077
  })
5272
5078
  );
5273
5079
  };
5274
- var SlotRender = (0, import_react32.forwardRef)(
5080
+ var SlotRender = (0, import_react33.forwardRef)(
5275
5081
  function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5276
5082
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
5277
5083
  if (!config.components[item.type]) {
@@ -5317,7 +5123,7 @@ var ContextSlotRender = ({
5317
5123
 
5318
5124
  // components/Render/index.tsx
5319
5125
  var import_jsx_runtime24 = require("react/jsx-runtime");
5320
- var renderContext = import_react33.default.createContext({
5126
+ var renderContext = import_react34.default.createContext({
5321
5127
  config: { components: {} },
5322
5128
  data: { root: {}, content: [] },
5323
5129
  metadata: {}
@@ -5346,7 +5152,7 @@ function Render({
5346
5152
  id: "puck-root"
5347
5153
  });
5348
5154
  const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
5349
- const nextContextValue = (0, import_react33.useMemo)(
5155
+ const nextContextValue = (0, import_react34.useMemo)(
5350
5156
  () => ({
5351
5157
  mode: "render",
5352
5158
  depth: 0
@@ -5368,17 +5174,16 @@ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5368
5174
  var DropZoneChild = ({
5369
5175
  zoneCompound,
5370
5176
  componentId,
5371
- preview,
5372
5177
  index,
5373
- isEnabled,
5374
5178
  dragAxis,
5375
5179
  collisionAxis,
5376
5180
  inDroppableZone
5377
5181
  }) => {
5378
5182
  var _a, _b;
5379
5183
  const metadata = useAppStore((s) => s.metadata);
5380
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5184
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5381
5185
  const { depth = 1 } = ctx != null ? ctx : {};
5186
+ const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5382
5187
  const nodeProps = useAppStore(
5383
5188
  (0, import_shallow3.useShallow)((s) => {
5384
5189
  var _a2;
@@ -5397,17 +5202,32 @@ var DropZoneChild = ({
5397
5202
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
5398
5203
  })
5399
5204
  );
5400
- const node = { type: nodeType, props: nodeProps };
5401
- const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
5205
+ const item = (0, import_react35.useMemo)(() => {
5206
+ if (nodeProps) {
5207
+ return { type: nodeType, props: nodeProps };
5208
+ }
5209
+ const preview = zoneStore.getState().previewIndex[zoneCompound];
5210
+ if (componentId === (preview == null ? void 0 : preview.props.id)) {
5211
+ return {
5212
+ type: preview.componentType,
5213
+ props: preview.props,
5214
+ previewType: preview.type
5215
+ };
5216
+ }
5217
+ return null;
5218
+ }, [componentId, zoneCompound, nodeType, nodeProps]);
5402
5219
  const componentConfig = useAppStore(
5403
5220
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
5404
5221
  );
5405
- const puckProps = {
5406
- renderDropZone: DropZoneEditPure,
5407
- isEditing: true,
5408
- dragRef: null,
5409
- metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5410
- };
5222
+ const puckProps = (0, import_react35.useMemo)(
5223
+ () => ({
5224
+ renderDropZone: DropZoneEditPure,
5225
+ isEditing: true,
5226
+ dragRef: null,
5227
+ metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5228
+ }),
5229
+ [metadata, componentConfig == null ? void 0 : componentConfig.metadata]
5230
+ );
5411
5231
  const overrides = useAppStore((s) => s.overrides);
5412
5232
  const isLoading = useAppStore(
5413
5233
  (s) => {
@@ -5422,13 +5242,13 @@ var DropZoneChild = ({
5422
5242
  }
5423
5243
  );
5424
5244
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
5425
- const renderPreview = (0, import_react34.useMemo)(
5426
- () => function Preview4() {
5245
+ const renderPreview = (0, import_react35.useMemo)(
5246
+ () => function Preview3() {
5427
5247
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
5428
5248
  },
5429
5249
  [componentId, label, overrides]
5430
5250
  );
5431
- const defaultsProps = (0, import_react34.useMemo)(
5251
+ const defaultsProps = (0, import_react35.useMemo)(
5432
5252
  () => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
5433
5253
  puck: puckProps,
5434
5254
  editMode: true
@@ -5450,8 +5270,8 @@ var DropZoneChild = ({
5450
5270
  item.type
5451
5271
  ] });
5452
5272
  let componentType = item.type;
5453
- const isPreview = componentId === (preview == null ? void 0 : preview.props.id) && preview.type === "insert";
5454
- if (isPreview) {
5273
+ const isInserting = item.previewType === "insert";
5274
+ if (isInserting) {
5455
5275
  Render2 = renderPreview;
5456
5276
  }
5457
5277
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -5465,11 +5285,10 @@ var DropZoneChild = ({
5465
5285
  isLoading,
5466
5286
  isSelected,
5467
5287
  label,
5468
- isEnabled,
5469
5288
  autoDragAxis: dragAxis,
5470
5289
  userDragAxis: collisionAxis,
5471
5290
  inDroppableZone,
5472
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5291
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5473
5292
  Render2,
5474
5293
  __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
5475
5294
  puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
@@ -5480,8 +5299,8 @@ var DropZoneChild = ({
5480
5299
  }
5481
5300
  );
5482
5301
  };
5483
- var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
5484
- var DropZoneEdit = (0, import_react34.forwardRef)(
5302
+ var DropZoneChildMemo = (0, import_react35.memo)(DropZoneChild);
5303
+ var DropZoneEdit = (0, import_react35.forwardRef)(
5485
5304
  function DropZoneEditInternal({
5486
5305
  zone,
5487
5306
  allow,
@@ -5491,7 +5310,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5491
5310
  minEmptyHeight: userMinEmptyHeight = 128,
5492
5311
  collisionAxis
5493
5312
  }, userRef) {
5494
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5313
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5495
5314
  const {
5496
5315
  // These all need setting via context
5497
5316
  areaId,
@@ -5512,20 +5331,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5512
5331
  }
5513
5332
  }
5514
5333
  const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
5515
- const {
5516
- isDeepestZone,
5517
- inNextDeepestArea,
5518
- draggedComponentType,
5519
- userIsDragging
5520
- } = useContextStore(ZoneStoreContext, (s) => {
5521
- var _a, _b;
5522
- return {
5523
- isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
5524
- inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
5525
- draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
5526
- userIsDragging: !!s.draggedItem
5527
- };
5528
- });
5334
+ const inNextDeepestArea = useContextStore(
5335
+ ZoneStoreContext,
5336
+ (s) => s.nextAreaDepthIndex[areaId || ""]
5337
+ );
5529
5338
  const zoneContentIds = useAppStore(
5530
5339
  (0, import_shallow3.useShallow)((s) => {
5531
5340
  var _a;
@@ -5538,7 +5347,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5538
5347
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
5539
5348
  })
5540
5349
  );
5541
- (0, import_react34.useEffect)(() => {
5350
+ (0, import_react35.useEffect)(() => {
5542
5351
  if (!zoneType || zoneType === "dropzone") {
5543
5352
  if (ctx == null ? void 0 : ctx.registerZone) {
5544
5353
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
@@ -5550,7 +5359,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5550
5359
  };
5551
5360
  }
5552
5361
  }, [zoneType]);
5553
- (0, import_react34.useEffect)(() => {
5362
+ (0, import_react35.useEffect)(() => {
5554
5363
  if (zoneType === "dropzone") {
5555
5364
  if (zoneCompound !== rootDroppableId) {
5556
5365
  console.warn(
@@ -5559,11 +5368,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5559
5368
  }
5560
5369
  }
5561
5370
  }, [zoneType]);
5562
- const contentIds = (0, import_react34.useMemo)(() => {
5371
+ const contentIds = (0, import_react35.useMemo)(() => {
5563
5372
  return zoneContentIds || [];
5564
5373
  }, [zoneContentIds]);
5565
- const ref = (0, import_react34.useRef)(null);
5566
- const acceptsTarget = (0, import_react34.useCallback)(
5374
+ const ref = (0, import_react35.useRef)(null);
5375
+ const acceptsTarget = (0, import_react35.useCallback)(
5567
5376
  (componentType) => {
5568
5377
  if (!componentType) {
5569
5378
  return true;
@@ -5585,29 +5394,44 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5585
5394
  },
5586
5395
  [allow, disallow]
5587
5396
  );
5588
- (0, import_react34.useEffect)(() => {
5397
+ const targetAccepted = useContextStore(ZoneStoreContext, (s) => {
5398
+ var _a;
5399
+ const draggedComponentType = (_a = s.draggedItem) == null ? void 0 : _a.data.componentType;
5400
+ return acceptsTarget(draggedComponentType);
5401
+ });
5402
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
5403
+ const isEnabled = useContextStore(ZoneStoreContext, (s) => {
5404
+ var _a;
5405
+ let _isEnabled = true;
5406
+ const isDeepestZone = (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false;
5407
+ _isEnabled = isDeepestZone;
5408
+ if (_isEnabled) {
5409
+ _isEnabled = targetAccepted;
5410
+ }
5411
+ return _isEnabled;
5412
+ });
5413
+ (0, import_react35.useEffect)(() => {
5589
5414
  if (registerLocalZone) {
5590
- registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
5415
+ registerLocalZone(zoneCompound, isEnabled);
5591
5416
  }
5592
5417
  return () => {
5593
5418
  if (unregisterLocalZone) {
5594
5419
  unregisterLocalZone(zoneCompound);
5595
5420
  }
5596
5421
  };
5597
- }, [draggedComponentType, zoneCompound]);
5598
- const hoveringOverArea = inNextDeepestArea || isRootZone;
5599
- let isEnabled = true;
5600
- if (userIsDragging) {
5601
- isEnabled = isDeepestZone;
5602
- }
5603
- if (isEnabled) {
5604
- isEnabled = acceptsTarget(draggedComponentType);
5605
- }
5422
+ }, [isEnabled, zoneCompound]);
5606
5423
  const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
5607
5424
  contentIds,
5608
5425
  zoneCompound
5609
5426
  );
5610
5427
  const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
5428
+ const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5429
+ (0, import_react35.useEffect)(() => {
5430
+ const { enabledIndex } = zoneStore.getState();
5431
+ zoneStore.setState({
5432
+ enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
5433
+ });
5434
+ }, [isEnabled, zoneStore, zoneCompound]);
5611
5435
  const droppableConfig = {
5612
5436
  id: zoneCompound,
5613
5437
  collisionPriority: isEnabled ? depth : 0,
@@ -5617,11 +5441,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5617
5441
  data: {
5618
5442
  areaId,
5619
5443
  depth,
5620
- isDroppableTarget: acceptsTarget(draggedComponentType),
5444
+ isDroppableTarget: targetAccepted,
5621
5445
  path: path || []
5622
5446
  }
5623
5447
  };
5624
- const { ref: dropRef } = useDroppableSafe(droppableConfig);
5448
+ const { ref: dropRef } = (0, import_react36.useDroppable)(droppableConfig);
5625
5449
  const isAreaSelected = useAppStore(
5626
5450
  (s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
5627
5451
  );
@@ -5636,7 +5460,6 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5636
5460
  {
5637
5461
  className: `${getClassName17({
5638
5462
  isRootZone,
5639
- userIsDragging,
5640
5463
  hoveringOverArea,
5641
5464
  isEnabled,
5642
5465
  isAreaSelected,
@@ -5658,12 +5481,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5658
5481
  {
5659
5482
  zoneCompound,
5660
5483
  componentId,
5661
- preview,
5662
5484
  dragAxis,
5663
- isEnabled,
5664
5485
  index: i,
5665
5486
  collisionAxis,
5666
- inDroppableZone: acceptsTarget(draggedComponentType)
5487
+ inDroppableZone: targetAccepted
5667
5488
  },
5668
5489
  componentId
5669
5490
  );
@@ -5679,7 +5500,7 @@ var DropZoneRenderItem = ({
5679
5500
  }) => {
5680
5501
  const Component = config.components[item.type];
5681
5502
  const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5682
- const nextContextValue = (0, import_react34.useMemo)(
5503
+ const nextContextValue = (0, import_react35.useMemo)(
5683
5504
  () => ({
5684
5505
  areaId: props.id,
5685
5506
  depth: 1
@@ -5697,14 +5518,14 @@ var DropZoneRenderItem = ({
5697
5518
  ) }, props.id);
5698
5519
  };
5699
5520
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
5700
- var DropZoneRender2 = (0, import_react34.forwardRef)(
5521
+ var DropZoneRender2 = (0, import_react35.forwardRef)(
5701
5522
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5702
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5523
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5703
5524
  const { areaId = "root" } = ctx || {};
5704
- const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
5525
+ const { config, data, metadata } = (0, import_react35.useContext)(renderContext);
5705
5526
  let zoneCompound = rootDroppableId;
5706
5527
  let content = (data == null ? void 0 : data.content) || [];
5707
- (0, import_react34.useEffect)(() => {
5528
+ (0, import_react35.useEffect)(() => {
5708
5529
  if (!content) {
5709
5530
  if (ctx == null ? void 0 : ctx.registerZone) {
5710
5531
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
@@ -5741,9 +5562,9 @@ var DropZoneRender2 = (0, import_react34.forwardRef)(
5741
5562
  }
5742
5563
  );
5743
5564
  var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
5744
- var DropZone = (0, import_react34.forwardRef)(
5565
+ var DropZone = (0, import_react35.forwardRef)(
5745
5566
  function DropZone2(props, ref) {
5746
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5567
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5747
5568
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5748
5569
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5749
5570
  }
@@ -5753,8 +5574,7 @@ var DropZone = (0, import_react34.forwardRef)(
5753
5574
 
5754
5575
  // lib/dnd/NestedDroppablePlugin.ts
5755
5576
  init_react_import();
5756
- var import_abstract10 = require("@dnd-kit/abstract");
5757
- var import_state2 = require("@dnd-kit/state");
5577
+ var import_abstract9 = require("@dnd-kit/abstract");
5758
5578
 
5759
5579
  // lib/throttle.ts
5760
5580
  init_react_import();
@@ -5908,7 +5728,8 @@ var getPointerCollisions = (position, manager) => {
5908
5728
  const element = elements[i];
5909
5729
  const dropzoneId = element.getAttribute("data-puck-dropzone");
5910
5730
  const id = element.getAttribute("data-puck-dnd");
5911
- if (BUFFER && (dropzoneId || id)) {
5731
+ const isVoid = element.hasAttribute("data-puck-dnd-void");
5732
+ if (BUFFER && (dropzoneId || id) && !isVoid) {
5912
5733
  const box = element.getBoundingClientRect();
5913
5734
  const contractedBox = {
5914
5735
  left: box.left + BUFFER,
@@ -5983,13 +5804,13 @@ var findDeepestCandidate = (position, manager) => {
5983
5804
  area: rootAreaId
5984
5805
  };
5985
5806
  };
5986
- var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract10.Plugin {
5807
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
5987
5808
  constructor(manager, options) {
5988
5809
  super(manager);
5989
5810
  if (typeof window === "undefined") {
5990
5811
  return;
5991
5812
  }
5992
- const cleanupEffect = (0, import_state2.effects)(() => {
5813
+ this.registerEffect(() => {
5993
5814
  const handleMove = (event) => {
5994
5815
  const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
5995
5816
  const position = new GlobalPosition(target, {
@@ -6013,12 +5834,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
6013
5834
  capture: true
6014
5835
  // dndkit's PointerSensor prevents propagation during drag
6015
5836
  });
6016
- this.destroy = () => {
5837
+ const cleanup = () => {
6017
5838
  document.body.removeEventListener("pointermove", handlePointerMove, {
6018
5839
  capture: true
6019
5840
  });
6020
- cleanupEffect();
6021
5841
  };
5842
+ return cleanup;
6022
5843
  });
6023
5844
  }
6024
5845
  };
@@ -6078,14 +5899,15 @@ function getDeepDir(el) {
6078
5899
  }
6079
5900
 
6080
5901
  // components/DragDropContext/index.tsx
5902
+ var import_state = require("@dnd-kit/state");
6081
5903
  var import_jsx_runtime26 = require("react/jsx-runtime");
6082
5904
  var DEBUG3 = false;
6083
- var dragListenerContext = (0, import_react36.createContext)({
5905
+ var dragListenerContext = (0, import_react38.createContext)({
6084
5906
  dragListeners: {}
6085
5907
  });
6086
5908
  function useDragListener(type, fn, deps = []) {
6087
- const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
6088
- (0, import_react36.useEffect)(() => {
5909
+ const { setDragListeners } = (0, import_react38.useContext)(dragListenerContext);
5910
+ (0, import_react38.useEffect)(() => {
6089
5911
  if (setDragListeners) {
6090
5912
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
6091
5913
  [type]: [...old[type] || [], fn]
@@ -6095,8 +5917,8 @@ function useDragListener(type, fn, deps = []) {
6095
5917
  }
6096
5918
  var AREA_CHANGE_DEBOUNCE_MS = 100;
6097
5919
  var useTempDisableFallback = (timeout3) => {
6098
- const lastFallbackDisable = (0, import_react36.useRef)(null);
6099
- return (0, import_react36.useCallback)((manager) => {
5920
+ const lastFallbackDisable = (0, import_react38.useRef)(null);
5921
+ return (0, import_react38.useCallback)((manager) => {
6100
5922
  collisionStore.setState({ fallbackEnabled: false });
6101
5923
  const fallbackId = generateId();
6102
5924
  lastFallbackDisable.current = fallbackId;
@@ -6115,19 +5937,21 @@ var DragDropContextClient = ({
6115
5937
  const dispatch = useAppStore((s) => s.dispatch);
6116
5938
  const appStore = useAppStoreApi();
6117
5939
  const id = useSafeId();
6118
- const debouncedParamsRef = (0, import_react36.useRef)(null);
5940
+ const debouncedParamsRef = (0, import_react38.useRef)(null);
6119
5941
  const tempDisableFallback = useTempDisableFallback(100);
6120
- const [zoneStore] = (0, import_react36.useState)(
5942
+ const [zoneStore] = (0, import_react38.useState)(
6121
5943
  () => (0, import_zustand5.createStore)(() => ({
6122
5944
  zoneDepthIndex: {},
6123
5945
  nextZoneDepthIndex: {},
6124
5946
  areaDepthIndex: {},
6125
5947
  nextAreaDepthIndex: {},
6126
5948
  draggedItem: null,
6127
- previewIndex: {}
5949
+ previewIndex: {},
5950
+ enabledIndex: {},
5951
+ hoveringComponent: null
6128
5952
  }))
6129
5953
  );
6130
- const getChanged2 = (0, import_react36.useCallback)(
5954
+ const getChanged2 = (0, import_react38.useCallback)(
6131
5955
  (params, id2) => {
6132
5956
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
6133
5957
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -6148,7 +5972,7 @@ var DragDropContextClient = ({
6148
5972
  },
6149
5973
  [zoneStore]
6150
5974
  );
6151
- const setDeepestAndCollide = (0, import_react36.useCallback)(
5975
+ const setDeepestAndCollide = (0, import_react38.useCallback)(
6152
5976
  (params, manager) => {
6153
5977
  const { zoneChanged, areaChanged } = getChanged2(params, id);
6154
5978
  if (!zoneChanged && !areaChanged) return;
@@ -6172,7 +5996,7 @@ var DragDropContextClient = ({
6172
5996
  setDeepestDb.cancel();
6173
5997
  debouncedParamsRef.current = null;
6174
5998
  };
6175
- (0, import_react36.useEffect)(() => {
5999
+ (0, import_react38.useEffect)(() => {
6176
6000
  if (DEBUG3) {
6177
6001
  zoneStore.subscribe(
6178
6002
  (s) => {
@@ -6186,7 +6010,7 @@ var DragDropContextClient = ({
6186
6010
  );
6187
6011
  }
6188
6012
  }, []);
6189
- const [plugins] = (0, import_react36.useState)(() => [
6013
+ const [plugins] = (0, import_react38.useState)(() => [
6190
6014
  ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
6191
6015
  createNestedDroppablePlugin(
6192
6016
  {
@@ -6234,10 +6058,10 @@ var DragDropContextClient = ({
6234
6058
  )
6235
6059
  ]);
6236
6060
  const sensors = useSensors();
6237
- const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
6238
- const dragMode = (0, import_react36.useRef)(null);
6239
- const initialSelector = (0, import_react36.useRef)(void 0);
6240
- const nextContextValue = (0, import_react36.useMemo)(
6061
+ const [dragListeners, setDragListeners] = (0, import_react38.useState)({});
6062
+ const dragMode = (0, import_react38.useRef)(null);
6063
+ const initialSelector = (0, import_react38.useRef)(void 0);
6064
+ const nextContextValue = (0, import_react38.useMemo)(
6241
6065
  () => ({
6242
6066
  mode: "edit",
6243
6067
  areaId: "root",
@@ -6253,12 +6077,14 @@ var DragDropContextClient = ({
6253
6077
  setDragListeners
6254
6078
  },
6255
6079
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6256
- import_react35.DragDropProvider,
6080
+ import_react37.DragDropProvider,
6257
6081
  {
6258
6082
  plugins,
6259
6083
  sensors,
6260
6084
  onDragEnd: (event, manager) => {
6261
- var _a;
6085
+ var _a, _b;
6086
+ const entryEl = (_a = getFrame()) == null ? void 0 : _a.querySelector("[data-puck-entry]");
6087
+ entryEl == null ? void 0 : entryEl.removeAttribute("data-puck-dragging");
6262
6088
  const { source, target } = event.operation;
6263
6089
  if (!source) {
6264
6090
  zoneStore.setState({ draggedItem: null });
@@ -6266,9 +6092,9 @@ var DragDropContextClient = ({
6266
6092
  }
6267
6093
  const { zone, index } = source.data;
6268
6094
  const { previewIndex = {} } = zoneStore.getState() || {};
6269
- const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
6270
- setTimeout(() => {
6271
- var _a2, _b;
6095
+ const thisPreview = ((_b = previewIndex[zone]) == null ? void 0 : _b.props.id) === source.id ? previewIndex[zone] : null;
6096
+ const onAnimationEnd = () => {
6097
+ var _a2, _b2;
6272
6098
  zoneStore.setState({ draggedItem: null });
6273
6099
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
6274
6100
  zoneStore.setState({ previewIndex: {} });
@@ -6304,23 +6130,28 @@ var DragDropContextClient = ({
6304
6130
  });
6305
6131
  }
6306
6132
  }
6307
- setTimeout(() => {
6308
- dispatch({
6309
- type: "setUi",
6310
- ui: {
6311
- itemSelector: { index, zone },
6312
- isDragging: false
6313
- },
6314
- recordHistory: true
6315
- });
6316
- }, 50);
6317
- (_b = dragListeners.dragend) == null ? void 0 : _b.forEach((fn) => {
6133
+ dispatch({
6134
+ type: "setUi",
6135
+ ui: {
6136
+ itemSelector: { index, zone },
6137
+ isDragging: false
6138
+ },
6139
+ recordHistory: true
6140
+ });
6141
+ (_b2 = dragListeners.dragend) == null ? void 0 : _b2.forEach((fn) => {
6318
6142
  fn(event, manager);
6319
6143
  });
6320
- }, 250);
6144
+ };
6145
+ let dispose;
6146
+ dispose = (0, import_state.effect)(() => {
6147
+ if (source.status === "idle") {
6148
+ onAnimationEnd();
6149
+ dispose == null ? void 0 : dispose();
6150
+ }
6151
+ });
6321
6152
  },
6322
6153
  onDragOver: (event, manager) => {
6323
- var _a, _b, _c, _d, _e;
6154
+ var _a, _b, _c, _d;
6324
6155
  event.preventDefault();
6325
6156
  const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
6326
6157
  if (!draggedItem) return;
@@ -6338,7 +6169,7 @@ var DragDropContextClient = ({
6338
6169
  const targetData = target.data;
6339
6170
  targetZone = targetData.zone;
6340
6171
  targetIndex = targetData.index;
6341
- const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
6172
+ const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
6342
6173
  const dir = getDeepDir(target.element);
6343
6174
  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";
6344
6175
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
@@ -6351,7 +6182,7 @@ var DragDropContextClient = ({
6351
6182
  targetZone = target.id.toString();
6352
6183
  targetIndex = 0;
6353
6184
  }
6354
- const path = ((_d = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _d.path) || [];
6185
+ const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
6355
6186
  if (targetId === sourceId || path.find((path2) => {
6356
6187
  const [pathId] = path2.split(":");
6357
6188
  return pathId === sourceId;
@@ -6397,16 +6228,12 @@ var DragDropContextClient = ({
6397
6228
  });
6398
6229
  }
6399
6230
  }
6400
- (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
6231
+ (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
6401
6232
  fn(event, manager);
6402
6233
  });
6403
6234
  },
6404
6235
  onDragStart: (event, manager) => {
6405
6236
  var _a;
6406
- dispatch({
6407
- type: "setUi",
6408
- ui: { itemSelector: null, isDragging: true }
6409
- });
6410
6237
  const { source } = event.operation;
6411
6238
  if (source && source.type !== "void") {
6412
6239
  const sourceData = source.data;
@@ -6436,11 +6263,31 @@ var DragDropContextClient = ({
6436
6263
  });
6437
6264
  },
6438
6265
  onBeforeDragStart: (event) => {
6439
- var _a;
6440
- const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
6266
+ var _a, _b, _c, _d;
6267
+ const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
6441
6268
  dragMode.current = isNewComponent ? "new" : "existing";
6442
6269
  initialSelector.current = void 0;
6443
6270
  zoneStore.setState({ draggedItem: event.operation.source });
6271
+ if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== ((_c = event.operation.source) == null ? void 0 : _c.id)) {
6272
+ dispatch({
6273
+ type: "setUi",
6274
+ ui: {
6275
+ itemSelector: null,
6276
+ isDragging: true
6277
+ },
6278
+ recordHistory: false
6279
+ });
6280
+ } else {
6281
+ dispatch({
6282
+ type: "setUi",
6283
+ ui: {
6284
+ isDragging: true
6285
+ },
6286
+ recordHistory: false
6287
+ });
6288
+ }
6289
+ const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
6290
+ entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
6444
6291
  },
6445
6292
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
6446
6293
  }
@@ -6460,6 +6307,7 @@ var DragDropContext = ({
6460
6307
  };
6461
6308
 
6462
6309
  // components/Drawer/index.tsx
6310
+ var import_react40 = require("@dnd-kit/react");
6463
6311
  var import_jsx_runtime27 = require("react/jsx-runtime");
6464
6312
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
6465
6313
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
@@ -6470,7 +6318,7 @@ var DrawerItemInner = ({
6470
6318
  dragRef,
6471
6319
  isDragDisabled
6472
6320
  }) => {
6473
- const CustomInner = (0, import_react37.useMemo)(
6321
+ const CustomInner = (0, import_react39.useMemo)(
6474
6322
  () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
6475
6323
  [children]
6476
6324
  );
@@ -6496,10 +6344,11 @@ var DrawerItemDraggable = ({
6496
6344
  id,
6497
6345
  isDragDisabled
6498
6346
  }) => {
6499
- const { ref } = useDraggableSafe({
6347
+ const { ref } = (0, import_react40.useDraggable)({
6500
6348
  id,
6501
- data: { type: "drawer", componentType: name },
6502
- disabled: isDragDisabled
6349
+ data: { componentType: name },
6350
+ disabled: isDragDisabled,
6351
+ type: "drawer"
6503
6352
  });
6504
6353
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName18("draggable"), children: [
6505
6354
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name, label, children }) }),
@@ -6524,7 +6373,7 @@ var DrawerItem = ({
6524
6373
  isDragDisabled
6525
6374
  }) => {
6526
6375
  const resolvedId = id || name;
6527
- const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
6376
+ const [dynamicId, setDynamicId] = (0, import_react39.useState)(generateId(resolvedId));
6528
6377
  if (typeof index !== "undefined") {
6529
6378
  console.error(
6530
6379
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -6564,7 +6413,7 @@ var Drawer = ({
6564
6413
  );
6565
6414
  }
6566
6415
  const id = useSafeId();
6567
- const { ref } = useDroppableSafe({
6416
+ const { ref } = (0, import_react40.useDroppable)({
6568
6417
  id,
6569
6418
  type: "void",
6570
6419
  collisionPriority: 0
@@ -6577,6 +6426,7 @@ var Drawer = ({
6577
6426
  ref,
6578
6427
  "data-puck-dnd": id,
6579
6428
  "data-puck-drawer": true,
6429
+ "data-puck-dnd-void": true,
6580
6430
  children
6581
6431
  }
6582
6432
  );
@@ -6585,7 +6435,7 @@ Drawer.Item = DrawerItem;
6585
6435
 
6586
6436
  // components/Puck/index.tsx
6587
6437
  init_react_import();
6588
- var import_react52 = require("react");
6438
+ var import_react56 = require("react");
6589
6439
 
6590
6440
  // components/SidebarSection/index.tsx
6591
6441
  init_react_import();
@@ -6596,7 +6446,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
6596
6446
 
6597
6447
  // lib/use-breadcrumbs.ts
6598
6448
  init_react_import();
6599
- var import_react38 = require("react");
6449
+ var import_react41 = require("react");
6600
6450
  var useBreadcrumbs = (renderCount) => {
6601
6451
  const selectedId = useAppStore((s) => {
6602
6452
  var _a;
@@ -6608,7 +6458,7 @@ var useBreadcrumbs = (renderCount) => {
6608
6458
  return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
6609
6459
  });
6610
6460
  const appStore = useAppStoreApi();
6611
- return (0, import_react38.useMemo)(() => {
6461
+ return (0, import_react41.useMemo)(() => {
6612
6462
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6613
6463
  var _a, _b, _c;
6614
6464
  const [componentId] = zoneCompound.split(":");
@@ -6680,70 +6530,26 @@ var SidebarSection = ({
6680
6530
  );
6681
6531
  };
6682
6532
 
6683
- // components/MenuBar/index.tsx
6684
- init_react_import();
6685
-
6686
- // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
6687
- init_react_import();
6688
- 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" };
6689
-
6690
- // components/MenuBar/index.tsx
6691
- var import_jsx_runtime29 = require("react/jsx-runtime");
6692
- var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
6693
- function MenuBar({
6694
- menuOpen = false,
6695
- renderHeaderActions,
6696
- setMenuOpen
6697
- }) {
6698
- const back = useAppStore((s) => s.history.back);
6699
- const forward = useAppStore((s) => s.history.forward);
6700
- const hasFuture = useAppStore((s) => s.history.hasFuture());
6701
- const hasPast = useAppStore((s) => s.history.hasPast());
6702
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6703
- "div",
6704
- {
6705
- className: getClassName20({ menuOpen }),
6706
- onClick: (event) => {
6707
- var _a;
6708
- const element = event.target;
6709
- if (window.matchMedia("(min-width: 638px)").matches) {
6710
- return;
6711
- }
6712
- if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
6713
- setMenuOpen(false);
6714
- }
6715
- },
6716
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("inner"), children: [
6717
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("history"), children: [
6718
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Undo2, { size: 21 }) }),
6719
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Redo2, { size: 21 }) })
6720
- ] }),
6721
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: renderHeaderActions && renderHeaderActions() })
6722
- ] })
6723
- }
6724
- );
6725
- }
6726
-
6727
6533
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6728
6534
  init_react_import();
6729
- 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" };
6535
+ 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" };
6730
6536
 
6731
6537
  // components/Puck/components/Fields/index.tsx
6732
6538
  init_react_import();
6733
6539
 
6734
6540
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
6735
6541
  init_react_import();
6736
- 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" };
6542
+ 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" };
6737
6543
 
6738
6544
  // components/Puck/components/Fields/index.tsx
6739
- var import_react39 = require("react");
6545
+ var import_react42 = require("react");
6740
6546
  var import_shallow4 = require("zustand/react/shallow");
6741
- var import_jsx_runtime30 = require("react/jsx-runtime");
6742
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
6547
+ var import_jsx_runtime29 = require("react/jsx-runtime");
6548
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
6743
6549
  var DefaultFields = ({
6744
6550
  children
6745
6551
  }) => {
6746
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
6552
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
6747
6553
  };
6748
6554
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6749
6555
  let currentProps;
@@ -6809,12 +6615,12 @@ var FieldsChild = ({ fieldName }) => {
6809
6615
  })
6810
6616
  );
6811
6617
  const appStore = useAppStoreApi();
6812
- const onChange = (0, import_react39.useCallback)(createOnChange(fieldName, appStore), [
6618
+ const onChange = (0, import_react42.useCallback)(createOnChange(fieldName, appStore), [
6813
6619
  fieldName
6814
6620
  ]);
6815
6621
  if (!field || !id) return null;
6816
6622
  if (field.type === "slot") return null;
6817
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6623
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("field"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6818
6624
  AutoFieldPrivate,
6819
6625
  {
6820
6626
  field,
@@ -6826,7 +6632,8 @@ var FieldsChild = ({ fieldName }) => {
6826
6632
  }
6827
6633
  ) }, id);
6828
6634
  };
6829
- var Fields = ({ wrapFields = true }) => {
6635
+ var FieldsChildMemo = (0, import_react42.memo)(FieldsChild);
6636
+ var FieldsInternal = ({ wrapFields = true }) => {
6830
6637
  const overrides = useAppStore((s) => s.overrides);
6831
6638
  const componentResolving = useAppStore((s) => {
6832
6639
  var _a, _b;
@@ -6850,39 +6657,40 @@ var Fields = ({ wrapFields = true }) => {
6850
6657
  })
6851
6658
  );
6852
6659
  const isLoading = fieldsLoading || componentResolving;
6853
- const Wrapper = (0, import_react39.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6854
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6660
+ const Wrapper = (0, import_react42.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6661
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6855
6662
  "form",
6856
6663
  {
6857
- className: getClassName21({ wrapFields }),
6664
+ className: getClassName20({ wrapFields }),
6858
6665
  onSubmit: (e) => {
6859
6666
  e.preventDefault();
6860
6667
  },
6861
6668
  children: [
6862
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChild, { fieldName }, fieldName)) }),
6863
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 16 }) }) })
6669
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
6670
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) }) })
6864
6671
  ]
6865
6672
  }
6866
6673
  );
6867
6674
  };
6675
+ var Fields = (0, import_react42.memo)(FieldsInternal);
6868
6676
 
6869
6677
  // components/Puck/components/Components/index.tsx
6870
6678
  init_react_import();
6871
6679
 
6872
6680
  // lib/use-component-list.tsx
6873
6681
  init_react_import();
6874
- var import_react40 = require("react");
6682
+ var import_react43 = require("react");
6875
6683
 
6876
6684
  // components/ComponentList/index.tsx
6877
6685
  init_react_import();
6878
6686
 
6879
6687
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6880
6688
  init_react_import();
6881
- 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" };
6689
+ 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" };
6882
6690
 
6883
6691
  // components/ComponentList/index.tsx
6884
- var import_jsx_runtime31 = require("react/jsx-runtime");
6885
- var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
6692
+ var import_jsx_runtime30 = require("react/jsx-runtime");
6693
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
6886
6694
  var ComponentListItem = ({
6887
6695
  name,
6888
6696
  label
@@ -6893,7 +6701,7 @@ var ComponentListItem = ({
6893
6701
  type: name
6894
6702
  }).insert
6895
6703
  );
6896
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6704
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6897
6705
  };
6898
6706
  var ComponentList = ({
6899
6707
  children,
@@ -6904,12 +6712,12 @@ var ComponentList = ({
6904
6712
  const setUi = useAppStore((s) => s.setUi);
6905
6713
  const componentList = useAppStore((s) => s.state.ui.componentList);
6906
6714
  const { expanded = true } = componentList[id] || {};
6907
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
6908
- title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
6715
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName21({ isExpanded: expanded }), children: [
6716
+ title && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6909
6717
  "button",
6910
6718
  {
6911
6719
  type: "button",
6912
- className: getClassName22("title"),
6720
+ className: getClassName21("title"),
6913
6721
  onClick: () => setUi({
6914
6722
  componentList: __spreadProps(__spreadValues({}, componentList), {
6915
6723
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6919,14 +6727,14 @@ var ComponentList = ({
6919
6727
  }),
6920
6728
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6921
6729
  children: [
6922
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
6923
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: 12 }) })
6730
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { children: title }),
6731
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronDown, { size: 12 }) })
6924
6732
  ]
6925
6733
  }
6926
6734
  ),
6927
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6735
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("content"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6928
6736
  var _a;
6929
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6737
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6930
6738
  ComponentListItem,
6931
6739
  {
6932
6740
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6940,12 +6748,12 @@ var ComponentList = ({
6940
6748
  ComponentList.Item = ComponentListItem;
6941
6749
 
6942
6750
  // lib/use-component-list.tsx
6943
- var import_jsx_runtime32 = require("react/jsx-runtime");
6751
+ var import_jsx_runtime31 = require("react/jsx-runtime");
6944
6752
  var useComponentList = () => {
6945
- const [componentList, setComponentList] = (0, import_react40.useState)();
6753
+ const [componentList, setComponentList] = (0, import_react43.useState)();
6946
6754
  const config = useAppStore((s) => s.config);
6947
6755
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6948
- (0, import_react40.useEffect)(() => {
6756
+ (0, import_react43.useEffect)(() => {
6949
6757
  var _a, _b, _c;
6950
6758
  if (Object.keys(uiComponentList).length > 0) {
6951
6759
  const matchedComponents = [];
@@ -6955,7 +6763,7 @@ var useComponentList = () => {
6955
6763
  if (category.visible === false || !category.components) {
6956
6764
  return null;
6957
6765
  }
6958
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6766
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6959
6767
  ComponentList,
6960
6768
  {
6961
6769
  id: categoryKey,
@@ -6964,7 +6772,7 @@ var useComponentList = () => {
6964
6772
  var _a2;
6965
6773
  matchedComponents.push(componentName);
6966
6774
  const componentConf = config.components[componentName] || {};
6967
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6775
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6968
6776
  ComponentList.Item,
6969
6777
  {
6970
6778
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6984,7 +6792,7 @@ var useComponentList = () => {
6984
6792
  );
6985
6793
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6986
6794
  _componentList.push(
6987
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6795
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6988
6796
  ComponentList,
6989
6797
  {
6990
6798
  id: "other",
@@ -6992,7 +6800,7 @@ var useComponentList = () => {
6992
6800
  children: remainingComponents.map((componentName, i) => {
6993
6801
  var _a2;
6994
6802
  const componentConf = config.components[componentName] || {};
6995
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6803
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6996
6804
  ComponentList.Item,
6997
6805
  {
6998
6806
  name: componentName,
@@ -7014,25 +6822,25 @@ var useComponentList = () => {
7014
6822
  };
7015
6823
 
7016
6824
  // components/Puck/components/Components/index.tsx
7017
- var import_react41 = require("react");
7018
- var import_jsx_runtime33 = require("react/jsx-runtime");
6825
+ var import_react44 = require("react");
6826
+ var import_jsx_runtime32 = require("react/jsx-runtime");
7019
6827
  var Components = () => {
7020
6828
  const overrides = useAppStore((s) => s.overrides);
7021
6829
  const componentList = useComponentList();
7022
- const Wrapper = (0, import_react41.useMemo)(() => overrides.components || "div", [overrides]);
7023
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
6830
+ const Wrapper = (0, import_react44.useMemo)(() => overrides.components || "div", [overrides]);
6831
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
7024
6832
  };
7025
6833
 
7026
6834
  // components/Puck/components/Preview/index.tsx
7027
6835
  init_react_import();
7028
- var import_react43 = require("react");
6836
+ var import_react46 = require("react");
7029
6837
 
7030
6838
  // components/AutoFrame/index.tsx
7031
6839
  init_react_import();
7032
- var import_react42 = require("react");
6840
+ var import_react45 = require("react");
7033
6841
  var import_object_hash = __toESM(require("object-hash"));
7034
6842
  var import_react_dom3 = require("react-dom");
7035
- var import_jsx_runtime34 = require("react/jsx-runtime");
6843
+ var import_jsx_runtime33 = require("react/jsx-runtime");
7036
6844
  var styleSelector = 'style, link[rel="stylesheet"]';
7037
6845
  var collectStyles = (doc) => {
7038
6846
  const collected = [];
@@ -7075,7 +6883,7 @@ var CopyHostStyles = ({
7075
6883
  onStylesLoaded = () => null
7076
6884
  }) => {
7077
6885
  const { document: doc, window: win } = useFrame();
7078
- (0, import_react42.useEffect)(() => {
6886
+ (0, import_react45.useEffect)(() => {
7079
6887
  if (!win || !doc) {
7080
6888
  return () => {
7081
6889
  };
@@ -7232,10 +7040,10 @@ var CopyHostStyles = ({
7232
7040
  observer.disconnect();
7233
7041
  };
7234
7042
  }, []);
7235
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
7043
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
7236
7044
  };
7237
- var autoFrameContext = (0, import_react42.createContext)({});
7238
- var useFrame = () => (0, import_react42.useContext)(autoFrameContext);
7045
+ var autoFrameContext = (0, import_react45.createContext)({});
7046
+ var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
7239
7047
  function AutoFrame(_a) {
7240
7048
  var _b = _a, {
7241
7049
  children,
@@ -7256,11 +7064,11 @@ function AutoFrame(_a) {
7256
7064
  "onNotReady",
7257
7065
  "frameRef"
7258
7066
  ]);
7259
- const [loaded, setLoaded] = (0, import_react42.useState)(false);
7260
- const [ctx, setCtx] = (0, import_react42.useState)({});
7261
- const [mountTarget, setMountTarget] = (0, import_react42.useState)();
7262
- const [stylesLoaded, setStylesLoaded] = (0, import_react42.useState)(false);
7263
- (0, import_react42.useEffect)(() => {
7067
+ const [loaded, setLoaded] = (0, import_react45.useState)(false);
7068
+ const [ctx, setCtx] = (0, import_react45.useState)({});
7069
+ const [mountTarget, setMountTarget] = (0, import_react45.useState)();
7070
+ const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
7071
+ (0, import_react45.useEffect)(() => {
7264
7072
  var _a2;
7265
7073
  if (frameRef.current) {
7266
7074
  const doc = frameRef.current.contentDocument;
@@ -7279,7 +7087,7 @@ function AutoFrame(_a) {
7279
7087
  }
7280
7088
  }
7281
7089
  }, [frameRef, loaded, stylesLoaded]);
7282
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7090
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7283
7091
  "iframe",
7284
7092
  __spreadProps(__spreadValues({}, props), {
7285
7093
  className,
@@ -7289,7 +7097,7 @@ function AutoFrame(_a) {
7289
7097
  onLoad: () => {
7290
7098
  setLoaded(true);
7291
7099
  },
7292
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7100
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7293
7101
  CopyHostStyles,
7294
7102
  {
7295
7103
  debug,
@@ -7305,14 +7113,14 @@ var AutoFrame_default = AutoFrame;
7305
7113
 
7306
7114
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
7307
7115
  init_react_import();
7308
- var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7116
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7309
7117
 
7310
7118
  // components/Puck/components/Preview/index.tsx
7311
- var import_jsx_runtime35 = require("react/jsx-runtime");
7312
- var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
7119
+ var import_jsx_runtime34 = require("react/jsx-runtime");
7120
+ var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
7313
7121
  var useBubbleIframeEvents = (ref) => {
7314
7122
  const status = useAppStore((s) => s.status);
7315
- (0, import_react43.useEffect)(() => {
7123
+ (0, import_react46.useEffect)(() => {
7316
7124
  if (ref.current && status === "READY") {
7317
7125
  const iframe = ref.current;
7318
7126
  const handlePointerMove = (event) => {
@@ -7350,7 +7158,7 @@ var useBubbleIframeEvents = (ref) => {
7350
7158
  }
7351
7159
  }, [status]);
7352
7160
  };
7353
- var Preview3 = ({ id = "puck-preview" }) => {
7161
+ var Preview2 = ({ id = "puck-preview" }) => {
7354
7162
  const dispatch = useAppStore((s) => s.dispatch);
7355
7163
  const root = useAppStore((s) => s.state.data.root);
7356
7164
  const config = useAppStore((s) => s.config);
@@ -7361,22 +7169,22 @@ var Preview3 = ({ id = "puck-preview" }) => {
7361
7169
  const renderData = useAppStore(
7362
7170
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
7363
7171
  );
7364
- const Page = (0, import_react43.useCallback)(
7172
+ const Page = (0, import_react46.useCallback)(
7365
7173
  (pageProps) => {
7366
7174
  var _a, _b;
7367
7175
  const rootConfig = config.root;
7368
7176
  const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
7369
7177
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
7370
7178
  id: "puck-root"
7371
- }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
7179
+ }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: propsWithSlots.children });
7372
7180
  },
7373
7181
  [config.root]
7374
7182
  );
7375
- const Frame = (0, import_react43.useMemo)(() => overrides.iframe, [overrides]);
7183
+ const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
7376
7184
  const rootProps = root.props || root;
7377
- const ref = (0, import_react43.useRef)(null);
7185
+ const ref = (0, import_react46.useRef)(null);
7378
7186
  useBubbleIframeEvents(ref);
7379
- const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7187
+ const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7380
7188
  Page,
7381
7189
  __spreadProps(__spreadValues({}, rootProps), {
7382
7190
  puck: {
@@ -7386,28 +7194,28 @@ var Preview3 = ({ id = "puck-preview" }) => {
7386
7194
  metadata
7387
7195
  },
7388
7196
  editMode: true,
7389
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
7197
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
7390
7198
  })
7391
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config });
7392
- (0, import_react43.useEffect)(() => {
7199
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config });
7200
+ (0, import_react46.useEffect)(() => {
7393
7201
  if (!iframe.enabled) {
7394
7202
  setStatus("READY");
7395
7203
  }
7396
7204
  }, [iframe.enabled]);
7397
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7205
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7398
7206
  "div",
7399
7207
  {
7400
- className: getClassName23(),
7208
+ className: getClassName22(),
7401
7209
  id,
7402
7210
  "data-puck-preview": true,
7403
7211
  onClick: () => {
7404
7212
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7405
7213
  },
7406
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7214
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7407
7215
  AutoFrame_default,
7408
7216
  {
7409
7217
  id: "preview-frame",
7410
- className: getClassName23("frame"),
7218
+ className: getClassName22("frame"),
7411
7219
  "data-rfd-iframe": true,
7412
7220
  onReady: () => {
7413
7221
  setStatus("READY");
@@ -7416,18 +7224,18 @@ var Preview3 = ({ id = "puck-preview" }) => {
7416
7224
  setStatus("MOUNTED");
7417
7225
  },
7418
7226
  frameRef: ref,
7419
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7227
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7420
7228
  if (Frame) {
7421
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
7229
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Frame, { document: document2, children: inner });
7422
7230
  }
7423
7231
  return inner;
7424
7232
  } })
7425
7233
  }
7426
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7234
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7427
7235
  "div",
7428
7236
  {
7429
7237
  id: "preview-frame",
7430
- className: getClassName23("frame"),
7238
+ className: getClassName22("frame"),
7431
7239
  ref,
7432
7240
  "data-puck-entry": true,
7433
7241
  children: inner
@@ -7445,7 +7253,7 @@ init_react_import();
7445
7253
 
7446
7254
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
7447
7255
  init_react_import();
7448
- 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" };
7256
+ 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" };
7449
7257
 
7450
7258
  // lib/scroll-into-view.ts
7451
7259
  init_react_import();
@@ -7459,7 +7267,7 @@ var scrollIntoView = (el) => {
7459
7267
  };
7460
7268
 
7461
7269
  // components/LayerTree/index.tsx
7462
- var import_react44 = require("react");
7270
+ var import_react47 = require("react");
7463
7271
 
7464
7272
  // lib/on-scroll-end.ts
7465
7273
  init_react_import();
@@ -7482,20 +7290,20 @@ var onScrollEnd = (frame, cb) => {
7482
7290
 
7483
7291
  // components/LayerTree/index.tsx
7484
7292
  var import_shallow5 = require("zustand/react/shallow");
7485
- var import_jsx_runtime36 = require("react/jsx-runtime");
7486
- var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
7487
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
7293
+ var import_jsx_runtime35 = require("react/jsx-runtime");
7294
+ var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
7295
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
7488
7296
  var Layer = ({
7489
7297
  index,
7490
7298
  itemId,
7491
7299
  zoneCompound
7492
7300
  }) => {
7493
7301
  var _a;
7494
- const ctx = (0, import_react44.useContext)(dropZoneContext);
7302
+ const ctx = (0, import_react47.useContext)(dropZoneContext);
7495
7303
  const config = useAppStore((s) => s.config);
7496
7304
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
7497
7305
  const dispatch = useAppStore((s) => s.dispatch);
7498
- const setItemSelector = (0, import_react44.useCallback)(
7306
+ const setItemSelector = (0, import_react47.useCallback)(
7499
7307
  (itemSelector2) => {
7500
7308
  dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
7501
7309
  },
@@ -7515,9 +7323,11 @@ var Layer = ({
7515
7323
  )
7516
7324
  );
7517
7325
  const containsZone = zonesForItem.length > 0;
7518
- const { setHoveringComponent = () => {
7519
- }, hoveringComponent } = ctx || {};
7520
- const isHovering = hoveringComponent === itemId;
7326
+ const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
7327
+ const isHovering = useContextStore(
7328
+ ZoneStoreContext,
7329
+ (s) => s.hoveringComponent === itemId
7330
+ );
7521
7331
  const childIsSelected = useAppStore((s) => {
7522
7332
  var _a2, _b;
7523
7333
  const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
@@ -7528,7 +7338,7 @@ var Layer = ({
7528
7338
  });
7529
7339
  const componentConfig = config.components[nodeData.data.type];
7530
7340
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
7531
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7341
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7532
7342
  "li",
7533
7343
  {
7534
7344
  className: getClassNameLayer({
@@ -7538,7 +7348,7 @@ var Layer = ({
7538
7348
  childIsSelected
7539
7349
  }),
7540
7350
  children: [
7541
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7351
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7542
7352
  "button",
7543
7353
  {
7544
7354
  type: "button",
@@ -7564,31 +7374,31 @@ var Layer = ({
7564
7374
  });
7565
7375
  });
7566
7376
  },
7567
- onMouseOver: (e) => {
7377
+ onMouseEnter: (e) => {
7568
7378
  e.stopPropagation();
7569
- setHoveringComponent(itemId);
7379
+ zoneStore.setState({ hoveringComponent: itemId });
7570
7380
  },
7571
- onMouseOut: (e) => {
7381
+ onMouseLeave: (e) => {
7572
7382
  e.stopPropagation();
7573
- setHoveringComponent(null);
7383
+ zoneStore.setState({ hoveringComponent: null });
7574
7384
  },
7575
7385
  children: [
7576
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7386
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7577
7387
  "div",
7578
7388
  {
7579
7389
  className: getClassNameLayer("chevron"),
7580
7390
  title: isSelected ? "Collapse" : "Expand",
7581
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
7391
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { size: "12" })
7582
7392
  }
7583
7393
  ),
7584
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
7585
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayoutGrid, { size: "16" }) }),
7586
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
7394
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassNameLayer("title"), children: [
7395
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayoutGrid, { size: "16" }) }),
7396
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("name"), children: label })
7587
7397
  ] })
7588
7398
  ]
7589
7399
  }
7590
7400
  ) }),
7591
- containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
7401
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
7592
7402
  ]
7593
7403
  }
7594
7404
  );
@@ -7606,15 +7416,15 @@ var LayerTree = ({
7606
7416
  }
7607
7417
  )
7608
7418
  );
7609
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
7610
- label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
7611
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
7419
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
7420
+ label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
7421
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
7612
7422
  label
7613
7423
  ] }),
7614
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
7615
- contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
7424
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
7425
+ contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
7616
7426
  contentIds.map((itemId, i) => {
7617
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7427
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7618
7428
  Layer,
7619
7429
  {
7620
7430
  index: i,
@@ -7629,7 +7439,7 @@ var LayerTree = ({
7629
7439
  };
7630
7440
 
7631
7441
  // components/Puck/components/Outline/index.tsx
7632
- var import_react45 = require("react");
7442
+ var import_react48 = require("react");
7633
7443
 
7634
7444
  // lib/data/find-zones-for-area.ts
7635
7445
  init_react_import();
@@ -7641,14 +7451,14 @@ var findZonesForArea = (state, area) => {
7641
7451
 
7642
7452
  // components/Puck/components/Outline/index.tsx
7643
7453
  var import_shallow6 = require("zustand/react/shallow");
7644
- var import_jsx_runtime37 = require("react/jsx-runtime");
7454
+ var import_jsx_runtime36 = require("react/jsx-runtime");
7645
7455
  var Outline = () => {
7646
7456
  const outlineOverride = useAppStore((s) => s.overrides.outline);
7647
7457
  const rootZones = useAppStore(
7648
7458
  (0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
7649
7459
  );
7650
- const Wrapper = (0, import_react45.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7651
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7460
+ const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7461
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7652
7462
  LayerTree,
7653
7463
  {
7654
7464
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -7781,25 +7591,25 @@ var getBox = function getBox2(el) {
7781
7591
  };
7782
7592
 
7783
7593
  // components/Puck/components/Canvas/index.tsx
7784
- var import_react47 = require("react");
7594
+ var import_react50 = require("react");
7785
7595
 
7786
7596
  // components/ViewportControls/index.tsx
7787
7597
  init_react_import();
7788
- var import_react46 = require("react");
7598
+ var import_react49 = require("react");
7789
7599
 
7790
7600
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7791
7601
  init_react_import();
7792
- 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" };
7602
+ 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" };
7793
7603
 
7794
7604
  // components/ViewportControls/index.tsx
7795
- var import_jsx_runtime38 = require("react/jsx-runtime");
7605
+ var import_jsx_runtime37 = require("react/jsx-runtime");
7796
7606
  var icons = {
7797
- Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
7798
- Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
7799
- Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
7607
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Smartphone, { size: 16 }),
7608
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Tablet, { size: 16 }),
7609
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Monitor, { size: 16 })
7800
7610
  };
7801
- var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
7802
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
7611
+ var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
7612
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
7803
7613
  var ViewportButton = ({
7804
7614
  children,
7805
7615
  height = "auto",
@@ -7808,11 +7618,11 @@ var ViewportButton = ({
7808
7618
  onClick
7809
7619
  }) => {
7810
7620
  const viewports = useAppStore((s) => s.state.ui.viewports);
7811
- const [isActive, setIsActive] = (0, import_react46.useState)(false);
7812
- (0, import_react46.useEffect)(() => {
7621
+ const [isActive, setIsActive] = (0, import_react49.useState)(false);
7622
+ (0, import_react49.useEffect)(() => {
7813
7623
  setIsActive(width === viewports.current.width);
7814
7624
  }, [width, viewports.current.width]);
7815
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7625
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7816
7626
  IconButton,
7817
7627
  {
7818
7628
  title,
@@ -7821,7 +7631,7 @@ var ViewportButton = ({
7821
7631
  e.stopPropagation();
7822
7632
  onClick({ width, height });
7823
7633
  },
7824
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
7634
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton("inner"), children })
7825
7635
  }
7826
7636
  ) });
7827
7637
  };
@@ -7845,7 +7655,7 @@ var ViewportControls = ({
7845
7655
  const defaultsContainAutoZoom = defaultZoomOptions.find(
7846
7656
  (option) => option.value === autoZoom
7847
7657
  );
7848
- const zoomOptions = (0, import_react46.useMemo)(
7658
+ const zoomOptions = (0, import_react49.useMemo)(
7849
7659
  () => [
7850
7660
  ...defaultZoomOptions,
7851
7661
  ...defaultsContainAutoZoom ? [] : [
@@ -7857,8 +7667,8 @@ var ViewportControls = ({
7857
7667
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7858
7668
  [autoZoom]
7859
7669
  );
7860
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
7861
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7670
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName24(), children: [
7671
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7862
7672
  ViewportButton,
7863
7673
  {
7864
7674
  height: viewport.height,
@@ -7869,8 +7679,8 @@ var ViewportControls = ({
7869
7679
  },
7870
7680
  i
7871
7681
  )),
7872
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7873
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7682
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7683
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7874
7684
  IconButton,
7875
7685
  {
7876
7686
  title: "Zoom viewport out",
@@ -7884,10 +7694,10 @@ var ViewportControls = ({
7884
7694
  )].value
7885
7695
  );
7886
7696
  },
7887
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
7697
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomOut, { size: 16 })
7888
7698
  }
7889
7699
  ),
7890
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7700
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7891
7701
  IconButton,
7892
7702
  {
7893
7703
  title: "Zoom viewport in",
@@ -7901,19 +7711,19 @@ var ViewportControls = ({
7901
7711
  )].value
7902
7712
  );
7903
7713
  },
7904
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
7714
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomIn, { size: 16 })
7905
7715
  }
7906
7716
  ),
7907
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7908
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7717
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7718
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7909
7719
  "select",
7910
7720
  {
7911
- className: getClassName25("zoomSelect"),
7721
+ className: getClassName24("zoomSelect"),
7912
7722
  value: zoom.toString(),
7913
7723
  onChange: (e) => {
7914
7724
  onZoom(parseFloat(e.currentTarget.value));
7915
7725
  },
7916
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7726
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7917
7727
  "option",
7918
7728
  {
7919
7729
  value: option.value,
@@ -7928,7 +7738,7 @@ var ViewportControls = ({
7928
7738
 
7929
7739
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7930
7740
  init_react_import();
7931
- 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" };
7741
+ 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" };
7932
7742
 
7933
7743
  // lib/get-zoom-config.ts
7934
7744
  init_react_import();
@@ -7962,8 +7772,8 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7962
7772
 
7963
7773
  // components/Puck/components/Canvas/index.tsx
7964
7774
  var import_shallow7 = require("zustand/react/shallow");
7965
- var import_jsx_runtime39 = require("react/jsx-runtime");
7966
- var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
7775
+ var import_jsx_runtime38 = require("react/jsx-runtime");
7776
+ var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
7967
7777
  var ZOOM_ON_CHANGE = true;
7968
7778
  var Canvas = () => {
7969
7779
  const {
@@ -7992,17 +7802,17 @@ var Canvas = () => {
7992
7802
  viewports: s.state.ui.viewports
7993
7803
  }))
7994
7804
  );
7995
- const frameRef = (0, import_react47.useRef)(null);
7996
- const [showTransition, setShowTransition] = (0, import_react47.useState)(false);
7997
- const defaultRender = (0, import_react47.useMemo)(() => {
7998
- const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
7805
+ const frameRef = (0, import_react50.useRef)(null);
7806
+ const [showTransition, setShowTransition] = (0, import_react50.useState)(false);
7807
+ const defaultRender = (0, import_react50.useMemo)(() => {
7808
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
7999
7809
  return PuckDefault;
8000
7810
  }, []);
8001
- const CustomPreview = (0, import_react47.useMemo)(
7811
+ const CustomPreview = (0, import_react50.useMemo)(
8002
7812
  () => overrides.preview || defaultRender,
8003
7813
  [overrides]
8004
7814
  );
8005
- const getFrameDimensions = (0, import_react47.useCallback)(() => {
7815
+ const getFrameDimensions = (0, import_react50.useCallback)(() => {
8006
7816
  if (frameRef.current) {
8007
7817
  const frame = frameRef.current;
8008
7818
  const box = getBox(frame);
@@ -8010,7 +7820,7 @@ var Canvas = () => {
8010
7820
  }
8011
7821
  return { width: 0, height: 0 };
8012
7822
  }, [frameRef]);
8013
- const resetAutoZoom = (0, import_react47.useCallback)(
7823
+ const resetAutoZoom = (0, import_react50.useCallback)(
8014
7824
  (newViewports = viewports) => {
8015
7825
  if (frameRef.current) {
8016
7826
  setZoomConfig(
@@ -8024,11 +7834,11 @@ var Canvas = () => {
8024
7834
  },
8025
7835
  [frameRef, zoomConfig, viewports]
8026
7836
  );
8027
- (0, import_react47.useEffect)(() => {
7837
+ (0, import_react50.useEffect)(() => {
8028
7838
  setShowTransition(false);
8029
7839
  resetAutoZoom(viewports);
8030
7840
  }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
8031
- (0, import_react47.useEffect)(() => {
7841
+ (0, import_react50.useEffect)(() => {
8032
7842
  const { height: frameHeight } = getFrameDimensions();
8033
7843
  if (viewports.current.height === "auto") {
8034
7844
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -8036,13 +7846,13 @@ var Canvas = () => {
8036
7846
  }));
8037
7847
  }
8038
7848
  }, [zoomConfig.zoom]);
8039
- (0, import_react47.useEffect)(() => {
7849
+ (0, import_react50.useEffect)(() => {
8040
7850
  if (ZOOM_ON_CHANGE) {
8041
7851
  setShowTransition(true);
8042
7852
  resetAutoZoom(viewports);
8043
7853
  }
8044
7854
  }, [viewports.current.width]);
8045
- (0, import_react47.useEffect)(() => {
7855
+ (0, import_react50.useEffect)(() => {
8046
7856
  const cb = () => {
8047
7857
  setShowTransition(false);
8048
7858
  resetAutoZoom();
@@ -8052,16 +7862,16 @@ var Canvas = () => {
8052
7862
  window.removeEventListener("resize", cb);
8053
7863
  };
8054
7864
  }, []);
8055
- const [showLoader, setShowLoader] = (0, import_react47.useState)(false);
8056
- (0, import_react47.useEffect)(() => {
7865
+ const [showLoader, setShowLoader] = (0, import_react50.useState)(false);
7866
+ (0, import_react50.useEffect)(() => {
8057
7867
  setTimeout(() => {
8058
7868
  setShowLoader(true);
8059
7869
  }, 500);
8060
7870
  }, []);
8061
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
7871
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
8062
7872
  "div",
8063
7873
  {
8064
- className: getClassName26({
7874
+ className: getClassName25({
8065
7875
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
8066
7876
  showLoader
8067
7877
  }),
@@ -8071,7 +7881,7 @@ var Canvas = () => {
8071
7881
  recordHistory: true
8072
7882
  }),
8073
7883
  children: [
8074
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7884
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8075
7885
  ViewportControls,
8076
7886
  {
8077
7887
  autoZoom: zoomConfig.autoZoom,
@@ -8097,11 +7907,11 @@ var Canvas = () => {
8097
7907
  }
8098
7908
  }
8099
7909
  ) }),
8100
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
8101
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7910
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25("inner"), ref: frameRef, children: [
7911
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8102
7912
  "div",
8103
7913
  {
8104
- className: getClassName26("root"),
7914
+ className: getClassName25("root"),
8105
7915
  style: {
8106
7916
  width: iframe.enabled ? viewports.current.width : "100%",
8107
7917
  height: zoomConfig.rootHeight,
@@ -8119,10 +7929,10 @@ var Canvas = () => {
8119
7929
  })
8120
7930
  );
8121
7931
  },
8122
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview3, {}) })
7932
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Preview2, {}) })
8123
7933
  }
8124
7934
  ),
8125
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
7935
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { size: 24 }) })
8126
7936
  ] })
8127
7937
  ]
8128
7938
  }
@@ -8131,7 +7941,7 @@ var Canvas = () => {
8131
7941
 
8132
7942
  // lib/use-loaded-overrides.ts
8133
7943
  init_react_import();
8134
- var import_react48 = require("react");
7944
+ var import_react51 = require("react");
8135
7945
 
8136
7946
  // lib/load-overrides.ts
8137
7947
  init_react_import();
@@ -8170,26 +7980,26 @@ var useLoadedOverrides = ({
8170
7980
  overrides,
8171
7981
  plugins
8172
7982
  }) => {
8173
- return (0, import_react48.useMemo)(() => {
7983
+ return (0, import_react51.useMemo)(() => {
8174
7984
  return loadOverrides({ overrides, plugins });
8175
7985
  }, [plugins, overrides]);
8176
7986
  };
8177
7987
 
8178
7988
  // components/DefaultOverride/index.tsx
8179
7989
  init_react_import();
8180
- var import_jsx_runtime40 = require("react/jsx-runtime");
8181
- var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
7990
+ var import_jsx_runtime39 = require("react/jsx-runtime");
7991
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
8182
7992
 
8183
7993
  // lib/use-inject-css.ts
8184
7994
  init_react_import();
8185
- var import_react49 = require("react");
7995
+ var import_react52 = require("react");
8186
7996
  var styles = ``;
8187
7997
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
8188
- const [el, setEl] = (0, import_react49.useState)();
8189
- (0, import_react49.useEffect)(() => {
7998
+ const [el, setEl] = (0, import_react52.useState)();
7999
+ (0, import_react52.useEffect)(() => {
8190
8000
  setEl(document.createElement("style"));
8191
8001
  }, []);
8192
- (0, import_react49.useEffect)(() => {
8002
+ (0, import_react52.useEffect)(() => {
8193
8003
  var _a;
8194
8004
  if (!el || typeof window === "undefined") {
8195
8005
  return;
@@ -8209,10 +8019,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
8209
8019
 
8210
8020
  // lib/use-preview-mode-hotkeys.ts
8211
8021
  init_react_import();
8212
- var import_react50 = require("react");
8022
+ var import_react53 = require("react");
8213
8023
  var usePreviewModeHotkeys = () => {
8214
8024
  const appStore = useAppStoreApi();
8215
- const toggleInteractive = (0, import_react50.useCallback)(() => {
8025
+ const toggleInteractive = (0, import_react53.useCallback)(() => {
8216
8026
  const dispatch = appStore.getState().dispatch;
8217
8027
  dispatch({
8218
8028
  type: "setUi",
@@ -8227,7 +8037,7 @@ var usePreviewModeHotkeys = () => {
8227
8037
 
8228
8038
  // lib/use-puck.ts
8229
8039
  init_react_import();
8230
- var import_react51 = require("react");
8040
+ var import_react54 = require("react");
8231
8041
  var import_zustand6 = require("zustand");
8232
8042
  var generateUsePuck = (store) => {
8233
8043
  const history = {
@@ -8261,7 +8071,7 @@ var generateUsePuck = (store) => {
8261
8071
  const get = () => storeData;
8262
8072
  return __spreadProps(__spreadValues({}, storeData), { get });
8263
8073
  };
8264
- var UsePuckStoreContext = (0, import_react51.createContext)(
8074
+ var UsePuckStoreContext = (0, import_react54.createContext)(
8265
8075
  null
8266
8076
  );
8267
8077
  var convertToPickedStore = (store) => {
@@ -8275,12 +8085,12 @@ var convertToPickedStore = (store) => {
8275
8085
  };
8276
8086
  };
8277
8087
  var useRegisterUsePuckStore = (appStore) => {
8278
- const [usePuckStore] = (0, import_react51.useState)(
8088
+ const [usePuckStore] = (0, import_react54.useState)(
8279
8089
  () => (0, import_zustand6.createStore)(
8280
8090
  () => generateUsePuck(convertToPickedStore(appStore.getState()))
8281
8091
  )
8282
8092
  );
8283
- (0, import_react51.useEffect)(() => {
8093
+ (0, import_react54.useEffect)(() => {
8284
8094
  return appStore.subscribe(
8285
8095
  (store) => convertToPickedStore(store),
8286
8096
  (pickedStore) => {
@@ -8292,7 +8102,7 @@ var useRegisterUsePuckStore = (appStore) => {
8292
8102
  };
8293
8103
  function createUsePuck() {
8294
8104
  return function usePuck2(selector) {
8295
- const usePuckApi = (0, import_react51.useContext)(UsePuckStoreContext);
8105
+ const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8296
8106
  if (!usePuckApi) {
8297
8107
  throw new Error("usePuck must be used inside <Puck>.");
8298
8108
  }
@@ -8304,19 +8114,241 @@ function createUsePuck() {
8304
8114
  };
8305
8115
  }
8306
8116
  function usePuck() {
8307
- (0, import_react51.useEffect)(() => {
8117
+ (0, import_react54.useEffect)(() => {
8308
8118
  console.warn(
8309
8119
  "You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
8310
8120
  );
8311
8121
  }, []);
8312
8122
  return createUsePuck()((s) => s);
8313
8123
  }
8124
+ function useGetPuck() {
8125
+ const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8126
+ if (!usePuckApi) {
8127
+ throw new Error("usePuckGet must be used inside <Puck>.");
8128
+ }
8129
+ return usePuckApi.getState;
8130
+ }
8314
8131
 
8315
8132
  // components/Puck/index.tsx
8316
8133
  var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
8134
+
8135
+ // components/Puck/components/Header/index.tsx
8136
+ init_react_import();
8137
+ var import_react55 = require("react");
8138
+
8139
+ // components/MenuBar/index.tsx
8140
+ init_react_import();
8141
+
8142
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
8143
+ init_react_import();
8144
+ 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" };
8145
+
8146
+ // components/MenuBar/index.tsx
8147
+ var import_jsx_runtime40 = require("react/jsx-runtime");
8148
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
8149
+ function MenuBar({
8150
+ menuOpen = false,
8151
+ renderHeaderActions,
8152
+ setMenuOpen
8153
+ }) {
8154
+ const back = useAppStore((s) => s.history.back);
8155
+ const forward = useAppStore((s) => s.history.forward);
8156
+ const hasFuture = useAppStore((s) => s.history.hasFuture());
8157
+ const hasPast = useAppStore((s) => s.history.hasPast());
8158
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8159
+ "div",
8160
+ {
8161
+ className: getClassName26({ menuOpen }),
8162
+ onClick: (event) => {
8163
+ var _a;
8164
+ const element = event.target;
8165
+ if (window.matchMedia("(min-width: 638px)").matches) {
8166
+ return;
8167
+ }
8168
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
8169
+ setMenuOpen(false);
8170
+ }
8171
+ },
8172
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("inner"), children: [
8173
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("history"), children: [
8174
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Undo2, { size: 21 }) }),
8175
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Redo2, { size: 21 }) })
8176
+ ] }),
8177
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: renderHeaderActions && renderHeaderActions() })
8178
+ ] })
8179
+ }
8180
+ );
8181
+ }
8182
+
8183
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
8184
+ init_react_import();
8185
+ 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" };
8186
+
8187
+ // components/Puck/components/Header/index.tsx
8317
8188
  var import_jsx_runtime41 = require("react/jsx-runtime");
8318
- var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
8319
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
8189
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
8190
+ var HeaderInner = () => {
8191
+ const {
8192
+ onPublish,
8193
+ renderHeader,
8194
+ renderHeaderActions,
8195
+ headerTitle,
8196
+ headerPath,
8197
+ iframe: _iframe
8198
+ } = usePropsContext();
8199
+ const dispatch = useAppStore((s) => s.dispatch);
8200
+ const appStore = useAppStoreApi();
8201
+ const defaultHeaderRender = (0, import_react55.useMemo)(() => {
8202
+ if (renderHeader) {
8203
+ console.warn(
8204
+ "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8205
+ );
8206
+ const RenderHeader = (_a) => {
8207
+ var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8208
+ const Comp = renderHeader;
8209
+ const appState = useAppStore((s) => s.state);
8210
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8211
+ };
8212
+ return RenderHeader;
8213
+ }
8214
+ return DefaultOverride;
8215
+ }, [renderHeader]);
8216
+ const defaultHeaderActionsRender = (0, import_react55.useMemo)(() => {
8217
+ if (renderHeaderActions) {
8218
+ console.warn(
8219
+ "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8220
+ );
8221
+ const RenderHeader = (props) => {
8222
+ const Comp = renderHeaderActions;
8223
+ const appState = useAppStore((s) => s.state);
8224
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8225
+ };
8226
+ return RenderHeader;
8227
+ }
8228
+ return DefaultOverride;
8229
+ }, [renderHeader]);
8230
+ const CustomHeader = useAppStore(
8231
+ (s) => s.overrides.header || defaultHeaderRender
8232
+ );
8233
+ const CustomHeaderActions = useAppStore(
8234
+ (s) => s.overrides.headerActions || defaultHeaderActionsRender
8235
+ );
8236
+ const [menuOpen, setMenuOpen] = (0, import_react55.useState)(false);
8237
+ const rootTitle = useAppStore((s) => {
8238
+ var _a, _b;
8239
+ const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
8240
+ return (_b = rootData.props.title) != null ? _b : "";
8241
+ });
8242
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8243
+ const rightSideBarVisible = useAppStore(
8244
+ (s) => s.state.ui.rightSideBarVisible
8245
+ );
8246
+ const toggleSidebars = (0, import_react55.useCallback)(
8247
+ (sidebar) => {
8248
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8249
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8250
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8251
+ dispatch({
8252
+ type: "setUi",
8253
+ ui: __spreadValues({
8254
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
8255
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
8256
+ });
8257
+ },
8258
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
8259
+ );
8260
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8261
+ CustomHeader,
8262
+ {
8263
+ actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8264
+ Button,
8265
+ {
8266
+ onClick: () => {
8267
+ const data = appStore.getState().state.data;
8268
+ onPublish && onPublish(data);
8269
+ },
8270
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8271
+ children: "Publish"
8272
+ }
8273
+ ) }) }),
8274
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8275
+ "header",
8276
+ {
8277
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
8278
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("inner"), children: [
8279
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("toggle"), children: [
8280
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8281
+ IconButton,
8282
+ {
8283
+ onClick: () => {
8284
+ toggleSidebars("left");
8285
+ },
8286
+ title: "Toggle left sidebar",
8287
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8288
+ }
8289
+ ) }),
8290
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8291
+ IconButton,
8292
+ {
8293
+ onClick: () => {
8294
+ toggleSidebars("right");
8295
+ },
8296
+ title: "Toggle right sidebar",
8297
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8298
+ }
8299
+ ) })
8300
+ ] }),
8301
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8302
+ headerTitle || rootTitle || "Page",
8303
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8304
+ " ",
8305
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("code", { className: getClassName27("path"), children: headerPath })
8306
+ ] })
8307
+ ] }) }),
8308
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("tools"), children: [
8309
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8310
+ IconButton,
8311
+ {
8312
+ onClick: () => {
8313
+ return setMenuOpen(!menuOpen);
8314
+ },
8315
+ title: "Toggle menu bar",
8316
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8317
+ }
8318
+ ) }),
8319
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8320
+ MenuBar,
8321
+ {
8322
+ dispatch,
8323
+ onPublish,
8324
+ menuOpen,
8325
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8326
+ Button,
8327
+ {
8328
+ onClick: () => {
8329
+ const data = appStore.getState().state.data;
8330
+ onPublish && onPublish(data);
8331
+ },
8332
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8333
+ children: "Publish"
8334
+ }
8335
+ ) }),
8336
+ setMenuOpen
8337
+ }
8338
+ )
8339
+ ] })
8340
+ ] })
8341
+ }
8342
+ )
8343
+ }
8344
+ );
8345
+ };
8346
+ var Header = (0, import_react55.memo)(HeaderInner);
8347
+
8348
+ // components/Puck/index.tsx
8349
+ var import_jsx_runtime42 = require("react/jsx-runtime");
8350
+ var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
8351
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
8320
8352
  var FieldSideBar = () => {
8321
8353
  const title = useAppStore(
8322
8354
  (s) => {
@@ -8324,13 +8356,13 @@ var FieldSideBar = () => {
8324
8356
  return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
8325
8357
  }
8326
8358
  );
8327
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Fields, {}) });
8359
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
8328
8360
  };
8329
- var propsContext = (0, import_react52.createContext)({});
8361
+ var propsContext = (0, import_react56.createContext)({});
8330
8362
  function PropsProvider(props) {
8331
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(propsContext.Provider, { value: props, children: props.children });
8363
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(propsContext.Provider, { value: props, children: props.children });
8332
8364
  }
8333
- var usePropsContext = () => (0, import_react52.useContext)(propsContext);
8365
+ var usePropsContext = () => (0, import_react56.useContext)(propsContext);
8334
8366
  function PuckProvider({ children }) {
8335
8367
  const {
8336
8368
  config,
@@ -8346,11 +8378,14 @@ function PuckProvider({ children }) {
8346
8378
  metadata,
8347
8379
  onAction
8348
8380
  } = usePropsContext();
8349
- const iframe = __spreadValues({
8350
- enabled: true,
8351
- waitForStyles: true
8352
- }, _iframe);
8353
- const [generatedAppState] = (0, import_react52.useState)(() => {
8381
+ const iframe = (0, import_react56.useMemo)(
8382
+ () => __spreadValues({
8383
+ enabled: true,
8384
+ waitForStyles: true
8385
+ }, _iframe),
8386
+ [_iframe]
8387
+ );
8388
+ const [generatedAppState] = (0, import_react56.useState)(() => {
8354
8389
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8355
8390
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
8356
8391
  let clientUiState = {};
@@ -8410,7 +8445,7 @@ function PuckProvider({ children }) {
8410
8445
  return walkAppState(newAppState, config);
8411
8446
  });
8412
8447
  const { appendData = true } = _initialHistory || {};
8413
- const [blendedHistories] = (0, import_react52.useState)(
8448
+ const [blendedHistories] = (0, import_react56.useState)(
8414
8449
  [
8415
8450
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8416
8451
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8430,7 +8465,7 @@ function PuckProvider({ children }) {
8430
8465
  overrides,
8431
8466
  plugins
8432
8467
  });
8433
- const generateAppStore = (0, import_react52.useCallback)(
8468
+ const generateAppStore = (0, import_react56.useCallback)(
8434
8469
  (state) => {
8435
8470
  return {
8436
8471
  state,
@@ -8454,10 +8489,10 @@ function PuckProvider({ children }) {
8454
8489
  metadata
8455
8490
  ]
8456
8491
  );
8457
- const [appStore] = (0, import_react52.useState)(
8492
+ const [appStore] = (0, import_react56.useState)(
8458
8493
  () => createAppStore(generateAppStore(initialAppState))
8459
8494
  );
8460
- (0, import_react52.useEffect)(() => {
8495
+ (0, import_react56.useEffect)(() => {
8461
8496
  const state = appStore.getState().state;
8462
8497
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8463
8498
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8466,8 +8501,8 @@ function PuckProvider({ children }) {
8466
8501
  index: initialHistoryIndex,
8467
8502
  initialAppState
8468
8503
  });
8469
- const previousData = (0, import_react52.useRef)(null);
8470
- (0, import_react52.useEffect)(() => {
8504
+ const previousData = (0, import_react56.useRef)(null);
8505
+ (0, import_react56.useEffect)(() => {
8471
8506
  appStore.subscribe(
8472
8507
  (s) => s.state.data,
8473
8508
  (data) => {
@@ -8481,53 +8516,32 @@ function PuckProvider({ children }) {
8481
8516
  }, []);
8482
8517
  useRegisterPermissionsSlice(appStore, permissions);
8483
8518
  const uPuckStore = useRegisterUsePuckStore(appStore);
8484
- (0, import_react52.useEffect)(() => {
8519
+ (0, import_react56.useEffect)(() => {
8485
8520
  const { resolveAndCommitData } = appStore.getState();
8486
8521
  resolveAndCommitData();
8487
8522
  }, []);
8488
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8523
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8489
8524
  }
8490
8525
  function PuckLayout({ children }) {
8491
8526
  const {
8492
- onPublish,
8493
- renderHeader,
8494
- renderHeaderActions,
8495
- headerTitle,
8496
- headerPath,
8497
8527
  iframe: _iframe,
8498
8528
  dnd,
8499
8529
  initialHistory: _initialHistory
8500
8530
  } = usePropsContext();
8501
- const iframe = __spreadValues({
8502
- enabled: true,
8503
- waitForStyles: true
8504
- }, _iframe);
8531
+ const iframe = (0, import_react56.useMemo)(
8532
+ () => __spreadValues({
8533
+ enabled: true,
8534
+ waitForStyles: true
8535
+ }, _iframe),
8536
+ [_iframe]
8537
+ );
8505
8538
  useInjectGlobalCss(iframe.enabled);
8506
8539
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8507
8540
  const rightSideBarVisible = useAppStore(
8508
8541
  (s) => s.state.ui.rightSideBarVisible
8509
8542
  );
8510
- const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
8511
- const appStore = useAppStoreApi();
8512
- const rootProps = useAppStore(
8513
- (s) => s.state.data.root.props || s.state.data.root.props
8514
- );
8515
8543
  const dispatch = useAppStore((s) => s.dispatch);
8516
- const toggleSidebars = (0, import_react52.useCallback)(
8517
- (sidebar) => {
8518
- const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8519
- const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8520
- const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8521
- dispatch({
8522
- type: "setUi",
8523
- ui: __spreadValues({
8524
- [`${sidebar}SideBarVisible`]: !sideBarVisible
8525
- }, !widerViewport ? { [oppositeSideBar]: false } : {})
8526
- });
8527
- },
8528
- [dispatch, leftSideBarVisible, rightSideBarVisible]
8529
- );
8530
- (0, import_react52.useEffect)(() => {
8544
+ (0, import_react56.useEffect)(() => {
8531
8545
  if (!window.matchMedia("(min-width: 638px)").matches) {
8532
8546
  dispatch({
8533
8547
  type: "setUi",
@@ -8550,55 +8564,18 @@ function PuckLayout({ children }) {
8550
8564
  window.removeEventListener("resize", handleResize);
8551
8565
  };
8552
8566
  }, []);
8553
- const defaultHeaderRender = (0, import_react52.useMemo)(() => {
8554
- if (renderHeader) {
8555
- console.warn(
8556
- "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8557
- );
8558
- const RenderHeader = (_a) => {
8559
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8560
- const Comp = renderHeader;
8561
- const appState = useAppStore((s) => s.state);
8562
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8563
- };
8564
- return RenderHeader;
8565
- }
8566
- return DefaultOverride;
8567
- }, [renderHeader]);
8568
- const defaultHeaderActionsRender = (0, import_react52.useMemo)(() => {
8569
- if (renderHeaderActions) {
8570
- console.warn(
8571
- "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8572
- );
8573
- const RenderHeader = (props) => {
8574
- const Comp = renderHeaderActions;
8575
- const appState = useAppStore((s) => s.state);
8576
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8577
- };
8578
- return RenderHeader;
8579
- }
8580
- return DefaultOverride;
8581
- }, [renderHeader]);
8582
8567
  const overrides = useAppStore((s) => s.overrides);
8583
- const CustomPuck = (0, import_react52.useMemo)(
8568
+ const CustomPuck = (0, import_react56.useMemo)(
8584
8569
  () => overrides.puck || DefaultOverride,
8585
8570
  [overrides]
8586
8571
  );
8587
- const CustomHeader = (0, import_react52.useMemo)(
8588
- () => overrides.header || defaultHeaderRender,
8589
- [overrides]
8590
- );
8591
- const CustomHeaderActions = (0, import_react52.useMemo)(
8592
- () => overrides.headerActions || defaultHeaderActionsRender,
8593
- [overrides]
8594
- );
8595
- const [mounted, setMounted] = (0, import_react52.useState)(false);
8596
- (0, import_react52.useEffect)(() => {
8572
+ const [mounted, setMounted] = (0, import_react56.useState)(false);
8573
+ (0, import_react56.useEffect)(() => {
8597
8574
  setMounted(true);
8598
8575
  }, []);
8599
8576
  const ready = useAppStore((s) => s.status === "READY");
8600
8577
  useMonitorHotkeys();
8601
- (0, import_react52.useEffect)(() => {
8578
+ (0, import_react56.useEffect)(() => {
8602
8579
  if (ready && iframe.enabled) {
8603
8580
  const frameDoc = getFrame();
8604
8581
  if (frameDoc) {
@@ -8607,133 +8584,36 @@ function PuckLayout({ children }) {
8607
8584
  }
8608
8585
  }, [ready, iframe.enabled]);
8609
8586
  usePreviewModeHotkeys();
8610
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
8611
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8587
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: `Puck ${getClassName28()}`, children: [
8588
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8612
8589
  "div",
8613
8590
  {
8614
8591
  className: getLayoutClassName({
8615
8592
  leftSideBarVisible,
8616
- menuOpen,
8617
8593
  mounted,
8618
8594
  rightSideBarVisible
8619
8595
  }),
8620
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8621
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8622
- CustomHeader,
8623
- {
8624
- actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8625
- Button,
8626
- {
8627
- onClick: () => {
8628
- const data = appStore.getState().state.data;
8629
- onPublish && onPublish(data);
8630
- },
8631
- icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8632
- children: "Publish"
8633
- }
8634
- ) }) }),
8635
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
8636
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
8637
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8638
- "div",
8639
- {
8640
- className: getLayoutClassName("leftSideBarToggle"),
8641
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8642
- IconButton,
8643
- {
8644
- onClick: () => {
8645
- toggleSidebars("left");
8646
- },
8647
- title: "Toggle left sidebar",
8648
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8649
- }
8650
- )
8651
- }
8652
- ),
8653
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8654
- "div",
8655
- {
8656
- className: getLayoutClassName("rightSideBarToggle"),
8657
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8658
- IconButton,
8659
- {
8660
- onClick: () => {
8661
- toggleSidebars("right");
8662
- },
8663
- title: "Toggle right sidebar",
8664
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8665
- }
8666
- )
8667
- }
8668
- )
8669
- ] }),
8670
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8671
- headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
8672
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8673
- " ",
8674
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8675
- "code",
8676
- {
8677
- className: getLayoutClassName("headerPath"),
8678
- children: headerPath
8679
- }
8680
- )
8681
- ] })
8682
- ] }) }),
8683
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
8684
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8685
- IconButton,
8686
- {
8687
- onClick: () => {
8688
- return setMenuOpen(!menuOpen);
8689
- },
8690
- title: "Toggle menu bar",
8691
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8692
- }
8693
- ) }),
8694
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8695
- MenuBar,
8696
- {
8697
- dispatch,
8698
- onPublish,
8699
- menuOpen,
8700
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8701
- Button,
8702
- {
8703
- onClick: () => {
8704
- const data = appStore.getState().state.data;
8705
- onPublish && onPublish(data);
8706
- },
8707
- icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8708
- children: "Publish"
8709
- }
8710
- ) }),
8711
- setMenuOpen
8712
- }
8713
- )
8714
- ] })
8715
- ] }) })
8716
- }
8717
- ),
8718
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8719
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Components, {}) }),
8720
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Outline, {}) })
8596
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8597
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Header, {}),
8598
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8599
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Components, {}) }),
8600
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Outline, {}) })
8721
8601
  ] }),
8722
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Canvas, {}),
8723
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(FieldSideBar, {}) })
8602
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Canvas, {}),
8603
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FieldSideBar, {}) })
8724
8604
  ] })
8725
8605
  }
8726
8606
  ) }) }),
8727
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
8607
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { id: "puck-portal-root", className: getClassName28("portal") })
8728
8608
  ] });
8729
8609
  }
8730
8610
  function Puck(props) {
8731
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
8611
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
8732
8612
  }
8733
8613
  Puck.Components = Components;
8734
8614
  Puck.Fields = Fields;
8735
8615
  Puck.Outline = Outline;
8736
- Puck.Preview = Preview3;
8616
+ Puck.Preview = Preview2;
8737
8617
 
8738
8618
  // lib/migrate.ts
8739
8619
  init_react_import();
@@ -8768,7 +8648,7 @@ var migrations = [
8768
8648
  const [id, slotName] = zoneCompound.split(":");
8769
8649
  const nodeData = indexes.nodes[id].data;
8770
8650
  const componentType = nodeData.type;
8771
- const configForComponent = config.components[componentType];
8651
+ const configForComponent = id === "root" ? config.root : config.components[componentType];
8772
8652
  if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
8773
8653
  updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
8774
8654
  props: __spreadProps(__spreadValues({}, nodeData.props), {
@@ -8826,11 +8706,13 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
8826
8706
  });
8827
8707
 
8828
8708
  // lib/transform-props.ts
8829
- function transformProps(data, propTransforms) {
8709
+ function transformProps(data, propTransforms, config = { components: {} }) {
8830
8710
  const mapItem = (item) => {
8831
8711
  if (propTransforms[item.type]) {
8832
8712
  return __spreadProps(__spreadValues({}, item), {
8833
- props: propTransforms[item.type](item.props)
8713
+ props: __spreadValues({
8714
+ id: item.props.id
8715
+ }, propTransforms[item.type](item.props))
8834
8716
  });
8835
8717
  }
8836
8718
  return item;
@@ -8839,23 +8721,18 @@ function transformProps(data, propTransforms) {
8839
8721
  const rootProps = defaultedData.root.props || defaultedData.root;
8840
8722
  let newRoot = __spreadValues({}, defaultedData.root);
8841
8723
  if (propTransforms["root"]) {
8842
- if (defaultedData.root.props) {
8843
- newRoot.props = propTransforms["root"](rootProps);
8844
- } else {
8845
- newRoot = propTransforms["root"](rootProps);
8846
- }
8724
+ newRoot.props = propTransforms["root"](rootProps);
8847
8725
  }
8848
- const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
8849
- root: newRoot,
8850
- content: defaultedData.content.map(mapItem),
8851
- zones: Object.keys(data.zones || {}).reduce(
8852
- (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
8853
- [zoneKey]: data.zones[zoneKey].map(mapItem)
8854
- }),
8855
- {}
8856
- )
8857
- });
8858
- return afterPropTransforms;
8726
+ const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
8727
+ const updatedData = walkTree(
8728
+ dataWithUpdatedRoot,
8729
+ config,
8730
+ (content) => content.map(mapItem)
8731
+ );
8732
+ if (!defaultedData.root.props) {
8733
+ updatedData.root = updatedData.root.props;
8734
+ }
8735
+ return updatedData;
8859
8736
  }
8860
8737
 
8861
8738
  // lib/resolve-all-data.ts
@@ -8940,6 +8817,7 @@ function resolveAllData(_0, _1) {
8940
8817
  renderContext,
8941
8818
  resolveAllData,
8942
8819
  transformProps,
8820
+ useGetPuck,
8943
8821
  usePuck,
8944
8822
  walkTree
8945
8823
  });