@measured/puck 0.18.2-canary.b399c21 → 0.18.2-canary.b9ce5b7
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.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1301 -1395
- package/dist/index.mjs +1113 -1207
- package/dist/{resolve-all-data-ppm982Jh.d.mts → resolve-all-data-C-cc7ftj.d.mts} +2 -2
- package/dist/{resolve-all-data-ppm982Jh.d.ts → resolve-all-data-C-cc7ftj.d.ts} +2 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- 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,9 +2509,9 @@ 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
|
-
if (mergedProps.name &&
|
2514
|
+
if (mergedProps.name && e.target.nodeName === "INPUT") {
|
3194
2515
|
e.stopPropagation();
|
3195
2516
|
dispatch({
|
3196
2517
|
type: "setUi",
|
@@ -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), {
|
@@ -3289,29 +2610,364 @@ init_react_import();
|
|
3289
2610
|
init_react_import();
|
3290
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" };
|
3291
2612
|
|
3292
|
-
// components/Drawer/index.tsx
|
3293
|
-
var
|
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
|
2728
|
+
init_react_import();
|
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,9 +3960,9 @@ 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
|
}
|
@@ -4328,8 +3984,8 @@ var getZoneId = (zoneCompound) => {
|
|
4328
3984
|
|
4329
3985
|
// lib/dnd/NestedDroppablePlugin.ts
|
4330
3986
|
init_react_import();
|
4331
|
-
var
|
4332
|
-
var
|
3987
|
+
var import_abstract9 = require("@dnd-kit/abstract");
|
3988
|
+
var import_state = require("@dnd-kit/state");
|
4333
3989
|
|
4334
3990
|
// lib/throttle.ts
|
4335
3991
|
init_react_import();
|
@@ -4545,13 +4201,13 @@ var findDeepestCandidate = (position, manager) => {
|
|
4545
4201
|
area: null
|
4546
4202
|
};
|
4547
4203
|
};
|
4548
|
-
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends
|
4204
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
4549
4205
|
constructor(manager, options) {
|
4550
4206
|
super(manager);
|
4551
4207
|
if (typeof window === "undefined") {
|
4552
4208
|
return;
|
4553
4209
|
}
|
4554
|
-
const cleanupEffect = (0,
|
4210
|
+
const cleanupEffect = (0, import_state.effects)(() => {
|
4555
4211
|
const handleMove = (event) => {
|
4556
4212
|
const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
|
4557
4213
|
const position = new GlobalPosition(target, {
|
@@ -4746,267 +4402,521 @@ function reduceData(data, action, config) {
|
|
4746
4402
|
if (action.type === "insert") {
|
4747
4403
|
return insertAction(data, action, config);
|
4748
4404
|
}
|
4749
|
-
if (action.type === "duplicate") {
|
4750
|
-
const item = getItem(
|
4751
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
4752
|
-
data
|
4753
|
-
);
|
4754
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
4755
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
4756
|
-
id: generateId(item.type)
|
4757
|
-
})
|
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
|
+
});
|
4434
|
+
}
|
4435
|
+
if (action.type === "reorder") {
|
4436
|
+
return reorderAction(data, action);
|
4437
|
+
}
|
4438
|
+
if (action.type === "move") {
|
4439
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
4440
|
+
return data;
|
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" }));
|
4452
|
+
}
|
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
|
+
});
|
4464
|
+
}
|
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
|
+
});
|
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
|
+
});
|
4489
|
+
}
|
4490
|
+
if (action.type === "replace") {
|
4491
|
+
return replaceAction(data, action);
|
4492
|
+
}
|
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
|
4498
|
+
);
|
4499
|
+
if (action.zone === rootDroppableId) {
|
4500
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
4501
|
+
content: remove(data.content, action.index)
|
4502
|
+
});
|
4503
|
+
}
|
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
|
+
})
|
4511
|
+
});
|
4512
|
+
}
|
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
|
+
})
|
4519
|
+
});
|
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
|
4557
|
+
});
|
4558
|
+
}
|
4559
|
+
return ui;
|
4560
|
+
};
|
4561
|
+
|
4562
|
+
// reducer/actions.tsx
|
4563
|
+
init_react_import();
|
4564
|
+
|
4565
|
+
// reducer/index.ts
|
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
|
+
};
|
4582
|
+
}
|
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));
|
4588
|
+
};
|
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);
|
4600
|
+
}
|
4601
|
+
return { data, ui };
|
4602
|
+
},
|
4603
|
+
record,
|
4604
|
+
onAction
|
4605
|
+
);
|
4606
|
+
}
|
4607
|
+
|
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
|
4622
|
+
};
|
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 })
|
4639
|
+
});
|
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
|
+
};
|
4670
|
+
});
|
4671
|
+
}
|
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
|
-
if (action.type === "replace") {
|
4835
|
-
return replaceAction(data, action);
|
4836
|
-
}
|
4837
|
-
if (action.type === "remove") {
|
4838
|
-
const item = getItem({ index: action.index, zone: action.zone }, data);
|
4839
|
-
const dataWithRelatedRemoved = setupZone(
|
4840
|
-
removeRelatedZones(item, data),
|
4841
|
-
action.zone
|
4842
|
-
);
|
4843
|
-
if (action.zone === rootDroppableId) {
|
4844
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
4845
|
-
content: remove(data.content, action.index)
|
4846
|
-
});
|
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
|
+
}
|
4847
4801
|
}
|
4848
|
-
|
4849
|
-
|
4850
|
-
|
4851
|
-
|
4852
|
-
action.index
|
4853
|
-
)
|
4854
|
-
})
|
4855
|
-
});
|
4856
|
-
}
|
4857
|
-
if (action.type === "registerZone") {
|
4858
|
-
if (zoneCache[action.zone]) {
|
4859
|
-
return __spreadProps(__spreadValues({}, data), {
|
4860
|
-
zones: __spreadProps(__spreadValues({}, data.zones), {
|
4861
|
-
[action.zone]: zoneCache[action.zone]
|
4862
|
-
})
|
4863
|
-
});
|
4802
|
+
if (delay) {
|
4803
|
+
if ((0, import_geometry8.exceedsDistance)(delta, delay.tolerance)) {
|
4804
|
+
return this.handleCancel();
|
4805
|
+
}
|
4864
4806
|
}
|
4865
|
-
return setupZone(data, action.zone);
|
4866
4807
|
}
|
4867
|
-
|
4868
|
-
|
4869
|
-
|
4870
|
-
zoneCache[action.zone] = _zones[action.zone];
|
4871
|
-
delete _zones[action.zone];
|
4808
|
+
handlePointerUp(event) {
|
4809
|
+
if (!this.source) {
|
4810
|
+
return;
|
4872
4811
|
}
|
4873
|
-
|
4874
|
-
|
4875
|
-
|
4876
|
-
if (
|
4877
|
-
|
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 });
|
4878
4818
|
}
|
4879
|
-
|
4819
|
+
this.cleanup.forEach((cleanup) => cleanup());
|
4820
|
+
this.cleanup.clear();
|
4880
4821
|
}
|
4881
|
-
|
4882
|
-
|
4883
|
-
|
4884
|
-
|
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);
|
4822
|
+
handleKeyDown(event) {
|
4823
|
+
if (event.key === "Escape") {
|
4824
|
+
event.preventDefault();
|
4825
|
+
this.handleCancel();
|
4890
4826
|
}
|
4891
|
-
return __spreadValues(__spreadValues({}, ui), action.ui(ui));
|
4892
4827
|
}
|
4893
|
-
|
4894
|
-
|
4895
|
-
|
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;
|
4834
|
+
}
|
4835
|
+
if (event.defaultPrevented) {
|
4836
|
+
return;
|
4837
|
+
}
|
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,
|
@@ -5217,13 +5145,6 @@ var DragDropContextClient = ({
|
|
5217
5145
|
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
5218
5146
|
fn(event, manager);
|
5219
5147
|
});
|
5220
|
-
dispatch({
|
5221
|
-
type: "setUi",
|
5222
|
-
ui: {
|
5223
|
-
itemSelector: null,
|
5224
|
-
isDragging: false
|
5225
|
-
}
|
5226
|
-
});
|
5227
5148
|
return;
|
5228
5149
|
}
|
5229
5150
|
if (thisPreview) {
|
@@ -5281,8 +5202,7 @@ var DragDropContextClient = ({
|
|
5281
5202
|
targetZone = targetData.zone;
|
5282
5203
|
targetIndex = targetData.index;
|
5283
5204
|
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
5284
|
-
const
|
5285
|
-
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || dir === "ltr" && (collisionData == null ? void 0 : collisionData.direction) === "left" || dir === "rtl" && (collisionData == null ? void 0 : collisionData.direction) === "right" ? "before" : "after";
|
5205
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
5286
5206
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
5287
5207
|
targetIndex = targetIndex - 1;
|
5288
5208
|
}
|
@@ -5424,7 +5344,7 @@ var DrawerItemInner = ({
|
|
5424
5344
|
dragRef,
|
5425
5345
|
isDragDisabled
|
5426
5346
|
}) => {
|
5427
|
-
const CustomInner = (0,
|
5347
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5428
5348
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5429
5349
|
[children]
|
5430
5350
|
);
|
@@ -5478,7 +5398,7 @@ var DrawerItem = ({
|
|
5478
5398
|
isDragDisabled
|
5479
5399
|
}) => {
|
5480
5400
|
const resolvedId = id || name;
|
5481
|
-
const [dynamicId, setDynamicId] = (0,
|
5401
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5482
5402
|
if (typeof index !== "undefined") {
|
5483
5403
|
console.error(
|
5484
5404
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5517,7 +5437,7 @@ var Drawer = ({
|
|
5517
5437
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5518
5438
|
);
|
5519
5439
|
}
|
5520
|
-
const id = (0,
|
5440
|
+
const id = (0, import_react32.useId)();
|
5521
5441
|
const { ref } = useDroppableSafe({
|
5522
5442
|
id,
|
5523
5443
|
type: "void",
|
@@ -5539,18 +5459,18 @@ Drawer.Item = DrawerItem;
|
|
5539
5459
|
|
5540
5460
|
// components/Puck/index.tsx
|
5541
5461
|
init_react_import();
|
5542
|
-
var
|
5462
|
+
var import_react50 = require("react");
|
5543
5463
|
|
5544
5464
|
// components/SidebarSection/index.tsx
|
5545
5465
|
init_react_import();
|
5546
5466
|
|
5547
5467
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
5548
5468
|
init_react_import();
|
5549
|
-
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" };
|
5550
5470
|
|
5551
5471
|
// lib/use-breadcrumbs.ts
|
5552
5472
|
init_react_import();
|
5553
|
-
var
|
5473
|
+
var import_react33 = require("react");
|
5554
5474
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5555
5475
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5556
5476
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5600,8 +5520,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5600
5520
|
state: { data },
|
5601
5521
|
selectedItem
|
5602
5522
|
} = useAppContext();
|
5603
|
-
const dzContext = (0,
|
5604
|
-
return (0,
|
5523
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5524
|
+
return (0, import_react33.useMemo)(() => {
|
5605
5525
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5606
5526
|
selectedItem,
|
5607
5527
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5725,7 +5645,7 @@ function MenuBar({
|
|
5725
5645
|
|
5726
5646
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5727
5647
|
init_react_import();
|
5728
|
-
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" };
|
5729
5649
|
|
5730
5650
|
// components/Puck/components/Fields/index.tsx
|
5731
5651
|
init_react_import();
|
@@ -5735,15 +5655,15 @@ init_react_import();
|
|
5735
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" };
|
5736
5656
|
|
5737
5657
|
// components/Puck/components/Fields/index.tsx
|
5738
|
-
var
|
5658
|
+
var import_react37 = require("react");
|
5739
5659
|
|
5740
5660
|
// lib/use-resolved-fields.ts
|
5741
5661
|
init_react_import();
|
5742
|
-
var
|
5662
|
+
var import_react36 = require("react");
|
5743
5663
|
|
5744
5664
|
// lib/use-parent.ts
|
5745
5665
|
init_react_import();
|
5746
|
-
var
|
5666
|
+
var import_react34 = require("react");
|
5747
5667
|
var getParent = (itemSelector, pathData, data) => {
|
5748
5668
|
var _a;
|
5749
5669
|
if (!itemSelector) return null;
|
@@ -5755,8 +5675,8 @@ var getParent = (itemSelector, pathData, data) => {
|
|
5755
5675
|
};
|
5756
5676
|
var useGetParent = () => {
|
5757
5677
|
const { state } = useAppContext();
|
5758
|
-
const { pathData } = (0,
|
5759
|
-
return (0,
|
5678
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5679
|
+
return (0, import_react34.useCallback)(
|
5760
5680
|
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5761
5681
|
[state.ui.itemSelector, pathData, state.data]
|
5762
5682
|
);
|
@@ -5767,10 +5687,10 @@ var useParent = () => {
|
|
5767
5687
|
|
5768
5688
|
// lib/use-on-value-change.ts
|
5769
5689
|
init_react_import();
|
5770
|
-
var
|
5690
|
+
var import_react35 = require("react");
|
5771
5691
|
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5772
|
-
const tracked = (0,
|
5773
|
-
(0,
|
5692
|
+
const tracked = (0, import_react35.useRef)(value);
|
5693
|
+
(0, import_react35.useEffect)(() => {
|
5774
5694
|
const oldValue = tracked.current;
|
5775
5695
|
if (!compare(value, oldValue)) {
|
5776
5696
|
tracked.current = value;
|
@@ -5787,37 +5707,31 @@ var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0
|
|
5787
5707
|
var defaultPageFields = {
|
5788
5708
|
title: { type: "text" }
|
5789
5709
|
};
|
5790
|
-
var useResolvedFields = ({
|
5791
|
-
_skipValueCheck,
|
5792
|
-
_skipIdCheck
|
5793
|
-
} = {}) => {
|
5710
|
+
var useResolvedFields = () => {
|
5794
5711
|
var _a, _b;
|
5795
5712
|
const { selectedItem, state, config } = useAppContext();
|
5796
5713
|
const parent = useParent();
|
5797
5714
|
const { data } = state;
|
5798
5715
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5799
5716
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5800
|
-
const defaultFields = (0,
|
5717
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5801
5718
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5802
5719
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5803
5720
|
);
|
5804
5721
|
const rootProps = data.root.props || data.root;
|
5805
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5806
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5807
|
-
|
5808
|
-
|
5809
|
-
});
|
5810
|
-
const [fieldsLoading, setFieldsLoading] = (0, import_react37.useState)(false);
|
5811
|
-
const lastFields = (0, import_react37.useRef)(defaultFields);
|
5722
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5723
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
|
5724
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5725
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5812
5726
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5813
|
-
const componentData = (0,
|
5727
|
+
const componentData = (0, import_react36.useMemo)(
|
5814
5728
|
() => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
|
5815
5729
|
[selectedItem, rootProps, data.root.readOnly]
|
5816
5730
|
);
|
5817
5731
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5818
5732
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5819
5733
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5820
|
-
const resolveFields = (0,
|
5734
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5821
5735
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5822
5736
|
var _a2;
|
5823
5737
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5855,27 +5769,23 @@ var useResolvedFields = ({
|
|
5855
5769
|
}),
|
5856
5770
|
[data, config, componentData, selectedItem, state, parent]
|
5857
5771
|
);
|
5858
|
-
const triggerResolver = (0,
|
5772
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5859
5773
|
var _a2, _b2;
|
5860
5774
|
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5861
5775
|
if (hasResolver) {
|
5862
5776
|
setFieldsLoading(true);
|
5863
5777
|
resolveFields(defaultFields).then((fields) => {
|
5864
|
-
setResolvedFields({
|
5865
|
-
fields: fields || {},
|
5866
|
-
id: selectedItem == null ? void 0 : selectedItem.props.id
|
5867
|
-
});
|
5778
|
+
setResolvedFields(fields || {});
|
5868
5779
|
lastFields.current = fields;
|
5869
5780
|
setFieldsLoading(false);
|
5870
5781
|
});
|
5871
5782
|
return;
|
5872
5783
|
}
|
5873
5784
|
}
|
5874
|
-
setResolvedFields(
|
5785
|
+
setResolvedFields(defaultFields);
|
5875
5786
|
}, [
|
5876
5787
|
defaultFields,
|
5877
5788
|
state.ui.itemSelector,
|
5878
|
-
selectedItem,
|
5879
5789
|
hasResolver,
|
5880
5790
|
parent,
|
5881
5791
|
resolveFields
|
@@ -5890,18 +5800,14 @@ var useResolvedFields = ({
|
|
5890
5800
|
useOnValueChange(
|
5891
5801
|
{ data, parent, itemSelector: state.ui.itemSelector },
|
5892
5802
|
() => {
|
5893
|
-
if (_skipValueCheck) return;
|
5894
5803
|
triggerResolver();
|
5895
5804
|
},
|
5896
5805
|
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5897
5806
|
);
|
5898
|
-
(0,
|
5807
|
+
(0, import_react36.useEffect)(() => {
|
5899
5808
|
triggerResolver();
|
5900
5809
|
}, []);
|
5901
|
-
|
5902
|
-
return [defaultFields, fieldsLoading];
|
5903
|
-
}
|
5904
|
-
return [resolvedFields.fields, fieldsLoading];
|
5810
|
+
return [resolvedFields, fieldsLoading];
|
5905
5811
|
};
|
5906
5812
|
|
5907
5813
|
// components/Puck/components/Fields/index.tsx
|
@@ -5930,7 +5836,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
5930
5836
|
const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
|
5931
5837
|
const isLoading = fieldsResolving || componentResolving;
|
5932
5838
|
const rootProps = data.root.props || data.root;
|
5933
|
-
const Wrapper = (0,
|
5839
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5934
5840
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5935
5841
|
"form",
|
5936
5842
|
{
|
@@ -6051,14 +5957,14 @@ init_react_import();
|
|
6051
5957
|
|
6052
5958
|
// lib/use-component-list.tsx
|
6053
5959
|
init_react_import();
|
6054
|
-
var
|
5960
|
+
var import_react38 = require("react");
|
6055
5961
|
|
6056
5962
|
// components/ComponentList/index.tsx
|
6057
5963
|
init_react_import();
|
6058
5964
|
|
6059
5965
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
6060
5966
|
init_react_import();
|
6061
|
-
var styles_module_default17 = { "ComponentList": "
|
5967
|
+
var styles_module_default17 = { "ComponentList": "_ComponentList_odh9d_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_odh9d_5", "ComponentList-content": "_ComponentList-content_odh9d_9", "ComponentList-title": "_ComponentList-title_odh9d_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_odh9d_53" };
|
6062
5968
|
|
6063
5969
|
// components/ComponentList/index.tsx
|
6064
5970
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
@@ -6118,8 +6024,8 @@ ComponentList.Item = ComponentListItem;
|
|
6118
6024
|
// lib/use-component-list.tsx
|
6119
6025
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6120
6026
|
var useComponentList = (config, ui) => {
|
6121
|
-
const [componentList, setComponentList] = (0,
|
6122
|
-
(0,
|
6027
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
6028
|
+
(0, import_react38.useEffect)(() => {
|
6123
6029
|
var _a, _b, _c;
|
6124
6030
|
if (Object.keys(ui.componentList).length > 0) {
|
6125
6031
|
const matchedComponents = [];
|
@@ -6188,22 +6094,22 @@ var useComponentList = (config, ui) => {
|
|
6188
6094
|
};
|
6189
6095
|
|
6190
6096
|
// components/Puck/components/Components/index.tsx
|
6191
|
-
var
|
6097
|
+
var import_react39 = require("react");
|
6192
6098
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6193
6099
|
var Components = () => {
|
6194
6100
|
const { config, state, overrides } = useAppContext();
|
6195
6101
|
const componentList = useComponentList(config, state.ui);
|
6196
|
-
const Wrapper = (0,
|
6102
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6197
6103
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6198
6104
|
};
|
6199
6105
|
|
6200
6106
|
// components/Puck/components/Preview/index.tsx
|
6201
6107
|
init_react_import();
|
6202
|
-
var
|
6108
|
+
var import_react41 = require("react");
|
6203
6109
|
|
6204
6110
|
// components/AutoFrame/index.tsx
|
6205
6111
|
init_react_import();
|
6206
|
-
var
|
6112
|
+
var import_react40 = require("react");
|
6207
6113
|
var import_object_hash = __toESM(require("object-hash"));
|
6208
6114
|
var import_react_dom3 = require("react-dom");
|
6209
6115
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6249,7 +6155,7 @@ var CopyHostStyles = ({
|
|
6249
6155
|
onStylesLoaded = () => null
|
6250
6156
|
}) => {
|
6251
6157
|
const { document: doc, window: win } = useFrame();
|
6252
|
-
(0,
|
6158
|
+
(0, import_react40.useEffect)(() => {
|
6253
6159
|
if (!win || !doc) {
|
6254
6160
|
return () => {
|
6255
6161
|
};
|
@@ -6408,8 +6314,8 @@ var CopyHostStyles = ({
|
|
6408
6314
|
}, []);
|
6409
6315
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6410
6316
|
};
|
6411
|
-
var autoFrameContext = (0,
|
6412
|
-
var useFrame = () => (0,
|
6317
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6318
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6413
6319
|
function AutoFrame(_a) {
|
6414
6320
|
var _b = _a, {
|
6415
6321
|
children,
|
@@ -6426,10 +6332,10 @@ function AutoFrame(_a) {
|
|
6426
6332
|
"onStylesLoaded",
|
6427
6333
|
"frameRef"
|
6428
6334
|
]);
|
6429
|
-
const [loaded, setLoaded] = (0,
|
6430
|
-
const [ctx, setCtx] = (0,
|
6431
|
-
const [mountTarget, setMountTarget] = (0,
|
6432
|
-
(0,
|
6335
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6336
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6337
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6338
|
+
(0, import_react40.useEffect)(() => {
|
6433
6339
|
var _a2;
|
6434
6340
|
if (frameRef.current) {
|
6435
6341
|
setCtx({
|
@@ -6524,7 +6430,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6524
6430
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6525
6431
|
var useBubbleIframeEvents = (ref) => {
|
6526
6432
|
const { status } = useAppContext();
|
6527
|
-
(0,
|
6433
|
+
(0, import_react41.useEffect)(() => {
|
6528
6434
|
var _a;
|
6529
6435
|
if (ref.current && status === "READY") {
|
6530
6436
|
const iframe = ref.current;
|
@@ -6557,7 +6463,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6557
6463
|
};
|
6558
6464
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6559
6465
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6560
|
-
const Page = (0,
|
6466
|
+
const Page = (0, import_react41.useCallback)(
|
6561
6467
|
(pageProps) => {
|
6562
6468
|
var _a, _b;
|
6563
6469
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6566,9 +6472,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6566
6472
|
},
|
6567
6473
|
[config.root]
|
6568
6474
|
);
|
6569
|
-
const Frame = (0,
|
6475
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6570
6476
|
const rootProps = state.data.root.props || state.data.root;
|
6571
|
-
const ref = (0,
|
6477
|
+
const ref = (0, import_react41.useRef)(null);
|
6572
6478
|
useBubbleIframeEvents(ref);
|
6573
6479
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6574
6480
|
Page,
|
@@ -6651,7 +6557,7 @@ init_react_import();
|
|
6651
6557
|
|
6652
6558
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
6653
6559
|
init_react_import();
|
6654
|
-
var styles_module_default19 = { "LayerTree": "
|
6560
|
+
var styles_module_default19 = { "LayerTree": "_LayerTree_1pgw8_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_1pgw8_11", "LayerTree-helper": "_LayerTree-helper_1pgw8_17", "Layer": "_Layer_1pgw8_1", "Layer-inner": "_Layer-inner_1pgw8_29", "Layer--containsZone": "_Layer--containsZone_1pgw8_35", "Layer-clickable": "_Layer-clickable_1pgw8_39", "Layer--isSelected": "_Layer--isSelected_1pgw8_61", "Layer-chevron": "_Layer-chevron_1pgw8_77", "Layer--childIsSelected": "_Layer--childIsSelected_1pgw8_78", "Layer-zones": "_Layer-zones_1pgw8_82", "Layer-title": "_Layer-title_1pgw8_96", "Layer-name": "_Layer-name_1pgw8_105", "Layer-icon": "_Layer-icon_1pgw8_111", "Layer-zoneIcon": "_Layer-zoneIcon_1pgw8_116" };
|
6655
6561
|
|
6656
6562
|
// lib/scroll-into-view.ts
|
6657
6563
|
init_react_import();
|
@@ -6665,7 +6571,7 @@ var scrollIntoView = (el) => {
|
|
6665
6571
|
};
|
6666
6572
|
|
6667
6573
|
// components/LayerTree/index.tsx
|
6668
|
-
var
|
6574
|
+
var import_react42 = require("react");
|
6669
6575
|
|
6670
6576
|
// lib/is-child-of-zone.ts
|
6671
6577
|
init_react_import();
|
@@ -6711,7 +6617,7 @@ var LayerTree = ({
|
|
6711
6617
|
label
|
6712
6618
|
}) => {
|
6713
6619
|
const zones = data.zones || {};
|
6714
|
-
const ctx = (0,
|
6620
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6715
6621
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6716
6622
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6717
6623
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6818,13 +6724,13 @@ var LayerTree = ({
|
|
6818
6724
|
};
|
6819
6725
|
|
6820
6726
|
// components/Puck/components/Outline/index.tsx
|
6821
|
-
var
|
6727
|
+
var import_react43 = require("react");
|
6822
6728
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6823
6729
|
var Outline = () => {
|
6824
6730
|
const { dispatch, state, overrides, config } = useAppContext();
|
6825
6731
|
const { data, ui } = state;
|
6826
6732
|
const { itemSelector } = ui;
|
6827
|
-
const setItemSelector = (0,
|
6733
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6828
6734
|
(newItemSelector) => {
|
6829
6735
|
dispatch({
|
6830
6736
|
type: "setUi",
|
@@ -6833,7 +6739,7 @@ var Outline = () => {
|
|
6833
6739
|
},
|
6834
6740
|
[]
|
6835
6741
|
);
|
6836
|
-
const Wrapper = (0,
|
6742
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6837
6743
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
6838
6744
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6839
6745
|
LayerTree,
|
@@ -6947,19 +6853,19 @@ function usePuckHistory({
|
|
6947
6853
|
|
6948
6854
|
// lib/use-history-store.ts
|
6949
6855
|
init_react_import();
|
6950
|
-
var
|
6856
|
+
var import_react44 = require("react");
|
6951
6857
|
var import_use_debounce3 = require("use-debounce");
|
6952
6858
|
var EMPTY_HISTORY_INDEX = 0;
|
6953
6859
|
function useHistoryStore(initialHistory) {
|
6954
6860
|
var _a, _b;
|
6955
|
-
const [histories, setHistories] = (0,
|
6861
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6956
6862
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6957
6863
|
);
|
6958
6864
|
const updateHistories = (histories2) => {
|
6959
6865
|
setHistories(histories2);
|
6960
6866
|
setIndex(histories2.length - 1);
|
6961
6867
|
};
|
6962
|
-
const [index, setIndex] = (0,
|
6868
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6963
6869
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6964
6870
|
);
|
6965
6871
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -7119,15 +7025,15 @@ var getBox = function getBox2(el) {
|
|
7119
7025
|
};
|
7120
7026
|
|
7121
7027
|
// components/Puck/components/Canvas/index.tsx
|
7122
|
-
var
|
7028
|
+
var import_react46 = require("react");
|
7123
7029
|
|
7124
7030
|
// components/ViewportControls/index.tsx
|
7125
7031
|
init_react_import();
|
7126
|
-
var
|
7032
|
+
var import_react45 = require("react");
|
7127
7033
|
|
7128
7034
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7129
7035
|
init_react_import();
|
7130
|
-
var styles_module_default20 = { "ViewportControls": "
|
7036
|
+
var styles_module_default20 = { "ViewportControls": "_ViewportControls_g1wgg_1", "ViewportControls-divider": "_ViewportControls-divider_g1wgg_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_g1wgg_21", "ViewportButton--isActive": "_ViewportButton--isActive_g1wgg_34", "ViewportButton-inner": "_ViewportButton-inner_g1wgg_34" };
|
7131
7037
|
|
7132
7038
|
// components/ViewportControls/index.tsx
|
7133
7039
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
@@ -7146,8 +7052,8 @@ var ViewportButton = ({
|
|
7146
7052
|
onClick
|
7147
7053
|
}) => {
|
7148
7054
|
const { state } = useAppContext();
|
7149
|
-
const [isActive, setIsActive] = (0,
|
7150
|
-
(0,
|
7055
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7056
|
+
(0, import_react45.useEffect)(() => {
|
7151
7057
|
setIsActive(width === state.ui.viewports.current.width);
|
7152
7058
|
}, [width, state.ui.viewports.current.width]);
|
7153
7059
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -7183,7 +7089,7 @@ var ViewportControls = ({
|
|
7183
7089
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7184
7090
|
(option) => option.value === autoZoom
|
7185
7091
|
);
|
7186
|
-
const zoomOptions = (0,
|
7092
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
7187
7093
|
() => [
|
7188
7094
|
...defaultZoomOptions,
|
7189
7095
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7306,17 +7212,17 @@ var Canvas = () => {
|
|
7306
7212
|
const { status, iframe } = useAppContext();
|
7307
7213
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7308
7214
|
const { ui } = state;
|
7309
|
-
const frameRef = (0,
|
7310
|
-
const [showTransition, setShowTransition] = (0,
|
7311
|
-
const defaultRender = (0,
|
7215
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7216
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7217
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7312
7218
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7313
7219
|
return PuckDefault;
|
7314
7220
|
}, []);
|
7315
|
-
const CustomPreview = (0,
|
7221
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7316
7222
|
() => overrides.preview || defaultRender,
|
7317
7223
|
[overrides]
|
7318
7224
|
);
|
7319
|
-
const getFrameDimensions = (0,
|
7225
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7320
7226
|
if (frameRef.current) {
|
7321
7227
|
const frame = frameRef.current;
|
7322
7228
|
const box = getBox(frame);
|
@@ -7324,7 +7230,7 @@ var Canvas = () => {
|
|
7324
7230
|
}
|
7325
7231
|
return { width: 0, height: 0 };
|
7326
7232
|
}, [frameRef]);
|
7327
|
-
const resetAutoZoom = (0,
|
7233
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7328
7234
|
(ui2 = state.ui) => {
|
7329
7235
|
if (frameRef.current) {
|
7330
7236
|
setZoomConfig(
|
@@ -7334,11 +7240,11 @@ var Canvas = () => {
|
|
7334
7240
|
},
|
7335
7241
|
[frameRef, zoomConfig, state.ui]
|
7336
7242
|
);
|
7337
|
-
(0,
|
7243
|
+
(0, import_react46.useEffect)(() => {
|
7338
7244
|
setShowTransition(false);
|
7339
7245
|
resetAutoZoom();
|
7340
7246
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7341
|
-
(0,
|
7247
|
+
(0, import_react46.useEffect)(() => {
|
7342
7248
|
const { height: frameHeight } = getFrameDimensions();
|
7343
7249
|
if (ui.viewports.current.height === "auto") {
|
7344
7250
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7346,13 +7252,13 @@ var Canvas = () => {
|
|
7346
7252
|
}));
|
7347
7253
|
}
|
7348
7254
|
}, [zoomConfig.zoom]);
|
7349
|
-
(0,
|
7255
|
+
(0, import_react46.useEffect)(() => {
|
7350
7256
|
if (ZOOM_ON_CHANGE) {
|
7351
7257
|
setShowTransition(true);
|
7352
7258
|
resetAutoZoom(ui);
|
7353
7259
|
}
|
7354
7260
|
}, [ui.viewports.current.width]);
|
7355
|
-
(0,
|
7261
|
+
(0, import_react46.useEffect)(() => {
|
7356
7262
|
const cb = () => {
|
7357
7263
|
setShowTransition(false);
|
7358
7264
|
resetAutoZoom();
|
@@ -7362,8 +7268,8 @@ var Canvas = () => {
|
|
7362
7268
|
window.removeEventListener("resize", cb);
|
7363
7269
|
};
|
7364
7270
|
}, []);
|
7365
|
-
const [showLoader, setShowLoader] = (0,
|
7366
|
-
(0,
|
7271
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7272
|
+
(0, import_react46.useEffect)(() => {
|
7367
7273
|
setTimeout(() => {
|
7368
7274
|
setShowLoader(true);
|
7369
7275
|
}, 500);
|
@@ -7441,7 +7347,7 @@ var Canvas = () => {
|
|
7441
7347
|
|
7442
7348
|
// lib/use-loaded-overrides.ts
|
7443
7349
|
init_react_import();
|
7444
|
-
var
|
7350
|
+
var import_react47 = require("react");
|
7445
7351
|
|
7446
7352
|
// lib/load-overrides.ts
|
7447
7353
|
init_react_import();
|
@@ -7480,7 +7386,7 @@ var useLoadedOverrides = ({
|
|
7480
7386
|
overrides,
|
7481
7387
|
plugins
|
7482
7388
|
}) => {
|
7483
|
-
return (0,
|
7389
|
+
return (0, import_react47.useMemo)(() => {
|
7484
7390
|
return loadOverrides({ overrides, plugins });
|
7485
7391
|
}, [plugins, overrides]);
|
7486
7392
|
};
|
@@ -7492,14 +7398,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7492
7398
|
|
7493
7399
|
// lib/use-inject-css.ts
|
7494
7400
|
init_react_import();
|
7495
|
-
var
|
7401
|
+
var import_react48 = require("react");
|
7496
7402
|
var styles = ``;
|
7497
7403
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7498
|
-
const [el, setEl] = (0,
|
7499
|
-
(0,
|
7404
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7405
|
+
(0, import_react48.useEffect)(() => {
|
7500
7406
|
setEl(document.createElement("style"));
|
7501
7407
|
}, []);
|
7502
|
-
(0,
|
7408
|
+
(0, import_react48.useEffect)(() => {
|
7503
7409
|
var _a;
|
7504
7410
|
if (!el || typeof window === "undefined") {
|
7505
7411
|
return;
|
@@ -7519,10 +7425,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7519
7425
|
|
7520
7426
|
// lib/use-preview-mode-hotkeys.ts
|
7521
7427
|
init_react_import();
|
7522
|
-
var
|
7428
|
+
var import_react49 = require("react");
|
7523
7429
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7524
7430
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7525
|
-
const toggleInteractive = (0,
|
7431
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7526
7432
|
dispatch({
|
7527
7433
|
type: "setUi",
|
7528
7434
|
ui: (ui) => ({
|
@@ -7579,7 +7485,7 @@ function Puck({
|
|
7579
7485
|
waitForStyles: true
|
7580
7486
|
}, _iframe);
|
7581
7487
|
useInjectGlobalCss(iframe.enabled);
|
7582
|
-
const [generatedAppState] = (0,
|
7488
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7583
7489
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7584
7490
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7585
7491
|
let clientUiState = {};
|
@@ -7651,14 +7557,14 @@ function Puck({
|
|
7651
7557
|
histories,
|
7652
7558
|
index: initialHistoryIndex
|
7653
7559
|
});
|
7654
|
-
const [reducer] = (0,
|
7560
|
+
const [reducer] = (0, import_react50.useState)(
|
7655
7561
|
() => createReducer({
|
7656
7562
|
config,
|
7657
7563
|
record: historyStore.record,
|
7658
7564
|
onAction
|
7659
7565
|
})
|
7660
7566
|
);
|
7661
|
-
const [appState, dispatch] = (0,
|
7567
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7662
7568
|
reducer,
|
7663
7569
|
flushZones(initialAppState)
|
7664
7570
|
);
|
@@ -7669,14 +7575,14 @@ function Puck({
|
|
7669
7575
|
historyStore,
|
7670
7576
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7671
7577
|
});
|
7672
|
-
const [menuOpen, setMenuOpen] = (0,
|
7578
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7673
7579
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7674
7580
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7675
|
-
(0,
|
7581
|
+
(0, import_react50.useEffect)(() => {
|
7676
7582
|
if (onChange) onChange(data);
|
7677
7583
|
}, [data]);
|
7678
7584
|
const rootProps = data.root.props || data.root;
|
7679
|
-
const toggleSidebars = (0,
|
7585
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7680
7586
|
(sidebar) => {
|
7681
7587
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7682
7588
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7690,7 +7596,7 @@ function Puck({
|
|
7690
7596
|
},
|
7691
7597
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7692
7598
|
);
|
7693
|
-
(0,
|
7599
|
+
(0, import_react50.useEffect)(() => {
|
7694
7600
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7695
7601
|
dispatch({
|
7696
7602
|
type: "setUi",
|
@@ -7713,7 +7619,7 @@ function Puck({
|
|
7713
7619
|
window.removeEventListener("resize", handleResize);
|
7714
7620
|
};
|
7715
7621
|
}, []);
|
7716
|
-
const defaultHeaderRender = (0,
|
7622
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7717
7623
|
if (renderHeader) {
|
7718
7624
|
console.warn(
|
7719
7625
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7727,7 +7633,7 @@ function Puck({
|
|
7727
7633
|
}
|
7728
7634
|
return DefaultOverride;
|
7729
7635
|
}, [renderHeader]);
|
7730
|
-
const defaultHeaderActionsRender = (0,
|
7636
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7731
7637
|
if (renderHeaderActions) {
|
7732
7638
|
console.warn(
|
7733
7639
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7744,20 +7650,20 @@ function Puck({
|
|
7744
7650
|
overrides,
|
7745
7651
|
plugins
|
7746
7652
|
});
|
7747
|
-
const CustomPuck = (0,
|
7653
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7748
7654
|
() => loadedOverrides.puck || DefaultOverride,
|
7749
7655
|
[loadedOverrides]
|
7750
7656
|
);
|
7751
|
-
const CustomHeader = (0,
|
7657
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7752
7658
|
() => loadedOverrides.header || defaultHeaderRender,
|
7753
7659
|
[loadedOverrides]
|
7754
7660
|
);
|
7755
|
-
const CustomHeaderActions = (0,
|
7661
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7756
7662
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7757
7663
|
[loadedOverrides]
|
7758
7664
|
);
|
7759
|
-
const [mounted, setMounted] = (0,
|
7760
|
-
(0,
|
7665
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7666
|
+
(0, import_react50.useEffect)(() => {
|
7761
7667
|
setMounted(true);
|
7762
7668
|
}, []);
|
7763
7669
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|