@measured/puck 0.18.0-canary.066aba9 → 0.18.0-canary.9c64ea4

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -1085,7 +1085,7 @@ init_react_import();
1085
1085
  import { DragDropProvider } from "@dnd-kit/react";
1086
1086
  import { useState as useState5 } from "react";
1087
1087
 
1088
- // lib/dnd-kit/safe.ts
1088
+ // lib/dnd/dnd-kit/safe.ts
1089
1089
  init_react_import();
1090
1090
  import {
1091
1091
  useDraggable,
@@ -2334,18 +2334,19 @@ init_react_import();
2334
2334
  var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
2335
2335
 
2336
2336
  // components/Drawer/index.tsx
2337
- import { useMemo as useMemo8, useState as useState17 } from "react";
2337
+ import { useMemo as useMemo8, useState as useState18 } from "react";
2338
2338
 
2339
2339
  // components/DragDropContext/index.tsx
2340
2340
  init_react_import();
2341
2341
  import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
2342
2342
  import {
2343
2343
  createContext as createContext3,
2344
- useCallback as useCallback9,
2345
- useContext as useContext4,
2346
- useEffect as useEffect13,
2344
+ useCallback as useCallback11,
2345
+ useContext as useContext5,
2346
+ useEffect as useEffect15,
2347
+ useId,
2347
2348
  useRef as useRef5,
2348
- useState as useState16
2349
+ useState as useState17
2349
2350
  } from "react";
2350
2351
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
2351
2352
 
@@ -2353,23 +2354,22 @@ import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
2353
2354
  init_react_import();
2354
2355
  import {
2355
2356
  forwardRef as forwardRef3,
2356
- useCallback as useCallback8,
2357
- useContext as useContext3,
2358
- useEffect as useEffect12,
2357
+ useCallback as useCallback10,
2358
+ useContext as useContext4,
2359
+ useEffect as useEffect14,
2359
2360
  useMemo as useMemo7,
2360
- useRef as useRef4,
2361
- useState as useState15
2361
+ useRef as useRef4
2362
2362
  } from "react";
2363
2363
 
2364
2364
  // components/DraggableComponent/index.tsx
2365
2365
  init_react_import();
2366
2366
  import {
2367
- useCallback as useCallback6,
2368
- useContext as useContext2,
2367
+ useCallback as useCallback7,
2368
+ useContext as useContext3,
2369
2369
  useEffect as useEffect10,
2370
- useMemo as useMemo5,
2370
+ useMemo as useMemo6,
2371
2371
  useRef as useRef3,
2372
- useState as useState12
2372
+ useState as useState13
2373
2373
  } from "react";
2374
2374
 
2375
2375
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
@@ -2379,18 +2379,18 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
2379
2379
  // components/DraggableComponent/index.tsx
2380
2380
  import { createPortal as createPortal2 } from "react-dom";
2381
2381
 
2382
- // components/DraggableComponent/collision/dynamic/index.ts
2382
+ // lib/dnd/collision/dynamic/index.ts
2383
2383
  init_react_import();
2384
2384
  import {
2385
2385
  CollisionPriority as CollisionPriority7,
2386
2386
  CollisionType as CollisionType7
2387
2387
  } from "@dnd-kit/abstract";
2388
2388
 
2389
- // components/DraggableComponent/collision/directional/index.ts
2389
+ // lib/dnd/collision/directional/index.ts
2390
2390
  init_react_import();
2391
2391
  import { CollisionType } from "@dnd-kit/abstract";
2392
2392
 
2393
- // components/DraggableComponent/collision/collision-debug.ts
2393
+ // lib/dnd/collision/collision-debug.ts
2394
2394
  init_react_import();
2395
2395
  var DEBUG = false;
2396
2396
  var debugElements = {};
@@ -2439,7 +2439,7 @@ var collisionDebug = (a, b, id, color, label) => {
2439
2439
  });
2440
2440
  };
2441
2441
 
2442
- // components/DraggableComponent/collision/directional/index.ts
2442
+ // lib/dnd/collision/directional/index.ts
2443
2443
  var distanceChange = "increasing";
2444
2444
  var directionalCollision = (input, previous) => {
2445
2445
  var _a;
@@ -2472,7 +2472,7 @@ var directionalCollision = (input, previous) => {
2472
2472
  return null;
2473
2473
  };
2474
2474
 
2475
- // components/DraggableComponent/collision/dynamic/get-direction.ts
2475
+ // lib/dnd/collision/dynamic/get-direction.ts
2476
2476
  init_react_import();
2477
2477
  var getDirection = (dragAxis, delta) => {
2478
2478
  if (dragAxis === "dynamic") {
@@ -2487,7 +2487,7 @@ var getDirection = (dragAxis, delta) => {
2487
2487
  return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2488
2488
  };
2489
2489
 
2490
- // components/DraggableComponent/collision/dynamic/get-midpoint-impact.ts
2490
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
2491
2491
  init_react_import();
2492
2492
  var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
2493
2493
  const dragRect = dragShape.boundingRectangle;
@@ -2506,7 +2506,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2506
2506
  return dragRect.right - offset >= dropCenter.x;
2507
2507
  };
2508
2508
 
2509
- // components/DraggableComponent/collision/dynamic/track-movement-interval.ts
2509
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
2510
2510
  init_react_import();
2511
2511
  import { Point } from "@dnd-kit/geometry";
2512
2512
  var INTERVAL_SENSITIVITY = 10;
@@ -2610,7 +2610,14 @@ var closestCorners = (input) => {
2610
2610
  };
2611
2611
  };
2612
2612
 
2613
- // components/DraggableComponent/collision/dynamic/index.ts
2613
+ // lib/dnd/collision/dynamic/store.ts
2614
+ init_react_import();
2615
+ import { createStore } from "zustand/vanilla";
2616
+ var collisionStore = createStore(() => ({
2617
+ fallbackEnabled: false
2618
+ }));
2619
+
2620
+ // lib/dnd/collision/dynamic/index.ts
2614
2621
  var flushNext = "";
2615
2622
  var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2616
2623
  var _a, _b, _c, _d, _e;
@@ -2622,6 +2629,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2622
2629
  return null;
2623
2630
  }
2624
2631
  const { center: dragCenter } = dragShape;
2632
+ const { fallbackEnabled } = collisionStore.getState();
2625
2633
  const interval = trackMovementInterval(position.current, dragAxis);
2626
2634
  dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2627
2635
  direction: interval.direction
@@ -2667,7 +2675,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2667
2675
  flushNext = "";
2668
2676
  return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2669
2677
  }
2670
- if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2678
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2671
2679
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
2672
2680
  const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
2673
2681
  if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
@@ -2728,8 +2736,107 @@ function getDeepScrollPosition(element) {
2728
2736
  return totalScroll;
2729
2737
  }
2730
2738
 
2739
+ // components/DropZone/context.tsx
2740
+ init_react_import();
2741
+ import {
2742
+ createContext as createContext2,
2743
+ useCallback as useCallback6,
2744
+ useMemo as useMemo5,
2745
+ useState as useState12
2746
+ } from "react";
2747
+ import { createStore as createStore2 } from "zustand";
2748
+ import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
2749
+ var dropZoneContext = createContext2(null);
2750
+ var ZoneStoreContext = createContext2(
2751
+ createStore2(() => ({
2752
+ zoneDepthIndex: {},
2753
+ nextZoneDepthIndex: {},
2754
+ areaDepthIndex: {},
2755
+ nextAreaDepthIndex: {},
2756
+ draggedItem: null,
2757
+ previewIndex: {}
2758
+ }))
2759
+ );
2760
+ var ZoneStoreProvider = ({
2761
+ children,
2762
+ store
2763
+ }) => {
2764
+ return /* @__PURE__ */ jsx19(ZoneStoreContext.Provider, { value: store, children });
2765
+ };
2766
+ var DropZoneProvider = ({
2767
+ children,
2768
+ value
2769
+ }) => {
2770
+ const [hoveringComponent, setHoveringComponent] = useState12();
2771
+ const [areasWithZones, setAreasWithZones] = useState12(
2772
+ {}
2773
+ );
2774
+ const [activeZones, setActiveZones] = useState12({});
2775
+ const { dispatch } = useAppContext();
2776
+ const registerZoneArea = useCallback6(
2777
+ (area) => {
2778
+ setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
2779
+ },
2780
+ [setAreasWithZones]
2781
+ );
2782
+ const registerZone = useCallback6(
2783
+ (zoneCompound) => {
2784
+ if (!dispatch) {
2785
+ return;
2786
+ }
2787
+ dispatch({
2788
+ type: "registerZone",
2789
+ zone: zoneCompound
2790
+ });
2791
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
2792
+ },
2793
+ [setActiveZones, dispatch]
2794
+ );
2795
+ const unregisterZone = useCallback6(
2796
+ (zoneCompound) => {
2797
+ if (!dispatch) {
2798
+ return;
2799
+ }
2800
+ dispatch({
2801
+ type: "unregisterZone",
2802
+ zone: zoneCompound
2803
+ });
2804
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
2805
+ [zoneCompound]: false
2806
+ }));
2807
+ },
2808
+ [setActiveZones, dispatch]
2809
+ );
2810
+ const memoValue = useMemo5(
2811
+ () => __spreadValues({
2812
+ hoveringComponent,
2813
+ setHoveringComponent,
2814
+ registerZoneArea,
2815
+ areasWithZones,
2816
+ registerZone,
2817
+ unregisterZone,
2818
+ activeZones
2819
+ }, value),
2820
+ [value, hoveringComponent, areasWithZones, activeZones]
2821
+ );
2822
+ return /* @__PURE__ */ jsx19(Fragment5, { children: memoValue && /* @__PURE__ */ jsx19(dropZoneContext.Provider, { value: memoValue, children }) });
2823
+ };
2824
+
2825
+ // lib/use-context-store.ts
2826
+ init_react_import();
2827
+ import { useContext as useContext2 } from "react";
2828
+ import { useStore } from "zustand";
2829
+ import { useShallow } from "zustand/react/shallow";
2830
+ function useContextStore(context, selector) {
2831
+ const store = useContext2(context);
2832
+ if (!store) {
2833
+ throw new Error("useContextStore must be used inside context");
2834
+ }
2835
+ return useStore(store, useShallow(selector));
2836
+ }
2837
+
2731
2838
  // components/DraggableComponent/index.tsx
