@measured/puck 0.17.0-canary.2d82115 → 0.17.0-canary.552c8f9

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({
@@ -2245,7 +2248,7 @@ import {
2245
2248
  useRef as useRef5,
2246
2249
  useState as useState15
2247
2250
  } from "react";
2248
- import { defaultPreset, PointerSensor } from "@dnd-kit/dom";
2251
+ import { defaultPreset } from "@dnd-kit/dom";
2249
2252
 
2250
2253
  // components/DropZone/index.tsx
2251
2254
  init_react_import();
@@ -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_146qs_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_146qs_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_146qs_29", "DraggableComponent--hover": "_DraggableComponent--hover_146qs_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_146qs_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_146qs_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_146qs_66", "DraggableComponent-actions": "_DraggableComponent-actions_146qs_66" };
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();
@@ -3586,7 +3619,7 @@ var DEBUG2 = false;
3586
3619
  var space = 8;
3587
3620
  var actionsOverlayTop = space * 6.5;
3588
3621
  var actionsTop = -(actionsOverlayTop - 8);
3589
- var actionsRight = space;
3622
+ var actionsSide = space;
3590
3623
  var DefaultActionBar = ({
3591
3624
  label,
3592
3625
  children
@@ -3618,7 +3651,6 @@ var DraggableComponent = ({
3618
3651
  } = useAppContext();
3619
3652
  const isModifierHeld = useModifierHeld("Alt");
3620
3653
  const ctx = useContext2(dropZoneContext);
3621
- const overlayRef = useRef3(null);
3622
3654
  const [localZones, setLocalZones] = useState12({});
3623
3655
  const registerLocalZone = useCallback6(
3624
3656
  (zoneCompound2, active) => {
@@ -3707,11 +3739,11 @@ var DraggableComponent = ({
3707
3739
  width: `${rect.width}px`
3708
3740
  };
3709
3741
  return style2;
3710
- }, [ref, overlayRef, iframe]);
3742
+ }, [ref, iframe]);
3711
3743
  const [style, setStyle] = useState12();
3712
3744
  const sync = useCallback6(() => {
3713
3745
  setStyle(getStyle());
3714
- }, [ref, overlayRef, iframe]);
3746
+ }, [ref, iframe]);
3715
3747
  useEffect11(() => {
3716
3748
  ctx == null ? void 0 : ctx.registerPath({
3717
3749
  index,
@@ -3793,6 +3825,7 @@ var DraggableComponent = ({
3793
3825
  el.removeAttribute("data-puck-dragging");
3794
3826
  }
3795
3827
  return () => {
3828
+ el.removeAttribute("data-puck-component");
3796
3829
  el.removeEventListener("click", onClick);
3797
3830
  el.removeEventListener("mouseover", _onMouseOver);
3798
3831
  el.removeEventListener("mouseout", _onMouseOut);
@@ -3800,7 +3833,6 @@ var DraggableComponent = ({
3800
3833
  };
3801
3834
  }, [
3802
3835
  ref,
3803
- overlayRef,
3804
3836
  onClick,
3805
3837
  containsActiveZone,
3806
3838
  zoneCompound,
@@ -3827,19 +3859,26 @@ var DraggableComponent = ({
3827
3859
  setIsVisible(false);
3828
3860
  }
3829
3861
  }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3830
- const [actionsWidth, setActionsWidth] = useState12(250);
3831
- const actionsRef = useRef3(null);
3832
- const updateActionsWidth = useCallback6(() => {
3833
- if (actionsRef.current) {
3834
- const rect = actionsRef.current.getBoundingClientRect();
3835
- setActionsWidth(rect.width);
3836
- }
3837
- }, []);
3838
- useEffect11(updateActionsWidth, [
3839
- actionsRef.current,
3840
- zoomConfig.zoom,
3841
- isSelected
3842
- ]);
3862
+ const syncActionsPosition = useCallback6(
3863
+ (el) => {
3864
+ if (el) {
3865
+ const view = el.ownerDocument.defaultView;
3866
+ if (view) {
3867
+ const rect = el.getBoundingClientRect();
3868
+ const diffLeft = rect.x;
3869
+ const exceedsBoundsLeft = diffLeft < 0;
3870
+ if (exceedsBoundsLeft) {
3871
+ el.style.transformOrigin = "left top";
3872
+ el.style.left = "0px";
3873
+ } else {
3874
+ el.style.transformOrigin = "right top";
3875
+ el.style.left = "";
3876
+ }
3877
+ }
3878
+ }
3879
+ },
3880
+ [zoomConfig]
3881
+ );
3843
3882
  useEffect11(() => {
3844
3883
  if (userDragAxis) {
3845
3884
  setDragAxis(userDragAxis);
@@ -3876,7 +3915,6 @@ var DraggableComponent = ({
3876
3915
  isModifierHeld,
3877
3916
  hover: hover || indicativeHover
3878
3917
  }),
3879
- ref: overlayRef,
3880
3918
  style: __spreadValues({}, style),
3881
3919
  children: [
3882
3920
  debug,
@@ -3886,9 +3924,7 @@ var DraggableComponent = ({
3886
3924
  {
3887
3925
  className: getClassName16("actionsOverlay"),
3888
3926
  style: {
3889
- top: actionsOverlayTop / zoomConfig.zoom,
3890
- // Offset against left of frame
3891
- minWidth: actionsWidth + 2 * actionsRight
3927
+ top: actionsOverlayTop / zoomConfig.zoom
3892
3928
  },
3893
3929
  children: /* @__PURE__ */ jsx21(
3894
3930
  "div",
@@ -3897,9 +3933,11 @@ var DraggableComponent = ({
3897
3933
  style: {
3898
3934
  transform: `scale(${1 / zoomConfig.zoom}`,
3899
3935
  top: actionsTop / zoomConfig.zoom,
3900
- right: actionsRight / zoomConfig.zoom
3936
+ right: 0,
3937
+ paddingLeft: actionsSide,
3938
+ paddingRight: actionsSide
3901
3939
  },
3902
- ref: actionsRef,
3940
+ ref: syncActionsPosition,
3903
3941
  children: /* @__PURE__ */ jsxs10(CustomActionBar, { label: DEBUG2 ? id : label, children: [
3904
3942
  permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
3905
3943
  permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
@@ -3922,7 +3960,7 @@ var DraggableComponent = ({
3922
3960
 
3923
3961
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
3924
3962
  init_react_import();
3925
- 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" };
3963
+ 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" };
3926
3964
 
3927
3965
  // components/DropZone/context.tsx
3928
3966
  init_react_import();
@@ -4802,6 +4840,11 @@ var reduceUi = (ui, action) => {
4802
4840
  }
4803
4841
  return __spreadValues(__spreadValues({}, ui), action.ui(ui));
4804
4842
  }
4843
+ if (action.type === "duplicate") {
4844
+ return __spreadProps(__spreadValues({}, ui), {
4845
+ itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4846
+ });
4847
+ }
4805
4848
  return ui;
4806
4849
  };
4807
4850
 
@@ -4887,7 +4930,274 @@ var insertComponent = (componentType, zone, index, {
4887
4930
 
4888
4931
  // components/DragDropContext/index.tsx
4889
4932
  import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
4890
- import { isElement } from "@dnd-kit/dom/utilities";
4933
+ import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
4934
+
4935
+ // components/DragDropContext/PointerSensor.ts
4936
+ init_react_import();
4937
+ import {
4938
+ getDocument,
4939
+ isElement,
4940
+ isHTMLElement,
4941
+ isPointerEvent,
4942
+ Listeners,
4943
+ getFrameTransform
4944
+ } from "@dnd-kit/dom/utilities";
4945
+ var _clearTimeout;
4946
+ var _PointerSensor = class _PointerSensor extends Sensor {
4947
+ constructor(manager, options) {
4948
+ super(manager);
4949
+ this.manager = manager;
4950
+ this.options = options;
4951
+ this.listeners = new Listeners();
4952
+ this.cleanup = /* @__PURE__ */ new Set();
4953
+ this.source = void 0;
4954
+ __privateAdd(this, _clearTimeout);
4955
+ this.handleCancel = this.handleCancel.bind(this);
4956
+ this.handlePointerUp = this.handlePointerUp.bind(this);
4957
+ this.handleKeyDown = this.handleKeyDown.bind(this);
4958
+ E(() => {
4959
+ const unbindGlobal = this.bindGlobal(options != null ? options : {});
4960
+ return () => {
4961
+ unbindGlobal();
4962
+ };
4963
+ });
4964
+ }
4965
+ bind(source, options = this.options) {
4966
+ const unbind = E(() => {
4967
+ var _a;
4968
+ const target = (_a = source.handle) != null ? _a : source.element;
4969
+ const listener = (event) => {
4970
+ if (isPointerEvent(event)) {
4971
+ this.handlePointerDown(event, source, options);
4972
+ }
4973
+ };
4974
+ if (target) {
4975
+ patchWindow(target.ownerDocument.defaultView);
4976
+ target.addEventListener("pointerdown", listener);
4977
+ return () => {
4978
+ target.removeEventListener("pointerdown", listener);
4979
+ };
4980
+ }
4981
+ });
4982
+ return unbind;
4983
+ }
4984
+ bindGlobal(options) {
4985
+ const documents = /* @__PURE__ */ new Set();
4986
+ for (const draggable of this.manager.registry.draggables.value) {
4987
+ if (draggable.element) {
4988
+ documents.add(getDocument(draggable.element));
4989
+ }
4990
+ }
4991
+ for (const droppable of this.manager.registry.droppables.value) {
4992
+ if (droppable.element) {
4993
+ documents.add(getDocument(droppable.element));
4994
+ }
4995
+ }
4996
+ const unbindFns = Array.from(documents).map(
4997
+ (doc) => this.listeners.bind(doc, [
4998
+ {
4999
+ type: "pointermove",
5000
+ listener: (event) => this.handlePointerMove(event, doc, options)
5001
+ },
5002
+ {
5003
+ type: "pointerup",
5004
+ listener: this.handlePointerUp,
5005
+ options: {
5006
+ capture: true
5007
+ }
5008
+ },
5009
+ {
5010
+ // Cancel activation if there is a competing Drag and Drop interaction
5011
+ type: "dragstart",
5012
+ listener: this.handleDragStart
5013
+ }
5014
+ ])
5015
+ );
5016
+ return () => {
5017
+ unbindFns.forEach((unbind) => unbind());
5018
+ };
5019
+ }
5020
+ handlePointerDown(event, source, options = {}) {
5021
+ if (this.disabled || !event.isPrimary || event.button !== 0 || !isElement(event.target) || source.disabled) {
5022
+ return;
5023
+ }
5024
+ const offset = getFrameTransform(source.element);
5025
+ this.initialCoordinates = {
5026
+ x: event.clientX * offset.scaleX + offset.x,
5027
+ y: event.clientY * offset.scaleY + offset.y
5028
+ };
5029
+ this.source = source;
5030
+ const { activationConstraints } = options;
5031
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
5032
+ event.stopImmediatePropagation();
5033
+ if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
5034
+ this.handleStart(source, event);
5035
+ } else {
5036
+ const { delay } = constraints;
5037
+ if (delay) {
5038
+ const timeout3 = setTimeout(
5039
+ () => this.handleStart(source, event),
5040
+ delay.value
5041
+ );
5042
+ __privateSet(this, _clearTimeout, () => {
5043
+ clearTimeout(timeout3);
5044
+ __privateSet(this, _clearTimeout, void 0);
5045
+ });
5046
+ }
5047
+ }
5048
+ const cleanup = () => {
5049
+ var _a;
5050
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
5051
+ this.initialCoordinates = void 0;
5052
+ this.source = void 0;
5053
+ };
5054
+ this.cleanup.add(cleanup);
5055
+ }
5056
+ handlePointerMove(event, doc, options) {
5057
+ if (!this.source) {
5058
+ return;
5059
+ }
5060
+ const ownerDocument = this.source.element && getDocument(this.source.element);
5061
+ if (doc !== ownerDocument) {
5062
+ return;
5063
+ }
5064
+ const coordinates = {
5065
+ x: event.clientX,
5066
+ y: event.clientY
5067
+ };
5068
+ const offset = getFrameTransform(this.source.element);
5069
+ coordinates.x = coordinates.x * offset.scaleX + offset.x;
5070
+ coordinates.y = coordinates.y * offset.scaleY + offset.y;
5071
+ if (this.manager.dragOperation.status.dragging) {
5072
+ event.preventDefault();
5073
+ event.stopPropagation();
5074
+ this.manager.actions.move({ to: coordinates });
5075
+ return;
5076
+ }
5077
+ if (!this.initialCoordinates) {
5078
+ return;
5079
+ }
5080
+ const delta = {
5081
+ x: coordinates.x - this.initialCoordinates.x,
5082
+ y: coordinates.y - this.initialCoordinates.y
5083
+ };
5084
+ const { activationConstraints } = options;
5085
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
5086
+ const { distance, delay } = constraints != null ? constraints : {};
5087
+ if (distance) {
5088
+ if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
5089
+ return this.handleCancel();
5090
+ }
5091
+ if (exceedsDistance(delta, distance.value)) {
5092
+ return this.handleStart(this.source, event);
5093
+ }
5094
+ }
5095
+ if (delay) {
5096
+ if (exceedsDistance(delta, delay.tolerance)) {
5097
+ return this.handleCancel();
5098
+ }
5099
+ }
5100
+ }
5101
+ handlePointerUp(event) {
5102
+ event.preventDefault();
5103
+ event.stopPropagation();
5104
+ const { status } = this.manager.dragOperation;
5105
+ if (!status.idle) {
5106
+ const canceled = !status.initialized;
5107
+ this.manager.actions.stop({ canceled });
5108
+ }
5109
+ this.cleanup.forEach((cleanup) => cleanup());
5110
+ this.cleanup.clear();
5111
+ }
5112
+ handleKeyDown(event) {
5113
+ if (event.key === "Escape") {
5114
+ event.preventDefault();
5115
+ this.handleCancel();
5116
+ }
5117
+ }
5118
+ handleStart(source, event) {
5119
+ var _a;
5120
+ const { manager, initialCoordinates } = this;
5121
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
5122
+ if (!initialCoordinates || manager.dragOperation.status.initialized) {
5123
+ return;
5124
+ }
5125
+ if (event.defaultPrevented) {
5126
+ return;
5127
+ }
5128
+ event.preventDefault();
5129
+ o(() => {
5130
+ manager.actions.setDragSource(source.id);
5131
+ manager.actions.start({ coordinates: initialCoordinates, event });
5132
+ });
5133
+ const ownerDocument = getDocument(event.target);
5134
+ const unbind = this.listeners.bind(ownerDocument, [
5135
+ {
5136
+ // Prevent scrolling on touch devices
5137
+ type: "touchmove",
5138
+ listener: preventDefault,
5139
+ options: {
5140
+ passive: false
5141
+ }
5142
+ },
5143
+ {
5144
+ // Prevent click events
5145
+ type: "click",
5146
+ listener: preventDefault
5147
+ },
5148
+ {
5149
+ type: "keydown",
5150
+ listener: this.handleKeyDown
5151
+ }
5152
+ ]);
5153
+ ownerDocument.body.setPointerCapture(event.pointerId);
5154
+ this.cleanup.add(unbind);
5155
+ }
5156
+ handleDragStart(event) {
5157
+ const { target } = event;
5158
+ if (!isElement(target)) {
5159
+ return;
5160
+ }
5161
+ const isNativeDraggable = isHTMLElement(target) && target.draggable && target.getAttribute("draggable") === "true";
5162
+ if (isNativeDraggable) {
5163
+ this.handleCancel();
5164
+ } else {
5165
+ preventDefault(event);
5166
+ }
5167
+ }
5168
+ handleCancel() {
5169
+ const { dragOperation } = this.manager;
5170
+ if (dragOperation.status.initialized) {
5171
+ this.manager.actions.stop({ canceled: true });
5172
+ }
5173
+ this.cleanup.forEach((cleanup) => cleanup());
5174
+ this.cleanup.clear();
5175
+ }
5176
+ destroy() {
5177
+ this.listeners.clear();
5178
+ }
5179
+ };
5180
+ _clearTimeout = new WeakMap();
5181
+ _PointerSensor.configure = configurator(_PointerSensor);
5182
+ var PointerSensor = _PointerSensor;
5183
+ function preventDefault(event) {
5184
+ event.preventDefault();
5185
+ }
5186
+ function noop() {
5187
+ }
5188
+ var windows = /* @__PURE__ */ new WeakSet();
5189
+ function patchWindow(window2) {
5190
+ if (!window2 || windows.has(window2)) {
5191
+ return;
5192
+ }
5193
+ window2.addEventListener("touchmove", noop, {
5194
+ capture: false,
5195
+ passive: false
5196
+ });
5197
+ windows.add(window2);
5198
+ }
5199
+
5200
+ // components/DragDropContext/index.tsx
4891
5201
  import { jsx as jsx24 } from "react/jsx-runtime";
4892
5202
  var dragListenerContext = createContext3({
4893
5203
  dragListeners: {}
@@ -4907,6 +5217,7 @@ var AREA_CHANGE_DEBOUNCE_MS = 100;
4907
5217
  var DragDropContextClient = ({ children }) => {
4908
5218
  const { state, config, dispatch, resolveData } = useAppContext();
4909
5219
  const [preview, setPreview] = useState15(null);
5220
+ const previewRef = useRef5(null);
4910
5221
  const { data } = state;
4911
5222
  const [deepest, setDeepest] = useState15(null);
4912
5223
  const [nextDeepest, setNextDeepest] = useState15(null);
@@ -4958,7 +5269,7 @@ var DragDropContextClient = ({ children }) => {
4958
5269
  activationConstraints(event, source) {
4959
5270
  var _a;
4960
5271
  const { pointerType, target } = event;
4961
- if (pointerType === "mouse" && isElement(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
5272
+ if (pointerType === "mouse" && isElement2(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
4962
5273
  return void 0;
4963
5274
  }
4964
5275
  const delay = { value: 200, tolerance: 10 };
@@ -5023,21 +5334,20 @@ var DragDropContextClient = ({ children }) => {
5023
5334
  var _a, _b;
5024
5335
  setDraggedItem(null);
5025
5336
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
5026
- if (preview) {
5027
- setPreview(null);
5028
- }
5337
+ setPreview(null);
5338
+ previewRef.current = null;
5029
5339
  (_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
5030
5340
  fn(event, manager);
5031
5341
  });
5032
5342
  return;
5033
5343
  }
5034
- if (preview) {
5344
+ if (previewRef.current) {
5035
5345
  setPreview(null);
5036
- if (preview.type === "insert") {
5346
+ if (previewRef.current.type === "insert") {
5037
5347
  insertComponent(
5038
- preview.componentType,
5039
- preview.zone,
5040
- preview.index,
5348
+ previewRef.current.componentType,
5349
+ previewRef.current.zone,
5350
+ previewRef.current.index,
5041
5351
  { config, dispatch, resolveData, state }
5042
5352
  );
5043
5353
  } else if (initialSelector.current) {
@@ -5045,11 +5355,12 @@ var DragDropContextClient = ({ children }) => {
5045
5355
  type: "move",
5046
5356
  sourceIndex: initialSelector.current.index,
5047
5357
  sourceZone: initialSelector.current.zone,
5048
- destinationIndex: preview.index,
5049
- destinationZone: preview.zone,
5358
+ destinationIndex: previewRef.current.index,
5359
+ destinationZone: previewRef.current.zone,
5050
5360
  recordHistory: false
5051
5361
  });
5052
5362
  }
5363
+ previewRef.current = null;
5053
5364
  }
5054
5365
  dispatch({
5055
5366
  type: "setUi",
@@ -5100,7 +5411,7 @@ var DragDropContextClient = ({ children }) => {
5100
5411
  return;
5101
5412
  }
5102
5413
  if (dragMode.current === "new") {
5103
- setPreview({
5414
+ previewRef.current = {
5104
5415
  componentType: sourceData.componentType,
5105
5416
  type: "insert",
5106
5417
  index: targetIndex,
@@ -5108,7 +5419,8 @@ var DragDropContextClient = ({ children }) => {
5108
5419
  props: {
5109
5420
  id: source.id.toString()
5110
5421
  }
5111
- });
5422
+ };
5423
+ setPreview(previewRef.current);
5112
5424
  } else {
5113
5425
  if (!initialSelector.current) {
5114
5426
  initialSelector.current = {
@@ -5118,13 +5430,14 @@ var DragDropContextClient = ({ children }) => {
5118
5430
  }
5119
5431
  const item = getItem(initialSelector.current, data);
5120
5432
  if (item) {
5121
- setPreview({
5433
+ previewRef.current = {
5122
5434
  componentType: sourceData.componentType,
5123
5435
  type: "move",
5124
5436
  index: targetIndex,
5125
5437
  zone: targetZone,
5126
5438
  props: item.props
5127
- });
5439
+ };
5440
+ setPreview(previewRef.current);
5128
5441
  }
5129
5442
  }
5130
5443
  (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
@@ -6919,7 +7232,7 @@ var ViewportControls = ({
6919
7232
 
6920
7233
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
6921
7234
  init_react_import();
6922
- var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_cf3je_1", "PuckCanvas-controls": "_PuckCanvas-controls_cf3je_16", "PuckCanvas-inner": "_PuckCanvas-inner_cf3je_21", "PuckCanvas-root": "_PuckCanvas-root_cf3je_32", "PuckCanvas--ready": "_PuckCanvas--ready_cf3je_57", "PuckCanvas-loader": "_PuckCanvas-loader_cf3je_62", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_cf3je_72" };
7235
+ 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" };
6923
7236
 
6924
7237
  // lib/get-zoom-config.ts
6925
7238
  init_react_import();