@measured/puck 0.18.2-canary.29a7f1d → 0.18.2-canary.3a69ad4
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.css +268 -279
- package/dist/index.js +1683 -1756
- package/dist/index.mjs +1109 -1182
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -260,7 +260,7 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
260
260
|
|
261
261
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
|
262
262
|
init_react_import();
|
263
|
-
var styles_module_default = { "ActionBar": "
|
263
|
+
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
264
|
|
265
265
|
// components/ActionBar/index.tsx
|
266
266
|
var import_jsx_runtime = require("react/jsx-runtime");
|
@@ -306,10 +306,10 @@ init_react_import();
|
|
306
306
|
|
307
307
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
308
308
|
init_react_import();
|
309
|
-
var styles_module_default2 = { "InputWrapper": "
|
309
|
+
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
310
|
|
311
311
|
// components/AutoField/index.tsx
|
312
|
-
var
|
312
|
+
var import_react20 = require("react");
|
313
313
|
|
314
314
|
// components/AutoField/fields/index.tsx
|
315
315
|
init_react_import();
|
@@ -319,7 +319,7 @@ init_react_import();
|
|
319
319
|
|
320
320
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/fields/ArrayField/styles.module.css#css-module
|
321
321
|
init_react_import();
|
322
|
-
var styles_module_default3 = { "ArrayField": "
|
322
|
+
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
323
|
|
324
324
|
// ../../node_modules/lucide-react/dist/esm/lucide-react.js
|
325
325
|
init_react_import();
|
@@ -769,7 +769,7 @@ var IconButton = ({
|
|
769
769
|
};
|
770
770
|
|
771
771
|
// components/AutoField/fields/ArrayField/index.tsx
|
772
|
-
var
|
772
|
+
var import_react12 = require("react");
|
773
773
|
|
774
774
|
// components/DragIcon/index.tsx
|
775
775
|
init_react_import();
|
@@ -1277,8 +1277,8 @@ function useAppContext() {
|
|
1277
1277
|
|
1278
1278
|
// components/Sortable/index.tsx
|
1279
1279
|
init_react_import();
|
1280
|
-
var
|
1281
|
-
var
|
1280
|
+
var import_react9 = require("@dnd-kit/react");
|
1281
|
+
var import_react10 = require("react");
|
1282
1282
|
|
1283
1283
|
// lib/dnd/dnd-kit/safe.ts
|
1284
1284
|
init_react_import();
|
@@ -1306,826 +1306,172 @@ function useSortableSafe(input) {
|
|
1306
1306
|
return (0, import_sortable.useSortable)(input);
|
1307
1307
|
}
|
1308
1308
|
|
1309
|
-
//
|
1310
|
-
|
1311
|
-
var
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
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
|
1309
|
+
// components/Sortable/index.tsx
|
1310
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
1311
|
+
var SortableProvider = ({
|
1312
|
+
children,
|
1313
|
+
onMove
|
1314
|
+
}) => {
|
1315
|
+
const [move, setMove] = (0, import_react10.useState)({ source: -1, target: -1 });
|
1316
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
1317
|
+
import_react9.DragDropProvider,
|
1318
|
+
{
|
1319
|
+
onDragOver: (event) => {
|
1320
|
+
const { operation } = event;
|
1321
|
+
if (operation.source && operation.target) {
|
1322
|
+
const newMove = {
|
1323
|
+
source: operation.source.data.index,
|
1324
|
+
target: operation.target.data.index
|
1325
|
+
};
|
1326
|
+
if (newMove.source !== newMove.target) {
|
1327
|
+
setMove({
|
1328
|
+
source: operation.source.data.index,
|
1329
|
+
target: operation.target.data.index
|
1330
|
+
});
|
1381
1331
|
}
|
1382
|
-
},
|
1383
|
-
{
|
1384
|
-
// Cancel activation if there is a competing Drag and Drop interaction
|
1385
|
-
type: "dragstart",
|
1386
|
-
listener: this.handleDragStart
|
1387
1332
|
}
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
|
1396
|
-
return;
|
1333
|
+
},
|
1334
|
+
onDragEnd: () => {
|
1335
|
+
if (move.source !== -1 && move.target !== -1) {
|
1336
|
+
onMove(move);
|
1337
|
+
}
|
1338
|
+
},
|
1339
|
+
children
|
1397
1340
|
}
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1341
|
+
);
|
1342
|
+
};
|
1343
|
+
var Sortable = ({
|
1344
|
+
id,
|
1345
|
+
index,
|
1346
|
+
disabled,
|
1347
|
+
children,
|
1348
|
+
type = "item"
|
1349
|
+
}) => {
|
1350
|
+
const { ref: sortableRef, status } = useSortableSafe({
|
1351
|
+
id,
|
1352
|
+
type,
|
1353
|
+
index,
|
1354
|
+
disabled,
|
1355
|
+
data: { index }
|
1356
|
+
});
|
1357
|
+
return children({ status, ref: sortableRef });
|
1358
|
+
};
|
1359
|
+
|
1360
|
+
// components/AutoField/context.tsx
|
1361
|
+
init_react_import();
|
1362
|
+
var import_react11 = require("react");
|
1363
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
1364
|
+
var NestedFieldContext = (0, import_react11.createContext)({});
|
1365
|
+
var useNestedFieldContext = () => {
|
1366
|
+
const context = (0, import_react11.useContext)(NestedFieldContext);
|
1367
|
+
return __spreadProps(__spreadValues({}, context), {
|
1368
|
+
readOnlyFields: context.readOnlyFields || {}
|
1369
|
+
});
|
1370
|
+
};
|
1371
|
+
var NestedFieldProvider = ({
|
1372
|
+
children,
|
1373
|
+
name,
|
1374
|
+
subName,
|
1375
|
+
wildcardName = name,
|
1376
|
+
readOnlyFields
|
1377
|
+
}) => {
|
1378
|
+
const subPath = `${name}.${subName}`;
|
1379
|
+
const wildcardSubPath = `${wildcardName}.${subName}`;
|
1380
|
+
const subReadOnlyFields = (0, import_react11.useMemo)(
|
1381
|
+
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
1382
|
+
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
1383
|
+
if (isLocal) {
|
1384
|
+
const subPathPattern = new RegExp(
|
1385
|
+
`^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
|
1415
1386
|
);
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1387
|
+
const localName = readOnlyKey.replace(subPathPattern, "");
|
1388
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1389
|
+
[localName]: readOnlyFields[readOnlyKey]
|
1419
1390
|
});
|
1420
1391
|
}
|
1392
|
+
return acc;
|
1393
|
+
}, {}),
|
1394
|
+
[name, subName, wildcardName, readOnlyFields]
|
1395
|
+
);
|
1396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
1397
|
+
NestedFieldContext.Provider,
|
1398
|
+
{
|
1399
|
+
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
1400
|
+
children
|
1421
1401
|
}
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
}
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
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));
|
1402
|
+
);
|
1403
|
+
};
|
1404
|
+
|
1405
|
+
// components/AutoField/fields/ArrayField/index.tsx
|
1406
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
1407
|
+
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
1408
|
+
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
1409
|
+
var ArrayField = ({
|
1410
|
+
field,
|
1411
|
+
onChange,
|
1412
|
+
value: _value,
|
1413
|
+
name,
|
1414
|
+
label,
|
1415
|
+
readOnly,
|
1416
|
+
id,
|
1417
|
+
Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", __spreadValues({}, props))
|
1418
|
+
}) => {
|
1419
|
+
const { state, setUi, selectedItem, getPermissions } = useAppContext();
|
1420
|
+
const { readOnlyFields, localName = name } = useNestedFieldContext();
|
1421
|
+
const value = _value;
|
1422
|
+
const arrayState = state.ui.arrayState[id] || {
|
1423
|
+
items: Array.from(value || []).map((item, idx) => {
|
1424
|
+
return {
|
1425
|
+
_originalIndex: idx,
|
1426
|
+
_arrayId: `${id}-${idx}`
|
1427
|
+
};
|
1428
|
+
}),
|
1429
|
+
openId: ""
|
1430
|
+
};
|
1431
|
+
const [localState, setLocalState] = (0, import_react12.useState)({ arrayState, value });
|
1432
|
+
(0, import_react12.useEffect)(() => {
|
1433
|
+
setLocalState({ arrayState, value });
|
1434
|
+
}, [value, state.ui.arrayState[id]]);
|
1435
|
+
const mapArrayStateToUi = (0, import_react12.useCallback)(
|
1436
|
+
(partialArrayState) => {
|
1437
|
+
return {
|
1438
|
+
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
1439
|
+
[id]: __spreadValues(__spreadValues({}, arrayState), partialArrayState)
|
1440
|
+
})
|
1441
|
+
};
|
1442
|
+
},
|
1443
|
+
[arrayState]
|
1444
|
+
);
|
1445
|
+
const getHighestIndex = (0, import_react12.useCallback)(() => {
|
1446
|
+
return arrayState.items.reduce(
|
1447
|
+
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
1448
|
+
-1
|
1449
|
+
);
|
1450
|
+
}, [arrayState]);
|
1451
|
+
const regenerateArrayState = (0, import_react12.useCallback)(
|
1452
|
+
(value2) => {
|
1453
|
+
let highestIndex = getHighestIndex();
|
1454
|
+
const newItems = Array.from(value2 || []).map((item, idx) => {
|
1455
|
+
var _a;
|
1456
|
+
const arrayStateItem = arrayState.items[idx];
|
1457
|
+
const newItem = {
|
1458
|
+
_originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : highestIndex + 1,
|
1459
|
+
_arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex + 1}`
|
1460
|
+
};
|
1461
|
+
if (newItem._originalIndex > highestIndex) {
|
1462
|
+
highestIndex = newItem._originalIndex;
|
1463
|
+
}
|
1464
|
+
return newItem;
|
1465
|
+
});
|
1466
|
+
return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
|
1467
|
+
},
|
1468
|
+
[arrayState]
|
1469
|
+
);
|
1470
|
+
(0, import_react12.useEffect)(() => {
|
1471
|
+
if (arrayState.items.length > 0) {
|
1472
|
+
setUi(mapArrayStateToUi(arrayState));
|
2126
1473
|
}
|
2127
1474
|
}, []);
|
2128
|
-
const [isDragging, setIsDragging] = (0, import_react13.useState)(false);
|
2129
1475
|
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
2130
1476
|
if (field.type !== "array" || !field.arrayFields) {
|
2131
1477
|
return null;
|
@@ -2141,8 +1487,6 @@ var ArrayField = ({
|
|
2141
1487
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2142
1488
|
SortableProvider,
|
2143
1489
|
{
|
2144
|
-
onDragStart: () => setIsDragging(true),
|
2145
|
-
onDragEnd: () => setIsDragging(false),
|
2146
1490
|
onMove: (move) => {
|
2147
1491
|
const newValue = reorder(value, move.source, move.target);
|
2148
1492
|
const newArrayStateItems = reorder(
|
@@ -2173,7 +1517,7 @@ var ArrayField = ({
|
|
2173
1517
|
e.preventDefault();
|
2174
1518
|
},
|
2175
1519
|
children: [
|
2176
|
-
|
1520
|
+
localState.arrayState.items.map((item, i) => {
|
2177
1521
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
2178
1522
|
const data = Array.from(localState.value || [])[i] || {};
|
2179
1523
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
@@ -2196,7 +1540,6 @@ var ArrayField = ({
|
|
2196
1540
|
"div",
|
2197
1541
|
{
|
2198
1542
|
onClick: (e) => {
|
2199
|
-
if (isDragging) return;
|
2200
1543
|
e.preventDefault();
|
2201
1544
|
e.stopPropagation();
|
2202
1545
|
if (arrayState.openId === _arrayId) {
|
@@ -2226,11 +1569,7 @@ var ArrayField = ({
|
|
2226
1569
|
onClick: (e) => {
|
2227
1570
|
e.stopPropagation();
|
2228
1571
|
const existingValue = [...value || []];
|
2229
|
-
existingValue.splice(
|
2230
|
-
i,
|
2231
|
-
0,
|
2232
|
-
existingValue[i]
|
2233
|
-
);
|
1572
|
+
existingValue.splice(i, 0, existingValue[i]);
|
2234
1573
|
onChange(
|
2235
1574
|
existingValue,
|
2236
1575
|
mapArrayStateToUi(
|
@@ -2272,72 +1611,62 @@ var ArrayField = ({
|
|
2272
1611
|
]
|
2273
1612
|
}
|
2274
1613
|
),
|
2275
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2276
|
-
|
2277
|
-
{
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
1614
|
+
/* @__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) => {
|
1615
|
+
const subField = field.arrayFields[subName];
|
1616
|
+
const indexName = `${name}[${i}]`;
|
1617
|
+
const subPath = `${indexName}.${subName}`;
|
1618
|
+
const localIndexName = `${localName}[${i}]`;
|
1619
|
+
const localWildcardName = `${localName}[*]`;
|
1620
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
1621
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
1622
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
1623
|
+
const label2 = subField.label || subName;
|
1624
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1625
|
+
NestedFieldProvider,
|
1626
|
+
{
|
1627
|
+
name: localIndexName,
|
1628
|
+
wildcardName: localWildcardName,
|
1629
|
+
subName,
|
1630
|
+
readOnlyFields,
|
1631
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1632
|
+
AutoFieldPrivate,
|
2294
1633
|
{
|
2295
|
-
name:
|
2296
|
-
|
2297
|
-
subName
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
}
|
2319
|
-
}
|
2320
|
-
)
|
2321
|
-
},
|
2322
|
-
subPath
|
2323
|
-
);
|
2324
|
-
})
|
2325
|
-
}
|
2326
|
-
) })
|
1634
|
+
name: subPath,
|
1635
|
+
label: label2,
|
1636
|
+
id: `${_arrayId}_${subName}`,
|
1637
|
+
readOnly: subReadOnly,
|
1638
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
1639
|
+
label: label2
|
1640
|
+
// May be used by custom fields
|
1641
|
+
}),
|
1642
|
+
value: data[subName],
|
1643
|
+
onChange: (val, ui) => {
|
1644
|
+
onChange(
|
1645
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
1646
|
+
[subName]: val
|
1647
|
+
})),
|
1648
|
+
ui
|
1649
|
+
);
|
1650
|
+
}
|
1651
|
+
}
|
1652
|
+
)
|
1653
|
+
},
|
1654
|
+
subPath
|
1655
|
+
);
|
1656
|
+
}) }) })
|
2327
1657
|
]
|
2328
1658
|
}
|
2329
1659
|
)
|
2330
1660
|
},
|
2331
1661
|
_arrayId
|
2332
1662
|
);
|
2333
|
-
})
|
1663
|
+
}),
|
2334
1664
|
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2335
1665
|
"button",
|
2336
1666
|
{
|
2337
1667
|
type: "button",
|
2338
1668
|
className: getClassName5("addButton"),
|
2339
1669
|
onClick: () => {
|
2340
|
-
if (isDragging) return;
|
2341
1670
|
const existingValue = value || [];
|
2342
1671
|
const newValue = [
|
2343
1672
|
...existingValue,
|
@@ -2418,19 +1747,19 @@ var DefaultField = ({
|
|
2418
1747
|
|
2419
1748
|
// components/AutoField/fields/ExternalField/index.tsx
|
2420
1749
|
init_react_import();
|
2421
|
-
var
|
1750
|
+
var import_react16 = require("react");
|
2422
1751
|
|
2423
1752
|
// components/ExternalInput/index.tsx
|
2424
1753
|
init_react_import();
|
2425
|
-
var
|
1754
|
+
var import_react15 = require("react");
|
2426
1755
|
|
2427
1756
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
2428
1757
|
init_react_import();
|
2429
|
-
var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-
|
1758
|
+
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
1759
|
|
2431
1760
|
// components/Modal/index.tsx
|
2432
1761
|
init_react_import();
|
2433
|
-
var
|
1762
|
+
var import_react13 = require("react");
|
2434
1763
|
|
2435
1764
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
2436
1765
|
init_react_import();
|
@@ -2445,8 +1774,8 @@ var Modal = ({
|
|
2445
1774
|
onClose,
|
2446
1775
|
isOpen
|
2447
1776
|
}) => {
|
2448
|
-
const [rootEl, setRootEl] = (0,
|
2449
|
-
(0,
|
1777
|
+
const [rootEl, setRootEl] = (0, import_react13.useState)(null);
|
1778
|
+
(0, import_react13.useEffect)(() => {
|
2450
1779
|
setRootEl(document.getElementById("puck-portal-root"));
|
2451
1780
|
}, []);
|
2452
1781
|
if (!rootEl) {
|
@@ -2493,11 +1822,11 @@ init_react_import();
|
|
2493
1822
|
|
2494
1823
|
// components/Button/Button.tsx
|
2495
1824
|
init_react_import();
|
2496
|
-
var
|
1825
|
+
var import_react14 = require("react");
|
2497
1826
|
|
2498
1827
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
2499
1828
|
init_react_import();
|
2500
|
-
var Button_module_default = { "Button": "
|
1829
|
+
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
1830
|
|
2502
1831
|
// lib/filter-data-attrs.ts
|
2503
1832
|
init_react_import();
|
@@ -2543,8 +1872,8 @@ var Button = (_a) => {
|
|
2543
1872
|
"size",
|
2544
1873
|
"loading"
|
2545
1874
|
]);
|
2546
|
-
const [loading, setLoading] = (0,
|
2547
|
-
(0,
|
1875
|
+
const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
|
1876
|
+
(0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
2548
1877
|
const ElementType = href ? "a" : type ? "button" : "span";
|
2549
1878
|
const dataAttrs = filterDataAttrs(props);
|
2550
1879
|
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
@@ -2599,28 +1928,28 @@ var ExternalInput = ({
|
|
2599
1928
|
mapRow = (val) => val,
|
2600
1929
|
filterFields
|
2601
1930
|
} = field || {};
|
2602
|
-
const [data, setData] = (0,
|
2603
|
-
const [isOpen, setOpen] = (0,
|
2604
|
-
const [isLoading, setIsLoading] = (0,
|
1931
|
+
const [data, setData] = (0, import_react15.useState)([]);
|
1932
|
+
const [isOpen, setOpen] = (0, import_react15.useState)(false);
|
1933
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
|
2605
1934
|
const hasFilterFields = !!filterFields;
|
2606
|
-
const [filters, setFilters] = (0,
|
2607
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
2608
|
-
const mappedData = (0,
|
1935
|
+
const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
|
1936
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
|
1937
|
+
const mappedData = (0, import_react15.useMemo)(() => {
|
2609
1938
|
return data.map(mapRow);
|
2610
1939
|
}, [data]);
|
2611
|
-
const keys = (0,
|
1940
|
+
const keys = (0, import_react15.useMemo)(() => {
|
2612
1941
|
const validKeys = /* @__PURE__ */ new Set();
|
2613
1942
|
for (const item of mappedData) {
|
2614
1943
|
for (const key of Object.keys(item)) {
|
2615
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
1944
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
|
2616
1945
|
validKeys.add(key);
|
2617
1946
|
}
|
2618
1947
|
}
|
2619
1948
|
}
|
2620
1949
|
return Array.from(validKeys);
|
2621
1950
|
}, [mappedData]);
|
2622
|
-
const [searchQuery, setSearchQuery] = (0,
|
2623
|
-
const search = (0,
|
1951
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
|
1952
|
+
const search = (0, import_react15.useCallback)(
|
2624
1953
|
(query, filters2) => __async(void 0, null, function* () {
|
2625
1954
|
setIsLoading(true);
|
2626
1955
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -2633,7 +1962,7 @@ var ExternalInput = ({
|
|
2633
1962
|
}),
|
2634
1963
|
[id, field]
|
2635
1964
|
);
|
2636
|
-
const Footer = (0,
|
1965
|
+
const Footer = (0, import_react15.useCallback)(
|
2637
1966
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
2638
1967
|
props.items.length,
|
2639
1968
|
" result",
|
@@ -2641,7 +1970,7 @@ var ExternalInput = ({
|
|
2641
1970
|
] }),
|
2642
1971
|
[field.renderFooter]
|
2643
1972
|
);
|
2644
|
-
(0,
|
1973
|
+
(0, import_react15.useEffect)(() => {
|
2645
1974
|
search(searchQuery, filters);
|
2646
1975
|
}, []);
|
2647
1976
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
@@ -2734,26 +2063,18 @@ var ExternalInput = ({
|
|
2734
2063
|
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
2735
2064
|
const filterField = filterFields[fieldName];
|
2736
2065
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
2737
|
-
|
2066
|
+
AutoFieldPrivate,
|
2738
2067
|
{
|
2739
|
-
|
2740
|
-
|
2741
|
-
|
2742
|
-
|
2743
|
-
|
2744
|
-
|
2745
|
-
|
2746
|
-
|
2747
|
-
|
2748
|
-
|
2749
|
-
const newFilters = __spreadProps(__spreadValues({}, filters), {
|
2750
|
-
[fieldName]: value2
|
2751
|
-
});
|
2752
|
-
setFilters(newFilters);
|
2753
|
-
search(searchQuery, newFilters);
|
2754
|
-
}
|
2755
|
-
}
|
2756
|
-
)
|
2068
|
+
field: filterField,
|
2069
|
+
name: fieldName,
|
2070
|
+
id: `external_field_${fieldName}_filter`,
|
2071
|
+
label: filterField.label || fieldName,
|
2072
|
+
value: filters[fieldName],
|
2073
|
+
onChange: (value2) => {
|
2074
|
+
const newFilters = __spreadProps(__spreadValues({}, filters), { [fieldName]: value2 });
|
2075
|
+
setFilters(newFilters);
|
2076
|
+
search(searchQuery, newFilters);
|
2077
|
+
}
|
2757
2078
|
},
|
2758
2079
|
fieldName
|
2759
2080
|
);
|
@@ -2812,7 +2133,7 @@ var ExternalField = ({
|
|
2812
2133
|
var _a, _b, _c;
|
2813
2134
|
const validField = field;
|
2814
2135
|
const deprecatedField = field;
|
2815
|
-
(0,
|
2136
|
+
(0, import_react16.useEffect)(() => {
|
2816
2137
|
if (deprecatedField.adaptor) {
|
2817
2138
|
console.error(
|
2818
2139
|
"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 +2168,7 @@ var ExternalField = ({
|
|
2847
2168
|
|
2848
2169
|
// components/AutoField/fields/RadioField/index.tsx
|
2849
2170
|
init_react_import();
|
2850
|
-
var
|
2171
|
+
var import_react17 = require("react");
|
2851
2172
|
|
2852
2173
|
// lib/safe-json-parse.ts
|
2853
2174
|
init_react_import();
|
@@ -2873,7 +2194,7 @@ var RadioField = ({
|
|
2873
2194
|
label,
|
2874
2195
|
Label: Label2
|
2875
2196
|
}) => {
|
2876
|
-
const flatOptions = (0,
|
2197
|
+
const flatOptions = (0, import_react17.useMemo)(
|
2877
2198
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2878
2199
|
[field]
|
2879
2200
|
);
|
@@ -2923,7 +2244,7 @@ var RadioField = ({
|
|
2923
2244
|
|
2924
2245
|
// components/AutoField/fields/SelectField/index.tsx
|
2925
2246
|
init_react_import();
|
2926
|
-
var
|
2247
|
+
var import_react18 = require("react");
|
2927
2248
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2928
2249
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2929
2250
|
var SelectField = ({
|
@@ -2936,7 +2257,7 @@ var SelectField = ({
|
|
2936
2257
|
readOnly,
|
2937
2258
|
id
|
2938
2259
|
}) => {
|
2939
|
-
const flatOptions = (0,
|
2260
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2940
2261
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2941
2262
|
[field]
|
2942
2263
|
);
|
@@ -3088,7 +2409,7 @@ var ObjectField = ({
|
|
3088
2409
|
|
3089
2410
|
// lib/use-safe-id.ts
|
3090
2411
|
init_react_import();
|
3091
|
-
var
|
2412
|
+
var import_react19 = __toESM(require("react"));
|
3092
2413
|
|
3093
2414
|
// lib/generate-id.ts
|
3094
2415
|
init_react_import();
|
@@ -3097,10 +2418,10 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
3097
2418
|
|
3098
2419
|
// lib/use-safe-id.ts
|
3099
2420
|
var useSafeId = () => {
|
3100
|
-
if (typeof
|
3101
|
-
return
|
2421
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
2422
|
+
return import_react19.default.useId();
|
3102
2423
|
}
|
3103
|
-
const [id] = (0,
|
2424
|
+
const [id] = (0, import_react19.useState)(generateId());
|
3104
2425
|
return id;
|
3105
2426
|
};
|
3106
2427
|
|
@@ -3134,7 +2455,7 @@ var FieldLabelInternal = ({
|
|
3134
2455
|
readOnly
|
3135
2456
|
}) => {
|
3136
2457
|
const { overrides } = useAppContext();
|
3137
|
-
const Wrapper = (0,
|
2458
|
+
const Wrapper = (0, import_react20.useMemo)(
|
3138
2459
|
() => overrides.fieldLabel || FieldLabel,
|
3139
2460
|
[overrides]
|
3140
2461
|
);
|
@@ -3156,7 +2477,7 @@ var FieldLabelInternal = ({
|
|
3156
2477
|
function AutoFieldInternal(props) {
|
3157
2478
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
3158
2479
|
const { dispatch, overrides, selectedItem } = useAppContext();
|
3159
|
-
const nestedFieldContext = (0,
|
2480
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
3160
2481
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
3161
2482
|
const field = props.field;
|
3162
2483
|
const label = field.label;
|
@@ -3188,7 +2509,7 @@ function AutoFieldInternal(props) {
|
|
3188
2509
|
Label: Label2,
|
3189
2510
|
id: resolvedId
|
3190
2511
|
});
|
3191
|
-
const onFocus = (0,
|
2512
|
+
const onFocus = (0, import_react20.useCallback)(
|
3192
2513
|
(e) => {
|
3193
2514
|
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
3194
2515
|
e.stopPropagation();
|
@@ -3202,7 +2523,7 @@ function AutoFieldInternal(props) {
|
|
3202
2523
|
},
|
3203
2524
|
[mergedProps.name]
|
3204
2525
|
);
|
3205
|
-
const onBlur = (0,
|
2526
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
3206
2527
|
if ("name" in e.target) {
|
3207
2528
|
dispatch({
|
3208
2529
|
type: "setUi",
|
@@ -3246,7 +2567,7 @@ function AutoFieldInternal(props) {
|
|
3246
2567
|
function AutoFieldPrivate(props) {
|
3247
2568
|
const { state } = useAppContext();
|
3248
2569
|
const { value, onChange } = props;
|
3249
|
-
const [localValue, setLocalValue] = (0,
|
2570
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
3250
2571
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
3251
2572
|
(val, ui) => {
|
3252
2573
|
onChange(val, ui);
|
@@ -3254,11 +2575,11 @@ function AutoFieldPrivate(props) {
|
|
3254
2575
|
50,
|
3255
2576
|
{ leading: true }
|
3256
2577
|
);
|
3257
|
-
const onChangeLocal = (0,
|
2578
|
+
const onChangeLocal = (0, import_react20.useCallback)((val, ui) => {
|
3258
2579
|
setLocalValue(val);
|
3259
2580
|
onChangeDb(val, ui);
|
3260
2581
|
}, []);
|
3261
|
-
(0,
|
2582
|
+
(0, import_react20.useEffect)(() => {
|
3262
2583
|
if (state.ui.field.focus !== props.name) {
|
3263
2584
|
setLocalValue(value);
|
3264
2585
|
}
|
@@ -3270,7 +2591,7 @@ function AutoFieldPrivate(props) {
|
|
3270
2591
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
3271
2592
|
}
|
3272
2593
|
function AutoField(props) {
|
3273
|
-
const DefaultLabel = (0,
|
2594
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
3274
2595
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
3275
2596
|
"div",
|
3276
2597
|
__spreadProps(__spreadValues({}, labelProps), {
|
@@ -3285,33 +2606,368 @@ function AutoField(props) {
|
|
3285
2606
|
// components/Drawer/index.tsx
|
3286
2607
|
init_react_import();
|
3287
2608
|
|
3288
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
2609
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
2610
|
+
init_react_import();
|
2611
|
+
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" };
|
2612
|
+
|
2613
|
+
// components/Drawer/index.tsx
|
2614
|
+
var import_react32 = require("react");
|
2615
|
+
|
2616
|
+
// components/DragDropContext/index.tsx
|
2617
|
+
init_react_import();
|
2618
|
+
var import_react30 = require("@dnd-kit/react");
|
2619
|
+
var import_react31 = require("react");
|
2620
|
+
var import_dom = require("@dnd-kit/dom");
|
2621
|
+
|
2622
|
+
// components/DropZone/index.tsx
|
2623
|
+
init_react_import();
|
2624
|
+
var import_react29 = require("react");
|
2625
|
+
|
2626
|
+
// components/DraggableComponent/index.tsx
|
2627
|
+
init_react_import();
|
2628
|
+
var import_react23 = require("react");
|
2629
|
+
|
2630
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
2631
|
+
init_react_import();
|
2632
|
+
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" };
|
2633
|
+
|
2634
|
+
// components/DraggableComponent/index.tsx
|
2635
|
+
var import_react_dom2 = require("react-dom");
|
2636
|
+
|
2637
|
+
// lib/dnd/collision/dynamic/index.ts
|
2638
|
+
init_react_import();
|
2639
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
2640
|
+
|
2641
|
+
// lib/dnd/collision/directional/index.ts
|
2642
|
+
init_react_import();
|
2643
|
+
var import_abstract = require("@dnd-kit/abstract");
|
2644
|
+
|
2645
|
+
// lib/dnd/collision/collision-debug.ts
|
2646
|
+
init_react_import();
|
2647
|
+
var DEBUG = false;
|
2648
|
+
var debugElements = {};
|
2649
|
+
var timeout;
|
2650
|
+
var collisionDebug = (a, b, id, color, label) => {
|
2651
|
+
if (!DEBUG) return;
|
2652
|
+
const debugId = `${id}-debug`;
|
2653
|
+
clearTimeout(timeout);
|
2654
|
+
timeout = setTimeout(() => {
|
2655
|
+
Object.entries(debugElements).forEach(([id2, { svg }]) => {
|
2656
|
+
svg.remove();
|
2657
|
+
delete debugElements[id2];
|
2658
|
+
});
|
2659
|
+
}, 1e3);
|
2660
|
+
requestAnimationFrame(() => {
|
2661
|
+
var _a, _b;
|
2662
|
+
const existingEl = debugElements[debugId];
|
2663
|
+
let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
|
2664
|
+
let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
|
2665
|
+
if (!existingEl) {
|
2666
|
+
const svgNs = "http://www.w3.org/2000/svg";
|
2667
|
+
const svg = document.createElementNS(svgNs, "svg");
|
2668
|
+
line = document.createElementNS(svgNs, "line");
|
2669
|
+
text = document.createElementNS(svgNs, "text");
|
2670
|
+
svg.setAttribute("id", debugId);
|
2671
|
+
svg.setAttribute(
|
2672
|
+
"style",
|
2673
|
+
"position: fixed; height: 100%; width: 100%; pointer-events: none;"
|
2674
|
+
);
|
2675
|
+
svg.appendChild(line);
|
2676
|
+
svg.appendChild(text);
|
2677
|
+
text.setAttribute("fill", `black`);
|
2678
|
+
document.body.appendChild(svg);
|
2679
|
+
debugElements[debugId] = { svg, line, text };
|
2680
|
+
}
|
2681
|
+
line.setAttribute("x1", a.x.toString());
|
2682
|
+
line.setAttribute("x2", b.x.toString());
|
2683
|
+
line.setAttribute("y1", a.y.toString());
|
2684
|
+
line.setAttribute("y2", b.y.toString());
|
2685
|
+
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
2686
|
+
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
2687
|
+
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
2688
|
+
if (label) {
|
2689
|
+
text.innerHTML = label;
|
2690
|
+
}
|
2691
|
+
});
|
2692
|
+
};
|
2693
|
+
|
2694
|
+
// lib/dnd/collision/directional/index.ts
|
2695
|
+
var distanceChange = "increasing";
|
2696
|
+
var directionalCollision = (input, previous) => {
|
2697
|
+
var _a;
|
2698
|
+
const { dragOperation, droppable } = input;
|
2699
|
+
const { shape: dropShape } = droppable;
|
2700
|
+
const { position } = dragOperation;
|
2701
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
2702
|
+
if (!dragShape || !dropShape) return null;
|
2703
|
+
const dropCenter = dropShape.center;
|
2704
|
+
const distanceToPrevious = Math.sqrt(
|
2705
|
+
Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
|
2706
|
+
);
|
2707
|
+
const distanceToCurrent = Math.sqrt(
|
2708
|
+
Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
|
2709
|
+
);
|
2710
|
+
distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
|
2711
|
+
collisionDebug(
|
2712
|
+
dragShape.center,
|
2713
|
+
dropCenter,
|
2714
|
+
droppable.id.toString(),
|
2715
|
+
"rebeccapurple"
|
2716
|
+
);
|
2717
|
+
if (distanceChange === "decreasing") {
|
2718
|
+
return {
|
2719
|
+
id: droppable.id,
|
2720
|
+
value: 1,
|
2721
|
+
type: import_abstract.CollisionType.Collision
|
2722
|
+
};
|
2723
|
+
}
|
2724
|
+
return null;
|
2725
|
+
};
|
2726
|
+
|
2727
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
3289
2728
|
init_react_import();
|
3290
|
-
var
|
3291
|
-
|
3292
|
-
|
3293
|
-
|
2729
|
+
var getDirection = (dragAxis, delta) => {
|
2730
|
+
if (dragAxis === "dynamic") {
|
2731
|
+
if (Math.abs(delta.y) > Math.abs(delta.x)) {
|
2732
|
+
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2733
|
+
} else {
|
2734
|
+
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
2735
|
+
}
|
2736
|
+
} else if (dragAxis === "x") {
|
2737
|
+
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
2738
|
+
}
|
2739
|
+
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2740
|
+
};
|
3294
2741
|
|
3295
|
-
//
|
2742
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
3296
2743
|
init_react_import();
|
3297
|
-
var
|
3298
|
-
|
3299
|
-
|
2744
|
+
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2745
|
+
const dragRect = dragShape.boundingRectangle;
|
2746
|
+
const dropCenter = dropShape.center;
|
2747
|
+
if (direction === "down") {
|
2748
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
2749
|
+
return dragRect.bottom >= dropCenter.y + offset2;
|
2750
|
+
} else if (direction === "up") {
|
2751
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
2752
|
+
return dragRect.top < dropCenter.y - offset2;
|
2753
|
+
} else if (direction === "left") {
|
2754
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
|
2755
|
+
return dropCenter.x - offset2 >= dragRect.left;
|
2756
|
+
}
|
2757
|
+
const offset = offsetMultiplier * dropShape.boundingRectangle.width;
|
2758
|
+
return dragRect.right - offset >= dropCenter.x;
|
2759
|
+
};
|
3300
2760
|
|
3301
|
-
//
|
2761
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
3302
2762
|
init_react_import();
|
3303
|
-
var
|
2763
|
+
var import_geometry = require("@dnd-kit/geometry");
|
2764
|
+
var INTERVAL_SENSITIVITY = 10;
|
2765
|
+
var intervalCache = {
|
2766
|
+
current: { x: 0, y: 0 },
|
2767
|
+
delta: { x: 0, y: 0 },
|
2768
|
+
previous: { x: 0, y: 0 },
|
2769
|
+
direction: null
|
2770
|
+
};
|
2771
|
+
var trackMovementInterval = (point, dragAxis = "dynamic") => {
|
2772
|
+
intervalCache.current = point;
|
2773
|
+
intervalCache.delta = {
|
2774
|
+
x: point.x - intervalCache.previous.x,
|
2775
|
+
y: point.y - intervalCache.previous.y
|
2776
|
+
};
|
2777
|
+
intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
|
2778
|
+
if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
|
2779
|
+
intervalCache.previous = import_geometry.Point.from(point);
|
2780
|
+
}
|
2781
|
+
return intervalCache;
|
2782
|
+
};
|
3304
2783
|
|
3305
|
-
//
|
2784
|
+
// ../../node_modules/@dnd-kit/collision/dist/index.js
|
3306
2785
|
init_react_import();
|
3307
|
-
var
|
2786
|
+
var import_abstract2 = require("@dnd-kit/abstract");
|
2787
|
+
var import_geometry2 = require("@dnd-kit/geometry");
|
2788
|
+
var import_abstract3 = require("@dnd-kit/abstract");
|
2789
|
+
var import_geometry3 = require("@dnd-kit/geometry");
|
2790
|
+
var import_abstract4 = require("@dnd-kit/abstract");
|
2791
|
+
var import_geometry4 = require("@dnd-kit/geometry");
|
2792
|
+
var import_abstract5 = require("@dnd-kit/abstract");
|
2793
|
+
var import_geometry5 = require("@dnd-kit/geometry");
|
2794
|
+
var import_abstract6 = require("@dnd-kit/abstract");
|
2795
|
+
var import_geometry6 = require("@dnd-kit/geometry");
|
2796
|
+
var import_abstract7 = require("@dnd-kit/abstract");
|
2797
|
+
var import_geometry7 = require("@dnd-kit/geometry");
|
2798
|
+
var pointerIntersection = ({
|
2799
|
+
dragOperation,
|
2800
|
+
droppable
|
2801
|
+
}) => {
|
2802
|
+
const pointerCoordinates = dragOperation.position.current;
|
2803
|
+
if (!pointerCoordinates) {
|
2804
|
+
return null;
|
2805
|
+
}
|
2806
|
+
const { id } = droppable;
|
2807
|
+
if (!droppable.shape) {
|
2808
|
+
return null;
|
2809
|
+
}
|
2810
|
+
if (droppable.shape.containsPoint(pointerCoordinates)) {
|
2811
|
+
const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
|
2812
|
+
return {
|
2813
|
+
id,
|
2814
|
+
value: 1 / distance,
|
2815
|
+
type: import_abstract2.CollisionType.PointerIntersection,
|
2816
|
+
priority: import_abstract2.CollisionPriority.High
|
2817
|
+
};
|
2818
|
+
}
|
2819
|
+
return null;
|
2820
|
+
};
|
2821
|
+
var closestCorners = (input) => {
|
2822
|
+
const { dragOperation, droppable } = input;
|
2823
|
+
const { shape, position } = dragOperation;
|
2824
|
+
if (!droppable.shape) {
|
2825
|
+
return null;
|
2826
|
+
}
|
2827
|
+
const { left, top, right, bottom } = droppable.shape.boundingRectangle;
|
2828
|
+
const corners = [
|
2829
|
+
{
|
2830
|
+
x: left,
|
2831
|
+
y: top
|
2832
|
+
},
|
2833
|
+
{
|
2834
|
+
x: right,
|
2835
|
+
y: top
|
2836
|
+
},
|
2837
|
+
{
|
2838
|
+
x: left,
|
2839
|
+
y: bottom
|
2840
|
+
},
|
2841
|
+
{
|
2842
|
+
x: right,
|
2843
|
+
y: bottom
|
2844
|
+
}
|
2845
|
+
];
|
2846
|
+
const distance = corners.reduce(
|
2847
|
+
(acc, corner) => {
|
2848
|
+
var _a;
|
2849
|
+
return acc + import_geometry4.Point.distance(
|
2850
|
+
import_geometry4.Point.from(corner),
|
2851
|
+
(_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
|
2852
|
+
);
|
2853
|
+
},
|
2854
|
+
0
|
2855
|
+
);
|
2856
|
+
const value = distance / 4;
|
2857
|
+
return {
|
2858
|
+
id: droppable.id,
|
2859
|
+
value: 1 / value,
|
2860
|
+
type: import_abstract4.CollisionType.Collision,
|
2861
|
+
priority: import_abstract4.CollisionPriority.Normal
|
2862
|
+
};
|
2863
|
+
};
|
3308
2864
|
|
3309
|
-
//
|
2865
|
+
// lib/dnd/collision/dynamic/store.ts
|
3310
2866
|
init_react_import();
|
3311
|
-
var
|
2867
|
+
var import_vanilla = require("zustand/vanilla");
|
2868
|
+
var collisionStore = (0, import_vanilla.createStore)(() => ({
|
2869
|
+
fallbackEnabled: false
|
2870
|
+
}));
|
3312
2871
|
|
3313
|
-
//
|
3314
|
-
var
|
2872
|
+
// lib/dnd/collision/dynamic/index.ts
|
2873
|
+
var flushNext = "";
|
2874
|
+
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2875
|
+
var _a, _b, _c, _d, _e;
|
2876
|
+
const { dragOperation, droppable } = input;
|
2877
|
+
const { position } = dragOperation;
|
2878
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
2879
|
+
const { shape: dropShape } = droppable;
|
2880
|
+
if (!dragShape || !dropShape) {
|
2881
|
+
return null;
|
2882
|
+
}
|
2883
|
+
const { center: dragCenter } = dragShape;
|
2884
|
+
const { fallbackEnabled } = collisionStore.getState();
|
2885
|
+
const interval = trackMovementInterval(position.current, dragAxis);
|
2886
|
+
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2887
|
+
direction: interval.direction
|
2888
|
+
});
|
2889
|
+
const collisionMap = dragOperation.data.collisionMap || {};
|
2890
|
+
dragOperation.data.collisionMap = collisionMap;
|
2891
|
+
collisionMap[droppable.id] = {
|
2892
|
+
direction: interval.direction
|
2893
|
+
};
|
2894
|
+
const { center: dropCenter } = dropShape;
|
2895
|
+
const overMidpoint = getMidpointImpact(
|
2896
|
+
dragShape,
|
2897
|
+
dropShape,
|
2898
|
+
interval.direction,
|
2899
|
+
midpointOffset
|
2900
|
+
);
|
2901
|
+
if (((_b = dragOperation.source) == null ? void 0 : _b.id) === droppable.id) {
|
2902
|
+
const collision = directionalCollision(input, interval.previous);
|
2903
|
+
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
2904
|
+
if (collision) {
|
2905
|
+
return __spreadProps(__spreadValues({}, collision), {
|
2906
|
+
priority: import_abstract8.CollisionPriority.Highest
|
2907
|
+
});
|
2908
|
+
}
|
2909
|
+
}
|
2910
|
+
const intersectionArea = dragShape.intersectionArea(dropShape);
|
2911
|
+
const intersectionRatio = intersectionArea / dropShape.area;
|
2912
|
+
if (intersectionArea && overMidpoint) {
|
2913
|
+
collisionDebug(
|
2914
|
+
dragCenter,
|
2915
|
+
dropCenter,
|
2916
|
+
droppable.id.toString(),
|
2917
|
+
"green",
|
2918
|
+
interval.direction
|
2919
|
+
);
|
2920
|
+
const collision = {
|
2921
|
+
id: droppable.id,
|
2922
|
+
value: intersectionRatio,
|
2923
|
+
priority: import_abstract8.CollisionPriority.High,
|
2924
|
+
type: import_abstract8.CollisionType.Collision
|
2925
|
+
};
|
2926
|
+
const shouldFlushId = flushNext === droppable.id;
|
2927
|
+
flushNext = "";
|
2928
|
+
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2929
|
+
}
|
2930
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2931
|
+
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2932
|
+
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2933
|
+
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
2934
|
+
const fallbackCollision = closestCorners(input);
|
2935
|
+
if (fallbackCollision) {
|
2936
|
+
const direction = getDirection(dragAxis, {
|
2937
|
+
x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
|
2938
|
+
y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
|
2939
|
+
});
|
2940
|
+
collisionMap[droppable.id] = {
|
2941
|
+
direction
|
2942
|
+
};
|
2943
|
+
if (intersectionArea) {
|
2944
|
+
collisionDebug(
|
2945
|
+
dragCenter,
|
2946
|
+
dropCenter,
|
2947
|
+
droppable.id.toString(),
|
2948
|
+
"red",
|
2949
|
+
direction || ""
|
2950
|
+
);
|
2951
|
+
flushNext = droppable.id;
|
2952
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2953
|
+
priority: import_abstract8.CollisionPriority.Low
|
2954
|
+
});
|
2955
|
+
}
|
2956
|
+
collisionDebug(
|
2957
|
+
dragCenter,
|
2958
|
+
dropCenter,
|
2959
|
+
droppable.id.toString(),
|
2960
|
+
"orange",
|
2961
|
+
direction || ""
|
2962
|
+
);
|
2963
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract8.CollisionPriority.Lowest });
|
2964
|
+
}
|
2965
|
+
}
|
2966
|
+
}
|
2967
|
+
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
2968
|
+
delete collisionMap[droppable.id];
|
2969
|
+
return null;
|
2970
|
+
};
|
3315
2971
|
|
3316
2972
|
// lib/get-deep-scroll-position.ts
|
3317
2973
|
init_react_import();
|
@@ -3334,11 +2990,11 @@ function getDeepScrollPosition(element) {
|
|
3334
2990
|
|
3335
2991
|
// components/DropZone/context.tsx
|
3336
2992
|
init_react_import();
|
3337
|
-
var
|
2993
|
+
var import_react21 = require("react");
|
3338
2994
|
var import_zustand = require("zustand");
|
3339
2995
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
3340
|
-
var dropZoneContext = (0,
|
3341
|
-
var ZoneStoreContext = (0,
|
2996
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
2997
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
3342
2998
|
(0, import_zustand.createStore)(() => ({
|
3343
2999
|
zoneDepthIndex: {},
|
3344
3000
|
nextZoneDepthIndex: {},
|
@@ -3358,19 +3014,19 @@ var DropZoneProvider = ({
|
|
3358
3014
|
children,
|
3359
3015
|
value
|
3360
3016
|
}) => {
|
3361
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
3362
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
3017
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3018
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
3363
3019
|
{}
|
3364
3020
|
);
|
3365
|
-
const [activeZones, setActiveZones] = (0,
|
3021
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
3366
3022
|
const { dispatch } = useAppContext();
|
3367
|
-
const registerZoneArea = (0,
|
3023
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
3368
3024
|
(area) => {
|
3369
3025
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3370
3026
|
},
|
3371
3027
|
[setAreasWithZones]
|
3372
3028
|
);
|
3373
|
-
const registerZone = (0,
|
3029
|
+
const registerZone = (0, import_react21.useCallback)(
|
3374
3030
|
(zoneCompound) => {
|
3375
3031
|
if (!dispatch) {
|
3376
3032
|
return;
|
@@ -3383,7 +3039,7 @@ var DropZoneProvider = ({
|
|
3383
3039
|
},
|
3384
3040
|
[setActiveZones, dispatch]
|
3385
3041
|
);
|
3386
|
-
const unregisterZone = (0,
|
3042
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
3387
3043
|
(zoneCompound) => {
|
3388
3044
|
if (!dispatch) {
|
3389
3045
|
return;
|
@@ -3398,7 +3054,7 @@ var DropZoneProvider = ({
|
|
3398
3054
|
},
|
3399
3055
|
[setActiveZones, dispatch]
|
3400
3056
|
);
|
3401
|
-
const memoValue = (0,
|
3057
|
+
const memoValue = (0, import_react21.useMemo)(
|
3402
3058
|
() => __spreadValues({
|
3403
3059
|
hoveringComponent,
|
3404
3060
|
setHoveringComponent,
|
@@ -3415,11 +3071,11 @@ var DropZoneProvider = ({
|
|
3415
3071
|
|
3416
3072
|
// lib/use-context-store.ts
|
3417
3073
|
init_react_import();
|
3418
|
-
var
|
3074
|
+
var import_react22 = require("react");
|
3419
3075
|
var import_zustand2 = require("zustand");
|
3420
3076
|
var import_shallow = require("zustand/react/shallow");
|
3421
3077
|
function useContextStore(context, selector) {
|
3422
|
-
const store = (0,
|
3078
|
+
const store = (0, import_react22.useContext)(context);
|
3423
3079
|
if (!store) {
|
3424
3080
|
throw new Error("useContextStore must be used inside context");
|
3425
3081
|
}
|
@@ -3478,9 +3134,9 @@ var DraggableComponent = ({
|
|
3478
3134
|
iframe,
|
3479
3135
|
state
|
3480
3136
|
} = useAppContext();
|
3481
|
-
const ctx = (0,
|
3482
|
-
const [localZones, setLocalZones] = (0,
|
3483
|
-
const registerLocalZone = (0,
|
3137
|
+
const ctx = (0, import_react23.useContext)(dropZoneContext);
|
3138
|
+
const [localZones, setLocalZones] = (0, import_react23.useState)({});
|
3139
|
+
const registerLocalZone = (0, import_react23.useCallback)(
|
3484
3140
|
(zoneCompound2, active) => {
|
3485
3141
|
var _a;
|
3486
3142
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -3490,7 +3146,7 @@ var DraggableComponent = ({
|
|
3490
3146
|
},
|
3491
3147
|
[setLocalZones]
|
3492
3148
|
);
|
3493
|
-
const unregisterLocalZone = (0,
|
3149
|
+
const unregisterLocalZone = (0, import_react23.useCallback)(
|
3494
3150
|
(zoneCompound2) => {
|
3495
3151
|
var _a;
|
3496
3152
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -3504,8 +3160,8 @@ var DraggableComponent = ({
|
|
3504
3160
|
);
|
3505
3161
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
3506
3162
|
const { path = [] } = ctx || {};
|
3507
|
-
const [canDrag, setCanDrag] = (0,
|
3508
|
-
(0,
|
3163
|
+
const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
|
3164
|
+
(0, import_react23.useEffect)(() => {
|
3509
3165
|
var _a;
|
3510
3166
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
3511
3167
|
if (item) {
|
@@ -3521,7 +3177,7 @@ var DraggableComponent = ({
|
|
3521
3177
|
);
|
3522
3178
|
const canCollide = canDrag || userIsDragging;
|
3523
3179
|
const disabled = !isEnabled || !canCollide;
|
3524
|
-
const [dragAxis, setDragAxis] = (0,
|
3180
|
+
const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
|
3525
3181
|
const { ref: sortableRef, status } = useSortableSafe({
|
3526
3182
|
id,
|
3527
3183
|
index,
|
@@ -3547,8 +3203,8 @@ var DraggableComponent = ({
|
|
3547
3203
|
}
|
3548
3204
|
});
|
3549
3205
|
const thisIsDragging = status === "dragging";
|
3550
|
-
const ref = (0,
|
3551
|
-
const refSetter = (0,
|
3206
|
+
const ref = (0, import_react23.useRef)(null);
|
3207
|
+
const refSetter = (0, import_react23.useCallback)(
|
3552
3208
|
(el) => {
|
3553
3209
|
sortableRef(el);
|
3554
3210
|
if (el) {
|
@@ -3557,14 +3213,14 @@ var DraggableComponent = ({
|
|
3557
3213
|
},
|
3558
3214
|
[sortableRef]
|
3559
3215
|
);
|
3560
|
-
const [portalEl, setPortalEl] = (0,
|
3561
|
-
(0,
|
3216
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)();
|
3217
|
+
(0, import_react23.useEffect)(() => {
|
3562
3218
|
var _a, _b, _c;
|
3563
3219
|
setPortalEl(
|
3564
3220
|
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
3221
|
);
|
3566
3222
|
}, [iframe.enabled, ref.current]);
|
3567
|
-
const getStyle = (0,
|
3223
|
+
const getStyle = (0, import_react23.useCallback)(() => {
|
3568
3224
|
var _a, _b, _c;
|
3569
3225
|
if (!ref.current) return;
|
3570
3226
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3584,11 +3240,11 @@ var DraggableComponent = ({
|
|
3584
3240
|
};
|
3585
3241
|
return style2;
|
3586
3242
|
}, [ref.current]);
|
3587
|
-
const [style, setStyle] = (0,
|
3588
|
-
const sync = (0,
|
3243
|
+
const [style, setStyle] = (0, import_react23.useState)();
|
3244
|
+
const sync = (0, import_react23.useCallback)(() => {
|
3589
3245
|
setStyle(getStyle());
|
3590
3246
|
}, [ref.current, iframe]);
|
3591
|
-
(0,
|
3247
|
+
(0, import_react23.useEffect)(() => {
|
3592
3248
|
if (ref.current && !userIsDragging) {
|
3593
3249
|
const observer = new ResizeObserver(sync);
|
3594
3250
|
observer.observe(ref.current);
|
@@ -3597,7 +3253,7 @@ var DraggableComponent = ({
|
|
3597
3253
|
};
|
3598
3254
|
}
|
3599
3255
|
}, [ref.current, userIsDragging]);
|
3600
|
-
(0,
|
3256
|
+
(0, import_react23.useEffect)(() => {
|
3601
3257
|
ctx == null ? void 0 : ctx.registerPath(
|
3602
3258
|
id,
|
3603
3259
|
{
|
@@ -3611,14 +3267,14 @@ var DraggableComponent = ({
|
|
3611
3267
|
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3612
3268
|
};
|
3613
3269
|
}, [id, zoneCompound, index, componentType]);
|
3614
|
-
const CustomActionBar = (0,
|
3270
|
+
const CustomActionBar = (0, import_react23.useMemo)(
|
3615
3271
|
() => overrides.actionBar || DefaultActionBar,
|
3616
3272
|
[overrides.actionBar]
|
3617
3273
|
);
|
3618
3274
|
const permissions = getPermissions({
|
3619
3275
|
item: selectedItem
|
3620
3276
|
});
|
3621
|
-
const onClick = (0,
|
3277
|
+
const onClick = (0, import_react23.useCallback)(
|
3622
3278
|
(e) => {
|
3623
3279
|
e.stopPropagation();
|
3624
3280
|
dispatch({
|
@@ -3630,7 +3286,7 @@ var DraggableComponent = ({
|
|
3630
3286
|
},
|
3631
3287
|
[index, zoneCompound, id]
|
3632
3288
|
);
|
3633
|
-
const onSelectParent = (0,
|
3289
|
+
const onSelectParent = (0, import_react23.useCallback)(() => {
|
3634
3290
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3635
3291
|
return;
|
3636
3292
|
}
|
@@ -3648,23 +3304,23 @@ var DraggableComponent = ({
|
|
3648
3304
|
}
|
3649
3305
|
});
|
3650
3306
|
}, [ctx, path]);
|
3651
|
-
const onDuplicate = (0,
|
3307
|
+
const onDuplicate = (0, import_react23.useCallback)(() => {
|
3652
3308
|
dispatch({
|
3653
3309
|
type: "duplicate",
|
3654
3310
|
sourceIndex: index,
|
3655
3311
|
sourceZone: zoneCompound
|
3656
3312
|
});
|
3657
3313
|
}, [index, zoneCompound]);
|
3658
|
-
const onDelete = (0,
|
3314
|
+
const onDelete = (0, import_react23.useCallback)(() => {
|
3659
3315
|
dispatch({
|
3660
3316
|
type: "remove",
|
3661
3317
|
index,
|
3662
3318
|
zone: zoneCompound
|
3663
3319
|
});
|
3664
3320
|
}, [index, zoneCompound]);
|
3665
|
-
const [hover, setHover] = (0,
|
3321
|
+
const [hover, setHover] = (0, import_react23.useState)(false);
|
3666
3322
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3667
|
-
(0,
|
3323
|
+
(0, import_react23.useEffect)(() => {
|
3668
3324
|
if (!ref.current) {
|
3669
3325
|
return;
|
3670
3326
|
}
|
@@ -3714,7 +3370,7 @@ var DraggableComponent = ({
|
|
3714
3370
|
thisIsDragging,
|
3715
3371
|
inDroppableZone
|
3716
3372
|
]);
|
3717
|
-
(0,
|
3373
|
+
(0, import_react23.useEffect)(() => {
|
3718
3374
|
if (ref.current && disabled) {
|
3719
3375
|
ref.current.setAttribute("data-puck-disabled", "");
|
3720
3376
|
return () => {
|
@@ -3723,8 +3379,8 @@ var DraggableComponent = ({
|
|
3723
3379
|
};
|
3724
3380
|
}
|
3725
3381
|
}, [disabled, ref]);
|
3726
|
-
const [isVisible, setIsVisible] = (0,
|
3727
|
-
(0,
|
3382
|
+
const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
|
3383
|
+
(0, import_react23.useEffect)(() => {
|
3728
3384
|
sync();
|
3729
3385
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3730
3386
|
setIsVisible(true);
|
@@ -3732,7 +3388,7 @@ var DraggableComponent = ({
|
|
3732
3388
|
setIsVisible(false);
|
3733
3389
|
}
|
3734
3390
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3735
|
-
const syncActionsPosition = (0,
|
3391
|
+
const syncActionsPosition = (0, import_react23.useCallback)(
|
3736
3392
|
(el) => {
|
3737
3393
|
if (el) {
|
3738
3394
|
const view = el.ownerDocument.defaultView;
|
@@ -3749,7 +3405,7 @@ var DraggableComponent = ({
|
|
3749
3405
|
},
|
3750
3406
|
[zoomConfig]
|
3751
3407
|
);
|
3752
|
-
(0,
|
3408
|
+
(0, import_react23.useEffect)(() => {
|
3753
3409
|
if (userDragAxis) {
|
3754
3410
|
setDragAxis(userDragAxis);
|
3755
3411
|
return;
|
@@ -3843,14 +3499,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
3843
3499
|
|
3844
3500
|
// components/DropZone/lib/use-min-empty-height.ts
|
3845
3501
|
init_react_import();
|
3846
|
-
var
|
3502
|
+
var import_react24 = require("react");
|
3847
3503
|
var useMinEmptyHeight = ({
|
3848
3504
|
zoneCompound,
|
3849
3505
|
userMinEmptyHeight,
|
3850
3506
|
ref
|
3851
3507
|
}) => {
|
3852
|
-
const [prevHeight, setPrevHeight] = (0,
|
3853
|
-
const [isAnimating, setIsAnimating] = (0,
|
3508
|
+
const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
|
3509
|
+
const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
|
3854
3510
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3855
3511
|
var _a, _b;
|
3856
3512
|
return {
|
@@ -3858,7 +3514,7 @@ var useMinEmptyHeight = ({
|
|
3858
3514
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3859
3515
|
};
|
3860
3516
|
});
|
3861
|
-
(0,
|
3517
|
+
(0, import_react24.useEffect)(() => {
|
3862
3518
|
if (draggedItem && ref.current) {
|
3863
3519
|
if (isZone) {
|
3864
3520
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3892,15 +3548,15 @@ function assignRefs(refs, node) {
|
|
3892
3548
|
|
3893
3549
|
// components/DropZone/lib/use-content-with-preview.ts
|
3894
3550
|
init_react_import();
|
3895
|
-
var
|
3551
|
+
var import_react27 = require("react");
|
3896
3552
|
|
3897
3553
|
// lib/dnd/use-rendered-callback.ts
|
3898
3554
|
init_react_import();
|
3899
|
-
var
|
3900
|
-
var
|
3555
|
+
var import_react25 = require("@dnd-kit/react");
|
3556
|
+
var import_react26 = require("react");
|
3901
3557
|
function useRenderedCallback(callback, deps) {
|
3902
|
-
const manager = (0,
|
3903
|
-
return (0,
|
3558
|
+
const manager = (0, import_react25.useDragDropManager)();
|
3559
|
+
return (0, import_react26.useCallback)(
|
3904
3560
|
(...args) => __async(this, null, function* () {
|
3905
3561
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
3906
3562
|
return callback(...args);
|
@@ -3935,8 +3591,8 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3935
3591
|
ui: { isDragging }
|
3936
3592
|
}
|
3937
3593
|
} = useAppContext();
|
3938
|
-
const [contentWithPreview, setContentWithPreview] = (0,
|
3939
|
-
const [localPreview, setLocalPreview] = (0,
|
3594
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3595
|
+
const [localPreview, setLocalPreview] = (0, import_react27.useState)(
|
3940
3596
|
preview
|
3941
3597
|
);
|
3942
3598
|
const updateContent = useRenderedCallback(
|
@@ -3977,7 +3633,7 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3977
3633
|
},
|
3978
3634
|
[draggedItemId, previewExists]
|
3979
3635
|
);
|
3980
|
-
(0,
|
3636
|
+
(0, import_react27.useEffect)(() => {
|
3981
3637
|
updateContent(content, preview, isDragging);
|
3982
3638
|
}, [content, preview, isDragging]);
|
3983
3639
|
return [contentWithPreview, localPreview];
|
@@ -3985,16 +3641,16 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3985
3641
|
|
3986
3642
|
// components/DropZone/lib/use-drag-axis.ts
|
3987
3643
|
init_react_import();
|
3988
|
-
var
|
3644
|
+
var import_react28 = require("react");
|
3989
3645
|
var GRID_DRAG_AXIS = "dynamic";
|
3990
3646
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3991
3647
|
var DEFAULT_DRAG_AXIS = "y";
|
3992
3648
|
var useDragAxis = (ref, collisionAxis) => {
|
3993
3649
|
const { status } = useAppContext();
|
3994
|
-
const [dragAxis, setDragAxis] = (0,
|
3650
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
3995
3651
|
collisionAxis || DEFAULT_DRAG_AXIS
|
3996
3652
|
);
|
3997
|
-
const calculateDragAxis = (0,
|
3653
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
3998
3654
|
if (ref.current) {
|
3999
3655
|
const computedStyle = window.getComputedStyle(ref.current);
|
4000
3656
|
if (computedStyle.display === "grid") {
|
@@ -4006,7 +3662,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4006
3662
|
}
|
4007
3663
|
}
|
4008
3664
|
}, [ref.current]);
|
4009
|
-
(0,
|
3665
|
+
(0, import_react28.useEffect)(() => {
|
4010
3666
|
const onViewportChange = () => {
|
4011
3667
|
calculateDragAxis();
|
4012
3668
|
};
|
@@ -4015,7 +3671,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4015
3671
|
window.removeEventListener("viewportchange", onViewportChange);
|
4016
3672
|
};
|
4017
3673
|
}, []);
|
4018
|
-
(0,
|
3674
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
4019
3675
|
return [dragAxis, calculateDragAxis];
|
4020
3676
|
};
|
4021
3677
|
|
@@ -4025,7 +3681,7 @@ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_de
|
|
4025
3681
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
4026
3682
|
var RENDER_DEBUG = false;
|
4027
3683
|
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
4028
|
-
var DropZoneEdit = (0,
|
3684
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
4029
3685
|
function DropZoneEditInternal({
|
4030
3686
|
zone,
|
4031
3687
|
allow,
|
@@ -4036,7 +3692,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4036
3692
|
collisionAxis
|
4037
3693
|
}, userRef) {
|
4038
3694
|
const appContext2 = useAppContext();
|
4039
|
-
const ctx = (0,
|
3695
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4040
3696
|
const {
|
4041
3697
|
// These all need setting via context
|
4042
3698
|
data,
|
@@ -4072,12 +3728,12 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4072
3728
|
};
|
4073
3729
|
});
|
4074
3730
|
const { itemSelector } = appContext2.state.ui;
|
4075
|
-
(0,
|
3731
|
+
(0, import_react29.useEffect)(() => {
|
4076
3732
|
if (areaId && registerZoneArea) {
|
4077
3733
|
registerZoneArea(areaId);
|
4078
3734
|
}
|
4079
3735
|
}, [areaId]);
|
4080
|
-
(0,
|
3736
|
+
(0, import_react29.useEffect)(() => {
|
4081
3737
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4082
3738
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4083
3739
|
}
|
@@ -4087,14 +3743,14 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4087
3743
|
}
|
4088
3744
|
};
|
4089
3745
|
}, []);
|
4090
|
-
const content = (0,
|
3746
|
+
const content = (0, import_react29.useMemo)(() => {
|
4091
3747
|
if (areaId && zone !== rootDroppableId) {
|
4092
3748
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
4093
3749
|
}
|
4094
3750
|
return data.content || [];
|
4095
3751
|
}, [data, zoneCompound]);
|
4096
|
-
const ref = (0,
|
4097
|
-
const acceptsTarget = (0,
|
3752
|
+
const ref = (0, import_react29.useRef)(null);
|
3753
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
4098
3754
|
(componentType) => {
|
4099
3755
|
if (!componentType) {
|
4100
3756
|
return true;
|
@@ -4116,7 +3772,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4116
3772
|
},
|
4117
3773
|
[allow, disallow]
|
4118
3774
|
);
|
4119
|
-
(0,
|
3775
|
+
(0, import_react29.useEffect)(() => {
|
4120
3776
|
if (registerLocalZone) {
|
4121
3777
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
4122
3778
|
}
|
@@ -4251,13 +3907,13 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4251
3907
|
}
|
4252
3908
|
);
|
4253
3909
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
4254
|
-
var DropZoneRender = (0,
|
3910
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
4255
3911
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
4256
|
-
const ctx = (0,
|
3912
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4257
3913
|
const { data, areaId = "root", config } = ctx || {};
|
4258
3914
|
let zoneCompound = rootDroppableId;
|
4259
3915
|
let content = (data == null ? void 0 : data.content) || [];
|
4260
|
-
(0,
|
3916
|
+
(0, import_react29.useEffect)(() => {
|
4261
3917
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4262
3918
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4263
3919
|
}
|
@@ -4304,709 +3960,963 @@ var DropZoneRender = (0, import_react30.forwardRef)(
|
|
4304
3960
|
}
|
4305
3961
|
);
|
4306
3962
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
|
4307
|
-
var DropZone = (0,
|
3963
|
+
var DropZone = (0, import_react29.forwardRef)(
|
4308
3964
|
function DropZone2(props, ref) {
|
4309
|
-
const ctx = (0,
|
3965
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4310
3966
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
4311
3967
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
4312
3968
|
}
|
4313
3969
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
4314
3970
|
}
|
4315
|
-
);
|
3971
|
+
);
|
3972
|
+
|
3973
|
+
// lib/get-zone-id.ts
|
3974
|
+
init_react_import();
|
3975
|
+
var getZoneId = (zoneCompound) => {
|
3976
|
+
if (!zoneCompound) {
|
3977
|
+
return [];
|
3978
|
+
}
|
3979
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
3980
|
+
return zoneCompound.split(":");
|
3981
|
+
}
|
3982
|
+
return [rootDroppableId, zoneCompound];
|
3983
|
+
};
|
3984
|
+
|
3985
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3986
|
+
init_react_import();
|
3987
|
+
var import_abstract9 = require("@dnd-kit/abstract");
|
3988
|
+
var import_state = require("@dnd-kit/state");
|
3989
|
+
|
3990
|
+
// lib/throttle.ts
|
3991
|
+
init_react_import();
|
3992
|
+
function timeout2(callback, duration) {
|
3993
|
+
const id = setTimeout(callback, duration);
|
3994
|
+
return () => clearTimeout(id);
|
3995
|
+
}
|
3996
|
+
function throttle(func, limit) {
|
3997
|
+
const time = () => performance.now();
|
3998
|
+
let cancel;
|
3999
|
+
let lastRan = 0;
|
4000
|
+
return function(...args) {
|
4001
|
+
const now = time();
|
4002
|
+
const context = this;
|
4003
|
+
if (now - lastRan >= limit) {
|
4004
|
+
func.apply(context, args);
|
4005
|
+
lastRan = now;
|
4006
|
+
} else {
|
4007
|
+
cancel == null ? void 0 : cancel();
|
4008
|
+
cancel = timeout2(() => {
|
4009
|
+
func.apply(context, args);
|
4010
|
+
lastRan = time();
|
4011
|
+
}, limit - (now - lastRan));
|
4012
|
+
}
|
4013
|
+
};
|
4014
|
+
}
|
4015
|
+
|
4016
|
+
// lib/get-frame.ts
|
4017
|
+
init_react_import();
|
4018
|
+
var getFrame = () => {
|
4019
|
+
if (typeof window === "undefined") return;
|
4020
|
+
let frameEl = document.querySelector("#preview-frame");
|
4021
|
+
if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
|
4022
|
+
return frameEl.contentDocument || document;
|
4023
|
+
}
|
4024
|
+
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
4025
|
+
};
|
4026
|
+
|
4027
|
+
// lib/global-position.ts
|
4028
|
+
init_react_import();
|
4029
|
+
var GlobalPosition = class {
|
4030
|
+
constructor(target, original) {
|
4031
|
+
this.scaleFactor = 1;
|
4032
|
+
this.frameEl = null;
|
4033
|
+
this.frameRect = null;
|
4034
|
+
var _a;
|
4035
|
+
this.target = target;
|
4036
|
+
this.original = original;
|
4037
|
+
this.frameEl = document.querySelector("iframe");
|
4038
|
+
if (this.frameEl) {
|
4039
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
4040
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
4041
|
+
}
|
4042
|
+
}
|
4043
|
+
get x() {
|
4044
|
+
return this.original.x;
|
4045
|
+
}
|
4046
|
+
get y() {
|
4047
|
+
return this.original.y;
|
4048
|
+
}
|
4049
|
+
get global() {
|
4050
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
4051
|
+
return {
|
4052
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
4053
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
4054
|
+
};
|
4055
|
+
}
|
4056
|
+
return this.original;
|
4057
|
+
}
|
4058
|
+
get frame() {
|
4059
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
4060
|
+
return {
|
4061
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
4062
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
4063
|
+
};
|
4064
|
+
}
|
4065
|
+
return this.original;
|
4066
|
+
}
|
4067
|
+
};
|
4068
|
+
|
4069
|
+
// lib/bubble-pointer-event.ts
|
4070
|
+
init_react_import();
|
4071
|
+
var BaseEvent = typeof PointerEvent !== "undefined" ? PointerEvent : Event;
|
4072
|
+
var BubbledPointerEvent = class extends BaseEvent {
|
4073
|
+
constructor(type, data) {
|
4074
|
+
super(type, data);
|
4075
|
+
this._originalTarget = null;
|
4076
|
+
this.originalTarget = data.originalTarget;
|
4077
|
+
}
|
4078
|
+
// Necessary for Firefox
|
4079
|
+
set originalTarget(target) {
|
4080
|
+
this._originalTarget = target;
|
4081
|
+
}
|
4082
|
+
// Necessary for Firefox
|
4083
|
+
get originalTarget() {
|
4084
|
+
return this._originalTarget;
|
4085
|
+
}
|
4086
|
+
};
|
4087
|
+
|
4088
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
4089
|
+
var depthSort = (candidates) => {
|
4090
|
+
return candidates.sort((a, b) => {
|
4091
|
+
const aData = a.data;
|
4092
|
+
const bData = b.data;
|
4093
|
+
if (aData.depth > bData.depth) {
|
4094
|
+
return 1;
|
4095
|
+
}
|
4096
|
+
if (bData.depth > aData.depth) {
|
4097
|
+
return -1;
|
4098
|
+
}
|
4099
|
+
return 0;
|
4100
|
+
});
|
4101
|
+
};
|
4102
|
+
var getZoneId2 = (candidate) => {
|
4103
|
+
let id = candidate == null ? void 0 : candidate.id;
|
4104
|
+
if (!candidate) return null;
|
4105
|
+
if (candidate.type === "component") {
|
4106
|
+
const data = candidate.data;
|
4107
|
+
if (data.containsActiveZone) {
|
4108
|
+
id = null;
|
4109
|
+
} else {
|
4110
|
+
id = data.zone;
|
4111
|
+
}
|
4112
|
+
} else if (candidate.type === "void") {
|
4113
|
+
return "void";
|
4114
|
+
}
|
4115
|
+
return id;
|
4116
|
+
};
|
4117
|
+
var getPointerCollisions = (position, manager) => {
|
4118
|
+
const candidates = [];
|
4119
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
4120
|
+
position.x,
|
4121
|
+
position.y
|
4122
|
+
);
|
4123
|
+
const previewFrame = elements.find(
|
4124
|
+
(el) => el.getAttribute("data-puck-preview")
|
4125
|
+
);
|
4126
|
+
const drawer = elements.find((el) => el.getAttribute("data-puck-drawer"));
|
4127
|
+
if (drawer) {
|
4128
|
+
elements = [drawer];
|
4129
|
+
}
|
4130
|
+
if (previewFrame) {
|
4131
|
+
const frame = getFrame();
|
4132
|
+
if (frame) {
|
4133
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
4134
|
+
}
|
4135
|
+
}
|
4136
|
+
if (elements) {
|
4137
|
+
for (let i = 0; i < elements.length; i++) {
|
4138
|
+
const element = elements[i];
|
4139
|
+
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
4140
|
+
if (dropzoneId) {
|
4141
|
+
const droppable = manager.registry.droppables.get(dropzoneId);
|
4142
|
+
if (droppable) {
|
4143
|
+
candidates.push(droppable);
|
4144
|
+
}
|
4145
|
+
}
|
4146
|
+
const id = element.getAttribute("data-puck-dnd");
|
4147
|
+
if (id) {
|
4148
|
+
const droppable = manager.registry.droppables.get(id);
|
4149
|
+
if (droppable) {
|
4150
|
+
candidates.push(droppable);
|
4151
|
+
}
|
4152
|
+
}
|
4153
|
+
}
|
4154
|
+
}
|
4155
|
+
return candidates;
|
4156
|
+
};
|
4157
|
+
var findDeepestCandidate = (position, manager) => {
|
4158
|
+
var _a;
|
4159
|
+
const candidates = getPointerCollisions(position, manager);
|
4160
|
+
if (candidates.length > 0) {
|
4161
|
+
const sortedCandidates = depthSort(candidates);
|
4162
|
+
const draggable = manager.dragOperation.source;
|
4163
|
+
const draggedCandidateIndex = sortedCandidates.findIndex(
|
4164
|
+
(candidate) => candidate.id === (draggable == null ? void 0 : draggable.id)
|
4165
|
+
);
|
4166
|
+
const draggedCandidateId = draggable == null ? void 0 : draggable.id;
|
4167
|
+
let filteredCandidates = [...sortedCandidates];
|
4168
|
+
if (draggedCandidateId && draggedCandidateIndex > -1) {
|
4169
|
+
filteredCandidates.splice(draggedCandidateIndex, 1);
|
4170
|
+
}
|
4171
|
+
filteredCandidates = filteredCandidates.filter((candidate) => {
|
4172
|
+
const candidateData = candidate.data;
|
4173
|
+
if (draggedCandidateId && draggedCandidateIndex > -1) {
|
4174
|
+
if (candidateData.path.indexOf(draggedCandidateId) > -1) {
|
4175
|
+
return false;
|
4176
|
+
}
|
4177
|
+
}
|
4178
|
+
if (candidate.type === "dropzone") {
|
4179
|
+
const candidateData2 = candidate.data;
|
4180
|
+
if (!candidateData2.isDroppableTarget) {
|
4181
|
+
return false;
|
4182
|
+
}
|
4183
|
+
if (candidateData2.areaId === draggedCandidateId) {
|
4184
|
+
return false;
|
4185
|
+
}
|
4186
|
+
} else if (candidate.type === "component") {
|
4187
|
+
const candidateData2 = candidate.data;
|
4188
|
+
if (!candidateData2.inDroppableZone) {
|
4189
|
+
return false;
|
4190
|
+
}
|
4191
|
+
}
|
4192
|
+
return true;
|
4193
|
+
});
|
4194
|
+
filteredCandidates.reverse();
|
4195
|
+
const zone = getZoneId2(filteredCandidates[0]);
|
4196
|
+
const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
|
4197
|
+
return { zone, area };
|
4198
|
+
}
|
4199
|
+
return {
|
4200
|
+
zone: "default-zone",
|
4201
|
+
area: null
|
4202
|
+
};
|
4203
|
+
};
|
4204
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
4205
|
+
constructor(manager, options) {
|
4206
|
+
super(manager);
|
4207
|
+
if (typeof window === "undefined") {
|
4208
|
+
return;
|
4209
|
+
}
|
4210
|
+
const cleanupEffect = (0, import_state.effects)(() => {
|
4211
|
+
const handleMove = (event) => {
|
4212
|
+
const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
|
4213
|
+
const position = new GlobalPosition(target, {
|
4214
|
+
x: event.clientX,
|
4215
|
+
y: event.clientY
|
4216
|
+
});
|
4217
|
+
const elements = document.elementsFromPoint(
|
4218
|
+
position.global.x,
|
4219
|
+
position.global.y
|
4220
|
+
);
|
4221
|
+
const overEl = elements.some((el) => el.id === id);
|
4222
|
+
if (overEl) {
|
4223
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
4224
|
+
}
|
4225
|
+
};
|
4226
|
+
const handleMoveThrottled = throttle(handleMove, 50);
|
4227
|
+
const handlePointerMove = (event) => {
|
4228
|
+
handleMoveThrottled(event);
|
4229
|
+
};
|
4230
|
+
document.body.addEventListener("pointermove", handlePointerMove, {
|
4231
|
+
capture: true
|
4232
|
+
// dndkit's PointerSensor prevents propagation during drag
|
4233
|
+
});
|
4234
|
+
this.destroy = () => {
|
4235
|
+
document.body.removeEventListener("pointermove", handlePointerMove, {
|
4236
|
+
capture: true
|
4237
|
+
});
|
4238
|
+
cleanupEffect();
|
4239
|
+
};
|
4240
|
+
});
|
4241
|
+
}
|
4242
|
+
};
|
4316
4243
|
|
4317
|
-
// lib/
|
4244
|
+
// lib/insert-component.ts
|
4318
4245
|
init_react_import();
|
4319
|
-
var getZoneId = (zoneCompound) => {
|
4320
|
-
if (!zoneCompound) {
|
4321
|
-
return [];
|
4322
|
-
}
|
4323
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
4324
|
-
return zoneCompound.split(":");
|
4325
|
-
}
|
4326
|
-
return [rootDroppableId, zoneCompound];
|
4327
|
-
};
|
4328
4246
|
|
4329
|
-
//
|
4247
|
+
// reducer/index.ts
|
4330
4248
|
init_react_import();
|
4331
|
-
var import_abstract10 = require("@dnd-kit/abstract");
|
4332
|
-
var import_state2 = require("@dnd-kit/state");
|
4333
4249
|
|
4334
|
-
//
|
4250
|
+
// reducer/data.ts
|
4335
4251
|
init_react_import();
|
4336
|
-
function timeout2(callback, duration) {
|
4337
|
-
const id = setTimeout(callback, duration);
|
4338
|
-
return () => clearTimeout(id);
|
4339
|
-
}
|
4340
|
-
function throttle(func, limit) {
|
4341
|
-
const time = () => performance.now();
|
4342
|
-
let cancel;
|
4343
|
-
let lastRan = 0;
|
4344
|
-
return function(...args) {
|
4345
|
-
const now = time();
|
4346
|
-
const context = this;
|
4347
|
-
if (now - lastRan >= limit) {
|
4348
|
-
func.apply(context, args);
|
4349
|
-
lastRan = now;
|
4350
|
-
} else {
|
4351
|
-
cancel == null ? void 0 : cancel();
|
4352
|
-
cancel = timeout2(() => {
|
4353
|
-
func.apply(context, args);
|
4354
|
-
lastRan = time();
|
4355
|
-
}, limit - (now - lastRan));
|
4356
|
-
}
|
4357
|
-
};
|
4358
|
-
}
|
4359
4252
|
|
4360
|
-
// lib/
|
4253
|
+
// lib/remove.ts
|
4361
4254
|
init_react_import();
|
4362
|
-
var
|
4363
|
-
|
4364
|
-
|
4365
|
-
|
4366
|
-
return frameEl.contentDocument || document;
|
4367
|
-
}
|
4368
|
-
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
4255
|
+
var remove = (list, index) => {
|
4256
|
+
const result = Array.from(list);
|
4257
|
+
result.splice(index, 1);
|
4258
|
+
return result;
|
4369
4259
|
};
|
4370
4260
|
|
4371
|
-
// lib/
|
4261
|
+
// lib/reduce-related-zones.ts
|
4372
4262
|
init_react_import();
|
4373
|
-
|
4374
|
-
|
4375
|
-
|
4376
|
-
|
4377
|
-
|
4378
|
-
|
4379
|
-
|
4380
|
-
|
4381
|
-
|
4382
|
-
|
4383
|
-
|
4384
|
-
|
4385
|
-
|
4386
|
-
}
|
4387
|
-
|
4388
|
-
|
4389
|
-
|
4390
|
-
|
4391
|
-
|
4263
|
+
function reduceRelatedZones(item, data, fn) {
|
4264
|
+
return __spreadProps(__spreadValues({}, data), {
|
4265
|
+
zones: Object.keys(data.zones || {}).reduce(
|
4266
|
+
(acc, key) => {
|
4267
|
+
const [parentId] = getZoneId(key);
|
4268
|
+
if (parentId === item.props.id) {
|
4269
|
+
const zones = data.zones;
|
4270
|
+
return fn(acc, key, zones[key]);
|
4271
|
+
}
|
4272
|
+
return __spreadProps(__spreadValues({}, acc), { [key]: data.zones[key] });
|
4273
|
+
},
|
4274
|
+
{}
|
4275
|
+
)
|
4276
|
+
});
|
4277
|
+
}
|
4278
|
+
var findRelatedByZoneId = (zoneId, data) => {
|
4279
|
+
const [zoneParentId] = getZoneId(zoneId);
|
4280
|
+
return (data.zones[zoneId] || []).reduce(
|
4281
|
+
(acc, zoneItem) => {
|
4282
|
+
const related = findRelatedByItem(zoneItem, data);
|
4283
|
+
if (zoneItem.props.id === zoneParentId) {
|
4284
|
+
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
|
4285
|
+
}
|
4286
|
+
return __spreadValues(__spreadValues({}, acc), related);
|
4287
|
+
},
|
4288
|
+
{}
|
4289
|
+
);
|
4290
|
+
};
|
4291
|
+
var findRelatedByItem = (item, data) => {
|
4292
|
+
return Object.keys(data.zones || {}).reduce(
|
4293
|
+
(acc, zoneId) => {
|
4294
|
+
const [zoneParentId] = getZoneId(zoneId);
|
4295
|
+
if (item.props.id === zoneParentId) {
|
4296
|
+
const related = findRelatedByZoneId(zoneId, data);
|
4297
|
+
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), {
|
4298
|
+
[zoneId]: data.zones[zoneId]
|
4299
|
+
});
|
4300
|
+
}
|
4301
|
+
return acc;
|
4302
|
+
},
|
4303
|
+
{}
|
4304
|
+
);
|
4305
|
+
};
|
4306
|
+
var removeRelatedZones = (item, data) => {
|
4307
|
+
const newData = __spreadValues({}, data);
|
4308
|
+
const related = findRelatedByItem(item, data);
|
4309
|
+
Object.keys(related).forEach((key) => {
|
4310
|
+
delete newData.zones[key];
|
4311
|
+
});
|
4312
|
+
return newData;
|
4313
|
+
};
|
4314
|
+
function duplicateRelatedZones(item, data, newId) {
|
4315
|
+
return reduceRelatedZones(item, data, (acc, key, zone) => {
|
4316
|
+
const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
|
4317
|
+
props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
|
4318
|
+
}));
|
4319
|
+
const dupeOfDupes = dupedZone.reduce(
|
4320
|
+
(dupeOfDupes2, item2, index) => __spreadValues(__spreadValues({}, dupeOfDupes2), duplicateRelatedZones(zone[index], data, item2.props.id).zones),
|
4321
|
+
acc
|
4322
|
+
);
|
4323
|
+
const [_, zoneId] = getZoneId(key);
|
4324
|
+
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
4325
|
+
[key]: zone,
|
4326
|
+
[`${newId}:${zoneId}`]: dupedZone
|
4327
|
+
});
|
4328
|
+
});
|
4329
|
+
}
|
4330
|
+
|
4331
|
+
// reducer/data.ts
|
4332
|
+
var zoneCache = {};
|
4333
|
+
var addToZoneCache = (key, data) => {
|
4334
|
+
zoneCache[key] = data;
|
4335
|
+
};
|
4336
|
+
var replaceAction = (data, action) => {
|
4337
|
+
if (action.destinationZone === rootDroppableId) {
|
4338
|
+
return __spreadProps(__spreadValues({}, data), {
|
4339
|
+
content: replace(data.content, action.destinationIndex, action.data)
|
4340
|
+
});
|
4392
4341
|
}
|
4393
|
-
|
4394
|
-
|
4395
|
-
|
4396
|
-
|
4397
|
-
|
4398
|
-
|
4399
|
-
|
4400
|
-
|
4342
|
+
const newData = setupZone(data, action.destinationZone);
|
4343
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4344
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4345
|
+
[action.destinationZone]: replace(
|
4346
|
+
newData.zones[action.destinationZone],
|
4347
|
+
action.destinationIndex,
|
4348
|
+
action.data
|
4349
|
+
)
|
4350
|
+
})
|
4351
|
+
});
|
4352
|
+
};
|
4353
|
+
function insertAction(data, action, config) {
|
4354
|
+
const emptyComponentData = {
|
4355
|
+
type: action.componentType,
|
4356
|
+
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
4357
|
+
id: action.id || generateId(action.componentType)
|
4358
|
+
})
|
4359
|
+
};
|
4360
|
+
if (action.destinationZone === rootDroppableId) {
|
4361
|
+
return __spreadProps(__spreadValues({}, data), {
|
4362
|
+
content: insert(
|
4363
|
+
data.content,
|
4364
|
+
action.destinationIndex,
|
4365
|
+
emptyComponentData
|
4366
|
+
)
|
4367
|
+
});
|
4401
4368
|
}
|
4402
|
-
|
4403
|
-
|
4404
|
-
|
4405
|
-
|
4406
|
-
|
4407
|
-
|
4408
|
-
|
4409
|
-
|
4369
|
+
const newData = setupZone(data, action.destinationZone);
|
4370
|
+
return __spreadProps(__spreadValues({}, data), {
|
4371
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4372
|
+
[action.destinationZone]: insert(
|
4373
|
+
newData.zones[action.destinationZone],
|
4374
|
+
action.destinationIndex,
|
4375
|
+
emptyComponentData
|
4376
|
+
)
|
4377
|
+
})
|
4378
|
+
});
|
4379
|
+
}
|
4380
|
+
var reorderAction = (data, action) => {
|
4381
|
+
if (action.destinationZone === rootDroppableId) {
|
4382
|
+
return __spreadProps(__spreadValues({}, data), {
|
4383
|
+
content: reorder(
|
4384
|
+
data.content,
|
4385
|
+
action.sourceIndex,
|
4386
|
+
action.destinationIndex
|
4387
|
+
)
|
4388
|
+
});
|
4410
4389
|
}
|
4411
|
-
|
4412
|
-
|
4413
|
-
|
4414
|
-
|
4415
|
-
|
4416
|
-
|
4417
|
-
|
4418
|
-
|
4419
|
-
|
4420
|
-
|
4390
|
+
const newData = setupZone(data, action.destinationZone);
|
4391
|
+
return __spreadProps(__spreadValues({}, data), {
|
4392
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4393
|
+
[action.destinationZone]: reorder(
|
4394
|
+
newData.zones[action.destinationZone],
|
4395
|
+
action.sourceIndex,
|
4396
|
+
action.destinationIndex
|
4397
|
+
)
|
4398
|
+
})
|
4399
|
+
});
|
4400
|
+
};
|
4401
|
+
function reduceData(data, action, config) {
|
4402
|
+
if (action.type === "insert") {
|
4403
|
+
return insertAction(data, action, config);
|
4421
4404
|
}
|
4422
|
-
|
4423
|
-
|
4424
|
-
|
4405
|
+
if (action.type === "duplicate") {
|
4406
|
+
const item = getItem(
|
4407
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
4408
|
+
data
|
4409
|
+
);
|
4410
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
4411
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
4412
|
+
id: generateId(item.type)
|
4413
|
+
})
|
4414
|
+
});
|
4415
|
+
const dataWithRelatedDuplicated = duplicateRelatedZones(
|
4416
|
+
item,
|
4417
|
+
data,
|
4418
|
+
newItem.props.id
|
4419
|
+
);
|
4420
|
+
if (action.sourceZone === rootDroppableId) {
|
4421
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
4422
|
+
content: insert(data.content, action.sourceIndex + 1, newItem)
|
4423
|
+
});
|
4424
|
+
}
|
4425
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
4426
|
+
zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
|
4427
|
+
[action.sourceZone]: insert(
|
4428
|
+
dataWithRelatedDuplicated.zones[action.sourceZone],
|
4429
|
+
action.sourceIndex + 1,
|
4430
|
+
newItem
|
4431
|
+
)
|
4432
|
+
})
|
4433
|
+
});
|
4425
4434
|
}
|
4426
|
-
|
4427
|
-
|
4428
|
-
return this._originalTarget;
|
4435
|
+
if (action.type === "reorder") {
|
4436
|
+
return reorderAction(data, action);
|
4429
4437
|
}
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4433
|
-
var depthSort = (candidates) => {
|
4434
|
-
return candidates.sort((a, b) => {
|
4435
|
-
const aData = a.data;
|
4436
|
-
const bData = b.data;
|
4437
|
-
if (aData.depth > bData.depth) {
|
4438
|
-
return 1;
|
4438
|
+
if (action.type === "move") {
|
4439
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
4440
|
+
return data;
|
4439
4441
|
}
|
4440
|
-
|
4441
|
-
|
4442
|
+
const newData = setupZone(
|
4443
|
+
setupZone(data, action.sourceZone),
|
4444
|
+
action.destinationZone
|
4445
|
+
);
|
4446
|
+
const item = getItem(
|
4447
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
4448
|
+
newData
|
4449
|
+
);
|
4450
|
+
if (action.sourceZone === action.destinationZone) {
|
4451
|
+
return reorderAction(data, __spreadProps(__spreadValues({}, action), { type: "reorder" }));
|
4442
4452
|
}
|
4443
|
-
|
4444
|
-
|
4445
|
-
|
4446
|
-
|
4447
|
-
|
4448
|
-
|
4449
|
-
|
4450
|
-
|
4451
|
-
|
4452
|
-
|
4453
|
-
|
4454
|
-
id = data.zone;
|
4453
|
+
if (action.sourceZone === rootDroppableId) {
|
4454
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4455
|
+
content: remove(newData.content, action.sourceIndex),
|
4456
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4457
|
+
[action.destinationZone]: insert(
|
4458
|
+
newData.zones[action.destinationZone],
|
4459
|
+
action.destinationIndex,
|
4460
|
+
item
|
4461
|
+
)
|
4462
|
+
})
|
4463
|
+
});
|
4455
4464
|
}
|
4456
|
-
|
4457
|
-
|
4458
|
-
|
4459
|
-
|
4460
|
-
|
4461
|
-
|
4462
|
-
|
4463
|
-
|
4464
|
-
|
4465
|
-
|
4466
|
-
);
|
4467
|
-
const previewFrame = elements.find(
|
4468
|
-
(el) => el.getAttribute("data-puck-preview")
|
4469
|
-
);
|
4470
|
-
const drawer = elements.find((el) => el.getAttribute("data-puck-drawer"));
|
4471
|
-
if (drawer) {
|
4472
|
-
elements = [drawer];
|
4473
|
-
}
|
4474
|
-
if (previewFrame) {
|
4475
|
-
const frame = getFrame();
|
4476
|
-
if (frame) {
|
4477
|
-
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
4465
|
+
if (action.destinationZone === rootDroppableId) {
|
4466
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4467
|
+
content: insert(newData.content, action.destinationIndex, item),
|
4468
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4469
|
+
[action.sourceZone]: remove(
|
4470
|
+
newData.zones[action.sourceZone],
|
4471
|
+
action.sourceIndex
|
4472
|
+
)
|
4473
|
+
})
|
4474
|
+
});
|
4478
4475
|
}
|
4476
|
+
return __spreadProps(__spreadValues({}, newData), {
|
4477
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
4478
|
+
[action.sourceZone]: remove(
|
4479
|
+
newData.zones[action.sourceZone],
|
4480
|
+
action.sourceIndex
|
4481
|
+
),
|
4482
|
+
[action.destinationZone]: insert(
|
4483
|
+
newData.zones[action.destinationZone],
|
4484
|
+
action.destinationIndex,
|
4485
|
+
item
|
4486
|
+
)
|
4487
|
+
})
|
4488
|
+
});
|
4479
4489
|
}
|
4480
|
-
if (
|
4481
|
-
|
4482
|
-
const element = elements[i];
|
4483
|
-
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
4484
|
-
if (dropzoneId) {
|
4485
|
-
const droppable = manager.registry.droppables.get(dropzoneId);
|
4486
|
-
if (droppable) {
|
4487
|
-
candidates.push(droppable);
|
4488
|
-
}
|
4489
|
-
}
|
4490
|
-
const id = element.getAttribute("data-puck-dnd");
|
4491
|
-
if (id) {
|
4492
|
-
const droppable = manager.registry.droppables.get(id);
|
4493
|
-
if (droppable) {
|
4494
|
-
candidates.push(droppable);
|
4495
|
-
}
|
4496
|
-
}
|
4497
|
-
}
|
4490
|
+
if (action.type === "replace") {
|
4491
|
+
return replaceAction(data, action);
|
4498
4492
|
}
|
4499
|
-
|
4500
|
-
};
|
4501
|
-
|
4502
|
-
|
4503
|
-
|
4504
|
-
if (candidates.length > 0) {
|
4505
|
-
const sortedCandidates = depthSort(candidates);
|
4506
|
-
const draggable = manager.dragOperation.source;
|
4507
|
-
const draggedCandidateIndex = sortedCandidates.findIndex(
|
4508
|
-
(candidate) => candidate.id === (draggable == null ? void 0 : draggable.id)
|
4493
|
+
if (action.type === "remove") {
|
4494
|
+
const item = getItem({ index: action.index, zone: action.zone }, data);
|
4495
|
+
const dataWithRelatedRemoved = setupZone(
|
4496
|
+
removeRelatedZones(item, data),
|
4497
|
+
action.zone
|
4509
4498
|
);
|
4510
|
-
|
4511
|
-
|
4512
|
-
|
4513
|
-
|
4499
|
+
if (action.zone === rootDroppableId) {
|
4500
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
4501
|
+
content: remove(data.content, action.index)
|
4502
|
+
});
|
4514
4503
|
}
|
4515
|
-
|
4516
|
-
|
4517
|
-
|
4518
|
-
|
4519
|
-
|
4520
|
-
|
4521
|
-
}
|
4522
|
-
if (candidate.type === "dropzone") {
|
4523
|
-
const candidateData2 = candidate.data;
|
4524
|
-
if (!candidateData2.isDroppableTarget) {
|
4525
|
-
return false;
|
4526
|
-
}
|
4527
|
-
if (candidateData2.areaId === draggedCandidateId) {
|
4528
|
-
return false;
|
4529
|
-
}
|
4530
|
-
} else if (candidate.type === "component") {
|
4531
|
-
const candidateData2 = candidate.data;
|
4532
|
-
if (!candidateData2.inDroppableZone) {
|
4533
|
-
return false;
|
4534
|
-
}
|
4535
|
-
}
|
4536
|
-
return true;
|
4504
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
4505
|
+
zones: __spreadProps(__spreadValues({}, dataWithRelatedRemoved.zones), {
|
4506
|
+
[action.zone]: remove(
|
4507
|
+
dataWithRelatedRemoved.zones[action.zone],
|
4508
|
+
action.index
|
4509
|
+
)
|
4510
|
+
})
|
4537
4511
|
});
|
4538
|
-
filteredCandidates.reverse();
|
4539
|
-
const zone = getZoneId2(filteredCandidates[0]);
|
4540
|
-
const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
|
4541
|
-
return { zone, area };
|
4542
4512
|
}
|
4543
|
-
|
4544
|
-
zone
|
4545
|
-
|
4546
|
-
|
4547
|
-
|
4548
|
-
|
4549
|
-
constructor(manager, options) {
|
4550
|
-
super(manager);
|
4551
|
-
if (typeof window === "undefined") {
|
4552
|
-
return;
|
4553
|
-
}
|
4554
|
-
const cleanupEffect = (0, import_state2.effects)(() => {
|
4555
|
-
const handleMove = (event) => {
|
4556
|
-
const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
|
4557
|
-
const position = new GlobalPosition(target, {
|
4558
|
-
x: event.clientX,
|
4559
|
-
y: event.clientY
|
4560
|
-
});
|
4561
|
-
const elements = document.elementsFromPoint(
|
4562
|
-
position.global.x,
|
4563
|
-
position.global.y
|
4564
|
-
);
|
4565
|
-
const overEl = elements.some((el) => el.id === id);
|
4566
|
-
if (overEl) {
|
4567
|
-
onChange(findDeepestCandidate(position, manager), manager);
|
4568
|
-
}
|
4569
|
-
};
|
4570
|
-
const handleMoveThrottled = throttle(handleMove, 50);
|
4571
|
-
const handlePointerMove = (event) => {
|
4572
|
-
handleMoveThrottled(event);
|
4573
|
-
};
|
4574
|
-
document.body.addEventListener("pointermove", handlePointerMove, {
|
4575
|
-
capture: true
|
4576
|
-
// dndkit's PointerSensor prevents propagation during drag
|
4513
|
+
if (action.type === "registerZone") {
|
4514
|
+
if (zoneCache[action.zone]) {
|
4515
|
+
return __spreadProps(__spreadValues({}, data), {
|
4516
|
+
zones: __spreadProps(__spreadValues({}, data.zones), {
|
4517
|
+
[action.zone]: zoneCache[action.zone]
|
4518
|
+
})
|
4577
4519
|
});
|
4578
|
-
|
4579
|
-
|
4580
|
-
|
4581
|
-
|
4582
|
-
|
4583
|
-
|
4520
|
+
}
|
4521
|
+
return setupZone(data, action.zone);
|
4522
|
+
}
|
4523
|
+
if (action.type === "unregisterZone") {
|
4524
|
+
const _zones = __spreadValues({}, data.zones || {});
|
4525
|
+
if (_zones[action.zone]) {
|
4526
|
+
zoneCache[action.zone] = _zones[action.zone];
|
4527
|
+
delete _zones[action.zone];
|
4528
|
+
}
|
4529
|
+
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
4530
|
+
}
|
4531
|
+
if (action.type === "setData") {
|
4532
|
+
if (typeof action.data === "object") {
|
4533
|
+
return __spreadValues(__spreadValues({}, data), action.data);
|
4534
|
+
}
|
4535
|
+
return __spreadValues(__spreadValues({}, data), action.data(data));
|
4536
|
+
}
|
4537
|
+
return data;
|
4538
|
+
}
|
4539
|
+
|
4540
|
+
// reducer/state.ts
|
4541
|
+
init_react_import();
|
4542
|
+
var reduceUi = (ui, action) => {
|
4543
|
+
if (action.type === "setUi") {
|
4544
|
+
if (typeof action.ui === "object") {
|
4545
|
+
return __spreadValues(__spreadValues({}, ui), action.ui);
|
4546
|
+
}
|
4547
|
+
return __spreadValues(__spreadValues({}, ui), action.ui(ui));
|
4548
|
+
}
|
4549
|
+
if (action.type === "duplicate") {
|
4550
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4551
|
+
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4552
|
+
});
|
4553
|
+
}
|
4554
|
+
if (action.type === "remove") {
|
4555
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4556
|
+
itemSelector: null
|
4584
4557
|
});
|
4585
4558
|
}
|
4559
|
+
return ui;
|
4586
4560
|
};
|
4587
4561
|
|
4588
|
-
//
|
4562
|
+
// reducer/actions.tsx
|
4589
4563
|
init_react_import();
|
4590
4564
|
|
4591
4565
|
// reducer/index.ts
|
4592
|
-
|
4593
|
-
|
4594
|
-
|
4595
|
-
|
4596
|
-
|
4597
|
-
|
4598
|
-
|
4599
|
-
|
4600
|
-
|
4601
|
-
|
4602
|
-
|
4603
|
-
|
4604
|
-
|
4605
|
-
|
4606
|
-
|
4607
|
-
|
4608
|
-
return __spreadProps(__spreadValues({}, data), {
|
4609
|
-
zones: Object.keys(data.zones || {}).reduce(
|
4610
|
-
(acc, key) => {
|
4611
|
-
const [parentId] = getZoneId(key);
|
4612
|
-
if (parentId === item.props.id) {
|
4613
|
-
const zones = data.zones;
|
4614
|
-
return fn(acc, key, zones[key]);
|
4615
|
-
}
|
4616
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: data.zones[key] });
|
4617
|
-
},
|
4618
|
-
{}
|
4619
|
-
)
|
4620
|
-
});
|
4566
|
+
function storeInterceptor(reducer, record, onAction) {
|
4567
|
+
return (state, action) => {
|
4568
|
+
const newAppState = reducer(state, action);
|
4569
|
+
const isValidType = ![
|
4570
|
+
"registerZone",
|
4571
|
+
"unregisterZone",
|
4572
|
+
"setData",
|
4573
|
+
"setUi",
|
4574
|
+
"set"
|
4575
|
+
].includes(action.type);
|
4576
|
+
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
4577
|
+
if (record) record(newAppState);
|
4578
|
+
}
|
4579
|
+
onAction == null ? void 0 : onAction(action, newAppState, state);
|
4580
|
+
return newAppState;
|
4581
|
+
};
|
4621
4582
|
}
|
4622
|
-
var
|
4623
|
-
|
4624
|
-
|
4625
|
-
|
4626
|
-
|
4627
|
-
if (zoneItem.props.id === zoneParentId) {
|
4628
|
-
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
|
4629
|
-
}
|
4630
|
-
return __spreadValues(__spreadValues({}, acc), related);
|
4631
|
-
},
|
4632
|
-
{}
|
4633
|
-
);
|
4583
|
+
var setAction = (state, action) => {
|
4584
|
+
if (typeof action.state === "object") {
|
4585
|
+
return __spreadValues(__spreadValues({}, state), action.state);
|
4586
|
+
}
|
4587
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
4634
4588
|
};
|
4635
|
-
|
4636
|
-
|
4637
|
-
|
4638
|
-
|
4639
|
-
|
4640
|
-
|
4641
|
-
|
4642
|
-
|
4643
|
-
|
4589
|
+
function createReducer({
|
4590
|
+
config,
|
4591
|
+
record,
|
4592
|
+
onAction
|
4593
|
+
}) {
|
4594
|
+
return storeInterceptor(
|
4595
|
+
(state, action) => {
|
4596
|
+
const data = reduceData(state.data, action, config);
|
4597
|
+
const ui = reduceUi(state.ui, action);
|
4598
|
+
if (action.type === "set") {
|
4599
|
+
return setAction(state, action);
|
4644
4600
|
}
|
4645
|
-
return
|
4601
|
+
return { data, ui };
|
4646
4602
|
},
|
4647
|
-
|
4603
|
+
record,
|
4604
|
+
onAction
|
4648
4605
|
);
|
4649
|
-
};
|
4650
|
-
var removeRelatedZones = (item, data) => {
|
4651
|
-
const newData = __spreadValues({}, data);
|
4652
|
-
const related = findRelatedByItem(item, data);
|
4653
|
-
Object.keys(related).forEach((key) => {
|
4654
|
-
delete newData.zones[key];
|
4655
|
-
});
|
4656
|
-
return newData;
|
4657
|
-
};
|
4658
|
-
function duplicateRelatedZones(item, data, newId) {
|
4659
|
-
return reduceRelatedZones(item, data, (acc, key, zone) => {
|
4660
|
-
const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
|
4661
|
-
props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
|
4662
|
-
}));
|
4663
|
-
const dupeOfDupes = dupedZone.reduce(
|
4664
|
-
(dupeOfDupes2, item2, index) => __spreadValues(__spreadValues({}, dupeOfDupes2), duplicateRelatedZones(zone[index], data, item2.props.id).zones),
|
4665
|
-
acc
|
4666
|
-
);
|
4667
|
-
const [_, zoneId] = getZoneId(key);
|
4668
|
-
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
4669
|
-
[key]: zone,
|
4670
|
-
[`${newId}:${zoneId}`]: dupedZone
|
4671
|
-
});
|
4672
|
-
});
|
4673
4606
|
}
|
4674
4607
|
|
4675
|
-
//
|
4676
|
-
var
|
4677
|
-
|
4678
|
-
|
4679
|
-
|
4680
|
-
|
4681
|
-
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
|
4688
|
-
|
4689
|
-
[action.destinationZone]: replace(
|
4690
|
-
newData.zones[action.destinationZone],
|
4691
|
-
action.destinationIndex,
|
4692
|
-
action.data
|
4693
|
-
)
|
4694
|
-
})
|
4695
|
-
});
|
4696
|
-
};
|
4697
|
-
function insertAction(data, action, config) {
|
4698
|
-
const emptyComponentData = {
|
4699
|
-
type: action.componentType,
|
4700
|
-
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
4701
|
-
id: action.id || generateId(action.componentType)
|
4702
|
-
})
|
4608
|
+
// lib/insert-component.ts
|
4609
|
+
var insertComponent = (componentType, zone, index, {
|
4610
|
+
config,
|
4611
|
+
dispatch,
|
4612
|
+
resolveData,
|
4613
|
+
state
|
4614
|
+
}) => {
|
4615
|
+
const id = generateId(componentType);
|
4616
|
+
const insertActionData = {
|
4617
|
+
type: "insert",
|
4618
|
+
componentType,
|
4619
|
+
destinationIndex: index,
|
4620
|
+
destinationZone: zone,
|
4621
|
+
id
|
4703
4622
|
};
|
4704
|
-
|
4705
|
-
|
4706
|
-
|
4707
|
-
|
4708
|
-
|
4709
|
-
|
4710
|
-
|
4711
|
-
|
4712
|
-
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4717
|
-
|
4718
|
-
|
4719
|
-
|
4720
|
-
)
|
4721
|
-
})
|
4623
|
+
const insertedData = insertAction(state.data, insertActionData, config);
|
4624
|
+
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
4625
|
+
// Dispatch insert rather set, as user's may rely on this via onAction
|
4626
|
+
// We must always record history here so the insert is added to user history
|
4627
|
+
// If the user has defined a resolveData method, they will end up with 2 history
|
4628
|
+
// entries on insert - one for the initial insert, and one when the data resolves
|
4629
|
+
recordHistory: true
|
4630
|
+
}));
|
4631
|
+
const itemSelector = {
|
4632
|
+
index,
|
4633
|
+
zone
|
4634
|
+
};
|
4635
|
+
dispatch({ type: "setUi", ui: { itemSelector } });
|
4636
|
+
resolveData({
|
4637
|
+
data: insertedData,
|
4638
|
+
ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector })
|
4722
4639
|
});
|
4723
|
-
}
|
4724
|
-
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
4729
|
-
|
4730
|
-
|
4731
|
-
|
4640
|
+
};
|
4641
|
+
|
4642
|
+
// components/DragDropContext/index.tsx
|
4643
|
+
var import_use_debounce2 = require("use-debounce");
|
4644
|
+
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
4645
|
+
|
4646
|
+
// lib/dnd/PointerSensor.ts
|
4647
|
+
init_react_import();
|
4648
|
+
var import_state3 = require("@dnd-kit/state");
|
4649
|
+
var import_abstract10 = require("@dnd-kit/abstract");
|
4650
|
+
var import_geometry8 = require("@dnd-kit/geometry");
|
4651
|
+
var import_utilities = require("@dnd-kit/dom/utilities");
|
4652
|
+
var _clearTimeout;
|
4653
|
+
var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
|
4654
|
+
constructor(manager, options) {
|
4655
|
+
super(manager);
|
4656
|
+
this.manager = manager;
|
4657
|
+
this.options = options;
|
4658
|
+
this.listeners = new import_utilities.Listeners();
|
4659
|
+
this.cleanup = /* @__PURE__ */ new Set();
|
4660
|
+
this.source = void 0;
|
4661
|
+
__privateAdd(this, _clearTimeout);
|
4662
|
+
this.handleCancel = this.handleCancel.bind(this);
|
4663
|
+
this.handlePointerUp = this.handlePointerUp.bind(this);
|
4664
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
4665
|
+
(0, import_state3.effect)(() => {
|
4666
|
+
const unbindGlobal = this.bindGlobal(options != null ? options : {});
|
4667
|
+
return () => {
|
4668
|
+
unbindGlobal();
|
4669
|
+
};
|
4732
4670
|
});
|
4733
4671
|
}
|
4734
|
-
|
4735
|
-
|
4736
|
-
|
4737
|
-
|
4738
|
-
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4743
|
-
|
4744
|
-
|
4745
|
-
|
4746
|
-
|
4747
|
-
|
4748
|
-
|
4749
|
-
|
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
|
-
})
|
4672
|
+
bind(source, options = this.options) {
|
4673
|
+
const unbind = (0, import_state3.effect)(() => {
|
4674
|
+
var _a;
|
4675
|
+
const target = (_a = source.handle) != null ? _a : source.element;
|
4676
|
+
const listener = (event) => {
|
4677
|
+
if ((0, import_utilities.isPointerEvent)(event)) {
|
4678
|
+
this.handlePointerDown(event, source, options);
|
4679
|
+
}
|
4680
|
+
};
|
4681
|
+
if (target) {
|
4682
|
+
patchWindow(target.ownerDocument.defaultView);
|
4683
|
+
target.addEventListener("pointerdown", listener);
|
4684
|
+
return () => {
|
4685
|
+
target.removeEventListener("pointerdown", listener);
|
4686
|
+
};
|
4687
|
+
}
|
4758
4688
|
});
|
4759
|
-
|
4760
|
-
|
4761
|
-
|
4762
|
-
|
4763
|
-
)
|
4764
|
-
|
4765
|
-
|
4766
|
-
|
4767
|
-
});
|
4689
|
+
return unbind;
|
4690
|
+
}
|
4691
|
+
bindGlobal(options) {
|
4692
|
+
const documents = /* @__PURE__ */ new Set();
|
4693
|
+
for (const draggable of this.manager.registry.draggables.value) {
|
4694
|
+
if (draggable.element) {
|
4695
|
+
documents.add((0, import_utilities.getDocument)(draggable.element));
|
4696
|
+
}
|
4768
4697
|
}
|
4769
|
-
|
4770
|
-
|
4771
|
-
|
4772
|
-
|
4773
|
-
|
4774
|
-
|
4775
|
-
|
4776
|
-
|
4777
|
-
|
4698
|
+
for (const droppable of this.manager.registry.droppables.value) {
|
4699
|
+
if (droppable.element) {
|
4700
|
+
documents.add((0, import_utilities.getDocument)(droppable.element));
|
4701
|
+
}
|
4702
|
+
}
|
4703
|
+
const unbindFns = Array.from(documents).map(
|
4704
|
+
(doc) => this.listeners.bind(doc, [
|
4705
|
+
{
|
4706
|
+
type: "pointermove",
|
4707
|
+
listener: (event) => this.handlePointerMove(event, doc, options)
|
4708
|
+
},
|
4709
|
+
{
|
4710
|
+
type: "pointerup",
|
4711
|
+
listener: this.handlePointerUp,
|
4712
|
+
options: {
|
4713
|
+
capture: true
|
4714
|
+
}
|
4715
|
+
},
|
4716
|
+
{
|
4717
|
+
// Cancel activation if there is a competing Drag and Drop interaction
|
4718
|
+
type: "dragstart",
|
4719
|
+
listener: this.handleDragStart
|
4720
|
+
}
|
4721
|
+
])
|
4722
|
+
);
|
4723
|
+
return () => {
|
4724
|
+
unbindFns.forEach((unbind) => unbind());
|
4725
|
+
};
|
4778
4726
|
}
|
4779
|
-
|
4780
|
-
|
4727
|
+
handlePointerDown(event, source, options = {}) {
|
4728
|
+
if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
|
4729
|
+
return;
|
4730
|
+
}
|
4731
|
+
const offset = (0, import_utilities.getFrameTransform)(source.element);
|
4732
|
+
this.initialCoordinates = {
|
4733
|
+
x: event.clientX * offset.scaleX + offset.x,
|
4734
|
+
y: event.clientY * offset.scaleY + offset.y
|
4735
|
+
};
|
4736
|
+
this.source = source;
|
4737
|
+
const { activationConstraints } = options;
|
4738
|
+
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
|
4739
|
+
event.stopImmediatePropagation();
|
4740
|
+
if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
|
4741
|
+
this.handleStart(source, event);
|
4742
|
+
} else {
|
4743
|
+
const { delay } = constraints;
|
4744
|
+
if (delay) {
|
4745
|
+
const timeout3 = setTimeout(
|
4746
|
+
() => this.handleStart(source, event),
|
4747
|
+
delay.value
|
4748
|
+
);
|
4749
|
+
__privateSet(this, _clearTimeout, () => {
|
4750
|
+
clearTimeout(timeout3);
|
4751
|
+
__privateSet(this, _clearTimeout, void 0);
|
4752
|
+
});
|
4753
|
+
}
|
4754
|
+
}
|
4755
|
+
const cleanup = () => {
|
4756
|
+
var _a;
|
4757
|
+
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
4758
|
+
this.initialCoordinates = void 0;
|
4759
|
+
this.source = void 0;
|
4760
|
+
};
|
4761
|
+
this.cleanup.add(cleanup);
|
4781
4762
|
}
|
4782
|
-
|
4783
|
-
if (
|
4784
|
-
return
|
4763
|
+
handlePointerMove(event, doc, options) {
|
4764
|
+
if (!this.source) {
|
4765
|
+
return;
|
4785
4766
|
}
|
4786
|
-
const
|
4787
|
-
|
4788
|
-
|
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" }));
|
4767
|
+
const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
|
4768
|
+
if (doc !== ownerDocument) {
|
4769
|
+
return;
|
4796
4770
|
}
|
4797
|
-
|
4798
|
-
|
4799
|
-
|
4800
|
-
|
4801
|
-
|
4802
|
-
|
4803
|
-
|
4804
|
-
|
4805
|
-
|
4806
|
-
|
4807
|
-
});
|
4771
|
+
const coordinates = {
|
4772
|
+
x: event.clientX,
|
4773
|
+
y: event.clientY
|
4774
|
+
};
|
4775
|
+
const offset = (0, import_utilities.getFrameTransform)(this.source.element);
|
4776
|
+
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
4777
|
+
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
4778
|
+
if (this.manager.dragOperation.status.dragging) {
|
4779
|
+
event.preventDefault();
|
4780
|
+
event.stopPropagation();
|
4781
|
+
this.manager.actions.move({ to: coordinates });
|
4782
|
+
return;
|
4808
4783
|
}
|
4809
|
-
if (
|
4810
|
-
return
|
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
|
-
});
|
4784
|
+
if (!this.initialCoordinates) {
|
4785
|
+
return;
|
4819
4786
|
}
|
4820
|
-
|
4821
|
-
|
4822
|
-
|
4823
|
-
|
4824
|
-
|
4825
|
-
|
4826
|
-
|
4827
|
-
|
4828
|
-
|
4829
|
-
|
4830
|
-
|
4831
|
-
|
4832
|
-
|
4833
|
-
|
4834
|
-
|
4835
|
-
|
4836
|
-
|
4837
|
-
|
4838
|
-
|
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
|
-
});
|
4787
|
+
const delta = {
|
4788
|
+
x: coordinates.x - this.initialCoordinates.x,
|
4789
|
+
y: coordinates.y - this.initialCoordinates.y
|
4790
|
+
};
|
4791
|
+
const { activationConstraints } = options;
|
4792
|
+
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
|
4793
|
+
const { distance, delay } = constraints != null ? constraints : {};
|
4794
|
+
if (distance) {
|
4795
|
+
if (distance.tolerance != null && (0, import_geometry8.exceedsDistance)(delta, distance.tolerance)) {
|
4796
|
+
return this.handleCancel();
|
4797
|
+
}
|
4798
|
+
if ((0, import_geometry8.exceedsDistance)(delta, distance.value)) {
|
4799
|
+
return this.handleStart(this.source, event);
|
4800
|
+
}
|
4801
|
+
}
|
4802
|
+
if (delay) {
|
4803
|
+
if ((0, import_geometry8.exceedsDistance)(delta, delay.tolerance)) {
|
4804
|
+
return this.handleCancel();
|
4805
|
+
}
|
4847
4806
|
}
|
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
4807
|
}
|
4857
|
-
|
4858
|
-
if (
|
4859
|
-
return
|
4860
|
-
|
4861
|
-
|
4862
|
-
|
4863
|
-
|
4808
|
+
handlePointerUp(event) {
|
4809
|
+
if (!this.source) {
|
4810
|
+
return;
|
4811
|
+
}
|
4812
|
+
event.preventDefault();
|
4813
|
+
event.stopPropagation();
|
4814
|
+
const { status } = this.manager.dragOperation;
|
4815
|
+
if (!status.idle) {
|
4816
|
+
const canceled = !status.initialized;
|
4817
|
+
this.manager.actions.stop({ canceled });
|
4864
4818
|
}
|
4865
|
-
|
4819
|
+
this.cleanup.forEach((cleanup) => cleanup());
|
4820
|
+
this.cleanup.clear();
|
4866
4821
|
}
|
4867
|
-
|
4868
|
-
|
4869
|
-
|
4870
|
-
|
4871
|
-
delete _zones[action.zone];
|
4822
|
+
handleKeyDown(event) {
|
4823
|
+
if (event.key === "Escape") {
|
4824
|
+
event.preventDefault();
|
4825
|
+
this.handleCancel();
|
4872
4826
|
}
|
4873
|
-
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
4874
4827
|
}
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4828
|
+
handleStart(source, event) {
|
4829
|
+
var _a;
|
4830
|
+
const { manager, initialCoordinates } = this;
|
4831
|
+
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
4832
|
+
if (!initialCoordinates || manager.dragOperation.status.initialized) {
|
4833
|
+
return;
|
4878
4834
|
}
|
4879
|
-
|
4880
|
-
|
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);
|
4835
|
+
if (event.defaultPrevented) {
|
4836
|
+
return;
|
4890
4837
|
}
|
4891
|
-
|
4892
|
-
|
4893
|
-
|
4894
|
-
|
4895
|
-
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4838
|
+
event.preventDefault();
|
4839
|
+
(0, import_state3.batch)(() => {
|
4840
|
+
manager.actions.setDragSource(source.id);
|
4841
|
+
manager.actions.start({ coordinates: initialCoordinates, event });
|
4896
4842
|
});
|
4843
|
+
const ownerDocument = (0, import_utilities.getDocument)(event.target);
|
4844
|
+
const unbind = this.listeners.bind(ownerDocument, [
|
4845
|
+
{
|
4846
|
+
// Prevent scrolling on touch devices
|
4847
|
+
type: "touchmove",
|
4848
|
+
listener: preventDefault,
|
4849
|
+
options: {
|
4850
|
+
passive: false
|
4851
|
+
}
|
4852
|
+
},
|
4853
|
+
{
|
4854
|
+
// Prevent click events
|
4855
|
+
type: "click",
|
4856
|
+
listener: preventDefault
|
4857
|
+
},
|
4858
|
+
{
|
4859
|
+
type: "keydown",
|
4860
|
+
listener: this.handleKeyDown
|
4861
|
+
}
|
4862
|
+
]);
|
4863
|
+
ownerDocument.body.setPointerCapture(event.pointerId);
|
4864
|
+
this.cleanup.add(unbind);
|
4897
4865
|
}
|
4898
|
-
|
4899
|
-
|
4900
|
-
|
4901
|
-
|
4866
|
+
handleDragStart(event) {
|
4867
|
+
const { target } = event;
|
4868
|
+
if (!(0, import_utilities.isElement)(target)) {
|
4869
|
+
return;
|
4870
|
+
}
|
4871
|
+
const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
|
4872
|
+
if (isNativeDraggable) {
|
4873
|
+
this.handleCancel();
|
4874
|
+
} else {
|
4875
|
+
preventDefault(event);
|
4876
|
+
}
|
4902
4877
|
}
|
4903
|
-
|
4904
|
-
};
|
4905
|
-
|
4906
|
-
|
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);
|
4878
|
+
handleCancel() {
|
4879
|
+
const { dragOperation } = this.manager;
|
4880
|
+
if (dragOperation.status.initialized) {
|
4881
|
+
this.manager.actions.stop({ canceled: true });
|
4922
4882
|
}
|
4923
|
-
|
4924
|
-
|
4925
|
-
}
|
4926
|
-
|
4927
|
-
|
4928
|
-
if (typeof action.state === "object") {
|
4929
|
-
return __spreadValues(__spreadValues({}, state), action.state);
|
4883
|
+
this.cleanup.forEach((cleanup) => cleanup());
|
4884
|
+
this.cleanup.clear();
|
4885
|
+
}
|
4886
|
+
destroy() {
|
4887
|
+
this.listeners.clear();
|
4930
4888
|
}
|
4931
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
4932
4889
|
};
|
4933
|
-
|
4934
|
-
|
4935
|
-
|
4936
|
-
|
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
|
-
);
|
4890
|
+
_clearTimeout = new WeakMap();
|
4891
|
+
_PointerSensor.configure = (0, import_abstract10.configurator)(_PointerSensor);
|
4892
|
+
var PointerSensor = _PointerSensor;
|
4893
|
+
function preventDefault(event) {
|
4894
|
+
event.preventDefault();
|
4950
4895
|
}
|
4951
|
-
|
4952
|
-
|
4953
|
-
var
|
4954
|
-
|
4955
|
-
|
4956
|
-
|
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);
|
4896
|
+
function noop() {
|
4897
|
+
}
|
4898
|
+
var windows = /* @__PURE__ */ new WeakSet();
|
4899
|
+
function patchWindow(window2) {
|
4900
|
+
if (!window2 || windows.has(window2)) {
|
4901
|
+
return;
|
4997
4902
|
}
|
4998
|
-
|
4903
|
+
window2.addEventListener("touchmove", noop, {
|
4904
|
+
capture: false,
|
4905
|
+
passive: false
|
4906
|
+
});
|
4907
|
+
windows.add(window2);
|
4999
4908
|
}
|
5000
4909
|
|
5001
4910
|
// components/DragDropContext/index.tsx
|
4911
|
+
var import_zustand3 = require("zustand");
|
5002
4912
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
5003
4913
|
var DEBUG3 = false;
|
5004
|
-
var dragListenerContext = (0,
|
4914
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
5005
4915
|
dragListeners: {}
|
5006
4916
|
});
|
5007
4917
|
function useDragListener(type, fn, deps = []) {
|
5008
|
-
const { setDragListeners } = (0,
|
5009
|
-
(0,
|
4918
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
4919
|
+
(0, import_react31.useEffect)(() => {
|
5010
4920
|
if (setDragListeners) {
|
5011
4921
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5012
4922
|
[type]: [...old[type] || [], fn]
|
@@ -5016,8 +4926,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5016
4926
|
}
|
5017
4927
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5018
4928
|
var useTempDisableFallback = (timeout3) => {
|
5019
|
-
const lastFallbackDisable = (0,
|
5020
|
-
return (0,
|
4929
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
4930
|
+
return (0, import_react31.useCallback)((manager) => {
|
5021
4931
|
collisionStore.setState({ fallbackEnabled: false });
|
5022
4932
|
const fallbackId = generateId();
|
5023
4933
|
lastFallbackDisable.current = fallbackId;
|
@@ -5034,11 +4944,11 @@ var DragDropContextClient = ({
|
|
5034
4944
|
disableAutoScroll
|
5035
4945
|
}) => {
|
5036
4946
|
const { state, config, dispatch, resolveData } = useAppContext();
|
5037
|
-
const id = (0,
|
4947
|
+
const id = (0, import_react31.useId)();
|
5038
4948
|
const { data } = state;
|
5039
|
-
const debouncedParamsRef = (0,
|
4949
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
5040
4950
|
const tempDisableFallback = useTempDisableFallback(100);
|
5041
|
-
const [zoneStore] = (0,
|
4951
|
+
const [zoneStore] = (0, import_react31.useState)(
|
5042
4952
|
() => (0, import_zustand3.createStore)(() => ({
|
5043
4953
|
zoneDepthIndex: {},
|
5044
4954
|
nextZoneDepthIndex: {},
|
@@ -5048,7 +4958,7 @@ var DragDropContextClient = ({
|
|
5048
4958
|
previewIndex: {}
|
5049
4959
|
}))
|
5050
4960
|
);
|
5051
|
-
const getChanged2 = (0,
|
4961
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
5052
4962
|
(params, id2) => {
|
5053
4963
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
5054
4964
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -5069,7 +4979,7 @@ var DragDropContextClient = ({
|
|
5069
4979
|
},
|
5070
4980
|
[zoneStore]
|
5071
4981
|
);
|
5072
|
-
const setDeepestAndCollide = (0,
|
4982
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
5073
4983
|
(params, manager) => {
|
5074
4984
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5075
4985
|
if (!zoneChanged && !areaChanged) return;
|
@@ -5093,7 +5003,7 @@ var DragDropContextClient = ({
|
|
5093
5003
|
setDeepestDb.cancel();
|
5094
5004
|
debouncedParamsRef.current = null;
|
5095
5005
|
};
|
5096
|
-
(0,
|
5006
|
+
(0, import_react31.useEffect)(() => {
|
5097
5007
|
if (DEBUG3) {
|
5098
5008
|
zoneStore.subscribe(
|
5099
5009
|
(s) => {
|
@@ -5107,7 +5017,7 @@ var DragDropContextClient = ({
|
|
5107
5017
|
);
|
5108
5018
|
}
|
5109
5019
|
}, []);
|
5110
|
-
const [plugins] = (0,
|
5020
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
5111
5021
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5112
5022
|
createNestedDroppablePlugin(
|
5113
5023
|
{
|
@@ -5154,11 +5064,29 @@ var DragDropContextClient = ({
|
|
5154
5064
|
id
|
5155
5065
|
)
|
5156
5066
|
]);
|
5157
|
-
const sensors =
|
5158
|
-
|
5159
|
-
|
5160
|
-
|
5161
|
-
|
5067
|
+
const [sensors] = (0, import_react31.useState)(() => [
|
5068
|
+
PointerSensor.configure({
|
5069
|
+
activationConstraints(event, source) {
|
5070
|
+
var _a;
|
5071
|
+
const { pointerType, target } = event;
|
5072
|
+
if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
5073
|
+
return void 0;
|
5074
|
+
}
|
5075
|
+
const delay = { value: 200, tolerance: 10 };
|
5076
|
+
if (pointerType === "touch") {
|
5077
|
+
return { delay };
|
5078
|
+
}
|
5079
|
+
return {
|
5080
|
+
delay,
|
5081
|
+
distance: { value: 5 }
|
5082
|
+
};
|
5083
|
+
}
|
5084
|
+
})
|
5085
|
+
]);
|
5086
|
+
const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
|
5087
|
+
const [pathData, setPathData] = (0, import_react31.useState)();
|
5088
|
+
const dragMode = (0, import_react31.useRef)(null);
|
5089
|
+
const registerPath = (0, import_react31.useCallback)(
|
5162
5090
|
(id2, selector, label) => {
|
5163
5091
|
const [area] = getZoneId(selector.zone);
|
5164
5092
|
setPathData((latestPathData = {}) => {
|
@@ -5176,7 +5104,7 @@ var DragDropContextClient = ({
|
|
5176
5104
|
},
|
5177
5105
|
[data, setPathData]
|
5178
5106
|
);
|
5179
|
-
const unregisterPath = (0,
|
5107
|
+
const unregisterPath = (0, import_react31.useCallback)(
|
5180
5108
|
(id2) => {
|
5181
5109
|
setPathData((latestPathData = {}) => {
|
5182
5110
|
const newPathData = __spreadValues({}, latestPathData);
|
@@ -5186,7 +5114,7 @@ var DragDropContextClient = ({
|
|
5186
5114
|
},
|
5187
5115
|
[data, setPathData]
|
5188
5116
|
);
|
5189
|
-
const initialSelector = (0,
|
5117
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5190
5118
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5191
5119
|
dragListenerContext.Provider,
|
5192
5120
|
{
|
@@ -5195,7 +5123,7 @@ var DragDropContextClient = ({
|
|
5195
5123
|
setDragListeners
|
5196
5124
|
},
|
5197
5125
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5198
|
-
|
5126
|
+
import_react30.DragDropProvider,
|
5199
5127
|
{
|
5200
5128
|
plugins,
|
5201
5129
|
sensors,
|
@@ -5274,8 +5202,7 @@ var DragDropContextClient = ({
|
|
5274
5202
|
targetZone = targetData.zone;
|
5275
5203
|
targetIndex = targetData.index;
|
5276
5204
|
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
5277
|
-
const
|
5278
|
-
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";
|
5205
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
5279
5206
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
5280
5207
|
targetIndex = targetIndex - 1;
|
5281
5208
|
}
|
@@ -5417,7 +5344,7 @@ var DrawerItemInner = ({
|
|
5417
5344
|
dragRef,
|
5418
5345
|
isDragDisabled
|
5419
5346
|
}) => {
|
5420
|
-
const CustomInner = (0,
|
5347
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5421
5348
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5422
5349
|
[children]
|
5423
5350
|
);
|
@@ -5471,7 +5398,7 @@ var DrawerItem = ({
|
|
5471
5398
|
isDragDisabled
|
5472
5399
|
}) => {
|
5473
5400
|
const resolvedId = id || name;
|
5474
|
-
const [dynamicId, setDynamicId] = (0,
|
5401
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5475
5402
|
if (typeof index !== "undefined") {
|
5476
5403
|
console.error(
|
5477
5404
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5510,7 +5437,7 @@ var Drawer = ({
|
|
5510
5437
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5511
5438
|
);
|
5512
5439
|
}
|
5513
|
-
const id = (0,
|
5440
|
+
const id = (0, import_react32.useId)();
|
5514
5441
|
const { ref } = useDroppableSafe({
|
5515
5442
|
id,
|
5516
5443
|
type: "void",
|
@@ -5532,18 +5459,18 @@ Drawer.Item = DrawerItem;
|
|
5532
5459
|
|
5533
5460
|
// components/Puck/index.tsx
|
5534
5461
|
init_react_import();
|
5535
|
-
var
|
5462
|
+
var import_react50 = require("react");
|
5536
5463
|
|
5537
5464
|
// components/SidebarSection/index.tsx
|
5538
5465
|
init_react_import();
|
5539
5466
|
|
5540
5467
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
5541
5468
|
init_react_import();
|
5542
|
-
var styles_module_default13 = { "SidebarSection": "
|
5469
|
+
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" };
|
5543
5470
|
|
5544
5471
|
// lib/use-breadcrumbs.ts
|
5545
5472
|
init_react_import();
|
5546
|
-
var
|
5473
|
+
var import_react33 = require("react");
|
5547
5474
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5548
5475
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5549
5476
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5593,8 +5520,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5593
5520
|
state: { data },
|
5594
5521
|
selectedItem
|
5595
5522
|
} = useAppContext();
|
5596
|
-
const dzContext = (0,
|
5597
|
-
return (0,
|
5523
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5524
|
+
return (0, import_react33.useMemo)(() => {
|
5598
5525
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5599
5526
|
selectedItem,
|
5600
5527
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5718,7 +5645,7 @@ function MenuBar({
|
|
5718
5645
|
|
5719
5646
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5720
5647
|
init_react_import();
|
5721
|
-
var styles_module_default15 = { "Puck": "
|
5648
|
+
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" };
|
5722
5649
|
|
5723
5650
|
// components/Puck/components/Fields/index.tsx
|
5724
5651
|
init_react_import();
|
@@ -5728,15 +5655,15 @@ init_react_import();
|
|
5728
5655
|
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" };
|
5729
5656
|
|
5730
5657
|
// components/Puck/components/Fields/index.tsx
|
5731
|
-
var
|
5658
|
+
var import_react37 = require("react");
|
5732
5659
|
|
5733
5660
|
// lib/use-resolved-fields.ts
|
5734
5661
|
init_react_import();
|
5735
|
-
var
|
5662
|
+
var import_react36 = require("react");
|
5736
5663
|
|
5737
5664
|
// lib/use-parent.ts
|
5738
5665
|
init_react_import();
|
5739
|
-
var
|
5666
|
+
var import_react34 = require("react");
|
5740
5667
|
var getParent = (itemSelector, pathData, data) => {
|
5741
5668
|
var _a;
|
5742
5669
|
if (!itemSelector) return null;
|
@@ -5748,8 +5675,8 @@ var getParent = (itemSelector, pathData, data) => {
|
|
5748
5675
|
};
|
5749
5676
|
var useGetParent = () => {
|
5750
5677
|
const { state } = useAppContext();
|
5751
|
-
const { pathData } = (0,
|
5752
|
-
return (0,
|
5678
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5679
|
+
return (0, import_react34.useCallback)(
|
5753
5680
|
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5754
5681
|
[state.ui.itemSelector, pathData, state.data]
|
5755
5682
|
);
|
@@ -5760,10 +5687,10 @@ var useParent = () => {
|
|
5760
5687
|
|
5761
5688
|
// lib/use-on-value-change.ts
|
5762
5689
|
init_react_import();
|
5763
|
-
var
|
5690
|
+
var import_react35 = require("react");
|
5764
5691
|
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5765
|
-
const tracked = (0,
|
5766
|
-
(0,
|
5692
|
+
const tracked = (0, import_react35.useRef)(value);
|
5693
|
+
(0, import_react35.useEffect)(() => {
|
5767
5694
|
const oldValue = tracked.current;
|
5768
5695
|
if (!compare(value, oldValue)) {
|
5769
5696
|
tracked.current = value;
|
@@ -5790,27 +5717,27 @@ var useResolvedFields = ({
|
|
5790
5717
|
const { data } = state;
|
5791
5718
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5792
5719
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5793
|
-
const defaultFields = (0,
|
5720
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5794
5721
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5795
5722
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5796
5723
|
);
|
5797
5724
|
const rootProps = data.root.props || data.root;
|
5798
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5799
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5725
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5726
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)({
|
5800
5727
|
fields: defaultFields,
|
5801
5728
|
id: selectedItem == null ? void 0 : selectedItem.props.id
|
5802
5729
|
});
|
5803
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5804
|
-
const lastFields = (0,
|
5730
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5731
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5805
5732
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5806
|
-
const componentData = (0,
|
5733
|
+
const componentData = (0, import_react36.useMemo)(
|
5807
5734
|
() => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
|
5808
5735
|
[selectedItem, rootProps, data.root.readOnly]
|
5809
5736
|
);
|
5810
5737
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5811
5738
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5812
5739
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5813
|
-
const resolveFields = (0,
|
5740
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5814
5741
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5815
5742
|
var _a2;
|
5816
5743
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5848,7 +5775,7 @@ var useResolvedFields = ({
|
|
5848
5775
|
}),
|
5849
5776
|
[data, config, componentData, selectedItem, state, parent]
|
5850
5777
|
);
|
5851
|
-
const triggerResolver = (0,
|
5778
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5852
5779
|
var _a2, _b2;
|
5853
5780
|
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5854
5781
|
if (hasResolver) {
|
@@ -5888,7 +5815,7 @@ var useResolvedFields = ({
|
|
5888
5815
|
},
|
5889
5816
|
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5890
5817
|
);
|
5891
|
-
(0,
|
5818
|
+
(0, import_react36.useEffect)(() => {
|
5892
5819
|
triggerResolver();
|
5893
5820
|
}, []);
|
5894
5821
|
if (resolvedFields.id !== (selectedItem == null ? void 0 : selectedItem.props.id) && !_skipIdCheck) {
|
@@ -5923,7 +5850,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
5923
5850
|
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;
|
5924
5851
|
const isLoading = fieldsResolving || componentResolving;
|
5925
5852
|
const rootProps = data.root.props || data.root;
|
5926
|
-
const Wrapper = (0,
|
5853
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5927
5854
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5928
5855
|
"form",
|
5929
5856
|
{
|
@@ -6044,14 +5971,14 @@ init_react_import();
|
|
6044
5971
|
|
6045
5972
|
// lib/use-component-list.tsx
|
6046
5973
|
init_react_import();
|
6047
|
-
var
|
5974
|
+
var import_react38 = require("react");
|
6048
5975
|
|
6049
5976
|
// components/ComponentList/index.tsx
|
6050
5977
|
init_react_import();
|
6051
5978
|
|
6052
5979
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
6053
5980
|
init_react_import();
|
6054
|
-
var styles_module_default17 = { "ComponentList": "
|
5981
|
+
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" };
|
6055
5982
|
|
6056
5983
|
// components/ComponentList/index.tsx
|
6057
5984
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
@@ -6111,8 +6038,8 @@ ComponentList.Item = ComponentListItem;
|
|
6111
6038
|
// lib/use-component-list.tsx
|
6112
6039
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6113
6040
|
var useComponentList = (config, ui) => {
|
6114
|
-
const [componentList, setComponentList] = (0,
|
6115
|
-
(0,
|
6041
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
6042
|
+
(0, import_react38.useEffect)(() => {
|
6116
6043
|
var _a, _b, _c;
|
6117
6044
|
if (Object.keys(ui.componentList).length > 0) {
|
6118
6045
|
const matchedComponents = [];
|
@@ -6181,22 +6108,22 @@ var useComponentList = (config, ui) => {
|
|
6181
6108
|
};
|
6182
6109
|
|
6183
6110
|
// components/Puck/components/Components/index.tsx
|
6184
|
-
var
|
6111
|
+
var import_react39 = require("react");
|
6185
6112
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6186
6113
|
var Components = () => {
|
6187
6114
|
const { config, state, overrides } = useAppContext();
|
6188
6115
|
const componentList = useComponentList(config, state.ui);
|
6189
|
-
const Wrapper = (0,
|
6116
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6190
6117
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6191
6118
|
};
|
6192
6119
|
|
6193
6120
|
// components/Puck/components/Preview/index.tsx
|
6194
6121
|
init_react_import();
|
6195
|
-
var
|
6122
|
+
var import_react41 = require("react");
|
6196
6123
|
|
6197
6124
|
// components/AutoFrame/index.tsx
|
6198
6125
|
init_react_import();
|
6199
|
-
var
|
6126
|
+
var import_react40 = require("react");
|
6200
6127
|
var import_object_hash = __toESM(require("object-hash"));
|
6201
6128
|
var import_react_dom3 = require("react-dom");
|
6202
6129
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6242,7 +6169,7 @@ var CopyHostStyles = ({
|
|
6242
6169
|
onStylesLoaded = () => null
|
6243
6170
|
}) => {
|
6244
6171
|
const { document: doc, window: win } = useFrame();
|
6245
|
-
(0,
|
6172
|
+
(0, import_react40.useEffect)(() => {
|
6246
6173
|
if (!win || !doc) {
|
6247
6174
|
return () => {
|
6248
6175
|
};
|
@@ -6401,8 +6328,8 @@ var CopyHostStyles = ({
|
|
6401
6328
|
}, []);
|
6402
6329
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6403
6330
|
};
|
6404
|
-
var autoFrameContext = (0,
|
6405
|
-
var useFrame = () => (0,
|
6331
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6332
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6406
6333
|
function AutoFrame(_a) {
|
6407
6334
|
var _b = _a, {
|
6408
6335
|
children,
|
@@ -6419,10 +6346,10 @@ function AutoFrame(_a) {
|
|
6419
6346
|
"onStylesLoaded",
|
6420
6347
|
"frameRef"
|
6421
6348
|
]);
|
6422
|
-
const [loaded, setLoaded] = (0,
|
6423
|
-
const [ctx, setCtx] = (0,
|
6424
|
-
const [mountTarget, setMountTarget] = (0,
|
6425
|
-
(0,
|
6349
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6350
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6351
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6352
|
+
(0, import_react40.useEffect)(() => {
|
6426
6353
|
var _a2;
|
6427
6354
|
if (frameRef.current) {
|
6428
6355
|
setCtx({
|
@@ -6517,7 +6444,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6517
6444
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6518
6445
|
var useBubbleIframeEvents = (ref) => {
|
6519
6446
|
const { status } = useAppContext();
|
6520
|
-
(0,
|
6447
|
+
(0, import_react41.useEffect)(() => {
|
6521
6448
|
var _a;
|
6522
6449
|
if (ref.current && status === "READY") {
|
6523
6450
|
const iframe = ref.current;
|
@@ -6550,7 +6477,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6550
6477
|
};
|
6551
6478
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6552
6479
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6553
|
-
const Page = (0,
|
6480
|
+
const Page = (0, import_react41.useCallback)(
|
6554
6481
|
(pageProps) => {
|
6555
6482
|
var _a, _b;
|
6556
6483
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6559,9 +6486,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6559
6486
|
},
|
6560
6487
|
[config.root]
|
6561
6488
|
);
|
6562
|
-
const Frame = (0,
|
6489
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6563
6490
|
const rootProps = state.data.root.props || state.data.root;
|
6564
|
-
const ref = (0,
|
6491
|
+
const ref = (0, import_react41.useRef)(null);
|
6565
6492
|
useBubbleIframeEvents(ref);
|
6566
6493
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6567
6494
|
Page,
|
@@ -6644,7 +6571,7 @@ init_react_import();
|
|
6644
6571
|
|
6645
6572
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
6646
6573
|
init_react_import();
|
6647
|
-
var styles_module_default19 = { "LayerTree": "
|
6574
|
+
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" };
|
6648
6575
|
|
6649
6576
|
// lib/scroll-into-view.ts
|
6650
6577
|
init_react_import();
|
@@ -6658,7 +6585,7 @@ var scrollIntoView = (el) => {
|
|
6658
6585
|
};
|
6659
6586
|
|
6660
6587
|
// components/LayerTree/index.tsx
|
6661
|
-
var
|
6588
|
+
var import_react42 = require("react");
|
6662
6589
|
|
6663
6590
|
// lib/is-child-of-zone.ts
|
6664
6591
|
init_react_import();
|
@@ -6704,7 +6631,7 @@ var LayerTree = ({
|
|
6704
6631
|
label
|
6705
6632
|
}) => {
|
6706
6633
|
const zones = data.zones || {};
|
6707
|
-
const ctx = (0,
|
6634
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6708
6635
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6709
6636
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6710
6637
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6811,13 +6738,13 @@ var LayerTree = ({
|
|
6811
6738
|
};
|
6812
6739
|
|
6813
6740
|
// components/Puck/components/Outline/index.tsx
|
6814
|
-
var
|
6741
|
+
var import_react43 = require("react");
|
6815
6742
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6816
6743
|
var Outline = () => {
|
6817
6744
|
const { dispatch, state, overrides, config } = useAppContext();
|
6818
6745
|
const { data, ui } = state;
|
6819
6746
|
const { itemSelector } = ui;
|
6820
|
-
const setItemSelector = (0,
|
6747
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6821
6748
|
(newItemSelector) => {
|
6822
6749
|
dispatch({
|
6823
6750
|
type: "setUi",
|
@@ -6826,7 +6753,7 @@ var Outline = () => {
|
|
6826
6753
|
},
|
6827
6754
|
[]
|
6828
6755
|
);
|
6829
|
-
const Wrapper = (0,
|
6756
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6830
6757
|
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: [
|
6831
6758
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6832
6759
|
LayerTree,
|
@@ -6940,19 +6867,19 @@ function usePuckHistory({
|
|
6940
6867
|
|
6941
6868
|
// lib/use-history-store.ts
|
6942
6869
|
init_react_import();
|
6943
|
-
var
|
6870
|
+
var import_react44 = require("react");
|
6944
6871
|
var import_use_debounce3 = require("use-debounce");
|
6945
6872
|
var EMPTY_HISTORY_INDEX = 0;
|
6946
6873
|
function useHistoryStore(initialHistory) {
|
6947
6874
|
var _a, _b;
|
6948
|
-
const [histories, setHistories] = (0,
|
6875
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6949
6876
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6950
6877
|
);
|
6951
6878
|
const updateHistories = (histories2) => {
|
6952
6879
|
setHistories(histories2);
|
6953
6880
|
setIndex(histories2.length - 1);
|
6954
6881
|
};
|
6955
|
-
const [index, setIndex] = (0,
|
6882
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6956
6883
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6957
6884
|
);
|
6958
6885
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -7112,15 +7039,15 @@ var getBox = function getBox2(el) {
|
|
7112
7039
|
};
|
7113
7040
|
|
7114
7041
|
// components/Puck/components/Canvas/index.tsx
|
7115
|
-
var
|
7042
|
+
var import_react46 = require("react");
|
7116
7043
|
|
7117
7044
|
// components/ViewportControls/index.tsx
|
7118
7045
|
init_react_import();
|
7119
|
-
var
|
7046
|
+
var import_react45 = require("react");
|
7120
7047
|
|
7121
7048
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7122
7049
|
init_react_import();
|
7123
|
-
var styles_module_default20 = { "ViewportControls": "
|
7050
|
+
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" };
|
7124
7051
|
|
7125
7052
|
// components/ViewportControls/index.tsx
|
7126
7053
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
@@ -7139,8 +7066,8 @@ var ViewportButton = ({
|
|
7139
7066
|
onClick
|
7140
7067
|
}) => {
|
7141
7068
|
const { state } = useAppContext();
|
7142
|
-
const [isActive, setIsActive] = (0,
|
7143
|
-
(0,
|
7069
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7070
|
+
(0, import_react45.useEffect)(() => {
|
7144
7071
|
setIsActive(width === state.ui.viewports.current.width);
|
7145
7072
|
}, [width, state.ui.viewports.current.width]);
|
7146
7073
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -7176,7 +7103,7 @@ var ViewportControls = ({
|
|
7176
7103
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7177
7104
|
(option) => option.value === autoZoom
|
7178
7105
|
);
|
7179
|
-
const zoomOptions = (0,
|
7106
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
7180
7107
|
() => [
|
7181
7108
|
...defaultZoomOptions,
|
7182
7109
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7299,17 +7226,17 @@ var Canvas = () => {
|
|
7299
7226
|
const { status, iframe } = useAppContext();
|
7300
7227
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7301
7228
|
const { ui } = state;
|
7302
|
-
const frameRef = (0,
|
7303
|
-
const [showTransition, setShowTransition] = (0,
|
7304
|
-
const defaultRender = (0,
|
7229
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7230
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7231
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7305
7232
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7306
7233
|
return PuckDefault;
|
7307
7234
|
}, []);
|
7308
|
-
const CustomPreview = (0,
|
7235
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7309
7236
|
() => overrides.preview || defaultRender,
|
7310
7237
|
[overrides]
|
7311
7238
|
);
|
7312
|
-
const getFrameDimensions = (0,
|
7239
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7313
7240
|
if (frameRef.current) {
|
7314
7241
|
const frame = frameRef.current;
|
7315
7242
|
const box = getBox(frame);
|
@@ -7317,7 +7244,7 @@ var Canvas = () => {
|
|
7317
7244
|
}
|
7318
7245
|
return { width: 0, height: 0 };
|
7319
7246
|
}, [frameRef]);
|
7320
|
-
const resetAutoZoom = (0,
|
7247
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7321
7248
|
(ui2 = state.ui) => {
|
7322
7249
|
if (frameRef.current) {
|
7323
7250
|
setZoomConfig(
|
@@ -7327,11 +7254,11 @@ var Canvas = () => {
|
|
7327
7254
|
},
|
7328
7255
|
[frameRef, zoomConfig, state.ui]
|
7329
7256
|
);
|
7330
|
-
(0,
|
7257
|
+
(0, import_react46.useEffect)(() => {
|
7331
7258
|
setShowTransition(false);
|
7332
7259
|
resetAutoZoom();
|
7333
7260
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7334
|
-
(0,
|
7261
|
+
(0, import_react46.useEffect)(() => {
|
7335
7262
|
const { height: frameHeight } = getFrameDimensions();
|
7336
7263
|
if (ui.viewports.current.height === "auto") {
|
7337
7264
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7339,13 +7266,13 @@ var Canvas = () => {
|
|
7339
7266
|
}));
|
7340
7267
|
}
|
7341
7268
|
}, [zoomConfig.zoom]);
|
7342
|
-
(0,
|
7269
|
+
(0, import_react46.useEffect)(() => {
|
7343
7270
|
if (ZOOM_ON_CHANGE) {
|
7344
7271
|
setShowTransition(true);
|
7345
7272
|
resetAutoZoom(ui);
|
7346
7273
|
}
|
7347
7274
|
}, [ui.viewports.current.width]);
|
7348
|
-
(0,
|
7275
|
+
(0, import_react46.useEffect)(() => {
|
7349
7276
|
const cb = () => {
|
7350
7277
|
setShowTransition(false);
|
7351
7278
|
resetAutoZoom();
|
@@ -7355,8 +7282,8 @@ var Canvas = () => {
|
|
7355
7282
|
window.removeEventListener("resize", cb);
|
7356
7283
|
};
|
7357
7284
|
}, []);
|
7358
|
-
const [showLoader, setShowLoader] = (0,
|
7359
|
-
(0,
|
7285
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7286
|
+
(0, import_react46.useEffect)(() => {
|
7360
7287
|
setTimeout(() => {
|
7361
7288
|
setShowLoader(true);
|
7362
7289
|
}, 500);
|
@@ -7434,7 +7361,7 @@ var Canvas = () => {
|
|
7434
7361
|
|
7435
7362
|
// lib/use-loaded-overrides.ts
|
7436
7363
|
init_react_import();
|
7437
|
-
var
|
7364
|
+
var import_react47 = require("react");
|
7438
7365
|
|
7439
7366
|
// lib/load-overrides.ts
|
7440
7367
|
init_react_import();
|
@@ -7473,7 +7400,7 @@ var useLoadedOverrides = ({
|
|
7473
7400
|
overrides,
|
7474
7401
|
plugins
|
7475
7402
|
}) => {
|
7476
|
-
return (0,
|
7403
|
+
return (0, import_react47.useMemo)(() => {
|
7477
7404
|
return loadOverrides({ overrides, plugins });
|
7478
7405
|
}, [plugins, overrides]);
|
7479
7406
|
};
|
@@ -7485,14 +7412,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7485
7412
|
|
7486
7413
|
// lib/use-inject-css.ts
|
7487
7414
|
init_react_import();
|
7488
|
-
var
|
7415
|
+
var import_react48 = require("react");
|
7489
7416
|
var styles = ``;
|
7490
7417
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7491
|
-
const [el, setEl] = (0,
|
7492
|
-
(0,
|
7418
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7419
|
+
(0, import_react48.useEffect)(() => {
|
7493
7420
|
setEl(document.createElement("style"));
|
7494
7421
|
}, []);
|
7495
|
-
(0,
|
7422
|
+
(0, import_react48.useEffect)(() => {
|
7496
7423
|
var _a;
|
7497
7424
|
if (!el || typeof window === "undefined") {
|
7498
7425
|
return;
|
@@ -7512,10 +7439,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7512
7439
|
|
7513
7440
|
// lib/use-preview-mode-hotkeys.ts
|
7514
7441
|
init_react_import();
|
7515
|
-
var
|
7442
|
+
var import_react49 = require("react");
|
7516
7443
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7517
7444
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7518
|
-
const toggleInteractive = (0,
|
7445
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7519
7446
|
dispatch({
|
7520
7447
|
type: "setUi",
|
7521
7448
|
ui: (ui) => ({
|
@@ -7572,7 +7499,7 @@ function Puck({
|
|
7572
7499
|
waitForStyles: true
|
7573
7500
|
}, _iframe);
|
7574
7501
|
useInjectGlobalCss(iframe.enabled);
|
7575
|
-
const [generatedAppState] = (0,
|
7502
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7576
7503
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7577
7504
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7578
7505
|
let clientUiState = {};
|
@@ -7644,14 +7571,14 @@ function Puck({
|
|
7644
7571
|
histories,
|
7645
7572
|
index: initialHistoryIndex
|
7646
7573
|
});
|
7647
|
-
const [reducer] = (0,
|
7574
|
+
const [reducer] = (0, import_react50.useState)(
|
7648
7575
|
() => createReducer({
|
7649
7576
|
config,
|
7650
7577
|
record: historyStore.record,
|
7651
7578
|
onAction
|
7652
7579
|
})
|
7653
7580
|
);
|
7654
|
-
const [appState, dispatch] = (0,
|
7581
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7655
7582
|
reducer,
|
7656
7583
|
flushZones(initialAppState)
|
7657
7584
|
);
|
@@ -7662,14 +7589,14 @@ function Puck({
|
|
7662
7589
|
historyStore,
|
7663
7590
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7664
7591
|
});
|
7665
|
-
const [menuOpen, setMenuOpen] = (0,
|
7592
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7666
7593
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7667
7594
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7668
|
-
(0,
|
7595
|
+
(0, import_react50.useEffect)(() => {
|
7669
7596
|
if (onChange) onChange(data);
|
7670
7597
|
}, [data]);
|
7671
7598
|
const rootProps = data.root.props || data.root;
|
7672
|
-
const toggleSidebars = (0,
|
7599
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7673
7600
|
(sidebar) => {
|
7674
7601
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7675
7602
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7683,7 +7610,7 @@ function Puck({
|
|
7683
7610
|
},
|
7684
7611
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7685
7612
|
);
|
7686
|
-
(0,
|
7613
|
+
(0, import_react50.useEffect)(() => {
|
7687
7614
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7688
7615
|
dispatch({
|
7689
7616
|
type: "setUi",
|
@@ -7706,7 +7633,7 @@ function Puck({
|
|
7706
7633
|
window.removeEventListener("resize", handleResize);
|
7707
7634
|
};
|
7708
7635
|
}, []);
|
7709
|
-
const defaultHeaderRender = (0,
|
7636
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7710
7637
|
if (renderHeader) {
|
7711
7638
|
console.warn(
|
7712
7639
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7720,7 +7647,7 @@ function Puck({
|
|
7720
7647
|
}
|
7721
7648
|
return DefaultOverride;
|
7722
7649
|
}, [renderHeader]);
|
7723
|
-
const defaultHeaderActionsRender = (0,
|
7650
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7724
7651
|
if (renderHeaderActions) {
|
7725
7652
|
console.warn(
|
7726
7653
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7737,20 +7664,20 @@ function Puck({
|
|
7737
7664
|
overrides,
|
7738
7665
|
plugins
|
7739
7666
|
});
|
7740
|
-
const CustomPuck = (0,
|
7667
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7741
7668
|
() => loadedOverrides.puck || DefaultOverride,
|
7742
7669
|
[loadedOverrides]
|
7743
7670
|
);
|
7744
|
-
const CustomHeader = (0,
|
7671
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7745
7672
|
() => loadedOverrides.header || defaultHeaderRender,
|
7746
7673
|
[loadedOverrides]
|
7747
7674
|
);
|
7748
|
-
const CustomHeaderActions = (0,
|
7675
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7749
7676
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7750
7677
|
[loadedOverrides]
|
7751
7678
|
);
|
7752
|
-
const [mounted, setMounted] = (0,
|
7753
|
-
(0,
|
7679
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7680
|
+
(0, import_react50.useEffect)(() => {
|
7754
7681
|
setMounted(true);
|
7755
7682
|
}, []);
|
7756
7683
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|