@measured/puck 0.18.2-canary.de48691 → 0.18.2-canary.fc7fda2

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
@@ -159,7 +159,7 @@ var get_class_name_factory_default = getClassNameFactory;
159
159
 
160
160
  // css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
161
161
  init_react_import();
162
- var styles_module_default = { "ActionBar": "_ActionBar_rvadt_1", "ActionBar-label": "_ActionBar-label_rvadt_18", "ActionBar-action": "_ActionBar-action_rvadt_30", "ActionBar-group": "_ActionBar-group_rvadt_38" };
162
+ var styles_module_default = { "ActionBar": "_ActionBar_194sn_1", "ActionBar-label": "_ActionBar-label_194sn_18", "ActionBar-action": "_ActionBar-action_194sn_30", "ActionBar-group": "_ActionBar-group_194sn_38" };
163
163
 
164
164
  // components/ActionBar/index.tsx
165
165
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -205,7 +205,7 @@ init_react_import();
205
205
 
206
206
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
207
207
  init_react_import();
208
- var styles_module_default2 = { "InputWrapper": "_InputWrapper_g5w3n_1", "Input-label": "_Input-label_g5w3n_5", "Input-labelIcon": "_Input-labelIcon_g5w3n_14", "Input-disabledIcon": "_Input-disabledIcon_g5w3n_21", "Input-input": "_Input-input_g5w3n_26", "Input": "_Input_g5w3n_1", "Input--readOnly": "_Input--readOnly_g5w3n_74", "Input-radioGroupItems": "_Input-radioGroupItems_g5w3n_85", "Input-radio": "_Input-radio_g5w3n_85", "Input-radioInner": "_Input-radioInner_g5w3n_102", "Input-radioInput": "_Input-radioInput_g5w3n_147" };
208
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
209
209
 
210
210
  // components/AutoField/index.tsx