2732
- import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
2839
+ import { jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
2733
2840
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
2734
2841
  var DEBUG2 = false;
2735
2842
  var space = 8;
@@ -2743,9 +2850,9 @@ var DefaultActionBar = ({
2743
2850
  }) => /* @__PURE__ */ jsxs9(ActionBar, { children: [
2744
2851
  /* @__PURE__ */ jsxs9(ActionBar.Group, { children: [
2745
2852
  parentAction,
2746
- label && /* @__PURE__ */ jsx19(ActionBar.Label, { label })
2853
+ label && /* @__PURE__ */ jsx20(ActionBar.Label, { label })
2747
2854
  ] }),
2748
- /* @__PURE__ */ jsx19(ActionBar.Group, { children })
2855
+ /* @__PURE__ */ jsx20(ActionBar.Group, { children })
2749
2856
  ] });
2750
2857
  var convertIdToSelector = (id, zoneCompound, data) => {
2751
2858
  const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
@@ -2780,9 +2887,9 @@ var DraggableComponent = ({
2780
2887
  iframe,
2781
2888
  state
2782
2889
  } = useAppContext();
2783
- const ctx = useContext2(dropZoneContext);
2784
- const [localZones, setLocalZones] = useState12({});
2785
- const registerLocalZone = useCallback6(
2890
+ const ctx = useContext3(dropZoneContext);
2891
+ const [localZones, setLocalZones] = useState13({});
2892
+ const registerLocalZone = useCallback7(
2786
2893
  (zoneCompound2, active) => {
2787
2894
  var _a;
2788
2895
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -2792,7 +2899,7 @@ var DraggableComponent = ({
2792
2899
  },
2793
2900
  [setLocalZones]
2794
2901
  );
2795
- const unregisterLocalZone = useCallback6(
2902
+ const unregisterLocalZone = useCallback7(
2796
2903
  (zoneCompound2) => {
2797
2904
  var _a;
2798
2905
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -2806,7 +2913,7 @@ var DraggableComponent = ({
2806
2913
  );
2807
2914
  const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
2808
2915
  const { path = [] } = ctx || {};
2809
- const [canDrag, setCanDrag] = useState12(false);
2916
+ const [canDrag, setCanDrag] = useState13(false);
2810
2917
  useEffect10(() => {
2811
2918
  var _a;
2812
2919
  const item = getItem({ index, zone: zoneCompound }, state.data);
@@ -2817,10 +2924,13 @@ var DraggableComponent = ({
2817
2924
  setCanDrag((_a = perms.drag) != null ? _a : true);
2818
2925
  }
2819
2926
  }, [state, index, zoneCompound, getPermissions]);
2820
- const userIsDragging = !!(ctx == null ? void 0 : ctx.draggedItem);
2927
+ const userIsDragging = useContextStore(
2928
+ ZoneStoreContext,
2929
+ (s) => !!s.draggedItem
2930
+ );
2821
2931
  const canCollide = canDrag || userIsDragging;
2822
2932
  const disabled = !isEnabled || !canCollide;
2823
- const [dragAxis, setDragAxis] = useState12(userDragAxis || autoDragAxis);
2933
+ const [dragAxis, setDragAxis] = useState13(userDragAxis || autoDragAxis);
2824
2934
  const { ref: sortableRef, status } = useSortableSafe({
2825
2935
  id,
2826
2936
  index,
@@ -2847,7 +2957,7 @@ var DraggableComponent = ({
2847
2957
  });
2848
2958
  const thisIsDragging = status === "dragging";
2849
2959
  const ref = useRef3(null);
2850
- const refSetter = useCallback6(
2960
+ const refSetter = useCallback7(
2851
2961
  (el) => {
2852
2962
  sortableRef(el);
2853
2963
  if (el) {
@@ -2856,14 +2966,14 @@ var DraggableComponent = ({
2856
2966
  },
2857
2967
  [sortableRef]
2858
2968
  );
2859
- const [portalEl, setPortalEl] = useState12();
2969
+ const [portalEl, setPortalEl] = useState13();
2860
2970
  useEffect10(() => {
2861
2971
  var _a, _b, _c;
2862
2972
  setPortalEl(
2863
2973
  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
2864
2974
  );
2865
2975
  }, [iframe.enabled, ref.current]);
2866
- const getStyle = useCallback6(() => {
2976
+ const getStyle = useCallback7(() => {
2867
2977
  var _a, _b, _c;
2868
2978
  if (!ref.current) return;
2869
2979
  const rect = ref.current.getBoundingClientRect();
@@ -2883,8 +2993,8 @@ var DraggableComponent = ({
2883
2993
  };
2884
2994
  return style2;
2885
2995
  }, [ref.current]);
2886
- const [style, setStyle] = useState12();
2887
- const sync = useCallback6(() => {
2996
+ const [style, setStyle] = useState13();
2997
+ const sync = useCallback7(() => {
2888
2998
  setStyle(getStyle());
2889
2999
  }, [ref.current, iframe]);
2890
3000
  useEffect10(() => {
@@ -2897,19 +3007,21 @@ var DraggableComponent = ({
2897
3007
  }
2898
3008
  }, [ref.current]);
2899
3009
  useEffect10(() => {
2900
- ctx == null ? void 0 : ctx.registerPath({
2901
- index,
2902
- zone: zoneCompound
2903
- });
3010
+ if (isSelected) {
3011
+ ctx == null ? void 0 : ctx.registerPath({
3012
+ index,
3013
+ zone: zoneCompound
3014
+ });
3015
+ }
2904
3016
  }, [isSelected]);
2905
- const CustomActionBar = useMemo5(
3017
+ const CustomActionBar = useMemo6(
2906
3018
  () => overrides.actionBar || DefaultActionBar,
2907
3019
  [overrides.actionBar]
2908
3020
  );
2909
3021
  const permissions = getPermissions({
2910
3022
  item: selectedItem
2911
3023
  });
2912
- const onClick = useCallback6(
3024
+ const onClick = useCallback7(
2913
3025
  (e) => {
2914
3026
  e.stopPropagation();
2915
3027
  dispatch({
@@ -2921,7 +3033,7 @@ var DraggableComponent = ({
2921
3033
  },
2922
3034
  [index, zoneCompound, id]
2923
3035
  );
2924
- const onSelectParent = useCallback6(() => {
3036
+ const onSelectParent = useCallback7(() => {
2925
3037
  if (!(ctx == null ? void 0 : ctx.areaId)) {
2926
3038
  return;
2927
3039
  }
@@ -2939,21 +3051,21 @@ var DraggableComponent = ({
2939
3051
  }
2940
3052
  });
2941
3053
  }, [ctx, path]);
2942
- const onDuplicate = useCallback6(() => {
3054
+ const onDuplicate = useCallback7(() => {
2943
3055
  dispatch({
2944
3056
  type: "duplicate",
2945
3057
  sourceIndex: index,
2946
3058
  sourceZone: zoneCompound
2947
3059
  });
2948
3060
  }, [index, zoneCompound]);
2949
- const onDelete = useCallback6(() => {
3061
+ const onDelete = useCallback7(() => {
2950
3062
  dispatch({
2951
3063
  type: "remove",
2952
3064
  index,
2953
3065
  zone: zoneCompound
2954
3066
  });
2955
3067
  }, [index, zoneCompound]);
2956
- const [hover, setHover] = useState12(false);
3068
+ const [hover, setHover] = useState13(false);
2957
3069
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
2958
3070
  useEffect10(() => {
2959
3071
  if (!ref.current) {
@@ -3014,7 +3126,7 @@ var DraggableComponent = ({
3014
3126
  };
3015
3127
  }
3016
3128
  }, [disabled, ref]);
3017
- const [isVisible, setIsVisible] = useState12(false);
3129
+ const [isVisible, setIsVisible] = useState13(false);
3018
3130
  useEffect10(() => {
3019
3131
  sync();
3020
3132
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
@@ -3023,7 +3135,7 @@ var DraggableComponent = ({
3023
3135
  setIsVisible(false);
3024
3136
  }
3025
3137
  }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3026
- const syncActionsPosition = useCallback6(
3138
+ const syncActionsPosition = useCallback7(
3027
3139
  (el) => {
3028
3140
  if (el) {
3029
3141
  const view = el.ownerDocument.defaultView;
@@ -3054,7 +3166,7 @@ var DraggableComponent = ({
3054
3166
  }
3055
3167
  setDragAxis(autoDragAxis);
3056
3168
  }, [ref, userDragAxis, autoDragAxis]);
3057
- const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx19(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx19(CornerLeftUp, { size: 16 }) });
3169
+ const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx20(CornerLeftUp, { size: 16 }) });
3058
3170
  return /* @__PURE__ */ jsxs9(
3059
3171
  DropZoneProvider,
3060
3172
  {
@@ -3081,15 +3193,15 @@ var DraggableComponent = ({
3081
3193
  "data-puck-overlay": true,
3082
3194
  children: [
3083
3195
  debug,
3084
- isLoading && /* @__PURE__ */ jsx19("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx19(Loader, {}) }),
3085
- /* @__PURE__ */ jsx19(
3196
+ isLoading && /* @__PURE__ */ jsx20("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx20(Loader, {}) }),
3197
+ /* @__PURE__ */ jsx20(
3086
3198
  "div",
3087
3199
  {
3088
3200
  className: getClassName16("actionsOverlay"),
3089
3201
  style: {
3090
3202
  top: actionsOverlayTop / zoomConfig.zoom
3091
3203
  },
3092
- children: /* @__PURE__ */ jsx19(
3204
+ children: /* @__PURE__ */ jsx20(
3093
3205
  "div",
3094
3206
  {
3095
3207
  className: getClassName16("actions"),
@@ -3107,8 +3219,8 @@ var DraggableComponent = ({
3107
3219
  parentAction,
3108
3220
  label: DEBUG2 ? id : label,
3109
3221
  children: [
3110
- permissions.duplicate && /* @__PURE__ */ jsx19(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx19(Copy, { size: 16 }) }),
3111
- permissions.delete && /* @__PURE__ */ jsx19(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx19(Trash, { size: 16 }) })
3222
+ permissions.duplicate && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx20(Copy, { size: 16 }) }),
3223
+ permissions.delete && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx20(Trash, { size: 16 }) })
3112
3224
  ]
3113
3225
  }
3114
3226
  )
@@ -3116,7 +3228,7 @@ var DraggableComponent = ({
3116
3228
  )
3117
3229
  }
3118
3230
  ),
3119
- /* @__PURE__ */ jsx19("div", { className: getClassName16("overlay") })
3231
+ /* @__PURE__ */ jsx20("div", { className: getClassName16("overlay") })
3120
3232
  ]
3121
3233
  }
3122
3234
  ),
@@ -3132,98 +3244,26 @@ var DraggableComponent = ({
3132
3244
  init_react_import();
3133
3245
  var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isActive": "_DropZone--isActive_kmkdc_10", "DropZone--hasChildren": "_DropZone--hasChildren_kmkdc_14", "DropZone--userIsDragging": "_DropZone--userIsDragging_kmkdc_22", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_kmkdc_26", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_kmkdc_27", "DropZone--isRootZone": "_DropZone--isRootZone_kmkdc_27", "DropZone--isDestination": "_DropZone--isDestination_kmkdc_37", "DropZone-item": "_DropZone-item_kmkdc_49", "DropZone-hitbox": "_DropZone-hitbox_kmkdc_53", "DropZone--isEnabled": "_DropZone--isEnabled_kmkdc_61", "DropZone--isAnimating": "_DropZone--isAnimating_kmkdc_70" };
3134
3246
 
3135
- // components/DropZone/context.tsx
3136
- init_react_import();
3137
- import {
3138
- createContext as createContext2,
3139
- useCallback as useCallback7,
3140
- useMemo as useMemo6,
3141
- useState as useState13
3142
- } from "react";
3143
- import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
3144
- var dropZoneContext = createContext2(null);
3145
- var DropZoneProvider = ({
3146
- children,
3147
- value
3148
- }) => {
3149
- const [hoveringComponent, setHoveringComponent] = useState13();
3150
- const [areasWithZones, setAreasWithZones] = useState13(
3151
- {}
3152
- );
3153
- const [activeZones, setActiveZones] = useState13({});
3154
- const { dispatch } = useAppContext();
3155
- const registerZoneArea = useCallback7(
3156
- (area) => {
3157
- setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
3158
- },
3159
- [setAreasWithZones]
3160
- );
3161
- const registerZone = useCallback7(
3162
- (zoneCompound) => {
3163
- if (!dispatch) {
3164
- return;
3165
- }
3166
- dispatch({
3167
- type: "registerZone",
3168
- zone: zoneCompound
3169
- });
3170
- setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
3171
- },
3172
- [setActiveZones, dispatch]
3173
- );
3174
- const unregisterZone = useCallback7(
3175
- (zoneCompound) => {
3176
- if (!dispatch) {
3177
- return;
3178
- }
3179
- dispatch({
3180
- type: "unregisterZone",
3181
- zone: zoneCompound
3182
- });
3183
- setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
3184
- [zoneCompound]: false
3185
- }));
3186
- },
3187
- [setActiveZones, dispatch]
3188
- );
3189
- const memoValue = useMemo6(
3190
- () => __spreadValues({
3191
- hoveringComponent,
3192
- setHoveringComponent,
3193
- registerZoneArea,
3194
- areasWithZones,
3195
- registerZone,
3196
- unregisterZone,
3197
- activeZones
3198
- }, value),
3199
- [value, hoveringComponent, areasWithZones, activeZones]
3200
- );
3201
- return /* @__PURE__ */ jsx20(Fragment5, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
3202
- };
3203
-
3204
- // lib/insert.ts
3205
- init_react_import();
3206
- var insert = (list, index, item) => {
3207
- const result = Array.from(list);
3208
- result.splice(index, 0, item);
3209
- return result;
3210
- };
3211
-
3212
- // components/DropZone/use-min-empty-height.ts
3247
+ // components/DropZone/lib/use-min-empty-height.ts
3213
3248
  init_react_import();
3214
3249
  import { useEffect as useEffect11, useState as useState14 } from "react";
3215
3250
  var useMinEmptyHeight = ({
3216
- draggedItem,
3217
3251
  zoneCompound,
3218
3252
  userMinEmptyHeight,
3219
3253
  ref
3220
3254
  }) => {
3221
3255
  const [prevHeight, setPrevHeight] = useState14(0);
3222
3256
  const [isAnimating, setIsAnimating] = useState14(false);
3257
+ const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3258
+ var _a, _b;
3259
+ return {
3260
+ draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
3261
+ isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
3262
+ };
3263
+ });
3223
3264
  useEffect11(() => {
3224
3265
  if (draggedItem && ref.current) {
3225
- const componentData = draggedItem.data;
3226
- if (componentData.zone === zoneCompound) {
3266
+ if (isZone) {
3227
3267
  const rect = ref.current.getBoundingClientRect();
3228
3268
  setPrevHeight(rect.height);
3229
3269
  setIsAnimating(true);
@@ -3253,13 +3293,128 @@ function assignRefs(refs, node) {
3253
3293
  });
3254
3294
  }
3255
3295
 
3256
- // components/DropZone/index.tsx
3257
- import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
3258
- var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3259
- var DEBUG3 = false;
3296
+ // components/DropZone/lib/use-content-with-preview.ts
3297
+ init_react_import();
3298
+ import { useEffect as useEffect12, useState as useState15 } from "react";
3299
+
3300
+ // lib/dnd/use-rendered-callback.ts
3301
+ init_react_import();
3302
+ import { useDragDropManager } from "@dnd-kit/react";
3303
+ import { useCallback as useCallback8 } from "react";
3304
+ function useRenderedCallback(callback, deps) {
3305
+ const manager = useDragDropManager();
3306
+ return useCallback8(
3307
+ (...args) => __async(this, null, function* () {
3308
+ yield manager == null ? void 0 : manager.renderer.rendering;
3309
+ return callback(...args);
3310
+ }),
3311
+ [...deps, manager]
3312
+ );
3313
+ }
3314
+
3315
+ // lib/insert.ts
3316
+ init_react_import();
3317
+ var insert = (list, index, item) => {
3318
+ const result = Array.from(list);
3319
+ result.splice(index, 0, item);
3320
+ return result;
3321
+ };
3322
+
3323
+ // components/DropZone/lib/use-content-with-preview.ts
3324
+ var useContentWithPreview = (content, zoneCompound) => {
3325
+ const { draggedItemId, preview, previewExists } = useContextStore(
3326
+ ZoneStoreContext,
3327
+ (s) => {
3328
+ var _a;
3329
+ return {
3330
+ draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
3331
+ preview: s.previewIndex[zoneCompound],
3332
+ previewExists: Object.keys(s.previewIndex || {}).length > 0
3333
+ };
3334
+ }
3335
+ );
3336
+ const [contentWithPreview, setContentWithPreview] = useState15(content);
3337
+ const updateContent = useRenderedCallback(
3338
+ (content2, preview2) => {
3339
+ if (preview2) {
3340
+ if (preview2.type === "insert") {
3341
+ setContentWithPreview(
3342
+ insert(
3343
+ content2.filter((item) => item.props.id !== preview2.props.id),
3344
+ preview2.index,
3345
+ {
3346
+ type: "preview",
3347
+ props: { id: preview2.props.id }
3348
+ }
3349
+ )
3350
+ );
3351
+ } else {
3352
+ setContentWithPreview(
3353
+ insert(
3354
+ content2.filter((item) => item.props.id !== preview2.props.id),
3355
+ preview2.index,
3356
+ {
3357
+ type: preview2.componentType,
3358
+ props: preview2.props
3359
+ }
3360
+ )
3361
+ );
3362
+ }
3363
+ } else {
3364
+ setContentWithPreview(
3365
+ previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
3366
+ );
3367
+ }
3368
+ },
3369
+ [draggedItemId, previewExists]
3370
+ );
3371
+ useEffect12(() => {
3372
+ updateContent(content, preview);
3373
+ }, [content, preview]);
3374
+ return contentWithPreview;
3375
+ };
3376
+
3377
+ // components/DropZone/lib/use-drag-axis.ts
3378
+ init_react_import();
3379
+ import { useCallback as useCallback9, useEffect as useEffect13, useState as useState16 } from "react";
3260
3380
  var GRID_DRAG_AXIS = "dynamic";
3261
3381
  var FLEX_ROW_DRAG_AXIS = "x";
3262
3382
  var DEFAULT_DRAG_AXIS = "y";
3383
+ var useDragAxis = (ref, collisionAxis) => {
3384
+ const { status } = useAppContext();
3385
+ const [dragAxis, setDragAxis] = useState16(
3386
+ collisionAxis || DEFAULT_DRAG_AXIS
3387
+ );
3388
+ const calculateDragAxis = useCallback9(() => {
3389
+ if (ref.current) {
3390
+ const computedStyle = window.getComputedStyle(ref.current);
3391
+ if (computedStyle.display === "grid") {
3392
+ setDragAxis(GRID_DRAG_AXIS);
3393
+ } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3394
+ setDragAxis(FLEX_ROW_DRAG_AXIS);
3395
+ } else {
3396
+ setDragAxis(DEFAULT_DRAG_AXIS);
3397
+ }
3398
+ }
3399
+ }, [ref.current]);
3400
+ useEffect13(() => {
3401
+ const onViewportChange = () => {
3402
+ calculateDragAxis();
3403
+ };
3404
+ window.addEventListener("viewportchange", onViewportChange);
3405
+ return () => {
3406
+ window.removeEventListener("viewportchange", onViewportChange);
3407
+ };
3408
+ }, []);
3409
+ useEffect13(calculateDragAxis, [status, collisionAxis]);
3410
+ return [dragAxis, calculateDragAxis];
3411
+ };
3412
+
3413
+ // components/DropZone/index.tsx
3414
+ import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
3415
+ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3416
+ var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3417
+ var RENDER_DEBUG = false;
3263
3418
  var DropZoneEdit = forwardRef3(
3264
3419
  function DropZoneEdit2({
3265
3420
  zone,
@@ -3271,31 +3426,50 @@ var DropZoneEdit = forwardRef3(
3271
3426
  collisionAxis
3272
3427
  }, userRef) {
3273
3428
  const appContext2 = useAppContext();
3274
- const ctx = useContext3(dropZoneContext);
3429
+ const ctx = useContext4(dropZoneContext);
3275
3430
  const {
3276
3431
  // These all need setting via context
3277
3432
  data,
3278
3433
  config,
3279
3434
  areaId,
3280
- draggedItem,
3281
3435
  registerZoneArea,
3282
3436
  depth,
3283
3437
  registerLocalZone,
3284
3438
  unregisterLocalZone,
3285
- deepestZone = rootDroppableId,
3286
- deepestArea,
3287
- nextDeepestArea,
3288
3439
  path = [],
3289
3440
  activeZones
3290
3441
  } = ctx;
3291
- const { itemSelector } = appContext2.state.ui;
3292
3442
  let zoneCompound = rootDroppableId;
3293
- useEffect12(() => {
3443
+ if (areaId) {
3444
+ if (zone !== rootDroppableId) {
3445
+ zoneCompound = `${areaId}:${zone}`;
3446
+ }
3447
+ }
3448
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3449
+ const {
3450
+ isDeepestZone,
3451
+ inNextDeepestArea,
3452
+ draggedComponentType,
3453
+ userIsDragging,
3454
+ preview
3455
+ } = useContextStore(ZoneStoreContext, (s) => {
3456
+ var _a, _b, _c;
3457
+ return {
3458
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3459
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3460
+ draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3461
+ draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3462
+ userIsDragging: !!s.draggedItem,
3463
+ preview: s.previewIndex[zoneCompound]
3464
+ };
3465
+ });
3466
+ const { itemSelector } = appContext2.state.ui;
3467
+ useEffect14(() => {
3294
3468
  if (areaId && registerZoneArea) {
3295
3469
  registerZoneArea(areaId);
3296
3470
  }
3297
3471
  }, [areaId]);
3298
- useEffect12(() => {
3472
+ useEffect14(() => {
3299
3473
  if (ctx == null ? void 0 : ctx.registerZone) {
3300
3474
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3301
3475
  }
@@ -3305,11 +3479,6 @@ var DropZoneEdit = forwardRef3(
3305
3479
  }
3306
3480
  };
3307
3481
  }, []);
3308
- if (areaId) {
3309
- if (zone !== rootDroppableId) {
3310
- zoneCompound = `${areaId}:${zone}`;
3311
- }
3312
- }
3313
3482
  const content = useMemo7(() => {
3314
3483
  if (areaId && zone !== rootDroppableId) {
3315
3484
  return setupZone(data, zoneCompound).zones[zoneCompound];
@@ -3317,13 +3486,11 @@ var DropZoneEdit = forwardRef3(
3317
3486
  return data.content || [];
3318
3487
  }, [data, zoneCompound]);
3319
3488
  const ref = useRef4(null);
3320
- const acceptsTarget = useCallback8(
3321
- (target) => {
3322
- if (!target) {
3489
+ const acceptsTarget = useCallback10(
3490
+ (componentType) => {
3491
+ if (!componentType) {
3323
3492
  return true;
3324
3493
  }
3325
- const data2 = target.data;
3326
- const { componentType } = data2;
3327
3494
  if (disallow) {
3328
3495
  const defaultedAllow = allow || [];
3329
3496
  const filteredDisallow = (disallow || []).filter(
@@ -3341,49 +3508,26 @@ var DropZoneEdit = forwardRef3(
3341
3508
  },
3342
3509
  [allow, disallow]
3343
3510
  );
3344
- useEffect12(() => {
3511
+ useEffect14(() => {
3345
3512
  if (registerLocalZone) {
3346
- registerLocalZone(zoneCompound, acceptsTarget(draggedItem));
3513
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3347
3514
  }
3348
3515
  return () => {
3349
3516
  if (unregisterLocalZone) {
3350
3517
  unregisterLocalZone(zoneCompound);
3351
3518
  }
3352
3519
  };
3353
- }, [draggedItem, zoneCompound]);
3354
- const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3355
- const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
3356
- const userIsDragging = !!draggedItem;
3520
+ }, [draggedComponentType, zoneCompound]);
3521
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3357
3522
  let isEnabled = true;
3358
- if (draggedItem) {
3359
- isEnabled = deepestZone === zoneCompound;
3523
+ if (userIsDragging) {
3524
+ isEnabled = isDeepestZone;
3360
3525
  }
3361
3526
  if (isEnabled) {
3362
- isEnabled = acceptsTarget(draggedItem);
3363
- }
3364
- const preview = useContext3(previewContext);
3365
- const previewInZone = (preview == null ? void 0 : preview.zone) === zoneCompound;
3366
- const contentWithPreview = useMemo7(() => {
3367
- let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
3368
- if (previewInZone) {
3369
- contentWithPreview2 = content.filter(
3370
- (item) => item.props.id !== preview.props.id
3371
- );
3372
- if (preview.type === "insert") {
3373
- contentWithPreview2 = insert(contentWithPreview2, preview.index, {
3374
- type: "preview",
3375
- props: { id: preview.props.id }
3376
- });
3377
- } else {
3378
- contentWithPreview2 = insert(contentWithPreview2, preview.index, {
3379
- type: preview.componentType,
3380
- props: preview.props
3381
- });
3382
- }
3383
- }
3384
- return contentWithPreview2;
3385
- }, [preview, content]);
3386
- const isDropEnabled = isEnabled && (previewInZone ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3527
+ isEnabled = acceptsTarget(draggedComponentType);
3528
+ }
3529
+ const contentWithPreview = useContentWithPreview(content, zoneCompound);
3530
+ const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3387
3531
  const droppableConfig = {
3388
3532
  id: zoneCompound,
3389
3533
  collisionPriority: isEnabled ? depth : 0,
@@ -3393,45 +3537,20 @@ var DropZoneEdit = forwardRef3(
3393
3537
  data: {
3394
3538
  areaId,
3395
3539
  depth,
3396
- isDroppableTarget: acceptsTarget(draggedItem),
3540
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3397
3541
  path
3398
3542
  }
3399
3543
  };
3400
3544
  const { ref: dropRef } = useDroppableSafe(droppableConfig);
3401
3545
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
3402
3546
  const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
3403
- const [dragAxis, setDragAxis] = useState15(
3404
- collisionAxis || DEFAULT_DRAG_AXIS
3405
- );
3406
- const calculateDragAxis = useCallback8(() => {
3407
- if (ref.current) {
3408
- const computedStyle = window.getComputedStyle(ref.current);
3409
- if (computedStyle.display === "grid") {
3410
- setDragAxis(GRID_DRAG_AXIS);
3411
- } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3412
- setDragAxis(FLEX_ROW_DRAG_AXIS);
3413
- } else {
3414
- setDragAxis(DEFAULT_DRAG_AXIS);
3415
- }
3416
- }
3417
- }, [ref.current]);
3418
- useEffect12(calculateDragAxis, [appContext2.status, collisionAxis]);
3419
- useEffect12(() => {
3420
- const onViewportChange = () => {
3421
- calculateDragAxis();
3422
- };
3423
- window.addEventListener("viewportchange", onViewportChange);
3424
- return () => {
3425
- window.removeEventListener("viewportchange", onViewportChange);
3426
- };
3427
- }, []);
3547
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3428
3548
  const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3429
- draggedItem,
3430
3549
  zoneCompound,
3431
3550
  userMinEmptyHeight,
3432
3551
  ref
3433
3552
  });
3434
- return /* @__PURE__ */ jsxs10(
3553
+ return /* @__PURE__ */ jsx21(
3435
3554
  "div",
3436
3555
  {
3437
3556
  className: `${getClassName17({
@@ -3451,88 +3570,83 @@ var DropZoneEdit = forwardRef3(
3451
3570
  "data-puck-dropzone": zoneCompound,
3452
3571
  "data-puck-dnd": zoneCompound,
3453
3572
  style: __spreadProps(__spreadValues({}, style), {
3454
- "--min-empty-height": `${minEmptyHeight}px`
3573
+ "--min-empty-height": `${minEmptyHeight}px`,
3574
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3455
3575
  }),
3456
- children: [
3457
- isRootZone && DEBUG3 && /* @__PURE__ */ jsxs10("div", { "data-puck-component": true, children: [
3458
- /* @__PURE__ */ jsx21("p", { children: deepestZone || rootDroppableId }),
3459
- /* @__PURE__ */ jsx21("p", { children: deepestArea || "No area" })
3460
- ] }),
3461
- contentWithPreview.map((item, i) => {
3462
- var _a, _b, _c, _d, _e;
3463
- const componentId = item.props.id;
3464
- const puckProps = {
3465
- renderDropZone: DropZone,
3466
- isEditing: true,
3467
- dragRef: null
3576
+ children: contentWithPreview.map((item, i) => {
3577
+ var _a, _b, _c, _d, _e;
3578
+ const componentId = item.props.id;
3579
+ const puckProps = {
3580
+ renderDropZone: DropZone,
3581
+ isEditing: true,
3582
+ dragRef: null
3583
+ };
3584
+ const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3585
+ puck: puckProps,
3586
+ editMode: true
3587
+ // DEPRECATED
3588
+ });
3589
+ const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3590
+ let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
3591
+ "No configuration for ",
3592
+ item.type
3593
+ ] });
3594
+ const componentConfig = config.components[item.type];
3595
+ let componentType = item.type;
3596
+ let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3597
+ if (item.type === "preview" && preview) {
3598
+ let Preview4 = function() {
3599
+ return /* @__PURE__ */ jsx21(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3468
3600
  };
3469
- const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
3470
- puck: puckProps,
3471
- editMode: true
3472
- // DEPRECATED
3473
- });
3474
- const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
3475
- let Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
3476
- "No configuration for ",
3477
- item.type
3478
- ] });
3479
- const componentConfig = config.components[item.type];
3480
- let componentType = item.type;
3481
- let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3482
- if (item.type === "preview") {
3483
- let Preview3 = function() {
3484
- return /* @__PURE__ */ jsx21(DrawerItemInner, { name: label });
3485
- };
3486
- var Preview2 = Preview3;
3487
- componentType = preview.componentType;
3488
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3489
- Render2 = Preview3;
3490
- }
3491
- return /* @__PURE__ */ jsx21(
3492
- DropZoneProvider,
3493
- {
3494
- value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3495
- children: /* @__PURE__ */ jsx21(
3496
- DraggableComponent,
3497
- {
3498
- id: componentId,
3499
- componentType,
3500
- zoneCompound,
3501
- depth: depth + 1,
3502
- index: i,
3503
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3504
- isSelected,
3505
- label,
3506
- isEnabled,
3507
- autoDragAxis: dragAxis,
3508
- userDragAxis: collisionAxis,
3509
- inDroppableZone: acceptsTarget(draggedItem),
3510
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx21(
3511
- Render2,
3512
- __spreadProps(__spreadValues({}, defaultedProps), {
3513
- puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3514
- dragRef
3515
- })
3601
+ var Preview3 = Preview4;
3602
+ componentType = preview.componentType;
3603
+ label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3604
+ Render2 = Preview4;
3605
+ }
3606
+ return /* @__PURE__ */ jsx21(
3607
+ DropZoneProvider,
3608
+ {
3609
+ value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
3610
+ children: /* @__PURE__ */ jsx21(
3611
+ DraggableComponent,
3612
+ {
3613
+ id: componentId,
3614
+ componentType,
3615
+ zoneCompound,
3616
+ depth: depth + 1,
3617
+ index: i,
3618
+ isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3619
+ isSelected,
3620
+ label,
3621
+ isEnabled,
3622
+ autoDragAxis: dragAxis,
3623
+ userDragAxis: collisionAxis,
3624
+ inDroppableZone: acceptsTarget(draggedComponentType),
3625
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx21(
3626
+ Render2,
3627
+ __spreadProps(__spreadValues({}, defaultedProps), {
3628
+ puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
3629
+ dragRef
3516
3630
  })
3517
- ) : /* @__PURE__ */ jsx21("div", { ref: dragRef, children: /* @__PURE__ */ jsx21(Render2, __spreadValues({}, defaultedProps)) })
3518
- }
3519
- )
3520
- },
3521
- componentId
3522
- );
3523
- })
3524
- ]
3631
+ })
3632
+ ) : /* @__PURE__ */ jsx21("div", { ref: dragRef, children: /* @__PURE__ */ jsx21(Render2, __spreadValues({}, defaultedProps)) })
3633
+ }
3634
+ )
3635
+ },
3636
+ componentId
3637
+ );
3638
+ })
3525
3639
  }
3526
3640
  );
3527
3641
  }
3528
3642
  );
3529
3643
  var DropZoneRender = forwardRef3(
3530
3644
  function DropZoneRender2({ className, style, zone }, ref) {
3531
- const ctx = useContext3(dropZoneContext);
3645
+ const ctx = useContext4(dropZoneContext);
3532
3646
  const { data, areaId = "root", config } = ctx || {};
3533
3647
  let zoneCompound = rootDroppableId;
3534
3648
  let content = (data == null ? void 0 : data.content) || [];
3535
- useEffect12(() => {
3649
+ useEffect14(() => {
3536
3650
  if (ctx == null ? void 0 : ctx.registerZone) {
3537
3651
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3538
3652
  }
@@ -3578,7 +3692,7 @@ var DropZoneRender = forwardRef3(
3578
3692
  );
3579
3693
  var DropZone = forwardRef3(
3580
3694
  function DropZone2(props, ref) {
3581
- const ctx = useContext3(dropZoneContext);
3695
+ const ctx = useContext4(dropZoneContext);
3582
3696
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3583
3697
  return /* @__PURE__ */ jsx21(Fragment6, { children: /* @__PURE__ */ jsx21(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3584
3698
  }
@@ -3598,7 +3712,7 @@ var getZoneId = (zoneCompound) => {
3598
3712
  return [rootDroppableId, zoneCompound];
3599
3713
  };
3600
3714
 
3601
- // components/DragDropContext/NestedDroppablePlugin.ts
3715
+ // lib/dnd/NestedDroppablePlugin.ts
3602
3716
  init_react_import();
3603
3717
  import { Plugin } from "@dnd-kit/abstract";
3604
3718
  import { effects } from "@dnd-kit/state";
@@ -3640,7 +3754,7 @@ var getFrame = () => {
3640
3754
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3641
3755
  };
3642
3756
 
3643
- // components/DragDropContext/NestedDroppablePlugin.ts
3757
+ // lib/dnd/NestedDroppablePlugin.ts
3644
3758
  var depthSort = (candidates) => {
3645
3759
  return candidates.sort((a, b) => {
3646
3760
  const aData = a.data;
@@ -3755,9 +3869,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
3755
3869
  area: null
3756
3870
  };
3757
3871
  };
3758
- var createNestedDroppablePlugin = ({
3759
- onChange
3760
- }) => class NestedDroppablePlugin extends Plugin {
3872
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
3761
3873
  constructor(manager, options) {
3762
3874
  super(manager);
3763
3875
  if (typeof window === "undefined") {
@@ -3771,10 +3883,17 @@ var createNestedDroppablePlugin = ({
3771
3883
  };
3772
3884
  const target = event.originalTarget || event.target;
3773
3885
  const ownerDocument = target == null ? void 0 : target.ownerDocument;
3774
- onChange(
3775
- findDeepestCandidate(position, manager, ownerDocument),
3776
- manager
3886
+ const elements = document.elementsFromPoint(
3887
+ event.clientX,
3888
+ event.clientY
3777
3889
  );
3890
+ const overEl = elements.some((el) => el.id === id);
3891
+ if (overEl) {
3892
+ onChange(
3893
+ findDeepestCandidate(position, manager, ownerDocument),
3894
+ manager
3895
+ );
3896
+ }
3778
3897
  };
3779
3898
  const handleMoveThrottled = throttle(handleMove, 50);
3780
3899
  const handlePointerMove = (event) => {
@@ -4191,7 +4310,7 @@ var insertComponent = (componentType, zone, index, {
4191
4310
  import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
4192
4311
  import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
4193
4312
 
4194
- // components/DragDropContext/PointerSensor.ts
4313
+ // lib/dnd/PointerSensor.ts
4195
4314
  init_react_import();
4196
4315
  import { batch, effect } from "@dnd-kit/state";
4197
4316
  import { Sensor, configurator } from "@dnd-kit/abstract";
@@ -4462,13 +4581,15 @@ function patchWindow(window2) {
4462
4581
  }
4463
4582
 
4464
4583
  // components/DragDropContext/index.tsx
4584
+ import { createStore as createStore3 } from "zustand";
4465
4585
  import { jsx as jsx22 } from "react/jsx-runtime";
4586
+ var DEBUG3 = false;
4466
4587
  var dragListenerContext = createContext3({
4467
4588
  dragListeners: {}
4468
4589
  });
4469
4590
  function useDragListener(type, fn, deps = []) {
4470
- const { setDragListeners } = useContext4(dragListenerContext);
4471
- useEffect13(() => {
4591
+ const { setDragListeners } = useContext5(dragListenerContext);
4592
+ useEffect15(() => {
4472
4593
  if (setDragListeners) {
4473
4594
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
4474
4595
  [type]: [...old[type] || [], fn]
@@ -4476,80 +4597,147 @@ function useDragListener(type, fn, deps = []) {
4476
4597
  }
4477
4598
  }, deps);
4478
4599
  }
4479
- var previewContext = createContext3(null);
4480
4600
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4601
+ var useTempDisableFallback = (timeout3) => {
4602
+ const lastFallbackDisable = useRef5(null);
4603
+ return useCallback11((manager) => {
4604
+ collisionStore.setState({ fallbackEnabled: false });
4605
+ const fallbackId = generateId();
4606
+ lastFallbackDisable.current = fallbackId;
4607
+ setTimeout(() => {
4608
+ if (lastFallbackDisable.current === fallbackId) {
4609
+ collisionStore.setState({ fallbackEnabled: true });
4610
+ manager.collisionObserver.forceUpdate(true);
4611
+ }
4612
+ }, timeout3);
4613
+ }, []);
4614
+ };
4481
4615
  var DragDropContextClient = ({
4482
4616
  children,
4483
4617
  disableAutoScroll
4484
4618
  }) => {
4485
4619
  const { state, config, dispatch, resolveData } = useAppContext();
4486
- const [preview, setPreview] = useState16(null);
4487
- const previewRef = useRef5(null);
4620
+ const id = useId();
4488
4621
  const { data } = state;
4489
- const [deepest, setDeepest] = useState16(null);
4490
- const [nextDeepest, setNextDeepest] = useState16(null);
4491
- const deepestRef = useRef5(deepest);
4492
4622
  const debouncedParamsRef = useRef5(null);
4493
- const setDeepestAndCollide = useCallback9(
4623
+ const tempDisableFallback = useTempDisableFallback(100);
4624
+ const [zoneStore] = useState17(
4625
+ () => createStore3(() => ({
4626
+ zoneDepthIndex: {},
4627
+ nextZoneDepthIndex: {},
4628
+ areaDepthIndex: {},
4629
+ nextAreaDepthIndex: {},
4630
+ draggedItem: null,
4631
+ previewIndex: {}
4632
+ }))
4633
+ );
4634
+ const getChanged2 = useCallback11(
4635
+ (params, id2) => {
4636
+ const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
4637
+ const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
4638
+ const stateHasArea = Object.keys(areaDepthIndex).length > 0;
4639
+ let zoneChanged = false;
4640
+ let areaChanged = false;
4641
+ if (params.zone && !zoneDepthIndex[params.zone]) {
4642
+ zoneChanged = true;
4643
+ } else if (!params.zone && stateHasZone) {
4644
+ zoneChanged = true;
4645
+ }
4646
+ if (params.area && !areaDepthIndex[params.area]) {
4647
+ areaChanged = true;
4648
+ } else if (!params.area && stateHasArea) {
4649
+ areaChanged = true;
4650
+ }
4651
+ return { zoneChanged, areaChanged };
4652
+ },
4653
+ [zoneStore]
4654
+ );
4655
+ const setDeepestAndCollide = useCallback11(
4494
4656
  (params, manager) => {
4495
- setDeepest(params);
4657
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4658
+ if (!zoneChanged && !areaChanged) return;
4659
+ zoneStore.setState({
4660
+ zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
4661
+ areaDepthIndex: params.area ? { [params.area]: true } : {}
4662
+ });
4663
+ tempDisableFallback(manager);
4496
4664
  setTimeout(() => {
4497
4665
  manager.collisionObserver.forceUpdate(true);
4498
4666
  }, 50);
4499
4667
  debouncedParamsRef.current = null;
4500
4668
  },
4501
- []
4669
+ [zoneStore]
4502
4670
  );
4503
4671
  const setDeepestDb = useDebouncedCallback2(
4504
4672
  setDeepestAndCollide,
4505
4673
  AREA_CHANGE_DEBOUNCE_MS
4506
4674
  );
4507
- useEffect13(() => {
4508
- deepestRef.current = deepest;
4509
- }, [deepest]);
4510
4675
  const cancelDb = () => {
4511
4676
  setDeepestDb.cancel();
4512
4677
  debouncedParamsRef.current = null;
4513
4678
  };
4514
- const [plugins] = useState16(() => [
4515
- ...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
4516
- createNestedDroppablePlugin({
4517
- onChange: (params, manager) => {
4518
- const lastParams = deepestRef.current;
4519
- const areaChanged = params.area !== (lastParams == null ? void 0 : lastParams.area);
4520
- const zoneChanged = params.zone !== (lastParams == null ? void 0 : lastParams.zone);
4521
- const isDragging = manager.dragOperation.status.dragging;
4522
- if (areaChanged || zoneChanged) {
4523
- setNextDeepest(params);
4524
- }
4525
- if (params.zone !== "void" && (lastParams == null ? void 0 : lastParams.zone) === "void") {
4526
- setDeepest(params);
4527
- manager.collisionObserver.forceUpdate(true);
4528
- return;
4679
+ useEffect15(() => {
4680
+ if (DEBUG3) {
4681
+ zoneStore.subscribe(
4682
+ (s) => {
4683
+ var _a, _b;
4684
+ return console.log(
4685
+ s.previewIndex,
4686
+ (_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
4687
+ (_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
4688
+ );
4529
4689
  }
4530
- if (areaChanged) {
4531
- if (isDragging) {
4532
- const debouncedParams = debouncedParamsRef.current;
4533
- const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4534
- if (!isSameParams) {
4690
+ );
4691
+ }
4692
+ }, []);
4693
+ const [plugins] = useState17(() => [
4694
+ ...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
4695
+ createNestedDroppablePlugin(
4696
+ {
4697
+ onChange: (params, manager) => {
4698
+ const state2 = zoneStore.getState();
4699
+ const { zoneChanged, areaChanged } = getChanged2(params, id);
4700
+ const isDragging = manager.dragOperation.status.dragging;
4701
+ if (areaChanged || zoneChanged) {
4702
+ let nextZoneDepthIndex = {};
4703
+ let nextAreaDepthIndex = {};
4704
+ if (params.zone) {
4705
+ nextZoneDepthIndex = { [params.zone]: true };
4706
+ }
4707
+ if (params.area) {
4708
+ nextAreaDepthIndex = { [params.area]: true };
4709
+ }
4710
+ zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
4711
+ }
4712
+ if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
4713
+ setDeepestAndCollide(params, manager);
4714
+ return;
4715
+ }
4716
+ if (areaChanged) {
4717
+ if (isDragging) {
4718
+ const debouncedParams = debouncedParamsRef.current;
4719
+ const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
4720
+ if (!isSameParams) {
4721
+ cancelDb();
4722
+ setDeepestDb(params, manager);
4723
+ debouncedParamsRef.current = params;
4724
+ }
4725
+ } else {
4535
4726
  cancelDb();
4536
- setDeepestDb(params, manager);
4537
- debouncedParamsRef.current = params;
4727
+ setDeepestAndCollide(params, manager);
4538
4728
  }
4539
- } else {
4540
- cancelDb();
4729
+ return;
4730
+ }
4731
+ if (zoneChanged) {
4541
4732
  setDeepestAndCollide(params, manager);
4542
4733
  }
4543
- return;
4544
- }
4545
- if (zoneChanged) {
4546
- setDeepestAndCollide(params, manager);
4734
+ cancelDb();
4547
4735
  }
4548
- cancelDb();
4549
- }
4550
- })
4736
+ },
4737
+ id
4738
+ )
4551
4739
  ]);
4552
- const [sensors] = useState16(() => [
4740
+ const [sensors] = useState17(() => [
4553
4741
  PointerSensor.configure({
4554
4742
  activationConstraints(event, source) {
4555
4743
  var _a;
@@ -4568,11 +4756,10 @@ var DragDropContextClient = ({
4568
4756
  }
4569
4757
  })
4570
4758
  ]);
4571
- const [draggedItem, setDraggedItem] = useState16();
4572
- const [dragListeners, setDragListeners] = useState16({});
4573
- const [pathData, setPathData] = useState16();
4759
+ const [dragListeners, setDragListeners] = useState17({});
4760
+ const [pathData, setPathData] = useState17();
4574
4761
  const dragMode = useRef5(null);
4575
- const registerPath = useCallback9(
4762
+ const registerPath = useCallback11(
4576
4763
  (selector) => {
4577
4764
  const item = getItem(selector, data);
4578
4765
  if (!item) {
@@ -4595,40 +4782,40 @@ var DragDropContextClient = ({
4595
4782
  [data, setPathData]
4596
4783
  );
4597
4784
  const initialSelector = useRef5(void 0);
4598
- return /* @__PURE__ */ jsx22(
4785
+ return /* @__PURE__ */ jsx22("div", { id, children: /* @__PURE__ */ jsx22(
4599
4786
  dragListenerContext.Provider,
4600
4787
  {
4601
4788
  value: {
4602
4789
  dragListeners,
4603
4790
  setDragListeners
4604
4791
  },
4605
- children: /* @__PURE__ */ jsx22(previewContext.Provider, { value: preview, children: /* @__PURE__ */ jsx22(
4792
+ children: /* @__PURE__ */ jsx22(
4606
4793
  DragDropProvider2,
4607
4794
  {
4608
4795
  plugins,
4609
4796
  sensors,
4610
4797
  onDragEnd: (event, manager) => {
4798
+ var _a;
4611
4799
  const { source, target } = event.operation;
4612
- deepestRef.current = null;
4613
4800
  if (!source) {
4614
- setDraggedItem(null);
4801
+ zoneStore.setState({ draggedItem: null });
4615
4802
  return;
4616
4803
  }
4617
4804
  const { zone, index } = source.data;
4618
- const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
4619
- previewRef.current = null;
4805
+ const { previewIndex = {} } = zoneStore.getState() || {};
4806
+ const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
4620
4807
  setTimeout(() => {
4621
- var _a, _b;
4622
- setDraggedItem(null);
4808
+ var _a2, _b;
4809
+ zoneStore.setState({ draggedItem: null });
4623
4810
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
4624
- setPreview(null);
4625
- (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
4811
+ zoneStore.setState({ previewIndex: {} });
4812
+ (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
4626
4813
  fn(event, manager);
4627
4814
  });
4628
4815
  return;
4629
4816
  }
4630
4817
  if (thisPreview) {
4631
- setPreview(null);
4818
+ zoneStore.setState({ previewIndex: {} });
4632
4819
  if (thisPreview.type === "insert") {
4633
4820
  insertComponent(
4634
4821
  thisPreview.componentType,
@@ -4663,8 +4850,9 @@ var DragDropContextClient = ({
4663
4850
  }, 250);
4664
4851
  },
4665
4852
  onDragOver: (event, manager) => {
4666
- var _a, _b, _c, _d;
4853
+ var _a, _b, _c, _d, _e;
4667
4854
  event.preventDefault();
4855
+ const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
4668
4856
  if (!draggedItem) return;
4669
4857
  cancelDb();
4670
4858
  const { source, target } = event.operation;
@@ -4680,7 +4868,7 @@ var DragDropContextClient = ({
4680
4868
  const targetData = target.data;
4681
4869
  targetZone = targetData.zone;
4682
4870
  targetIndex = targetData.index;
4683
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[targetId];
4871
+ const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
4684
4872
  const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
4685
4873
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
4686
4874
  targetIndex = targetIndex - 1;
@@ -4692,23 +4880,26 @@ var DragDropContextClient = ({
4692
4880
  targetZone = target.id.toString();
4693
4881
  targetIndex = 0;
4694
4882
  }
4695
- if (targetId === sourceId || ((_c = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _c.path.find((path) => {
4883
+ if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
4696
4884
  const [pathId] = path.split(":");
4697
4885
  return pathId === sourceId;
4698
4886
  }))) {
4699
4887
  return;
4700
4888
  }
4701
4889
  if (dragMode.current === "new") {
4702
- previewRef.current = {
4703
- componentType: sourceData.componentType,
4704
- type: "insert",
4705
- index: targetIndex,
4706
- zone: targetZone,
4707
- props: {
4708
- id: source.id.toString()
4890
+ zoneStore.setState({
4891
+ previewIndex: {
4892
+ [targetZone]: {
4893
+ componentType: sourceData.componentType,
4894
+ type: "insert",
4895
+ index: targetIndex,
4896
+ zone: targetZone,
4897
+ props: {
4898
+ id: source.id.toString()
4899
+ }
4900
+ }
4709
4901
  }
4710
- };
4711
- setPreview(previewRef.current);
4902
+ });
4712
4903
  } else {
4713
4904
  if (!initialSelector.current) {
4714
4905
  initialSelector.current = {
@@ -4718,17 +4909,20 @@ var DragDropContextClient = ({
4718
4909
  }
4719
4910
  const item = getItem(initialSelector.current, data);
4720
4911
  if (item) {
4721
- previewRef.current = {
4722
- componentType: sourceData.componentType,
4723
- type: "move",
4724
- index: targetIndex,
4725
- zone: targetZone,
4726
- props: item.props
4727
- };
4728
- setPreview(previewRef.current);
4912
+ zoneStore.setState({
4913
+ previewIndex: {
4914
+ [targetZone]: {
4915
+ componentType: sourceData.componentType,
4916
+ type: "move",
4917
+ index: targetIndex,
4918
+ zone: targetZone,
4919
+ props: item.props
4920
+ }
4921
+ }
4922
+ });
4729
4923
  }
4730
4924
  }
4731
- (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
4925
+ (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
4732
4926
  fn(event, manager);
4733
4927
  });
4734
4928
  },
@@ -4738,45 +4932,61 @@ var DragDropContextClient = ({
4738
4932
  type: "setUi",
4739
4933
  ui: { itemSelector: null, isDragging: true }
4740
4934
  });
4935
+ const { source } = event.operation;
4936
+ if (source && source.type !== "void") {
4937
+ const sourceData = source.data;
4938
+ const item = getItem(
4939
+ {
4940
+ zone: sourceData.zone,
4941
+ index: sourceData.index
4942
+ },
4943
+ data
4944
+ );
4945
+ if (item) {
4946
+ zoneStore.setState({
4947
+ previewIndex: {
4948
+ [sourceData.zone]: {
4949
+ componentType: sourceData.componentType,
4950
+ type: "move",
4951
+ index: sourceData.index,
4952
+ zone: sourceData.zone,
4953
+ props: item.props
4954
+ }
4955
+ }
4956
+ });
4957
+ }
4958
+ }
4741
4959
  (_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
4742
4960
  fn(event, manager);
4743
4961
  });
4744
4962
  },
4745
4963
  onBeforeDragStart: (event) => {
4746
4964
  var _a;
4747
- if (draggedItem) {
4748
- console.warn("New drag started before previous drag cleaned up");
4749
- }
4750
4965
  const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
4751
4966
  dragMode.current = isNewComponent ? "new" : "existing";
4752
4967
  initialSelector.current = void 0;
4753
- setDraggedItem(event.operation.source);
4968
+ zoneStore.setState({ draggedItem: event.operation.source });
4754
4969
  },
4755
- children: /* @__PURE__ */ jsx22(
4970
+ children: /* @__PURE__ */ jsx22(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx22(
4756
4971
  DropZoneProvider,
4757
4972
  {
4758
4973
  value: {
4759
4974
  data,
4760
4975
  config,
4761
- draggedItem,
4762
4976
  mode: "edit",
4763
4977
  areaId: "root",
4764
4978
  depth: 0,
4765
4979
  registerPath,
4766
4980
  pathData,
4767
- deepestZone: deepest == null ? void 0 : deepest.zone,
4768
- deepestArea: deepest == null ? void 0 : deepest.area,
4769
- nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
4770
- nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
4771
4981
  path: []
4772
4982
  },
4773
4983
  children
4774
4984
  }
4775
- )
4985
+ ) })
4776
4986
  }
4777
- ) })
4987
+ )
4778
4988
  }
4779
- );
4989
+ ) });
4780
4990
  };
4781
4991
  var DragDropContext = ({
4782
4992
  children,
@@ -4854,7 +5064,7 @@ var DrawerItem = ({
4854
5064
  isDragDisabled
4855
5065
  }) => {
4856
5066
  const resolvedId = id || name;
4857
- const [dynamicId, setDynamicId] = useState17(generateId(resolvedId));
5067
+ const [dynamicId, setDynamicId] = useState18(generateId(resolvedId));
4858
5068
  if (typeof index !== "undefined") {
4859
5069
  console.error(
4860
5070
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -4893,7 +5103,7 @@ var Drawer = ({
4893
5103
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
4894
5104
  );
4895
5105
  }
4896
- const [id] = useState17(generateId());
5106
+ const [id] = useState18(generateId());
4897
5107
  const { ref } = useDroppableSafe({
4898
5108
  id,
4899
5109
  type: "void",
@@ -4916,11 +5126,11 @@ Drawer.Item = DrawerItem;
4916
5126
  // components/Puck/index.tsx
4917
5127
  init_react_import();
4918
5128
  import {
4919
- useCallback as useCallback15,
4920
- useEffect as useEffect21,
5129
+ useCallback as useCallback17,
5130
+ useEffect as useEffect23,
4921
5131
  useMemo as useMemo17,
4922
5132
  useReducer,
4923
- useState as useState25
5133
+ useState as useState26
4924
5134
  } from "react";
4925
5135
 
4926
5136
  // components/SidebarSection/index.tsx
@@ -4932,7 +5142,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
4932
5142
 
4933
5143
  // lib/use-breadcrumbs.ts
4934
5144
  init_react_import();
4935
- import { useContext as useContext5, useMemo as useMemo9 } from "react";
5145
+ import { useContext as useContext6, useMemo as useMemo9 } from "react";
4936
5146
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
4937
5147
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
4938
5148
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -4982,7 +5192,7 @@ var useBreadcrumbs = (renderCount) => {
4982
5192
  state: { data },
4983
5193
  selectedItem
4984
5194
  } = useAppContext();
4985
- const dzContext = useContext5(dropZoneContext);
5195
+ const dzContext = useContext6(dropZoneContext);
4986
5196
  return useMemo9(() => {
4987
5197
  const breadcrumbs = convertPathDataToBreadcrumbs(
4988
5198
  selectedItem,
@@ -5107,7 +5317,7 @@ function MenuBar({
5107
5317
 
5108
5318
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5109
5319
  init_react_import();
5110
- var styles_module_default15 = { "Puck": "_Puck_1g88c_19", "Puck-portal": "_Puck-portal_1g88c_24", "PuckLayout": "_PuckLayout_1g88c_31", "PuckLayout-inner": "_PuckLayout-inner_1g88c_39", "PuckLayout--mounted": "_PuckLayout--mounted_1g88c_51", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_1g88c_55", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_1g88c_61", "PuckLayout-mounted": "_PuckLayout-mounted_1g88c_75", "PuckLayout-header": "_PuckLayout-header_1g88c_116", "PuckLayout-headerInner": "_PuckLayout-headerInner_1g88c_125", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_1g88c_135", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_1g88c_142", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_1g88c_143", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_1g88c_147", "PuckLayout-headerPath": "_PuckLayout-headerPath_1g88c_151", "PuckLayout-headerTools": "_PuckLayout-headerTools_1g88c_158", "PuckLayout-menuButton": "_PuckLayout-menuButton_1g88c_164", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_1g88c_169", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_1g88c_143", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_1g88c_142" };
5320
+ var styles_module_default15 = { "Puck": "_Puck_12s9r_19", "Puck-portal": "_Puck-portal_12s9r_24", "PuckLayout-inner": "_PuckLayout-inner_12s9r_31", "PuckLayout--mounted": "_PuckLayout--mounted_12s9r_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_12s9r_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_12s9r_53", "PuckLayout-mounted": "_PuckLayout-mounted_12s9r_67", "PuckLayout": "_PuckLayout_12s9r_31", "PuckLayout-header": "_PuckLayout-header_12s9r_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_12s9r_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_12s9r_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_12s9r_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_12s9r_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_12s9r_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_12s9r_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_12s9r_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_12s9r_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_12s9r_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_12s9r_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_12s9r_134" };
5111
5321
 
5112
5322
  // components/Puck/components/Fields/index.tsx
5113
5323
  init_react_import();
@@ -5117,15 +5327,15 @@ init_react_import();
5117
5327
  var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
5118
5328
 
5119
5329
  // components/Puck/components/Fields/index.tsx
5120
- import { useCallback as useCallback10, useEffect as useEffect14, useMemo as useMemo10, useState as useState18 } from "react";
5330
+ import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo10, useState as useState19 } from "react";
5121
5331
 
5122
5332
  // lib/use-parent.ts
5123
5333
  init_react_import();
5124
- import { useContext as useContext6 } from "react";
5334
+ import { useContext as useContext7 } from "react";
5125
5335
  var useParent = (itemSelector) => {
5126
5336
  var _a;
5127
5337
  const { selectedItem, state } = useAppContext();
5128
- const { pathData } = useContext6(dropZoneContext) || {};
5338
+ const { pathData } = useContext7(dropZoneContext) || {};
5129
5339
  const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5130
5340
  const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5131
5341
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
@@ -5156,15 +5366,15 @@ var useResolvedFields = () => {
5156
5366
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5157
5367
  );
5158
5368
  const rootProps = data.root.props || data.root;
5159
- const [lastSelectedData, setLastSelectedData] = useState18({});
5160
- const [resolvedFields, setResolvedFields] = useState18(defaultFields);
5161
- const [fieldsLoading, setFieldsLoading] = useState18(false);
5369
+ const [lastSelectedData, setLastSelectedData] = useState19({});
5370
+ const [resolvedFields, setResolvedFields] = useState19(defaultFields);
5371
+ const [fieldsLoading, setFieldsLoading] = useState19(false);
5162
5372
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5163
5373
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5164
5374
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5165
5375
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5166
5376
  const hasResolver = hasComponentResolver || hasRootResolver;
5167
- const resolveFields = useCallback10(
5377
+ const resolveFields = useCallback12(
5168
5378
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5169
5379
  var _a2;
5170
5380
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5202,7 +5412,7 @@ var useResolvedFields = () => {
5202
5412
  }),
5203
5413
  [data, config, componentData, selectedItem, resolvedFields, state]
5204
5414
  );
5205
- useEffect14(() => {
5415
+ useEffect16(() => {
5206
5416
  if (hasResolver) {
5207
5417
  setFieldsLoading(true);
5208
5418
  resolveFields(defaultFields).then((fields) => {
@@ -5356,7 +5566,7 @@ init_react_import();
5356
5566
 
5357
5567
  // lib/use-component-list.tsx
5358
5568
  init_react_import();
5359
- import { useEffect as useEffect15, useState as useState19 } from "react";
5569
+ import { useEffect as useEffect17, useState as useState20 } from "react";
5360
5570
 
5361
5571
  // components/ComponentList/index.tsx
5362
5572
  init_react_import();
@@ -5423,8 +5633,8 @@ ComponentList.Item = ComponentListItem;
5423
5633
  // lib/use-component-list.tsx
5424
5634
  import { jsx as jsx28 } from "react/jsx-runtime";
5425
5635
  var useComponentList = (config, ui) => {
5426
- const [componentList, setComponentList] = useState19();
5427
- useEffect15(() => {
5636
+ const [componentList, setComponentList] = useState20();
5637
+ useEffect17(() => {
5428
5638
  var _a, _b, _c;
5429
5639
  if (Object.keys(ui.componentList).length > 0) {
5430
5640
  const matchedComponents = [];
@@ -5504,15 +5714,15 @@ var Components = () => {
5504
5714
 
5505
5715
  // components/Puck/components/Preview/index.tsx
5506
5716
  init_react_import();
5507
- import { useCallback as useCallback11, useEffect as useEffect17, useRef as useRef7, useMemo as useMemo12 } from "react";
5717
+ import { useCallback as useCallback13, useEffect as useEffect19, useRef as useRef7, useMemo as useMemo12 } from "react";
5508
5718
 
5509
5719
  // components/AutoFrame/index.tsx
5510
5720
  init_react_import();
5511
5721
  import {
5512
5722
  createContext as createContext4,
5513
- useContext as useContext7,
5514
- useEffect as useEffect16,
5515
- useState as useState20
5723
+ useContext as useContext8,
5724
+ useEffect as useEffect18,
5725
+ useState as useState21
5516
5726
  } from "react";
5517
5727
  import hash from "object-hash";
5518
5728
  import { createPortal as createPortal3 } from "react-dom";
@@ -5559,7 +5769,7 @@ var CopyHostStyles = ({
5559
5769
  onStylesLoaded = () => null
5560
5770
  }) => {
5561
5771
  const { document: doc, window: win } = useFrame();
5562
- useEffect16(() => {
5772
+ useEffect18(() => {
5563
5773
  if (!win || !doc) {
5564
5774
  return () => {
5565
5775
  };
@@ -5719,7 +5929,7 @@ var CopyHostStyles = ({
5719
5929
  return /* @__PURE__ */ jsx30(Fragment9, { children });
5720
5930
  };
5721
5931
  var autoFrameContext = createContext4({});
5722
- var useFrame = () => useContext7(autoFrameContext);
5932
+ var useFrame = () => useContext8(autoFrameContext);
5723
5933
  function AutoFrame(_a) {
5724
5934
  var _b = _a, {
5725
5935
  children,
@@ -5736,10 +5946,10 @@ function AutoFrame(_a) {
5736
5946
  "onStylesLoaded",
5737
5947
  "frameRef"
5738
5948
  ]);
5739
- const [loaded, setLoaded] = useState20(false);
5740
- const [ctx, setCtx] = useState20({});
5741
- const [mountTarget, setMountTarget] = useState20();
5742
- useEffect16(() => {
5949
+ const [loaded, setLoaded] = useState21(false);
5950
+ const [ctx, setCtx] = useState21({});
5951
+ const [mountTarget, setMountTarget] = useState21();
5952
+ useEffect18(() => {
5743
5953
  var _a2;
5744
5954
  if (frameRef.current) {
5745
5955
  setCtx({
@@ -5833,7 +6043,7 @@ import { Fragment as Fragment10, jsx as jsx32 } from "react/jsx-runtime";
5833
6043
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
5834
6044
  var useBubbleIframeEvents = (ref) => {
5835
6045
  const { status } = useAppContext();
5836
- useEffect17(() => {
6046
+ useEffect19(() => {
5837
6047
  var _a;
5838
6048
  if (ref.current && status === "READY") {
5839
6049
  const iframe = ref.current;
@@ -5870,9 +6080,9 @@ var useBubbleIframeEvents = (ref) => {
5870
6080
  }
5871
6081
  }, [status]);
5872
6082
  };
5873
- var Preview = ({ id = "puck-preview" }) => {
6083
+ var Preview2 = ({ id = "puck-preview" }) => {
5874
6084
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
5875
- const Page = useCallback11(
6085
+ const Page = useCallback13(
5876
6086
  (pageProps) => {
5877
6087
  var _a, _b;
5878
6088
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
@@ -5980,7 +6190,7 @@ var scrollIntoView = (el) => {
5980
6190
  };
5981
6191
 
5982
6192
  // components/LayerTree/index.tsx
5983
- import { useContext as useContext8 } from "react";
6193
+ import { useContext as useContext9 } from "react";
5984
6194
 
5985
6195
  // lib/is-child-of-zone.ts
5986
6196
  init_react_import();
@@ -6026,7 +6236,7 @@ var LayerTree = ({
6026
6236
  label
6027
6237
  }) => {
6028
6238
  const zones = data.zones || {};
6029
- const ctx = useContext8(dropZoneContext);
6239
+ const ctx = useContext9(dropZoneContext);
6030
6240
  return /* @__PURE__ */ jsxs16(Fragment11, { children: [
6031
6241
  label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
6032
6242
  /* @__PURE__ */ jsx33("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
@@ -6133,13 +6343,13 @@ var LayerTree = ({
6133
6343
  };
6134
6344
 
6135
6345
  // components/Puck/components/Outline/index.tsx
6136
- import { useCallback as useCallback12, useMemo as useMemo13 } from "react";
6346
+ import { useCallback as useCallback14, useMemo as useMemo13 } from "react";
6137
6347
  import { Fragment as Fragment12, jsx as jsx34, jsxs as jsxs17 } from "react/jsx-runtime";
6138
6348
  var Outline = () => {
6139
6349
  const { dispatch, state, overrides, config } = useAppContext();
6140
6350
  const { data, ui } = state;
6141
6351
  const { itemSelector } = ui;
6142
- const setItemSelector = useCallback12(
6352
+ const setItemSelector = useCallback14(
6143
6353
  (newItemSelector) => {
6144
6354
  dispatch({
6145
6355
  type: "setUi",
@@ -6262,19 +6472,19 @@ function usePuckHistory({
6262
6472
 
6263
6473
  // lib/use-history-store.ts
6264
6474
  init_react_import();
6265
- import { useState as useState21 } from "react";
6475
+ import { useState as useState22 } from "react";
6266
6476
  import { useDebouncedCallback as useDebouncedCallback3 } from "use-debounce";
6267
6477
  var EMPTY_HISTORY_INDEX = 0;
6268
6478
  function useHistoryStore(initialHistory) {
6269
6479
  var _a, _b;
6270
- const [histories, setHistories] = useState21(
6480
+ const [histories, setHistories] = useState22(
6271
6481
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
6272
6482
  );
6273
6483
  const updateHistories = (histories2) => {
6274
6484
  setHistories(histories2);
6275
6485
  setIndex(histories2.length - 1);
6276
6486
  };
6277
- const [index, setIndex] = useState21(
6487
+ const [index, setIndex] = useState22(
6278
6488
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
6279
6489
  );
6280
6490
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -6435,16 +6645,16 @@ var getBox = function getBox2(el) {
6435
6645
 
6436
6646
  // components/Puck/components/Canvas/index.tsx
6437
6647
  import {
6438
- useCallback as useCallback13,
6439
- useEffect as useEffect19,
6648
+ useCallback as useCallback15,
6649
+ useEffect as useEffect21,
6440
6650
  useMemo as useMemo15,
6441
6651
  useRef as useRef8,
6442
- useState as useState23
6652
+ useState as useState24
6443
6653
  } from "react";
6444
6654
 
6445
6655
  // components/ViewportControls/index.tsx
6446
6656
  init_react_import();
6447
- import { useEffect as useEffect18, useMemo as useMemo14, useState as useState22 } from "react";
6657
+ import { useEffect as useEffect20, useMemo as useMemo14, useState as useState23 } from "react";
6448
6658
 
6449
6659
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6450
6660
  init_react_import();
@@ -6467,8 +6677,8 @@ var ViewportButton = ({
6467
6677
  onClick
6468
6678
  }) => {
6469
6679
  const { state } = useAppContext();
6470
- const [isActive, setIsActive] = useState22(false);
6471
- useEffect18(() => {
6680
+ const [isActive, setIsActive] = useState23(false);
6681
+ useEffect20(() => {
6472
6682
  setIsActive(width === state.ui.viewports.current.width);
6473
6683
  }, [width, state.ui.viewports.current.width]);
6474
6684
  return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
@@ -6628,7 +6838,7 @@ var Canvas = () => {
6628
6838
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
6629
6839
  const { ui } = state;
6630
6840
  const frameRef = useRef8(null);
6631
- const [showTransition, setShowTransition] = useState23(false);
6841
+ const [showTransition, setShowTransition] = useState24(false);
6632
6842
  const defaultRender = useMemo15(() => {
6633
6843
  const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment13, { children });
6634
6844
  return PuckDefault;
@@ -6637,7 +6847,7 @@ var Canvas = () => {
6637
6847
  () => overrides.preview || defaultRender,
6638
6848
  [overrides]
6639
6849
  );
6640
- const getFrameDimensions = useCallback13(() => {
6850
+ const getFrameDimensions = useCallback15(() => {
6641
6851
  if (frameRef.current) {
6642
6852
  const frame = frameRef.current;
6643
6853
  const box = getBox(frame);
@@ -6645,7 +6855,7 @@ var Canvas = () => {
6645
6855
  }
6646
6856
  return { width: 0, height: 0 };
6647
6857
  }, [frameRef]);
6648
- const resetAutoZoom = useCallback13(
6858
+ const resetAutoZoom = useCallback15(
6649
6859
  (ui2 = state.ui) => {
6650
6860
  if (frameRef.current) {
6651
6861
  setZoomConfig(
@@ -6655,11 +6865,11 @@ var Canvas = () => {
6655
6865
  },
6656
6866
  [frameRef, zoomConfig, state.ui]
6657
6867
  );
6658
- useEffect19(() => {
6868
+ useEffect21(() => {
6659
6869
  setShowTransition(false);
6660
6870
  resetAutoZoom();
6661
6871
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6662
- useEffect19(() => {
6872
+ useEffect21(() => {
6663
6873
  const { height: frameHeight } = getFrameDimensions();
6664
6874
  if (ui.viewports.current.height === "auto") {
6665
6875
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6667,13 +6877,13 @@ var Canvas = () => {
6667
6877
  }));
6668
6878
  }
6669
6879
  }, [zoomConfig.zoom]);
6670
- useEffect19(() => {
6880
+ useEffect21(() => {
6671
6881
  if (ZOOM_ON_CHANGE) {
6672
6882
  setShowTransition(true);
6673
6883
  resetAutoZoom(ui);
6674
6884
  }
6675
6885
  }, [ui.viewports.current.width]);
6676
- useEffect19(() => {
6886
+ useEffect21(() => {
6677
6887
  const cb = () => {
6678
6888
  setShowTransition(false);
6679
6889
  resetAutoZoom();
@@ -6683,8 +6893,8 @@ var Canvas = () => {
6683
6893
  window.removeEventListener("resize", cb);
6684
6894
  };
6685
6895
  }, []);
6686
- const [showLoader, setShowLoader] = useState23(false);
6687
- useEffect19(() => {
6896
+ const [showLoader, setShowLoader] = useState24(false);
6897
+ useEffect21(() => {
6688
6898
  setTimeout(() => {
6689
6899
  setShowLoader(true);
6690
6900
  }, 500);
@@ -6750,7 +6960,7 @@ var Canvas = () => {
6750
6960
  })
6751
6961
  );
6752
6962
  },
6753
- children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview, {}) })
6963
+ children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview2, {}) })
6754
6964
  }
6755
6965
  ),
6756
6966
  /* @__PURE__ */ jsx36("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
@@ -6813,14 +7023,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment14, { chil
6813
7023
 
6814
7024
  // lib/use-inject-css.ts
6815
7025
  init_react_import();
6816
- import { useEffect as useEffect20, useState as useState24 } from "react";
7026
+ import { useEffect as useEffect22, useState as useState25 } from "react";
6817
7027
  var styles = ``;
6818
7028
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
6819
- const [el, setEl] = useState24();
6820
- useEffect20(() => {
7029
+ const [el, setEl] = useState25();
7030
+ useEffect22(() => {
6821
7031
  setEl(document.createElement("style"));
6822
7032
  }, []);
6823
- useEffect20(() => {
7033
+ useEffect22(() => {
6824
7034
  var _a;
6825
7035
  if (!el || typeof window === "undefined") {
6826
7036
  return;
@@ -6840,10 +7050,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
6840
7050
 
6841
7051
  // lib/use-preview-mode-hotkeys.ts
6842
7052
  init_react_import();
6843
- import { useCallback as useCallback14 } from "react";
7053
+ import { useCallback as useCallback16 } from "react";
6844
7054
  import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
6845
7055
  var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
6846
- const toggleInteractive = useCallback14(() => {
7056
+ const toggleInteractive = useCallback16(() => {
6847
7057
  dispatch({
6848
7058
  type: "setUi",
6849
7059
  ui: (ui) => ({
@@ -6895,7 +7105,7 @@ function Puck({
6895
7105
  waitForStyles: true
6896
7106
  }, _iframe);
6897
7107
  useInjectGlobalCss(iframe.enabled);
6898
- const [generatedAppState] = useState25(() => {
7108
+ const [generatedAppState] = useState26(() => {
6899
7109
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
6900
7110
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
6901
7111
  let clientUiState = {};
@@ -6967,7 +7177,7 @@ function Puck({
6967
7177
  histories,
6968
7178
  index: initialHistoryIndex
6969
7179
  });
6970
- const [reducer] = useState25(
7180
+ const [reducer] = useState26(
6971
7181
  () => createReducer({
6972
7182
  config,
6973
7183
  record: historyStore.record,
@@ -6985,14 +7195,14 @@ function Puck({
6985
7195
  historyStore,
6986
7196
  iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
6987
7197
  });
6988
- const [menuOpen, setMenuOpen] = useState25(false);
7198
+ const [menuOpen, setMenuOpen] = useState26(false);
6989
7199
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
6990
7200
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
6991
- useEffect21(() => {
7201
+ useEffect23(() => {
6992
7202
  if (onChange) onChange(data);
6993
7203
  }, [data]);
6994
7204
  const rootProps = data.root.props || data.root;
6995
- const toggleSidebars = useCallback15(
7205
+ const toggleSidebars = useCallback17(
6996
7206
  (sidebar) => {
6997
7207
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
6998
7208
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7006,7 +7216,7 @@ function Puck({
7006
7216
  },
7007
7217
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7008
7218
  );
7009
- useEffect21(() => {
7219
+ useEffect23(() => {
7010
7220
  if (!window.matchMedia("(min-width: 638px)").matches) {
7011
7221
  dispatch({
7012
7222
  type: "setUi",
@@ -7072,8 +7282,8 @@ function Puck({
7072
7282
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7073
7283
  [loadedOverrides]
7074
7284
  );
7075
- const [mounted, setMounted] = useState25(false);
7076
- useEffect21(() => {
7285
+ const [mounted, setMounted] = useState26(false);
7286
+ useEffect23(() => {
7077
7287
  setMounted(true);
7078
7288
  }, []);
7079
7289
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
@@ -7234,7 +7444,7 @@ function Puck({
7234
7444
  Puck.Components = Components;
7235
7445
  Puck.Fields = Fields;
7236
7446
  Puck.Outline = Outline;
7237
- Puck.Preview = Preview;
7447
+ Puck.Preview = Preview2;
7238
7448
 
7239
7449
  // lib/migrate.ts
7240
7450
  init_react_import();