@measured/puck 0.18.2-canary.73bb338 → 0.18.2-canary.8992a94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -169,12 +169,14 @@ __export(core_exports, {
169
169
  Button: () => Button,
170
170
  Drawer: () => Drawer,
171
171
  DropZone: () => DropZone,
172
+ DropZoneProvider: () => DropZoneProvider,
172
173
  FieldLabel: () => FieldLabel,
173
174
  Group: () => Group,
174
175
  IconButton: () => IconButton,
175
176
  Label: () => Label,
176
177
  Puck: () => Puck,
177
178
  Render: () => Render,
179
+ dropZoneContext: () => dropZoneContext,
178
180
  migrate: () => migrate,
179
181
  overrideKeys: () => overrideKeys,
180
182
  resolveAllData: () => resolveAllData,
@@ -260,7 +262,7 @@ var get_class_name_factory_default = getClassNameFactory;
260
262
 
261
263
  // css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
262
264
  init_react_import();
263
- 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" };
265
+ 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" };
264
266
 
265
267
  // components/ActionBar/index.tsx
266
268
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -306,10 +308,10 @@ init_react_import();
306
308
 
307
309
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
308
310
  init_react_import();
309
- 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" };
311
+ 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" };
310
312
 
311
313
  // components/AutoField/index.tsx
312
- var import_react21 = require("react");
314
+ var import_react20 = require("react");
313
315
 
314
316
  // components/AutoField/fields/index.tsx
315
317
  init_react_import();
@@ -319,7 +321,7 @@ init_react_import();
319
321
 
320
322
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/fields/ArrayField/styles.module.css#css-module
321
323
  init_react_import();
322
- 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" };
324
+ 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" };
323
325
 
324
326
  // ../../node_modules/lucide-react/dist/esm/lucide-react.js
325
327
  init_react_import();
@@ -769,7 +771,7 @@ var IconButton = ({
769
771
  };
770
772
 
771
773
  // components/AutoField/fields/ArrayField/index.tsx
772
- var import_react13 = require("react");
774
+ var import_react12 = require("react");
773
775
 
774
776
  // components/DragIcon/index.tsx
775
777
  init_react_import();
@@ -1277,8 +1279,8 @@ function useAppContext() {
1277
1279
 
1278
1280
  // components/Sortable/index.tsx
1279
1281
  init_react_import();
1280
- var import_react10 = require("@dnd-kit/react");
1281
- var import_react11 = require("react");
1282
+ var import_react9 = require("@dnd-kit/react");
1283
+ var import_react10 = require("react");
1282
1284
 
1283
1285
  // lib/dnd/dnd-kit/safe.ts
1284
1286
  init_react_import();
@@ -1306,826 +1308,172 @@ function useSortableSafe(input) {
1306
1308
  return (0, import_sortable.useSortable)(input);
1307
1309
  }
1308
1310
 
1309
- // lib/dnd/use-sensors.ts
1310
- init_react_import();
1311
- var import_react9 = require("react");
1312
-
1313
- // lib/dnd/PointerSensor.ts
1314
- init_react_import();
1315
- var import_state = require("@dnd-kit/state");
1316
- var import_abstract = require("@dnd-kit/abstract");
1317
- var import_geometry = require("@dnd-kit/geometry");
1318
- var import_utilities = require("@dnd-kit/dom/utilities");
1319
- var _clearTimeout;
1320
- var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
1321
- constructor(manager, options) {
1322
- super(manager);
1323
- this.manager = manager;
1324
- this.options = options;
1325
- this.listeners = new import_utilities.Listeners();
1326
- this.cleanup = /* @__PURE__ */ new Set();
1327
- this.source = void 0;
1328
- __privateAdd(this, _clearTimeout);
1329
- this.handleCancel = this.handleCancel.bind(this);
1330
- this.handlePointerUp = this.handlePointerUp.bind(this);
1331
- this.handleKeyDown = this.handleKeyDown.bind(this);
1332
- (0, import_state.effect)(() => {
1333
- const unbindGlobal = this.bindGlobal(options != null ? options : {});
1334
- return () => {
1335
- unbindGlobal();
1336
- };
1337
- });
1338
- }
1339
- bind(source, options = this.options) {
1340
- const unbind = (0, import_state.effect)(() => {
1341
- var _a;
1342
- const target = (_a = source.handle) != null ? _a : source.element;
1343
- const listener = (event) => {
1344
- if ((0, import_utilities.isPointerEvent)(event)) {
1345
- this.handlePointerDown(event, source, options);
1346
- }
1347
- };
1348
- if (target) {
1349
- patchWindow(target.ownerDocument.defaultView);
1350
- target.addEventListener("pointerdown", listener);
1351
- return () => {
1352
- target.removeEventListener("pointerdown", listener);
1353
- };
1354
- }
1355
- });
1356
- return unbind;
1357
- }
1358
- bindGlobal(options) {
1359
- const documents = /* @__PURE__ */ new Set();
1360
- for (const draggable of this.manager.registry.draggables.value) {
1361
- if (draggable.element) {
1362
- documents.add((0, import_utilities.getDocument)(draggable.element));
1363
- }
1364
- }
1365
- for (const droppable of this.manager.registry.droppables.value) {
1366
- if (droppable.element) {
1367
- documents.add((0, import_utilities.getDocument)(droppable.element));
1368
- }
1369
- }
1370
- const unbindFns = Array.from(documents).map(
1371
- (doc) => this.listeners.bind(doc, [
1372
- {
1373
- type: "pointermove",
1374
- listener: (event) => this.handlePointerMove(event, doc, options)
1375
- },
1376
- {
1377
- type: "pointerup",
1378
- listener: this.handlePointerUp,
1379
- options: {
1380
- capture: true
1311
+ // components/Sortable/index.tsx
1312
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1313
+ var SortableProvider = ({
1314
+ children,
1315
+ onMove
1316
+ }) => {
1317
+ const [move, setMove] = (0, import_react10.useState)({ source: -1, target: -1 });
1318
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1319
+ import_react9.DragDropProvider,
1320
+ {
1321
+ onDragOver: (event) => {
1322
+ const { operation } = event;
1323
+ if (operation.source && operation.target) {
1324
+ const newMove = {
1325
+ source: operation.source.data.index,
1326
+ target: operation.target.data.index
1327
+ };
1328
+ if (newMove.source !== newMove.target) {
1329
+ setMove({
1330
+ source: operation.source.data.index,
1331
+ target: operation.target.data.index
1332
+ });
1381
1333
  }
1382
- },
1383
- {
1384
- // Cancel activation if there is a competing Drag and Drop interaction
1385
- type: "dragstart",
1386
- listener: this.handleDragStart
1387
1334
  }
1388
- ])
1389
- );
1390
- return () => {
1391
- unbindFns.forEach((unbind) => unbind());
1392
- };
1393
- }
1394
- handlePointerDown(event, source, options = {}) {
1395
- if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
1396
- return;
1335
+ },
1336
+ onDragEnd: () => {
1337
+ if (move.source !== -1 && move.target !== -1) {
1338
+ onMove(move);
1339
+ }
1340
+ },
1341
+ children
1397
1342
  }
1398
- const offset = (0, import_utilities.getFrameTransform)(source.element);
1399
- this.initialCoordinates = {
1400
- x: event.clientX * offset.scaleX + offset.x,
1401
- y: event.clientY * offset.scaleY + offset.y
1402
- };
1403
- this.source = source;
1404
- const { activationConstraints } = options;
1405
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
1406
- event.stopImmediatePropagation();
1407
- if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
1408
- this.handleStart(source, event);
1409
- } else {
1410
- const { delay } = constraints;
1411
- if (delay) {
1412
- const timeout3 = setTimeout(
1413
- () => this.handleStart(source, event),
1414
- delay.value
1343
+ );
1344
+ };
1345
+ var Sortable = ({
1346
+ id,
1347
+ index,
1348
+ disabled,
1349
+ children,
1350
+ type = "item"
1351
+ }) => {
1352
+ const { ref: sortableRef, status } = useSortableSafe({
1353
+ id,
1354
+ type,
1355
+ index,
1356
+ disabled,
1357
+ data: { index }
1358
+ });
1359
+ return children({ status, ref: sortableRef });
1360
+ };
1361
+
1362
+ // components/AutoField/context.tsx
1363
+ init_react_import();
1364
+ var import_react11 = require("react");
1365
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1366
+ var NestedFieldContext = (0, import_react11.createContext)({});
1367
+ var useNestedFieldContext = () => {
1368
+ const context = (0, import_react11.useContext)(NestedFieldContext);
1369
+ return __spreadProps(__spreadValues({}, context), {
1370
+ readOnlyFields: context.readOnlyFields || {}
1371
+ });
1372
+ };
1373
+ var NestedFieldProvider = ({
1374
+ children,
1375
+ name,
1376
+ subName,
1377
+ wildcardName = name,
1378
+ readOnlyFields
1379
+ }) => {
1380
+ const subPath = `${name}.${subName}`;
1381
+ const wildcardSubPath = `${wildcardName}.${subName}`;
1382
+ const subReadOnlyFields = (0, import_react11.useMemo)(
1383
+ () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
1384
+ const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
1385
+ if (isLocal) {
1386
+ const subPathPattern = new RegExp(
1387
+ `^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
1415
1388
  );
1416
- __privateSet(this, _clearTimeout, () => {
1417
- clearTimeout(timeout3);
1418
- __privateSet(this, _clearTimeout, void 0);
1389
+ const localName = readOnlyKey.replace(subPathPattern, "");
1390
+ return __spreadProps(__spreadValues({}, acc), {
1391
+ [localName]: readOnlyFields[readOnlyKey]
1419
1392
  });
1420
1393
  }
1394
+ return acc;
1395
+ }, {}),
1396
+ [name, subName, wildcardName, readOnlyFields]
1397
+ );
1398
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1399
+ NestedFieldContext.Provider,
1400
+ {
1401
+ value: { readOnlyFields: subReadOnlyFields, localName: subName },
1402
+ children
1421
1403
  }
1422
- const cleanup = () => {
1423
- var _a;
1424
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
1425
- this.initialCoordinates = void 0;
1426
- this.source = void 0;
1427
- };
1428
- this.cleanup.add(cleanup);
1429
- }
1430
- handlePointerMove(event, doc, options) {
1431
- if (!this.source) {
1432
- return;
1433
- }
1434
- const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
1435
- if (doc !== ownerDocument) {
1436
- return;
1437
- }
1438
- const coordinates = {
1439
- x: event.clientX,
1440
- y: event.clientY
1441
- };
1442
- const offset = (0, import_utilities.getFrameTransform)(this.source.element);
1443
- coordinates.x = coordinates.x * offset.scaleX + offset.x;
1444
- coordinates.y = coordinates.y * offset.scaleY + offset.y;
1445
- if (this.manager.dragOperation.status.dragging) {
1446
- event.preventDefault();
1447
- event.stopPropagation();
1448
- this.manager.actions.move({ to: coordinates });
1449
- return;
1450
- }
1451
- if (!this.initialCoordinates) {
1452
- return;
1453
- }
1454
- const delta = {
1455
- x: coordinates.x - this.initialCoordinates.x,
1456
- y: coordinates.y - this.initialCoordinates.y
1457
- };
1458
- const { activationConstraints } = options;
1459
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
1460
- const { distance, delay } = constraints != null ? constraints : {};
1461
- if (distance) {
1462
- if (distance.tolerance != null && (0, import_geometry.exceedsDistance)(delta, distance.tolerance)) {
1463
- return this.handleCancel();
1464
- }
1465
- if ((0, import_geometry.exceedsDistance)(delta, distance.value)) {
1466
- return this.handleStart(this.source, event);
1467
- }
1468
- }
1469
- if (delay) {
1470
- if ((0, import_geometry.exceedsDistance)(delta, delay.tolerance)) {
1471
- return this.handleCancel();
1472
- }
1473
- }
1474
- }
1475
- handlePointerUp(event) {
1476
- if (!this.source) {
1477
- return;
1478
- }
1479
- event.preventDefault();
1480
- event.stopPropagation();
1481
- const { status } = this.manager.dragOperation;
1482
- if (!status.idle) {
1483
- const canceled = !status.initialized;
1484
- this.manager.actions.stop({ canceled });
1485
- }
1486
- this.cleanup.forEach((cleanup) => cleanup());
1487
- this.cleanup.clear();
1488
- }
1489
- handleKeyDown(event) {
1490
- if (event.key === "Escape") {
1491
- event.preventDefault();
1492
- this.handleCancel();
1493
- }
1494
- }
1495
- handleStart(source, event) {
1496
- var _a;
1497
- const { manager, initialCoordinates } = this;
1498
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
1499
- if (!initialCoordinates || manager.dragOperation.status.initialized) {
1500
- return;
1501
- }
1502
- if (event.defaultPrevented) {
1503
- return;
1504
- }
1505
- event.preventDefault();
1506
- (0, import_state.batch)(() => {
1507
- manager.actions.setDragSource(source.id);
1508
- manager.actions.start({ coordinates: initialCoordinates, event });
1509
- });
1510
- const ownerDocument = (0, import_utilities.getDocument)(event.target);
1511
- const unbind = this.listeners.bind(ownerDocument, [
1512
- {
1513
- // Prevent scrolling on touch devices
1514
- type: "touchmove",
1515
- listener: preventDefault,
1516
- options: {
1517
- passive: false
1518
- }
1519
- },
1520
- {
1521
- // Prevent click events
1522
- type: "click",
1523
- listener: preventDefault
1524
- },
1525
- {
1526
- type: "keydown",
1527
- listener: this.handleKeyDown
1528
- }
1529
- ]);
1530
- ownerDocument.body.setPointerCapture(event.pointerId);
1531
- this.cleanup.add(unbind);
1532
- }
1533
- handleDragStart(event) {
1534
- const { target } = event;
1535
- if (!(0, import_utilities.isElement)(target)) {
1536
- return;
1537
- }
1538
- const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
1539
- if (isNativeDraggable) {
1540
- this.handleCancel();
1541
- } else {
1542
- preventDefault(event);
1543
- }
1544
- }
1545
- handleCancel() {
1546
- const { dragOperation } = this.manager;
1547
- if (dragOperation.status.initialized) {
1548
- this.manager.actions.stop({ canceled: true });
1549
- }
1550
- this.cleanup.forEach((cleanup) => cleanup());
1551
- this.cleanup.clear();
1552
- }
1553
- destroy() {
1554
- this.listeners.clear();
1555
- }
1556
- };
1557
- _clearTimeout = new WeakMap();
1558
- _PointerSensor.configure = (0, import_abstract.configurator)(_PointerSensor);
1559
- var PointerSensor = _PointerSensor;
1560
- function preventDefault(event) {
1561
- event.preventDefault();
1562
- }
1563
- function noop() {
1564
- }
1565
- var windows = /* @__PURE__ */ new WeakSet();
1566
- function patchWindow(window2) {
1567
- if (!window2 || windows.has(window2)) {
1568
- return;
1569
- }
1570
- window2.addEventListener("touchmove", noop, {
1571
- capture: false,
1572
- passive: false
1573
- });
1574
- windows.add(window2);
1575
- }
1576
-
1577
- // lib/dnd/use-sensors.ts
1578
- var import_utilities2 = require("@dnd-kit/dom/utilities");
1579
- var useSensors = () => {
1580
- const [sensors] = (0, import_react9.useState)(() => [
1581
- PointerSensor.configure({
1582
- activationConstraints(event, source) {
1583
- var _a;
1584
- const { pointerType, target } = event;
1585
- if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
1586
- return void 0;
1587
- }
1588
- const delay = { value: 200, tolerance: 10 };
1589
- if (pointerType === "touch") {
1590
- return { delay };
1591
- }
1592
- return {
1593
- delay,
1594
- distance: { value: 5 }
1595
- };
1596
- }
1597
- })
1598
- ]);
1599
- return sensors;
1600
- };
1601
-
1602
- // lib/dnd/collision/dynamic/index.ts
1603
- init_react_import();
1604
- var import_abstract9 = require("@dnd-kit/abstract");
1605
-
1606
- // lib/dnd/collision/directional/index.ts
1607
- init_react_import();
1608
- var import_abstract2 = require("@dnd-kit/abstract");
1609
-
1610
- // lib/dnd/collision/collision-debug.ts
1611
- init_react_import();
1612
- var DEBUG = false;
1613
- var debugElements = {};
1614
- var timeout;
1615
- var collisionDebug = (a, b, id, color, label) => {
1616
- if (!DEBUG) return;
1617
- const debugId = `${id}-debug`;
1618
- clearTimeout(timeout);
1619
- timeout = setTimeout(() => {
1620
- Object.entries(debugElements).forEach(([id2, { svg }]) => {
1621
- svg.remove();
1622
- delete debugElements[id2];
1623
- });
1624
- }, 1e3);
1625
- requestAnimationFrame(() => {
1626
- var _a, _b;
1627
- const existingEl = debugElements[debugId];
1628
- let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
1629
- let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
1630
- if (!existingEl) {
1631
- const svgNs = "http://www.w3.org/2000/svg";
1632
- const svg = document.createElementNS(svgNs, "svg");
1633
- line = document.createElementNS(svgNs, "line");
1634
- text = document.createElementNS(svgNs, "text");
1635
- svg.setAttribute("id", debugId);
1636
- svg.setAttribute(
1637
- "style",
1638
- "position: fixed; height: 100%; width: 100%; pointer-events: none;"
1639
- );
1640
- svg.appendChild(line);
1641
- svg.appendChild(text);
1642
- text.setAttribute("fill", `black`);
1643
- document.body.appendChild(svg);
1644
- debugElements[debugId] = { svg, line, text };
1645
- }
1646
- line.setAttribute("x1", a.x.toString());
1647
- line.setAttribute("x2", b.x.toString());
1648
- line.setAttribute("y1", a.y.toString());
1649
- line.setAttribute("y2", b.y.toString());
1650
- line.setAttribute("style", `stroke:${color};stroke-width:2`);
1651
- text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
1652
- text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
1653
- if (label) {
1654
- text.innerHTML = label;
1655
- }
1656
- });
1657
- };
1658
-
1659
- // lib/dnd/collision/directional/index.ts
1660
- var distanceChange = "increasing";
1661
- var directionalCollision = (input, previous) => {
1662
- var _a;
1663
- const { dragOperation, droppable } = input;
1664
- const { shape: dropShape } = droppable;
1665
- const { position } = dragOperation;
1666
- const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
1667
- if (!dragShape || !dropShape) return null;
1668
- const dropCenter = dropShape.center;
1669
- const distanceToPrevious = Math.sqrt(
1670
- Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
1671
- );
1672
- const distanceToCurrent = Math.sqrt(
1673
- Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
1674
- );
1675
- distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
1676
- collisionDebug(
1677
- dragShape.center,
1678
- dropCenter,
1679
- droppable.id.toString(),
1680
- "rebeccapurple"
1681
- );
1682
- if (distanceChange === "decreasing") {
1683
- return {
1684
- id: droppable.id,
1685
- value: 1,
1686
- type: import_abstract2.CollisionType.Collision
1687
- };
1688
- }
1689
- return null;
1690
- };
1691
-
1692
- // lib/dnd/collision/dynamic/get-direction.ts
1693
- init_react_import();
1694
- var getDirection = (dragAxis, delta) => {
1695
- if (dragAxis === "dynamic") {
1696
- if (Math.abs(delta.y) > Math.abs(delta.x)) {
1697
- return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
1698
- } else {
1699
- return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
1700
- }
1701
- } else if (dragAxis === "x") {
1702
- return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
1703
- }
1704
- return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
1705
- };
1706
-
1707
- // lib/dnd/collision/dynamic/get-midpoint-impact.ts
1708
- init_react_import();
1709
- var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
1710
- const dragRect = dragShape.boundingRectangle;
1711
- const dropCenter = dropShape.center;
1712
- if (direction === "down") {
1713
- const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
1714
- return dragRect.bottom >= dropCenter.y + offset2;
1715
- } else if (direction === "up") {
1716
- const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
1717
- return dragRect.top < dropCenter.y - offset2;
1718
- } else if (direction === "left") {
1719
- const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
1720
- return dropCenter.x - offset2 >= dragRect.left;
1721
- }
1722
- const offset = offsetMultiplier * dropShape.boundingRectangle.width;
1723
- return dragRect.right - offset >= dropCenter.x;
1724
- };
1725
-
1726
- // lib/dnd/collision/dynamic/track-movement-interval.ts
1727
- init_react_import();
1728
- var import_geometry2 = require("@dnd-kit/geometry");
1729
- var INTERVAL_SENSITIVITY = 10;
1730
- var intervalCache = {
1731
- current: { x: 0, y: 0 },
1732
- delta: { x: 0, y: 0 },
1733
- previous: { x: 0, y: 0 },
1734
- direction: null
1735
- };
1736
- var trackMovementInterval = (point, dragAxis = "dynamic") => {
1737
- intervalCache.current = point;
1738
- intervalCache.delta = {
1739
- x: point.x - intervalCache.previous.x,
1740
- y: point.y - intervalCache.previous.y
1741
- };
1742
- intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
1743
- if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
1744
- intervalCache.previous = import_geometry2.Point.from(point);
1745
- }
1746
- return intervalCache;
1747
- };
1748
-
1749
- // ../../node_modules/@dnd-kit/collision/dist/index.js
1750
- init_react_import();
1751
- var import_abstract3 = require("@dnd-kit/abstract");
1752
- var import_geometry3 = require("@dnd-kit/geometry");
1753
- var import_abstract4 = require("@dnd-kit/abstract");
1754
- var import_geometry4 = require("@dnd-kit/geometry");
1755
- var import_abstract5 = require("@dnd-kit/abstract");
1756
- var import_geometry5 = require("@dnd-kit/geometry");
1757
- var import_abstract6 = require("@dnd-kit/abstract");
1758
- var import_geometry6 = require("@dnd-kit/geometry");
1759
- var import_abstract7 = require("@dnd-kit/abstract");
1760
- var import_geometry7 = require("@dnd-kit/geometry");
1761
- var import_abstract8 = require("@dnd-kit/abstract");
1762
- var import_geometry8 = require("@dnd-kit/geometry");
1763
- var pointerIntersection = ({
1764
- dragOperation,
1765
- droppable
1766
- }) => {
1767
- const pointerCoordinates = dragOperation.position.current;
1768
- if (!pointerCoordinates) {
1769
- return null;
1770
- }
1771
- const { id } = droppable;
1772
- if (!droppable.shape) {
1773
- return null;
1774
- }
1775
- if (droppable.shape.containsPoint(pointerCoordinates)) {
1776
- const distance = import_geometry3.Point.distance(droppable.shape.center, pointerCoordinates);
1777
- return {
1778
- id,
1779
- value: 1 / distance,
1780
- type: import_abstract3.CollisionType.PointerIntersection,
1781
- priority: import_abstract3.CollisionPriority.High
1782
- };
1783
- }
1784
- return null;
1785
- };
1786
- var closestCorners = (input) => {
1787
- const { dragOperation, droppable } = input;
1788
- const { shape, position } = dragOperation;
1789
- if (!droppable.shape) {
1790
- return null;
1791
- }
1792
- const { left, top, right, bottom } = droppable.shape.boundingRectangle;
1793
- const corners = [
1794
- {
1795
- x: left,
1796
- y: top
1797
- },
1798
- {
1799
- x: right,
1800
- y: top
1801
- },
1802
- {
1803
- x: left,
1804
- y: bottom
1805
- },
1806
- {
1807
- x: right,
1808
- y: bottom
1809
- }
1810
- ];
1811
- const distance = corners.reduce(
1812
- (acc, corner) => {
1813
- var _a;
1814
- return acc + import_geometry5.Point.distance(
1815
- import_geometry5.Point.from(corner),
1816
- (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
1817
- );
1818
- },
1819
- 0
1820
- );
1821
- const value = distance / 4;
1822
- return {
1823
- id: droppable.id,
1824
- value: 1 / value,
1825
- type: import_abstract5.CollisionType.Collision,
1826
- priority: import_abstract5.CollisionPriority.Normal
1827
- };
1828
- };
1829
-
1830
- // lib/dnd/collision/dynamic/store.ts
1831
- init_react_import();
1832
- var import_vanilla = require("zustand/vanilla");
1833
- var collisionStore = (0, import_vanilla.createStore)(() => ({
1834
- fallbackEnabled: false
1835
- }));
1836
-
1837
- // lib/dnd/collision/dynamic/index.ts
1838
- var flushNext = "";
1839
- var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
1840
- var _a, _b, _c, _d, _e;
1841
- const { dragOperation, droppable } = input;
1842
- const { position } = dragOperation;
1843
- const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
1844
- const { shape: dropShape } = droppable;
1845
- if (!dragShape || !dropShape) {
1846
- return null;
1847
- }
1848
- const { center: dragCenter } = dragShape;
1849
- const { fallbackEnabled } = collisionStore.getState();
1850
- const interval = trackMovementInterval(position.current, dragAxis);
1851
- dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
1852
- direction: interval.direction
1853
- });
1854
- const collisionMap = dragOperation.data.collisionMap || {};
1855
- dragOperation.data.collisionMap = collisionMap;
1856
- collisionMap[droppable.id] = {
1857
- direction: interval.direction
1858
- };
1859
- const { center: dropCenter } = dropShape;
1860
- const overMidpoint = getMidpointImpact(
1861
- dragShape,
1862
- dropShape,
1863
- interval.direction,
1864
- midpointOffset
1865
- );
1866
- if (((_b = dragOperation.source) == null ? void 0 : _b.id) === droppable.id) {
1867
- const collision = directionalCollision(input, interval.previous);
1868
- collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
1869
- if (collision) {
1870
- return __spreadProps(__spreadValues({}, collision), {
1871
- priority: import_abstract9.CollisionPriority.Highest
1872
- });
1873
- }
1874
- }
1875
- const intersectionArea = dragShape.intersectionArea(dropShape);
1876
- const intersectionRatio = intersectionArea / dropShape.area;
1877
- if (intersectionArea && overMidpoint) {
1878
- collisionDebug(
1879
- dragCenter,
1880
- dropCenter,
1881
- droppable.id.toString(),
1882
- "green",
1883
- interval.direction
1884
- );
1885
- const collision = {
1886
- id: droppable.id,
1887
- value: intersectionRatio,
1888
- priority: import_abstract9.CollisionPriority.High,
1889
- type: import_abstract9.CollisionType.Collision
1890
- };
1891
- const shouldFlushId = flushNext === droppable.id;
1892
- flushNext = "";
1893
- return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
1894
- }
1895
- if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
1896
- const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
1897
- const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
1898
- if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
1899
- const fallbackCollision = closestCorners(input);
1900
- if (fallbackCollision) {
1901
- const direction = getDirection(dragAxis, {
1902
- x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
1903
- y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
1904
- });
1905
- collisionMap[droppable.id] = {
1906
- direction
1907
- };
1908
- if (intersectionArea) {
1909
- collisionDebug(
1910
- dragCenter,
1911
- dropCenter,
1912
- droppable.id.toString(),
1913
- "red",
1914
- direction || ""
1915
- );
1916
- flushNext = droppable.id;
1917
- return __spreadProps(__spreadValues({}, fallbackCollision), {
1918
- priority: import_abstract9.CollisionPriority.Low
1919
- });
1920
- }
1921
- collisionDebug(
1922
- dragCenter,
1923
- dropCenter,
1924
- droppable.id.toString(),
1925
- "orange",
1926
- direction || ""
1927
- );
1928
- return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract9.CollisionPriority.Lowest });
1929
- }
1930
- }
1931
- }
1932
- collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
1933
- delete collisionMap[droppable.id];
1934
- return null;
1935
- };
1936
-
1937
- // components/Sortable/index.tsx
1938
- var import_modifiers = require("@dnd-kit/dom/modifiers");
1939
- var import_jsx_runtime6 = require("react/jsx-runtime");
1940
- var SortableProvider = ({
1941
- children,
1942
- onDragStart,
1943
- onDragEnd,
1944
- onMove
1945
- }) => {
1946
- const [move, setMove] = (0, import_react11.useState)({ source: -1, target: -1 });
1947
- const sensors = useSensors();
1948
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1949
- import_react10.DragDropProvider,
1950
- {
1951
- sensors,
1952
- modifiers: [
1953
- import_modifiers.RestrictToElement.configure({
1954
- element() {
1955
- return document.querySelector("[data-dnd-container]");
1956
- }
1957
- })
1958
- ],
1959
- onDragStart,
1960
- onDragOver: (event, manager) => {
1961
- var _a, _b;
1962
- const { operation } = event;
1963
- const { source, target } = operation;
1964
- if (!source || !target) return;
1965
- let sourceIndex = source.data.index;
1966
- let targetIndex = target.data.index;
1967
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
1968
- if (sourceIndex !== targetIndex && source.id !== target.id) {
1969
- const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
1970
- if (targetIndex >= sourceIndex) {
1971
- targetIndex = targetIndex - 1;
1972
- }
1973
- if (collisionPosition === "after") {
1974
- targetIndex = targetIndex + 1;
1975
- }
1976
- setMove({
1977
- source: sourceIndex,
1978
- target: targetIndex
1979
- });
1980
- }
1981
- },
1982
- onDragEnd: () => {
1983
- setTimeout(() => {
1984
- if (move.source !== -1 && move.target !== -1) {
1985
- onMove(move);
1986
- }
1987
- onDragEnd();
1988
- }, 250);
1989
- setMove({ source: -1, target: -1 });
1990
- },
1991
- children
1992
- }
1993
- );
1994
- };
1995
- var Sortable = ({
1996
- id,
1997
- index,
1998
- disabled,
1999
- children,
2000
- type = "item"
2001
- }) => {
2002
- const { ref: sortableRef, status } = useSortableSafe({
2003
- id,
2004
- type,
2005
- index,
2006
- disabled,
2007
- data: { index },
2008
- collisionDetector: createDynamicCollisionDetector("y")
2009
- });
2010
- return children({ status, ref: sortableRef });
2011
- };
2012
-
2013
- // components/AutoField/context.tsx
2014
- init_react_import();
2015
- var import_react12 = require("react");
2016
- var import_jsx_runtime7 = require("react/jsx-runtime");
2017
- var NestedFieldContext = (0, import_react12.createContext)({});
2018
- var useNestedFieldContext = () => {
2019
- const context = (0, import_react12.useContext)(NestedFieldContext);
2020
- return __spreadProps(__spreadValues({}, context), {
2021
- readOnlyFields: context.readOnlyFields || {}
2022
- });
2023
- };
2024
- var NestedFieldProvider = ({
2025
- children,
2026
- name,
2027
- subName,
2028
- wildcardName = name,
2029
- readOnlyFields
2030
- }) => {
2031
- const subPath = `${name}.${subName}`;
2032
- const wildcardSubPath = `${wildcardName}.${subName}`;
2033
- const subReadOnlyFields = (0, import_react12.useMemo)(
2034
- () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
2035
- const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
2036
- if (isLocal) {
2037
- const subPathPattern = new RegExp(
2038
- `^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
2039
- );
2040
- const localName = readOnlyKey.replace(subPathPattern, "");
2041
- return __spreadProps(__spreadValues({}, acc), {
2042
- [localName]: readOnlyFields[readOnlyKey]
2043
- });
2044
- }
2045
- return acc;
2046
- }, {}),
2047
- [name, subName, wildcardName, readOnlyFields]
2048
- );
2049
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2050
- NestedFieldContext.Provider,
2051
- {
2052
- value: { readOnlyFields: subReadOnlyFields, localName: subName },
2053
- children
2054
- }
2055
- );
2056
- };
2057
-
2058
- // components/AutoField/fields/ArrayField/index.tsx
2059
- var import_jsx_runtime8 = require("react/jsx-runtime");
2060
- var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
2061
- var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
2062
- var ArrayField = ({
2063
- field,
2064
- onChange,
2065
- value: _value,
2066
- name,
2067
- label,
2068
- readOnly,
2069
- id,
2070
- Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", __spreadValues({}, props))
2071
- }) => {
2072
- const { state, setUi, selectedItem, getPermissions } = useAppContext();
2073
- const { readOnlyFields, localName = name } = useNestedFieldContext();
2074
- const value = _value;
2075
- const arrayState = state.ui.arrayState[id] || {
2076
- items: Array.from(value || []).map((item, idx) => {
2077
- return {
2078
- _originalIndex: idx,
2079
- _arrayId: `${id}-${idx}`
2080
- };
2081
- }),
2082
- openId: ""
2083
- };
2084
- const [localState, setLocalState] = (0, import_react13.useState)({ arrayState, value });
2085
- (0, import_react13.useEffect)(() => {
2086
- setLocalState({ arrayState, value });
2087
- }, [value, state.ui.arrayState[id]]);
2088
- const mapArrayStateToUi = (0, import_react13.useCallback)(
2089
- (partialArrayState) => {
2090
- return {
2091
- arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
2092
- [id]: __spreadValues(__spreadValues({}, arrayState), partialArrayState)
2093
- })
2094
- };
2095
- },
2096
- [arrayState]
2097
- );
2098
- const getHighestIndex = (0, import_react13.useCallback)(() => {
2099
- return arrayState.items.reduce(
2100
- (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
2101
- -1
2102
- );
2103
- }, [arrayState]);
2104
- const regenerateArrayState = (0, import_react13.useCallback)(
2105
- (value2) => {
2106
- let highestIndex = getHighestIndex();
2107
- const newItems = Array.from(value2 || []).map((item, idx) => {
2108
- var _a;
2109
- const arrayStateItem = arrayState.items[idx];
2110
- const newItem = {
2111
- _originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : highestIndex + 1,
2112
- _arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex + 1}`
2113
- };
2114
- if (newItem._originalIndex > highestIndex) {
2115
- highestIndex = newItem._originalIndex;
2116
- }
2117
- return newItem;
2118
- });
2119
- return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
2120
- },
2121
- [arrayState]
2122
- );
2123
- (0, import_react13.useEffect)(() => {
2124
- if (arrayState.items.length > 0) {
2125
- setUi(mapArrayStateToUi(arrayState));
1404
+ );
1405
+ };
1406
+
1407
+ // components/AutoField/fields/ArrayField/index.tsx
1408
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1409
+ var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
1410
+ var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
1411
+ var ArrayField = ({
1412
+ field,
1413
+ onChange,
1414
+ value: _value,
1415
+ name,
1416
+ label,
1417
+ readOnly,
1418
+ id,
1419
+ Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", __spreadValues({}, props))
1420
+ }) => {
1421
+ const { state, setUi, selectedItem, getPermissions } = useAppContext();
1422
+ const { readOnlyFields, localName = name } = useNestedFieldContext();
1423
+ const value = _value;
1424
+ const arrayState = state.ui.arrayState[id] || {
1425
+ items: Array.from(value || []).map((item, idx) => {
1426
+ return {
1427
+ _originalIndex: idx,
1428
+ _arrayId: `${id}-${idx}`
1429
+ };
1430
+ }),
1431
+ openId: ""
1432
+ };
1433
+ const [localState, setLocalState] = (0, import_react12.useState)({ arrayState, value });
1434
+ (0, import_react12.useEffect)(() => {
1435
+ setLocalState({ arrayState, value });
1436
+ }, [value, state.ui.arrayState[id]]);
1437
+ const mapArrayStateToUi = (0, import_react12.useCallback)(
1438
+ (partialArrayState) => {
1439
+ return {
1440
+ arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
1441
+ [id]: __spreadValues(__spreadValues({}, arrayState), partialArrayState)
1442
+ })
1443
+ };
1444
+ },
1445
+ [arrayState]
1446
+ );
1447
+ const getHighestIndex = (0, import_react12.useCallback)(() => {
1448
+ return arrayState.items.reduce(
1449
+ (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
1450
+ -1
1451
+ );
1452
+ }, [arrayState]);
1453
+ const regenerateArrayState = (0, import_react12.useCallback)(
1454
+ (value2) => {
1455
+ let highestIndex = getHighestIndex();
1456
+ const newItems = Array.from(value2 || []).map((item, idx) => {
1457
+ var _a;
1458
+ const arrayStateItem = arrayState.items[idx];
1459
+ const newItem = {
1460
+ _originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : highestIndex + 1,
1461
+ _arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex + 1}`
1462
+ };
1463
+ if (newItem._originalIndex > highestIndex) {
1464
+ highestIndex = newItem._originalIndex;
1465
+ }
1466
+ return newItem;
1467
+ });
1468
+ return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
1469
+ },
1470
+ [arrayState]
1471
+ );
1472
+ (0, import_react12.useEffect)(() => {
1473
+ if (arrayState.items.length > 0) {
1474
+ setUi(mapArrayStateToUi(arrayState));
2126
1475
  }
2127
1476
  }, []);
2128
- const [isDragging, setIsDragging] = (0, import_react13.useState)(false);
2129
1477
  const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
2130
1478
  if (field.type !== "array" || !field.arrayFields) {
2131
1479
  return null;
@@ -2141,8 +1489,6 @@ var ArrayField = ({
2141
1489
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2142
1490
  SortableProvider,
2143
1491
  {
2144
- onDragStart: () => setIsDragging(true),
2145
- onDragEnd: () => setIsDragging(false),
2146
1492
  onMove: (move) => {
2147
1493
  const newValue = reorder(value, move.source, move.target);
2148
1494
  const newArrayStateItems = reorder(
@@ -2173,7 +1519,7 @@ var ArrayField = ({
2173
1519
  e.preventDefault();
2174
1520
  },
2175
1521
  children: [
2176
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
1522
+ localState.arrayState.items.map((item, i) => {
2177
1523
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
2178
1524
  const data = Array.from(localState.value || [])[i] || {};
2179
1525
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -2196,7 +1542,6 @@ var ArrayField = ({
2196
1542
  "div",
2197
1543
  {
2198
1544
  onClick: (e) => {
2199
- if (isDragging) return;
2200
1545
  e.preventDefault();
2201
1546
  e.stopPropagation();
2202
1547
  if (arrayState.openId === _arrayId) {
@@ -2226,11 +1571,7 @@ var ArrayField = ({
2226
1571
  onClick: (e) => {
2227
1572
  e.stopPropagation();
2228
1573
  const existingValue = [...value || []];
2229
- existingValue.splice(
2230
- i,
2231
- 0,
2232
- existingValue[i]
2233
- );
1574
+ existingValue.splice(i, 0, existingValue[i]);
2234
1575
  onChange(
2235
1576
  existingValue,
2236
1577
  mapArrayStateToUi(
@@ -2272,72 +1613,62 @@ var ArrayField = ({
2272
1613
  ]
2273
1614
  }
2274
1615
  ),
2275
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2276
- "fieldset",
2277
- {
2278
- className: getClassNameItem("fieldset"),
2279
- onPointerDownCapture: (e) => {
2280
- e.stopPropagation();
2281
- },
2282
- children: Object.keys(field.arrayFields).map((subName) => {
2283
- const subField = field.arrayFields[subName];
2284
- const indexName = `${name}[${i}]`;
2285
- const subPath = `${indexName}.${subName}`;
2286
- const localIndexName = `${localName}[${i}]`;
2287
- const localWildcardName = `${localName}[*]`;
2288
- const localSubPath = `${localIndexName}.${subName}`;
2289
- const localWildcardSubPath = `${localWildcardName}.${subName}`;
2290
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
2291
- const label2 = subField.label || subName;
2292
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2293
- NestedFieldProvider,
1616
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
1617
+ const subField = field.arrayFields[subName];
1618
+ const indexName = `${name}[${i}]`;
1619
+ const subPath = `${indexName}.${subName}`;
1620
+ const localIndexName = `${localName}[${i}]`;
1621
+ const localWildcardName = `${localName}[*]`;
1622
+ const localSubPath = `${localIndexName}.${subName}`;
1623
+ const localWildcardSubPath = `${localWildcardName}.${subName}`;
1624
+ const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
1625
+ const label2 = subField.label || subName;
1626
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1627
+ NestedFieldProvider,
1628
+ {
1629
+ name: localIndexName,
1630
+ wildcardName: localWildcardName,
1631
+ subName,
1632
+ readOnlyFields,
1633
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1634
+ AutoFieldPrivate,
2294
1635
  {
2295
- name: localIndexName,
2296
- wildcardName: localWildcardName,
2297
- subName,
2298
- readOnlyFields,
2299
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2300
- AutoFieldPrivate,
2301
- {
2302
- name: subPath,
2303
- label: label2,
2304
- id: `${_arrayId}_${subName}`,
2305
- readOnly: subReadOnly,
2306
- field: __spreadProps(__spreadValues({}, subField), {
2307
- label: label2
2308
- // May be used by custom fields
2309
- }),
2310
- value: data[subName],
2311
- onChange: (val, ui) => {
2312
- onChange(
2313
- replace(value, i, __spreadProps(__spreadValues({}, data), {
2314
- [subName]: val
2315
- })),
2316
- ui
2317
- );
2318
- }
2319
- }
2320
- )
2321
- },
2322
- subPath
2323
- );
2324
- })
2325
- }
2326
- ) })
1636
+ name: subPath,
1637
+ label: label2,
1638
+ id: `${_arrayId}_${subName}`,
1639
+ readOnly: subReadOnly,
1640
+ field: __spreadProps(__spreadValues({}, subField), {
1641
+ label: label2
1642
+ // May be used by custom fields
1643
+ }),
1644
+ value: data[subName],
1645
+ onChange: (val, ui) => {
1646
+ onChange(
1647
+ replace(value, i, __spreadProps(__spreadValues({}, data), {
1648
+ [subName]: val
1649
+ })),
1650
+ ui
1651
+ );
1652
+ }
1653
+ }
1654
+ )
1655
+ },
1656
+ subPath
1657
+ );
1658
+ }) }) })
2327
1659
  ]
2328
1660
  }
2329
1661
  )
2330
1662
  },
2331
1663
  _arrayId
2332
1664
  );
2333
- }) }),
1665
+ }),
2334
1666
  !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2335
