@measured/puck 0.17.0-canary.9de5e5e → 0.17.0-canary.bda6153

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2,6 +2,9 @@ import {
2
2
  __async,
3
3
  __commonJS,
4
4
  __objRest,
5
+ __privateAdd,
6
+ __privateGet,
7
+ __privateSet,
5
8
  __spreadProps,
6
9
  __spreadValues,
7
10
  __toESM,
@@ -13,7 +16,7 @@ import {
13
16
  resolveRootData,
14
17
  rootDroppableId,
15
18
  setupZone
16
- } from "./chunk-7IH6SUIT.mjs";
19
+ } from "./chunk-EXKSBUY5.mjs";
17
20
 
18
21
  // ../../node_modules/classnames/index.js
19
22
  var require_classnames = __commonJS({
@@ -2229,7 +2232,7 @@ init_react_import();
2229
2232
 
2230
2233
  // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
2231
2234
  init_react_import();
2232
- var styles_module_default10 = { "Drawer": "_Drawer_1pb1t_1", "DrawerItem-draggable": "_DrawerItem-draggable_1pb1t_8", "DrawerItem--disabled": "_DrawerItem--disabled_1pb1t_20", "DrawerItem": "_DrawerItem_1pb1t_8", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_1pb1t_30", "DrawerItem-name": "_DrawerItem-name_1pb1t_48" };
2235
+ var styles_module_default10 = { "Drawer": "_Drawer_1ob9x_1", "DrawerItem-draggable": "_DrawerItem-draggable_1ob9x_8", "DrawerItem--disabled": "_DrawerItem--disabled_1ob9x_21", "DrawerItem": "_DrawerItem_1ob9x_8", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_1ob9x_31", "DrawerItem-name": "_DrawerItem-name_1ob9x_49" };
2233
2236
 
2234
2237
  // components/Drawer/index.tsx
2235
2238
  import { useMemo as useMemo5, useState as useState16 } from "react";
@@ -2271,7 +2274,7 @@ import {
2271
2274
 
2272
2275
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
2273
2276
  init_react_import();
2274
- var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_33bhx_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_33bhx_13", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_33bhx_30", "DraggableComponent--hover": "_DraggableComponent--hover_33bhx_46", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_33bhx_46", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_33bhx_55", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_33bhx_67", "DraggableComponent-actions": "_DraggableComponent-actions_33bhx_67" };
2277
+ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1uqah_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1uqah_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1uqah_29", "DraggableComponent--hover": "_DraggableComponent--hover_1uqah_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1uqah_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1uqah_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1uqah_66", "DraggableComponent-actions": "_DraggableComponent-actions_1uqah_66" };
2275
2278
 
2276
2279
  // lib/use-modifier-held.ts
2277
2280
  init_react_import();
@@ -2716,6 +2719,7 @@ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.
2716
2719
  var __typeError = (msg) => {
2717
2720
  throw TypeError(msg);
2718
2721
  };
2722
+ var __pow = Math.pow;
2719
2723
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2720
2724
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
2721
2725
  var __decoratorStart = (base) => {
@@ -2735,17 +2739,17 @@ var __decorateElement = (array, flags, name, decorators, target, extra) => {
2735
2739
  var j = k > 3 ? array.length + 1 : k ? s2 ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
2736
2740
  var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
2737
2741
  var desc = k && (!p2 && !s2 && (target = target.prototype), k < 5 && (k > 3 || !p2) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
2738
- return __privateGet(this, extra);
2742
+ return __privateGet2(this, extra);
2739
2743
  }, set [name](x) {
2740
- return __privateSet(this, extra, x);
2744
+ return __privateSet2(this, extra, x);
2741
2745
  } }, name));
2742
2746
  k ? p2 && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
2743
2747
  for (var i2 = decorators.length - 1; i2 >= 0; i2--) {
2744
2748
  ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
2745
2749
  if (k) {
2746
2750
  ctx.static = s2, ctx.private = p2, access = ctx.access = { has: p2 ? (x) => __privateIn(target, x) : (x) => name in x };
2747
- if (k ^ 3) access.get = p2 ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
2748
- if (k > 2) access.set = p2 ? (x, y2) => __privateSet(x, target, y2, k ^ 4 ? extra : desc.set) : (x, y2) => x[name] = y2;
2751
+ if (k ^ 3) access.get = p2 ? (x) => (k ^ 1 ? __privateGet2 : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
2752
+ if (k > 2) access.set = p2 ? (x, y2) => __privateSet2(x, target, y2, k ^ 4 ? extra : desc.set) : (x, y2) => x[name] = y2;
2749
2753
  }
2750
2754
  it = (0, decorators[i2])(k ? k < 4 ? p2 ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
2751
2755
  if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p2 ? extra = it : desc[key] = it : target = it);
@@ -2756,9 +2760,9 @@ var __decorateElement = (array, flags, name, decorators, target, extra) => {
2756
2760
  };
2757
2761
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
2758
2762
  var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
2759
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2760
- 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);
2761
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2763
+ var __privateGet2 = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2764
+ var __privateAdd2 = (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);
2765
+ var __privateSet2 = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2762
2766
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
2763
2767
  var Point = class _Point {
2764
2768
  /**
@@ -2817,14 +2821,14 @@ _velocity_dec = [reactive], _initial_dec = [reactive], _previous_dec = [reactive
2817
2821
  var Position = class {
2818
2822
  constructor(initialValue) {
2819
2823
  __runInitializers(_init, 5, this);
2820
- __privateAdd(this, _timestamp, 0);
2821
- __privateAdd(this, _velocity, __runInitializers(_init, 8, this, {
2824
+ __privateAdd2(this, _timestamp, 0);
2825
+ __privateAdd2(this, _velocity, __runInitializers(_init, 8, this, {
2822
2826
  x: 0,
2823
2827
  y: 0
2824
2828
  })), __runInitializers(_init, 11, this);
2825
- __privateAdd(this, _initial, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
2826
- __privateAdd(this, _previous, __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
2827
- __privateAdd(this, _current, __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this);
2829
+ __privateAdd2(this, _initial, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
2830
+ __privateAdd2(this, _previous, __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
2831
+ __privateAdd2(this, _current, __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this);
2828
2832
  const point = Point.from(initialValue);
2829
2833
  this.initial = point;
2830
2834
  this.current = point;
@@ -2849,7 +2853,7 @@ var Position = class {
2849
2853
  reset(coordinates) {
2850
2854
  const point = Point.from(coordinates);
2851
2855
  o(() => {
2852
- __privateSet(this, _timestamp, 0);
2856
+ __privateSet2(this, _timestamp, 0);
2853
2857
  this.velocity = { x: 0, y: 0 };
2854
2858
  this.current = point;
2855
2859
  this.previous = point;
@@ -2867,12 +2871,12 @@ var Position = class {
2867
2871
  y: point.y - current.y
2868
2872
  };
2869
2873
  const timestamp = Date.now();
2870
- const timeDelta = timestamp - __privateGet(this, _timestamp);
2874
+ const timeDelta = timestamp - __privateGet2(this, _timestamp);
2871
2875
  const velocity = (delta2) => Math.round(delta2 / timeDelta * 100);
2872
2876
  if (Math.abs(delta.x) < SENSITIVITY || Math.abs(delta.y) < SENSITIVITY) {
2873
2877
  this.previous = current;
2874
2878
  }
2875
- __privateSet(this, _timestamp, timestamp);
2879
+ __privateSet2(this, _timestamp, timestamp);
2876
2880
  this.velocity = {
2877
2881
  x: velocity(delta.x),
2878
2882
  y: velocity(delta.y)
@@ -2893,6 +2897,23 @@ __decorateElement(_init, 4, "current", _current_dec, Position, _current);
2893
2897
  __decorateElement(_init, 2, "delta", _delta_dec, Position);
2894
2898
  __decorateElement(_init, 2, "direction", _direction_dec, Position);
2895
2899
  __decoratorMetadata(_init, Position);
2900
+ function exceedsDistance({ x, y: y2 }, distance) {
2901
+ const dx = Math.abs(x);
2902
+ const dy = Math.abs(y2);
2903
+ if (typeof distance === "number") {
2904
+ return Math.sqrt(__pow(dx, 2) + __pow(dy, 2)) > distance;
2905
+ }
2906
+ if ("x" in distance && "y" in distance) {
2907
+ return dx > distance.x && dy > distance.y;
2908
+ }
2909
+ if ("x" in distance) {
2910
+ return dx > distance.x;
2911
+ }
2912
+ if ("y" in distance) {
2913
+ return dy > distance.y;
2914
+ }
2915
+ return false;
2916
+ }
2896
2917
  var Axis = /* @__PURE__ */ ((Axis2) => {
2897
2918
  Axis2["Horizontal"] = "x";
2898
2919
  Axis2["Vertical"] = "y";
@@ -2942,17 +2963,17 @@ var __decorateElement2 = (array, flags, name, decorators, target, extra) => {
2942
2963
  var j = k > 3 ? array.length + 1 : k ? s2 ? 1 : 2 : 0, key = __decoratorStrings2[k + 5];
2943
2964
  var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
2944
2965
  var desc = k && (!p2 && !s2 && (target = target.prototype), k < 5 && (k > 3 || !p2) && __getOwnPropDesc2(k < 4 ? target : { get [name]() {
2945
- return __privateGet2(this, extra);
2966
+ return __privateGet3(this, extra);
2946
2967
  }, set [name](x) {
2947
- return __privateSet2(this, extra, x);
2968
+ return __privateSet3(this, extra, x);
2948
2969
  } }, name));
2949
2970
  k ? p2 && k < 4 && __name2(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name2(target, name);
2950
2971
  for (var i2 = decorators.length - 1; i2 >= 0; i2--) {
2951
2972
  ctx = __decoratorContext2(k, name, done = {}, array[3], extraInitializers);
2952
2973
  if (k) {
2953
2974
  ctx.static = s2, ctx.private = p2, access = ctx.access = { has: p2 ? (x) => __privateIn2(target, x) : (x) => name in x };
2954
- if (k ^ 3) access.get = p2 ? (x) => (k ^ 1 ? __privateGet2 : __privateMethod2)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
2955
- if (k > 2) access.set = p2 ? (x, y2) => __privateSet2(x, target, y2, k ^ 4 ? extra : desc.set) : (x, y2) => x[name] = y2;
2975
+ if (k ^ 3) access.get = p2 ? (x) => (k ^ 1 ? __privateGet3 : __privateMethod2)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
2976
+ if (k > 2) access.set = p2 ? (x, y2) => __privateSet3(x, target, y2, k ^ 4 ? extra : desc.set) : (x, y2) => x[name] = y2;
2956
2977
  }
2957
2978
  it = (0, decorators[i2])(k ? k < 4 ? p2 ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
2958
2979
  if (k ^ 4 || it === void 0) __expectFn2(it) && (k > 4 ? initializers.unshift(it) : k ? p2 ? extra = it : desc[key] = it : target = it);
@@ -2963,9 +2984,9 @@ var __decorateElement2 = (array, flags, name, decorators, target, extra) => {
2963
2984
  };
2964
2985
  var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
2965
2986
  var __privateIn2 = (member, obj) => Object(obj) !== obj ? __typeError2('Cannot use the "in" operator on this value') : member.has(obj);
2966
- var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2967
- var __privateAdd2 = (obj, member, value) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2968
- var __privateSet2 = (obj, member, value, setter) => (__accessCheck2(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2987
+ var __privateGet3 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2988
+ var __privateAdd3 = (obj, member, value) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2989
+ var __privateSet3 = (obj, member, value, setter) => (__accessCheck2(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2969
2990
  var __privateMethod2 = (obj, member, method) => (__accessCheck2(obj, member, "access private method"), method);
2970
2991
  function configure(plugin, options) {
2971
2992
  return {
@@ -2973,6 +2994,11 @@ function configure(plugin, options) {
2973
2994
  options
2974
2995
  };
2975
2996
  }
2997
+ function configurator(plugin) {
2998
+ return (options) => {
2999
+ return configure(plugin, options);
3000
+ };
3001
+ }
2976
3002
  var _disabled_dec;
2977
3003
  var _init2;
2978
3004
  var _disabled;
@@ -2981,7 +3007,7 @@ var Plugin = class {
2981
3007
  constructor(manager, options) {
2982
3008
  this.manager = manager;
2983
3009
  this.options = options;
2984
- __privateAdd2(this, _disabled, __runInitializers2(_init2, 8, this, false)), __runInitializers2(_init2, 11, this);
3010
+ __privateAdd3(this, _disabled, __runInitializers2(_init2, 8, this, false)), __runInitializers2(_init2, 11, this);
2985
3011
  }
2986
3012
  /**
2987
3013
  * Enable a disabled plugin instance.
@@ -3068,10 +3094,10 @@ var Entity = class {
3068
3094
  * @param manager - The manager that controls the drag and drop operations.
3069
3095
  */
3070
3096
  constructor(input, manager) {
3071
- __privateAdd2(this, _manager, __runInitializers2(_init22, 8, this)), __runInitializers2(_init22, 11, this);
3072
- __privateAdd2(this, _id, __runInitializers2(_init22, 12, this)), __runInitializers2(_init22, 15, this);
3073
- __privateAdd2(this, _data, __runInitializers2(_init22, 16, this)), __runInitializers2(_init22, 19, this);
3074
- __privateAdd2(this, _disabled2, __runInitializers2(_init22, 20, this)), __runInitializers2(_init22, 23, this);
3097
+ __privateAdd3(this, _manager, __runInitializers2(_init22, 8, this)), __runInitializers2(_init22, 11, this);
3098
+ __privateAdd3(this, _id, __runInitializers2(_init22, 12, this)), __runInitializers2(_init22, 15, this);
3099
+ __privateAdd3(this, _data, __runInitializers2(_init22, 16, this)), __runInitializers2(_init22, 19, this);
3100
+ __privateAdd3(this, _disabled2, __runInitializers2(_init22, 20, this)), __runInitializers2(_init22, 23, this);
3075
3101
  this.effects = void 0;
3076
3102
  const { effects: effects5, id, data = {}, disabled = false } = input;
3077
3103
  let previousId = id;
@@ -3151,9 +3177,9 @@ var Draggable2 = class extends (_c = Entity, _modifiers_dec = [reactive], _type_
3151
3177
  super(input, manager);
3152
3178
  __runInitializers2(_init3, 5, this);
3153
3179
  this.sensors = void 0;
3154
- __privateAdd2(this, _modifiers, __runInitializers2(_init3, 8, this)), __runInitializers2(_init3, 11, this);
3155
- __privateAdd2(this, _type, __runInitializers2(_init3, 12, this)), __runInitializers2(_init3, 15, this);
3156
- __privateAdd2(this, _status, __runInitializers2(_init3, 16, this, "idle")), __runInitializers2(_init3, 19, this);
3180
+ __privateAdd3(this, _modifiers, __runInitializers2(_init3, 8, this)), __runInitializers2(_init3, 11, this);
3181
+ __privateAdd3(this, _type, __runInitializers2(_init3, 12, this)), __runInitializers2(_init3, 15, this);
3182
+ __privateAdd3(this, _status, __runInitializers2(_init3, 16, this, "idle")), __runInitializers2(_init3, 19, this);
3157
3183
  this.type = type;
3158
3184
  this.sensors = sensors;
3159
3185
  this.modifiers = modifiers;
@@ -3190,11 +3216,11 @@ var Droppable2 = class extends (_c2 = Entity, _accept_dec = [reactive], _type_de
3190
3216
  var _b = _a, { accept, collisionDetector, collisionPriority, type } = _b, input = __objRest2(_b, ["accept", "collisionDetector", "collisionPriority", "type"]);
3191
3217
  super(input, manager);
3192
3218
  __runInitializers2(_init4, 5, this);
3193
- __privateAdd2(this, _accept, __runInitializers2(_init4, 8, this)), __runInitializers2(_init4, 11, this);
3194
- __privateAdd2(this, _type2, __runInitializers2(_init4, 12, this)), __runInitializers2(_init4, 15, this);
3195
- __privateAdd2(this, _collisionDetector, __runInitializers2(_init4, 16, this)), __runInitializers2(_init4, 19, this);
3196
- __privateAdd2(this, _collisionPriority, __runInitializers2(_init4, 20, this)), __runInitializers2(_init4, 23, this);
3197
- __privateAdd2(this, _shape, __runInitializers2(_init4, 24, this)), __runInitializers2(_init4, 27, this);
3219
+ __privateAdd3(this, _accept, __runInitializers2(_init4, 8, this)), __runInitializers2(_init4, 11, this);
3220
+ __privateAdd3(this, _type2, __runInitializers2(_init4, 12, this)), __runInitializers2(_init4, 15, this);
3221
+ __privateAdd3(this, _collisionDetector, __runInitializers2(_init4, 16, this)), __runInitializers2(_init4, 19, this);
3222
+ __privateAdd3(this, _collisionPriority, __runInitializers2(_init4, 20, this)), __runInitializers2(_init4, 23, this);
3223
+ __privateAdd3(this, _shape, __runInitializers2(_init4, 24, this)), __runInitializers2(_init4, 27, this);
3198
3224
  this.accept = accept;
3199
3225
  this.collisionDetector = collisionDetector;
3200
3226
  this.collisionPriority = collisionPriority;
@@ -3240,6 +3266,13 @@ __decorateElement2(_init4, 4, "collisionPriority", _collisionPriority_dec, Dropp
3240
3266
  __decorateElement2(_init4, 4, "shape", _shape_dec, Droppable2, _shape);
3241
3267
  __decorateElement2(_init4, 2, "isDropTarget", _isDropTarget_dec, Droppable2);
3242
3268
  __decoratorMetadata2(_init4, Droppable2);
3269
+ var Sensor = class extends Plugin {
3270
+ constructor(manager, options) {
3271
+ super(manager, options);
3272
+ this.manager = manager;
3273
+ this.options = options;
3274
+ }
3275
+ };
3243
3276
 
3244
3277
  // components/DraggableComponent/collision/directional/index.ts
3245
3278
  init_react_import();
@@ -3579,6 +3612,25 @@ function useSortableSafe(input) {
3579
3612
  return useSortable(input);
3580
3613
  }
3581
3614
 
3615
+ // lib/get-deep-scroll-position.ts
3616
+ init_react_import();
3617
+ function getDeepScrollPosition(element) {
3618
+ let totalScroll = {
3619
+ x: 0,
3620
+ y: 0
3621
+ };
3622
+ let current = element;
3623
+ while (current && current !== document.documentElement) {
3624
+ const parent = current.parentElement;
3625
+ if (parent) {
3626
+ totalScroll.x += parent.scrollLeft;
3627
+ totalScroll.y += parent.scrollTop;
3628
+ }
3629
+ current = parent;
3630
+ }
3631
+ return totalScroll;
3632
+ }
3633
+
3582
3634
  // components/DraggableComponent/index.tsx
3583
3635
  import { jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
3584
3636
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
@@ -3586,7 +3638,7 @@ var DEBUG2 = false;
3586
3638
  var space = 8;
3587
3639
  var actionsOverlayTop = space * 6.5;
3588
3640
  var actionsTop = -(actionsOverlayTop - 8);
3589
- var actionsRight = space;
3641
+ var actionsSide = space;
3590
3642
  var DefaultActionBar = ({
3591
3643
  label,
3592
3644
  children
@@ -3618,7 +3670,6 @@ var DraggableComponent = ({
3618
3670
  } = useAppContext();
3619
3671
  const isModifierHeld = useModifierHeld("Alt");
3620
3672
  const ctx = useContext2(dropZoneContext);
3621
- const overlayRef = useRef3(null);
3622
3673
  const [localZones, setLocalZones] = useState12({});
3623
3674
  const registerLocalZone = useCallback6(
3624
3675
  (zoneCompound2, active) => {
@@ -3688,24 +3739,31 @@ var DraggableComponent = ({
3688
3739
  (_b = iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : document.getElementById("puck-preview")) != null ? _b : document.body
3689
3740
  );
3690
3741
  }, [iframe.enabled]);
3691
- const sync = useCallback6(() => {
3742
+ const portalContainerRect = useMemo3(() => {
3743
+ const portalContainerEl = iframe.enabled ? null : document.getElementById("puck-preview");
3744
+ return portalContainerEl == null ? void 0 : portalContainerEl.getBoundingClientRect();
3745
+ }, [iframe.enabled]);
3746
+ const getStyle = useCallback6(() => {
3692
3747
  var _a, _b;
3693
- if (!ref.current || !overlayRef.current) return;
3748
+ if (!ref.current) return;
3694
3749
  const rect = ref.current.getBoundingClientRect();
3695
- const doc = ref.current.ownerDocument;
3696
- const view = doc.defaultView;
3697
- const portalContainerEl = iframe.enabled ? null : document.getElementById("puck-preview");
3698
- const portalContainerRect = portalContainerEl == null ? void 0 : portalContainerEl.getBoundingClientRect();
3750
+ const deepScrollPosition = getDeepScrollPosition(ref.current);
3699
3751
  const scroll = {
3700
- x: ((view == null ? void 0 : view.scrollX) || 0) - ((_a = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _a : 0),
3701
- y: ((view == null ? void 0 : view.scrollY) || 0) - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _b : 0)
3752
+ x: deepScrollPosition.x - ((_a = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _a : 0),
3753
+ y: deepScrollPosition.y - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _b : 0)
3754
+ };
3755
+ const style2 = {
3756
+ left: `${rect.left + scroll.x}px`,
3757
+ top: `${rect.top + scroll.y}px`,
3758
+ height: `${rect.height}px`,
3759
+ width: `${rect.width}px`
3702
3760
  };
3703
- overlayRef.current.style.left = `${rect.left + scroll.x}px`;
3704
- overlayRef.current.style.top = `${rect.top + scroll.y}px`;
3705
- overlayRef.current.style.height = `${rect.height}px`;
3706
- overlayRef.current.style.width = `${rect.width}px`;
3707
- overlayRef.current.style.opacity = "1";
3708
- }, [ref, overlayRef, iframe]);
3761
+ return style2;
3762
+ }, [ref, portalContainerRect]);
3763
+ const [style, setStyle] = useState12();
3764
+ const sync = useCallback6(() => {
3765
+ setStyle(getStyle());
3766
+ }, [ref, iframe]);
3709
3767
  useEffect11(() => {
3710
3768
  ctx == null ? void 0 : ctx.registerPath({
3711
3769
  index,
@@ -3787,6 +3845,7 @@ var DraggableComponent = ({
3787
3845
  el.removeAttribute("data-puck-dragging");
3788
3846
  }
3789
3847
  return () => {
3848
+ el.removeAttribute("data-puck-component");
3790
3849
  el.removeEventListener("click", onClick);
3791
3850
  el.removeEventListener("mouseover", _onMouseOver);
3792
3851
  el.removeEventListener("mouseout", _onMouseOut);
@@ -3794,7 +3853,6 @@ var DraggableComponent = ({
3794
3853
  };
3795
3854
  }, [
3796
3855
  ref,
3797
- overlayRef,
3798
3856
  onClick,
3799
3857
  containsActiveZone,
3800
3858
  zoneCompound,
@@ -3812,20 +3870,35 @@ var DraggableComponent = ({
3812
3870
  };
3813
3871
  }
3814
3872
  }, [disabled, ref]);
3815
- const isVisible = isSelected || hover || indicativeHover;
3816
- const [actionsWidth, setActionsWidth] = useState12(250);
3817
- const actionsRef = useRef3(null);
3818
- const updateActionsWidth = useCallback6(() => {
3819
- if (actionsRef.current) {
3820
- const rect = actionsRef.current.getBoundingClientRect();
3821
- setActionsWidth(rect.width);
3873
+ const [isVisible, setIsVisible] = useState12(false);
3874
+ useEffect11(() => {
3875
+ sync();
3876
+ if ((isSelected || hover || indicativeHover) && !userIsDragging) {
3877
+ setIsVisible(true);
3878
+ } else {
3879
+ setIsVisible(false);
3822
3880
  }
3823
- }, []);
3824
- useEffect11(updateActionsWidth, [
3825
- actionsRef.current,
3826
- zoomConfig.zoom,
3827
- isSelected
3828
- ]);
3881
+ }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3882
+ const syncActionsPosition = useCallback6(
3883
+ (el) => {
3884
+ if (el) {
3885
+ const view = el.ownerDocument.defaultView;
3886
+ if (view) {
3887
+ const rect = el.getBoundingClientRect();
3888
+ const diffLeft = rect.x;
3889
+ const exceedsBoundsLeft = diffLeft < 0;
3890
+ if (exceedsBoundsLeft) {
3891
+ el.style.transformOrigin = "left top";
3892
+ el.style.left = "0px";
3893
+ } else {
3894
+ el.style.transformOrigin = "right top";
3895
+ el.style.left = "";
3896
+ }
3897
+ }
3898
+ }
3899
+ },
3900
+ [zoomConfig]
3901
+ );
3829
3902
  useEffect11(() => {
3830
3903
  if (userDragAxis) {
3831
3904
  setDragAxis(userDragAxis);
@@ -3840,7 +3913,6 @@ var DraggableComponent = ({
3840
3913
  }
3841
3914
  setDragAxis(autoDragAxis);
3842
3915
  }, [ref, userDragAxis, autoDragAxis]);
3843
- useEffect11(sync, [ref, overlayRef, isVisible, hover, iframe, state.data]);
3844
3916
  return /* @__PURE__ */ jsxs10(
3845
3917
  DropZoneProvider,
3846
3918
  {
@@ -3863,7 +3935,7 @@ var DraggableComponent = ({
3863
3935
  isModifierHeld,
3864
3936
  hover: hover || indicativeHover
3865
3937
  }),
3866
- ref: overlayRef,
3938
+ style: __spreadValues({}, style),
3867
3939
  children: [
3868
3940
  debug,
3869
3941
  isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
@@ -3872,9 +3944,7 @@ var DraggableComponent = ({
3872
3944
  {
3873
3945
  className: getClassName16("actionsOverlay"),
3874
3946
  style: {
3875
- top: actionsOverlayTop / zoomConfig.zoom,
3876
- // Offset against left of frame
3877
- minWidth: actionsWidth + 2 * actionsRight
3947
+ top: actionsOverlayTop / zoomConfig.zoom
3878
3948
  },
3879
3949
  children: /* @__PURE__ */ jsx21(
3880
3950
  "div",
@@ -3883,9 +3953,11 @@ var DraggableComponent = ({
3883
3953
  style: {
3884
3954
  transform: `scale(${1 / zoomConfig.zoom}`,
3885
3955
  top: actionsTop / zoomConfig.zoom,
3886
- right: actionsRight / zoomConfig.zoom
3956
+ right: 0,
3957
+ paddingLeft: actionsSide,
3958
+ paddingRight: actionsSide
3887
3959
  },
3888
- ref: actionsRef,
3960
+ ref: syncActionsPosition,
3889
3961
  children: /* @__PURE__ */ jsxs10(CustomActionBar, { label: DEBUG2 ? id : label, children: [
3890
3962
  permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
3891
3963
  permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
@@ -3908,7 +3980,7 @@ var DraggableComponent = ({
3908
3980
 
3909
3981
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
3910
3982
  init_react_import();
3911
- var styles_module_default12 = { "DropZone": "_DropZone_q2ip3_1", "DropZone--hasChildren": "_DropZone--hasChildren_q2ip3_12", "DropZone--userIsDragging": "_DropZone--userIsDragging_q2ip3_20", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_q2ip3_29", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_q2ip3_30", "DropZone--isRootZone": "_DropZone--isRootZone_q2ip3_30", "DropZone--isDestination": "_DropZone--isDestination_q2ip3_40", "DropZone-item": "_DropZone-item_q2ip3_52", "DropZone-hitbox": "_DropZone-hitbox_q2ip3_56", "DropZone--isEnabled": "_DropZone--isEnabled_q2ip3_64" };
3983
+ var styles_module_default12 = { "DropZone": "_DropZone_74ebh_1", "DropZone--hasChildren": "_DropZone--hasChildren_74ebh_12", "DropZone--userIsDragging": "_DropZone--userIsDragging_74ebh_20", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_74ebh_29", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_74ebh_30", "DropZone--isRootZone": "_DropZone--isRootZone_74ebh_30", "DropZone--isDestination": "_DropZone--isDestination_74ebh_40", "DropZone-item": "_DropZone-item_74ebh_52", "DropZone-hitbox": "_DropZone-hitbox_74ebh_56", "DropZone--isEnabled": "_DropZone--isEnabled_74ebh_64" };
3912
3984
 
3913
3985
  // components/DropZone/context.tsx
3914
3986
  init_react_import();
@@ -4122,7 +4194,7 @@ function DropZoneEdit({
4122
4194
  const [dragAxis, setDragAxis] = useState14(
4123
4195
  collisionAxis || DEFAULT_DRAG_AXIS
4124
4196
  );
4125
- useEffect12(() => {
4197
+ const calculateDragAxis = useCallback8(() => {
4126
4198
  if (ref.current) {
4127
4199
  const computedStyle = window.getComputedStyle(ref.current);
4128
4200
  if (computedStyle.display === "grid") {
@@ -4133,7 +4205,17 @@ function DropZoneEdit({
4133
4205
  setDragAxis(DEFAULT_DRAG_AXIS);
4134
4206
  }
4135
4207
  }
4136
- }, [ref, appContext2.status, collisionAxis]);
4208
+ }, [ref.current]);
4209
+ useEffect12(calculateDragAxis, [appContext2.status, collisionAxis]);
4210
+ useEffect12(() => {
4211
+ const onViewportChange = () => {
4212
+ calculateDragAxis();
4213
+ };
4214
+ window.addEventListener("viewportchange", onViewportChange);
4215
+ return () => {
4216
+ window.removeEventListener("viewportchange", onViewportChange);
4217
+ };
4218
+ }, []);
4137
4219
  return /* @__PURE__ */ jsxs11(
4138
4220
  "div",
4139
4221
  {
@@ -4422,6 +4504,11 @@ var findDeepestCandidate = (position, manager) => {
4422
4504
  if (candidateData2.areaId === draggedCandidateId) {
4423
4505
  return false;
4424
4506
  }
4507
+ } else if (candidate.type === "component") {
4508
+ const candidateData2 = candidate.data;
4509
+ if (!candidateData2.inDroppableZone) {
4510
+ return false;
4511
+ }
4425
4512
  }
4426
4513
  return true;
4427
4514
  });
@@ -4459,9 +4546,14 @@ var createNestedDroppablePlugin = ({
4459
4546
  y: event.clientY
4460
4547
  });
4461
4548
  };
4462
- document.body.addEventListener("pointermove", handlePointerMove);
4549
+ document.body.addEventListener("pointermove", handlePointerMove, {
4550
+ capture: true
4551
+ // dndkit's PointerSensor prevents propagation during drag
4552
+ });
4463
4553
  this.destroy = () => {
4464
- document.body.removeEventListener("pointermove", handlePointerMove);
4554
+ document.body.removeEventListener("pointermove", handlePointerMove, {
4555
+ capture: true
4556
+ });
4465
4557
  cleanupEffect();
4466
4558
  };
4467
4559
  });
@@ -4773,6 +4865,11 @@ var reduceUi = (ui, action) => {
4773
4865
  }
4774
4866
  return __spreadValues(__spreadValues({}, ui), action.ui(ui));
4775
4867
  }
4868
+ if (action.type === "duplicate") {
4869
+ return __spreadProps(__spreadValues({}, ui), {
4870
+ itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4871
+ });
4872
+ }
4776
4873
  return ui;
4777
4874
  };
4778
4875
 
@@ -4858,6 +4955,274 @@ var insertComponent = (componentType, zone, index, {
4858
4955
 
4859
4956
  // components/DragDropContext/index.tsx
4860
4957
  import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
4958
+ import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
4959
+
4960
+ // components/DragDropContext/PointerSensor.ts
4961
+ init_react_import();
4962
+ import {
4963
+ getDocument,
4964
+ isElement,
4965
+ isHTMLElement,
4966
+ isPointerEvent,
4967
+ Listeners,
4968
+ getFrameTransform
4969
+ } from "@dnd-kit/dom/utilities";
4970
+ var _clearTimeout;
4971
+ var _PointerSensor = class _PointerSensor extends Sensor {
4972
+ constructor(manager, options) {
4973
+ super(manager);
4974
+ this.manager = manager;
4975
+ this.options = options;
4976
+ this.listeners = new Listeners();
4977
+ this.cleanup = /* @__PURE__ */ new Set();
4978
+ this.source = void 0;
4979
+ __privateAdd(this, _clearTimeout);
4980
+ this.handleCancel = this.handleCancel.bind(this);
4981
+ this.handlePointerUp = this.handlePointerUp.bind(this);
4982
+ this.handleKeyDown = this.handleKeyDown.bind(this);
4983
+ E(() => {
4984
+ const unbindGlobal = this.bindGlobal(options != null ? options : {});
4985
+ return () => {
4986
+ unbindGlobal();
4987
+ };
4988
+ });
4989
+ }
4990
+ bind(source, options = this.options) {
4991
+ const unbind = E(() => {
4992
+ var _a;
4993
+ const target = (_a = source.handle) != null ? _a : source.element;
4994
+ const listener = (event) => {
4995
+ if (isPointerEvent(event)) {
4996
+ this.handlePointerDown(event, source, options);
4997
+ }
4998
+ };
4999
+ if (target) {
5000
+ patchWindow(target.ownerDocument.defaultView);
5001
+ target.addEventListener("pointerdown", listener);
5002
+ return () => {
5003
+ target.removeEventListener("pointerdown", listener);
5004
+ };
5005
+ }
5006
+ });
5007
+ return unbind;
5008
+ }
5009
+ bindGlobal(options) {
5010
+ const documents = /* @__PURE__ */ new Set();
5011
+ for (const draggable of this.manager.registry.draggables.value) {
5012
+ if (draggable.element) {
5013
+ documents.add(getDocument(draggable.element));
5014
+ }
5015
+ }
5016
+ for (const droppable of this.manager.registry.droppables.value) {
5017
+ if (droppable.element) {
5018
+ documents.add(getDocument(droppable.element));
5019
+ }
5020
+ }
5021
+ const unbindFns = Array.from(documents).map(
5022
+ (doc) => this.listeners.bind(doc, [
5023
+ {
5024
+ type: "pointermove",
5025
+ listener: (event) => this.handlePointerMove(event, doc, options)
5026
+ },
5027
+ {
5028
+ type: "pointerup",
5029
+ listener: this.handlePointerUp,
5030
+ options: {
5031
+ capture: true
5032
+ }
5033
+ },
5034
+ {
5035
+ // Cancel activation if there is a competing Drag and Drop interaction
5036
+ type: "dragstart",
5037
+ listener: this.handleDragStart
5038
+ }
5039
+ ])
5040
+ );
5041
+ return () => {
5042
+ unbindFns.forEach((unbind) => unbind());
5043
+ };
5044
+ }
5045
+ handlePointerDown(event, source, options = {}) {
5046
+ if (this.disabled || !event.isPrimary || event.button !== 0 || !isElement(event.target) || source.disabled) {
5047
+ return;
5048
+ }
5049
+ const offset = getFrameTransform(source.element);
5050
+ this.initialCoordinates = {
5051
+ x: event.clientX * offset.scaleX + offset.x,
5052
+ y: event.clientY * offset.scaleY + offset.y
5053
+ };
5054
+ this.source = source;
5055
+ const { activationConstraints } = options;
5056
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
5057
+ event.stopImmediatePropagation();
5058
+ if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
5059
+ this.handleStart(source, event);
5060
+ } else {
5061
+ const { delay } = constraints;
5062
+ if (delay) {
5063
+ const timeout3 = setTimeout(
5064
+ () => this.handleStart(source, event),
5065
+ delay.value
5066
+ );
5067
+ __privateSet(this, _clearTimeout, () => {
5068
+ clearTimeout(timeout3);
5069
+ __privateSet(this, _clearTimeout, void 0);
5070
+ });
5071
+ }
5072
+ }
5073
+ const cleanup = () => {
5074
+ var _a;
5075
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
5076
+ this.initialCoordinates = void 0;
5077
+ this.source = void 0;
5078
+ };
5079
+ this.cleanup.add(cleanup);
5080
+ }
5081
+ handlePointerMove(event, doc, options) {
5082
+ if (!this.source) {
5083
+ return;
5084
+ }
5085
+ const ownerDocument = this.source.element && getDocument(this.source.element);
5086
+ if (doc !== ownerDocument) {
5087
+ return;
5088
+ }
5089
+ const coordinates = {
5090
+ x: event.clientX,
5091
+ y: event.clientY
5092
+ };
5093
+ const offset = getFrameTransform(this.source.element);
5094
+ coordinates.x = coordinates.x * offset.scaleX + offset.x;
5095
+ coordinates.y = coordinates.y * offset.scaleY + offset.y;
5096
+ if (this.manager.dragOperation.status.dragging) {
5097
+ event.preventDefault();
5098
+ event.stopPropagation();
5099
+ this.manager.actions.move({ to: coordinates });
5100
+ return;
5101
+ }
5102
+ if (!this.initialCoordinates) {
5103
+ return;
5104
+ }
5105
+ const delta = {
5106
+ x: coordinates.x - this.initialCoordinates.x,
5107
+ y: coordinates.y - this.initialCoordinates.y
5108
+ };
5109
+ const { activationConstraints } = options;
5110
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
5111
+ const { distance, delay } = constraints != null ? constraints : {};
5112
+ if (distance) {
5113
+ if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
5114
+ return this.handleCancel();
5115
+ }
5116
+ if (exceedsDistance(delta, distance.value)) {
5117
+ return this.handleStart(this.source, event);
5118
+ }
5119
+ }
5120
+ if (delay) {
5121
+ if (exceedsDistance(delta, delay.tolerance)) {
5122
+ return this.handleCancel();
5123
+ }
5124
+ }
5125
+ }
5126
+ handlePointerUp(event) {
5127
+ event.preventDefault();
5128
+ event.stopPropagation();
5129
+ const { status } = this.manager.dragOperation;
5130
+ if (!status.idle) {
5131
+ const canceled = !status.initialized;
5132
+ this.manager.actions.stop({ canceled });
5133
+ }
5134
+ this.cleanup.forEach((cleanup) => cleanup());
5135
+ this.cleanup.clear();
5136
+ }
5137
+ handleKeyDown(event) {
5138
+ if (event.key === "Escape") {
5139
+ event.preventDefault();
5140
+ this.handleCancel();
5141
+ }
5142
+ }
5143
+ handleStart(source, event) {
5144
+ var _a;
5145
+ const { manager, initialCoordinates } = this;
5146
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
5147
+ if (!initialCoordinates || manager.dragOperation.status.initialized) {
5148
+ return;
5149
+ }
5150
+ if (event.defaultPrevented) {
5151
+ return;
5152
+ }
5153
+ event.preventDefault();
5154
+ o(() => {
5155
+ manager.actions.setDragSource(source.id);
5156
+ manager.actions.start({ coordinates: initialCoordinates, event });
5157
+ });
5158
+ const ownerDocument = getDocument(event.target);
5159
+ const unbind = this.listeners.bind(ownerDocument, [
5160
+ {
5161
+ // Prevent scrolling on touch devices
5162
+ type: "touchmove",
5163
+ listener: preventDefault,
5164
+ options: {
5165
+ passive: false
5166
+ }
5167
+ },
5168
+ {
5169
+ // Prevent click events
5170
+ type: "click",
5171
+ listener: preventDefault
5172
+ },
5173
+ {
5174
+ type: "keydown",
5175
+ listener: this.handleKeyDown
5176
+ }
5177
+ ]);
5178
+ ownerDocument.body.setPointerCapture(event.pointerId);
5179
+ this.cleanup.add(unbind);
5180
+ }
5181
+ handleDragStart(event) {
5182
+ const { target } = event;
5183
+ if (!isElement(target)) {
5184
+ return;
5185
+ }
5186
+ const isNativeDraggable = isHTMLElement(target) && target.draggable && target.getAttribute("draggable") === "true";
5187
+ if (isNativeDraggable) {
5188
+ this.handleCancel();
5189
+ } else {
5190
+ preventDefault(event);
5191
+ }
5192
+ }
5193
+ handleCancel() {
5194
+ const { dragOperation } = this.manager;
5195
+ if (dragOperation.status.initialized) {
5196
+ this.manager.actions.stop({ canceled: true });
5197
+ }
5198
+ this.cleanup.forEach((cleanup) => cleanup());
5199
+ this.cleanup.clear();
5200
+ }
5201
+ destroy() {
5202
+ this.listeners.clear();
5203
+ }
5204
+ };
5205
+ _clearTimeout = new WeakMap();
5206
+ _PointerSensor.configure = configurator(_PointerSensor);
5207
+ var PointerSensor = _PointerSensor;
5208
+ function preventDefault(event) {
5209
+ event.preventDefault();
5210
+ }
5211
+ function noop() {
5212
+ }
5213
+ var windows = /* @__PURE__ */ new WeakSet();
5214
+ function patchWindow(window2) {
5215
+ if (!window2 || windows.has(window2)) {
5216
+ return;
5217
+ }
5218
+ window2.addEventListener("touchmove", noop, {
5219
+ capture: false,
5220
+ passive: false
5221
+ });
5222
+ windows.add(window2);
5223
+ }
5224
+
5225
+ // components/DragDropContext/index.tsx
4861
5226
  import { jsx as jsx24 } from "react/jsx-runtime";
4862
5227
  var dragListenerContext = createContext3({
4863
5228
  dragListeners: {}
@@ -4873,10 +5238,11 @@ function useDragListener(type, fn, deps = []) {
4873
5238
  }, deps);
4874
5239
  }
4875
5240
  var previewContext = createContext3(null);
4876
- var AREA_CHANGE_DEBOUNCE_MS = 150;
5241
+ var AREA_CHANGE_DEBOUNCE_MS = 100;
4877
5242
  var DragDropContextClient = ({ children }) => {
4878
5243
  const { state, config, dispatch, resolveData } = useAppContext();
4879
5244
  const [preview, setPreview] = useState15(null);
5245
+ const previewRef = useRef5(null);
4880
5246
  const { data } = state;
4881
5247
  const [deepest, setDeepest] = useState15(null);
4882
5248
  const [nextDeepest, setNextDeepest] = useState15(null);
@@ -4923,6 +5289,25 @@ var DragDropContextClient = ({ children }) => {
4923
5289
  }
4924
5290
  })
4925
5291
  ]);
5292
+ const [sensors] = useState15(() => [
5293
+ PointerSensor.configure({
5294
+ activationConstraints(event, source) {
5295
+ var _a;
5296
+ const { pointerType, target } = event;
5297
+ if (pointerType === "mouse" && isElement2(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
5298
+ return void 0;
5299
+ }
5300
+ const delay = { value: 200, tolerance: 10 };
5301
+ if (pointerType === "touch") {
5302
+ return { delay };
5303
+ }
5304
+ return {
5305
+ delay,
5306
+ distance: { value: 5 }
5307
+ };
5308
+ }
5309
+ })
5310
+ ]);
4926
5311
  const [draggedItem, setDraggedItem] = useState15();
4927
5312
  const [dragListeners, setDragListeners] = useState15({});
4928
5313
  const [pathData, setPathData] = useState15();
@@ -4961,32 +5346,34 @@ var DragDropContextClient = ({ children }) => {
4961
5346
  DragDropProvider,
4962
5347
  {
4963
5348
  plugins,
5349
+ sensors,
4964
5350
  onDragEnd: (event, manager) => {
4965
5351
  const { source, target } = event.operation;
5352
+ deepestRef.current = null;
4966
5353
  if (!source) {
4967
5354
  setDraggedItem(null);
4968
5355
  return;
4969
5356
  }
4970
5357
  const { zone, index } = source.data;
5358
+ const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
5359
+ previewRef.current = null;
4971
5360
  setTimeout(() => {
4972
5361
  var _a, _b;
4973
5362
  setDraggedItem(null);
4974
5363
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
4975
- if (preview) {
4976
- setPreview(null);
4977
- }
5364
+ setPreview(null);
4978
5365
  (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
4979
5366
  fn(event, manager);
4980
5367
  });
4981
5368
  return;
4982
5369
  }
4983
- if (preview) {
5370
+ if (thisPreview) {
4984
5371
  setPreview(null);
4985
- if (preview.type === "insert") {
5372
+ if (thisPreview.type === "insert") {
4986
5373
  insertComponent(
4987
- preview.componentType,
4988
- preview.zone,
4989
- preview.index,
5374
+ thisPreview.componentType,
5375
+ thisPreview.zone,
5376
+ thisPreview.index,
4990
5377
  { config, dispatch, resolveData, state }
4991
5378
  );
4992
5379
  } else if (initialSelector.current) {
@@ -4994,8 +5381,8 @@ var DragDropContextClient = ({ children }) => {
4994
5381
  type: "move",
4995
5382
  sourceIndex: initialSelector.current.index,
4996
5383
  sourceZone: initialSelector.current.zone,
4997
- destinationIndex: preview.index,
4998
- destinationZone: preview.zone,
5384
+ destinationIndex: thisPreview.index,
5385
+ destinationZone: thisPreview.zone,
4999
5386
  recordHistory: false
5000
5387
  });
5001
5388
  }
@@ -5011,7 +5398,7 @@ var DragDropContextClient = ({ children }) => {
5011
5398
  (_b = dragListeners.dragend) == null ? void 0 : _b.forEach((fn) => {
5012
5399
  fn(event, manager);
5013
5400
  });
5014
- }, 250);
5401
+ }, 300);
5015
5402
  },
5016
5403
  onDragOver: (event, manager) => {
5017
5404
  var _a, _b, _c3, _d;
@@ -5049,7 +5436,7 @@ var DragDropContextClient = ({ children }) => {
5049
5436
  return;
5050
5437
  }
5051
5438
  if (dragMode.current === "new") {
5052
- setPreview({
5439
+ previewRef.current = {
5053
5440
  componentType: sourceData.componentType,
5054
5441
  type: "insert",
5055
5442
  index: targetIndex,
@@ -5057,7 +5444,8 @@ var DragDropContextClient = ({ children }) => {
5057
5444
  props: {
5058
5445
  id: source.id.toString()
5059
5446
  }
5060
- });
5447
+ };
5448
+ setPreview(previewRef.current);
5061
5449
  } else {
5062
5450
  if (!initialSelector.current) {
5063
5451
  initialSelector.current = {
@@ -5067,13 +5455,14 @@ var DragDropContextClient = ({ children }) => {
5067
5455
  }
5068
5456
  const item = getItem(initialSelector.current, data);
5069
5457
  if (item) {
5070
- setPreview({
5458
+ previewRef.current = {
5071
5459
  componentType: sourceData.componentType,
5072
5460
  type: "move",
5073
5461
  index: targetIndex,
5074
5462
  zone: targetZone,
5075
5463
  props: item.props
5076
- });
5464
+ };
5465
+ setPreview(previewRef.current);
5077
5466
  }
5078
5467
  }
5079
5468
  (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
@@ -5240,7 +5629,9 @@ var Drawer = ({
5240
5629
  const [id] = useState16(generateId());
5241
5630
  const { ref } = useDroppableSafe({
5242
5631
  id,
5243
- type: "void"
5632
+ type: "void",
5633
+ collisionPriority: 0
5634
+ // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
5244
5635
  });
5245
5636
  return /* @__PURE__ */ jsx25("div", { className: getClassName18(), ref, children });
5246
5637
  };
@@ -6107,11 +6498,12 @@ var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPrev
6107
6498
  import { Fragment as Fragment14, jsx as jsx33 } from "react/jsx-runtime";
6108
6499
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
6109
6500
  var useBubbleIframeEvents = (ref) => {
6501
+ const { status } = useAppContext();
6110
6502
  useEffect17(() => {
6111
6503
  var _a;
6112
- if (ref.current) {
6504
+ if (ref.current && status === "READY") {
6113
6505
  const iframe = ref.current;
6114
- (_a = iframe.contentWindow) == null ? void 0 : _a.addEventListener("mousemove", function(event) {
6506
+ const handlePointerMove = (event) => {
6115
6507
  var _a2;
6116
6508
  const rect = iframe.getBoundingClientRect();
6117
6509
  const evt = new CustomEvent("pointermove", {
@@ -6122,9 +6514,23 @@ var useBubbleIframeEvents = (ref) => {
6122
6514
  evt.clientX = event.clientX * scaleFactor + rect.left;
6123
6515
  evt.clientY = event.clientY * scaleFactor + rect.top;
6124
6516
  iframe.dispatchEvent(evt);
6125
- });
6517
+ };
6518
+ (_a = iframe.contentDocument) == null ? void 0 : _a.addEventListener(
6519
+ "pointermove",
6520
+ handlePointerMove,
6521
+ {
6522
+ capture: true
6523
+ }
6524
+ );
6525
+ return () => {
6526
+ var _a2;
6527
+ (_a2 = iframe.contentDocument) == null ? void 0 : _a2.removeEventListener(
6528
+ "pointermove",
6529
+ handlePointerMove
6530
+ );
6531
+ };
6126
6532
  }
6127
- }, [ref]);
6533
+ }, [status]);
6128
6534
  };
6129
6535
  var Preview = ({ id = "puck-preview" }) => {
6130
6536
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
@@ -6851,7 +7257,7 @@ var ViewportControls = ({
6851
7257
 
6852
7258
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
6853
7259
  init_react_import();
6854
- var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_avf1c_1", "PuckCanvas-controls": "_PuckCanvas-controls_avf1c_16", "PuckCanvas-inner": "_PuckCanvas-inner_avf1c_21", "PuckCanvas-root": "_PuckCanvas-root_avf1c_32", "PuckCanvas--ready": "_PuckCanvas--ready_avf1c_57", "PuckCanvas-loader": "_PuckCanvas-loader_avf1c_62", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_avf1c_72" };
7260
+ 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" };
6855
7261
 
6856
7262
  // lib/get-zoom-config.ts
6857
7263
  init_react_import();
@@ -7006,6 +7412,14 @@ var Canvas = () => {
7006
7412
  },
7007
7413
  suppressHydrationWarning: true,
7008
7414
  id: "puck-canvas-root",
7415
+ onTransitionEnd: () => {
7416
+ window.dispatchEvent(
7417
+ new CustomEvent("viewportchange", {
7418
+ bubbles: true,
7419
+ cancelable: false
7420
+ })
7421
+ );
7422
+ },
7009
7423
  children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview, {}) })
7010
7424
  }
7011
7425
  ),
@@ -7076,6 +7490,7 @@ import { useEffect as useEffect20, useState as useState23 } from "react";
7076
7490
  var styles = `
7077
7491
  /* Prevent user from interacting with underlying component */
7078
7492
  [data-puck-component] * {
7493
+ pointer-events: none;
7079
7494
  user-select: none;
7080
7495
  -webkit-user-select: none;
7081
7496
  }