211
211
  import {
@@ -213,7 +213,7 @@ import {
213
213
  useContext as useContext3,
214
214
  useEffect as useEffect9,
215
215
  useMemo as useMemo5,
216
- useState as useState12
216
+ useState as useState11
217
217
  } from "react";
218
218
 
219
219
  // components/AutoField/fields/index.tsx
@@ -224,7 +224,7 @@ init_react_import();
224
224
 
225
225
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/fields/ArrayField/styles.module.css#css-module
226
226
  init_react_import();
227
- var styles_module_default3 = { "ArrayField": "_ArrayField_14u8o_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_14u8o_13", "ArrayField-addButton": "_ArrayField-addButton_14u8o_18", "ArrayField--hasItems": "_ArrayField--hasItems_14u8o_33", "ArrayField-inner": "_ArrayField-inner_14u8o_59", "ArrayFieldItem": "_ArrayFieldItem_14u8o_67", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_14u8o_78", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_14u8o_82", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_14u8o_97", "ArrayField--addDisabled": "_ArrayField--addDisabled_14u8o_127", "ArrayFieldItem-body": "_ArrayFieldItem-body_14u8o_166", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_14u8o_175", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_14u8o_183", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_14u8o_189" };
227
+ var styles_module_default3 = { "ArrayField": "_ArrayField_1jcbq_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_1jcbq_13", "ArrayField-addButton": "_ArrayField-addButton_1jcbq_18", "ArrayField--hasItems": "_ArrayField--hasItems_1jcbq_33", "ArrayFieldItem": "_ArrayFieldItem_1jcbq_63", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_1jcbq_71", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_1jcbq_81", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_1jcbq_97", "ArrayField--addDisabled": "_ArrayField--addDisabled_1jcbq_128", "ArrayFieldItem-body": "_ArrayFieldItem-body_1jcbq_164", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_1jcbq_173", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_1jcbq_181", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_1jcbq_187" };
228
228
 
229
229
  // ../../node_modules/lucide-react/dist/esm/lucide-react.js
230
230
  init_react_import();
@@ -674,7 +674,7 @@ var IconButton = ({
674
674
  };
675
675
 
676
676
  // components/AutoField/fields/ArrayField/index.tsx
677
- import { useCallback as useCallback3, useEffect as useEffect4, useState as useState7 } from "react";
677
+ import { useCallback as useCallback3, useEffect as useEffect4, useState as useState6 } from "react";
678
678
 
679
679
  // components/DragIcon/index.tsx
680
680
  init_react_import();
@@ -1084,7 +1084,7 @@ function useAppContext() {
1084
1084
  // components/Sortable/index.tsx
1085
1085
  init_react_import();
1086
1086
  import { DragDropProvider } from "@dnd-kit/react";
1087
- import { useState as useState6 } from "react";
1087
+ import { useState as useState5 } from "react";
1088
1088
 
1089
1089
  // lib/dnd/dnd-kit/safe.ts
1090
1090
  init_react_import();
@@ -1115,763 +1115,98 @@ function useSortableSafe(input) {
1115
1115
  return useSortable(input);
1116
1116
  }
1117
1117
 
1118
- // lib/dnd/use-sensors.ts
1119
- init_react_import();
1120
- import { useState as useState5 } from "react";
1121
-
1122
- // lib/dnd/PointerSensor.ts
1123
- init_react_import();
1124
- import { batch, effect } from "@dnd-kit/state";
1125
- import { Sensor, configurator } from "@dnd-kit/abstract";
1126
- import {
1127
- exceedsDistance
1128
- } from "@dnd-kit/geometry";
1129
- import {
1130
- getDocument,
1131
- isElement,
1132
- isHTMLElement,
1133
- isPointerEvent,
1134
- Listeners,
1135
- getFrameTransform
1136
- } from "@dnd-kit/dom/utilities";
1137
- var _clearTimeout;
1138
- var _PointerSensor = class _PointerSensor extends Sensor {
1139
- constructor(manager, options) {
1140
- super(manager);
1141
- this.manager = manager;
1142
- this.options = options;
1143
- this.listeners = new Listeners();
1144
- this.cleanup = /* @__PURE__ */ new Set();
1145
- this.source = void 0;
1146
- __privateAdd(this, _clearTimeout);
1147
- this.handleCancel = this.handleCancel.bind(this);
1148
- this.handlePointerUp = this.handlePointerUp.bind(this);
1149
- this.handleKeyDown = this.handleKeyDown.bind(this);
1150
- effect(() => {
1151
- const unbindGlobal = this.bindGlobal(options != null ? options : {});
1152
- return () => {
1153
- unbindGlobal();
1154
- };
1155
- });
1156
- }
1157
- bind(source, options = this.options) {
1158
- const unbind = effect(() => {
1159
- var _a;
1160
- const target = (_a = source.handle) != null ? _a : source.element;
1161
- const listener = (event) => {
1162
- if (isPointerEvent(event)) {
1163
- this.handlePointerDown(event, source, options);
1164
- }
1165
- };
1166
- if (target) {
1167
- patchWindow(target.ownerDocument.defaultView);
1168
- target.addEventListener("pointerdown", listener);
1169
- return () => {
1170
- target.removeEventListener("pointerdown", listener);
1171
- };
1172
- }
1173
- });
1174
- return unbind;
1175
- }
1176
- bindGlobal(options) {
1177
- const documents = /* @__PURE__ */ new Set();
1178
- for (const draggable of this.manager.registry.draggables.value) {
1179
- if (draggable.element) {
1180
- documents.add(getDocument(draggable.element));
1181
- }
1182
- }
1183
- for (const droppable of this.manager.registry.droppables.value) {
1184
- if (droppable.element) {
1185
- documents.add(getDocument(droppable.element));
1186
- }
1187
- }
1188
- const unbindFns = Array.from(documents).map(
1189
- (doc) => this.listeners.bind(doc, [
1190
- {
1191
- type: "pointermove",
1192
- listener: (event) => this.handlePointerMove(event, doc, options)
1193
- },
1194
- {
1195
- type: "pointerup",
1196
- listener: this.handlePointerUp,
1197
- options: {
1198
- capture: true
1118
+ // components/Sortable/index.tsx
1119
+ import { jsx as jsx6 } from "react/jsx-runtime";
1120
+ var SortableProvider = ({
1121
+ children,
1122
+ onMove
1123
+ }) => {
1124
+ const [move, setMove] = useState5({ source: -1, target: -1 });
1125
+ return /* @__PURE__ */ jsx6(
1126
+ DragDropProvider,
1127
+ {
1128
+ onDragOver: (event) => {
1129
+ const { operation } = event;
1130
+ if (operation.source && operation.target) {
1131
+ const newMove = {
1132
+ source: operation.source.data.index,
1133
+ target: operation.target.data.index
1134
+ };
1135
+ if (newMove.source !== newMove.target) {
1136
+ setMove({
1137
+ source: operation.source.data.index,
1138
+ target: operation.target.data.index
1139
+ });
1199
1140
  }
1200
- },
1201
- {
1202
- // Cancel activation if there is a competing Drag and Drop interaction
1203
- type: "dragstart",
1204
- listener: this.handleDragStart
1205
1141
  }
1206
- ])
1207
- );
1208
- return () => {
1209
- unbindFns.forEach((unbind) => unbind());
1210
- };
1211
- }
1212
- handlePointerDown(event, source, options = {}) {
1213
- if (this.disabled || !event.isPrimary || event.button !== 0 || !isElement(event.target) || source.disabled) {
1214
- return;
1142
+ },
1143
+ onDragEnd: () => {
1144
+ if (move.source !== -1 && move.target !== -1) {
1145
+ onMove(move);
1146
+ }
1147
+ },
1148
+ children
1215
1149
  }
1216
- const offset = getFrameTransform(source.element);
1217
- this.initialCoordinates = {
1218
- x: event.clientX * offset.scaleX + offset.x,
1219
- y: event.clientY * offset.scaleY + offset.y
1220
- };
1221
- this.source = source;
1222
- const { activationConstraints } = options;
1223
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
1224
- event.stopImmediatePropagation();
1225
- if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
1226
- this.handleStart(source, event);
1227
- } else {
1228
- const { delay } = constraints;
1229
- if (delay) {
1230
- const timeout3 = setTimeout(
1231
- () => this.handleStart(source, event),
1232
- delay.value
1150
+ );
1151
+ };
1152
+ var Sortable = ({
1153
+ id,
1154
+ index,
1155
+ disabled,
1156
+ children,
1157
+ type = "item"
1158
+ }) => {
1159
+ const { ref: sortableRef, status } = useSortableSafe({
1160
+ id,
1161
+ type,
1162
+ index,
1163
+ disabled,
1164
+ data: { index }
1165
+ });
1166
+ return children({ status, ref: sortableRef });
1167
+ };
1168
+
1169
+ // components/AutoField/context.tsx
1170
+ init_react_import();
1171
+ import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
1172
+ import { jsx as jsx7 } from "react/jsx-runtime";
1173
+ var NestedFieldContext = createContext2({});
1174
+ var useNestedFieldContext = () => {
1175
+ const context = useContext2(NestedFieldContext);
1176
+ return __spreadProps(__spreadValues({}, context), {
1177
+ readOnlyFields: context.readOnlyFields || {}
1178
+ });
1179
+ };
1180
+ var NestedFieldProvider = ({
1181
+ children,
1182
+ name,
1183
+ subName,
1184
+ wildcardName = name,
1185
+ readOnlyFields
1186
+ }) => {
1187
+ const subPath = `${name}.${subName}`;
1188
+ const wildcardSubPath = `${wildcardName}.${subName}`;
1189
+ const subReadOnlyFields = useMemo(
1190
+ () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
1191
+ const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
1192
+ if (isLocal) {
1193
+ const subPathPattern = new RegExp(
1194
+ `^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
1233
1195
  );
1234
- __privateSet(this, _clearTimeout, () => {
1235
- clearTimeout(timeout3);
1236
- __privateSet(this, _clearTimeout, void 0);
1196
+ const localName = readOnlyKey.replace(subPathPattern, "");
1197
+ return __spreadProps(__spreadValues({}, acc), {
1198
+ [localName]: readOnlyFields[readOnlyKey]
1237
1199
  });
1238
1200
  }
1239
- }
1240
- const cleanup = () => {
1241
- var _a;
1242
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
1243
- this.initialCoordinates = void 0;
1244
- this.source = void 0;
1245
- };
1246
- this.cleanup.add(cleanup);
1247
- }
1248
- handlePointerMove(event, doc, options) {
1249
- if (!this.source) {
1250
- return;
1251
- }
1252
- const ownerDocument = this.source.element && getDocument(this.source.element);
1253
- if (doc !== ownerDocument) {
1254
- return;
1255
- }
1256
- const coordinates = {
1257
- x: event.clientX,
1258
- y: event.clientY
1259
- };
1260
- const offset = getFrameTransform(this.source.element);
1261
- coordinates.x = coordinates.x * offset.scaleX + offset.x;
1262
- coordinates.y = coordinates.y * offset.scaleY + offset.y;
1263
- if (this.manager.dragOperation.status.dragging) {
1264
- event.preventDefault();
1265
- event.stopPropagation();
1266
- this.manager.actions.move({ to: coordinates });
1267
- return;
1268
- }
1269
- if (!this.initialCoordinates) {
1270
- return;
1271
- }
1272
- const delta = {
1273
- x: coordinates.x - this.initialCoordinates.x,
1274
- y: coordinates.y - this.initialCoordinates.y
1275
- };
1276
- const { activationConstraints } = options;
1277
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
1278
- const { distance, delay } = constraints != null ? constraints : {};
1279
- if (distance) {
1280
- if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
1281
- return this.handleCancel();
1282
- }
1283
- if (exceedsDistance(delta, distance.value)) {
1284
- return this.handleStart(this.source, event);
1285
- }
1286
- }
1287
- if (delay) {
1288
- if (exceedsDistance(delta, delay.tolerance)) {
1289
- return this.handleCancel();
1290
- }
1291
- }
1292
- }
1293
- handlePointerUp(event) {
1294
- if (!this.source) {
1295
- return;
1296
- }
1297
- event.preventDefault();
1298
- event.stopPropagation();
1299
- const { status } = this.manager.dragOperation;
1300
- if (!status.idle) {
1301
- const canceled = !status.initialized;
1302
- this.manager.actions.stop({ canceled });
1303
- }
1304
- this.cleanup.forEach((cleanup) => cleanup());
1305
- this.cleanup.clear();
1306
- }
1307
- handleKeyDown(event) {
1308
- if (event.key === "Escape") {
1309
- event.preventDefault();
1310
- this.handleCancel();
1311
- }
1312
- }
1313
- handleStart(source, event) {
1314
- var _a;
1315
- const { manager, initialCoordinates } = this;
1316
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
1317
- if (!initialCoordinates || manager.dragOperation.status.initialized) {
1318
- return;
1319
- }
1320
- if (event.defaultPrevented) {
1321
- return;
1322
- }
1323
- event.preventDefault();
1324
- batch(() => {
1325
- manager.actions.setDragSource(source.id);
1326
- manager.actions.start({ coordinates: initialCoordinates, event });
1327
- });
1328
- const ownerDocument = getDocument(event.target);
1329
- const unbind = this.listeners.bind(ownerDocument, [
1330
- {
1331
- // Prevent scrolling on touch devices
1332
- type: "touchmove",
1333
- listener: preventDefault,
1334
- options: {
1335
- passive: false
1336
- }
1337
- },
1338
- {
1339
- // Prevent click events
1340
- type: "click",
1341
- listener: preventDefault
1342
- },
1343
- {
1344
- type: "keydown",
1345
- listener: this.handleKeyDown
1346
- }
1347
- ]);
1348
- ownerDocument.body.setPointerCapture(event.pointerId);
1349
- this.cleanup.add(unbind);
1350
- }
1351
- handleDragStart(event) {
1352
- const { target } = event;
1353
- if (!isElement(target)) {
1354
- return;
1355
- }
1356
- const isNativeDraggable = isHTMLElement(target) && target.draggable && target.getAttribute("draggable") === "true";
1357
- if (isNativeDraggable) {
1358
- this.handleCancel();
1359
- } else {
1360
- preventDefault(event);
1361
- }
1362
- }
1363
- handleCancel() {
1364
- const { dragOperation } = this.manager;
1365
- if (dragOperation.status.initialized) {
1366
- this.manager.actions.stop({ canceled: true });
1367
- }
1368
- this.cleanup.forEach((cleanup) => cleanup());
1369
- this.cleanup.clear();
1370
- }
1371
- destroy() {
1372
- this.listeners.clear();
1373
- }
1374
- };
1375
- _clearTimeout = new WeakMap();
1376
- _PointerSensor.configure = configurator(_PointerSensor);
1377
- var PointerSensor = _PointerSensor;
1378
- function preventDefault(event) {
1379
- event.preventDefault();
1380
- }
1381
- function noop() {
1382
- }
1383
- var windows = /* @__PURE__ */ new WeakSet();
1384
- function patchWindow(window2) {
1385
- if (!window2 || windows.has(window2)) {
1386
- return;
1387
- }
1388
- window2.addEventListener("touchmove", noop, {
1389
- capture: false,
1390
- passive: false
1391
- });
1392
- windows.add(window2);
1393
- }
1394
-
1395
- // lib/dnd/use-sensors.ts
1396
- import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
1397
- var useSensors = () => {
1398
- const [sensors] = useState5(() => [
1399
- PointerSensor.configure({
1400
- activationConstraints(event, source) {
1401
- var _a;
1402
- const { pointerType, target } = event;
1403
- if (pointerType === "mouse" && isElement2(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
1404
- return void 0;
1405
- }
1406
- const delay = { value: 200, tolerance: 10 };
1407
- if (pointerType === "touch") {
1408
- return { delay };
1409
- }
1410
- return {
1411
- delay,
1412
- distance: { value: 5 }
1413
- };
1414
- }
1415
- })
1416
- ]);
1417
- return sensors;
1418
- };
1419
-
1420
- // lib/dnd/collision/dynamic/index.ts
1421
- init_react_import();
1422
- import {
1423
- CollisionPriority as CollisionPriority7,
1424
- CollisionType as CollisionType7
1425
- } from "@dnd-kit/abstract";
1426
-
1427
- // lib/dnd/collision/directional/index.ts
1428
- init_react_import();
1429
- import { CollisionType } from "@dnd-kit/abstract";
1430
-
1431
- // lib/dnd/collision/collision-debug.ts
1432
- init_react_import();
1433
- var DEBUG = false;
1434
- var debugElements = {};
1435
- var timeout;
1436
- var collisionDebug = (a, b, id, color, label) => {
1437
- if (!DEBUG) return;
1438
- const debugId = `${id}-debug`;
1439
- clearTimeout(timeout);
1440
- timeout = setTimeout(() => {
1441
- Object.entries(debugElements).forEach(([id2, { svg }]) => {
1442
- svg.remove();
1443
- delete debugElements[id2];
1444
- });
1445
- }, 1e3);
1446
- requestAnimationFrame(() => {
1447
- var _a, _b;
1448
- const existingEl = debugElements[debugId];
1449
- let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
1450
- let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
1451
- if (!existingEl) {
1452
- const svgNs = "http://www.w3.org/2000/svg";
1453
- const svg = document.createElementNS(svgNs, "svg");
1454
- line = document.createElementNS(svgNs, "line");
1455
- text = document.createElementNS(svgNs, "text");
1456
- svg.setAttribute("id", debugId);
1457
- svg.setAttribute(
1458
- "style",
1459
- "position: fixed; height: 100%; width: 100%; pointer-events: none;"
1460
- );
1461
- svg.appendChild(line);
1462
- svg.appendChild(text);
1463
- text.setAttribute("fill", `black`);
1464
- document.body.appendChild(svg);
1465
- debugElements[debugId] = { svg, line, text };
1466
- }
1467
- line.setAttribute("x1", a.x.toString());
1468
- line.setAttribute("x2", b.x.toString());
1469
- line.setAttribute("y1", a.y.toString());
1470
- line.setAttribute("y2", b.y.toString());
1471
- line.setAttribute("style", `stroke:${color};stroke-width:2`);
1472
- text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
1473
- text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
1474
- if (label) {
1475
- text.innerHTML = label;
1476
- }
1477
- });
1478
- };
1479
-
1480
- // lib/dnd/collision/directional/index.ts
1481
- var distanceChange = "increasing";
1482
- var directionalCollision = (input, previous) => {
1483
- var _a;
1484
- const { dragOperation, droppable } = input;
1485
- const { shape: dropShape } = droppable;
1486
- const { position } = dragOperation;
1487
- const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
1488
- if (!dragShape || !dropShape) return null;
1489
- const dropCenter = dropShape.center;
1490
- const distanceToPrevious = Math.sqrt(
1491
- Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
1492
- );
1493
- const distanceToCurrent = Math.sqrt(
1494
- Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
1495
- );
1496
- distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
1497
- collisionDebug(
1498
- dragShape.center,
1499
- dropCenter,
1500
- droppable.id.toString(),
1501
- "rebeccapurple"
1502
- );
1503
- if (distanceChange === "decreasing") {
1504
- return {
1505
- id: droppable.id,
1506
- value: 1,
1507
- type: CollisionType.Collision
1508
- };
1509
- }
1510
- return null;
1511
- };
1512
-
1513
- // lib/dnd/collision/dynamic/get-direction.ts
1514
- init_react_import();
1515
- var getDirection = (dragAxis, delta) => {
1516
- if (dragAxis === "dynamic") {
1517
- if (Math.abs(delta.y) > Math.abs(delta.x)) {
1518
- return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
1519
- } else {
1520
- return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
1521
- }
1522
- } else if (dragAxis === "x") {
1523
- return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
1524
- }
1525
- return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
1526
- };
1527
-
1528
- // lib/dnd/collision/dynamic/get-midpoint-impact.ts
1529
- init_react_import();
1530
- var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
1531
- const dragRect = dragShape.boundingRectangle;
1532
- const dropCenter = dropShape.center;
1533
- if (direction === "down") {
1534
- const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
1535
- return dragRect.bottom >= dropCenter.y + offset2;
1536
- } else if (direction === "up") {
1537
- const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
1538
- return dragRect.top < dropCenter.y - offset2;
1539
- } else if (direction === "left") {
1540
- const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
1541
- return dropCenter.x - offset2 >= dragRect.left;
1542
- }
1543
- const offset = offsetMultiplier * dropShape.boundingRectangle.width;
1544
- return dragRect.right - offset >= dropCenter.x;
1545
- };
1546
-
1547
- // lib/dnd/collision/dynamic/track-movement-interval.ts
1548
- init_react_import();
1549
- import { Point } from "@dnd-kit/geometry";
1550
- var INTERVAL_SENSITIVITY = 10;
1551
- var intervalCache = {
1552
- current: { x: 0, y: 0 },
1553
- delta: { x: 0, y: 0 },
1554
- previous: { x: 0, y: 0 },
1555
- direction: null
1556
- };
1557
- var trackMovementInterval = (point, dragAxis = "dynamic") => {
1558
- intervalCache.current = point;
1559
- intervalCache.delta = {
1560
- x: point.x - intervalCache.previous.x,
1561
- y: point.y - intervalCache.previous.y
1562
- };
1563
- intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
1564
- if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
1565
- intervalCache.previous = Point.from(point);
1566
- }
1567
- return intervalCache;
1568
- };
1569
-
1570
- // ../../node_modules/@dnd-kit/collision/dist/index.js
1571
- init_react_import();
1572
- import { CollisionPriority, CollisionType as CollisionType2 } from "@dnd-kit/abstract";
1573
- import { Point as Point2 } from "@dnd-kit/geometry";
1574
- import { CollisionPriority as CollisionPriority2, CollisionType as CollisionType22 } from "@dnd-kit/abstract";
1575
- import { Point as Point22 } from "@dnd-kit/geometry";
1576
- import { CollisionPriority as CollisionPriority3, CollisionType as CollisionType3 } from "@dnd-kit/abstract";
1577
- import { Point as Point3 } from "@dnd-kit/geometry";
1578
- import { CollisionPriority as CollisionPriority4, CollisionType as CollisionType4 } from "@dnd-kit/abstract";
1579
- import { Point as Point4 } from "@dnd-kit/geometry";
1580
- import { CollisionPriority as CollisionPriority5, CollisionType as CollisionType5 } from "@dnd-kit/abstract";
1581
- import { Point as Point5 } from "@dnd-kit/geometry";
1582
- import { CollisionPriority as CollisionPriority6, CollisionType as CollisionType6 } from "@dnd-kit/abstract";
1583
- import { Point as Point6 } from "@dnd-kit/geometry";
1584
- var pointerIntersection = ({
1585
- dragOperation,
1586
- droppable
1587
- }) => {
1588
- const pointerCoordinates = dragOperation.position.current;
1589
- if (!pointerCoordinates) {
1590
- return null;
1591
- }
1592
- const { id } = droppable;
1593
- if (!droppable.shape) {
1594
- return null;
1595
- }
1596
- if (droppable.shape.containsPoint(pointerCoordinates)) {
1597
- const distance = Point2.distance(droppable.shape.center, pointerCoordinates);
1598
- return {
1599
- id,
1600
- value: 1 / distance,
1601
- type: CollisionType2.PointerIntersection,
1602
- priority: CollisionPriority.High
1603
- };
1604
- }
1605
- return null;
1606
- };
1607
- var closestCorners = (input) => {
1608
- const { dragOperation, droppable } = input;
1609
- const { shape, position } = dragOperation;
1610
- if (!droppable.shape) {
1611
- return null;
1612
- }
1613
- const { left, top, right, bottom } = droppable.shape.boundingRectangle;
1614
- const corners = [
1615
- {
1616
- x: left,
1617
- y: top
1618
- },
1619
- {
1620
- x: right,
1621
- y: top
1622
- },
1623
- {
1624
- x: left,
1625
- y: bottom
1626
- },
1627
- {
1628
- x: right,
1629
- y: bottom
1630
- }
1631
- ];
1632
- const distance = corners.reduce(
1633
- (acc, corner) => {
1634
- var _a;
1635
- return acc + Point3.distance(
1636
- Point3.from(corner),
1637
- (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
1638
- );
1639
- },
1640
- 0
1641
- );
1642
- const value = distance / 4;
1643
- return {
1644
- id: droppable.id,
1645
- value: 1 / value,
1646
- type: CollisionType3.Collision,
1647
- priority: CollisionPriority3.Normal
1648
- };
1649
- };
1650
-
1651
- // lib/dnd/collision/dynamic/store.ts
1652
- init_react_import();
1653
- import { createStore } from "zustand/vanilla";
1654
- var collisionStore = createStore(() => ({
1655
- fallbackEnabled: false
1656
- }));
1657
-
1658
- // lib/dnd/collision/dynamic/index.ts
1659
- var flushNext = "";
1660
- var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
1661
- var _a, _b, _c, _d, _e;
1662
- const { dragOperation, droppable } = input;
1663
- const { position } = dragOperation;
1664
- const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
1665
- const { shape: dropShape } = droppable;
1666
- if (!dragShape || !dropShape) {
1667
- return null;
1668
- }
1669
- const { center: dragCenter } = dragShape;
1670
- const { fallbackEnabled } = collisionStore.getState();
1671
- const interval = trackMovementInterval(position.current, dragAxis);
1672
- dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
1673
- direction: interval.direction
1674
- });
1675
- const collisionMap = dragOperation.data.collisionMap || {};
1676
- dragOperation.data.collisionMap = collisionMap;
1677
- collisionMap[droppable.id] = {
1678
- direction: interval.direction
1679
- };
1680
- const { center: dropCenter } = dropShape;
1681
- const overMidpoint = getMidpointImpact(
1682
- dragShape,
1683
- dropShape,
1684
- interval.direction,
1685
- midpointOffset
1686
- );
1687
- if (((_b = dragOperation.source) == null ? void 0 : _b.id) === droppable.id) {
1688
- const collision = directionalCollision(input, interval.previous);
1689
- collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
1690
- if (collision) {
1691
- return __spreadProps(__spreadValues({}, collision), {
1692
- priority: CollisionPriority7.Highest
1693
- });
1694
- }
1695
- }
1696
- const intersectionArea = dragShape.intersectionArea(dropShape);
1697
- const intersectionRatio = intersectionArea / dropShape.area;
1698
- if (intersectionArea && overMidpoint) {
1699
- collisionDebug(
1700
- dragCenter,
1701
- dropCenter,
1702
- droppable.id.toString(),
1703
- "green",
1704
- interval.direction
1705
- );
1706
- const collision = {
1707
- id: droppable.id,
1708
- value: intersectionRatio,
1709
- priority: CollisionPriority7.High,
1710
- type: CollisionType7.Collision
1711
- };
1712
- const shouldFlushId = flushNext === droppable.id;
1713
- flushNext = "";
1714
- return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
1715
- }
1716
- if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
1717
- const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
1718
- const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
1719
- if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
1720
- const fallbackCollision = closestCorners(input);
1721
- if (fallbackCollision) {
1722
- const direction = getDirection(dragAxis, {
1723
- x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
1724
- y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
1725
- });
1726
- collisionMap[droppable.id] = {
1727
- direction
1728
- };
1729
- if (intersectionArea) {
1730
- collisionDebug(
1731
- dragCenter,
1732
- dropCenter,
1733
- droppable.id.toString(),
1734
- "red",
1735
- direction || ""
1736
- );
1737
- flushNext = droppable.id;
1738
- return __spreadProps(__spreadValues({}, fallbackCollision), {
1739
- priority: CollisionPriority7.Low
1740
- });
1741
- }
1742
- collisionDebug(
1743
- dragCenter,
1744
- dropCenter,
1745
- droppable.id.toString(),
1746
- "orange",
1747
- direction || ""
1748
- );
1749
- return __spreadProps(__spreadValues({}, fallbackCollision), { priority: CollisionPriority7.Lowest });
1750
- }
1751
- }
1752
- }
1753
- collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
1754
- delete collisionMap[droppable.id];
1755
- return null;
1756
- };
1757
-
1758
- // components/Sortable/index.tsx
1759
- import { RestrictToElement } from "@dnd-kit/dom/modifiers";
1760
- import { jsx as jsx6 } from "react/jsx-runtime";
1761
- var SortableProvider = ({
1762
- children,
1763
- onDragStart,
1764
- onDragEnd,
1765
- onMove
1766
- }) => {
1767
- const [move, setMove] = useState6({ source: -1, target: -1 });
1768
- const sensors = useSensors();
1769
- return /* @__PURE__ */ jsx6(
1770
- DragDropProvider,
1771
- {
1772
- sensors,
1773
- modifiers: [
1774
- RestrictToElement.configure({
1775
- element() {
1776
- return document.querySelector("[data-dnd-container]");
1777
- }
1778
- })
1779
- ],
1780
- onDragStart,
1781
- onDragOver: (event, manager) => {
1782
- var _a, _b;
1783
- const { operation } = event;
1784
- const { source, target } = operation;
1785
- if (!source || !target) return;
1786
- let sourceIndex = source.data.index;
1787
- let targetIndex = target.data.index;
1788
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
1789
- if (sourceIndex !== targetIndex && source.id !== target.id) {
1790
- const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
1791
- if (targetIndex >= sourceIndex) {
1792
- targetIndex = targetIndex - 1;
1793
- }
1794
- if (collisionPosition === "after") {
1795
- targetIndex = targetIndex + 1;
1796
- }
1797
- setMove({
1798
- source: sourceIndex,
1799
- target: targetIndex
1800
- });
1801
- }
1802
- },
1803
- onDragEnd: () => {
1804
- setTimeout(() => {
1805
- if (move.source !== -1 && move.target !== -1) {
1806
- onMove(move);
1807
- }
1808
- onDragEnd();
1809
- }, 250);
1810
- setMove({ source: -1, target: -1 });
1811
- },
1812
- children
1813
- }
1814
- );
1815
- };
1816
- var Sortable = ({
1817
- id,
1818
- index,
1819
- disabled,
1820
- children,
1821
- type = "item"
1822
- }) => {
1823
- const { ref: sortableRef, status } = useSortableSafe({
1824
- id,
1825
- type,
1826
- index,
1827
- disabled,
1828
- data: { index },
1829
- collisionDetector: createDynamicCollisionDetector("y")
1830
- });
1831
- return children({ status, ref: sortableRef });
1832
- };
1833
-
1834
- // components/AutoField/context.tsx
1835
- init_react_import();
1836
- import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
1837
- import { jsx as jsx7 } from "react/jsx-runtime";
1838
- var NestedFieldContext = createContext2({});
1839
- var useNestedFieldContext = () => {
1840
- const context = useContext2(NestedFieldContext);
1841
- return __spreadProps(__spreadValues({}, context), {
1842
- readOnlyFields: context.readOnlyFields || {}
1843
- });
1844
- };
1845
- var NestedFieldProvider = ({
1846
- children,
1847
- name,
1848
- subName,
1849
- wildcardName = name,
1850
- readOnlyFields
1851
- }) => {
1852
- const subPath = `${name}.${subName}`;
1853
- const wildcardSubPath = `${wildcardName}.${subName}`;
1854
- const subReadOnlyFields = useMemo(
1855
- () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
1856
- const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
1857
- if (isLocal) {
1858
- const subPathPattern = new RegExp(
1859
- `^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
1860
- );
1861
- const localName = readOnlyKey.replace(subPathPattern, "");
1862
- return __spreadProps(__spreadValues({}, acc), {
1863
- [localName]: readOnlyFields[readOnlyKey]
1864
- });
1865
- }
1866
- return acc;
1867
- }, {}),
1868
- [name, subName, wildcardName, readOnlyFields]
1869
- );
1870
- return /* @__PURE__ */ jsx7(
1871
- NestedFieldContext.Provider,
1872
- {
1873
- value: { readOnlyFields: subReadOnlyFields, localName: subName },
1874
- children
1201
+ return acc;
1202
+ }, {}),
1203
+ [name, subName, wildcardName, readOnlyFields]
1204
+ );
1205
+ return /* @__PURE__ */ jsx7(
1206
+ NestedFieldContext.Provider,
1207
+ {
1208
+ value: { readOnlyFields: subReadOnlyFields, localName: subName },
1209
+ children
1875
1210
  }
1876
1211
  );
1877
1212
  };
@@ -1902,7 +1237,7 @@ var ArrayField = ({
1902
1237
  }),
1903
1238
  openId: ""
1904
1239
  };
1905
- const [localState, setLocalState] = useState7({ arrayState, value });
1240
+ const [localState, setLocalState] = useState6({ arrayState, value });
1906
1241
  useEffect4(() => {
1907
1242
  setLocalState({ arrayState, value });
1908
1243
  }, [value, state.ui.arrayState[id]]);
@@ -1946,7 +1281,6 @@ var ArrayField = ({
1946
1281
  setUi(mapArrayStateToUi(arrayState));
1947
1282
  }
1948
1283
  }, []);
1949
- const [isDragging, setIsDragging] = useState7(false);
1950
1284
  const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
1951
1285
  if (field.type !== "array" || !field.arrayFields) {
1952
1286
  return null;
@@ -1962,8 +1296,6 @@ var ArrayField = ({
1962
1296
  children: /* @__PURE__ */ jsx8(
1963
1297
  SortableProvider,
1964
1298
  {
1965
- onDragStart: () => setIsDragging(true),
1966
- onDragEnd: () => setIsDragging(false),
1967
1299
  onMove: (move) => {
1968
1300
  const newValue = reorder(value, move.source, move.target);
1969
1301
  const newArrayStateItems = reorder(
@@ -1994,7 +1326,7 @@ var ArrayField = ({
1994
1326
  e.preventDefault();
1995
1327
  },
1996
1328
  children: [
1997
- /* @__PURE__ */ jsx8("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
1329
+ localState.arrayState.items.map((item, i) => {
1998
1330
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
1999
1331
  const data = Array.from(localState.value || [])[i] || {};
2000
1332
  return /* @__PURE__ */ jsx8(
@@ -2017,7 +1349,6 @@ var ArrayField = ({
2017
1349
  "div",
2018
1350
  {
2019
1351
  onClick: (e) => {
2020
- if (isDragging) return;
2021
1352
  e.preventDefault();
2022
1353
  e.stopPropagation();
2023
1354
  if (arrayState.openId === _arrayId) {
@@ -2047,11 +1378,7 @@ var ArrayField = ({
2047
1378
  onClick: (e) => {
2048
1379
  e.stopPropagation();
2049
1380
  const existingValue = [...value || []];
2050
- existingValue.splice(
2051
- i,
2052
- 0,
2053
- existingValue[i]
2054
- );
1381
+ existingValue.splice(i, 0, existingValue[i]);
2055
1382
  onChange(
2056
1383
  existingValue,
2057
1384
  mapArrayStateToUi(
@@ -2093,72 +1420,62 @@ var ArrayField = ({
2093
1420
  ]
2094
1421
  }
2095
1422
  ),
2096
- /* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8(
2097
- "fieldset",
2098
- {
2099
- className: getClassNameItem("fieldset"),
2100
- onPointerDownCapture: (e) => {
2101
- e.stopPropagation();
2102
- },
2103
- children: Object.keys(field.arrayFields).map((subName) => {
2104
- const subField = field.arrayFields[subName];
2105
- const indexName = `${name}[${i}]`;
2106
- const subPath = `${indexName}.${subName}`;
2107
- const localIndexName = `${localName}[${i}]`;
2108
- const localWildcardName = `${localName}[*]`;
2109
- const localSubPath = `${localIndexName}.${subName}`;
2110
- const localWildcardSubPath = `${localWildcardName}.${subName}`;
2111
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
2112
- const label2 = subField.label || subName;
2113
- return /* @__PURE__ */ jsx8(
2114
- NestedFieldProvider,
1423
+ /* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
1424
+ const subField = field.arrayFields[subName];
1425
+ const indexName = `${name}[${i}]`;
1426
+ const subPath = `${indexName}.${subName}`;
1427
+ const localIndexName = `${localName}[${i}]`;
1428
+ const localWildcardName = `${localName}[*]`;
1429
+ const localSubPath = `${localIndexName}.${subName}`;
1430
+ const localWildcardSubPath = `${localWildcardName}.${subName}`;
1431
+ const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
1432
+ const label2 = subField.label || subName;
1433
+ return /* @__PURE__ */ jsx8(
1434
+ NestedFieldProvider,
1435
+ {
1436
+ name: localIndexName,
1437
+ wildcardName: localWildcardName,
1438
+ subName,
1439
+ readOnlyFields,
1440
+ children: /* @__PURE__ */ jsx8(
1441
+ AutoFieldPrivate,
2115
1442
  {
2116
- name: localIndexName,
2117
- wildcardName: localWildcardName,
2118
- subName,
2119
- readOnlyFields,
2120
- children: /* @__PURE__ */ jsx8(
2121
- AutoFieldPrivate,
2122
- {
2123
- name: subPath,
2124
- label: label2,
2125
- id: `${_arrayId}_${subName}`,
2126
- readOnly: subReadOnly,
2127
- field: __spreadProps(__spreadValues({}, subField), {
2128
- label: label2
2129
- // May be used by custom fields
2130
- }),
2131
- value: data[subName],
2132
- onChange: (val, ui) => {
2133
- onChange(
2134
- replace(value, i, __spreadProps(__spreadValues({}, data), {
2135
- [subName]: val
2136
- })),
2137
- ui
2138
- );
2139
- }
2140
- }
2141
- )
2142
- },
2143
- subPath
2144
- );
2145
- })
2146
- }
2147
- ) })
1443
+ name: subPath,
1444
+ label: label2,
1445
+ id: `${_arrayId}_${subName}`,
1446
+ readOnly: subReadOnly,
1447
+ field: __spreadProps(__spreadValues({}, subField), {
1448
+ label: label2
1449
+ // May be used by custom fields
1450
+ }),
1451
+ value: data[subName],
1452
+ onChange: (val, ui) => {
1453
+ onChange(
1454
+ replace(value, i, __spreadProps(__spreadValues({}, data), {
1455
+ [subName]: val
1456
+ })),
1457
+ ui
1458
+ );
1459
+ }
1460
+ }
1461
+ )
1462
+ },
1463
+ subPath
1464
+ );
1465
+ }) }) })
2148
1466
  ]
2149
1467
  }
2150
1468
  )
2151
1469
  },
2152
1470
  _arrayId
2153
1471
  );
2154
- }) }),
1472
+ }),
2155
1473
  !addDisabled && /* @__PURE__ */ jsx8(
2156
1474
  "button",
2157
1475
  {
2158
1476
  type: "button",
2159
1477
  className: getClassName5("addButton"),
2160
1478
  onClick: () => {
2161
- if (isDragging) return;
2162
1479
  const existingValue = value || [];
2163
1480
  const newValue = [
2164
1481
  ...existingValue,
@@ -2246,18 +1563,18 @@ init_react_import();
2246
1563
  import {
2247
1564
  useMemo as useMemo2,
2248
1565
  useEffect as useEffect7,
2249
- useState as useState10,
1566
+ useState as useState9,
2250
1567
  useCallback as useCallback4,
2251
1568
  isValidElement
2252
1569
  } from "react";
2253
1570
 
2254
1571
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
2255
1572
  init_react_import();
2256
- var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_91ls0_1", "ExternalInput-button": "_ExternalInput-button_91ls0_5", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_91ls0_24", "ExternalInput--readOnly": "_ExternalInput--readOnly_91ls0_31", "ExternalInput-detachButton": "_ExternalInput-detachButton_91ls0_35", "ExternalInput": "_ExternalInput_91ls0_1", "ExternalInputModal": "_ExternalInputModal_91ls0_79", "ExternalInputModal-grid": "_ExternalInputModal-grid_91ls0_89", "ExternalInputModal--filtersToggled": "_ExternalInputModal--filtersToggled_91ls0_100", "ExternalInputModal-filters": "_ExternalInputModal-filters_91ls0_105", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_91ls0_124", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_91ls0_133", "ExternalInputModal-table": "_ExternalInputModal-table_91ls0_133", "ExternalInputModal-thead": "_ExternalInputModal-thead_91ls0_149", "ExternalInputModal-th": "_ExternalInputModal-th_91ls0_149", "ExternalInputModal-td": "_ExternalInputModal-td_91ls0_164", "ExternalInputModal-tr": "_ExternalInputModal-tr_91ls0_169", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_91ls0_176", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_91ls0_202", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_91ls0_206", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_91ls0_223", "ExternalInputModal-searchForm": "_ExternalInputModal-searchForm_91ls0_227", "ExternalInputModal-search": "_ExternalInputModal-search_91ls0_227", "ExternalInputModal-searchIcon": "_ExternalInputModal-searchIcon_91ls0_264", "ExternalInputModal-searchIconText": "_ExternalInputModal-searchIconText_91ls0_289", "ExternalInputModal-searchInput": "_ExternalInputModal-searchInput_91ls0_299", "ExternalInputModal-searchActions": "_ExternalInputModal-searchActions_91ls0_313", "ExternalInputModal-searchActionIcon": "_ExternalInputModal-searchActionIcon_91ls0_326", "ExternalInputModal-footerContainer": "_ExternalInputModal-footerContainer_91ls0_330", "ExternalInputModal-footer": "_ExternalInputModal-footer_91ls0_330", "ExternalInputModal-field": "_ExternalInputModal-field_91ls0_343" };
1573
+ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_8wgzm_1", "ExternalInput-button": "_ExternalInput-button_8wgzm_5", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_8wgzm_24", "ExternalInput--readOnly": "_ExternalInput--readOnly_8wgzm_31", "ExternalInput-detachButton": "_ExternalInput-detachButton_8wgzm_35", "ExternalInput": "_ExternalInput_8wgzm_1", "ExternalInputModal": "_ExternalInputModal_8wgzm_79", "ExternalInputModal-grid": "_ExternalInputModal-grid_8wgzm_89", "ExternalInputModal--filtersToggled": "_ExternalInputModal--filtersToggled_8wgzm_100", "ExternalInputModal-filters": "_ExternalInputModal-filters_8wgzm_105", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_8wgzm_124", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_8wgzm_133", "ExternalInputModal-table": "_ExternalInputModal-table_8wgzm_133", "ExternalInputModal-thead": "_ExternalInputModal-thead_8wgzm_149", "ExternalInputModal-th": "_ExternalInputModal-th_8wgzm_149", "ExternalInputModal-td": "_ExternalInputModal-td_8wgzm_164", "ExternalInputModal-tr": "_ExternalInputModal-tr_8wgzm_169", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_8wgzm_176", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_8wgzm_202", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_8wgzm_206", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_8wgzm_223", "ExternalInputModal-searchForm": "_ExternalInputModal-searchForm_8wgzm_227", "ExternalInputModal-search": "_ExternalInputModal-search_8wgzm_227", "ExternalInputModal-searchIcon": "_ExternalInputModal-searchIcon_8wgzm_264", "ExternalInputModal-searchIconText": "_ExternalInputModal-searchIconText_8wgzm_289", "ExternalInputModal-searchInput": "_ExternalInputModal-searchInput_8wgzm_299", "ExternalInputModal-searchActions": "_ExternalInputModal-searchActions_8wgzm_313", "ExternalInputModal-searchActionIcon": "_ExternalInputModal-searchActionIcon_8wgzm_326", "ExternalInputModal-footerContainer": "_ExternalInputModal-footerContainer_8wgzm_330", "ExternalInputModal-footer": "_ExternalInputModal-footer_8wgzm_330" };
2257
1574
 
2258
1575
  // components/Modal/index.tsx
2259
1576
  init_react_import();
2260
- import { useEffect as useEffect5, useState as useState8 } from "react";
1577
+ import { useEffect as useEffect5, useState as useState7 } from "react";
2261
1578
 
2262
1579
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
2263
1580
  init_react_import();
@@ -2272,7 +1589,7 @@ var Modal = ({
2272
1589
  onClose,
2273
1590
  isOpen
2274
1591
  }) => {
2275
- const [rootEl, setRootEl] = useState8(null);
1592
+ const [rootEl, setRootEl] = useState7(null);
2276
1593
  useEffect5(() => {
2277
1594
  setRootEl(document.getElementById("puck-portal-root"));
2278
1595
  }, []);
@@ -2320,11 +1637,11 @@ init_react_import();
2320
1637
 
2321
1638
  // components/Button/Button.tsx
2322
1639
  init_react_import();
2323
- import { useEffect as useEffect6, useState as useState9 } from "react";
1640
+ import { useEffect as useEffect6, useState as useState8 } from "react";
2324
1641
 
2325
1642
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
2326
1643
  init_react_import();
2327
- var Button_module_default = { "Button": "_Button_10byl_1", "Button--medium": "_Button--medium_10byl_29", "Button--large": "_Button--large_10byl_37", "Button-icon": "_Button-icon_10byl_44", "Button--primary": "_Button--primary_10byl_48", "Button--secondary": "_Button--secondary_10byl_67", "Button--flush": "_Button--flush_10byl_84", "Button--disabled": "_Button--disabled_10byl_88", "Button--fullWidth": "_Button--fullWidth_10byl_95", "Button-spinner": "_Button-spinner_10byl_100" };
1644
+ var Button_module_default = { "Button": "_Button_1t64k_1", "Button--medium": "_Button--medium_1t64k_29", "Button--large": "_Button--large_1t64k_37", "Button-icon": "_Button-icon_1t64k_44", "Button--primary": "_Button--primary_1t64k_48", "Button--secondary": "_Button--secondary_1t64k_67", "Button--flush": "_Button--flush_1t64k_84", "Button--disabled": "_Button--disabled_1t64k_88", "Button--fullWidth": "_Button--fullWidth_1t64k_95", "Button-spinner": "_Button-spinner_1t64k_100" };
2328
1645
 
2329
1646
  // lib/filter-data-attrs.ts
2330
1647
  init_react_import();
@@ -2370,7 +1687,7 @@ var Button = (_a) => {
2370
1687
  "size",
2371
1688
  "loading"
2372
1689
  ]);
2373
- const [loading, setLoading] = useState9(loadingProp);
1690
+ const [loading, setLoading] = useState8(loadingProp);
2374
1691
  useEffect6(() => setLoading(loadingProp), [loadingProp]);
2375
1692
  const ElementType = href ? "a" : type ? "button" : "span";
2376
1693
  const dataAttrs = filterDataAttrs(props);
@@ -2426,12 +1743,12 @@ var ExternalInput = ({
2426
1743
  mapRow = (val) => val,
2427
1744
  filterFields
2428
1745
  } = field || {};
2429
- const [data, setData] = useState10([]);
2430
- const [isOpen, setOpen] = useState10(false);
2431
- const [isLoading, setIsLoading] = useState10(true);
1746
+ const [data, setData] = useState9([]);
1747
+ const [isOpen, setOpen] = useState9(false);
1748
+ const [isLoading, setIsLoading] = useState9(true);
2432
1749
  const hasFilterFields = !!filterFields;
2433
- const [filters, setFilters] = useState10(field.initialFilters || {});
2434
- const [filtersToggled, setFiltersToggled] = useState10(hasFilterFields);
1750
+ const [filters, setFilters] = useState9(field.initialFilters || {});
1751
+ const [filtersToggled, setFiltersToggled] = useState9(hasFilterFields);
2435
1752
  const mappedData = useMemo2(() => {
2436
1753
  return data.map(mapRow);
2437
1754
  }, [data]);
@@ -2446,7 +1763,7 @@ var ExternalInput = ({
2446
1763
  }
2447
1764
  return Array.from(validKeys);
2448
1765
  }, [mappedData]);
2449
- const [searchQuery, setSearchQuery] = useState10(field.initialQuery || "");
1766
+ const [searchQuery, setSearchQuery] = useState9(field.initialQuery || "");
2450
1767
  const search = useCallback4(
2451
1768
  (query, filters2) => __async(void 0, null, function* () {
2452
1769
  setIsLoading(true);
@@ -2561,26 +1878,18 @@ var ExternalInput = ({
2561
1878
  hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
2562
1879
  const filterField = filterFields[fieldName];
2563
1880
  return /* @__PURE__ */ jsx13(
2564
- "div",
1881
+ AutoFieldPrivate,
2565
1882
  {
2566
- className: getClassNameModal("field"),
2567
- children: /* @__PURE__ */ jsx13(
2568
- AutoFieldPrivate,
2569
- {
2570
- field: filterField,
2571
- name: fieldName,
2572
- id: `external_field_${fieldName}_filter`,
2573
- label: filterField.label || fieldName,
2574
- value: filters[fieldName],
2575
- onChange: (value2) => {
2576
- const newFilters = __spreadProps(__spreadValues({}, filters), {
2577
- [fieldName]: value2
2578
- });
2579
- setFilters(newFilters);
2580
- search(searchQuery, newFilters);
2581
- }
2582
- }
2583
- )
1883
+ field: filterField,
1884
+ name: fieldName,
1885
+ id: `external_field_${fieldName}_filter`,
1886
+ label: filterField.label || fieldName,
1887
+ value: filters[fieldName],
1888
+ onChange: (value2) => {
1889
+ const newFilters = __spreadProps(__spreadValues({}, filters), { [fieldName]: value2 });
1890
+ setFilters(newFilters);
1891
+ search(searchQuery, newFilters);
1892
+ }
2584
1893
  },
2585
1894
  fieldName
2586
1895
  );
@@ -2915,7 +2224,7 @@ var ObjectField = ({
2915
2224
 
2916
2225
  // lib/use-safe-id.ts
2917
2226
  init_react_import();
2918
- import React2, { useState as useState11 } from "react";
2227
+ import React2, { useState as useState10 } from "react";
2919
2228
 
2920
2229
  // lib/generate-id.ts
2921
2230
  init_react_import();
@@ -2927,7 +2236,7 @@ var useSafeId = () => {
2927
2236
  if (typeof React2.useId !== "undefined") {
2928
2237
  return React2.useId();
2929
2238
  }
2930
- const [id] = useState11(generateId());
2239
+ const [id] = useState10(generateId());
2931
2240
  return id;
2932
2241
  };
2933
2242
 
@@ -3073,7 +2382,7 @@ function AutoFieldInternal(props) {
3073
2382
  function AutoFieldPrivate(props) {
3074
2383
  const { state } = useAppContext();
3075
2384
  const { value, onChange } = props;
3076
- const [localValue, setLocalValue] = useState12(value);
2385
+ const [localValue, setLocalValue] = useState11(value);
3077
2386
  const onChangeDb = useDebouncedCallback(
3078
2387
  (val, ui) => {
3079
2388
  onChange(val, ui);
@@ -3112,55 +2421,393 @@ function AutoField(props) {
3112
2421
  // components/Drawer/index.tsx
3113
2422
  init_react_import();
3114
2423
 
3115
- // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
3116
- init_react_import();
3117
- 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" };
2424
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
2425
+ init_react_import();
2426
+ 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" };
2427
+
2428
+ // components/Drawer/index.tsx
2429
+ import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
2430
+
2431
+ // components/DragDropContext/index.tsx
2432
+ init_react_import();
2433
+ import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
2434
+ import {
2435
+ createContext as createContext4,
2436
+ useCallback as useCallback11,
2437
+ useContext as useContext7,
2438
+ useEffect as useEffect15,
2439
+ useId,
2440
+ useRef as useRef3,
2441
+ useState as useState17
2442
+ } from "react";
2443
+ import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
2444
+
2445
+ // components/DropZone/index.tsx
2446
+ init_react_import();
2447
+ import {
2448
+ forwardRef as forwardRef3,
2449
+ useCallback as useCallback10,
2450
+ useContext as useContext6,
2451
+ useEffect as useEffect14,
2452
+ useMemo as useMemo8,
2453
+ useRef as useRef2
2454
+ } from "react";
2455
+
2456
+ // components/DraggableComponent/index.tsx
2457
+ init_react_import();
2458
+ import {
2459
+ useCallback as useCallback7,
2460
+ useContext as useContext5,
2461
+ useEffect as useEffect10,
2462
+ useMemo as useMemo7,
2463
+ useRef,
2464
+ useState as useState13
2465
+ } from "react";
2466
+
2467
+ // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
2468
+ init_react_import();
2469
+ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
2470
+
2471
+ // components/DraggableComponent/index.tsx
2472
+ import { createPortal as createPortal2 } from "react-dom";
2473
+
2474
+ // lib/dnd/collision/dynamic/index.ts
2475
+ init_react_import();
2476
+ import {
2477
+ CollisionPriority as CollisionPriority7,
2478
+ CollisionType as CollisionType7
2479
+ } from "@dnd-kit/abstract";
2480
+
2481
+ // lib/dnd/collision/directional/index.ts
2482
+ init_react_import();
2483
+ import { CollisionType } from "@dnd-kit/abstract";
2484
+
2485
+ // lib/dnd/collision/collision-debug.ts
2486
+ init_react_import();
2487
+ var DEBUG = false;
2488
+ var debugElements = {};
2489
+ var timeout;
2490
+ var collisionDebug = (a, b, id, color, label) => {
2491
+ if (!DEBUG) return;
2492
+ const debugId = `${id}-debug`;
2493
+ clearTimeout(timeout);
2494
+ timeout = setTimeout(() => {
2495
+ Object.entries(debugElements).forEach(([id2, { svg }]) => {
2496
+ svg.remove();
2497
+ delete debugElements[id2];
2498
+ });
2499
+ }, 1e3);
2500
+ requestAnimationFrame(() => {
2501
+ var _a, _b;
2502
+ const existingEl = debugElements[debugId];
2503
+ let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
2504
+ let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
2505
+ if (!existingEl) {
2506
+ const svgNs = "http://www.w3.org/2000/svg";
2507
+ const svg = document.createElementNS(svgNs, "svg");
2508
+ line = document.createElementNS(svgNs, "line");
2509
+ text = document.createElementNS(svgNs, "text");
2510
+ svg.setAttribute("id", debugId);
2511
+ svg.setAttribute(
2512
+ "style",
2513
+ "position: fixed; height: 100%; width: 100%; pointer-events: none;"
2514
+ );
2515
+ svg.appendChild(line);
2516
+ svg.appendChild(text);
2517
+ text.setAttribute("fill", `black`);
2518
+ document.body.appendChild(svg);
2519
+ debugElements[debugId] = { svg, line, text };
2520
+ }
2521
+ line.setAttribute("x1", a.x.toString());
2522
+ line.setAttribute("x2", b.x.toString());
2523
+ line.setAttribute("y1", a.y.toString());
2524
+ line.setAttribute("y2", b.y.toString());
2525
+ line.setAttribute("style", `stroke:${color};stroke-width:2`);
2526
+ text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
2527
+ text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
2528
+ if (label) {
2529
+ text.innerHTML = label;
2530
+ }
2531
+ });
2532
+ };
2533
+
2534
+ // lib/dnd/collision/directional/index.ts
2535
+ var distanceChange = "increasing";
2536
+ var directionalCollision = (input, previous) => {
2537
+ var _a;
2538
+ const { dragOperation, droppable } = input;
2539
+ const { shape: dropShape } = droppable;
2540
+ const { position } = dragOperation;
2541
+ const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
2542
+ if (!dragShape || !dropShape) return null;
2543
+ const dropCenter = dropShape.center;
2544
+ const distanceToPrevious = Math.sqrt(
2545
+ Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
2546
+ );
2547
+ const distanceToCurrent = Math.sqrt(
2548
+ Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
2549
+ );
2550
+ distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
2551
+ collisionDebug(
2552
+ dragShape.center,
2553
+ dropCenter,
2554
+ droppable.id.toString(),
2555
+ "rebeccapurple"
2556
+ );
2557
+ if (distanceChange === "decreasing") {
2558
+ return {
2559
+ id: droppable.id,
2560
+ value: 1,
2561
+ type: CollisionType.Collision
2562
+ };
2563
+ }
2564
+ return null;
2565
+ };
3118
2566
 
3119
- // components/Drawer/index.tsx
3120
- import { useId as useId2, useMemo as useMemo9, useState as useState19 } from "react";
2567
+ // lib/dnd/collision/dynamic/get-direction.ts
2568
+ init_react_import();
2569
+ var getDirection = (dragAxis, delta) => {
2570
+ if (dragAxis === "dynamic") {
2571
+ if (Math.abs(delta.y) > Math.abs(delta.x)) {
2572
+ return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2573
+ } else {
2574
+ return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
2575
+ }
2576
+ } else if (dragAxis === "x") {
2577
+ return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
2578
+ }
2579
+ return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2580
+ };
3121
2581
 
3122
- // components/DragDropContext/index.tsx
2582
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
3123
2583
  init_react_import();
3124
- import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
3125
- import {
3126
- createContext as createContext4,
3127
- useCallback as useCallback11,
3128
- useContext as useContext7,
3129
- useEffect as useEffect15,
3130
- useId,
3131
- useRef as useRef3,
3132
- useState as useState18
3133
- } from "react";
3134
- import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
2584
+ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
2585
+ const dragRect = dragShape.boundingRectangle;
2586
+ const dropCenter = dropShape.center;
2587
+ if (direction === "down") {
2588
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
2589
+ return dragRect.bottom >= dropCenter.y + offset2;
2590
+ } else if (direction === "up") {
2591
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
2592
+ return dragRect.top < dropCenter.y - offset2;
2593
+ } else if (direction === "left") {
2594
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
2595
+ return dropCenter.x - offset2 >= dragRect.left;
2596
+ }
2597
+ const offset = offsetMultiplier * dropShape.boundingRectangle.width;
2598
+ return dragRect.right - offset >= dropCenter.x;
2599
+ };
3135
2600
 
3136
- // components/DropZone/index.tsx
2601
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
3137
2602
  init_react_import();
3138
- import {
3139
- forwardRef as forwardRef3,
3140
- useCallback as useCallback10,
3141
- useContext as useContext6,
3142
- useEffect as useEffect14,
3143
- useMemo as useMemo8,
3144
- useRef as useRef2
3145
- } from "react";
2603
+ import { Point } from "@dnd-kit/geometry";
2604
+ var INTERVAL_SENSITIVITY = 10;
2605
+ var intervalCache = {
2606
+ current: { x: 0, y: 0 },
2607
+ delta: { x: 0, y: 0 },
2608
+ previous: { x: 0, y: 0 },
2609
+ direction: null
2610
+ };
2611
+ var trackMovementInterval = (point, dragAxis = "dynamic") => {
2612
+ intervalCache.current = point;
2613
+ intervalCache.delta = {
2614
+ x: point.x - intervalCache.previous.x,
2615
+ y: point.y - intervalCache.previous.y
2616
+ };
2617
+ intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
2618
+ if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
2619
+ intervalCache.previous = Point.from(point);
2620
+ }
2621
+ return intervalCache;
2622
+ };
3146
2623
 
3147
- // components/DraggableComponent/index.tsx
2624
+ // ../../node_modules/@dnd-kit/collision/dist/index.js
3148
2625
  init_react_import();
3149
- import {
3150
- useCallback as useCallback7,
3151
- useContext as useContext5,
3152
- useEffect as useEffect10,
3153
- useMemo as useMemo7,
3154
- useRef,
3155
- useState as useState14
3156
- } from "react";
2626
+ import { CollisionPriority, CollisionType as CollisionType2 } from "@dnd-kit/abstract";
2627
+ import { Point as Point2 } from "@dnd-kit/geometry";
2628
+ import { CollisionPriority as CollisionPriority2, CollisionType as CollisionType22 } from "@dnd-kit/abstract";
2629
+ import { Point as Point22 } from "@dnd-kit/geometry";
2630
+ import { CollisionPriority as CollisionPriority3, CollisionType as CollisionType3 } from "@dnd-kit/abstract";
2631
+ import { Point as Point3 } from "@dnd-kit/geometry";
2632
+ import { CollisionPriority as CollisionPriority4, CollisionType as CollisionType4 } from "@dnd-kit/abstract";
2633
+ import { Point as Point4 } from "@dnd-kit/geometry";
2634
+ import { CollisionPriority as CollisionPriority5, CollisionType as CollisionType5 } from "@dnd-kit/abstract";
2635
+ import { Point as Point5 } from "@dnd-kit/geometry";
2636
+ import { CollisionPriority as CollisionPriority6, CollisionType as CollisionType6 } from "@dnd-kit/abstract";
2637
+ import { Point as Point6 } from "@dnd-kit/geometry";
2638
+ var pointerIntersection = ({
2639
+ dragOperation,
2640
+ droppable
2641
+ }) => {
2642
+ const pointerCoordinates = dragOperation.position.current;
2643
+ if (!pointerCoordinates) {
2644
+ return null;
2645
+ }
2646
+ const { id } = droppable;
2647
+ if (!droppable.shape) {
2648
+ return null;
2649
+ }
2650
+ if (droppable.shape.containsPoint(pointerCoordinates)) {
2651
+ const distance = Point2.distance(droppable.shape.center, pointerCoordinates);
2652
+ return {
2653
+ id,
2654
+ value: 1 / distance,
2655
+ type: CollisionType2.PointerIntersection,
2656
+ priority: CollisionPriority.High
2657
+ };
2658
+ }
2659
+ return null;
2660
+ };
2661
+ var closestCorners = (input) => {
2662
+ const { dragOperation, droppable } = input;
2663
+ const { shape, position } = dragOperation;
2664
+ if (!droppable.shape) {
2665
+ return null;
2666
+ }
2667
+ const { left, top, right, bottom } = droppable.shape.boundingRectangle;
2668
+ const corners = [
2669
+ {
2670
+ x: left,
2671
+ y: top
2672
+ },
2673
+ {
2674
+ x: right,
2675
+ y: top
2676
+ },
2677
+ {
2678
+ x: left,
2679
+ y: bottom
2680
+ },
2681
+ {
2682
+ x: right,
2683
+ y: bottom
2684
+ }
2685
+ ];
2686
+ const distance = corners.reduce(
2687
+ (acc, corner) => {
2688
+ var _a;
2689
+ return acc + Point3.distance(
2690
+ Point3.from(corner),
2691
+ (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
2692
+ );
2693
+ },
2694
+ 0
2695
+ );
2696
+ const value = distance / 4;
2697
+ return {
2698
+ id: droppable.id,
2699
+ value: 1 / value,
2700
+ type: CollisionType3.Collision,
2701
+ priority: CollisionPriority3.Normal
2702
+ };
2703
+ };
3157
2704
 
3158
- // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
2705
+ // lib/dnd/collision/dynamic/store.ts
3159
2706
  init_react_import();
3160
- var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
2707
+ import { createStore } from "zustand/vanilla";
2708
+ var collisionStore = createStore(() => ({
2709
+ fallbackEnabled: false
2710
+ }));
3161
2711
 
3162
- // components/DraggableComponent/index.tsx
3163
- import { createPortal as createPortal2 } from "react-dom";
2712
+ // lib/dnd/collision/dynamic/index.ts
2713
+ var flushNext = "";
2714
+ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2715
+ var _a, _b, _c, _d, _e;
2716
+ const { dragOperation, droppable } = input;
2717
+ const { position } = dragOperation;
2718
+ const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
2719
+ const { shape: dropShape } = droppable;
2720
+ if (!dragShape || !dropShape) {
2721
+ return null;
2722
+ }
2723
+ const { center: dragCenter } = dragShape;
2724
+ const { fallbackEnabled } = collisionStore.getState();
2725
+ const interval = trackMovementInterval(position.current, dragAxis);
2726
+ dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2727
+ direction: interval.direction
2728
+ });
2729
+ const collisionMap = dragOperation.data.collisionMap || {};
2730
+ dragOperation.data.collisionMap = collisionMap;
2731
+ collisionMap[droppable.id] = {
2732
+ direction: interval.direction
2733
+ };
2734
+ const { center: dropCenter } = dropShape;
2735
+ const overMidpoint = getMidpointImpact(
2736
+ dragShape,
2737
+ dropShape,
2738
+ interval.direction,
2739
+ midpointOffset
2740
+ );
2741
+ if (((_b = dragOperation.source) == null ? void 0 : _b.id) === droppable.id) {
2742
+ const collision = directionalCollision(input, interval.previous);
2743
+ collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
2744
+ if (collision) {
2745
+ return __spreadProps(__spreadValues({}, collision), {
2746
+ priority: CollisionPriority7.Highest
2747
+ });
2748
+ }
2749
+ }
2750
+ const intersectionArea = dragShape.intersectionArea(dropShape);
2751
+ const intersectionRatio = intersectionArea / dropShape.area;
2752
+ if (intersectionArea && overMidpoint) {
2753
+ collisionDebug(
2754
+ dragCenter,
2755
+ dropCenter,
2756
+ droppable.id.toString(),
2757
+ "green",
2758
+ interval.direction
2759
+ );
2760
+ const collision = {
2761
+ id: droppable.id,
2762
+ value: intersectionRatio,
2763
+ priority: CollisionPriority7.High,
2764
+ type: CollisionType7.Collision
2765
+ };
2766
+ const shouldFlushId = flushNext === droppable.id;
2767
+ flushNext = "";
2768
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2769
+ }
2770
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2771
+ const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
2772
+ const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
2773
+ if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
2774
+ const fallbackCollision = closestCorners(input);
2775
+ if (fallbackCollision) {
2776
+ const direction = getDirection(dragAxis, {
2777
+ x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
2778
+ y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
2779
+ });
2780
+ collisionMap[droppable.id] = {
2781
+ direction
2782
+ };
2783
+ if (intersectionArea) {
2784
+ collisionDebug(
2785
+ dragCenter,
2786
+ dropCenter,
2787
+ droppable.id.toString(),
2788
+ "red",
2789
+ direction || ""
2790
+ );
2791
+ flushNext = droppable.id;
2792
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2793
+ priority: CollisionPriority7.Low
2794
+ });
2795
+ }
2796
+ collisionDebug(
2797
+ dragCenter,
2798
+ dropCenter,
2799
+ droppable.id.toString(),
2800
+ "orange",
2801
+ direction || ""
2802
+ );
2803
+ return __spreadProps(__spreadValues({}, fallbackCollision), { priority: CollisionPriority7.Lowest });
2804
+ }
2805
+ }
2806
+ }
2807
+ collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2808
+ delete collisionMap[droppable.id];
2809
+ return null;
2810
+ };
3164
2811
 
3165
2812
  // lib/get-deep-scroll-position.ts
3166
2813
  init_react_import();
@@ -3187,7 +2834,7 @@ import {
3187
2834
  createContext as createContext3,
3188
2835
  useCallback as useCallback6,
3189
2836
  useMemo as useMemo6,
3190
- useState as useState13
2837
+ useState as useState12
3191
2838
  } from "react";
3192
2839
  import { createStore as createStore2 } from "zustand";
3193
2840
  import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
@@ -3212,11 +2859,11 @@ var DropZoneProvider = ({
3212
2859
  children,
3213
2860
  value
3214
2861
  }) => {
3215
- const [hoveringComponent, setHoveringComponent] = useState13();
3216
- const [areasWithZones, setAreasWithZones] = useState13(
2862
+ const [hoveringComponent, setHoveringComponent] = useState12();
2863
+ const [areasWithZones, setAreasWithZones] = useState12(
3217
2864
  {}
3218
2865
  );
3219
- const [activeZones, setActiveZones] = useState13({});
2866
+ const [activeZones, setActiveZones] = useState12({});
3220
2867
  const { dispatch } = useAppContext();
3221
2868
  const registerZoneArea = useCallback6(
3222
2869
  (area) => {
@@ -3333,7 +2980,7 @@ var DraggableComponent = ({
3333
2980
  state
3334
2981
  } = useAppContext();
3335
2982
  const ctx = useContext5(dropZoneContext);
3336
- const [localZones, setLocalZones] = useState14({});
2983
+ const [localZones, setLocalZones] = useState13({});
3337
2984
  const registerLocalZone = useCallback7(
3338
2985
  (zoneCompound2, active) => {
3339
2986
  var _a;
@@ -3358,7 +3005,7 @@ var DraggableComponent = ({
3358
3005
  );
3359
3006
  const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
3360
3007
  const { path = [] } = ctx || {};
3361
- const [canDrag, setCanDrag] = useState14(false);
3008
+ const [canDrag, setCanDrag] = useState13(false);
3362
3009
  useEffect10(() => {
3363
3010
  var _a;
3364
3011
  const item = getItem({ index, zone: zoneCompound }, state.data);
@@ -3375,7 +3022,7 @@ var DraggableComponent = ({
3375
3022
  );
3376
3023
  const canCollide = canDrag || userIsDragging;
3377
3024
  const disabled = !isEnabled || !canCollide;
3378
- const [dragAxis, setDragAxis] = useState14(userDragAxis || autoDragAxis);
3025
+ const [dragAxis, setDragAxis] = useState13(userDragAxis || autoDragAxis);
3379
3026
  const { ref: sortableRef, status } = useSortableSafe({
3380
3027
  id,
3381
3028
  index,
@@ -3411,7 +3058,7 @@ var DraggableComponent = ({
3411
3058
  },
3412
3059
  [sortableRef]
3413
3060
  );
3414
- const [portalEl, setPortalEl] = useState14();
3061
+ const [portalEl, setPortalEl] = useState13();
3415
3062
  useEffect10(() => {
3416
3063
  var _a, _b, _c;
3417
3064
  setPortalEl(
@@ -3438,7 +3085,7 @@ var DraggableComponent = ({
3438
3085
  };
3439
3086
  return style2;
3440
3087
  }, [ref.current]);
3441
- const [style, setStyle] = useState14();
3088
+ const [style, setStyle] = useState13();
3442
3089
  const sync = useCallback7(() => {
3443
3090
  setStyle(getStyle());
3444
3091
  }, [ref.current, iframe]);
@@ -3516,7 +3163,7 @@ var DraggableComponent = ({
3516
3163
  zone: zoneCompound
3517
3164
  });
3518
3165
  }, [index, zoneCompound]);
3519
- const [hover, setHover] = useState14(false);
3166
+ const [hover, setHover] = useState13(false);
3520
3167
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
3521
3168
  useEffect10(() => {
3522
3169
  if (!ref.current) {
@@ -3577,7 +3224,7 @@ var DraggableComponent = ({
3577
3224
  };
3578
3225
  }
3579
3226
  }, [disabled, ref]);
3580
- const [isVisible, setIsVisible] = useState14(false);
3227
+ const [isVisible, setIsVisible] = useState13(false);
3581
3228
  useEffect10(() => {
3582
3229
  sync();
3583
3230
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
@@ -3697,14 +3344,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
3697
3344
 
3698
3345
  // components/DropZone/lib/use-min-empty-height.ts
3699
3346
  init_react_import();
3700
- import { useEffect as useEffect11, useState as useState15 } from "react";
3347
+ import { useEffect as useEffect11, useState as useState14 } from "react";
3701
3348
  var useMinEmptyHeight = ({
3702
3349
  zoneCompound,
3703
3350
  userMinEmptyHeight,
3704
3351
  ref
3705
3352
  }) => {
3706
- const [prevHeight, setPrevHeight] = useState15(0);
3707
- const [isAnimating, setIsAnimating] = useState15(false);
3353
+ const [prevHeight, setPrevHeight] = useState14(0);
3354
+ const [isAnimating, setIsAnimating] = useState14(false);
3708
3355
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3709
3356
  var _a, _b;
3710
3357
  return {
@@ -3746,7 +3393,7 @@ function assignRefs(refs, node) {
3746
3393
 
3747
3394
  // components/DropZone/lib/use-content-with-preview.ts
3748
3395
  init_react_import();
3749
- import { useEffect as useEffect12, useState as useState16 } from "react";
3396
+ import { useEffect as useEffect12, useState as useState15 } from "react";
3750
3397
 
3751
3398
  // lib/dnd/use-rendered-callback.ts
3752
3399
  init_react_import();
@@ -3789,8 +3436,8 @@ var useContentWithPreview = (content, zoneCompound) => {
3789
3436
  ui: { isDragging }
3790
3437
  }
3791
3438
  } = useAppContext();
3792
- const [contentWithPreview, setContentWithPreview] = useState16(content);
3793
- const [localPreview, setLocalPreview] = useState16(
3439
+ const [contentWithPreview, setContentWithPreview] = useState15(content);
3440
+ const [localPreview, setLocalPreview] = useState15(
3794
3441
  preview
3795
3442
  );
3796
3443
  const updateContent = useRenderedCallback(
@@ -3839,13 +3486,13 @@ var useContentWithPreview = (content, zoneCompound) => {
3839
3486
 
3840
3487
  // components/DropZone/lib/use-drag-axis.ts
3841
3488
  init_react_import();
3842
- import { useCallback as useCallback9, useEffect as useEffect13, useState as useState17 } from "react";
3489
+ import { useCallback as useCallback9, useEffect as useEffect13, useState as useState16 } from "react";
3843
3490
  var GRID_DRAG_AXIS = "dynamic";
3844
3491
  var FLEX_ROW_DRAG_AXIS = "x";
3845
3492
  var DEFAULT_DRAG_AXIS = "y";
3846
3493
  var useDragAxis = (ref, collisionAxis) => {
3847
3494
  const { status } = useAppContext();
3848
- const [dragAxis, setDragAxis] = useState17(
3495
+ const [dragAxis, setDragAxis] = useState16(
3849
3496
  collisionAxis || DEFAULT_DRAG_AXIS
3850
3497
  );
3851
3498
  const calculateDragAxis = useCallback9(() => {
@@ -4157,702 +3804,945 @@ var DropZoneRender = forwardRef3(
4157
3804
  }) });
4158
3805
  }
4159
3806
  );
4160
- var DropZonePure = (props) => /* @__PURE__ */ jsx22(DropZone, __spreadValues({}, props));
4161
3807
  var DropZone = forwardRef3(
4162
3808
  function DropZone2(props, ref) {
4163
3809
  const ctx = useContext6(dropZoneContext);
4164
3810
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
4165
3811
  return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
4166
3812
  }
4167
- return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3813
+ return /* @__PURE__ */ jsx22(Fragment6, { children: /* @__PURE__ */ jsx22(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3814
+ }
3815
+ );
3816
+
3817
+ // lib/get-zone-id.ts
3818
+ init_react_import();
3819
+ var getZoneId = (zoneCompound) => {
3820
+ if (!zoneCompound) {
3821
+ return [];
3822
+ }
3823
+ if (zoneCompound && zoneCompound.indexOf(":") > -1) {
3824
+ return zoneCompound.split(":");
3825
+ }
3826
+ return [rootDroppableId, zoneCompound];
3827
+ };
3828
+
3829
+ // lib/dnd/NestedDroppablePlugin.ts
3830
+ init_react_import();
3831
+ import { Plugin } from "@dnd-kit/abstract";
3832
+ import { effects } from "@dnd-kit/state";
3833
+
3834
+ // lib/throttle.ts
3835
+ init_react_import();
3836
+ function timeout2(callback, duration) {
3837
+ const id = setTimeout(callback, duration);
3838
+ return () => clearTimeout(id);
3839
+ }
3840
+ function throttle(func, limit) {
3841
+ const time = () => performance.now();
3842
+ let cancel;
3843
+ let lastRan = 0;
3844
+ return function(...args) {
3845
+ const now = time();
3846
+ const context = this;
3847
+ if (now - lastRan >= limit) {
3848
+ func.apply(context, args);
3849
+ lastRan = now;
3850
+ } else {
3851
+ cancel == null ? void 0 : cancel();
3852
+ cancel = timeout2(() => {
3853
+ func.apply(context, args);
3854
+ lastRan = time();
3855
+ }, limit - (now - lastRan));
3856
+ }
3857
+ };
3858
+ }
3859
+
3860
+ // lib/get-frame.ts
3861
+ init_react_import();
3862
+ var getFrame = () => {
3863
+ if (typeof window === "undefined") return;
3864
+ let frameEl = document.querySelector("#preview-frame");
3865
+ if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
3866
+ return frameEl.contentDocument || document;
3867
+ }
3868
+ return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3869
+ };
3870
+
3871
+ // lib/global-position.ts
3872
+ init_react_import();
3873
+ var GlobalPosition = class {
3874
+ constructor(target, original) {
3875
+ this.scaleFactor = 1;
3876
+ this.frameEl = null;
3877
+ this.frameRect = null;
3878
+ var _a;
3879
+ this.target = target;
3880
+ this.original = original;
3881
+ this.frameEl = document.querySelector("iframe");
3882
+ if (this.frameEl) {
3883
+ this.frameRect = this.frameEl.getBoundingClientRect();
3884
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3885
+ }
3886
+ }
3887
+ get x() {
3888
+ return this.original.x;
3889
+ }
3890
+ get y() {
3891
+ return this.original.y;
3892
+ }
3893
+ get global() {
3894
+ if (document !== this.target.ownerDocument && this.frameRect) {
3895
+ return {
3896
+ x: this.x * this.scaleFactor + this.frameRect.left,
3897
+ y: this.y * this.scaleFactor + this.frameRect.top
3898
+ };
3899
+ }
3900
+ return this.original;
3901
+ }
3902
+ get frame() {
3903
+ if (document === this.target.ownerDocument && this.frameRect) {
3904
+ return {
3905
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
3906
+ y: (this.y - this.frameRect.top) / this.scaleFactor
3907
+ };
3908
+ }
3909
+ return this.original;
3910
+ }
3911
+ };
3912
+
3913
+ // lib/dnd/NestedDroppablePlugin.ts
3914
+ var depthSort = (candidates) => {
3915
+ return candidates.sort((a, b) => {
3916
+ const aData = a.data;
3917
+ const bData = b.data;
3918
+ if (aData.depth > bData.depth) {
3919
+ return 1;
3920
+ }
3921
+ if (bData.depth > aData.depth) {
3922
+ return -1;
3923
+ }
3924
+ return 0;
3925
+ });
3926
+ };
3927
+ var getZoneId2 = (candidate) => {
3928
+ let id = candidate == null ? void 0 : candidate.id;
3929
+ if (!candidate) return null;
3930
+ if (candidate.type === "component") {
3931
+ const data = candidate.data;
3932
+ if (data.containsActiveZone) {
3933
+ id = null;
3934
+ } else {
3935
+ id = data.zone;
3936
+ }
3937
+ } else if (candidate.type === "void") {
3938
+ return "void";
3939
+ }
3940
+ return id;
3941
+ };
3942
+ var getPointerCollisions = (position, manager) => {
3943
+ const candidates = [];
3944
+ let elements = position.target.ownerDocument.elementsFromPoint(
3945
+ position.x,
3946
+ position.y
3947
+ );
3948
+ const previewFrame = elements.find(
3949
+ (el) => el.getAttribute("data-puck-preview")
3950
+ );
3951
+ const drawer = elements.find((el) => el.getAttribute("data-puck-drawer"));
3952
+ if (drawer) {
3953
+ elements = [drawer];
3954
+ }
3955
+ if (previewFrame) {
3956
+ const frame = getFrame();
3957
+ if (frame) {
3958
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
3959
+ }
3960
+ }
3961
+ if (elements) {
3962
+ for (let i = 0; i < elements.length; i++) {
3963
+ const element = elements[i];
3964
+ const dropzoneId = element.getAttribute("data-puck-dropzone");
3965
+ if (dropzoneId) {
3966
+ const droppable = manager.registry.droppables.get(dropzoneId);
3967
+ if (droppable) {
3968
+ candidates.push(droppable);
3969
+ }
3970
+ }
3971
+ const id = element.getAttribute("data-puck-dnd");
3972
+ if (id) {
3973
+ const droppable = manager.registry.droppables.get(id);
3974
+ if (droppable) {
3975
+ candidates.push(droppable);
3976
+ }
3977
+ }
3978
+ }
3979
+ }
3980
+ return candidates;
3981
+ };
3982
+ var findDeepestCandidate = (position, manager) => {
3983
+ var _a;
3984
+ const candidates = getPointerCollisions(position, manager);
3985
+ if (candidates.length > 0) {
3986
+ const sortedCandidates = depthSort(candidates);
3987
+ const draggable = manager.dragOperation.source;
3988
+ const draggedCandidateIndex = sortedCandidates.findIndex(
3989
+ (candidate) => candidate.id === (draggable == null ? void 0 : draggable.id)
3990
+ );
3991
+ const draggedCandidateId = draggable == null ? void 0 : draggable.id;
3992
+ let filteredCandidates = [...sortedCandidates];
3993
+ if (draggedCandidateId && draggedCandidateIndex > -1) {
3994
+ filteredCandidates.splice(draggedCandidateIndex, 1);
3995
+ }
3996
+ filteredCandidates = filteredCandidates.filter((candidate) => {
3997
+ const candidateData = candidate.data;
3998
+ if (draggedCandidateId && draggedCandidateIndex > -1) {
3999
+ if (candidateData.path.indexOf(draggedCandidateId) > -1) {
4000
+ return false;
4001
+ }
4002
+ }
4003
+ if (candidate.type === "dropzone") {
4004
+ const candidateData2 = candidate.data;
4005
+ if (!candidateData2.isDroppableTarget) {
4006
+ return false;
4007
+ }
4008
+ if (candidateData2.areaId === draggedCandidateId) {
4009
+ return false;
4010
+ }
4011
+ } else if (candidate.type === "component") {
4012
+ const candidateData2 = candidate.data;
4013
+ if (!candidateData2.inDroppableZone) {
4014
+ return false;
4015
+ }
4016
+ }
4017
+ return true;
4018
+ });
4019
+ filteredCandidates.reverse();
4020
+ const zone = getZoneId2(filteredCandidates[0]);
4021
+ const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
4022
+ return { zone, area };
4023
+ }
4024
+ return {
4025
+ zone: "default-zone",
4026
+ area: null
4027
+ };
4028
+ };
4029
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
4030
+ constructor(manager, options) {
4031
+ super(manager);
4032
+ if (typeof window === "undefined") {
4033
+ return;
4034
+ }
4035
+ const cleanupEffect = effects(() => {
4036
+ const handleMove = (event) => {
4037
+ const target = event.originalTarget || event.target;
4038
+ const position = new GlobalPosition(target, {
4039
+ x: event.clientX,
4040
+ y: event.clientY
4041
+ });
4042
+ const elements = document.elementsFromPoint(
4043
+ position.global.x,
4044
+ position.global.y
4045
+ );
4046
+ const overEl = elements.some((el) => el.id === id);
4047
+ if (overEl) {
4048
+ onChange(findDeepestCandidate(position, manager), manager);
4049
+ }
4050
+ };
4051
+ const handleMoveThrottled = throttle(handleMove, 50);
4052
+ const handlePointerMove = (event) => {
4053
+ handleMoveThrottled(event);
4054
+ };
4055
+ document.body.addEventListener("pointermove", handlePointerMove, {
4056
+ capture: true
4057
+ // dndkit's PointerSensor prevents propagation during drag
4058
+ });
4059
+ this.destroy = () => {
4060
+ document.body.removeEventListener("pointermove", handlePointerMove, {
4061
+ capture: true
4062
+ });
4063
+ cleanupEffect();
4064
+ };
4065
+ });
4168
4066
  }
4169
- );
4067
+ };
4170
4068
 
4171
- // lib/get-zone-id.ts
4069
+ // lib/insert-component.ts
4172
4070
  init_react_import();
4173
- var getZoneId = (zoneCompound) => {
4174
- if (!zoneCompound) {
4175
- return [];
4176
- }
4177
- if (zoneCompound && zoneCompound.indexOf(":") > -1) {
4178
- return zoneCompound.split(":");
4179
- }
4180
- return [rootDroppableId, zoneCompound];
4181
- };
4182
4071
 
4183
- // lib/dnd/NestedDroppablePlugin.ts
4072
+ // reducer/index.ts
4184
4073
  init_react_import();
4185
- import { Plugin } from "@dnd-kit/abstract";
4186
- import { effects } from "@dnd-kit/state";
4187
4074
 
4188
- // lib/throttle.ts
4075
+ // reducer/data.ts
4189
4076
  init_react_import();
4190
- function timeout2(callback, duration) {
4191
- const id = setTimeout(callback, duration);
4192
- return () => clearTimeout(id);
4193
- }
4194
- function throttle(func, limit) {
4195
- const time = () => performance.now();
4196
- let cancel;
4197
- let lastRan = 0;
4198
- return function(...args) {
4199
- const now = time();
4200
- const context = this;
4201
- if (now - lastRan >= limit) {
4202
- func.apply(context, args);
4203
- lastRan = now;
4204
- } else {
4205
- cancel == null ? void 0 : cancel();
4206
- cancel = timeout2(() => {
4207
- func.apply(context, args);
4208
- lastRan = time();
4209
- }, limit - (now - lastRan));
4210
- }
4211
- };
4212
- }
4213
4077
 
4214
- // lib/get-frame.ts
4078
+ // lib/remove.ts
4215
4079
  init_react_import();
4216
- var getFrame = () => {
4217
- if (typeof window === "undefined") return;
4218
- let frameEl = document.querySelector("#preview-frame");
4219
- if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
4220
- return frameEl.contentDocument || document;
4221
- }
4222
- return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
4080
+ var remove = (list, index) => {
4081
+ const result = Array.from(list);
4082
+ result.splice(index, 1);
4083
+ return result;
4223
4084
  };
4224
4085
 
4225
- // lib/global-position.ts
4086
+ // lib/reduce-related-zones.ts
4226
4087
  init_react_import();
4227
- var GlobalPosition = class {
4228
- constructor(target, original) {
4229
- this.scaleFactor = 1;
4230
- this.frameEl = null;
4231
- this.frameRect = null;
4232
- var _a;
4233
- this.target = target;
4234
- this.original = original;
4235
- this.frameEl = document.querySelector("iframe");
4236
- if (this.frameEl) {
4237
- this.frameRect = this.frameEl.getBoundingClientRect();
4238
- this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
4239
- }
4240
- }
4241
- get x() {
4242
- return this.original.x;
4243
- }
4244
- get y() {
4245
- return this.original.y;
4088
+ function reduceRelatedZones(item, data, fn) {
4089
+ return __spreadProps(__spreadValues({}, data), {
4090
+ zones: Object.keys(data.zones || {}).reduce(
4091
+ (acc, key) => {
4092
+ const [parentId] = getZoneId(key);
4093
+ if (parentId === item.props.id) {
4094
+ const zones = data.zones;
4095
+ return fn(acc, key, zones[key]);
4096
+ }
4097
+ return __spreadProps(__spreadValues({}, acc), { [key]: data.zones[key] });
4098
+ },
4099
+ {}
4100
+ )
4101
+ });
4102
+ }
4103
+ var findRelatedByZoneId = (zoneId, data) => {
4104
+ const [zoneParentId] = getZoneId(zoneId);
4105
+ return (data.zones[zoneId] || []).reduce(
4106
+ (acc, zoneItem) => {
4107
+ const related = findRelatedByItem(zoneItem, data);
4108
+ if (zoneItem.props.id === zoneParentId) {
4109
+ return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
4110
+ }
4111
+ return __spreadValues(__spreadValues({}, acc), related);
4112
+ },
4113
+ {}
4114
+ );
4115
+ };
4116
+ var findRelatedByItem = (item, data) => {
4117
+ return Object.keys(data.zones || {}).reduce(
4118
+ (acc, zoneId) => {
4119
+ const [zoneParentId] = getZoneId(zoneId);
4120
+ if (item.props.id === zoneParentId) {
4121
+ const related = findRelatedByZoneId(zoneId, data);
4122
+ return __spreadProps(__spreadValues(__spreadValues({}, acc), related), {
4123
+ [zoneId]: data.zones[zoneId]
4124
+ });
4125
+ }
4126
+ return acc;
4127
+ },
4128
+ {}
4129
+ );
4130
+ };
4131
+ var removeRelatedZones = (item, data) => {
4132
+ const newData = __spreadValues({}, data);
4133
+ const related = findRelatedByItem(item, data);
4134
+ Object.keys(related).forEach((key) => {
4135
+ delete newData.zones[key];
4136
+ });
4137
+ return newData;
4138
+ };
4139
+ function duplicateRelatedZones(item, data, newId) {
4140
+ return reduceRelatedZones(item, data, (acc, key, zone) => {
4141
+ const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
4142
+ props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
4143
+ }));
4144
+ const dupeOfDupes = dupedZone.reduce(
4145
+ (dupeOfDupes2, item2, index) => __spreadValues(__spreadValues({}, dupeOfDupes2), duplicateRelatedZones(zone[index], data, item2.props.id).zones),
4146
+ acc
4147
+ );
4148
+ const [_, zoneId] = getZoneId(key);
4149
+ return __spreadProps(__spreadValues({}, dupeOfDupes), {
4150
+ [key]: zone,
4151
+ [`${newId}:${zoneId}`]: dupedZone
4152
+ });
4153
+ });
4154
+ }
4155
+
4156
+ // reducer/data.ts
4157
+ var zoneCache = {};
4158
+ var addToZoneCache = (key, data) => {
4159
+ zoneCache[key] = data;
4160
+ };
4161
+ var replaceAction = (data, action) => {
4162
+ if (action.destinationZone === rootDroppableId) {
4163
+ return __spreadProps(__spreadValues({}, data), {
4164
+ content: replace(data.content, action.destinationIndex, action.data)
4165
+ });
4246
4166
  }
4247
- get global() {
4248
- if (document !== this.target.ownerDocument && this.frameRect) {
4249
- return {
4250
- x: this.x * this.scaleFactor + this.frameRect.left,
4251
- y: this.y * this.scaleFactor + this.frameRect.top
4252
- };
4253
- }
4254
- return this.original;
4167
+ const newData = setupZone(data, action.destinationZone);
4168
+ return __spreadProps(__spreadValues({}, newData), {
4169
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
4170
+ [action.destinationZone]: replace(
4171
+ newData.zones[action.destinationZone],
4172
+ action.destinationIndex,
4173
+ action.data
4174
+ )
4175
+ })
4176
+ });
4177
+ };
4178
+ function insertAction(data, action, config) {
4179
+ const emptyComponentData = {
4180
+ type: action.componentType,
4181
+ props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
4182
+ id: action.id || generateId(action.componentType)
4183
+ })
4184
+ };
4185
+ if (action.destinationZone === rootDroppableId) {
4186
+ return __spreadProps(__spreadValues({}, data), {
4187
+ content: insert(
4188
+ data.content,
4189
+ action.destinationIndex,
4190
+ emptyComponentData
4191
+ )
4192
+ });
4255
4193
  }
4256
- get frame() {
4257
- if (document === this.target.ownerDocument && this.frameRect) {
4258
- return {
4259
- x: (this.x - this.frameRect.left) / this.scaleFactor,
4260
- y: (this.y - this.frameRect.top) / this.scaleFactor
4261
- };
4262
- }
4263
- return this.original;
4194
+ const newData = setupZone(data, action.destinationZone);
4195
+ return __spreadProps(__spreadValues({}, data), {
4196
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
4197
+ [action.destinationZone]: insert(
4198
+ newData.zones[action.destinationZone],
4199
+ action.destinationIndex,
4200
+ emptyComponentData
4201
+ )
4202
+ })
4203
+ });
4204
+ }
4205
+ var reorderAction = (data, action) => {
4206
+ if (action.destinationZone === rootDroppableId) {
4207
+ return __spreadProps(__spreadValues({}, data), {
4208
+ content: reorder(
4209
+ data.content,
4210
+ action.sourceIndex,
4211
+ action.destinationIndex
4212
+ )
4213
+ });
4264
4214
  }
4215
+ const newData = setupZone(data, action.destinationZone);
4216
+ return __spreadProps(__spreadValues({}, data), {
4217
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
4218
+ [action.destinationZone]: reorder(
4219
+ newData.zones[action.destinationZone],
4220
+ action.sourceIndex,
4221
+ action.destinationIndex
4222
+ )
4223
+ })
4224
+ });
4265
4225
  };
4266
-
4267
- // lib/bubble-pointer-event.ts
4268
- init_react_import();
4269
- var BaseEvent = typeof PointerEvent !== "undefined" ? PointerEvent : Event;
4270
- var BubbledPointerEvent = class extends BaseEvent {
4271
- constructor(type, data) {
4272
- super(type, data);
4273
- this._originalTarget = null;
4274
- this.originalTarget = data.originalTarget;
4226
+ function reduceData(data, action, config) {
4227
+ if (action.type === "insert") {
4228
+ return insertAction(data, action, config);
4275
4229
  }
4276
- // Necessary for Firefox
4277
- set originalTarget(target) {
4278
- this._originalTarget = target;
4230
+ if (action.type === "duplicate") {
4231
+ const item = getItem(
4232
+ { index: action.sourceIndex, zone: action.sourceZone },
4233
+ data
4234
+ );
4235
+ const newItem = __spreadProps(__spreadValues({}, item), {
4236
+ props: __spreadProps(__spreadValues({}, item.props), {
4237
+ id: generateId(item.type)
4238
+ })
4239
+ });
4240
+ const dataWithRelatedDuplicated = duplicateRelatedZones(
4241
+ item,
4242
+ data,
4243
+ newItem.props.id
4244
+ );
4245
+ if (action.sourceZone === rootDroppableId) {
4246
+ return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
4247
+ content: insert(data.content, action.sourceIndex + 1, newItem)
4248
+ });
4249
+ }
4250
+ return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
4251
+ zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
4252
+ [action.sourceZone]: insert(
4253
+ dataWithRelatedDuplicated.zones[action.sourceZone],
4254
+ action.sourceIndex + 1,
4255
+ newItem
4256
+ )
4257
+ })
4258
+ });
4279
4259
  }
4280
- // Necessary for Firefox
4281
- get originalTarget() {
4282
- return this._originalTarget;
4260
+ if (action.type === "reorder") {
4261
+ return reorderAction(data, action);
4283
4262
  }
4284
- };
4285
-
4286
- // lib/dnd/NestedDroppablePlugin.ts
4287
- var depthSort = (candidates) => {
4288
- return candidates.sort((a, b) => {
4289
- const aData = a.data;
4290
- const bData = b.data;
4291
- if (aData.depth > bData.depth) {
4292
- return 1;
4263
+ if (action.type === "move") {
4264
+ if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
4265
+ return data;
4293
4266
  }
4294
- if (bData.depth > aData.depth) {
4295
- return -1;
4267
+ const newData = setupZone(
4268
+ setupZone(data, action.sourceZone),
4269
+ action.destinationZone
4270
+ );
4271
+ const item = getItem(
4272
+ { zone: action.sourceZone, index: action.sourceIndex },
4273
+ newData
4274
+ );
4275
+ if (action.sourceZone === action.destinationZone) {
4276
+ return reorderAction(data, __spreadProps(__spreadValues({}, action), { type: "reorder" }));
4296
4277
  }
4297
- return 0;
4298
- });
4299
- };
4300
- var getZoneId2 = (candidate) => {
4301
- let id = candidate == null ? void 0 : candidate.id;
4302
- if (!candidate) return null;
4303
- if (candidate.type === "component") {
4304
- const data = candidate.data;
4305
- if (data.containsActiveZone) {
4306
- id = null;
4307
- } else {
4308
- id = data.zone;
4278
+ if (action.sourceZone === rootDroppableId) {
4279
+ return __spreadProps(__spreadValues({}, newData), {
4280
+ content: remove(newData.content, action.sourceIndex),
4281
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
4282
+ [action.destinationZone]: insert(
4283
+ newData.zones[action.destinationZone],
4284
+ action.destinationIndex,
4285
+ item
4286
+ )
4287
+ })
4288
+ });
4309
4289
  }
4310
- } else if (candidate.type === "void") {
4311
- return "void";
4312
- }
4313
- return id;
4314
- };
4315
- var getPointerCollisions = (position, manager) => {
4316
- const candidates = [];
4317
- let elements = position.target.ownerDocument.elementsFromPoint(
4318
- position.x,
4319
- position.y
4320
- );
4321
- const previewFrame = elements.find(
4322
- (el) => el.getAttribute("data-puck-preview")
4323
- );
4324
- const drawer = elements.find((el) => el.getAttribute("data-puck-drawer"));
4325
- if (drawer) {
4326
- elements = [drawer];
4327
- }
4328
- if (previewFrame) {
4329
- const frame = getFrame();
4330
- if (frame) {
4331
- elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
4290
+ if (action.destinationZone === rootDroppableId) {
4291
+ return __spreadProps(__spreadValues({}, newData), {
4292
+ content: insert(newData.content, action.destinationIndex, item),
4293
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
4294
+ [action.sourceZone]: remove(
4295
+ newData.zones[action.sourceZone],
4296
+ action.sourceIndex
4297
+ )
4298
+ })
4299
+ });
4332
4300
  }
4301
+ return __spreadProps(__spreadValues({}, newData), {
4302
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
4303
+ [action.sourceZone]: remove(
4304
+ newData.zones[action.sourceZone],
4305
+ action.sourceIndex
4306
+ ),
4307
+ [action.destinationZone]: insert(
4308
+ newData.zones[action.destinationZone],
4309
+ action.destinationIndex,
4310
+ item
4311
+ )
4312
+ })
4313
+ });
4333
4314
  }
4334
- if (elements) {
4335
- for (let i = 0; i < elements.length; i++) {
4336
- const element = elements[i];
4337
- const dropzoneId = element.getAttribute("data-puck-dropzone");
4338
- if (dropzoneId) {
4339
- const droppable = manager.registry.droppables.get(dropzoneId);
4340
- if (droppable) {
4341
- candidates.push(droppable);
4342
- }
4343
- }
4344
- const id = element.getAttribute("data-puck-dnd");
4345
- if (id) {
4346
- const droppable = manager.registry.droppables.get(id);
4347
- if (droppable) {
4348
- candidates.push(droppable);
4349
- }
4350
- }
4351
- }
4315
+ if (action.type === "replace") {
4316
+ return replaceAction(data, action);
4352
4317
  }
4353
- return candidates;
4354
- };
4355
- var findDeepestCandidate = (position, manager) => {
4356
- var _a;
4357
- const candidates = getPointerCollisions(position, manager);
4358
- if (candidates.length > 0) {
4359
- const sortedCandidates = depthSort(candidates);
4360
- const draggable = manager.dragOperation.source;
4361
- const draggedCandidateIndex = sortedCandidates.findIndex(
4362
- (candidate) => candidate.id === (draggable == null ? void 0 : draggable.id)
4318
+ if (action.type === "remove") {
4319
+ const item = getItem({ index: action.index, zone: action.zone }, data);
4320
+ const dataWithRelatedRemoved = setupZone(
4321
+ removeRelatedZones(item, data),
4322
+ action.zone
4363
4323
  );
4364
- const draggedCandidateId = draggable == null ? void 0 : draggable.id;
4365
- let filteredCandidates = [...sortedCandidates];
4366
- if (draggedCandidateId && draggedCandidateIndex > -1) {
4367
- filteredCandidates.splice(draggedCandidateIndex, 1);
4324
+ if (action.zone === rootDroppableId) {
4325
+ return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
4326
+ content: remove(data.content, action.index)
4327
+ });
4368
4328
  }
4369
- filteredCandidates = filteredCandidates.filter((candidate) => {
4370
- const candidateData = candidate.data;
4371
- if (draggedCandidateId && draggedCandidateIndex > -1) {
4372
- if (candidateData.path.indexOf(draggedCandidateId) > -1) {
4373
- return false;
4374
- }
4375
- }
4376
- if (candidate.type === "dropzone") {
4377
- const candidateData2 = candidate.data;
4378
- if (!candidateData2.isDroppableTarget) {
4379
- return false;
4380
- }
4381
- if (candidateData2.areaId === draggedCandidateId) {
4382
- return false;
4383
- }
4384
- } else if (candidate.type === "component") {
4385
- const candidateData2 = candidate.data;
4386
- if (!candidateData2.inDroppableZone) {
4387
- return false;
4388
- }
4389
- }
4390
- return true;
4329
+ return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
4330
+ zones: __spreadProps(__spreadValues({}, dataWithRelatedRemoved.zones), {
4331
+ [action.zone]: remove(
4332
+ dataWithRelatedRemoved.zones[action.zone],
4333
+ action.index
4334
+ )
4335
+ })
4391
4336
  });
4392
- filteredCandidates.reverse();
4393
- const zone = getZoneId2(filteredCandidates[0]);
4394
- const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
4395
- return { zone, area };
4396
4337
  }
4397
- return {
4398
- zone: "default-zone",
4399
- area: null
4400
- };
4401
- };
4402
- var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
4403
- constructor(manager, options) {
4404
- super(manager);
4405
- if (typeof window === "undefined") {
4406
- return;
4407
- }
4408
- const cleanupEffect = effects(() => {
4409
- const handleMove = (event) => {
4410
- const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
4411
- const position = new GlobalPosition(target, {
4412
- x: event.clientX,
4413
- y: event.clientY
4414
- });
4415
- const elements = document.elementsFromPoint(
4416
- position.global.x,
4417
- position.global.y
4418
- );
4419
- const overEl = elements.some((el) => el.id === id);
4420
- if (overEl) {
4421
- onChange(findDeepestCandidate(position, manager), manager);
4422
- }
4423
- };
4424
- const handleMoveThrottled = throttle(handleMove, 50);
4425
- const handlePointerMove = (event) => {
4426
- handleMoveThrottled(event);
4427
- };
4428
- document.body.addEventListener("pointermove", handlePointerMove, {
4429
- capture: true
4430
- // dndkit's PointerSensor prevents propagation during drag
4338
+ if (action.type === "registerZone") {
4339
+ if (zoneCache[action.zone]) {
4340
+ return __spreadProps(__spreadValues({}, data), {
4341
+ zones: __spreadProps(__spreadValues({}, data.zones), {
4342
+ [action.zone]: zoneCache[action.zone]
4343
+ })
4431
4344
  });
4432
- this.destroy = () => {
4433
- document.body.removeEventListener("pointermove", handlePointerMove, {
4434
- capture: true
4435
- });
4436
- cleanupEffect();
4437
- };
4345
+ }
4346
+ return setupZone(data, action.zone);
4347
+ }
4348
+ if (action.type === "unregisterZone") {
4349
+ const _zones = __spreadValues({}, data.zones || {});
4350
+ if (_zones[action.zone]) {
4351
+ zoneCache[action.zone] = _zones[action.zone];
4352
+ delete _zones[action.zone];
4353
+ }
4354
+ return __spreadProps(__spreadValues({}, data), { zones: _zones });
4355
+ }
4356
+ if (action.type === "setData") {
4357
+ if (typeof action.data === "object") {
4358
+ return __spreadValues(__spreadValues({}, data), action.data);
4359
+ }
4360
+ return __spreadValues(__spreadValues({}, data), action.data(data));
4361
+ }
4362
+ return data;
4363
+ }
4364
+
4365
+ // reducer/state.ts
4366
+ init_react_import();
4367
+ var reduceUi = (ui, action) => {
4368
+ if (action.type === "setUi") {
4369
+ if (typeof action.ui === "object") {
4370
+ return __spreadValues(__spreadValues({}, ui), action.ui);
4371
+ }
4372
+ return __spreadValues(__spreadValues({}, ui), action.ui(ui));
4373
+ }
4374
+ if (action.type === "duplicate") {
4375
+ return __spreadProps(__spreadValues({}, ui), {
4376
+ itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4377
+ });
4378
+ }
4379
+ if (action.type === "remove") {
4380
+ return __spreadProps(__spreadValues({}, ui), {
4381
+ itemSelector: null
4438
4382
  });
4439
4383
  }
4384
+ return ui;
4440
4385
  };
4441
4386
 
4442
- // lib/insert-component.ts
4387
+ // reducer/actions.tsx
4443
4388
  init_react_import();
4444
4389
 
4445
4390
  // reducer/index.ts
4446
- init_react_import();
4447
-
4448
- // reducer/data.ts
4449
- init_react_import();
4450
-
4451
- // lib/remove.ts
4452
- init_react_import();
4453
- var remove = (list, index) => {
4454
- const result = Array.from(list);
4455
- result.splice(index, 1);
4456
- return result;
4457
- };
4458
-
4459
- // lib/reduce-related-zones.ts
4460
- init_react_import();
4461
- function reduceRelatedZones(item, data, fn) {
4462
- return __spreadProps(__spreadValues({}, data), {
4463
- zones: Object.keys(data.zones || {}).reduce(
4464
- (acc, key) => {
4465
- const [parentId] = getZoneId(key);
4466
- if (parentId === item.props.id) {
4467
- const zones = data.zones;
4468
- return fn(acc, key, zones[key]);
4469
- }
4470
- return __spreadProps(__spreadValues({}, acc), { [key]: data.zones[key] });
4471
- },
4472
- {}
4473
- )
4474
- });
4391
+ function storeInterceptor(reducer, record, onAction) {
4392
+ return (state, action) => {
4393
+ const newAppState = reducer(state, action);
4394
+ const isValidType = ![
4395
+ "registerZone",
4396
+ "unregisterZone",
4397
+ "setData",
4398
+ "setUi",
4399
+ "set"
4400
+ ].includes(action.type);
4401
+ if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
4402
+ if (record) record(newAppState);
4403
+ }
4404
+ onAction == null ? void 0 : onAction(action, newAppState, state);
4405
+ return newAppState;
4406
+ };
4475
4407
  }
4476
- var findRelatedByZoneId = (zoneId, data) => {
4477
- const [zoneParentId] = getZoneId(zoneId);
4478
- return (data.zones[zoneId] || []).reduce(
4479
- (acc, zoneItem) => {
4480
- const related = findRelatedByItem(zoneItem, data);
4481
- if (zoneItem.props.id === zoneParentId) {
4482
- return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
4483
- }
4484
- return __spreadValues(__spreadValues({}, acc), related);
4485
- },
4486
- {}
4487
- );
4408
+ var setAction = (state, action) => {
4409
+ if (typeof action.state === "object") {
4410
+ return __spreadValues(__spreadValues({}, state), action.state);
4411
+ }
4412
+ return __spreadValues(__spreadValues({}, state), action.state(state));
4488
4413
  };
4489
- var findRelatedByItem = (item, data) => {
4490
- return Object.keys(data.zones || {}).reduce(
4491
- (acc, zoneId) => {
4492
- const [zoneParentId] = getZoneId(zoneId);
4493
- if (item.props.id === zoneParentId) {
4494
- const related = findRelatedByZoneId(zoneId, data);
4495
- return __spreadProps(__spreadValues(__spreadValues({}, acc), related), {
4496
- [zoneId]: data.zones[zoneId]
4497
- });
4414
+ function createReducer({
4415
+ config,
4416
+ record,
4417
+ onAction
4418
+ }) {
4419
+ return storeInterceptor(
4420
+ (state, action) => {
4421
+ const data = reduceData(state.data, action, config);
4422
+ const ui = reduceUi(state.ui, action);
4423
+ if (action.type === "set") {
4424
+ return setAction(state, action);
4498
4425
  }
4499
- return acc;
4426
+ return { data, ui };
4500
4427
  },
4501
- {}
4428
+ record,
4429
+ onAction
4502
4430
  );
4503
- };
4504
- var removeRelatedZones = (item, data) => {
4505
- const newData = __spreadValues({}, data);
4506
- const related = findRelatedByItem(item, data);
4507
- Object.keys(related).forEach((key) => {
4508
- delete newData.zones[key];
4509
- });
4510
- return newData;
4511
- };
4512
- function duplicateRelatedZones(item, data, newId) {
4513
- return reduceRelatedZones(item, data, (acc, key, zone) => {
4514
- const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
4515
- props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
4516
- }));
4517
- const dupeOfDupes = dupedZone.reduce(
4518
- (dupeOfDupes2, item2, index) => __spreadValues(__spreadValues({}, dupeOfDupes2), duplicateRelatedZones(zone[index], data, item2.props.id).zones),
4519
- acc
4520
- );
4521
- const [_, zoneId] = getZoneId(key);
4522
- return __spreadProps(__spreadValues({}, dupeOfDupes), {
4523
- [key]: zone,
4524
- [`${newId}:${zoneId}`]: dupedZone
4525
- });
4526
- });
4527
4431
  }
4528
4432
 
4529
- // reducer/data.ts
4530
- var zoneCache = {};
4531
- var addToZoneCache = (key, data) => {
4532
- zoneCache[key] = data;
4533
- };
4534
- var replaceAction = (data, action) => {
4535
- if (action.destinationZone === rootDroppableId) {
4536
- return __spreadProps(__spreadValues({}, data), {
4537
- content: replace(data.content, action.destinationIndex, action.data)
4538
- });
4539
- }
4540
- const newData = setupZone(data, action.destinationZone);
4541
- return __spreadProps(__spreadValues({}, newData), {
4542
- zones: __spreadProps(__spreadValues({}, newData.zones), {
4543
- [action.destinationZone]: replace(
4544
- newData.zones[action.destinationZone],
4545
- action.destinationIndex,
4546
- action.data
4547
- )
4548
- })
4433
+ // lib/insert-component.ts
4434
+ var insertComponent = (componentType, zone, index, {
4435
+ config,
4436
+ dispatch,
4437
+ resolveData,
4438
+ state
4439
+ }) => {
4440
+ const id = generateId(componentType);
4441
+ const insertActionData = {
4442
+ type: "insert",
4443
+ componentType,
4444
+ destinationIndex: index,
4445
+ destinationZone: zone,
4446
+ id
4447
+ };
4448
+ const insertedData = insertAction(state.data, insertActionData, config);
4449
+ dispatch(__spreadProps(__spreadValues({}, insertActionData), {
4450
+ // Dispatch insert rather set, as user's may rely on this via onAction
4451
+ // We must always record history here so the insert is added to user history
4452
+ // If the user has defined a resolveData method, they will end up with 2 history
4453
+ // entries on insert - one for the initial insert, and one when the data resolves
4454
+ recordHistory: true
4455
+ }));
4456
+ const itemSelector = {
4457
+ index,
4458
+ zone
4459
+ };
4460
+ dispatch({ type: "setUi", ui: { itemSelector } });
4461
+ resolveData({
4462
+ data: insertedData,
4463
+ ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector })
4549
4464
  });
4550
4465
  };
4551
- function insertAction(data, action, config) {
4552
- const emptyComponentData = {
4553
- type: action.componentType,
4554
- props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
4555
- id: action.id || generateId(action.componentType)
4556
- })
4557
- };
4558
- if (action.destinationZone === rootDroppableId) {
4559
- return __spreadProps(__spreadValues({}, data), {
4560
- content: insert(
4561
- data.content,
4562
- action.destinationIndex,
4563
- emptyComponentData
4564
- )
4466
+
4467
+ // components/DragDropContext/index.tsx
4468
+ import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
4469
+ import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
4470
+
4471
+ // lib/dnd/PointerSensor.ts
4472
+ init_react_import();
4473
+ import { batch, effect } from "@dnd-kit/state";
4474
+ import { Sensor, configurator } from "@dnd-kit/abstract";
4475
+ import {
4476
+ exceedsDistance
4477
+ } from "@dnd-kit/geometry";
4478
+ import {
4479
+ getDocument,
4480
+ isElement,
4481
+ isHTMLElement,
4482
+ isPointerEvent,
4483
+ Listeners,
4484
+ getFrameTransform
4485
+ } from "@dnd-kit/dom/utilities";
4486
+ var _clearTimeout;
4487
+ var _PointerSensor = class _PointerSensor extends Sensor {
4488
+ constructor(manager, options) {
4489
+ super(manager);
4490
+ this.manager = manager;
4491
+ this.options = options;
4492
+ this.listeners = new Listeners();
4493
+ this.cleanup = /* @__PURE__ */ new Set();
4494
+ this.source = void 0;
4495
+ __privateAdd(this, _clearTimeout);
4496
+ this.handleCancel = this.handleCancel.bind(this);
4497
+ this.handlePointerUp = this.handlePointerUp.bind(this);
4498
+ this.handleKeyDown = this.handleKeyDown.bind(this);
4499
+ effect(() => {
4500
+ const unbindGlobal = this.bindGlobal(options != null ? options : {});
4501
+ return () => {
4502
+ unbindGlobal();
4503
+ };
4565
4504
  });
4566
4505
  }
4567
- const newData = setupZone(data, action.destinationZone);
4568
- return __spreadProps(__spreadValues({}, data), {
4569
- zones: __spreadProps(__spreadValues({}, newData.zones), {
4570
- [action.destinationZone]: insert(
4571
- newData.zones[action.destinationZone],
4572
- action.destinationIndex,
4573
- emptyComponentData
4574
- )
4575
- })
4576
- });
4577
- }
4578
- var reorderAction = (data, action) => {
4579
- if (action.destinationZone === rootDroppableId) {
4580
- return __spreadProps(__spreadValues({}, data), {
4581
- content: reorder(
4582
- data.content,
4583
- action.sourceIndex,
4584
- action.destinationIndex
4585
- )
4506
+ bind(source, options = this.options) {
4507
+ const unbind = effect(() => {
4508
+ var _a;
4509
+ const target = (_a = source.handle) != null ? _a : source.element;
4510
+ const listener = (event) => {
4511
+ if (isPointerEvent(event)) {
4512
+ this.handlePointerDown(event, source, options);
4513
+ }
4514
+ };
4515
+ if (target) {
4516
+ patchWindow(target.ownerDocument.defaultView);
4517
+ target.addEventListener("pointerdown", listener);
4518
+ return () => {
4519
+ target.removeEventListener("pointerdown", listener);
4520
+ };
4521
+ }
4586
4522
  });
4523
+ return unbind;
4587
4524
  }
4588
- const newData = setupZone(data, action.destinationZone);
4589
- return __spreadProps(__spreadValues({}, data), {
4590
- zones: __spreadProps(__spreadValues({}, newData.zones), {
4591
- [action.destinationZone]: reorder(
4592
- newData.zones[action.destinationZone],
4593
- action.sourceIndex,
4594
- action.destinationIndex
4595
- )
4596
- })
4597
- });
4598
- };
4599
- function reduceData(data, action, config) {
4600
- if (action.type === "insert") {
4601
- return insertAction(data, action, config);
4602
- }
4603
- if (action.type === "duplicate") {
4604
- const item = getItem(
4605
- { index: action.sourceIndex, zone: action.sourceZone },
4606
- data
4607
- );
4608
- const newItem = __spreadProps(__spreadValues({}, item), {
4609
- props: __spreadProps(__spreadValues({}, item.props), {
4610
- id: generateId(item.type)
4611
- })
4612
- });
4613
- const dataWithRelatedDuplicated = duplicateRelatedZones(
4614
- item,
4615
- data,
4616
- newItem.props.id
4617
- );
4618
- if (action.sourceZone === rootDroppableId) {
4619
- return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
4620
- content: insert(data.content, action.sourceIndex + 1, newItem)
4621
- });
4525
+ bindGlobal(options) {
4526
+ const documents = /* @__PURE__ */ new Set();
4527
+ for (const draggable of this.manager.registry.draggables.value) {
4528
+ if (draggable.element) {
4529
+ documents.add(getDocument(draggable.element));
4530
+ }
4622
4531
  }
4623
- return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
4624
- zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
4625
- [action.sourceZone]: insert(
4626
- dataWithRelatedDuplicated.zones[action.sourceZone],
4627
- action.sourceIndex + 1,
4628
- newItem
4629
- )
4630
- })
4631
- });
4532
+ for (const droppable of this.manager.registry.droppables.value) {
4533
+ if (droppable.element) {
4534
+ documents.add(getDocument(droppable.element));
4535
+ }
4536
+ }
4537
+ const unbindFns = Array.from(documents).map(
4538
+ (doc) => this.listeners.bind(doc, [
4539
+ {
4540
+ type: "pointermove",
4541
+ listener: (event) => this.handlePointerMove(event, doc, options)
4542
+ },
4543
+ {
4544
+ type: "pointerup",
4545
+ listener: this.handlePointerUp,
4546
+ options: {
4547
+ capture: true
4548
+ }
4549
+ },
4550
+ {
4551
+ // Cancel activation if there is a competing Drag and Drop interaction
4552
+ type: "dragstart",
4553
+ listener: this.handleDragStart
4554
+ }
4555
+ ])
4556
+ );
4557
+ return () => {
4558
+ unbindFns.forEach((unbind) => unbind());
4559
+ };
4632
4560
  }
4633
- if (action.type === "reorder") {
4634
- return reorderAction(data, action);
4561
+ handlePointerDown(event, source, options = {}) {
4562
+ if (this.disabled || !event.isPrimary || event.button !== 0 || !isElement(event.target) || source.disabled) {
4563
+ return;
4564
+ }
4565
+ const offset = getFrameTransform(source.element);
4566
+ this.initialCoordinates = {
4567
+ x: event.clientX * offset.scaleX + offset.x,
4568
+ y: event.clientY * offset.scaleY + offset.y
4569
+ };
4570
+ this.source = source;
4571
+ const { activationConstraints } = options;
4572
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
4573
+ event.stopImmediatePropagation();
4574
+ if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
4575
+ this.handleStart(source, event);
4576
+ } else {
4577
+ const { delay } = constraints;
4578
+ if (delay) {
4579
+ const timeout3 = setTimeout(
4580
+ () => this.handleStart(source, event),
4581
+ delay.value
4582
+ );
4583
+ __privateSet(this, _clearTimeout, () => {
4584
+ clearTimeout(timeout3);
4585
+ __privateSet(this, _clearTimeout, void 0);
4586
+ });
4587
+ }
4588
+ }
4589
+ const cleanup = () => {
4590
+ var _a;
4591
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
4592
+ this.initialCoordinates = void 0;
4593
+ this.source = void 0;
4594
+ };
4595
+ this.cleanup.add(cleanup);
4635
4596
  }
4636
- if (action.type === "move") {
4637
- if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
4638
- return data;
4597
+ handlePointerMove(event, doc, options) {
4598
+ if (!this.source) {
4599
+ return;
4639
4600
  }
4640
- const newData = setupZone(
4641
- setupZone(data, action.sourceZone),
4642
- action.destinationZone
4643
- );
4644
- const item = getItem(
4645
- { zone: action.sourceZone, index: action.sourceIndex },
4646
- newData
4647
- );
4648
- if (action.sourceZone === action.destinationZone) {
4649
- return reorderAction(data, __spreadProps(__spreadValues({}, action), { type: "reorder" }));
4601
+ const ownerDocument = this.source.element && getDocument(this.source.element);
4602
+ if (doc !== ownerDocument) {
4603
+ return;
4650
4604
  }
4651
- if (action.sourceZone === rootDroppableId) {
4652
- return __spreadProps(__spreadValues({}, newData), {
4653
- content: remove(newData.content, action.sourceIndex),
4654
- zones: __spreadProps(__spreadValues({}, newData.zones), {
4655
- [action.destinationZone]: insert(
4656
- newData.zones[action.destinationZone],
4657
- action.destinationIndex,
4658
- item
4659
- )
4660
- })
4661
- });
4605
+ const coordinates = {
4606
+ x: event.clientX,
4607
+ y: event.clientY
4608
+ };
4609
+ const offset = getFrameTransform(this.source.element);
4610
+ coordinates.x = coordinates.x * offset.scaleX + offset.x;
4611
+ coordinates.y = coordinates.y * offset.scaleY + offset.y;
4612
+ if (this.manager.dragOperation.status.dragging) {
4613
+ event.preventDefault();
4614
+ event.stopPropagation();
4615
+ this.manager.actions.move({ to: coordinates });
4616
+ return;
4662
4617
  }
4663
- if (action.destinationZone === rootDroppableId) {
4664
- return __spreadProps(__spreadValues({}, newData), {
4665
- content: insert(newData.content, action.destinationIndex, item),
4666
- zones: __spreadProps(__spreadValues({}, newData.zones), {
4667
- [action.sourceZone]: remove(
4668
- newData.zones[action.sourceZone],
4669
- action.sourceIndex
4670
- )
4671
- })
4672
- });
4618
+ if (!this.initialCoordinates) {
4619
+ return;
4673
4620
  }
4674
- return __spreadProps(__spreadValues({}, newData), {
4675
- zones: __spreadProps(__spreadValues({}, newData.zones), {
4676
- [action.sourceZone]: remove(
4677
- newData.zones[action.sourceZone],
4678
- action.sourceIndex
4679
- ),
4680
- [action.destinationZone]: insert(
4681
- newData.zones[action.destinationZone],
4682
- action.destinationIndex,
4683
- item
4684
- )
4685
- })
4686
- });
4687
- }
4688
- if (action.type === "replace") {
4689
- return replaceAction(data, action);
4690
- }
4691
- if (action.type === "remove") {
4692
- const item = getItem({ index: action.index, zone: action.zone }, data);
4693
- const dataWithRelatedRemoved = setupZone(
4694
- removeRelatedZones(item, data),
4695
- action.zone
4696
- );
4697
- if (action.zone === rootDroppableId) {
4698
- return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
4699
- content: remove(data.content, action.index)
4700
- });
4621
+ const delta = {
4622
+ x: coordinates.x - this.initialCoordinates.x,
4623
+ y: coordinates.y - this.initialCoordinates.y
4624
+ };
4625
+ const { activationConstraints } = options;
4626
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
4627
+ const { distance, delay } = constraints != null ? constraints : {};
4628
+ if (distance) {
4629
+ if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
4630
+ return this.handleCancel();
4631
+ }
4632
+ if (exceedsDistance(delta, distance.value)) {
4633
+ return this.handleStart(this.source, event);
4634
+ }
4635
+ }
4636
+ if (delay) {
4637
+ if (exceedsDistance(delta, delay.tolerance)) {
4638
+ return this.handleCancel();
4639
+ }
4701
4640
  }
4702
- return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
4703
- zones: __spreadProps(__spreadValues({}, dataWithRelatedRemoved.zones), {
4704
- [action.zone]: remove(
4705
- dataWithRelatedRemoved.zones[action.zone],
4706
- action.index
4707
- )
4708
- })
4709
- });
4710
4641
  }
4711
- if (action.type === "registerZone") {
4712
- if (zoneCache[action.zone]) {
4713
- return __spreadProps(__spreadValues({}, data), {
4714
- zones: __spreadProps(__spreadValues({}, data.zones), {
4715
- [action.zone]: zoneCache[action.zone]
4716
- })
4717
- });
4642
+ handlePointerUp(event) {
4643
+ if (!this.source) {
4644
+ return;
4718
4645
  }
4719
- return setupZone(data, action.zone);
4720
- }
4721
- if (action.type === "unregisterZone") {
4722
- const _zones = __spreadValues({}, data.zones || {});
4723
- if (_zones[action.zone]) {
4724
- zoneCache[action.zone] = _zones[action.zone];
4725
- delete _zones[action.zone];
4646
+ event.preventDefault();
4647
+ event.stopPropagation();
4648
+ const { status } = this.manager.dragOperation;
4649
+ if (!status.idle) {
4650
+ const canceled = !status.initialized;
4651
+ this.manager.actions.stop({ canceled });
4726
4652
  }
4727
- return __spreadProps(__spreadValues({}, data), { zones: _zones });
4653
+ this.cleanup.forEach((cleanup) => cleanup());
4654
+ this.cleanup.clear();
4728
4655
  }
4729
- if (action.type === "setData") {
4730
- if (typeof action.data === "object") {
4731
- return __spreadValues(__spreadValues({}, data), action.data);
4656
+ handleKeyDown(event) {
4657
+ if (event.key === "Escape") {
4658
+ event.preventDefault();
4659
+ this.handleCancel();
4732
4660
  }
4733
- return __spreadValues(__spreadValues({}, data), action.data(data));
4734
4661
  }
4735
- return data;
4736
- }
4737
-
4738
- // reducer/state.ts
4739
- init_react_import();
4740
- var reduceUi = (ui, action) => {
4741
- if (action.type === "setUi") {
4742
- if (typeof action.ui === "object") {
4743
- return __spreadValues(__spreadValues({}, ui), action.ui);
4662
+ handleStart(source, event) {
4663
+ var _a;
4664
+ const { manager, initialCoordinates } = this;
4665
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
4666
+ if (!initialCoordinates || manager.dragOperation.status.initialized) {
4667
+ return;
4744
4668
  }
4745
- return __spreadValues(__spreadValues({}, ui), action.ui(ui));
4746
- }
4747
- if (action.type === "duplicate") {
4748
- return __spreadProps(__spreadValues({}, ui), {
4749
- itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4669
+ if (event.defaultPrevented) {
4670
+ return;
4671
+ }
4672
+ event.preventDefault();
4673
+ batch(() => {
4674
+ manager.actions.setDragSource(source.id);
4675
+ manager.actions.start({ coordinates: initialCoordinates, event });
4750
4676
  });
4677
+ const ownerDocument = getDocument(event.target);
4678
+ const unbind = this.listeners.bind(ownerDocument, [
4679
+ {
4680
+ // Prevent scrolling on touch devices
4681
+ type: "touchmove",
4682
+ listener: preventDefault,
4683
+ options: {
4684
+ passive: false
4685
+ }
4686
+ },
4687
+ {
4688
+ // Prevent click events
4689
+ type: "click",
4690
+ listener: preventDefault
4691
+ },
4692
+ {
4693
+ type: "keydown",
4694
+ listener: this.handleKeyDown
4695
+ }
4696
+ ]);
4697
+ ownerDocument.body.setPointerCapture(event.pointerId);
4698
+ this.cleanup.add(unbind);
4751
4699
  }
4752
- if (action.type === "remove") {
4753
- return __spreadProps(__spreadValues({}, ui), {
4754
- itemSelector: null
4755
- });
4700
+ handleDragStart(event) {
4701
+ const { target } = event;
4702
+ if (!isElement(target)) {
4703
+ return;
4704
+ }
4705
+ const isNativeDraggable = isHTMLElement(target) && target.draggable && target.getAttribute("draggable") === "true";
4706
+ if (isNativeDraggable) {
4707
+ this.handleCancel();
4708
+ } else {
4709
+ preventDefault(event);
4710
+ }
4756
4711
  }
4757
- return ui;
4758
- };
4759
-
4760
- // reducer/actions.tsx
4761
- init_react_import();
4762
-
4763
- // reducer/index.ts
4764
- function storeInterceptor(reducer, record, onAction) {
4765
- return (state, action) => {
4766
- const newAppState = reducer(state, action);
4767
- const isValidType = ![
4768
- "registerZone",
4769
- "unregisterZone",
4770
- "setData",
4771
- "setUi",
4772
- "set"
4773
- ].includes(action.type);
4774
- if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
4775
- if (record) record(newAppState);
4712
+ handleCancel() {
4713
+ const { dragOperation } = this.manager;
4714
+ if (dragOperation.status.initialized) {
4715
+ this.manager.actions.stop({ canceled: true });
4776
4716
  }
4777
- onAction == null ? void 0 : onAction(action, newAppState, state);
4778
- return newAppState;
4779
- };
4780
- }
4781
- var setAction = (state, action) => {
4782
- if (typeof action.state === "object") {
4783
- return __spreadValues(__spreadValues({}, state), action.state);
4717
+ this.cleanup.forEach((cleanup) => cleanup());
4718
+ this.cleanup.clear();
4719
+ }
4720
+ destroy() {
4721
+ this.listeners.clear();
4784
4722
  }
4785
- return __spreadValues(__spreadValues({}, state), action.state(state));
4786
4723
  };
4787
- function createReducer({
4788
- config,
4789
- record,
4790
- onAction
4791
- }) {
4792
- return storeInterceptor(
4793
- (state, action) => {
4794
- const data = reduceData(state.data, action, config);
4795
- const ui = reduceUi(state.ui, action);
4796
- if (action.type === "set") {
4797
- return setAction(state, action);
4798
- }
4799
- return { data, ui };
4800
- },
4801
- record,
4802
- onAction
4803
- );
4724
+ _clearTimeout = new WeakMap();
4725
+ _PointerSensor.configure = configurator(_PointerSensor);
4726
+ var PointerSensor = _PointerSensor;
4727
+ function preventDefault(event) {
4728
+ event.preventDefault();
4804
4729
  }
4805
-
4806
- // lib/insert-component.ts
4807
- var insertComponent = (componentType, zone, index, {
4808
- config,
4809
- dispatch,
4810
- resolveData,
4811
- state
4812
- }) => {
4813
- const id = generateId(componentType);
4814
- const insertActionData = {
4815
- type: "insert",
4816
- componentType,
4817
- destinationIndex: index,
4818
- destinationZone: zone,
4819
- id
4820
- };
4821
- const insertedData = insertAction(state.data, insertActionData, config);
4822
- dispatch(__spreadProps(__spreadValues({}, insertActionData), {
4823
- // Dispatch insert rather set, as user's may rely on this via onAction
4824
- // We must always record history here so the insert is added to user history
4825
- // If the user has defined a resolveData method, they will end up with 2 history
4826
- // entries on insert - one for the initial insert, and one when the data resolves
4827
- recordHistory: true
4828
- }));
4829
- const itemSelector = {
4830
- index,
4831
- zone
4832
- };
4833
- dispatch({ type: "setUi", ui: { itemSelector } });
4834
- resolveData({
4835
- data: insertedData,
4836
- ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector })
4837
- });
4838
- };
4839
-
4840
- // components/DragDropContext/index.tsx
4841
- import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
4842
- import { createStore as createStore3 } from "zustand";
4843
-
4844
- // lib/get-deep-dir.ts
4845
- init_react_import();
4846
- function getDeepDir(el) {
4847
- function findDir(node) {
4848
- if (!node) return "ltr";
4849
- const d = node.getAttribute("dir");
4850
- return d || findDir(node.parentElement);
4730
+ function noop() {
4731
+ }
4732
+ var windows = /* @__PURE__ */ new WeakSet();
4733
+ function patchWindow(window2) {
4734
+ if (!window2 || windows.has(window2)) {
4735
+ return;
4851
4736
  }
4852
- return el ? findDir(el) : "ltr";
4737
+ window2.addEventListener("touchmove", noop, {
4738
+ capture: false,
4739
+ passive: false
4740
+ });
4741
+ windows.add(window2);
4853
4742
  }
4854
4743
 
4855
4744
  // components/DragDropContext/index.tsx
4745
+ import { createStore as createStore3 } from "zustand";
4856
4746
  import { jsx as jsx23 } from "react/jsx-runtime";
4857
4747
  var DEBUG3 = false;
4858
4748
  var dragListenerContext = createContext4({
@@ -4892,7 +4782,7 @@ var DragDropContextClient = ({
4892
4782
  const { data } = state;
4893
4783
  const debouncedParamsRef = useRef3(null);
4894
4784
  const tempDisableFallback = useTempDisableFallback(100);
4895
- const [zoneStore] = useState18(
4785
+ const [zoneStore] = useState17(
4896
4786
  () => createStore3(() => ({
4897
4787
  zoneDepthIndex: {},
4898
4788
  nextZoneDepthIndex: {},
@@ -4961,7 +4851,7 @@ var DragDropContextClient = ({
4961
4851
  );
4962
4852
  }
4963
4853
  }, []);
4964
- const [plugins] = useState18(() => [
4854
+ const [plugins] = useState17(() => [
4965
4855
  ...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
4966
4856
  createNestedDroppablePlugin(
4967
4857
  {
@@ -5008,9 +4898,27 @@ var DragDropContextClient = ({
5008
4898
  id
5009
4899
  )
5010
4900
  ]);
5011
- const sensors = useSensors();
5012
- const [dragListeners, setDragListeners] = useState18({});
5013
- const [pathData, setPathData] = useState18();
4901
+ const [sensors] = useState17(() => [
4902
+ PointerSensor.configure({
4903
+ activationConstraints(event, source) {
4904
+ var _a;
4905
+ const { pointerType, target } = event;
4906
+ if (pointerType === "mouse" && isElement2(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
4907
+ return void 0;
4908
+ }
4909
+ const delay = { value: 200, tolerance: 10 };
4910
+ if (pointerType === "touch") {
4911
+ return { delay };
4912
+ }
4913
+ return {
4914
+ delay,
4915
+ distance: { value: 5 }
4916
+ };
4917
+ }
4918
+ })
4919
+ ]);
4920
+ const [dragListeners, setDragListeners] = useState17({});
4921
+ const [pathData, setPathData] = useState17();
5014
4922
  const dragMode = useRef3(null);
5015
4923
  const registerPath = useCallback11(
5016
4924
  (id2, selector, label) => {
@@ -5071,13 +4979,6 @@ var DragDropContextClient = ({
5071
4979
  (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
5072
4980
  fn(event, manager);
5073
4981
  });
5074
- dispatch({
5075
- type: "setUi",
5076
- ui: {
5077
- itemSelector: null,
5078
- isDragging: false
5079
- }
5080
- });
5081
4982
  return;
5082
4983
  }
5083
4984
  if (thisPreview) {
@@ -5135,8 +5036,7 @@ var DragDropContextClient = ({
5135
5036
  targetZone = targetData.zone;
5136
5037
  targetIndex = targetData.index;
5137
5038
  const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
5138
- const dir = getDeepDir(target.element);
5139
- const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || dir === "ltr" && (collisionData == null ? void 0 : collisionData.direction) === "left" || dir === "rtl" && (collisionData == null ? void 0 : collisionData.direction) === "right" ? "before" : "after";
5039
+ const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
5140
5040
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
5141
5041
  targetIndex = targetIndex - 1;
5142
5042
  }
@@ -5332,7 +5232,7 @@ var DrawerItem = ({
5332
5232
  isDragDisabled
5333
5233
  }) => {
5334
5234
  const resolvedId = id || name;
5335
- const [dynamicId, setDynamicId] = useState19(generateId(resolvedId));
5235
+ const [dynamicId, setDynamicId] = useState18(generateId(resolvedId));
5336
5236
  if (typeof index !== "undefined") {
5337
5237
  console.error(
5338
5238
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -5398,7 +5298,7 @@ import {
5398
5298
  useEffect as useEffect24,
5399
5299
  useMemo as useMemo19,
5400
5300
  useReducer,
5401
- useState as useState27
5301
+ useState as useState26
5402
5302
  } from "react";
5403
5303
 
5404
5304
  // components/SidebarSection/index.tsx
@@ -5406,7 +5306,7 @@ init_react_import();
5406
5306
 
5407
5307
  // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
5408
5308
  init_react_import();
5409
- var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
5309
+ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "SidebarSection-title": "_SidebarSection-title_125qe_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_125qe_20", "SidebarSection-content": "_SidebarSection-content_125qe_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_125qe_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_125qe_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_125qe_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_125qe_41", "SidebarSection-heading": "_SidebarSection-heading_125qe_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_125qe_86" };
5410
5310
 
5411
5311
  // lib/use-breadcrumbs.ts
5412
5312
  init_react_import();
@@ -5585,7 +5485,7 @@ function MenuBar({
5585
5485
 
5586
5486
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5587
5487
  init_react_import();
5588
- var styles_module_default15 = { "Puck": "_Puck_11o75_19", "Puck-portal": "_Puck-portal_11o75_24", "PuckLayout-inner": "_PuckLayout-inner_11o75_31", "PuckLayout--mounted": "_PuckLayout--mounted_11o75_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_11o75_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_11o75_53", "PuckLayout-mounted": "_PuckLayout-mounted_11o75_67", "PuckLayout": "_PuckLayout_11o75_31", "PuckLayout-header": "_PuckLayout-header_11o75_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_11o75_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_11o75_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_11o75_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_11o75_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_11o75_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_11o75_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_11o75_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_11o75_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_11o75_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_11o75_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_11o75_134" };
5488
+ 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" };
5589
5489
 
5590
5490
  // components/Puck/components/Fields/index.tsx
5591
5491
  init_react_import();
@@ -5599,7 +5499,7 @@ import { useMemo as useMemo12 } from "react";
5599
5499
 
5600
5500
  // lib/use-resolved-fields.ts
5601
5501
  init_react_import();
5602
- import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState20 } from "react";
5502
+ import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
5603
5503
 
5604
5504
  // lib/use-parent.ts
5605
5505
  init_react_import();
@@ -5647,10 +5547,7 @@ var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0
5647
5547
  var defaultPageFields = {
5648
5548
  title: { type: "text" }
5649
5549
  };
5650
- var useResolvedFields = ({
5651
- _skipValueCheck,
5652
- _skipIdCheck
5653
- } = {}) => {
5550
+ var useResolvedFields = () => {
5654
5551
  var _a, _b;
5655
5552
  const { selectedItem, state, config } = useAppContext();
5656
5553
  const parent = useParent();
@@ -5662,18 +5559,12 @@ var useResolvedFields = ({
5662
5559
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5663
5560
  );
5664
5561
  const rootProps = data.root.props || data.root;
5665
- const [lastSelectedData, setLastSelectedData] = useState20({});
5666
- const [resolvedFields, setResolvedFields] = useState20({
5667
- fields: defaultFields,
5668
- id: selectedItem == null ? void 0 : selectedItem.props.id
5669
- });
5670
- const [fieldsLoading, setFieldsLoading] = useState20(false);
5562
+ const [lastSelectedData, setLastSelectedData] = useState19({});
5563
+ const [resolvedFields, setResolvedFields] = useState19(defaultFields);
5564
+ const [fieldsLoading, setFieldsLoading] = useState19(false);
5671
5565
  const lastFields = useRef5(defaultFields);
5672
5566
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5673
- const componentData = useMemo11(
5674
- () => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
5675
- [selectedItem, rootProps, data.root.readOnly]
5676
- );
5567
+ const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5677
5568
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5678
5569
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5679
5570
  const hasResolver = hasComponentResolver || hasRootResolver;
@@ -5721,25 +5612,15 @@ var useResolvedFields = ({
5721
5612
  if (hasResolver) {
5722
5613
  setFieldsLoading(true);
5723
5614
  resolveFields(defaultFields).then((fields) => {
5724
- setResolvedFields({
5725
- fields: fields || {},
5726
- id: selectedItem == null ? void 0 : selectedItem.props.id
5727
- });
5615
+ setResolvedFields(fields || {});
5728
5616
  lastFields.current = fields;
5729
5617
  setFieldsLoading(false);
5730
5618
  });
5731
5619
  return;
5732
5620
  }
5733
5621
  }
5734
- setResolvedFields({ fields: defaultFields, id: selectedItem == null ? void 0 : selectedItem.props.id });
5735
- }, [
5736
- defaultFields,
5737
- state.ui.itemSelector,
5738
- selectedItem,
5739
- hasResolver,
5740
- parent,
5741
- resolveFields
5742
- ]);
5622
+ setResolvedFields(defaultFields);
5623
+ }, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
5743
5624
  useOnValueChange(
5744
5625
  state.ui.itemSelector,
5745
5626
  () => {
@@ -5750,7 +5631,6 @@ var useResolvedFields = ({
5750
5631
  useOnValueChange(
5751
5632
  { data, parent, itemSelector: state.ui.itemSelector },
5752
5633
  () => {
5753
- if (_skipValueCheck) return;
5754
5634
  triggerResolver();
5755
5635
  },
5756
5636
  (a, b) => JSON.stringify(a) === JSON.stringify(b)
@@ -5758,10 +5638,7 @@ var useResolvedFields = ({
5758
5638
  useEffect17(() => {
5759
5639
  triggerResolver();
5760
5640
  }, []);
5761
- if (resolvedFields.id !== (selectedItem == null ? void 0 : selectedItem.props.id) && !_skipIdCheck) {
5762
- return [defaultFields, fieldsLoading];
5763
- }
5764
- return [resolvedFields.fields, fieldsLoading];
5641
+ return [resolvedFields, fieldsLoading];
5765
5642
  };
5766
5643
 
5767
5644
  // components/Puck/components/Fields/index.tsx
@@ -5911,14 +5788,14 @@ init_react_import();
5911
5788
 
5912
5789
  // lib/use-component-list.tsx
5913
5790
  init_react_import();
5914
- import { useEffect as useEffect18, useState as useState21 } from "react";
5791
+ import { useEffect as useEffect18, useState as useState20 } from "react";
5915
5792
 
5916
5793
  // components/ComponentList/index.tsx
5917
5794
  init_react_import();
5918
5795
 
5919
5796
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
5920
5797
  init_react_import();
5921
- var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
5798
+ var styles_module_default17 = { "ComponentList": "_ComponentList_odh9d_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_odh9d_5", "ComponentList-content": "_ComponentList-content_odh9d_9", "ComponentList-title": "_ComponentList-title_odh9d_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_odh9d_53" };
5922
5799
 
5923
5800
  // components/ComponentList/index.tsx
5924
5801
  import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
@@ -5978,7 +5855,7 @@ ComponentList.Item = ComponentListItem;
5978
5855
  // lib/use-component-list.tsx
5979
5856
  import { jsx as jsx29 } from "react/jsx-runtime";
5980
5857
  var useComponentList = (config, ui) => {
5981
- const [componentList, setComponentList] = useState21();
5858
+ const [componentList, setComponentList] = useState20();
5982
5859
  useEffect18(() => {
5983
5860
  var _a, _b, _c;
5984
5861
  if (Object.keys(ui.componentList).length > 0) {
@@ -6067,7 +5944,7 @@ import {
6067
5944
  createContext as createContext5,
6068
5945
  useContext as useContext10,
6069
5946
  useEffect as useEffect19,
6070
- useState as useState22
5947
+ useState as useState21
6071
5948
  } from "react";
6072
5949
  import hash from "object-hash";
6073
5950
  import { createPortal as createPortal3 } from "react-dom";
@@ -6291,9 +6168,9 @@ function AutoFrame(_a) {
6291
6168
  "onStylesLoaded",
6292
6169
  "frameRef"
6293
6170
  ]);
6294
- const [loaded, setLoaded] = useState22(false);
6295
- const [ctx, setCtx] = useState22({});
6296
- const [mountTarget, setMountTarget] = useState22();
6171
+ const [loaded, setLoaded] = useState21(false);
6172
+ const [ctx, setCtx] = useState21({});
6173
+ const [mountTarget, setMountTarget] = useState21();
6297
6174
  useEffect19(() => {
6298
6175
  var _a2;
6299
6176
  if (frameRef.current) {
@@ -6356,14 +6233,13 @@ function Render({
6356
6233
  config.root.render,
6357
6234
  __spreadProps(__spreadValues({}, rootProps), {
6358
6235
  puck: {
6359
- renderDropZone: DropZonePure,
6360
- isEditing: false,
6361
- dragRef: null
6236
+ renderDropZone: DropZone,
6237
+ isEditing: false
6362
6238
  },
6363
6239
  title,
6364
6240
  editMode: false,
6365
6241
  id: "puck-root",
6366
- children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
6242
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6367
6243
  })
6368
6244
  )
6369
6245
  }
@@ -6379,7 +6255,7 @@ function Render({
6379
6255
  depth: 0,
6380
6256
  path: []
6381
6257
  },
6382
- children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
6258
+ children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
6383
6259
  }
6384
6260
  );
6385
6261
  }
@@ -6393,8 +6269,21 @@ var useBubbleIframeEvents = (ref) => {
6393
6269
  var _a;
6394
6270
  if (ref.current && status === "READY") {
6395
6271
  const iframe = ref.current;
6272
+ class BubbledPointerEventClass extends PointerEvent {
6273
+ constructor(type, data) {
6274
+ super(type, data);
6275
+ this._originalTarget = null;
6276
+ this.originalTarget = data.originalTarget;
6277
+ }
6278
+ set originalTarget(target) {
6279
+ this._originalTarget = target;
6280
+ }
6281
+ get originalTarget() {
6282
+ return this._originalTarget;
6283
+ }
6284
+ }
6396
6285
  const handlePointerMove = (event) => {
6397
- const evt = new BubbledPointerEvent("pointermove", __spreadProps(__spreadValues({}, event), {
6286
+ const evt = new BubbledPointerEventClass("pointermove", __spreadProps(__spreadValues({}, event), {
6398
6287
  bubbles: true,
6399
6288
  cancelable: false,
6400
6289
  clientX: event.clientX,
@@ -6439,12 +6328,12 @@ var Preview2 = ({ id = "puck-preview" }) => {
6439
6328
  Page,
6440
6329
  __spreadProps(__spreadValues({}, rootProps), {
6441
6330
  puck: {
6442
- renderDropZone: DropZonePure,
6331
+ renderDropZone: DropZone,
6443
6332
  isEditing: true,
6444
6333
  dragRef: null
6445
6334
  },
6446
6335
  editMode: true,
6447
- children: /* @__PURE__ */ jsx33(DropZonePure, { zone: rootDroppableId })
6336
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
6448
6337
  })
6449
6338
  ) : /* @__PURE__ */ jsx33(Render, { data: state.data, config });
6450
6339
  return /* @__PURE__ */ jsx33(
@@ -6516,7 +6405,7 @@ init_react_import();
6516
6405
 
6517
6406
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
6518
6407
  init_react_import();
6519
- var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
6408
+ var styles_module_default19 = { "LayerTree": "_LayerTree_1pgw8_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_1pgw8_11", "LayerTree-helper": "_LayerTree-helper_1pgw8_17", "Layer": "_Layer_1pgw8_1", "Layer-inner": "_Layer-inner_1pgw8_29", "Layer--containsZone": "_Layer--containsZone_1pgw8_35", "Layer-clickable": "_Layer-clickable_1pgw8_39", "Layer--isSelected": "_Layer--isSelected_1pgw8_61", "Layer-chevron": "_Layer-chevron_1pgw8_77", "Layer--childIsSelected": "_Layer--childIsSelected_1pgw8_78", "Layer-zones": "_Layer-zones_1pgw8_82", "Layer-title": "_Layer-title_1pgw8_96", "Layer-name": "_Layer-name_1pgw8_105", "Layer-icon": "_Layer-icon_1pgw8_111", "Layer-zoneIcon": "_Layer-zoneIcon_1pgw8_116" };
6520
6409
 
6521
6410
  // lib/scroll-into-view.ts
6522
6411
  init_react_import();
@@ -6812,19 +6701,19 @@ function usePuckHistory({
6812
6701
 
6813
6702
  // lib/use-history-store.ts
6814
6703
  init_react_import();
6815
- import { useState as useState23 } from "react";
6704
+ import { useState as useState22 } from "react";
6816
6705
  import { useDebouncedCallback as useDebouncedCallback3 } from "use-debounce";
6817
6706
  var EMPTY_HISTORY_INDEX = 0;
6818
6707
  function useHistoryStore(initialHistory) {
6819
6708
  var _a, _b;
6820
- const [histories, setHistories] = useState23(
6709
+ const [histories, setHistories] = useState22(
6821
6710
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
6822
6711
  );
6823
6712
  const updateHistories = (histories2) => {
6824
6713
  setHistories(histories2);
6825
6714
  setIndex(histories2.length - 1);
6826
6715
  };
6827
- const [index, setIndex] = useState23(
6716
+ const [index, setIndex] = useState22(
6828
6717
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
6829
6718
  );
6830
6719
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -6989,16 +6878,16 @@ import {
6989
6878
  useEffect as useEffect22,
6990
6879
  useMemo as useMemo17,
6991
6880
  useRef as useRef8,
6992
- useState as useState25
6881
+ useState as useState24
6993
6882
  } from "react";
6994
6883
 
6995
6884
  // components/ViewportControls/index.tsx
6996
6885
  init_react_import();
6997
- import { useEffect as useEffect21, useMemo as useMemo16, useState as useState24 } from "react";
6886
+ import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
6998
6887
 
6999
6888
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7000
6889
  init_react_import();
7001
- var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
6890
+ var styles_module_default20 = { "ViewportControls": "_ViewportControls_g1wgg_1", "ViewportControls-divider": "_ViewportControls-divider_g1wgg_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_g1wgg_21", "ViewportButton--isActive": "_ViewportButton--isActive_g1wgg_34", "ViewportButton-inner": "_ViewportButton-inner_g1wgg_34" };
7002
6891
 
7003
6892
  // components/ViewportControls/index.tsx
7004
6893
  import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
@@ -7017,7 +6906,7 @@ var ViewportButton = ({
7017
6906
  onClick
7018
6907
  }) => {
7019
6908
  const { state } = useAppContext();
7020
- const [isActive, setIsActive] = useState24(false);
6909
+ const [isActive, setIsActive] = useState23(false);
7021
6910
  useEffect21(() => {
7022
6911
  setIsActive(width === state.ui.viewports.current.width);
7023
6912
  }, [width, state.ui.viewports.current.width]);
@@ -7178,7 +7067,7 @@ var Canvas = () => {
7178
7067
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
7179
7068
  const { ui } = state;
7180
7069
  const frameRef = useRef8(null);
7181
- const [showTransition, setShowTransition] = useState25(false);
7070
+ const [showTransition, setShowTransition] = useState24(false);
7182
7071
  const defaultRender = useMemo17(() => {
7183
7072
  const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
7184
7073
  return PuckDefault;
@@ -7233,7 +7122,7 @@ var Canvas = () => {
7233
7122
  window.removeEventListener("resize", cb);
7234
7123
  };
7235
7124
  }, []);
7236
- const [showLoader, setShowLoader] = useState25(false);
7125
+ const [showLoader, setShowLoader] = useState24(false);
7237
7126
  useEffect22(() => {
7238
7127
  setTimeout(() => {
7239
7128
  setShowLoader(true);
@@ -7363,10 +7252,10 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { chil
7363
7252
 
7364
7253
  // lib/use-inject-css.ts
7365
7254
  init_react_import();
7366
- import { useEffect as useEffect23, useState as useState26 } from "react";
7255
+ import { useEffect as useEffect23, useState as useState25 } from "react";
7367
7256
  var styles = ``;
7368
7257
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7369
- const [el, setEl] = useState26();
7258
+ const [el, setEl] = useState25();
7370
7259
  useEffect23(() => {
7371
7260
  setEl(document.createElement("style"));
7372
7261
  }, []);
@@ -7413,11 +7302,6 @@ var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7413
7302
  preventDefault: true,
7414
7303
  document: resolvedFrame
7415
7304
  });
7416
- useHotkeys2("ctrl+i", toggleInteractive, { preventDefault: true });
7417
- useHotkeys2("ctrl+i", toggleInteractiveIframe, {
7418
- preventDefault: true,
7419
- document: resolvedFrame
7420
- });
7421
7305
  };
7422
7306
 
7423
7307
  // components/Puck/index.tsx
@@ -7450,7 +7334,7 @@ function Puck({
7450
7334
  waitForStyles: true
7451
7335
  }, _iframe);
7452
7336
  useInjectGlobalCss(iframe.enabled);
7453
- const [generatedAppState] = useState27(() => {
7337
+ const [generatedAppState] = useState26(() => {
7454
7338
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
7455
7339
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7456
7340
  let clientUiState = {};
@@ -7522,7 +7406,7 @@ function Puck({
7522
7406
  histories,
7523
7407
  index: initialHistoryIndex
7524
7408
  });
7525
- const [reducer] = useState27(
7409
+ const [reducer] = useState26(
7526
7410
  () => createReducer({
7527
7411
  config,
7528
7412
  record: historyStore.record,
@@ -7540,7 +7424,7 @@ function Puck({
7540
7424
  historyStore,
7541
7425
  iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
7542
7426
  });
7543
- const [menuOpen, setMenuOpen] = useState27(false);
7427
+ const [menuOpen, setMenuOpen] = useState26(false);
7544
7428
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
7545
7429
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
7546
7430
  useEffect24(() => {
@@ -7627,7 +7511,7 @@ function Puck({
7627
7511
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7628
7512
  [loadedOverrides]
7629
7513
  );
7630
- const [mounted, setMounted] = useState27(false);
7514
+ const [mounted, setMounted] = useState26(false);
7631
7515
  useEffect24(() => {
7632
7516
  setMounted(true);
7633
7517
  }, []);
@@ -7892,12 +7776,14 @@ export {
7892
7776
  Button,
7893
7777
  Drawer,
7894
7778
  DropZone,
7779
+ DropZoneProvider,
7895
7780
  FieldLabel,
7896
7781
  Group,
7897
7782
  IconButton,
7898
7783
  Label,
7899
7784
  Puck,
7900
7785
  Render,
7786
+ dropZoneContext,
7901
7787
  migrate,
7902
7788
  overrideKeys,
7903
7789
  resolveAllData,