1667
  "button",
2336
1668
  {
2337
1669
  type: "button",
2338
1670
  className: getClassName5("addButton"),
2339
1671
  onClick: () => {
2340
- if (isDragging) return;
2341
1672
  const existingValue = value || [];
2342
1673
  const newValue = [
2343
1674
  ...existingValue,
@@ -2418,19 +1749,19 @@ var DefaultField = ({
2418
1749
 
2419
1750
  // components/AutoField/fields/ExternalField/index.tsx
2420
1751
  init_react_import();
2421
- var import_react17 = require("react");
1752
+ var import_react16 = require("react");
2422
1753
 
2423
1754
  // components/ExternalInput/index.tsx
2424
1755
  init_react_import();
2425
- var import_react16 = require("react");
1756
+ var import_react15 = require("react");
2426
1757
 
2427
1758
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
2428
1759
  init_react_import();
2429
- 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" };
1760
+ 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" };
2430
1761
 
2431
1762
  // components/Modal/index.tsx
2432
1763
  init_react_import();
2433
- var import_react14 = require("react");
1764
+ var import_react13 = require("react");
2434
1765
 
2435
1766
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
2436
1767
  init_react_import();
@@ -2445,8 +1776,8 @@ var Modal = ({
2445
1776
  onClose,
2446
1777
  isOpen
2447
1778
  }) => {
2448
- const [rootEl, setRootEl] = (0, import_react14.useState)(null);
2449
- (0, import_react14.useEffect)(() => {
1779
+ const [rootEl, setRootEl] = (0, import_react13.useState)(null);
1780
+ (0, import_react13.useEffect)(() => {
2450
1781
  setRootEl(document.getElementById("puck-portal-root"));
2451
1782
  }, []);
2452
1783
  if (!rootEl) {
@@ -2493,11 +1824,11 @@ init_react_import();
2493
1824
 
2494
1825
  // components/Button/Button.tsx
2495
1826
  init_react_import();
2496
- var import_react15 = require("react");
1827
+ var import_react14 = require("react");
2497
1828
 
2498
1829
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
2499
1830
  init_react_import();
2500
- 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" };
1831
+ 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" };
2501
1832
 
2502
1833
  // lib/filter-data-attrs.ts
2503
1834
  init_react_import();
@@ -2543,8 +1874,8 @@ var Button = (_a) => {
2543
1874
  "size",
2544
1875
  "loading"
2545
1876
  ]);
2546
- const [loading, setLoading] = (0, import_react15.useState)(loadingProp);
2547
- (0, import_react15.useEffect)(() => setLoading(loadingProp), [loadingProp]);
1877
+ const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
1878
+ (0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
2548
1879
  const ElementType = href ? "a" : type ? "button" : "span";
2549
1880
  const dataAttrs = filterDataAttrs(props);
2550
1881
  const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
@@ -2599,28 +1930,28 @@ var ExternalInput = ({
2599
1930
  mapRow = (val) => val,
2600
1931
  filterFields
2601
1932
  } = field || {};
2602
- const [data, setData] = (0, import_react16.useState)([]);
2603
- const [isOpen, setOpen] = (0, import_react16.useState)(false);
2604
- const [isLoading, setIsLoading] = (0, import_react16.useState)(true);
1933
+ const [data, setData] = (0, import_react15.useState)([]);
1934
+ const [isOpen, setOpen] = (0, import_react15.useState)(false);
1935
+ const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
2605
1936
  const hasFilterFields = !!filterFields;
2606
- const [filters, setFilters] = (0, import_react16.useState)(field.initialFilters || {});
2607
- const [filtersToggled, setFiltersToggled] = (0, import_react16.useState)(hasFilterFields);
2608
- const mappedData = (0, import_react16.useMemo)(() => {
1937
+ const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
1938
+ const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
1939
+ const mappedData = (0, import_react15.useMemo)(() => {
2609
1940
  return data.map(mapRow);
2610
1941
  }, [data]);
2611
- const keys = (0, import_react16.useMemo)(() => {
1942
+ const keys = (0, import_react15.useMemo)(() => {
2612
1943
  const validKeys = /* @__PURE__ */ new Set();
2613
1944
  for (const item of mappedData) {
2614
1945
  for (const key of Object.keys(item)) {
2615
- if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react16.isValidElement)(item[key])) {
1946
+ if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
2616
1947
  validKeys.add(key);
2617
1948
  }
2618
1949
  }
2619
1950
  }
2620
1951
  return Array.from(validKeys);
2621
1952
  }, [mappedData]);
2622
- const [searchQuery, setSearchQuery] = (0, import_react16.useState)(field.initialQuery || "");
2623
- const search = (0, import_react16.useCallback)(
1953
+ const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
1954
+ const search = (0, import_react15.useCallback)(
2624
1955
  (query, filters2) => __async(void 0, null, function* () {
2625
1956
  setIsLoading(true);
2626
1957
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
@@ -2633,7 +1964,7 @@ var ExternalInput = ({
2633
1964
  }),
2634
1965
  [id, field]
2635
1966
  );
2636
- const Footer = (0, import_react16.useCallback)(
1967
+ const Footer = (0, import_react15.useCallback)(
2637
1968
  (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
2638
1969
  props.items.length,
2639
1970
  " result",
@@ -2641,7 +1972,7 @@ var ExternalInput = ({
2641
1972
  ] }),
2642
1973
  [field.renderFooter]
2643
1974
  );
2644
- (0, import_react16.useEffect)(() => {
1975
+ (0, import_react15.useEffect)(() => {
2645
1976
  search(searchQuery, filters);
2646
1977
  }, []);
2647
1978
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
@@ -2734,26 +2065,18 @@ var ExternalInput = ({
2734
2065
  hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
2735
2066
  const filterField = filterFields[fieldName];
2736
2067
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2737
- "div",
2068
+ AutoFieldPrivate,
2738
2069
  {
2739
- className: getClassNameModal("field"),
2740
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2741
- AutoFieldPrivate,
2742
- {
2743
- field: filterField,
2744
- name: fieldName,
2745
- id: `external_field_${fieldName}_filter`,
2746
- label: filterField.label || fieldName,
2747
- value: filters[fieldName],
2748
- onChange: (value2) => {
2749
- const newFilters = __spreadProps(__spreadValues({}, filters), {
2750
- [fieldName]: value2
2751
- });
2752
- setFilters(newFilters);
2753
- search(searchQuery, newFilters);
2754
- }
2755
- }
2756
- )
2070
+ field: filterField,
2071
+ name: fieldName,
2072
+ id: `external_field_${fieldName}_filter`,
2073
+ label: filterField.label || fieldName,
2074
+ value: filters[fieldName],
2075
+ onChange: (value2) => {
2076
+ const newFilters = __spreadProps(__spreadValues({}, filters), { [fieldName]: value2 });
2077
+ setFilters(newFilters);
2078
+ search(searchQuery, newFilters);
2079
+ }
2757
2080
  },
2758
2081
  fieldName
2759
2082
  );
@@ -2812,7 +2135,7 @@ var ExternalField = ({
2812
2135
  var _a, _b, _c;
2813
2136
  const validField = field;
2814
2137
  const deprecatedField = field;
2815
- (0, import_react17.useEffect)(() => {
2138
+ (0, import_react16.useEffect)(() => {
2816
2139
  if (deprecatedField.adaptor) {
2817
2140
  console.error(
2818
2141
  "Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
@@ -2847,7 +2170,7 @@ var ExternalField = ({
2847
2170
 
2848
2171
  // components/AutoField/fields/RadioField/index.tsx
2849
2172
  init_react_import();
2850
- var import_react18 = require("react");
2173
+ var import_react17 = require("react");
2851
2174
 
2852
2175
  // lib/safe-json-parse.ts
2853
2176
  init_react_import();
@@ -2873,7 +2196,7 @@ var RadioField = ({
2873
2196
  label,
2874
2197
  Label: Label2
2875
2198
  }) => {
2876
- const flatOptions = (0, import_react18.useMemo)(
2199
+ const flatOptions = (0, import_react17.useMemo)(
2877
2200
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
2878
2201
  [field]
2879
2202
  );
@@ -2923,7 +2246,7 @@ var RadioField = ({
2923
2246
 
2924
2247
  // components/AutoField/fields/SelectField/index.tsx
2925
2248
  init_react_import();
2926
- var import_react19 = require("react");
2249
+ var import_react18 = require("react");
2927
2250
  var import_jsx_runtime16 = require("react/jsx-runtime");
2928
2251
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
2929
2252
  var SelectField = ({
@@ -2936,7 +2259,7 @@ var SelectField = ({
2936
2259
  readOnly,
2937
2260
  id
2938
2261
  }) => {
2939
- const flatOptions = (0, import_react19.useMemo)(
2262
+ const flatOptions = (0, import_react18.useMemo)(
2940
2263
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
2941
2264
  [field]
2942
2265
  );
@@ -3088,7 +2411,7 @@ var ObjectField = ({
3088
2411
 
3089
2412
  // lib/use-safe-id.ts
3090
2413
  init_react_import();
3091
- var import_react20 = __toESM(require("react"));
2414
+ var import_react19 = __toESM(require("react"));
3092
2415
 
3093
2416
  // lib/generate-id.ts
3094
2417
  init_react_import();
@@ -3097,10 +2420,10 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
3097
2420
 
3098
2421
  // lib/use-safe-id.ts
3099
2422
  var useSafeId = () => {
3100
- if (typeof import_react20.default.useId !== "undefined") {
3101
- return import_react20.default.useId();
2423
+ if (typeof import_react19.default.useId !== "undefined") {
2424
+ return import_react19.default.useId();
3102
2425
  }
3103
- const [id] = (0, import_react20.useState)(generateId());
2426
+ const [id] = (0, import_react19.useState)(generateId());
3104
2427
  return id;
3105
2428
  };
3106
2429
 
@@ -3134,7 +2457,7 @@ var FieldLabelInternal = ({
3134
2457
  readOnly
3135
2458
  }) => {
3136
2459
  const { overrides } = useAppContext();
3137
- const Wrapper = (0, import_react21.useMemo)(
2460
+ const Wrapper = (0, import_react20.useMemo)(
3138
2461
  () => overrides.fieldLabel || FieldLabel,
3139
2462
  [overrides]
3140
2463
  );
@@ -3156,7 +2479,7 @@ var FieldLabelInternal = ({
3156
2479
  function AutoFieldInternal(props) {
3157
2480
  var _a, _b, _c, _d, _e, _f, _g, _h;
3158
2481
  const { dispatch, overrides, selectedItem } = useAppContext();
3159
- const nestedFieldContext = (0, import_react21.useContext)(NestedFieldContext);
2482
+ const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
3160
2483
  const { id, Label: Label2 = FieldLabelInternal } = props;
3161
2484
  const field = props.field;
3162
2485
  const label = field.label;
@@ -3188,9 +2511,9 @@ function AutoFieldInternal(props) {
3188
2511
  Label: Label2,
3189
2512
  id: resolvedId
3190
2513
  });
3191
- const onFocus = (0, import_react21.useCallback)(
2514
+ const onFocus = (0, import_react20.useCallback)(
3192
2515
  (e) => {
3193
- if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
2516
+ if (mergedProps.name && e.target.nodeName === "INPUT") {
3194
2517
  e.stopPropagation();
3195
2518
  dispatch({
3196
2519
  type: "setUi",
@@ -3202,7 +2525,7 @@ function AutoFieldInternal(props) {
3202
2525
  },
3203
2526
  [mergedProps.name]
3204
2527
  );
3205
- const onBlur = (0, import_react21.useCallback)((e) => {
2528
+ const onBlur = (0, import_react20.useCallback)((e) => {
3206
2529
  if ("name" in e.target) {
3207
2530
  dispatch({
3208
2531
  type: "setUi",
@@ -3246,7 +2569,7 @@ function AutoFieldInternal(props) {
3246
2569
  function AutoFieldPrivate(props) {
3247
2570
  const { state } = useAppContext();
3248
2571
  const { value, onChange } = props;
3249
- const [localValue, setLocalValue] = (0, import_react21.useState)(value);
2572
+ const [localValue, setLocalValue] = (0, import_react20.useState)(value);
3250
2573
  const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
3251
2574
  (val, ui) => {
3252
2575
  onChange(val, ui);
@@ -3254,11 +2577,11 @@ function AutoFieldPrivate(props) {
3254
2577
  50,
3255
2578
  { leading: true }
3256
2579
  );
3257
- const onChangeLocal = (0, import_react21.useCallback)((val, ui) => {
2580
+ const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
3258
2581
  setLocalValue(val);
3259
2582
  onChangeDb(val, ui);
3260
2583
  }, []);
3261
- (0, import_react21.useEffect)(() => {
2584
+ (0, import_react20.useEffect)(() => {
3262
2585
  if (state.ui.field.focus !== props.name) {
3263
2586
  setLocalValue(value);
3264
2587
  }
@@ -3270,7 +2593,7 @@ function AutoFieldPrivate(props) {
3270
2593
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
3271
2594
  }
3272
2595
  function AutoField(props) {
3273
- const DefaultLabel = (0, import_react21.useMemo)(() => {
2596
+ const DefaultLabel = (0, import_react20.useMemo)(() => {
3274
2597
  const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3275
2598
  "div",
3276
2599
  __spreadProps(__spreadValues({}, labelProps), {
@@ -3289,29 +2612,364 @@ init_react_import();
3289
2612
  init_react_import();
3290
2613
  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" };
3291
2614
 
3292
- // components/Drawer/index.tsx
3293
- var import_react33 = require("react");
2615
+ // components/Drawer/index.tsx
2616
+ var import_react32 = require("react");
2617
+
2618
+ // components/DragDropContext/index.tsx
2619
+ init_react_import();
2620
+ var import_react30 = require("@dnd-kit/react");
2621
+ var import_react31 = require("react");
2622
+ var import_dom = require("@dnd-kit/dom");
2623
+
2624
+ // components/DropZone/index.tsx
2625
+ init_react_import();
2626
+ var import_react29 = require("react");
2627
+
2628
+ // components/DraggableComponent/index.tsx
2629
+ init_react_import();
2630
+ var import_react23 = require("react");
2631
+
2632
+ // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
2633
+ init_react_import();
2634
+ 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" };
2635
+
2636
+ // components/DraggableComponent/index.tsx
2637
+ var import_react_dom2 = require("react-dom");
2638
+
2639
+ // lib/dnd/collision/dynamic/index.ts
2640
+ init_react_import();
2641
+ var import_abstract8 = require("@dnd-kit/abstract");
2642
+
2643
+ // lib/dnd/collision/directional/index.ts
2644
+ init_react_import();
2645
+ var import_abstract = require("@dnd-kit/abstract");
2646
+
2647
+ // lib/dnd/collision/collision-debug.ts
2648
+ init_react_import();
2649
+ var DEBUG = false;
2650
+ var debugElements = {};
2651
+ var timeout;
2652
+ var collisionDebug = (a, b, id, color, label) => {
2653
+ if (!DEBUG) return;
2654
+ const debugId = `${id}-debug`;
2655
+ clearTimeout(timeout);
2656
+ timeout = setTimeout(() => {
2657
+ Object.entries(debugElements).forEach(([id2, { svg }]) => {
2658
+ svg.remove();
2659
+ delete debugElements[id2];
2660
+ });
2661
+ }, 1e3);
2662
+ requestAnimationFrame(() => {
2663
+ var _a, _b;
2664
+ const existingEl = debugElements[debugId];
2665
+ let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
2666
+ let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
2667
+ if (!existingEl) {
2668
+ const svgNs = "http://www.w3.org/2000/svg";
2669
+ const svg = document.createElementNS(svgNs, "svg");
2670
+ line = document.createElementNS(svgNs, "line");
2671
+ text = document.createElementNS(svgNs, "text");
2672
+ svg.setAttribute("id", debugId);
2673
+ svg.setAttribute(
2674
+ "style",
2675
+ "position: fixed; height: 100%; width: 100%; pointer-events: none;"
2676
+ );
2677
+ svg.appendChild(line);
2678
+ svg.appendChild(text);
2679
+ text.setAttribute("fill", `black`);
2680
+ document.body.appendChild(svg);
2681
+ debugElements[debugId] = { svg, line, text };
2682
+ }
2683
+ line.setAttribute("x1", a.x.toString());
2684
+ line.setAttribute("x2", b.x.toString());
2685
+ line.setAttribute("y1", a.y.toString());
2686
+ line.setAttribute("y2", b.y.toString());
2687
+ line.setAttribute("style", `stroke:${color};stroke-width:2`);
2688
+ text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
2689
+ text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
2690
+ if (label) {
2691
+ text.innerHTML = label;
2692
+ }
2693
+ });
2694
+ };
2695
+
2696
+ // lib/dnd/collision/directional/index.ts
2697
+ var distanceChange = "increasing";
2698
+ var directionalCollision = (input, previous) => {
2699
+ var _a;
2700
+ const { dragOperation, droppable } = input;
2701
+ const { shape: dropShape } = droppable;
2702
+ const { position } = dragOperation;
2703
+ const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
2704
+ if (!dragShape || !dropShape) return null;
2705
+ const dropCenter = dropShape.center;
2706
+ const distanceToPrevious = Math.sqrt(
2707
+ Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
2708
+ );
2709
+ const distanceToCurrent = Math.sqrt(
2710
+ Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
2711
+ );
2712
+ distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
2713
+ collisionDebug(
2714
+ dragShape.center,
2715
+ dropCenter,
2716
+ droppable.id.toString(),
2717
+ "rebeccapurple"
2718
+ );
2719
+ if (distanceChange === "decreasing") {
2720
+ return {
2721
+ id: droppable.id,
2722
+ value: 1,
2723
+ type: import_abstract.CollisionType.Collision
2724
+ };
2725
+ }
2726
+ return null;
2727
+ };
2728
+
2729
+ // lib/dnd/collision/dynamic/get-direction.ts
2730
+ init_react_import();
2731
+ var getDirection = (dragAxis, delta) => {
2732
+ if (dragAxis === "dynamic") {
2733
+ if (Math.abs(delta.y) > Math.abs(delta.x)) {
2734
+ return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2735
+ } else {
2736
+ return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
2737
+ }
2738
+ } else if (dragAxis === "x") {
2739
+ return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
2740
+ }
2741
+ return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
2742
+ };
3294
2743
 
3295
- // components/DragDropContext/index.tsx
2744
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
3296
2745
  init_react_import();
3297
- var import_react31 = require("@dnd-kit/react");
3298
- var import_react32 = require("react");
3299
- var import_dom = require("@dnd-kit/dom");
2746
+ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
2747
+ const dragRect = dragShape.boundingRectangle;
2748
+ const dropCenter = dropShape.center;
2749
+ if (direction === "down") {
2750
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
2751
+ return dragRect.bottom >= dropCenter.y + offset2;
2752
+ } else if (direction === "up") {
2753
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
2754
+ return dragRect.top < dropCenter.y - offset2;
2755
+ } else if (direction === "left") {
2756
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
2757
+ return dropCenter.x - offset2 >= dragRect.left;
2758
+ }
2759
+ const offset = offsetMultiplier * dropShape.boundingRectangle.width;
2760
+ return dragRect.right - offset >= dropCenter.x;
2761
+ };
3300
2762
 
3301
- // components/DropZone/index.tsx
2763
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
3302
2764
  init_react_import();
3303
- var import_react30 = require("react");
2765
+ var import_geometry = require("@dnd-kit/geometry");
2766
+ var INTERVAL_SENSITIVITY = 10;
2767
+ var intervalCache = {
2768
+ current: { x: 0, y: 0 },
2769
+ delta: { x: 0, y: 0 },
2770
+ previous: { x: 0, y: 0 },
2771
+ direction: null
2772
+ };
2773
+ var trackMovementInterval = (point, dragAxis = "dynamic") => {
2774
+ intervalCache.current = point;
2775
+ intervalCache.delta = {
2776
+ x: point.x - intervalCache.previous.x,
2777
+ y: point.y - intervalCache.previous.y
2778
+ };
2779
+ intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
2780
+ if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
2781
+ intervalCache.previous = import_geometry.Point.from(point);
2782
+ }
2783
+ return intervalCache;
2784
+ };
3304
2785
 
3305
- // components/DraggableComponent/index.tsx
2786
+ // ../../node_modules/@dnd-kit/collision/dist/index.js
3306
2787
  init_react_import();
3307
- var import_react24 = require("react");
2788
+ var import_abstract2 = require("@dnd-kit/abstract");
2789
+ var import_geometry2 = require("@dnd-kit/geometry");
2790
+ var import_abstract3 = require("@dnd-kit/abstract");
2791
+ var import_geometry3 = require("@dnd-kit/geometry");
2792
+ var import_abstract4 = require("@dnd-kit/abstract");
2793
+ var import_geometry4 = require("@dnd-kit/geometry");
2794
+ var import_abstract5 = require("@dnd-kit/abstract");
2795
+ var import_geometry5 = require("@dnd-kit/geometry");
2796
+ var import_abstract6 = require("@dnd-kit/abstract");
2797
+ var import_geometry6 = require("@dnd-kit/geometry");
2798
+ var import_abstract7 = require("@dnd-kit/abstract");
2799
+ var import_geometry7 = require("@dnd-kit/geometry");
2800
+ var pointerIntersection = ({
2801
+ dragOperation,
2802
+ droppable
2803
+ }) => {
2804
+ const pointerCoordinates = dragOperation.position.current;
2805
+ if (!pointerCoordinates) {
2806
+ return null;
2807
+ }
2808
+ const { id } = droppable;
2809
+ if (!droppable.shape) {
2810
+ return null;
2811
+ }
2812
+ if (droppable.shape.containsPoint(pointerCoordinates)) {
2813
+ const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
2814
+ return {
2815
+ id,
2816
+ value: 1 / distance,
2817
+ type: import_abstract2.CollisionType.PointerIntersection,
2818
+ priority: import_abstract2.CollisionPriority.High
2819
+ };
2820
+ }
2821
+ return null;
2822
+ };
2823
+ var closestCorners = (input) => {
2824
+ const { dragOperation, droppable } = input;
2825
+ const { shape, position } = dragOperation;
2826
+ if (!droppable.shape) {
2827
+ return null;
2828
+ }
2829
+ const { left, top, right, bottom } = droppable.shape.boundingRectangle;
2830
+ const corners = [
2831
+ {
2832
+ x: left,
2833
+ y: top
2834
+ },
2835
+ {
2836
+ x: right,
2837
+ y: top
2838
+ },
2839
+ {
2840
+ x: left,
2841
+ y: bottom
2842
+ },
2843
+ {
2844
+ x: right,
2845
+ y: bottom
2846
+ }
2847
+ ];
2848
+ const distance = corners.reduce(
2849
+ (acc, corner) => {
2850
+ var _a;
2851
+ return acc + import_geometry4.Point.distance(
2852
+ import_geometry4.Point.from(corner),
2853
+ (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
2854
+ );
2855
+ },
2856
+ 0
2857
+ );
2858
+ const value = distance / 4;
2859
+ return {
2860
+ id: droppable.id,
2861
+ value: 1 / value,
2862
+ type: import_abstract4.CollisionType.Collision,
2863
+ priority: import_abstract4.CollisionPriority.Normal
2864
+ };
2865
+ };
3308
2866
 
3309
- // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
2867
+ // lib/dnd/collision/dynamic/store.ts
3310
2868
  init_react_import();
3311
- 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" };
2869
+ var import_vanilla = require("zustand/vanilla");
2870
+ var collisionStore = (0, import_vanilla.createStore)(() => ({
2871
+ fallbackEnabled: false
2872
+ }));
3312
2873
 
3313
- // components/DraggableComponent/index.tsx
3314
- var import_react_dom2 = require("react-dom");
2874
+ // lib/dnd/collision/dynamic/index.ts
2875
+ var flushNext = "";
2876
+ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2877
+ var _a, _b, _c, _d, _e;
2878
+ const { dragOperation, droppable } = input;
2879
+ const { position } = dragOperation;
2880
+ const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
2881
+ const { shape: dropShape } = droppable;
2882
+ if (!dragShape || !dropShape) {
2883
+ return null;
2884
+ }
2885
+ const { center: dragCenter } = dragShape;
2886
+ const { fallbackEnabled } = collisionStore.getState();
2887
+ const interval = trackMovementInterval(position.current, dragAxis);
2888
+ dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2889
+ direction: interval.direction
2890
+ });
2891
+ const collisionMap = dragOperation.data.collisionMap || {};
2892
+ dragOperation.data.collisionMap = collisionMap;
2893
+ collisionMap[droppable.id] = {
2894
+ direction: interval.direction
2895
+ };
2896
+ const { center: dropCenter } = dropShape;
2897
+ const overMidpoint = getMidpointImpact(
2898
+ dragShape,
2899
+ dropShape,
2900
+ interval.direction,
2901
+ midpointOffset
2902
+ );
2903
+ if (((_b = dragOperation.source) == null ? void 0 : _b.id) === droppable.id) {
2904
+ const collision = directionalCollision(input, interval.previous);
2905
+ collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
2906
+ if (collision) {
2907
+ return __spreadProps(__spreadValues({}, collision), {
2908
+ priority: import_abstract8.CollisionPriority.Highest
2909
+ });
2910
+ }
2911
+ }
2912
+ const intersectionArea = dragShape.intersectionArea(dropShape);
2913
+ const intersectionRatio = intersectionArea / dropShape.area;
2914
+ if (intersectionArea && overMidpoint) {
2915
+ collisionDebug(
2916
+ dragCenter,
2917
+ dropCenter,
2918
+ droppable.id.toString(),
2919
+ "green",
2920
+ interval.direction
2921
+ );
2922
+ const collision = {
2923
+ id: droppable.id,
2924
+ value: intersectionRatio,
2925
+ priority: import_abstract8.CollisionPriority.High,
2926
+ type: import_abstract8.CollisionType.Collision
2927
+ };
2928
+ const shouldFlushId = flushNext === droppable.id;
2929
+ flushNext = "";
2930
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2931
+ }
2932
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2933
+ const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
2934
+ const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
2935
+ if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
2936
+ const fallbackCollision = closestCorners(input);
2937
+ if (fallbackCollision) {
2938
+ const direction = getDirection(dragAxis, {
2939
+ x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
2940
+ y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
2941
+ });
2942
+ collisionMap[droppable.id] = {
2943
+ direction
2944
+ };
2945
+ if (intersectionArea) {
2946
+ collisionDebug(
2947
+ dragCenter,
2948
+ dropCenter,
2949
+ droppable.id.toString(),
2950
+ "red",
2951
+ direction || ""
2952
+ );
2953
+ flushNext = droppable.id;
2954
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2955
+ priority: import_abstract8.CollisionPriority.Low
2956
+ });
2957
+ }
2958
+ collisionDebug(
2959
+ dragCenter,
2960
+ dropCenter,
2961
+ droppable.id.toString(),
2962
+ "orange",
2963
+ direction || ""
2964
+ );
2965
+ return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract8.CollisionPriority.Lowest });
2966
+ }
2967
+ }
2968
+ }
2969
+ collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2970
+ delete collisionMap[droppable.id];
2971
+ return null;
2972
+ };
3315
2973
 
3316
2974
  // lib/get-deep-scroll-position.ts
3317
2975
  init_react_import();
@@ -3334,11 +2992,11 @@ function getDeepScrollPosition(element) {
3334
2992
 
3335
2993
  // components/DropZone/context.tsx
3336
2994
  init_react_import();
3337
- var import_react22 = require("react");
2995
+ var import_react21 = require("react");
3338
2996
  var import_zustand = require("zustand");
3339
2997
  var import_jsx_runtime20 = require("react/jsx-runtime");
3340
- var dropZoneContext = (0, import_react22.createContext)(null);
3341
- var ZoneStoreContext = (0, import_react22.createContext)(
2998
+ var dropZoneContext = (0, import_react21.createContext)(null);
2999
+ var ZoneStoreContext = (0, import_react21.createContext)(
3342
3000
  (0, import_zustand.createStore)(() => ({
3343
3001
  zoneDepthIndex: {},
3344
3002
  nextZoneDepthIndex: {},
@@ -3358,19 +3016,19 @@ var DropZoneProvider = ({
3358
3016
  children,
3359
3017
  value
3360
3018
  }) => {
3361
- const [hoveringComponent, setHoveringComponent] = (0, import_react22.useState)();
3362
- const [areasWithZones, setAreasWithZones] = (0, import_react22.useState)(
3019
+ const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
3020
+ const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
3363
3021
  {}
3364
3022
  );
3365
- const [activeZones, setActiveZones] = (0, import_react22.useState)({});
3023
+ const [activeZones, setActiveZones] = (0, import_react21.useState)({});
3366
3024
  const { dispatch } = useAppContext();
3367
- const registerZoneArea = (0, import_react22.useCallback)(
3025
+ const registerZoneArea = (0, import_react21.useCallback)(
3368
3026
  (area) => {
3369
3027
  setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
3370
3028
  },
3371
3029
  [setAreasWithZones]
3372
3030
  );
3373
- const registerZone = (0, import_react22.useCallback)(
3031
+ const registerZone = (0, import_react21.useCallback)(
3374
3032
  (zoneCompound) => {
3375
3033
  if (!dispatch) {
3376
3034
  return;
@@ -3383,7 +3041,7 @@ var DropZoneProvider = ({
3383
3041
  },
3384
3042
  [setActiveZones, dispatch]
3385
3043
  );
3386
- const unregisterZone = (0, import_react22.useCallback)(
3044
+ const unregisterZone = (0, import_react21.useCallback)(
3387
3045
  (zoneCompound) => {
3388
3046
  if (!dispatch) {
3389
3047
  return;
@@ -3398,7 +3056,7 @@ var DropZoneProvider = ({
3398
3056
  },
3399
3057
  [setActiveZones, dispatch]
3400
3058
  );
3401
- const memoValue = (0, import_react22.useMemo)(
3059
+ const memoValue = (0, import_react21.useMemo)(
3402
3060
  () => __spreadValues({
3403
3061
  hoveringComponent,
3404
3062
  setHoveringComponent,
@@ -3415,11 +3073,11 @@ var DropZoneProvider = ({
3415
3073
 
3416
3074
  // lib/use-context-store.ts
3417
3075
  init_react_import();
3418
- var import_react23 = require("react");
3076
+ var import_react22 = require("react");
3419
3077
  var import_zustand2 = require("zustand");
3420
3078
  var import_shallow = require("zustand/react/shallow");
3421
3079
  function useContextStore(context, selector) {
3422
- const store = (0, import_react23.useContext)(context);
3080
+ const store = (0, import_react22.useContext)(context);
3423
3081
  if (!store) {
3424
3082
  throw new Error("useContextStore must be used inside context");
3425
3083
  }
@@ -3478,9 +3136,9 @@ var DraggableComponent = ({
3478
3136
  iframe,
3479
3137
  state
3480
3138
  } = useAppContext();
3481
- const ctx = (0, import_react24.useContext)(dropZoneContext);
3482
- const [localZones, setLocalZones] = (0, import_react24.useState)({});
3483
- const registerLocalZone = (0, import_react24.useCallback)(
3139
+ const ctx = (0, import_react23.useContext)(dropZoneContext);
3140
+ const [localZones, setLocalZones] = (0, import_react23.useState)({});
3141
+ const registerLocalZone = (0, import_react23.useCallback)(
3484
3142
  (zoneCompound2, active) => {
3485
3143
  var _a;
3486
3144
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -3490,7 +3148,7 @@ var DraggableComponent = ({
3490
3148
  },
3491
3149
  [setLocalZones]
3492
3150
  );
3493
- const unregisterLocalZone = (0, import_react24.useCallback)(
3151
+ const unregisterLocalZone = (0, import_react23.useCallback)(
3494
3152
  (zoneCompound2) => {
3495
3153
  var _a;
3496
3154
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -3504,8 +3162,8 @@ var DraggableComponent = ({
3504
3162
  );
3505
3163
  const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
3506
3164
  const { path = [] } = ctx || {};
3507
- const [canDrag, setCanDrag] = (0, import_react24.useState)(false);
3508
- (0, import_react24.useEffect)(() => {
3165
+ const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
3166
+ (0, import_react23.useEffect)(() => {
3509
3167
  var _a;
3510
3168
  const item = getItem({ index, zone: zoneCompound }, state.data);
3511
3169
  if (item) {
@@ -3521,7 +3179,7 @@ var DraggableComponent = ({
3521
3179
  );
3522
3180
  const canCollide = canDrag || userIsDragging;
3523
3181
  const disabled = !isEnabled || !canCollide;
3524
- const [dragAxis, setDragAxis] = (0, import_react24.useState)(userDragAxis || autoDragAxis);
3182
+ const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
3525
3183
  const { ref: sortableRef, status } = useSortableSafe({
3526
3184
  id,
3527
3185
  index,
@@ -3547,8 +3205,8 @@ var DraggableComponent = ({
3547
3205
  }
3548
3206
  });
3549
3207
  const thisIsDragging = status === "dragging";
3550
- const ref = (0, import_react24.useRef)(null);
3551
- const refSetter = (0, import_react24.useCallback)(
3208
+ const ref = (0, import_react23.useRef)(null);
3209
+ const refSetter = (0, import_react23.useCallback)(
3552
3210
  (el) => {
3553
3211
  sortableRef(el);
3554
3212
  if (el) {
@@ -3557,14 +3215,14 @@ var DraggableComponent = ({
3557
3215
  },
3558
3216
  [sortableRef]
3559
3217
  );
3560
- const [portalEl, setPortalEl] = (0, import_react24.useState)();
3561
- (0, import_react24.useEffect)(() => {
3218
+ const [portalEl, setPortalEl] = (0, import_react23.useState)();
3219
+ (0, import_react23.useEffect)(() => {
3562
3220
  var _a, _b, _c;
3563
3221
  setPortalEl(
3564
3222
  iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
3565
3223
  );
3566
3224
  }, [iframe.enabled, ref.current]);
3567
- const getStyle = (0, import_react24.useCallback)(() => {
3225
+ const getStyle = (0, import_react23.useCallback)(() => {
3568
3226
  var _a, _b, _c;
3569
3227
  if (!ref.current) return;
3570
3228
  const rect = ref.current.getBoundingClientRect();
@@ -3584,11 +3242,11 @@ var DraggableComponent = ({
3584
3242
  };
3585
3243
  return style2;
3586
3244
  }, [ref.current]);
3587
- const [style, setStyle] = (0, import_react24.useState)();
3588
- const sync = (0, import_react24.useCallback)(() => {
3245
+ const [style, setStyle] = (0, import_react23.useState)();
3246
+ const sync = (0, import_react23.useCallback)(() => {
3589
3247
  setStyle(getStyle());
3590
3248
  }, [ref.current, iframe]);
3591
- (0, import_react24.useEffect)(() => {
3249
+ (0, import_react23.useEffect)(() => {
3592
3250
  if (ref.current && !userIsDragging) {
3593
3251
  const observer = new ResizeObserver(sync);
3594
3252
  observer.observe(ref.current);
@@ -3597,7 +3255,7 @@ var DraggableComponent = ({
3597
3255
  };
3598
3256
  }
3599
3257
  }, [ref.current, userIsDragging]);
3600
- (0, import_react24.useEffect)(() => {
3258
+ (0, import_react23.useEffect)(() => {
3601
3259
  ctx == null ? void 0 : ctx.registerPath(
3602
3260
  id,
3603
3261
  {
@@ -3611,14 +3269,14 @@ var DraggableComponent = ({
3611
3269
  (_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
3612
3270
  };
3613
3271
  }, [id, zoneCompound, index, componentType]);
3614
- const CustomActionBar = (0, import_react24.useMemo)(
3272
+ const CustomActionBar = (0, import_react23.useMemo)(
3615
3273
  () => overrides.actionBar || DefaultActionBar,
3616
3274
  [overrides.actionBar]
3617
3275
  );
3618
3276
  const permissions = getPermissions({
3619
3277
  item: selectedItem
3620
3278
  });
3621
- const onClick = (0, import_react24.useCallback)(
3279
+ const onClick = (0, import_react23.useCallback)(
3622
3280
  (e) => {
3623
3281
  e.stopPropagation();
3624
3282
  dispatch({
@@ -3630,7 +3288,7 @@ var DraggableComponent = ({
3630
3288
  },
3631
3289
  [index, zoneCompound, id]
3632
3290
  );
3633
- const onSelectParent = (0, import_react24.useCallback)(() => {
3291
+ const onSelectParent = (0, import_react23.useCallback)(() => {
3634
3292
  if (!(ctx == null ? void 0 : ctx.areaId)) {
3635
3293
  return;
3636
3294
  }
@@ -3648,23 +3306,23 @@ var DraggableComponent = ({
3648
3306
  }
3649
3307
  });
3650
3308
  }, [ctx, path]);
3651
- const onDuplicate = (0, import_react24.useCallback)(() => {
3309
+ const onDuplicate = (0, import_react23.useCallback)(() => {
3652
3310
  dispatch({
3653
3311
  type: "duplicate",
3654
3312
  sourceIndex: index,
3655
3313
  sourceZone: zoneCompound
3656
3314
  });
3657
3315
  }, [index, zoneCompound]);
3658
- const onDelete = (0, import_react24.useCallback)(() => {
3316
+ const onDelete = (0, import_react23.useCallback)(() => {
3659
3317
  dispatch({
3660
3318
  type: "remove",
3661
3319
  index,
3662
3320
  zone: zoneCompound
3663
3321
  });
3664
3322
  }, [index, zoneCompound]);
3665
- const [hover, setHover] = (0, import_react24.useState)(false);
3323
+ const [hover, setHover] = (0, import_react23.useState)(false);
3666
3324
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
3667
- (0, import_react24.useEffect)(() => {
3325
+ (0, import_react23.useEffect)(() => {
3668
3326
  if (!ref.current) {
3669
3327
  return;
3670
3328
  }
@@ -3714,7 +3372,7 @@ var DraggableComponent = ({
3714
3372
  thisIsDragging,
3715
3373
  inDroppableZone
3716
3374
  ]);
3717
- (0, import_react24.useEffect)(() => {
3375
+ (0, import_react23.useEffect)(() => {
3718
3376
  if (ref.current && disabled) {
3719
3377
  ref.current.setAttribute("data-puck-disabled", "");
3720
3378
  return () => {
@@ -3723,8 +3381,8 @@ var DraggableComponent = ({
3723
3381
  };
3724
3382
  }
3725
3383
  }, [disabled, ref]);
3726
- const [isVisible, setIsVisible] = (0, import_react24.useState)(false);
3727
- (0, import_react24.useEffect)(() => {
3384
+ const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
3385
+ (0, import_react23.useEffect)(() => {
3728
3386
  sync();
3729
3387
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
3730
3388
  setIsVisible(true);
@@ -3732,7 +3390,7 @@ var DraggableComponent = ({
3732
3390
  setIsVisible(false);
3733
3391
  }
3734
3392
  }, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
3735
- const syncActionsPosition = (0, import_react24.useCallback)(
3393
+ const syncActionsPosition = (0, import_react23.useCallback)(
3736
3394
  (el) => {
3737
3395
  if (el) {
3738
3396
  const view = el.ownerDocument.defaultView;
@@ -3749,7 +3407,7 @@ var DraggableComponent = ({
3749
3407
  },
3750
3408
  [zoomConfig]
3751
3409
  );
3752
- (0, import_react24.useEffect)(() => {
3410
+ (0, import_react23.useEffect)(() => {
3753
3411
  if (userDragAxis) {
3754
3412
  setDragAxis(userDragAxis);
3755
3413
  return;
@@ -3843,14 +3501,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
3843
3501
 
3844
3502
  // components/DropZone/lib/use-min-empty-height.ts
3845
3503
  init_react_import();
3846
- var import_react25 = require("react");
3504
+ var import_react24 = require("react");
3847
3505
  var useMinEmptyHeight = ({
3848
3506
  zoneCompound,
3849
3507
  userMinEmptyHeight,
3850
3508
  ref
3851
3509
  }) => {
3852
- const [prevHeight, setPrevHeight] = (0, import_react25.useState)(0);
3853
- const [isAnimating, setIsAnimating] = (0, import_react25.useState)(false);
3510
+ const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
3511
+ const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
3854
3512
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3855
3513
  var _a, _b;
3856
3514
  return {
@@ -3858,7 +3516,7 @@ var useMinEmptyHeight = ({
3858
3516
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
3859
3517
  };
3860
3518
  });
3861
- (0, import_react25.useEffect)(() => {
3519
+ (0, import_react24.useEffect)(() => {
3862
3520
  if (draggedItem && ref.current) {
3863
3521
  if (isZone) {
3864
3522
  const rect = ref.current.getBoundingClientRect();
@@ -3892,15 +3550,15 @@ function assignRefs(refs, node) {
3892
3550
 
3893
3551
  // components/DropZone/lib/use-content-with-preview.ts
3894
3552
  init_react_import();
3895
- var import_react28 = require("react");
3553
+ var import_react27 = require("react");
3896
3554
 
3897
3555
  // lib/dnd/use-rendered-callback.ts
3898
3556
  init_react_import();
3899
- var import_react26 = require("@dnd-kit/react");
3900
- var import_react27 = require("react");
3557
+ var import_react25 = require("@dnd-kit/react");
3558
+ var import_react26 = require("react");
3901
3559
  function useRenderedCallback(callback, deps) {
3902
- const manager = (0, import_react26.useDragDropManager)();
3903
- return (0, import_react27.useCallback)(
3560
+ const manager = (0, import_react25.useDragDropManager)();
3561
+ return (0, import_react26.useCallback)(
3904
3562
  (...args) => __async(this, null, function* () {
3905
3563
  yield manager == null ? void 0 : manager.renderer.rendering;
3906
3564
  return callback(...args);
@@ -3935,8 +3593,8 @@ var useContentWithPreview = (content, zoneCompound) => {
3935
3593
  ui: { isDragging }
3936
3594
  }
3937
3595
  } = useAppContext();
3938
- const [contentWithPreview, setContentWithPreview] = (0, import_react28.useState)(content);
3939
- const [localPreview, setLocalPreview] = (0, import_react28.useState)(
3596
+ const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
3597
+ const [localPreview, setLocalPreview] = (0, import_react27.useState)(
3940
3598
  preview
3941
3599
  );
3942
3600
  const updateContent = useRenderedCallback(
@@ -3977,7 +3635,7 @@ var useContentWithPreview = (content, zoneCompound) => {
3977
3635
  },
3978
3636
  [draggedItemId, previewExists]
3979
3637
  );
3980
- (0, import_react28.useEffect)(() => {
3638
+ (0, import_react27.useEffect)(() => {
3981
3639
  updateContent(content, preview, isDragging);
3982
3640
  }, [content, preview, isDragging]);
3983
3641
  return [contentWithPreview, localPreview];
@@ -3985,16 +3643,16 @@ var useContentWithPreview = (content, zoneCompound) => {
3985
3643
 
3986
3644
  // components/DropZone/lib/use-drag-axis.ts
3987
3645
  init_react_import();
3988
- var import_react29 = require("react");
3646
+ var import_react28 = require("react");
3989
3647
  var GRID_DRAG_AXIS = "dynamic";
3990
3648
  var FLEX_ROW_DRAG_AXIS = "x";
3991
3649
  var DEFAULT_DRAG_AXIS = "y";
3992
3650
  var useDragAxis = (ref, collisionAxis) => {
3993
3651
  const { status } = useAppContext();
3994
- const [dragAxis, setDragAxis] = (0, import_react29.useState)(
3652
+ const [dragAxis, setDragAxis] = (0, import_react28.useState)(
3995
3653
  collisionAxis || DEFAULT_DRAG_AXIS
3996
3654
  );
3997
- const calculateDragAxis = (0, import_react29.useCallback)(() => {
3655
+ const calculateDragAxis = (0, import_react28.useCallback)(() => {
3998
3656
  if (ref.current) {
3999
3657
  const computedStyle = window.getComputedStyle(ref.current);
4000
3658
  if (computedStyle.display === "grid") {
@@ -4006,7 +3664,7 @@ var useDragAxis = (ref, collisionAxis) => {
4006
3664
  }
4007
3665
  }
4008
3666
  }, [ref.current]);
4009
- (0, import_react29.useEffect)(() => {
3667
+ (0, import_react28.useEffect)(() => {
4010
3668
  const onViewportChange = () => {
4011
3669
  calculateDragAxis();
4012
3670
  };
@@ -4015,7 +3673,7 @@ var useDragAxis = (ref, collisionAxis) => {
4015
3673
  window.removeEventListener("viewportchange", onViewportChange);
4016
3674
  };
4017
3675
  }, []);
4018
- (0, import_react29.useEffect)(calculateDragAxis, [status, collisionAxis]);
3676
+ (0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
4019
3677
  return [dragAxis, calculateDragAxis];
4020
3678
  };
4021
3679
 
@@ -4025,7 +3683,7 @@ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_de
4025
3683
  var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
4026
3684
  var RENDER_DEBUG = false;
4027
3685
  var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
4028
- var DropZoneEdit = (0, import_react30.forwardRef)(
3686
+ var DropZoneEdit = (0, import_react29.forwardRef)(
4029
3687
  function DropZoneEditInternal({
4030
3688
  zone,
4031
3689
  allow,
@@ -4036,7 +3694,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
4036
3694
  collisionAxis
4037
3695
  }, userRef) {
4038
3696
  const appContext2 = useAppContext();
4039
- const ctx = (0, import_react30.useContext)(dropZoneContext);
3697
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
4040
3698
  const {
4041
3699
  // These all need setting via context
4042
3700
  data,
@@ -4072,12 +3730,12 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
4072
3730
  };
4073
3731
  });
4074
3732
  const { itemSelector } = appContext2.state.ui;
4075
- (0, import_react30.useEffect)(() => {
3733
+ (0, import_react29.useEffect)(() => {
4076
3734
  if (areaId && registerZoneArea) {
4077
3735
  registerZoneArea(areaId);
4078
3736
  }
4079
3737
  }, [areaId]);
4080
- (0, import_react30.useEffect)(() => {
3738
+ (0, import_react29.useEffect)(() => {
4081
3739
  if (ctx == null ? void 0 : ctx.registerZone) {
4082
3740
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
4083
3741
  }
@@ -4087,14 +3745,14 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
4087
3745
  }
4088
3746
  };
4089
3747
  }, []);
4090
- const content = (0, import_react30.useMemo)(() => {
3748
+ const content = (0, import_react29.useMemo)(() => {
4091
3749
  if (areaId && zone !== rootDroppableId) {
4092
3750
  return setupZone(data, zoneCompound).zones[zoneCompound];
4093
3751
  }
4094
3752
  return data.content || [];
4095
3753
  }, [data, zoneCompound]);
4096
- const ref = (0, import_react30.useRef)(null);
4097
- const acceptsTarget = (0, import_react30.useCallback)(
3754
+ const ref = (0, import_react29.useRef)(null);
3755
+ const acceptsTarget = (0, import_react29.useCallback)(
4098
3756
  (componentType) => {
4099
3757
  if (!componentType) {
4100
3758
  return true;
@@ -4116,7 +3774,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
4116
3774
  },
4117
3775
  [allow, disallow]
4118
3776
  );
4119
- (0, import_react30.useEffect)(() => {
3777
+ (0, import_react29.useEffect)(() => {
4120
3778
  if (registerLocalZone) {
4121
3779
  registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
4122
3780
  }
@@ -4251,13 +3909,13 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
4251
3909
  }
4252
3910
  );
4253
3911
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
4254
- var DropZoneRender = (0, import_react30.forwardRef)(
3912
+ var DropZoneRender = (0, import_react29.forwardRef)(
4255
3913
  function DropZoneRenderInternal({ className, style, zone }, ref) {
4256
- const ctx = (0, import_react30.useContext)(dropZoneContext);
3914
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
4257
3915
  const { data, areaId = "root", config } = ctx || {};
4258
3916
  let zoneCompound = rootDroppableId;
4259
3917
  let content = (data == null ? void 0 : data.content) || [];
4260
- (0, import_react30.useEffect)(() => {
3918
+ (0, import_react29.useEffect)(() => {
4261
3919
  if (ctx == null ? void 0 : ctx.registerZone) {
4262
3920
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
4263
3921
  }
@@ -4303,10 +3961,9 @@ var DropZoneRender = (0, import_react30.forwardRef)(
4303
3961
  }) });
4304
3962
  }
4305
3963
  );
4306
- var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
4307
- var DropZone = (0, import_react30.forwardRef)(
3964
+ var DropZone = (0, import_react29.forwardRef)(
4308
3965
  function DropZone2(props, ref) {
4309
- const ctx = (0, import_react30.useContext)(dropZoneContext);
3966
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
4310
3967
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
4311
3968
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
4312
3969
  }
@@ -4328,8 +3985,8 @@ var getZoneId = (zoneCompound) => {
4328
3985
 
4329
3986
  // lib/dnd/NestedDroppablePlugin.ts
4330
3987
  init_react_import();
4331
- var import_abstract10 = require("@dnd-kit/abstract");
4332
- var import_state2 = require("@dnd-kit/state");
3988
+ var import_abstract9 = require("@dnd-kit/abstract");
3989
+ var import_state = require("@dnd-kit/state");
4333
3990
 
4334
3991
  // lib/throttle.ts
4335
3992
  init_react_import();
@@ -4545,13 +4202,13 @@ var findDeepestCandidate = (position, manager) => {
4545
4202
  area: null
4546
4203
  };
4547
4204
  };
4548
- var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract10.Plugin {
4205
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
4549
4206
  constructor(manager, options) {
4550
4207
  super(manager);
4551
4208
  if (typeof window === "undefined") {
4552
4209
  return;
4553
4210
  }
4554
- const cleanupEffect = (0, import_state2.effects)(() => {
4211
+ const cleanupEffect = (0, import_state.effects)(() => {
4555
4212
  const handleMove = (event) => {
4556
4213
  const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
4557
4214
  const position = new GlobalPosition(target, {
@@ -4746,267 +4403,521 @@ function reduceData(data, action, config) {
4746
4403
  if (action.type === "insert") {
4747
4404
  return insertAction(data, action, config);
4748
4405
  }
4749
- if (action.type === "duplicate") {
4750
- const item = getItem(
4751
- { index: action.sourceIndex, zone: action.sourceZone },
4752
- data
4753
- );
4754
- const newItem = __spreadProps(__spreadValues({}, item), {
4755
- props: __spreadProps(__spreadValues({}, item.props), {
4756
- id: generateId(item.type)
4757
- })
4406
+ if (action.type === "duplicate") {
4407
+ const item = getItem(
4408
+ { index: action.sourceIndex, zone: action.sourceZone },
4409
+ data
4410
+ );
4411
+ const newItem = __spreadProps(__spreadValues({}, item), {
4412
+ props: __spreadProps(__spreadValues({}, item.props), {
4413
+ id: generateId(item.type)
4414
+ })
4415
+ });
4416
+ const dataWithRelatedDuplicated = duplicateRelatedZones(
4417
+ item,
4418
+ data,
4419
+ newItem.props.id
4420
+ );
4421
+ if (action.sourceZone === rootDroppableId) {
4422
+ return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
4423
+ content: insert(data.content, action.sourceIndex + 1, newItem)
4424
+ });
4425
+ }
4426
+ return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
4427
+ zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
4428
+ [action.sourceZone]: insert(
4429
+ dataWithRelatedDuplicated.zones[action.sourceZone],
4430
+ action.sourceIndex + 1,
4431
+ newItem
4432
+ )
4433
+ })
4434
+ });
4435
+ }
4436
+ if (action.type === "reorder") {
4437
+ return reorderAction(data, action);
4438
+ }
4439
+ if (action.type === "move") {
4440
+ if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
4441
+ return data;
4442
+ }
4443
+ const newData = setupZone(
4444
+ setupZone(data, action.sourceZone),
4445
+ action.destinationZone
4446
+ );
4447
+ const item = getItem(
4448
+ { zone: action.sourceZone, index: action.sourceIndex },
4449
+ newData
4450
+ );
4451
+ if (action.sourceZone === action.destinationZone) {
4452
+ return reorderAction(data, __spreadProps(__spreadValues({}, action), { type: "reorder" }));
4453
+ }
4454
+ if (action.sourceZone === rootDroppableId) {
4455
+ return __spreadProps(__spreadValues({}, newData), {
4456
+ content: remove(newData.content, action.sourceIndex),
4457
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
4458
+ [action.destinationZone]: insert(
4459
+ newData.zones[action.destinationZone],
4460
+ action.destinationIndex,
4461
+ item
4462
+ )
4463
+ })
4464
+ });
4465
+ }
4466
+ if (action.destinationZone === rootDroppableId) {
4467
+ return __spreadProps(__spreadValues({}, newData), {
4468
+ content: insert(newData.content, action.destinationIndex, item),
4469
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
4470
+ [action.sourceZone]: remove(
4471
+ newData.zones[action.sourceZone],
4472
+ action.sourceIndex
4473
+ )
4474
+ })
4475
+ });
4476
+ }
4477
+ return __spreadProps(__spreadValues({}, newData), {
4478
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
4479
+ [action.sourceZone]: remove(
4480
+ newData.zones[action.sourceZone],
4481
+ action.sourceIndex
4482
+ ),
4483
+ [action.destinationZone]: insert(
4484
+ newData.zones[action.destinationZone],
4485
+ action.destinationIndex,
4486
+ item
4487
+ )
4488
+ })
4489
+ });
4490
+ }
4491
+ if (action.type === "replace") {
4492
+ return replaceAction(data, action);
4493
+ }
4494
+ if (action.type === "remove") {
4495
+ const item = getItem({ index: action.index, zone: action.zone }, data);
4496
+ const dataWithRelatedRemoved = setupZone(
4497
+ removeRelatedZones(item, data),
4498
+ action.zone
4499
+ );
4500
+ if (action.zone === rootDroppableId) {
4501
+ return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
4502
+ content: remove(data.content, action.index)
4503
+ });
4504
+ }
4505
+ return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
4506
+ zones: __spreadProps(__spreadValues({}, dataWithRelatedRemoved.zones), {
4507
+ [action.zone]: remove(
4508
+ dataWithRelatedRemoved.zones[action.zone],
4509
+ action.index
4510
+ )
4511
+ })
4512
+ });
4513
+ }
4514
+ if (action.type === "registerZone") {
4515
+ if (zoneCache[action.zone]) {
4516
+ return __spreadProps(__spreadValues({}, data), {
4517
+ zones: __spreadProps(__spreadValues({}, data.zones), {
4518
+ [action.zone]: zoneCache[action.zone]
4519
+ })
4520
+ });
4521
+ }
4522
+ return setupZone(data, action.zone);
4523
+ }
4524
+ if (action.type === "unregisterZone") {
4525
+ const _zones = __spreadValues({}, data.zones || {});
4526
+ if (_zones[action.zone]) {
4527
+ zoneCache[action.zone] = _zones[action.zone];
4528
+ delete _zones[action.zone];
4529
+ }
4530
+ return __spreadProps(__spreadValues({}, data), { zones: _zones });
4531
+ }
4532
+ if (action.type === "setData") {
4533
+ if (typeof action.data === "object") {
4534
+ return __spreadValues(__spreadValues({}, data), action.data);
4535
+ }
4536
+ return __spreadValues(__spreadValues({}, data), action.data(data));
4537
+ }
4538
+ return data;
4539
+ }
4540
+
4541
+ // reducer/state.ts
4542
+ init_react_import();
4543
+ var reduceUi = (ui, action) => {
4544
+ if (action.type === "setUi") {
4545
+ if (typeof action.ui === "object") {
4546
+ return __spreadValues(__spreadValues({}, ui), action.ui);
4547
+ }
4548
+ return __spreadValues(__spreadValues({}, ui), action.ui(ui));
4549
+ }
4550
+ if (action.type === "duplicate") {
4551
+ return __spreadProps(__spreadValues({}, ui), {
4552
+ itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4553
+ });
4554
+ }
4555
+ if (action.type === "remove") {
4556
+ return __spreadProps(__spreadValues({}, ui), {
4557
+ itemSelector: null
4558
+ });
4559
+ }
4560
+ return ui;
4561
+ };
4562
+
4563
+ // reducer/actions.tsx
4564
+ init_react_import();
4565
+
4566
+ // reducer/index.ts
4567
+ function storeInterceptor(reducer, record, onAction) {
4568
+ return (state, action) => {
4569
+ const newAppState = reducer(state, action);
4570
+ const isValidType = ![
4571
+ "registerZone",
4572
+ "unregisterZone",
4573
+ "setData",
4574
+ "setUi",
4575
+ "set"
4576
+ ].includes(action.type);
4577
+ if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
4578
+ if (record) record(newAppState);
4579
+ }
4580
+ onAction == null ? void 0 : onAction(action, newAppState, state);
4581
+ return newAppState;
4582
+ };
4583
+ }
4584
+ var setAction = (state, action) => {
4585
+ if (typeof action.state === "object") {
4586
+ return __spreadValues(__spreadValues({}, state), action.state);
4587
+ }
4588
+ return __spreadValues(__spreadValues({}, state), action.state(state));
4589
+ };
4590
+ function createReducer({
4591
+ config,
4592
+ record,
4593
+ onAction
4594
+ }) {
4595
+ return storeInterceptor(
4596
+ (state, action) => {
4597
+ const data = reduceData(state.data, action, config);
4598
+ const ui = reduceUi(state.ui, action);
4599
+ if (action.type === "set") {
4600
+ return setAction(state, action);
4601
+ }
4602
+ return { data, ui };
4603
+ },
4604
+ record,
4605
+ onAction
4606
+ );
4607
+ }
4608
+
4609
+ // lib/insert-component.ts
4610
+ var insertComponent = (componentType, zone, index, {
4611
+ config,
4612
+ dispatch,
4613
+ resolveData,
4614
+ state
4615
+ }) => {
4616
+ const id = generateId(componentType);
4617
+ const insertActionData = {
4618
+ type: "insert",
4619
+ componentType,
4620
+ destinationIndex: index,
4621
+ destinationZone: zone,
4622
+ id
4623
+ };
4624
+ const insertedData = insertAction(state.data, insertActionData, config);
4625
+ dispatch(__spreadProps(__spreadValues({}, insertActionData), {
4626
+ // Dispatch insert rather set, as user's may rely on this via onAction
4627
+ // We must always record history here so the insert is added to user history
4628
+ // If the user has defined a resolveData method, they will end up with 2 history
4629
+ // entries on insert - one for the initial insert, and one when the data resolves
4630
+ recordHistory: true
4631
+ }));
4632
+ const itemSelector = {
4633
+ index,
4634
+ zone
4635
+ };
4636
+ dispatch({ type: "setUi", ui: { itemSelector } });
4637
+ resolveData({
4638
+ data: insertedData,
4639
+ ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector })
4640
+ });
4641
+ };
4642
+
4643
+ // components/DragDropContext/index.tsx
4644
+ var import_use_debounce2 = require("use-debounce");
4645
+ var import_utilities2 = require("@dnd-kit/dom/utilities");
4646
+
4647
+ // lib/dnd/PointerSensor.ts
4648
+ init_react_import();
4649
+ var import_state3 = require("@dnd-kit/state");
4650
+ var import_abstract10 = require("@dnd-kit/abstract");
4651
+ var import_geometry8 = require("@dnd-kit/geometry");
4652
+ var import_utilities = require("@dnd-kit/dom/utilities");
4653
+ var _clearTimeout;
4654
+ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
4655
+ constructor(manager, options) {
4656
+ super(manager);
4657
+ this.manager = manager;
4658
+ this.options = options;
4659
+ this.listeners = new import_utilities.Listeners();
4660
+ this.cleanup = /* @__PURE__ */ new Set();
4661
+ this.source = void 0;
4662
+ __privateAdd(this, _clearTimeout);
4663
+ this.handleCancel = this.handleCancel.bind(this);
4664
+ this.handlePointerUp = this.handlePointerUp.bind(this);
4665
+ this.handleKeyDown = this.handleKeyDown.bind(this);
4666
+ (0, import_state3.effect)(() => {
4667
+ const unbindGlobal = this.bindGlobal(options != null ? options : {});
4668
+ return () => {
4669
+ unbindGlobal();
4670
+ };
4671
+ });
4672
+ }
4673
+ bind(source, options = this.options) {
4674
+ const unbind = (0, import_state3.effect)(() => {
4675
+ var _a;
4676
+ const target = (_a = source.handle) != null ? _a : source.element;
4677
+ const listener = (event) => {
4678
+ if ((0, import_utilities.isPointerEvent)(event)) {
4679
+ this.handlePointerDown(event, source, options);
4680
+ }
4681
+ };
4682
+ if (target) {
4683
+ patchWindow(target.ownerDocument.defaultView);
4684
+ target.addEventListener("pointerdown", listener);
4685
+ return () => {
4686
+ target.removeEventListener("pointerdown", listener);
4687
+ };
4688
+ }
4758
4689
  });
4759
- const dataWithRelatedDuplicated = duplicateRelatedZones(
4760
- item,
4761
- data,
4762
- newItem.props.id
4763
- );
4764
- if (action.sourceZone === rootDroppableId) {
4765
- return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
4766
- content: insert(data.content, action.sourceIndex + 1, newItem)
4767
- });
4690
+ return unbind;
4691
+ }
4692
+ bindGlobal(options) {
4693
+ const documents = /* @__PURE__ */ new Set();
4694
+ for (const draggable of this.manager.registry.draggables.value) {
4695
+ if (draggable.element) {
4696
+ documents.add((0, import_utilities.getDocument)(draggable.element));
4697
+ }
4768
4698
  }
4769
- return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
4770
- zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
4771
- [action.sourceZone]: insert(
4772
- dataWithRelatedDuplicated.zones[action.sourceZone],
4773
- action.sourceIndex + 1,
4774
- newItem
4775
- )
4776
- })
4777
- });
4699
+ for (const droppable of this.manager.registry.droppables.value) {
4700
+ if (droppable.element) {
4701
+ documents.add((0, import_utilities.getDocument)(droppable.element));
4702
+ }
4703
+ }
4704
+ const unbindFns = Array.from(documents).map(
4705
+ (doc) => this.listeners.bind(doc, [
4706
+ {
4707
+ type: "pointermove",
4708
+ listener: (event) => this.handlePointerMove(event, doc, options)
4709
+ },
4710
+ {
4711
+ type: "pointerup",
4712
+ listener: this.handlePointerUp,
4713
+ options: {
4714
+ capture: true
4715
+ }
4716
+ },
4717
+ {
4718
+ // Cancel activation if there is a competing Drag and Drop interaction
4719
+ type: "dragstart",
4720
+ listener: this.handleDragStart
4721
+ }
4722
+ ])
4723
+ );
4724
+ return () => {
4725
+ unbindFns.forEach((unbind) => unbind());
4726
+ };
4778
4727
  }
4779
- if (action.type === "reorder") {
4780
- return reorderAction(data, action);
4728
+ handlePointerDown(event, source, options = {}) {
4729
+ if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
4730
+ return;
4731
+ }
4732
+ const offset = (0, import_utilities.getFrameTransform)(source.element);
4733
+ this.initialCoordinates = {
4734
+ x: event.clientX * offset.scaleX + offset.x,
4735
+ y: event.clientY * offset.scaleY + offset.y
4736
+ };
4737
+ this.source = source;
4738
+ const { activationConstraints } = options;
4739
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
4740
+ event.stopImmediatePropagation();
4741
+ if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
4742
+ this.handleStart(source, event);
4743
+ } else {
4744
+ const { delay } = constraints;
4745
+ if (delay) {
4746
+ const timeout3 = setTimeout(
4747
+ () => this.handleStart(source, event),
4748
+ delay.value
4749
+ );
4750
+ __privateSet(this, _clearTimeout, () => {
4751
+ clearTimeout(timeout3);
4752
+ __privateSet(this, _clearTimeout, void 0);
4753
+ });
4754
+ }
4755
+ }
4756
+ const cleanup = () => {
4757
+ var _a;
4758
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
4759
+ this.initialCoordinates = void 0;
4760
+ this.source = void 0;
4761
+ };
4762
+ this.cleanup.add(cleanup);
4781
4763
  }
4782
- if (action.type === "move") {
4783
- if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
4784
- return data;
4764
+ handlePointerMove(event, doc, options) {
4765
+ if (!this.source) {
4766
+ return;
4785
4767
  }
4786
- const newData = setupZone(
4787
- setupZone(data, action.sourceZone),
4788
- action.destinationZone
4789
- );
4790
- const item = getItem(
4791
- { zone: action.sourceZone, index: action.sourceIndex },
4792
- newData
4793
- );
4794
- if (action.sourceZone === action.destinationZone) {
4795
- return reorderAction(data, __spreadProps(__spreadValues({}, action), { type: "reorder" }));
4768
+ const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
4769
+ if (doc !== ownerDocument) {
4770
+ return;
4796
4771
  }
4797
- if (action.sourceZone === rootDroppableId) {
4798
- return __spreadProps(__spreadValues({}, newData), {
4799
- content: remove(newData.content, action.sourceIndex),
4800
- zones: __spreadProps(__spreadValues({}, newData.zones), {
4801
- [action.destinationZone]: insert(
4802
- newData.zones[action.destinationZone],
4803
- action.destinationIndex,
4804
- item
4805
- )
4806
- })
4807
- });
4772
+ const coordinates = {
4773
+ x: event.clientX,
4774
+ y: event.clientY
4775
+ };
4776
+ const offset = (0, import_utilities.getFrameTransform)(this.source.element);
4777
+ coordinates.x = coordinates.x * offset.scaleX + offset.x;
4778
+ coordinates.y = coordinates.y * offset.scaleY + offset.y;
4779
+ if (this.manager.dragOperation.status.dragging) {
4780
+ event.preventDefault();
4781
+ event.stopPropagation();
4782
+ this.manager.actions.move({ to: coordinates });
4783
+ return;
4808
4784
  }
4809
- if (action.destinationZone === rootDroppableId) {
4810
- return __spreadProps(__spreadValues({}, newData), {
4811
- content: insert(newData.content, action.destinationIndex, item),
4812
- zones: __spreadProps(__spreadValues({}, newData.zones), {
4813
- [action.sourceZone]: remove(
4814
- newData.zones[action.sourceZone],
4815
- action.sourceIndex
4816
- )
4817
- })
4818
- });
4785
+ if (!this.initialCoordinates) {
4786
+ return;
4819
4787
  }
4820
- return __spreadProps(__spreadValues({}, newData), {
4821
- zones: __spreadProps(__spreadValues({}, newData.zones), {
4822
- [action.sourceZone]: remove(
4823
- newData.zones[action.sourceZone],
4824
- action.sourceIndex
4825
- ),
4826
- [action.destinationZone]: insert(
4827
- newData.zones[action.destinationZone],
4828
- action.destinationIndex,
4829
- item
4830
- )
4831
- })
4832
- });
4833
- }
4834
- if (action.type === "replace") {
4835
- return replaceAction(data, action);
4836
- }
4837
- if (action.type === "remove") {
4838
- const item = getItem({ index: action.index, zone: action.zone }, data);
4839
- const dataWithRelatedRemoved = setupZone(
4840
- removeRelatedZones(item, data),
4841
- action.zone
4842
- );
4843
- if (action.zone === rootDroppableId) {
4844
- return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
4845
- content: remove(data.content, action.index)
4846
- });
4788
+ const delta = {
4789
+ x: coordinates.x - this.initialCoordinates.x,
4790
+ y: coordinates.y - this.initialCoordinates.y
4791
+ };
4792
+ const { activationConstraints } = options;
4793
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
4794
+ const { distance, delay } = constraints != null ? constraints : {};
4795
+ if (distance) {
4796
+ if (distance.tolerance != null && (0, import_geometry8.exceedsDistance)(delta, distance.tolerance)) {
4797
+ return this.handleCancel();
4798
+ }
4799
+ if ((0, import_geometry8.exceedsDistance)(delta, distance.value)) {
4800
+ return this.handleStart(this.source, event);
4801
+ }
4847
4802
  }
4848
- return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
4849
- zones: __spreadProps(__spreadValues({}, dataWithRelatedRemoved.zones), {
4850
- [action.zone]: remove(
4851
- dataWithRelatedRemoved.zones[action.zone],
4852
- action.index
4853
- )
4854
- })
4855
- });
4856
- }
4857
- if (action.type === "registerZone") {
4858
- if (zoneCache[action.zone]) {
4859
- return __spreadProps(__spreadValues({}, data), {
4860
- zones: __spreadProps(__spreadValues({}, data.zones), {
4861
- [action.zone]: zoneCache[action.zone]
4862
- })
4863
- });
4803
+ if (delay) {
4804
+ if ((0, import_geometry8.exceedsDistance)(delta, delay.tolerance)) {
4805
+ return this.handleCancel();
4806
+ }
4864
4807
  }
4865
- return setupZone(data, action.zone);
4866
4808
  }
4867
- if (action.type === "unregisterZone") {
4868
- const _zones = __spreadValues({}, data.zones || {});
4869
- if (_zones[action.zone]) {
4870
- zoneCache[action.zone] = _zones[action.zone];
4871
- delete _zones[action.zone];
4809
+ handlePointerUp(event) {
4810
+ if (!this.source) {
4811
+ return;
4872
4812
  }
4873
- return __spreadProps(__spreadValues({}, data), { zones: _zones });
4874
- }
4875
- if (action.type === "setData") {
4876
- if (typeof action.data === "object") {
4877
- return __spreadValues(__spreadValues({}, data), action.data);
4813
+ event.preventDefault();
4814
+ event.stopPropagation();
4815
+ const { status } = this.manager.dragOperation;
4816
+ if (!status.idle) {
4817
+ const canceled = !status.initialized;
4818
+ this.manager.actions.stop({ canceled });
4878
4819
  }
4879
- return __spreadValues(__spreadValues({}, data), action.data(data));
4820
+ this.cleanup.forEach((cleanup) => cleanup());
4821
+ this.cleanup.clear();
4880
4822
  }
4881
- return data;
4882
- }
4883
-
4884
- // reducer/state.ts
4885
- init_react_import();
4886
- var reduceUi = (ui, action) => {
4887
- if (action.type === "setUi") {
4888
- if (typeof action.ui === "object") {
4889
- return __spreadValues(__spreadValues({}, ui), action.ui);
4823
+ handleKeyDown(event) {
4824
+ if (event.key === "Escape") {
4825
+ event.preventDefault();
4826
+ this.handleCancel();
4890
4827
  }
4891
- return __spreadValues(__spreadValues({}, ui), action.ui(ui));
4892
4828
  }
4893
- if (action.type === "duplicate") {
4894
- return __spreadProps(__spreadValues({}, ui), {
4895
- itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4829
+ handleStart(source, event) {
4830
+ var _a;
4831
+ const { manager, initialCoordinates } = this;
4832
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
4833
+ if (!initialCoordinates || manager.dragOperation.status.initialized) {
4834
+ return;
4835
+ }
4836
+ if (event.defaultPrevented) {
4837
+ return;
4838
+ }
4839
+ event.preventDefault();
4840
+ (0, import_state3.batch)(() => {
4841
+ manager.actions.setDragSource(source.id);
4842
+ manager.actions.start({ coordinates: initialCoordinates, event });
4896
4843
  });
4844
+ const ownerDocument = (0, import_utilities.getDocument)(event.target);
4845
+ const unbind = this.listeners.bind(ownerDocument, [
4846
+ {
4847
+ // Prevent scrolling on touch devices
4848
+ type: "touchmove",
4849
+ listener: preventDefault,
4850
+ options: {
4851
+ passive: false
4852
+ }
4853
+ },
4854
+ {
4855
+ // Prevent click events
4856
+ type: "click",
4857
+ listener: preventDefault
4858
+ },
4859
+ {
4860
+ type: "keydown",
4861
+ listener: this.handleKeyDown
4862
+ }
4863
+ ]);
4864
+ ownerDocument.body.setPointerCapture(event.pointerId);
4865
+ this.cleanup.add(unbind);
4897
4866
  }
4898
- if (action.type === "remove") {
4899
- return __spreadProps(__spreadValues({}, ui), {
4900
- itemSelector: null
4901
- });
4867
+ handleDragStart(event) {
4868
+ const { target } = event;
4869
+ if (!(0, import_utilities.isElement)(target)) {
4870
+ return;
4871
+ }
4872
+ const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
4873
+ if (isNativeDraggable) {
4874
+ this.handleCancel();
4875
+ } else {
4876
+ preventDefault(event);
4877
+ }
4902
4878
  }
4903
- return ui;
4904
- };
4905
-
4906
- // reducer/actions.tsx
4907
- init_react_import();
4908
-
4909
- // reducer/index.ts
4910
- function storeInterceptor(reducer, record, onAction) {
4911
- return (state, action) => {
4912
- const newAppState = reducer(state, action);
4913
- const isValidType = ![
4914
- "registerZone",
4915
- "unregisterZone",
4916
- "setData",
4917
- "setUi",
4918
- "set"
4919
- ].includes(action.type);
4920
- if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
4921
- if (record) record(newAppState);
4879
+ handleCancel() {
4880
+ const { dragOperation } = this.manager;
4881
+ if (dragOperation.status.initialized) {
4882
+ this.manager.actions.stop({ canceled: true });
4922
4883
  }
4923
- onAction == null ? void 0 : onAction(action, newAppState, state);
4924
- return newAppState;
4925
- };
4926
- }
4927
- var setAction = (state, action) => {
4928
- if (typeof action.state === "object") {
4929
- return __spreadValues(__spreadValues({}, state), action.state);
4884
+ this.cleanup.forEach((cleanup) => cleanup());
4885
+ this.cleanup.clear();
4886
+ }
4887
+ destroy() {
4888
+ this.listeners.clear();
4930
4889
  }
4931
- return __spreadValues(__spreadValues({}, state), action.state(state));
4932
4890
  };
4933
- function createReducer({
4934
- config,
4935
- record,
4936
- onAction
4937
- }) {
4938
- return storeInterceptor(
4939
- (state, action) => {
4940
- const data = reduceData(state.data, action, config);
4941
- const ui = reduceUi(state.ui, action);
4942
- if (action.type === "set") {
4943
- return setAction(state, action);
4944
- }
4945
- return { data, ui };
4946
- },
4947
- record,
4948
- onAction
4949
- );
4891
+ _clearTimeout = new WeakMap();
4892
+ _PointerSensor.configure = (0, import_abstract10.configurator)(_PointerSensor);
4893
+ var PointerSensor = _PointerSensor;
4894
+ function preventDefault(event) {
4895
+ event.preventDefault();
4950
4896
  }
4951
-
4952
- // lib/insert-component.ts
4953
- var insertComponent = (componentType, zone, index, {
4954
- config,
4955
- dispatch,
4956
- resolveData,
4957
- state
4958
- }) => {
4959
- const id = generateId(componentType);
4960
- const insertActionData = {
4961
- type: "insert",
4962
- componentType,
4963
- destinationIndex: index,
4964
- destinationZone: zone,
4965
- id
4966
- };
4967
- const insertedData = insertAction(state.data, insertActionData, config);
4968
- dispatch(__spreadProps(__spreadValues({}, insertActionData), {
4969
- // Dispatch insert rather set, as user's may rely on this via onAction
4970
- // We must always record history here so the insert is added to user history
4971
- // If the user has defined a resolveData method, they will end up with 2 history
4972
- // entries on insert - one for the initial insert, and one when the data resolves
4973
- recordHistory: true
4974
- }));
4975
- const itemSelector = {
4976
- index,
4977
- zone
4978
- };
4979
- dispatch({ type: "setUi", ui: { itemSelector } });
4980
- resolveData({
4981
- data: insertedData,
4982
- ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector })
4983
- });
4984
- };
4985
-
4986
- // components/DragDropContext/index.tsx
4987
- var import_use_debounce2 = require("use-debounce");
4988
- var import_zustand3 = require("zustand");
4989
-
4990
- // lib/get-deep-dir.ts
4991
- init_react_import();
4992
- function getDeepDir(el) {
4993
- function findDir(node) {
4994
- if (!node) return "ltr";
4995
- const d = node.getAttribute("dir");
4996
- return d || findDir(node.parentElement);
4897
+ function noop() {
4898
+ }
4899
+ var windows = /* @__PURE__ */ new WeakSet();
4900
+ function patchWindow(window2) {
4901
+ if (!window2 || windows.has(window2)) {
4902
+ return;
4997
4903
  }
4998
- return el ? findDir(el) : "ltr";
4904
+ window2.addEventListener("touchmove", noop, {
4905
+ capture: false,
4906
+ passive: false
4907
+ });
4908
+ windows.add(window2);
4999
4909
  }
5000
4910
 
5001
4911
  // components/DragDropContext/index.tsx
4912
+ var import_zustand3 = require("zustand");
5002
4913
  var import_jsx_runtime23 = require("react/jsx-runtime");
5003
4914
  var DEBUG3 = false;
5004
- var dragListenerContext = (0, import_react32.createContext)({
4915
+ var dragListenerContext = (0, import_react31.createContext)({
5005
4916
  dragListeners: {}
5006
4917
  });
5007
4918
  function useDragListener(type, fn, deps = []) {
5008
- const { setDragListeners } = (0, import_react32.useContext)(dragListenerContext);
5009
- (0, import_react32.useEffect)(() => {
4919
+ const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
4920
+ (0, import_react31.useEffect)(() => {
5010
4921
  if (setDragListeners) {
5011
4922
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
5012
4923
  [type]: [...old[type] || [], fn]
@@ -5016,8 +4927,8 @@ function useDragListener(type, fn, deps = []) {
5016
4927
  }
5017
4928
  var AREA_CHANGE_DEBOUNCE_MS = 100;
5018
4929
  var useTempDisableFallback = (timeout3) => {
5019
- const lastFallbackDisable = (0, import_react32.useRef)(null);
5020
- return (0, import_react32.useCallback)((manager) => {
4930
+ const lastFallbackDisable = (0, import_react31.useRef)(null);
4931
+ return (0, import_react31.useCallback)((manager) => {
5021
4932
  collisionStore.setState({ fallbackEnabled: false });
5022
4933
  const fallbackId = generateId();
5023
4934
  lastFallbackDisable.current = fallbackId;
@@ -5034,11 +4945,11 @@ var DragDropContextClient = ({
5034
4945
  disableAutoScroll
5035
4946
  }) => {
5036
4947
  const { state, config, dispatch, resolveData } = useAppContext();
5037
- const id = (0, import_react32.useId)();
4948
+ const id = (0, import_react31.useId)();
5038
4949
  const { data } = state;
5039
- const debouncedParamsRef = (0, import_react32.useRef)(null);
4950
+ const debouncedParamsRef = (0, import_react31.useRef)(null);
5040
4951
  const tempDisableFallback = useTempDisableFallback(100);
5041
- const [zoneStore] = (0, import_react32.useState)(
4952
+ const [zoneStore] = (0, import_react31.useState)(
5042
4953
  () => (0, import_zustand3.createStore)(() => ({
5043
4954
  zoneDepthIndex: {},
5044
4955
  nextZoneDepthIndex: {},
@@ -5048,7 +4959,7 @@ var DragDropContextClient = ({
5048
4959
  previewIndex: {}
5049
4960
  }))
5050
4961
  );
5051
- const getChanged2 = (0, import_react32.useCallback)(
4962
+ const getChanged2 = (0, import_react31.useCallback)(
5052
4963
  (params, id2) => {
5053
4964
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
5054
4965
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -5069,7 +4980,7 @@ var DragDropContextClient = ({
5069
4980
  },
5070
4981
  [zoneStore]
5071
4982
  );
5072
- const setDeepestAndCollide = (0, import_react32.useCallback)(
4983
+ const setDeepestAndCollide = (0, import_react31.useCallback)(
5073
4984
  (params, manager) => {
5074
4985
  const { zoneChanged, areaChanged } = getChanged2(params, id);
5075
4986
  if (!zoneChanged && !areaChanged) return;
@@ -5093,7 +5004,7 @@ var DragDropContextClient = ({
5093
5004
  setDeepestDb.cancel();
5094
5005
  debouncedParamsRef.current = null;
5095
5006
  };
5096
- (0, import_react32.useEffect)(() => {
5007
+ (0, import_react31.useEffect)(() => {
5097
5008
  if (DEBUG3) {
5098
5009
  zoneStore.subscribe(
5099
5010
  (s) => {
@@ -5107,7 +5018,7 @@ var DragDropContextClient = ({
5107
5018
  );
5108
5019
  }
5109
5020
  }, []);
5110
- const [plugins] = (0, import_react32.useState)(() => [
5021
+ const [plugins] = (0, import_react31.useState)(() => [
5111
5022
  ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
5112
5023
  createNestedDroppablePlugin(
5113
5024
  {
@@ -5154,11 +5065,29 @@ var DragDropContextClient = ({
5154
5065
  id
5155
5066
  )
5156
5067
  ]);
5157
- const sensors = useSensors();
5158
- const [dragListeners, setDragListeners] = (0, import_react32.useState)({});
5159
- const [pathData, setPathData] = (0, import_react32.useState)();
5160
- const dragMode = (0, import_react32.useRef)(null);
5161
- const registerPath = (0, import_react32.useCallback)(
5068
+ const [sensors] = (0, import_react31.useState)(() => [
5069
+ PointerSensor.configure({
5070
+ activationConstraints(event, source) {
5071
+ var _a;
5072
+ const { pointerType, target } = event;
5073
+ if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
5074
+ return void 0;
5075
+ }
5076
+ const delay = { value: 200, tolerance: 10 };
5077
+ if (pointerType === "touch") {
5078
+ return { delay };
5079
+ }
5080
+ return {
5081
+ delay,
5082
+ distance: { value: 5 }
5083
+ };
5084
+ }
5085
+ })
5086
+ ]);
5087
+ const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
5088
+ const [pathData, setPathData] = (0, import_react31.useState)();
5089
+ const dragMode = (0, import_react31.useRef)(null);
5090
+ const registerPath = (0, import_react31.useCallback)(
5162
5091
  (id2, selector, label) => {
5163
5092
  const [area] = getZoneId(selector.zone);
5164
5093
  setPathData((latestPathData = {}) => {
@@ -5176,7 +5105,7 @@ var DragDropContextClient = ({
5176
5105
  },
5177
5106
  [data, setPathData]
5178
5107
  );
5179
- const unregisterPath = (0, import_react32.useCallback)(
5108
+ const unregisterPath = (0, import_react31.useCallback)(
5180
5109
  (id2) => {
5181
5110
  setPathData((latestPathData = {}) => {
5182
5111
  const newPathData = __spreadValues({}, latestPathData);
@@ -5186,7 +5115,7 @@ var DragDropContextClient = ({
5186
5115
  },
5187
5116
  [data, setPathData]
5188
5117
  );
5189
- const initialSelector = (0, import_react32.useRef)(void 0);
5118
+ const initialSelector = (0, import_react31.useRef)(void 0);
5190
5119
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5191
5120
  dragListenerContext.Provider,
5192
5121
  {
@@ -5195,7 +5124,7 @@ var DragDropContextClient = ({
5195
5124
  setDragListeners
5196
5125
  },
5197
5126
  children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5198
- import_react31.DragDropProvider,
5127
+ import_react30.DragDropProvider,
5199
5128
  {
5200
5129
  plugins,
5201
5130
  sensors,
@@ -5217,13 +5146,6 @@ var DragDropContextClient = ({
5217
5146
  (_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
5218
5147
  fn(event, manager);
5219
5148
  });
5220
- dispatch({
5221
- type: "setUi",
5222
- ui: {
5223
- itemSelector: null,
5224
- isDragging: false
5225
- }
5226
- });
5227
5149
  return;
5228
5150
  }
5229
5151
  if (thisPreview) {
@@ -5281,8 +5203,7 @@ var DragDropContextClient = ({
5281
5203
  targetZone = targetData.zone;
5282
5204
  targetIndex = targetData.index;
5283
5205
  const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
5284
- const dir = getDeepDir(target.element);
5285
- 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";
5206
+ const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
5286
5207
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
5287
5208
  targetIndex = targetIndex - 1;
5288
5209
  }
@@ -5424,7 +5345,7 @@ var DrawerItemInner = ({
5424
5345
  dragRef,
5425
5346
  isDragDisabled
5426
5347
  }) => {
5427
- const CustomInner = (0, import_react33.useMemo)(
5348
+ const CustomInner = (0, import_react32.useMemo)(
5428
5349
  () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
5429
5350
  [children]
5430
5351
  );
@@ -5478,7 +5399,7 @@ var DrawerItem = ({
5478
5399
  isDragDisabled
5479
5400
  }) => {
5480
5401
  const resolvedId = id || name;
5481
- const [dynamicId, setDynamicId] = (0, import_react33.useState)(generateId(resolvedId));
5402
+ const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
5482
5403
  if (typeof index !== "undefined") {
5483
5404
  console.error(
5484
5405
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -5517,7 +5438,7 @@ var Drawer = ({
5517
5438
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
5518
5439
  );
5519
5440
  }
5520
- const id = (0, import_react33.useId)();
5441
+ const id = (0, import_react32.useId)();
5521
5442
  const { ref } = useDroppableSafe({
5522
5443
  id,
5523
5444
  type: "void",
@@ -5539,18 +5460,18 @@ Drawer.Item = DrawerItem;
5539
5460
 
5540
5461
  // components/Puck/index.tsx
5541
5462
  init_react_import();
5542
- var import_react51 = require("react");
5463
+ var import_react50 = require("react");
5543
5464
 
5544
5465
  // components/SidebarSection/index.tsx
5545
5466
  init_react_import();
5546
5467
 
5547
5468
  // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
5548
5469
  init_react_import();
5549
- 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" };
5470
+ 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" };
5550
5471
 
5551
5472
  // lib/use-breadcrumbs.ts
5552
5473
  init_react_import();
5553
- var import_react34 = require("react");
5474
+ var import_react33 = require("react");
5554
5475
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
5555
5476
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
5556
5477
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -5600,8 +5521,8 @@ var useBreadcrumbs = (renderCount) => {
5600
5521
  state: { data },
5601
5522
  selectedItem
5602
5523
  } = useAppContext();
5603
- const dzContext = (0, import_react34.useContext)(dropZoneContext);
5604
- return (0, import_react34.useMemo)(() => {
5524
+ const dzContext = (0, import_react33.useContext)(dropZoneContext);
5525
+ return (0, import_react33.useMemo)(() => {
5605
5526
  const breadcrumbs = convertPathDataToBreadcrumbs(
5606
5527
  selectedItem,
5607
5528
  dzContext == null ? void 0 : dzContext.pathData,
@@ -5725,7 +5646,7 @@ function MenuBar({
5725
5646
 
5726
5647
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5727
5648
  init_react_import();
5728
- 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" };
5649
+ 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" };
5729
5650
 
5730
5651
  // components/Puck/components/Fields/index.tsx
5731
5652
  init_react_import();
@@ -5735,15 +5656,15 @@ init_react_import();
5735
5656
  var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
5736
5657
 
5737
5658
  // components/Puck/components/Fields/index.tsx
5738
- var import_react38 = require("react");
5659
+ var import_react37 = require("react");
5739
5660
 
5740
5661
  // lib/use-resolved-fields.ts
5741
5662
  init_react_import();
5742
- var import_react37 = require("react");
5663
+ var import_react36 = require("react");
5743
5664
 
5744
5665
  // lib/use-parent.ts
5745
5666
  init_react_import();
5746
- var import_react35 = require("react");
5667
+ var import_react34 = require("react");
5747
5668
  var getParent = (itemSelector, pathData, data) => {
5748
5669
  var _a;
5749
5670
  if (!itemSelector) return null;
@@ -5755,8 +5676,8 @@ var getParent = (itemSelector, pathData, data) => {
5755
5676
  };
5756
5677
  var useGetParent = () => {
5757
5678
  const { state } = useAppContext();
5758
- const { pathData } = (0, import_react35.useContext)(dropZoneContext) || {};
5759
- return (0, import_react35.useCallback)(
5679
+ const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
5680
+ return (0, import_react34.useCallback)(
5760
5681
  () => getParent(state.ui.itemSelector, pathData, state.data),
5761
5682
  [state.ui.itemSelector, pathData, state.data]
5762
5683
  );
@@ -5767,10 +5688,10 @@ var useParent = () => {
5767
5688
 
5768
5689
  // lib/use-on-value-change.ts
5769
5690
  init_react_import();
5770
- var import_react36 = require("react");
5691
+ var import_react35 = require("react");
5771
5692
  function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
5772
- const tracked = (0, import_react36.useRef)(value);
5773
- (0, import_react36.useEffect)(() => {
5693
+ const tracked = (0, import_react35.useRef)(value);
5694
+ (0, import_react35.useEffect)(() => {
5774
5695
  const oldValue = tracked.current;
5775
5696
  if (!compare(value, oldValue)) {
5776
5697
  tracked.current = value;
@@ -5787,37 +5708,31 @@ var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0
5787
5708
  var defaultPageFields = {
5788
5709
  title: { type: "text" }
5789
5710
  };
5790
- var useResolvedFields = ({
5791
- _skipValueCheck,
5792
- _skipIdCheck
5793
- } = {}) => {
5711
+ var useResolvedFields = () => {
5794
5712
  var _a, _b;
5795
5713
  const { selectedItem, state, config } = useAppContext();
5796
5714
  const parent = useParent();
5797
5715
  const { data } = state;
5798
5716
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5799
5717
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5800
- const defaultFields = (0, import_react37.useMemo)(
5718
+ const defaultFields = (0, import_react36.useMemo)(
5801
5719
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5802
5720
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5803
5721
  );
5804
5722
  const rootProps = data.root.props || data.root;
5805
- const [lastSelectedData, setLastSelectedData] = (0, import_react37.useState)({});
5806
- const [resolvedFields, setResolvedFields] = (0, import_react37.useState)({
5807
- fields: defaultFields,
5808
- id: selectedItem == null ? void 0 : selectedItem.props.id
5809
- });
5810
- const [fieldsLoading, setFieldsLoading] = (0, import_react37.useState)(false);
5811
- const lastFields = (0, import_react37.useRef)(defaultFields);
5723
+ const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
5724
+ const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
5725
+ const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
5726
+ const lastFields = (0, import_react36.useRef)(defaultFields);
5812
5727
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5813
- const componentData = (0, import_react37.useMemo)(
5728
+ const componentData = (0, import_react36.useMemo)(
5814
5729
  () => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
5815
5730
  [selectedItem, rootProps, data.root.readOnly]
5816
5731
  );
5817
5732
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5818
5733
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5819
5734
  const hasResolver = hasComponentResolver || hasRootResolver;
5820
- const resolveFields = (0, import_react37.useCallback)(
5735
+ const resolveFields = (0, import_react36.useCallback)(
5821
5736
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5822
5737
  var _a2;
5823
5738
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5855,27 +5770,23 @@ var useResolvedFields = ({
5855
5770
  }),
5856
5771
  [data, config, componentData, selectedItem, state, parent]
5857
5772
  );
5858
- const triggerResolver = (0, import_react37.useCallback)(() => {
5773
+ const triggerResolver = (0, import_react36.useCallback)(() => {
5859
5774
  var _a2, _b2;
5860
5775
  if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
5861
5776
  if (hasResolver) {
5862
5777
  setFieldsLoading(true);
5863
5778
  resolveFields(defaultFields).then((fields) => {
5864
- setResolvedFields({
5865
- fields: fields || {},
5866
- id: selectedItem == null ? void 0 : selectedItem.props.id
5867
- });
5779
+ setResolvedFields(fields || {});
5868
5780
  lastFields.current = fields;
5869
5781
  setFieldsLoading(false);
5870
5782
  });
5871
5783
  return;
5872
5784
  }
5873
5785
  }
5874
- setResolvedFields({ fields: defaultFields, id: selectedItem == null ? void 0 : selectedItem.props.id });
5786
+ setResolvedFields(defaultFields);
5875
5787
  }, [
5876
5788
  defaultFields,
5877
5789
  state.ui.itemSelector,
5878
- selectedItem,
5879
5790
  hasResolver,
5880
5791
  parent,
5881
5792
  resolveFields
@@ -5890,18 +5801,14 @@ var useResolvedFields = ({
5890
5801
  useOnValueChange(
5891
5802
  { data, parent, itemSelector: state.ui.itemSelector },
5892
5803
  () => {
5893
- if (_skipValueCheck) return;
5894
5804
  triggerResolver();
5895
5805
  },
5896
5806
  (a, b) => JSON.stringify(a) === JSON.stringify(b)
5897
5807
  );
5898
- (0, import_react37.useEffect)(() => {
5808
+ (0, import_react36.useEffect)(() => {
5899
5809
  triggerResolver();
5900
5810
  }, []);
5901
- if (resolvedFields.id !== (selectedItem == null ? void 0 : selectedItem.props.id) && !_skipIdCheck) {
5902
- return [defaultFields, fieldsLoading];
5903
- }
5904
- return [resolvedFields.fields, fieldsLoading];
5811
+ return [resolvedFields, fieldsLoading];
5905
5812
  };
5906
5813
 
5907
5814
  // components/Puck/components/Fields/index.tsx
@@ -5930,7 +5837,7 @@ var Fields = ({ wrapFields = true }) => {
5930
5837
  const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
5931
5838
  const isLoading = fieldsResolving || componentResolving;
5932
5839
  const rootProps = data.root.props || data.root;
5933
- const Wrapper = (0, import_react38.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
5840
+ const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
5934
5841
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
5935
5842
  "form",
5936
5843
  {
@@ -6051,14 +5958,14 @@ init_react_import();
6051
5958
 
6052
5959
  // lib/use-component-list.tsx
6053
5960
  init_react_import();
6054
- var import_react39 = require("react");
5961
+ var import_react38 = require("react");
6055
5962
 
6056
5963
  // components/ComponentList/index.tsx
6057
5964
  init_react_import();
6058
5965
 
6059
5966
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6060
5967
  init_react_import();
6061
- 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" };
5968
+ 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" };
6062
5969
 
6063
5970
  // components/ComponentList/index.tsx
6064
5971
  var import_jsx_runtime28 = require("react/jsx-runtime");
@@ -6118,8 +6025,8 @@ ComponentList.Item = ComponentListItem;
6118
6025
  // lib/use-component-list.tsx
6119
6026
  var import_jsx_runtime29 = require("react/jsx-runtime");
6120
6027
  var useComponentList = (config, ui) => {
6121
- const [componentList, setComponentList] = (0, import_react39.useState)();
6122
- (0, import_react39.useEffect)(() => {
6028
+ const [componentList, setComponentList] = (0, import_react38.useState)();
6029
+ (0, import_react38.useEffect)(() => {
6123
6030
  var _a, _b, _c;
6124
6031
  if (Object.keys(ui.componentList).length > 0) {
6125
6032
  const matchedComponents = [];
@@ -6188,22 +6095,22 @@ var useComponentList = (config, ui) => {
6188
6095
  };
6189
6096
 
6190
6097
  // components/Puck/components/Components/index.tsx
6191
- var import_react40 = require("react");
6098
+ var import_react39 = require("react");
6192
6099
  var import_jsx_runtime30 = require("react/jsx-runtime");
6193
6100
  var Components = () => {
6194
6101
  const { config, state, overrides } = useAppContext();
6195
6102
  const componentList = useComponentList(config, state.ui);
6196
- const Wrapper = (0, import_react40.useMemo)(() => overrides.components || "div", [overrides]);
6103
+ const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
6197
6104
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
6198
6105
  };
6199
6106
 
6200
6107
  // components/Puck/components/Preview/index.tsx
6201
6108
  init_react_import();
6202
- var import_react42 = require("react");
6109
+ var import_react41 = require("react");
6203
6110
 
6204
6111
  // components/AutoFrame/index.tsx
6205
6112
  init_react_import();
6206
- var import_react41 = require("react");
6113
+ var import_react40 = require("react");
6207
6114
  var import_object_hash = __toESM(require("object-hash"));
6208
6115
  var import_react_dom3 = require("react-dom");
6209
6116
  var import_jsx_runtime31 = require("react/jsx-runtime");
@@ -6249,7 +6156,7 @@ var CopyHostStyles = ({
6249
6156
  onStylesLoaded = () => null
6250
6157
  }) => {
6251
6158
  const { document: doc, window: win } = useFrame();
6252
- (0, import_react41.useEffect)(() => {
6159
+ (0, import_react40.useEffect)(() => {
6253
6160
  if (!win || !doc) {
6254
6161
  return () => {
6255
6162
  };
@@ -6408,8 +6315,8 @@ var CopyHostStyles = ({
6408
6315
  }, []);
6409
6316
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
6410
6317
  };
6411
- var autoFrameContext = (0, import_react41.createContext)({});
6412
- var useFrame = () => (0, import_react41.useContext)(autoFrameContext);
6318
+ var autoFrameContext = (0, import_react40.createContext)({});
6319
+ var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
6413
6320
  function AutoFrame(_a) {
6414
6321
  var _b = _a, {
6415
6322
  children,
@@ -6426,10 +6333,10 @@ function AutoFrame(_a) {
6426
6333
  "onStylesLoaded",
6427
6334
  "frameRef"
6428
6335
  ]);
6429
- const [loaded, setLoaded] = (0, import_react41.useState)(false);
6430
- const [ctx, setCtx] = (0, import_react41.useState)({});
6431
- const [mountTarget, setMountTarget] = (0, import_react41.useState)();
6432
- (0, import_react41.useEffect)(() => {
6336
+ const [loaded, setLoaded] = (0, import_react40.useState)(false);
6337
+ const [ctx, setCtx] = (0, import_react40.useState)({});
6338
+ const [mountTarget, setMountTarget] = (0, import_react40.useState)();
6339
+ (0, import_react40.useEffect)(() => {
6433
6340
  var _a2;
6434
6341
  if (frameRef.current) {
6435
6342
  setCtx({
@@ -6491,14 +6398,13 @@ function Render({
6491
6398
  config.root.render,
6492
6399
  __spreadProps(__spreadValues({}, rootProps), {
6493
6400
  puck: {
6494
- renderDropZone: DropZonePure,
6495
- isEditing: false,
6496
- dragRef: null
6401
+ renderDropZone: DropZone,
6402
+ isEditing: false
6497
6403
  },
6498
6404
  title,
6499
6405
  editMode: false,
6500
6406
  id: "puck-root",
6501
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
6407
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
6502
6408
  })
6503
6409
  )
6504
6410
  }
@@ -6514,7 +6420,7 @@ function Render({
6514
6420
  depth: 0,
6515
6421
  path: []
6516
6422
  },
6517
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
6423
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
6518
6424
  }
6519
6425
  );
6520
6426
  }
@@ -6524,7 +6430,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
6524
6430
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
6525
6431
  var useBubbleIframeEvents = (ref) => {
6526
6432
  const { status } = useAppContext();
6527
- (0, import_react42.useEffect)(() => {
6433
+ (0, import_react41.useEffect)(() => {
6528
6434
  var _a;
6529
6435
  if (ref.current && status === "READY") {
6530
6436
  const iframe = ref.current;
@@ -6557,7 +6463,7 @@ var useBubbleIframeEvents = (ref) => {
6557
6463
  };
6558
6464
  var Preview2 = ({ id = "puck-preview" }) => {
6559
6465
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
6560
- const Page = (0, import_react42.useCallback)(
6466
+ const Page = (0, import_react41.useCallback)(
6561
6467
  (pageProps) => {
6562
6468
  var _a, _b;
6563
6469
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
@@ -6566,20 +6472,20 @@ var Preview2 = ({ id = "puck-preview" }) => {
6566
6472
  },
6567
6473
  [config.root]
6568
6474
  );
6569
- const Frame = (0, import_react42.useMemo)(() => overrides.iframe, [overrides]);
6475
+ const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
6570
6476
  const rootProps = state.data.root.props || state.data.root;
6571
- const ref = (0, import_react42.useRef)(null);
6477
+ const ref = (0, import_react41.useRef)(null);
6572
6478
  useBubbleIframeEvents(ref);
6573
6479
  const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6574
6480
  Page,
6575
6481
  __spreadProps(__spreadValues({}, rootProps), {
6576
6482
  puck: {
6577
- renderDropZone: DropZonePure,
6483
+ renderDropZone: DropZone,
6578
6484
  isEditing: true,
6579
6485
  dragRef: null
6580
6486
  },
6581
6487
  editMode: true,
6582
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZonePure, { zone: rootDroppableId })
6488
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
6583
6489
  })
6584
6490
  ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render, { data: state.data, config });
6585
6491
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
@@ -6651,7 +6557,7 @@ init_react_import();
6651
6557
 
6652
6558
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
6653
6559
  init_react_import();
6654
- 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" };
6560
+ 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" };
6655
6561
 
6656
6562
  // lib/scroll-into-view.ts
6657
6563
  init_react_import();
@@ -6665,7 +6571,7 @@ var scrollIntoView = (el) => {
6665
6571
  };
6666
6572
 
6667
6573
  // components/LayerTree/index.tsx
6668
- var import_react43 = require("react");
6574
+ var import_react42 = require("react");
6669
6575
 
6670
6576
  // lib/is-child-of-zone.ts
6671
6577
  init_react_import();
@@ -6711,7 +6617,7 @@ var LayerTree = ({
6711
6617
  label
6712
6618
  }) => {
6713
6619
  const zones = data.zones || {};
6714
- const ctx = (0, import_react43.useContext)(dropZoneContext);
6620
+ const ctx = (0, import_react42.useContext)(dropZoneContext);
6715
6621
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
6716
6622
  label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
6717
6623
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
@@ -6818,13 +6724,13 @@ var LayerTree = ({
6818
6724
  };
6819
6725
 
6820
6726
  // components/Puck/components/Outline/index.tsx
6821
- var import_react44 = require("react");
6727
+ var import_react43 = require("react");
6822
6728
  var import_jsx_runtime35 = require("react/jsx-runtime");
6823
6729
  var Outline = () => {
6824
6730
  const { dispatch, state, overrides, config } = useAppContext();
6825
6731
  const { data, ui } = state;
6826
6732
  const { itemSelector } = ui;
6827
- const setItemSelector = (0, import_react44.useCallback)(
6733
+ const setItemSelector = (0, import_react43.useCallback)(
6828
6734
  (newItemSelector) => {
6829
6735
  dispatch({
6830
6736
  type: "setUi",
@@ -6833,7 +6739,7 @@ var Outline = () => {
6833
6739
  },
6834
6740
  []
6835
6741
  );
6836
- const Wrapper = (0, import_react44.useMemo)(() => overrides.outline || "div", [overrides]);
6742
+ const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
6837
6743
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
6838
6744
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
6839
6745
  LayerTree,
@@ -6947,19 +6853,19 @@ function usePuckHistory({
6947
6853
 
6948
6854
  // lib/use-history-store.ts
6949
6855
  init_react_import();
6950
- var import_react45 = require("react");
6856
+ var import_react44 = require("react");
6951
6857
  var import_use_debounce3 = require("use-debounce");
6952
6858
  var EMPTY_HISTORY_INDEX = 0;
6953
6859
  function useHistoryStore(initialHistory) {
6954
6860
  var _a, _b;
6955
- const [histories, setHistories] = (0, import_react45.useState)(
6861
+ const [histories, setHistories] = (0, import_react44.useState)(
6956
6862
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
6957
6863
  );
6958
6864
  const updateHistories = (histories2) => {
6959
6865
  setHistories(histories2);
6960
6866
  setIndex(histories2.length - 1);
6961
6867
  };
6962
- const [index, setIndex] = (0, import_react45.useState)(
6868
+ const [index, setIndex] = (0, import_react44.useState)(
6963
6869
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
6964
6870
  );
6965
6871
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -7119,15 +7025,15 @@ var getBox = function getBox2(el) {
7119
7025
  };
7120
7026
 
7121
7027
  // components/Puck/components/Canvas/index.tsx
7122
- var import_react47 = require("react");
7028
+ var import_react46 = require("react");
7123
7029
 
7124
7030
  // components/ViewportControls/index.tsx
7125
7031
  init_react_import();
7126
- var import_react46 = require("react");
7032
+ var import_react45 = require("react");
7127
7033
 
7128
7034
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7129
7035
  init_react_import();
7130
- 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" };
7036
+ 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" };
7131
7037
 
7132
7038
  // components/ViewportControls/index.tsx
7133
7039
  var import_jsx_runtime36 = require("react/jsx-runtime");
@@ -7146,8 +7052,8 @@ var ViewportButton = ({
7146
7052
  onClick
7147
7053
  }) => {
7148
7054
  const { state } = useAppContext();
7149
- const [isActive, setIsActive] = (0, import_react46.useState)(false);
7150
- (0, import_react46.useEffect)(() => {
7055
+ const [isActive, setIsActive] = (0, import_react45.useState)(false);
7056
+ (0, import_react45.useEffect)(() => {
7151
7057
  setIsActive(width === state.ui.viewports.current.width);
7152
7058
  }, [width, state.ui.viewports.current.width]);
7153
7059
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
@@ -7183,7 +7089,7 @@ var ViewportControls = ({
7183
7089
  const defaultsContainAutoZoom = defaultZoomOptions.find(
7184
7090
  (option) => option.value === autoZoom
7185
7091
  );
7186
- const zoomOptions = (0, import_react46.useMemo)(
7092
+ const zoomOptions = (0, import_react45.useMemo)(
7187
7093
  () => [
7188
7094
  ...defaultZoomOptions,
7189
7095
  ...defaultsContainAutoZoom ? [] : [
@@ -7306,17 +7212,17 @@ var Canvas = () => {
7306
7212
  const { status, iframe } = useAppContext();
7307
7213
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
7308
7214
  const { ui } = state;
7309
- const frameRef = (0, import_react47.useRef)(null);
7310
- const [showTransition, setShowTransition] = (0, import_react47.useState)(false);
7311
- const defaultRender = (0, import_react47.useMemo)(() => {
7215
+ const frameRef = (0, import_react46.useRef)(null);
7216
+ const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
7217
+ const defaultRender = (0, import_react46.useMemo)(() => {
7312
7218
  const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
7313
7219
  return PuckDefault;
7314
7220
  }, []);
7315
- const CustomPreview = (0, import_react47.useMemo)(
7221
+ const CustomPreview = (0, import_react46.useMemo)(
7316
7222
  () => overrides.preview || defaultRender,
7317
7223
  [overrides]
7318
7224
  );
7319
- const getFrameDimensions = (0, import_react47.useCallback)(() => {
7225
+ const getFrameDimensions = (0, import_react46.useCallback)(() => {
7320
7226
  if (frameRef.current) {
7321
7227
  const frame = frameRef.current;
7322
7228
  const box = getBox(frame);
@@ -7324,7 +7230,7 @@ var Canvas = () => {
7324
7230
  }
7325
7231
  return { width: 0, height: 0 };
7326
7232
  }, [frameRef]);
7327
- const resetAutoZoom = (0, import_react47.useCallback)(
7233
+ const resetAutoZoom = (0, import_react46.useCallback)(
7328
7234
  (ui2 = state.ui) => {
7329
7235
  if (frameRef.current) {
7330
7236
  setZoomConfig(
@@ -7334,11 +7240,11 @@ var Canvas = () => {
7334
7240
  },
7335
7241
  [frameRef, zoomConfig, state.ui]
7336
7242
  );
7337
- (0, import_react47.useEffect)(() => {
7243
+ (0, import_react46.useEffect)(() => {
7338
7244
  setShowTransition(false);
7339
7245
  resetAutoZoom();
7340
7246
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
7341
- (0, import_react47.useEffect)(() => {
7247
+ (0, import_react46.useEffect)(() => {
7342
7248
  const { height: frameHeight } = getFrameDimensions();
7343
7249
  if (ui.viewports.current.height === "auto") {
7344
7250
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -7346,13 +7252,13 @@ var Canvas = () => {
7346
7252
  }));
7347
7253
  }
7348
7254
  }, [zoomConfig.zoom]);
7349
- (0, import_react47.useEffect)(() => {
7255
+ (0, import_react46.useEffect)(() => {
7350
7256
  if (ZOOM_ON_CHANGE) {
7351
7257
  setShowTransition(true);
7352
7258
  resetAutoZoom(ui);
7353
7259
  }
7354
7260
  }, [ui.viewports.current.width]);
7355
- (0, import_react47.useEffect)(() => {
7261
+ (0, import_react46.useEffect)(() => {
7356
7262
  const cb = () => {
7357
7263
  setShowTransition(false);
7358
7264
  resetAutoZoom();
@@ -7362,8 +7268,8 @@ var Canvas = () => {
7362
7268
  window.removeEventListener("resize", cb);
7363
7269
  };
7364
7270
  }, []);
7365
- const [showLoader, setShowLoader] = (0, import_react47.useState)(false);
7366
- (0, import_react47.useEffect)(() => {
7271
+ const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
7272
+ (0, import_react46.useEffect)(() => {
7367
7273
  setTimeout(() => {
7368
7274
  setShowLoader(true);
7369
7275
  }, 500);
@@ -7441,7 +7347,7 @@ var Canvas = () => {
7441
7347
 
7442
7348
  // lib/use-loaded-overrides.ts
7443
7349
  init_react_import();
7444
- var import_react48 = require("react");
7350
+ var import_react47 = require("react");
7445
7351
 
7446
7352
  // lib/load-overrides.ts
7447
7353
  init_react_import();
@@ -7480,7 +7386,7 @@ var useLoadedOverrides = ({
7480
7386
  overrides,
7481
7387
  plugins
7482
7388
  }) => {
7483
- return (0, import_react48.useMemo)(() => {
7389
+ return (0, import_react47.useMemo)(() => {
7484
7390
  return loadOverrides({ overrides, plugins });
7485
7391
  }, [plugins, overrides]);
7486
7392
  };
@@ -7492,14 +7398,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
7492
7398
 
7493
7399
  // lib/use-inject-css.ts
7494
7400
  init_react_import();
7495
- var import_react49 = require("react");
7401
+ var import_react48 = require("react");
7496
7402
  var styles = ``;
7497
7403
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7498
- const [el, setEl] = (0, import_react49.useState)();
7499
- (0, import_react49.useEffect)(() => {
7404
+ const [el, setEl] = (0, import_react48.useState)();
7405
+ (0, import_react48.useEffect)(() => {
7500
7406
  setEl(document.createElement("style"));
7501
7407
  }, []);
7502
- (0, import_react49.useEffect)(() => {
7408
+ (0, import_react48.useEffect)(() => {
7503
7409
  var _a;
7504
7410
  if (!el || typeof window === "undefined") {
7505
7411
  return;
@@ -7519,10 +7425,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
7519
7425
 
7520
7426
  // lib/use-preview-mode-hotkeys.ts
7521
7427
  init_react_import();
7522
- var import_react50 = require("react");
7428
+ var import_react49 = require("react");
7523
7429
  var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
7524
7430
  var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7525
- const toggleInteractive = (0, import_react50.useCallback)(() => {
7431
+ const toggleInteractive = (0, import_react49.useCallback)(() => {
7526
7432
  dispatch({
7527
7433
  type: "setUi",
7528
7434
  ui: (ui) => ({
@@ -7579,7 +7485,7 @@ function Puck({
7579
7485
  waitForStyles: true
7580
7486
  }, _iframe);
7581
7487
  useInjectGlobalCss(iframe.enabled);
7582
- const [generatedAppState] = (0, import_react51.useState)(() => {
7488
+ const [generatedAppState] = (0, import_react50.useState)(() => {
7583
7489
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
7584
7490
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7585
7491
  let clientUiState = {};
@@ -7651,14 +7557,14 @@ function Puck({
7651
7557
  histories,
7652
7558
  index: initialHistoryIndex
7653
7559
  });
7654
- const [reducer] = (0, import_react51.useState)(
7560
+ const [reducer] = (0, import_react50.useState)(
7655
7561
  () => createReducer({
7656
7562
  config,
7657
7563
  record: historyStore.record,
7658
7564
  onAction
7659
7565
  })
7660
7566
  );
7661
- const [appState, dispatch] = (0, import_react51.useReducer)(
7567
+ const [appState, dispatch] = (0, import_react50.useReducer)(
7662
7568
  reducer,
7663
7569
  flushZones(initialAppState)
7664
7570
  );
@@ -7669,14 +7575,14 @@ function Puck({
7669
7575
  historyStore,
7670
7576
  iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
7671
7577
  });
7672
- const [menuOpen, setMenuOpen] = (0, import_react51.useState)(false);
7578
+ const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
7673
7579
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
7674
7580
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
7675
- (0, import_react51.useEffect)(() => {
7581
+ (0, import_react50.useEffect)(() => {
7676
7582
  if (onChange) onChange(data);
7677
7583
  }, [data]);
7678
7584
  const rootProps = data.root.props || data.root;
7679
- const toggleSidebars = (0, import_react51.useCallback)(
7585
+ const toggleSidebars = (0, import_react50.useCallback)(
7680
7586
  (sidebar) => {
7681
7587
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7682
7588
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7690,7 +7596,7 @@ function Puck({
7690
7596
  },
7691
7597
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7692
7598
  );
7693
- (0, import_react51.useEffect)(() => {
7599
+ (0, import_react50.useEffect)(() => {
7694
7600
  if (!window.matchMedia("(min-width: 638px)").matches) {
7695
7601
  dispatch({
7696
7602
  type: "setUi",
@@ -7713,7 +7619,7 @@ function Puck({
7713
7619
  window.removeEventListener("resize", handleResize);
7714
7620
  };
7715
7621
  }, []);
7716
- const defaultHeaderRender = (0, import_react51.useMemo)(() => {
7622
+ const defaultHeaderRender = (0, import_react50.useMemo)(() => {
7717
7623
  if (renderHeader) {
7718
7624
  console.warn(
7719
7625
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -7727,7 +7633,7 @@ function Puck({
7727
7633
  }
7728
7634
  return DefaultOverride;
7729
7635
  }, [renderHeader]);
7730
- const defaultHeaderActionsRender = (0, import_react51.useMemo)(() => {
7636
+ const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
7731
7637
  if (renderHeaderActions) {
7732
7638
  console.warn(
7733
7639
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -7744,20 +7650,20 @@ function Puck({
7744
7650
  overrides,
7745
7651
  plugins
7746
7652
  });
7747
- const CustomPuck = (0, import_react51.useMemo)(
7653
+ const CustomPuck = (0, import_react50.useMemo)(
7748
7654
  () => loadedOverrides.puck || DefaultOverride,
7749
7655
  [loadedOverrides]
7750
7656
  );
7751
- const CustomHeader = (0, import_react51.useMemo)(
7657
+ const CustomHeader = (0, import_react50.useMemo)(
7752
7658
  () => loadedOverrides.header || defaultHeaderRender,
7753
7659
  [loadedOverrides]
7754
7660
  );
7755
- const CustomHeaderActions = (0, import_react51.useMemo)(
7661
+ const CustomHeaderActions = (0, import_react50.useMemo)(
7756
7662
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7757
7663
  [loadedOverrides]
7758
7664
  );
7759
- const [mounted, setMounted] = (0, import_react51.useState)(false);
7760
- (0, import_react51.useEffect)(() => {
7665
+ const [mounted, setMounted] = (0, import_react50.useState)(false);
7666
+ (0, import_react50.useEffect)(() => {
7761
7667
  setMounted(true);
7762
7668
  }, []);
7763
7669
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
@@ -8062,12 +7968,14 @@ var usePuck = () => {
8062
7968
  Button,
8063
7969
  Drawer,
8064
7970
  DropZone,
7971
+ DropZoneProvider,
8065
7972
  FieldLabel,
8066
7973
  Group,
8067
7974
  IconButton,
8068
7975
  Label,
8069
7976
  Puck,
8070
7977
  Render,
7978
+ dropZoneContext,
8071
7979
  migrate,
8072
7980
  overrideKeys,
8073
7981
  resolveAllData,